edwardk on #haskell-game pointed out the Num-Instance of V3 ... doh!

This commit is contained in:
Nicole Dresselhaus 2014-10-24 22:55:28 +02:00
parent 55778d2fc9
commit df11c1aed0

View File

@ -34,7 +34,7 @@ render w h s index = PixelRGB8 (ci cr) (ci cg) (ci cb)
Nothing -> bgColor $ sceneBackground s Nothing -> bgColor $ sceneBackground s
Just c@(Collision pos _ _ obj) -> Just c@(Collision pos _ _ obj) ->
-- ambient lighting -- ambient lighting
((*) <$> (ambColor . ambientLight $ s) <*> (materialAmbience . getMaterial $ obj)) ((ambColor . ambientLight $ s) * (materialAmbience . getMaterial $ obj))
-- + diffuse lighting -- + diffuse lighting
^+^ (foldl1 (^+^) $ (diffuse c s) <$> sceneLights s) ^+^ (foldl1 (^+^) $ (diffuse c s) <$> sceneLights s)
-- + reflections - TODO -- + reflections - TODO
@ -56,8 +56,7 @@ diffuse (Collision pos n _ obj) s (Light lpos color int) =
else else
ill ill
where where
-- angle of light * (color * material) ill = i * dot n (normalize lightdir) *^ color * materialDiffuse mat
ill = (*) (dot n $ normalize lightdir) <$> ((*) <$> color ^* i <*> materialDiffuse mat)
mat = getMaterial obj mat = getMaterial obj
blocked = raytrace (Ray pos lightdir) s blocked = raytrace (Ray pos lightdir) s
lightdir = (lpos ^-^ pos) lightdir = (lpos ^-^ pos)