Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Clipping planes with programmable pipeline

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

hello. i need to use user defined clip planes, and i want to include pixel and vertex shaders. now, from the docs, i see that when using pixel/vertex shaders, the clip planes are defined in clip space. i searched through the docs, to try and figure out what is clipping space, but the only helpfull words i found, is, that when using vertex shaders the world space and clipping space are the same, and somewhere else, i saw that clipping space is where the vertices reside after transformations, ie. in the output register. this doesnt mean the same as the previous statement. so my question is, how should i define the clip planes? how should i transform them to clip space? multiply the plane equation with a projection matrix? thnx.

Share this post

Link to post
Share on other sites
ok. so you dont know.
do you know whether the clip planes equation are transformed by the some matrix, or should i transfrom it myself?

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
iirc you should multiply the plane by view*projection.

Share this post

Link to post
Share on other sites
Homogeneous clip-space is the one vertices are transformed to using the worldViewProjection matrix. So, I think you should do as AP said.

Muhammad Haggag

Share this post

Link to post
Share on other sites
hello. sorry for the delay.
thanx for the answers.
i tried multiplying the plane equation with the W*V*P matrix i use for rendering. but it doesnt work, i can see some clipping but not in place. maybe i should transpose or inverse the matrix? i tried, but it didnt work, maybe i did the wrong thing.
any ideas?

Share this post

Link to post
Share on other sites
Hi, I''ve got exactly the same problem. I use the D3DXPlaneFromPoints function to create the points for the general plane equation. Before using that funtion I multiply the points (0,0,0), (0,0,1) and (1,0,0) with my WVP matrix. First the result looks good, but when I turn the camera about 90 degrees or so the plane seems to flip. The geometry on the other side of the plane is clipped.

Share this post

Link to post
Share on other sites

anyway. I''ve been trying to find a solution to this exact problem all day... Couldn''t find anything on the web, so I did it by trial-and-error.. This is what I got, some people may find it quite useful:

D3DXPLANE CDirect3DRenderer::projectPlaneToClipSpace(D3DXPLANE plane, D3DXMATRIX view, D3DXMATRIX projection)
const D3DXVECTOR3 x(-10,0,0), y(0,-10,0), z(0,0,-10), zero(0,0,0);

D3DXVECTOR3 planeNorm(plane.a,plane.b,plane.c);

D3DXVECTOR3 p1=planeNorm*-plane.d;

D3DXVECTOR3 p2,p3,p4;


if (p2==zero)
if (p3==zero)


D3DXVECTOR4 dp1(p1.x,p1.y,p1.z,1);
D3DXVECTOR4 dp2(p2.x,p2.y,p2.z,1);
D3DXVECTOR4 dp3(p3.x,p3.y,p3.z,1);

D3DXVECTOR4 dpOut1,dpOut2,dpOut3;




if ((dpOut1.z>0) ^ (dpOut2.z>0) ^ (dpOut3.z>0))

return plane;

| - My project website - | - email me - |

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!