Skip to main content
GameDev.net gamedev.net
🔒 Locked

SetClipPlane

Started by Lazy Dec 4, 2011 at 9:39 PM 1 replies 2.1k views
Original Post
Lazy
Lazy
Hi! Im trying to do a simple water shader with reflection. But I just cant get plane clipping to work. Doesn't matter what position or normal I use for my plane, nothing is ever clipped. The water reflects correctly except it also reflects stuff under the water.
Does anyone see any error in the code?

any help is appreciated



D3DXPLANE clip_plane;
D3DXPlaneFromPointNormal(&clip_plane, &D3DXVECTOR3(0,-5, 0), &D3DXVECTOR3(0,1,0));
D3DXPlaneNormalize(&clip_plane, &clip_plane);

D3DXMATRIX view_projection = camera.GetViewProjectionMatrix();
D3DXMatrixInverse(&view_projection, NULL, &view_projection);
D3DXMatrixTranspose(&view_projection, &view_projection);

D3DXPLANE view_clip_plane;
D3DXPlaneTransform(&view_clip_plane, &clip_plane, &view_projection);

NGraphics::GetD3D9Device()->SetClipPlane(0, view_clip_plane);
NGraphics::GetD3D9Device()->SetRenderState(D3DRS_CLIPPLANEENABLE, D3DCLIPPLANE0);

//I draw the water here
ZZzz..
Lazy
Lazy
Hmm.. not ok. Works at work on my 8800 GTX. But not at home on my 570 GTX. Very strange.
ZZzz..
Lazy
Lazy
The solution at home was to check the world position in the Pixel shader and discard; the pixel if it was too low. I guess this is slower... but at least it works.
ZZzz..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.