Fast pixelshader 2D raytracing
Posted
by
heishe
on Game Development
See other posts from Game Development
or by heishe
Published on 2012-04-04T17:15:34Z
Indexed on
2012/04/04
17:42 UTC
Read the original article
Hit count: 325
I'd like to do a simple 2D shadow calculation algorithm by rendering my environment into a texture, and then use raytracing to determine what pixels of the texture are not visible to the point light (simply handed to the shader as a vec2 position) .
A simple brute force algorithm per pixel would looks like this:
line_segment = line segment between current pixel of texture and light source
For each pixel in the texture:
{
if pixel is not just empty space && pixel is on line_segment
output = black
else
output = normal color of the pixel
}
This is, of course, probably not the fastest way to do it. Question is: What are faster ways to do it or what are some optimizations that can be applied to this technique?
© Game Development or respective owner