You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is great, however it only seems to work if the section box is aligned to the XYZ axis.
I am trying to get it to work when the box is at any angle, however I cant get the shader to work right, i believe due to the camera position. I am working out the dot product but the results are not always correct. Heres my shader code...
This is great, however it only seems to work if the section box is aligned to the XYZ axis.
I am trying to get it to work when the box is at any angle, however I cant get the shader to work right, i believe due to the camera position. I am working out the dot product but the results are not always correct. Heres my shader code...
fragmentClipping2: '
uniform vec3 color;
uniform vec3 clippingLow;
uniform vec3 clippingHigh;
uniform vec3 planeNormal1;
uniform vec3 planeNormal2;
uniform vec3 planeNormal3;
uniform vec3 planeNormal4;
uniform vec3 planeNormal5;
uniform vec3 planeNormal6;
uniform float planeDistance1;
uniform float planeDistance2;
uniform float planeDistance3;
uniform float planeDistance4;
uniform float planeDistance5;
uniform float planeDistance6;
uniform int reverse;
varying vec3 pixelNormal;
varying vec4 worldPosition;
varying vec3 camPosition;
bool isClipped(vec4 point){
vec4 planes[6];
planes[0]=vec4(planeNormal1.x,planeNormal1.y,planeNormal1.z,planeDistance1);
planes[1]=vec4(planeNormal2.x,planeNormal2.y,planeNormal2.z,planeDistance2);
planes[2]=vec4(planeNormal3.x,planeNormal3.y,planeNormal3.z,planeDistance3);
planes[3]=vec4(planeNormal4.x,planeNormal4.y,planeNormal4.z,planeDistance4);
planes[4]=vec4(planeNormal5.x,planeNormal5.y,planeNormal5.z,planeDistance5);
planes[5]=vec4(planeNormal6.x,planeNormal6.y,planeNormal6.z,planeDistance6);
for (int i=0;i<6;i++){
float dotProduct=dot(point.xyz,planes[i].xyz)+planes[i].w;
float dotProduct2=dot(camPosition.xyz,planes[i].xyz);
if(dotProduct<0.0 && dotProduct2 <0.0){
return true;
}
if(dotProduct<0.0 && dotProduct2>0.0){
return false;
}
}
return false;
}
void main( void ) {
float shade = (
3.0 * pow ( abs ( pixelNormal.y ), 2.0 )
+ 2.0 * pow ( abs ( pixelNormal.z ), 2.0 )
+ 1.0 * pow ( abs ( pixelNormal.x ), 2.0 )
) / 3.0;
if(isClipped(worldPosition)){
discard;
}
else{
gl_FragColor = vec4( color * shade, 1.0 );
return;
}
}'
looks good here...
but if i rotate the camera you can see its not capping correctly
Any help or suggestions would be greatly appriciated
The text was updated successfully, but these errors were encountered: