@@ -183,6 +183,52 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) {
183
183
superClass . replaceShaderNormal ( shaders , ren , actor ) ;
184
184
} ;
185
185
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
+
186
232
publicAPI . replaceShaderColor = ( shaders , ren , actor ) => {
187
233
if ( model . hardwareSupport && model . renderable . getColorArray ( ) ) {
188
234
let VSSource = shaders . Vertex ;
0 commit comments