From 8502861b17bba5b375b2fe1466306bb4a3c903e9 Mon Sep 17 00:00:00 2001 From: Stefan Dresselhaus Date: Thu, 4 Dec 2014 00:43:39 +0100 Subject: [PATCH] phong-lighting still wrong. noise is gone. --- src/Scene/Renderer.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Scene/Renderer.hs b/src/Scene/Renderer.hs index 642c83a..af69bd2 100644 --- a/src/Scene/Renderer.hs +++ b/src/Scene/Renderer.hs @@ -204,9 +204,10 @@ intersect r@(Ray ro rd) m@(M (Mesh s _ v f vn fn b)) = case catMaybes . elems $ det2v = det2m !* (pos - (verts IM.! w1)) det2 = det2v ^. _x >= 0 && det2v ^. _y >= 0 && det2v ^. _x + det2v ^. _y <= 1 - vns = (sqrt (sqr ( det2v ^. _x) + sqr ( det2v ^. _y))) *^ (vnorm IM.! w1) - + (sqrt (sqr (1 - det2v ^. _x) + sqr ( det2v ^. _y))) *^ (vnorm IM.! w2) - + (sqrt (sqr ( det2v ^. _x) + sqr (1 - det2v ^. _y))) *^ (vnorm IM.! w3) + vns = normalize $ + (0.5 - sqrt ((sqr (det2v ^. _x) + sqr (det2v ^. _y))/2)) *^ (vnorm IM.! w1) + + ((det2v ^. _y)/2) *^ (vnorm IM.! w2) + + ((det2v ^. _x)/2) *^ (vnorm IM.! w3) sqr = \x -> x * x