Jump to content
  • Advertisement
Sign in to follow this  
caxieyou

glsl with anti-aliasing

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

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~

Share this post


Link to post
Share on other sites
Advertisement
Look up multisampling glEnable(GL_MULTISAMPLE), you need to request a multi sample buffer at startup as you do for a depth/color buffer.

Share this post


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


Look up multisampling glEnable(GL_MULTISAMPLE), you need to request a multi sample buffer at startup as you do for a depth/color buffer.

Share this post


Link to post
Share on other sites
Multisampling is done in the hardware, you don't do anything except enable it. Does not matter if you run a shader or not.

Share this post


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

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!