hi,
I'm trying to simulate lighting effect on my 2D scene. so for example i have a objects drawn in a flat plane, and then i want to give a lighting effect on the scene by highlighting a specific area. so if the light source position is at (0, 0), every pixel at distance less than radius (let say 4) has a brighter color.
Let say I draw the plane and objects with rgb (0.1, 0.1, 0.1). If its highlighted (based on the position and light radius) I want to update the color to (0.2, 0.2, 0.2). Is it possible to do that in openGL? How can I get the value of the current pixel on the fragment without using 2 buffers?
thanks in advance.
GLSL: adding color from previous drawing
That requires RTT = render to texture
You render your scene to a texture. On the second step, you render to your back buffer and you sample that texture from your fragment shader.
However, I would just re-render the scene with the light. It is likely to perform much better than hacking around with RTT.
You render your scene to a texture. On the second step, you render to your back buffer and you sample that texture from your fragment shader.
However, I would just re-render the scene with the light. It is likely to perform much better than hacking around with RTT.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement