When use the shader, especially the frag to render scene, it draw pixel by pixel, how to apply anti-aliasing in a shader?
after reading the orange book, chapter 17, I got nothing understand...
what exactly does the fwidth function return?
Thanks in adav~
glsl with anti-aliasing
Look up multisampling glEnable(GL_MULTISAMPLE), you need to request a multi sample buffer at startup as you do for a depth/color buffer.
Thanks
Do you mean if I just use the regular way to render the secen and do post operation in the shader, there is no way to do the antialiasing?
BTW, does the fwidth function have any relationship with the multisample?
Do you mean if I just use the regular way to render the secen and do post operation in the shader, there is no way to do the antialiasing?
BTW, does the fwidth function have any relationship with the multisample?
Look up multisampling glEnable(GL_MULTISAMPLE), you need to request a multi sample buffer at startup as you do for a depth/color buffer.
Multisampling is done in the hardware, you don't do anything except enable it. Does not matter if you run a shader or not.
I typed a long and detailed reply to this, only to have the new forums swallow it. Gah.
In short: I think the OP wants to anti-alias his (possibly procedural) shaders. Typical multisampling doesn't help here, as it will only invoke a shader once per pixel, regardless of coverage samples. You'll need to manually AA your shader using partial derivatives and/or estimate filter width over a sub-pixel area (ddx, ddy, fwidth, etc). fwidth returns the sum of the absolute partial derivatives in x and y of the specified varying at the current location.
There's also ARB_sample_shading, which more or less brute-forces this automatically, to some extend (if your HW supports it).
Both approaches will typically have a large impact on performance.
In short: I think the OP wants to anti-alias his (possibly procedural) shaders. Typical multisampling doesn't help here, as it will only invoke a shader once per pixel, regardless of coverage samples. You'll need to manually AA your shader using partial derivatives and/or estimate filter width over a sub-pixel area (ddx, ddy, fwidth, etc). fwidth returns the sum of the absolute partial derivatives in x and y of the specified varying at the current location.
There's also ARB_sample_shading, which more or less brute-forces this automatically, to some extend (if your HW supports it).
Both approaches will typically have a large impact on performance.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement