Jump to content
  • Advertisement
Sign in to follow this  
plainoldcj

Orthographic projection causes artifacts

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

Hey guys,

 

I observe strange artifacts in my application when I switch from perspective projection

to orthographic projection.

Here's an image of the problem: https://dl.dropboxusercontent.com/u/56764397/projection_bug.png

It looks to me like some sort of z-fighting.

 

Now, I'm using depth peeling for transparency and the artifacts

disappear when rendering with another transparency technique,

so maybe the issue is how I read and write the depth textures.

 

It's pretty strange, though, because the projection matrix is not referenced in any fragment shaders.

 

Any ideas what I can do to isolate the problem?

 

 

Share this post


Link to post
Share on other sites
Advertisement

Hmm. To my surprise the problem disappears when I choose a sufficiently large negative value for the near clipping plane.

So before I set (znear, zfar) = (0.1, 100.0) for both the perspective and the orthographic projection matrix and the error

occurs. When I choose (znear, zfar) = (-100.0, 100.0) for the orthographic matrix everything looks fine.

I have no idea why. Since setting znear = -100.0 essentially doubles the viewing volume I would guess the error

becomes even worse!

Share this post


Link to post
Share on other sites

I noticed a similar thing when I was rotating a plane of width 1000 so that part of it would be cut off by the near plane. I noticed that if for example the plane was 1000 in size then the front and far clipping planes would need to accommodate the size(around 0,0,0) so -500 to +500 or something like that. I did like you and changed it to allow bigger objects with world matrix applied and now it works - mine is like so:

public void Use2DCamera()

{

    Shader.Projection = Matrix.CreateOrthographicOffCenter(0.0f, device.Viewport.Width, device.Viewport.Height, 0.0f, -2000f, 2000.0f); //near and far need to be huge for 3d world rotations to work

    Shader.View = Matrix.Identity;

}

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!