Jump to content
  • Advertisement
Sign in to follow this  
plainoldcj

Stencil Buffer Artifacts

This topic is 2071 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 everyone,

 

I'm using the stencil buffer to draw the intersection of a plane and a sphere. However I'm getting some annoying artifacts near

the boundary of the intersection. See the attached image.

These artifacts depend on the camera position. And although they look somewhat polygonal they generally don't coincide with

the edges of either mesh.

 

Any ideas?

 

Here's the algorithm I'm using:

 

Depth test is enabled, culling is disabled.

 

- Draw the plane mesh with stencil.func.ref = 1 and stencil.func = GL_REPLACE.

(ie. fill the stencil buffer with 1)

 

- Draw the sphere with depth.mask = false and

stencil.op.zpass = GL_INCR for front faces and stencil.op.zpass = GL_DECR_WRAP for backfaces

(I use glStencipOpSeparate and draw the sphere once)

 

- Blend fullscreen quad where stencil value is greater than 1

Share this post


Link to post
Share on other sites
Advertisement

 

(I use glStencipOpSeparate and draw the sphere once)

try not to do this and see wheather artifact persists. The rendering engine will perform a lot of hidden logic by this being issued and I would not bet it would perform any better than 2 draws with a culling and zpass operation state changed.

Edited by JohnnyCode

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!