SetClipPlane and NVIDIA drivers

Started by
2 comments, last by Black Knight 15 years, 2 months ago
I'm having troubles with DX9 SetClipPlane in a demo i'm developing. After moving from XP to Vista, and updating NVIDIA graphic drivers, along with other issues that i managed to solve, i found this one problem that bugs me quite. I use planar reflections to simulate the reflection of a dynamic environment over a water surface; to do this i render the scene from below the water surface inside a texture, and then project this texture and access it inside a ps to render the water surface. In order to exclude from this first pass all the geometry that happens to be below the water surface i have a user clip plane. Everything worked fine under XP (with old GPU drivers), but now on Vista and NVIDIA 181.22 drivers when the camera moves it looks like the clip plane (whose equation must be specified in clip space) doesn't get updated in each frame, as if SetClipPlane was completely ignored after the first call. Has anyone experienced anything like this? Could this be due to a driver bug? Or am i doing something wrong? Thanks
Advertisement
I experience something similar but it was solved by reseting the clip plane after drawing.

Try something like this maybe it helps.

m_D3DDevice->SetClipPlane(0, (float*)waterPlaneH);
m_D3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 1);

//draw

//Need to reset the clipping plane for some reason.It works on a ATI card but
//not on a NVIDIA card.
m_D3DDevice->SetClipPlane(0, (float*)waterPlaneH);
m_D3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 1);
m_D3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
Quote:Original post by Black Knight

Try something like this maybe it helps.

m_D3DDevice->SetClipPlane(0, (float*)waterPlaneH);
m_D3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 1);

//draw

//Need to reset the clipping plane for some reason.It works on a ATI card but
//not on a NVIDIA card.
m_D3DDevice->SetClipPlane(0, (float*)waterPlaneH);
m_D3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 1);
m_D3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);


This helps but it doesn't solve the problem completely.
I my case doing so ensures that each frame will be rendered with the clip plane set for the previous one.
So the error doesn't accumulate when the camera moves, but while it's moving i can see the reflected skybox on the background flickering, because each frame uses the clip plane calculated from the point of view of the previous frame.

It looks like SetClipPlane doesn't actually update the clip plane until after the first draw call or some other call i can't figure out.

However thank you for your help.
My rendering goes like this so it doesnt cause any problems :

m_D3DDevice->SetClipPlane(0, (float*)waterPlaneH);m_D3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 1);//draw world inventerted to texturedrawWorldInverted();//Need to reset the clipping plane for some reason.It works on a ATI card but//not on a NVIDIA card.m_D3DDevice->SetClipPlane(0, (float*)waterPlaneH);m_D3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 1);m_D3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);//clear color buffers etc.//draw world normallydrawWorld();


So it all happens in the same frame I draw the reflection to a texture clear everything then draw the world to the backbuffer.

This topic is closed to new replies.

Advertisement