# [DX9] face visibility & camera angolation

This topic is 2896 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi there!
i've got a problem..
i draw a sort of floor (a rectangle made of 2 triangles) with DrawPrimitive function.
If i look at the floor from an higher z value it is not drawn. On the other hand, when i look at the floor from a lower z value it switchs to visible.
What should i do to make it visible from any point of view? Thanks in advance
edit: Moreover , even if the rectangle is visible, it is bad drawn against an other polygon ( a block ).
I think it is due to the same problem..

##### Share on other sites
You have two problems here.

To make the 'floor' visible from both sides either change D3DRS_CULLMODE to D3DCULL_NONE or duplicate the triangles, but with the opposite vertex winding order.

To make it sort correctly with the cube make sure that D3DRS_ZENABLE and D3DRS_ZWRITEENABLE are set to TRUE, make sure the near and far clip planes are sensible (aim for a ratio of about 1000:1 or less between the two) and make sure you've created a z-buffer.

##### Share on other sites

You have two problems here.

To make the 'floor' visible from both sides either change D3DRS_CULLMODE to D3DCULL_NONE or duplicate the triangles, but with the opposite vertex winding order.

To make it sort correctly with the cube make sure that D3DRS_ZENABLE and D3DRS_ZWRITEENABLE are set to TRUE, make sure the near and far clip planes are sensible (aim for a ratio of about 1000:1 or less between the two) and make sure you've created a z-buffer.

Firstly i'll try to fix my zbuffer trouble.
Actually there was no zbuffer before.
I mean, I used to believe that DX automatically initializes it, so my presentation parameters were these:

 d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = SCREEN_HEIGHT; d3dpp.BackBufferWidth = SCREEN_WIDTH; d3dpp.hDeviceWindow = hwnd;
With them the cube and the floor didn't have any depth checking.
Still, if i change my pp in this way:

 d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = SCREEN_HEIGHT; d3dpp.BackBufferWidth = SCREEN_WIDTH; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.hDeviceWindow = hwnd;
nothing is visible.
Even if I set this:

 pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE); pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);

So, where is the problem? I'm so confused..

##### Share on other sites
Are you clearing your new depth buffer?

##### Share on other sites

Are you clearing your new depth buffer?

yayyy
That was what i forgot! Thank you ;D

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 21
• 23
• 11
• 25