Sign in to follow this  

Orthographic projection causes artifacts

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:

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this