if( FAILED( g_pD3D->CheckDeviceType( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8,
D3DFMT_X8R8G8B8,
FALSE ) ) )
{
return;
}
if( FAILED( g_pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8,
D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE,
D3DFMT_D16 ) ) )
{
return;
}
D3DPRESENT_PARAMETERS d3dpp;
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferWidth = width;
d3dpp.BackBufferHeight = height;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hwnd,
dwBehaviorFlags,
d3dpp,
&g_pd3dDevice ) ) )
{
return;
}
🔒 Locked
Problems with Z-Buffer
Advertisement
Original Post
Hello, I think I have problems with Z-Buffer. In the image below I render a skydome and geometry:
In other parts of the map I alse have textures that disappear. This is the code I use to create the device: What I'm doing wrong? I use a znear value of 1 and zfar value of 3000. ( with opengl I don't have problems with this values). Thank you very much. VinCenT
Looks like z-fighting to me. I could be wrong though.
If it is z-fighting, it's the result of rendering coplanar polygons. You need to set the "D3DRS_DEPTHBIAS" render state before drawing them to make one appear in fron of the other, or just make sure the polygons aren't coplanar.
If it is z-fighting, it's the result of rendering coplanar polygons. You need to set the "D3DRS_DEPTHBIAS" render state before drawing them to make one appear in fron of the other, or just make sure the polygons aren't coplanar.
Hello,
I also think that is z-fighting, because there aren't coplanar polygons. The problem is that I can't set a 32bit Z buffer. I don't understand why. I have a nVidia GeForce 4 Ti 4400.
If I use the following code:
The call don't fail, but the device is not created ( = NULL ).
What can I do?
Thank you very much.
I also think that is z-fighting, because there aren't coplanar polygons. The problem is that I can't set a 32bit Z buffer. I don't understand why. I have a nVidia GeForce 4 Ti 4400.
If I use the following code:
d3dpp.Windowed = TRUE; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D32; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferWidth = width; d3dpp.BackBufferHeight = height; d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, dwBehaviorFlags, d3dpp, &g_pd3dDevice ) ) ) { return; }The call don't fail, but the device is not created ( = NULL ).
What can I do?
Thank you very much.
Quote:
Try setting a 24-bit depth buffer.
Yeah, there are still a lot of cards that don't support anything but 16-bit z-buffers, and maybe 24-bit.
Quote:
Also play with the near and far planes of your projection matrix.. set the near plane as FAR away as possible to maximize z-buffer resolution.
If the z-fighting isn't the result of coplanar polygons, then it is the result of uneven distribution of data on the z-buffer. If changing the n/f planes doesn't work, try changing your sort algorithm, to create more "overdraw". i.e. Draw polygons from closest to farthest. NOTE: this may cause problems with transparent polygons.
Quote:
Original post by lack o comments
Looks like z-fighting to me. I could be wrong though.
If it is z-fighting, it's the result of rendering coplanar polygons. You need to set the "D3DRS_DEPTHBIAS" render state before drawing them to make one appear in fron of the other, or just make sure the polygons aren't coplanar.
Listen to him!!!
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement