summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--raytracer.hs11
1 files 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