- data PacketColor = PacketColor !Color !Color !Color !Color
- debug_norm_shade :: Rayint -> Ray -> Scene -> Int -> Int -> Color
- flat_shade :: Rayint -> Ray -> Scene -> Int -> Int -> Color
- shade :: Rayint -> Ray -> Scene -> Int -> Int -> Color
- trace :: Scene -> Ray -> Flt -> Int -> Color
- trace_depth :: Scene -> Ray -> Flt -> Int -> (Color, Flt)
- trace_pos :: Scene -> Ray -> Flt -> Int -> (Color, Vec)
- trace_debug :: Scene -> Ray -> Flt -> Int -> Color
- trace_packet :: Scene -> Ray -> Ray -> Ray -> Ray -> Flt -> Int -> PacketColor
Documentation
data PacketColor Source
Result of tracing a packet of 4 rays at once.
PacketColor !Color !Color !Color !Color |
:: Rayint | ray intersection returned by rayint |
-> Ray | ray that resuted in the ray intersection |
-> Scene | scene we're rendering |
-> Int | recursion limit |
-> Int | debugging value (usualy not used) |
-> Color | computed color |
This is the lighting routine that handles diffuse light, shadows, specular highlights and reflection. Given a ray intersection, the ray, a scene, and a recursion limit, return a color. Debug is a parameter useful for debugging; sometimes we might want to tint the color by the number of bounding boxes tested or something similar. Todo: refraction
trace :: Scene -> Ray -> Flt -> Int -> ColorSource
Given a scene, a ray, a maximum distance, and a maximum recursion depth, test the ray for intersection against the object within the scene, then pass the ray intersection to the shade routine (which may trace secondary rays of its own), which returns a color. For most applications, this is the entry point into the ray tracer.
trace_depth :: Scene -> Ray -> Flt -> Int -> (Color, Flt)Source
Similar to trace, but return depth as well as color. We might want the depth for post-processing effects.
trace_pos :: Scene -> Ray -> Flt -> Int -> (Color, Vec)Source
Similar to trace, but return hit position as well as color.
trace_debug :: Scene -> Ray -> Flt -> Int -> ColorSource
A trace function which returns some additional debugging info, mainly for performance tuning.
trace_packet :: Scene -> Ray -> Ray -> Ray -> Ray -> Flt -> Int -> PacketColorSource
Trace a packet of four rays at a time. Sometimes, this may be a performance advantage. However, ever since my transition to typeclasses, this has not performed any better than the mono-ray path.