From df11c1aed0d6191c02cbc4ec5d2259ca42996b4d Mon Sep 17 00:00:00 2001 From: Stefan Dresselhaus Date: Fri, 24 Oct 2014 22:55:28 +0200 Subject: [PATCH] edwardk on #haskell-game pointed out the Num-Instance of V3 ... doh! --- src/Scene/Renderer.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Scene/Renderer.hs b/src/Scene/Renderer.hs index 5c84e5e..29d0d25 100644 --- a/src/Scene/Renderer.hs +++ b/src/Scene/Renderer.hs @@ -34,7 +34,7 @@ render w h s index = PixelRGB8 (ci cr) (ci cg) (ci cb) Nothing -> bgColor $ sceneBackground s Just c@(Collision pos _ _ obj) -> -- ambient lighting - ((*) <$> (ambColor . ambientLight $ s) <*> (materialAmbience . getMaterial $ obj)) + ((ambColor . ambientLight $ s) * (materialAmbience . getMaterial $ obj)) -- + diffuse lighting ^+^ (foldl1 (^+^) $ (diffuse c s) <$> sceneLights s) -- + reflections - TODO @@ -56,8 +56,7 @@ diffuse (Collision pos n _ obj) s (Light lpos color int) = else ill where - -- angle of light * (color * material) - ill = (*) (dot n $ normalize lightdir) <$> ((*) <$> color ^* i <*> materialDiffuse mat) + ill = i * dot n (normalize lightdir) *^ color * materialDiffuse mat mat = getMaterial obj blocked = raytrace (Ray pos lightdir) s lightdir = (lpos ^-^ pos)