Advertisement

gl_ClipDistance for clipping

Started by September 03, 2024 02:19 PM
0 comments, last by wsd 3 months, 2 weeks ago

I'm using gl_ClipDistance for clipping. When displaying only the surface, everything is fine, but when I add the lines, the issue shown in the image below occurs. What could be causing this?



fragment-face
-----------------------------------------
#version 430 core
layout (location=0) in vec3 aPos;
layout (location=1) in float valuef;
out mat4 vmodel;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;

uniform int planeNum;
uniform float flip;
uniform vec4 plane[6];

void main()
{
vmodel = model;

value = valuef;

vPosition = vec3(model * vec4(aPos, 1.0));
gl_Position = projection * view * model*vec4(aPos, 1.0);

for(int i=0;i<planeNum;i++)
{
gl_ClipDistance[i] = dot(vec4(aPos, 1.0), plane[i])*flip;
}
}
------------------------------------------------------------------
fragment-Curve
------------------------
#version 430 core
layout (location=0) in vec3 aPos;
out vec3 aColor;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
uniform vec3 curveColor;


uniform int planeNum;
uniform float flip;
uniform vec4 plane[6];


void main()
{
aColor = curveColor;

gl_Position = projection * view * model * vec4(aPos,1.0);

for(int i=0;i<planeNum;i++)
{
gl_ClipDistance[i] =flip* dot(vec4(aPos, 1.0), plane[i]);
}
}
----------------------------------------------------

This topic is closed to new replies.

Advertisement