• Advertisement
Sign in to follow this  

gl_FragColor

This topic is 4040 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

hi, Can i color a pixel (x,y) in the fragment shader when the shader is called for another fragment. e.g: GPU shader was initilized for pixel (a,b). can i set color of multiple fragements in the shader program. Lets say i want to color (a,b), (a+1,b+1), (c,d) all in the same program? thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
No. There is no scatter in fragment programs. The program is called for(a,b) and can *only* produce output for (a,b).

Share this post


Link to post
Share on other sites
I have a related question, and since it seems the OP's question has been answered, I'll just ask it here (if not, I'll remove my post).

Is it possible to access the destination alpha value within a pixel shader? If so, is it possible to change the source alpha value of the incoming fragment, so that the new modified value would be used for blending?

eg. If my blending function is glBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA),

can I set the incoming fragment alpha value to the product of itself and the destination alpha value,

to effectively create a glBlend(GL_SRC_ALPHA_TIMES_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA_TIMES_DST_ALPHA) blending function?

Or is the fragment program only able to work on the *incoming* pixel, and has no access to the previous pixel in the same position on the screen.

Share this post


Link to post
Share on other sites
Quote:
Original post by shurcool
...
Or is the fragment program only able to work on the *incoming* pixel, and has no access to the previous pixel in the same position on the screen.
That's it. You can, however, render the scene behind the object you want to blend to a texture and then in the fragment shader for that object sample the texel that corresponds to the current fragment's framebuffer location to get the destination color. You can do custom blending operations in this way, although it will be much slower than regular blending.

Share this post


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

  • Advertisement