From dc2de954b63d9ff4eac201e7be7e7be2520d1304 Mon Sep 17 00:00:00 2001 From: Matthias Braendli Date: Tue, 3 Dec 2013 09:01:40 +0100 Subject: correct skycolor --- raytracer.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/raytracer.hs b/raytracer.hs index fe873e0..3b6a8fa 100644 --- a/raytracer.hs +++ b/raytracer.hs @@ -32,7 +32,7 @@ filename num = "foo/foo" ++ show num ++ ".ppm" --spherepos = take 1 [0,20..] --spherepos = take 10 [0,36..] -spherepos = [36] +spherepos = [72] spheres num = [ trace ("Sphere at " ++ show (round (80 * sin(num * degrees))) ++ "," ++ @@ -58,7 +58,7 @@ floorscale = 4 w = 600 * 2 h = 330 * 2 -oversampling = 2 -- each pixel is oversampling^2 rays +oversampling = 4 -- each pixel is oversampling^2 rays black :: Color black = (0,0,0) @@ -153,9 +153,10 @@ intersect_floor source (alpha, beta) -- blue is beautiful, but a green tint is nice too skycolor :: Coord -> ScreenCoord -> Color -skycolor source (alpha, beta) = (60, - round ((sqrt (alpha/6)) / (sqrt (90 * degrees)) * 128), - round ((sqrt (-beta+90*degrees)) / (sqrt (90 * degrees)) * 255) ) +skycolor source (alpha, beta) = (r,g,b) + where r = 60 + g = max 0 $ round $ (sqrt (alpha/6)) / (sqrt (90 * degrees)) * 128 + b = max 0 $ round $ (sqrt (-beta+90*degrees)) / (sqrt (90 * degrees)) * 255 data SphereIntersect = SphereIntersect Double Color deriving (Eq, Show) -- distance color instance Ord SphereIntersect where -- cgit v1.2.3