2. A hidden-surface determination algorithm is a solution to the
visibility problem, which was one of the first major problems in
the field of 3D computer graphics. sometimes its called hiding and
a hider.
There are dozens of hidden surface algorithms.
We look at prominent ones:
Ray casting
Hidden Surface Algorithms
3. Ray casting is the most basic of many computer graphics
rendering algorithms that use the geometric algorithm of ray
tracing.
It is capable of creating a three-dimensional perspective in a two-
dimensional map. Also considered one of the most basic graphics-
rendering algorithms. Ray casting makes use the same geometric
algorithm as ray tracing.
Ray Casting Algorithm
4. For each pixel center 𝑃𝑖𝑗
• Send ray from eye point (COP), C, through 𝑃𝑖𝑗 into scene. Š
• Intersect ray with each object.Š
• Select nearest intersection.
Ray Casting Idea
5. Pros:
It provides a realistic simulation of lighting.
Effects such as reflections and shadows
Cons:
Much more expensive than local reflection
Still empirical
Only handles specular inter-object reflection
Entire calculation is view-dependent
Ray Casting Pros & Cons
6. Cast ray from viewpoint through each pixel to find front-most
surface
Based geometric optics method that trace rays of light
Ray Casting Method (1/2)
7. Light-ray paths backward from the pixels through the scene
More effective detection method
- Curved surface, particularly spheres
a variation on the depth buffer method
Conceptually simple, but not generally used
Ray Casting Method (2/2)
8. Given a point and a polygon, check if the point is inside or outside
the polygon using the ray-casting algorithm.
A pseudo code can be simply:
count ← 0
foreach side in polygon:
if ray_intersects_segment(P,side) then
count ← count + 1
if is_odd(count) then
return inside
else
return outside
Ray Casting algorithm procedure
9. • Might parameterize each ray:
r 𝑡 = 𝐶 + 𝑡(𝑃𝑖𝑗 − 𝐶)
where t > 0.
• Each object 𝑂 𝑘 returns 𝑡 𝑘 > 0 such that first
intersection with 𝑂 𝑘 occurs at r(𝑡 𝑘).
Implementation
10. Easy to implement
Easy to implement in hardware
Incremental drawing calculations
Pre-processing required
If objects move, does it take more work than normal to draw
the frame.
If the viewer moves, does it take more work than normal to
draw the frame
Typically polygon based
Efficient shading
Handles transparency
Ray casting: Analysis