gl_FragColor

Started by
3 comments, last by shurcool 17 years, 2 months ago
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
Advertisement
No. There is no scatter in fragment programs. The program is called for(a,b) and can *only* produce output for (a,b).
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.
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.
All right, I was afraid of that. Thanks a lot!

This topic is closed to new replies.

Advertisement