@@ -191,6 +191,24 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
191
191
`#define vtkLightComplexity ${ model . lastLightComplexity } `
192
192
) . result ;
193
193
194
+ // set shadow blending flag
195
+ if ( model . lastLightComplexity > 0 ) {
196
+ if ( model . renderable . getVolumetricScatteringBlending ( ) > 0.0 ) {
197
+ FSSource = vtkShaderProgram . substitute (
198
+ FSSource ,
199
+ '//VTK::VolumeShadowOn' ,
200
+ `#define VolumeShadowOn`
201
+ ) . result ;
202
+ }
203
+ if ( model . renderable . getVolumetricScatteringBlending ( ) < 1.0 ) {
204
+ FSSource = vtkShaderProgram . substitute (
205
+ FSSource ,
206
+ '//VTK::SurfaceShadowOn' ,
207
+ `#define SurfaceShadowOn`
208
+ ) . result ;
209
+ }
210
+ }
211
+
194
212
// if using gradient opacity define that
195
213
model . gopacity = actor . getProperty ( ) . getUseGradientOpacity ( 0 ) ;
196
214
for ( let nc = 1 ; iComps && ! model . gopacity && nc < numComp ; ++ nc ) {
@@ -290,6 +308,22 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
290
308
false
291
309
) . result ;
292
310
}
311
+
312
+ if ( model . renderable . getVolumetricScatteringBlending ( ) > 0.0 ) {
313
+ FSSource = vtkShaderProgram . substitute (
314
+ FSSource ,
315
+ '//VTK::VolumeShadow::Dec' ,
316
+ [
317
+ `uniform float volumetricScatteringBlending;` ,
318
+ `uniform float giReach;` ,
319
+ `uniform float volumeShadowSamplingDistFactor;` ,
320
+ `uniform float anisotropy;` ,
321
+ `uniform float anisotropy2;` ,
322
+ ] ,
323
+ false
324
+ ) . result ;
325
+ }
326
+
293
327
shaders . Fragment = FSSource ;
294
328
} ;
295
329
@@ -738,26 +772,26 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
738
772
// specify the planes in view coordinates
739
773
program . setUniform3f ( `vPlaneNormal${ i } ` , normal [ 0 ] , normal [ 1 ] , normal [ 2 ] ) ;
740
774
program . setUniformf ( `vPlaneDistance${ i } ` , dist ) ;
775
+ }
741
776
742
- if ( actor . getProperty ( ) . getUseLabelOutline ( ) ) {
743
- const image = model . currentInput ;
744
- const worldToIndex = image . getWorldToIndex ( ) ;
777
+ if ( actor . getProperty ( ) . getUseLabelOutline ( ) ) {
778
+ const image = model . currentInput ;
779
+ const worldToIndex = image . getWorldToIndex ( ) ;
745
780
746
- program . setUniformMatrix ( 'vWCtoIDX' , worldToIndex ) ;
781
+ program . setUniformMatrix ( 'vWCtoIDX' , worldToIndex ) ;
747
782
748
- // Get the projection coordinate to world coordinate transformation matrix.
749
- mat4 . invert ( model . projectionToWorld , keyMats . wcpc ) ;
750
- program . setUniformMatrix ( 'PCWCMatrix' , model . projectionToWorld ) ;
783
+ // Get the projection coordinate to world coordinate transformation matrix.
784
+ mat4 . invert ( model . projectionToWorld , keyMats . wcpc ) ;
785
+ program . setUniformMatrix ( 'PCWCMatrix' , model . projectionToWorld ) ;
751
786
752
- const size = publicAPI . getRenderTargetSize ( ) ;
787
+ const size = publicAPI . getRenderTargetSize ( ) ;
753
788
754
- program . setUniformf ( 'vpWidth' , size [ 0 ] ) ;
755
- program . setUniformf ( 'vpHeight' , size [ 1 ] ) ;
789
+ program . setUniformf ( 'vpWidth' , size [ 0 ] ) ;
790
+ program . setUniformf ( 'vpHeight' , size [ 1 ] ) ;
756
791
757
- const offset = publicAPI . getRenderTargetOffset ( ) ;
758
- program . setUniformf ( 'vpOffsetX' , offset [ 0 ] / size [ 0 ] ) ;
759
- program . setUniformf ( 'vpOffsetY' , offset [ 1 ] / size [ 1 ] ) ;
760
- }
792
+ const offset = publicAPI . getRenderTargetOffset ( ) ;
793
+ program . setUniformf ( 'vpOffsetX' , offset [ 0 ] / size [ 0 ] ) ;
794
+ program . setUniformf ( 'vpOffsetY' , offset [ 1 ] / size [ 1 ] ) ;
761
795
}
762
796
763
797
mat4 . invert ( model . projectionToView , keyMats . vcpc ) ;
@@ -830,6 +864,25 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
830
864
program . setUniformfv ( 'lightExponent' , lightExponent ) ;
831
865
program . setUniformiv ( 'lightPositional' , lightPositional ) ;
832
866
}
867
+ if ( model . renderable . getVolumetricScatteringBlending ( ) > 0.0 ) {
868
+ program . setUniformf (
869
+ 'giReach' ,
870
+ model . renderable . getGlobalIlluminationReach ( )
871
+ ) ;
872
+ program . setUniformf (
873
+ 'volumetricScatteringBlending' ,
874
+ model . renderable . getVolumetricScatteringBlending ( )
875
+ ) ;
876
+ program . setUniformf (
877
+ 'volumeShadowSamplingDistFactor' ,
878
+ model . renderable . getVolumeShadowSamplingDistFactor ( )
879
+ ) ;
880
+ program . setUniformf ( 'anisotropy' , model . renderable . getAnisotropy ( ) ) ;
881
+ program . setUniformf (
882
+ 'anisotropy2' ,
883
+ model . renderable . getAnisotropy ( ) ** 2.0
884
+ ) ;
885
+ }
833
886
} ;
834
887
835
888
publicAPI . setPropertyShaderParameters = ( cellBO , ren , actor ) => {
0 commit comments