gl_ClipVertex alternative

Started by
7 comments, last by pressgreen 11 years, 10 months ago
I want to clip some geometry but when i try to use gl_ClipVertex in my vertex shader I get a message saying its deprecated after version 120. This is fine but what do i use as an alternative to this gl_ClipVertex if i want to clip geometry? if any one can help me that would be awesome.
I am using opengl version #140 with C++ and visual studio professional.
Thanks
J-GREEN

Greenpanoply
Advertisement
Try not forcing #version or whatever in your shader. Looks like in the newest spec I just read that variable still exists.

Try this as well.
gl_ClipDistance

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

ok i have tried gl_ClipDistance[] but i want to do two cliping planes now at the same time and there is no documentation any where that i can find to explain how this might be done. any one have any suggestions or a link to info that might explain in full how the gl_ClipDistance[] is used with multiple clipping planes.
J-GREEN

Greenpanoply
did you try writing the array at [0] and [1] ? I assume that it just works under the hood that when you compile the shader it knows you will only clip 2 planes.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal


I am using opengl version #140 with C++ and visual studio professional.

It is GLSL version 1.40, not OpenGL version. The corresponding OpenGL version is 3.1.


Try not forcing #version or whatever in your shader.

#version is very important directive! If not used GLSL 1.1 is assumed. So, DO use #version. NVIDIA is quite permissive. AMD is not.


did you try writing the array at [0] and [1] ? I assume that it just works under the hood that when you compile the shader it knows you will only clip 2 planes.

This is ridiculous! If you don't know the answer, please don't write such nonsense.

1. Clip distances have to be enabled by
glEnable(GL_CLIP_DISTANCE0 + i)

2. Send clip planes as uniforms to your vertex shader.

3. Calculate glClipDistance as a dot product of clip-plane and the vertex position vector.

Only the sign is important, not the value. If the distance is negative, the vertex will be clipped. The vertex and clip plane have to be in the same coordinate system in order to have a valid result.
I didn't know the answer on my first comment but it helped him. Better to post something than nothing to get him trying something. Your response was only a day later than mine and I've never seen your name in the GL forums in the 7 years I've been on it, so I actually know quite a bit. Stop being a douche.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

And the reason it wasnt nonsense is because if you dont write gl_FragDepth, it is taken care of before the pixel shader and early z-discard takes place before the shader. I assumed it might happen for clip planes in the current specs.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal


Better to post something than nothing to get him trying something.

Strongly disagree! If the pointer is wrong, he could get lost.


Your response was only a day later than mine and I've never seen your name in the GL forums in the 7 years I've been on it, so I actually know quite a bit. Stop being a douche.

Sorry for being impulsive! You wrote something that was not right I reacted for the sake of beginners that might be reading this.
I haven't posted anything on this forum for a while. But I am pretty active on opengl.org with my real name. smile.png
Whatever, it doesn't matter.


And the reason it wasnt nonsense is because if you dont write gl_FragDepth, it is taken care of before the pixel shader and early z-discard takes place before the shader. I assumed it might happen for clip planes in the current specs.

smile.png What is a connection with fragments and discarding? Totally wrong assumption.
1. Clip distances have to be enabled by
glEnable(GL_CLIP_DISTANCE0 + i)

This was the issue i was having I did not enable the right number of planes. for some reason I wrote glEnable(GL_CLIP_DISTANCE0) for the first clipping plan and glEnable(GL_CLIP_DISTANCE2) for the second one. although i do apretiate all the help It was the check list that Aks9 that helped me discover the problem. thanks to both of you though.
J-GREEN

Greenpanoply

This topic is closed to new replies.

Advertisement