Jump to content

  • Log In with Google      Sign In   
  • Create Account


GLSL: adding color from previous drawing


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 svnstrk   Members   -  Reputation: 133

Like
0Likes
Like

Posted 15 February 2012 - 06:39 AM

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.

Sponsor:

#2 V-man   Members   -  Reputation: 797

Like
0Likes
Like

Posted 15 February 2012 - 08:29 AM

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.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS