diff --git a/src/Main.hs b/src/Main.hs index 051303f..a69d0d3 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -81,7 +81,7 @@ main = do let (w,h) = (width . sceneCamera $ s, height . sceneCamera $ s) imdata = map (render w h s) [0..w*h-1] imvec = fromList imdata - im = generateImage (\x y -> imvec ! (x*w+y)) w h + im = generateImage (\x y -> imvec ! (x*w+(h-y-1))) w h print s print (w,h) writePng "out.png" im diff --git a/src/Scene/Renderer.hs b/src/Scene/Renderer.hs index 66a6231..0ad300d 100644 --- a/src/Scene/Renderer.hs +++ b/src/Scene/Renderer.hs @@ -34,11 +34,13 @@ render w h s index = case pcolls of (Background (V3 br bg bb)) = sceneBackground s pcolls = map fromJust $ filter isJust $ (intersect ray) <$> (sceneObjects s) (Collision pos _ coll) = foldl1 min pcolls - ray = camRay x y (sceneCamera s) --Ray (eye cam) $ rotCam x y w h (center cam ^-^ eye cam) (up cam) (fovy cam) - cam = sceneCamera s + ray = camRay x y (sceneCamera s) y = fromIntegral $ index `mod` w x = fromIntegral $ index `div` w ci = floor . (*255) + --wrong format: + --Ray (eye cam) $ rotCam x y w h (center cam ^-^ eye cam) (up cam) (fovy cam) + --cam = sceneCamera s camRay :: Float -> Float -> Camera -> Ray camRay x y c = Ray (eye c) (lowerLeft c ^+^ x *^ xDir c ^+^ y *^ yDir c ^-^ eye c)