Sign in to follow this  

Visual Artifacts when disabling backface culling in Directx9

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

The first screenshot is when backface culling is enabled (D3DRS_CULLMODE, D3DCULL_CCW) with no starfield background, all the textures display nicely.

 

[attachment=23547:screenshot.png]

 

The second one is when it's disabled (D3DRS_CULLMODE, D3DCULL_NONE) so the starfield sphere can be displayed in the background (it gets enabled again inmediately after rendering the starfield), but then all the other textures get messed up.

 

[attachment=23548:screenshot2.png]

 

I've been looking for a solution for this issue for weeks now and couldn't find out the way to fix it,,, can someone please tell me how to fix it?

Share this post


Link to post
Share on other sites

disabled (D3DRS_CULLMODE, D3DCULL_NONE) so the starfield sphere can be displayed in the background

 

Why do you have to disable culling to render the starfield sphere? What other parameters do you change between rendering the starfield sphere and the globe (or vice-versa)?

 

Not sure what or how you are rendering, but, if there are backfaces being rendered, the texture coordinates will be "backwards" also.

Edited by Buckeye

Share this post


Link to post
Share on other sites

 

Why do you have to disable culling to render the starfield sphere? What other parameters do you change between rendering the starfield sphere and the globe (or vice-versa)?

 

Not sure what or how you are rendering, but, if there are backfaces being rendered, the texture coordinates will be "backwards" also.

 

 

The whole scene is inside the starfield sphere, so to display the texture wrapped on it I need to render the texture "backwards" or it won't render at all, that's why I disable the culling when rendering the starfield. I enable it again when rendering the rest of the scene.

That's pretty much the only parameter I change when rendering the starfield sphere. Another thing to notice is that if the globe is tiny enough or it is very close to the camera then the texture displays properly. This issue only seems to happen either when the globe is big or far from the camera and the starfield is rendered backwards as it is supposed to be done.

Edited by Haalef

Share this post


Link to post
Share on other sites

If the starfield is intended to appear as stars at distances at astonomical distances with respect to foreground objects, rendering as a sky-box is likely a better approach. The next choice would be a sphere created to be viewed from the inside. However, I understand the desire to "use what you've got" and not "what you should have."

 

1. Your problem may be a case of z-fighting. The near- and far-plane settings in your projection matrix should be set to the smallest ratio possible to provide the best useable depth resolution. Considering the distances that appear in your images, you may be trying to distinguish distances (depths) beyond the resolution of the depth buffer.

2. In general, you should render objects front to back to take advantage of early depth testing.

3. Have you tried setting cullmode to D3DCULL_CW (instead of disabling it)?

4. You can render the starfield first, with depth disabled and CULL_CW (to render it "inside-out"). Then set your near- and far-planes at the smallest ratio that renders desired objects, with culling as appropriate.

Share this post


Link to post
Share on other sites


1. Your problem may be a case of z-fighting. The near- and far-plane settings in your projection matrix should be set to the smallest ratio possible to provide the best useable depth resolution. Considering the distances that appear in your images, you may be trying to distinguish distances (depths) beyond the resolution of the depth buffer.

 

Yep, that's it, it was a case of z-fighting as you suggested. I fixed it by adjusting the near and far view-planes. I set the near value as big as possible and the far value as small as possible and it now works like a charm. Thanks bro! you're the man! that depth buffer is a bitch XD

Share this post


Link to post
Share on other sites

This topic is 1192 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.

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