Jump to content
  • Advertisement
Sign in to follow this  
pressgreen

OpenGL gl_ClipVertex alternative

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

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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. Edited by Aks9

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!