For a big project I’m needing fast mesh slicing … but actually only for displaying purposes!
So, by some tips I’ve received, I’m trying to do it with GHGL.
Problem:
The script: GHGL clipping plane V0.1.gh (22.1 KB)
This is actually less than 5 rows of code of addition from a fresh GL Mesh Shader component…
took me 4 hours… OpenGL is hard!
How can I set it so it render correctly also the back faces and doesn’t mess up the preview of other GH objects?
( Also, with really smaller importance, how can I feed GHGL a material? Is this possible? )
Vertex:
#version 330
layout(location = 0) in vec3 _meshVertex;
layout(location = 1) in vec3 _meshNormal;
uniform mat4 _worldToClip;
out vec3 normal;
out vec3 pos;
void main() {
normal = _meshNormal;
pos = _meshVertex;
gl_Position = _worldToClip * vec4(_meshVertex , 1.0);
}
I’ve not been brave enough to dive into shaders yet. Good luck with that! I wonder why you’re not using clipping planes? There’s a bunch of c# nodes floating around for creating and orienting clipping planes. I use one of them regularly and it works pretty well.
My other solution is using actual “phisical” Mesh-Plane splitting, and for that I’m putting up a fast c# multithreaded, but it will always be slower than openGL.
I just need a quick/responsive dynamic preview while the user move the controls (sliders, etc…)
Selective clipping per object is available in Rhino 8 if that is an option. There are still a number of bugs I’m working on for this, but I’m hoping to have them fixed in the next couple weeks.
Looks great. That style of clipping (boolean combinations of multiple planes) probably won’t be supported in Rhino 8 anyways so it’s good you were able to do it yourself.