PDA

View Full Version : visualizing user clip planes?



Vexator
12-20-2007, 06:27 PM
is there a way to visualize the clip planes sent to opengl? i had reflections working perfectly, but now, after i've re-organized my shaders, the user clip planes don't work correctly anymore.

it doesn't seem to be possible to query the planes using glGet(), but what i actually need are the transformed, post-vs, planes anyway.

any ideas? it's hard to debug like this :( thanks.

T101
12-21-2007, 01:45 AM
If you just want to _see_ them, how about just rendering some translucent quads?

Vexator
12-21-2007, 05:19 AM
yeah but that's not very helpful :(

this is what i have in my vs:


gl_ClipVertex = gl_ModelViewMatrix*gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;

is this the correct setup?
as i said it used to work fine, but now the clip planes seem to depend on the orientation of the camera.

this video shows what i looked like: http://youtube.com/watch?v=USfsrLE4CiM

i compute a reflection matrix from from the plane equation given by the mirror's normal (= abc) and the dot product of this normal and the mirror's center (= d). i then multiply this matrix with the current view matrix. finally, i pass the plane equation to glClipPlane and render.

Humus
12-22-2007, 08:12 AM
is this the correct setup?
as i said it used to work fine, but now the clip planes seem to depend on the orientation of the camera.

It depends on what space your clip planes are in. Keep in mind that the clip planes are automatically transformed to eye-space when you specify them, so what your modelview matrix is at that point matters. I think the most straight-forward approach is to use clip-space planes, then you can simply do gl_ClipVertex = gl_Position.

Vexator
12-23-2007, 06:45 AM
Keep in mind that the clip planes are automatically transformed to eye-space when you specify them, so what your modelview matrix is at that point matters.

yeah that was the problem! i didn't know that the clip planes are transformed by the view matrix, so it was just luck that the correct matrix was present when i set the planes :) thanks!