And if I remove the shader and leave the texture on the object, then the clipping plane works.
So having a shader on the material is the problem. How can I solve this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ModelMatrix I get from scene.buffer.rendercontext.pipelinetransformations.modelmatrix,
and clipPlane is a vector4f that I send in as a uniform vec4(0.0, 1.0, 0.0 0.0).
The clipplane seems to be stuck in the object space and follows the moving ships movements and do not stay at the world pos.
Any idea what's wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I am setting up a clip plane like this:
It works on standard objects like a GLSphere, but it doesn't work on my FreeForm objects, any idea why?
Cheers and thanks!
/Daniel
An update.
When I remove the material which has a shader, then the clipping plane works!?
How can I use the clip plane on a textured freeform?
And if I remove the shader and leave the texture on the object, then the clipping plane works.
So having a shader on the material is the problem. How can I solve this?
Hi Daniel in your case, you need to implement clipping plane in the shader
Some links found with google :
https://community.khronos.org/t/how-to-activate-clip-planes-via-shader/61904/2
https://prideout.net/clip-planes
https://stackoverflow.com/questions/51406431/implementing-clip-planes-with-geometry-shaders
https://www.youtube.com/watch?v=0NH9k4zTAqk
https://www.reddit.com/r/opengl/comments/8jy5zx/simple_shader_with_custom_clipping_plane/
Cheers
Hi Jerome!
Thanks! That worked.
But I am having trouble with the matrixes.
I do this on a moving shipmodel:
ModelMatrix I get from scene.buffer.rendercontext.pipelinetransformations.modelmatrix,
and clipPlane is a vector4f that I send in as a uniform vec4(0.0, 1.0, 0.0 0.0).
The clipplane seems to be stuck in the object space and follows the moving ships movements and do not stay at the world pos.
Any idea what's wrong?
Hi Daniel, hard to answer like this.
1st On what tutorial have you take reference ?
2nd Can you make a little sample, for testing ?
So i think
gl_ClipDistance[0] = dot(gl_Vertex * modelMatrix, clipPlane);
is wrong
if i understand well, it should be
position = gl_Vertex * modelViewProjectionMatrix
gl_ClipDistance[0] = dot(position, clipPlane);
Cheers
Sadly it didn't help.
I am using the code from https://prideout.net/clip-planes
I will try to make an sample program.
Thanks for helping!!
Hi Daniel can you post the code of your shader, and how you pass attributes to it ?
Cheers
Absolutly!
mm := GLSceneViewer1.Buffer.RenderingContext.PipelineTransformation.modelMatrix;
cPlane := Vector4fMake(0.0,1.0,0.0,2.0);
I will fix a sample program as soon as I can.
Last edit: Daniel 2020-07-20