Skip to content

Commit 87c2cf9

Browse files
sankheshfinetjul
authored andcommitted
fix(glyph3dmapper): fix clipping plane support for vtkGlyph3DMapper
The clipping planes were being applied to the individual glyph geometries instead of the input geometry.
1 parent 4137d60 commit 87c2cf9

File tree

1 file changed

+46
-0
lines changed
  • Sources/Rendering/OpenGL/Glyph3DMapper

1 file changed

+46
-0
lines changed

Sources/Rendering/OpenGL/Glyph3DMapper/index.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,52 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) {
183183
superClass.replaceShaderNormal(shaders, ren, actor);
184184
};
185185

186+
publicAPI.replaceShaderClip = (shaders, ren, actor) => {
187+
if (model.hardwareSupport) {
188+
let VSSource = shaders.Vertex;
189+
let FSSource = shaders.Fragment;
190+
191+
if (model.renderable.getNumberOfClippingPlanes()) {
192+
const numClipPlanes = model.renderable.getNumberOfClippingPlanes();
193+
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Dec', [
194+
'uniform int numClipPlanes;',
195+
`uniform vec4 clipPlanes[${numClipPlanes}];`,
196+
`varying float clipDistancesVSOutput[${numClipPlanes}];`,
197+
]).result;
198+
199+
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Impl', [
200+
`for (int planeNum = 0; planeNum < ${numClipPlanes}; planeNum++)`,
201+
' {',
202+
' if (planeNum >= numClipPlanes)',
203+
' {',
204+
' break;',
205+
' }',
206+
' vec4 gVertex = gMatrix * vertexMC;',
207+
' clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], gVertex);',
208+
' }',
209+
]).result;
210+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Dec', [
211+
'uniform int numClipPlanes;',
212+
`varying float clipDistancesVSOutput[${numClipPlanes}];`,
213+
]).result;
214+
215+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Impl', [
216+
`for (int planeNum = 0; planeNum < ${numClipPlanes}; planeNum++)`,
217+
' {',
218+
' if (planeNum >= numClipPlanes)',
219+
' {',
220+
' break;',
221+
' }',
222+
' if (clipDistancesVSOutput[planeNum] < 0.0) discard;',
223+
' }',
224+
]).result;
225+
}
226+
shaders.Vertex = VSSource;
227+
shaders.Fragment = FSSource;
228+
}
229+
superClass.replaceShaderClip(shaders, ren, actor);
230+
};
231+
186232
publicAPI.replaceShaderColor = (shaders, ren, actor) => {
187233
if (model.hardwareSupport && model.renderable.getColorArray()) {
188234
let VSSource = shaders.Vertex;

0 commit comments

Comments
 (0)