Advertisement Jump to content
Sign in to follow this  

OpenGL GLSL: adding color from previous drawing

This topic is 2531 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!