Jump to content

  • Log In with Google      Sign In   
  • Create Account

gl_ClipVertex alternative


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 greenzone   Members   -  Reputation: 672

Like
0Likes
Like

Posted 29 May 2012 - 12:26 PM

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

Sponsor:

#2 dpadam450   Members   -  Reputation: 949

Like
0Likes
Like

Posted 29 May 2012 - 07:12 PM

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[i]

#3 greenzone   Members   -  Reputation: 672

Like
0Likes
Like

Posted 31 May 2012 - 01:02 PM

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

#4 dpadam450   Members   -  Reputation: 949

Like
1Likes
Like

Posted 31 May 2012 - 01:18 PM

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.

#5 Aks9   Members   -  Reputation: 919

Like
2Likes
Like

Posted 31 May 2012 - 03:47 PM

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[i] 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.

#6 dpadam450   Members   -  Reputation: 949

Like
2Likes
Like

Posted 31 May 2012 - 07:22 PM

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.

#7 dpadam450   Members   -  Reputation: 949

Like
2Likes
Like

Posted 31 May 2012 - 07:23 PM

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.

#8 Aks9   Members   -  Reputation: 919

Like
1Likes
Like

Posted 01 June 2012 - 03:48 AM

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. Posted Image
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.

Posted Image What is a connection with fragments and discarding? Totally wrong assumption.

Edited by Aks9, 01 June 2012 - 06:16 AM.


#9 greenzone   Members   -  Reputation: 672

Like
0Likes
Like

Posted 04 June 2012 - 08:48 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS