@@ -819,6 +819,7 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
819
819
code = fDesc . getCode ( ) ;
820
820
821
821
const actor = model . WebGPUActor . getRenderable ( ) ;
822
+ const property = actor . getProperty ( ) ;
822
823
823
824
const checkDims = ( texture ) => {
824
825
if ( ! texture ) return false ;
@@ -827,15 +828,16 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
827
828
} ;
828
829
829
830
const usedTextures = [ ] ;
831
+ const diffuseTexture = property . getDiffuseTexture ?. ( ) ;
830
832
831
833
if (
832
- actor . getProperty ( ) . getDiffuseTexture ?. ( ) ?. getImageLoaded ( ) ||
834
+ diffuseTexture ?. getImageLoaded ( ) ||
833
835
actor . getTextures ( ) [ 0 ] ||
834
836
model . colorTexture
835
837
) {
836
838
if (
837
839
// Chained or statements here are questionable
838
- checkDims ( actor . getProperty ( ) . getDiffuseTexture ?. ( ) ) ||
840
+ checkDims ( diffuseTexture ) ||
839
841
checkDims ( actor . getTextures ( ) [ 0 ] ) ||
840
842
checkDims ( model . colorTexture )
841
843
) {
@@ -844,38 +846,65 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
844
846
) ;
845
847
}
846
848
}
847
- if ( actor . getProperty ( ) . getRoughnessTexture ?. ( ) ?. getImageLoaded ( ) ) {
848
- if ( checkDims ( actor . getProperty ( ) . getRoughnessTexture ( ) ) ) {
849
+
850
+ const ormTexture = property . getORMTexture ?. ( ) ;
851
+ const rmTexture = property . getRMTexture ?. ( ) ;
852
+ const roughnessTexture = property . getRoughnessTexture ?. ( ) ;
853
+ const metallicTexture = property . getMetallicTexture ?. ( ) ;
854
+ const ambientOcclusionTexture = property . getAmbientOcclusionTexture ?. ( ) ;
855
+ const emissionTexture = property . getEmissionTexture ?. ( ) ;
856
+ const normalTexture = property . getNormalTexture ?. ( ) ;
857
+
858
+ // ORM texture support: if present, sample R/G/B for AO/Roughness/Metallic
859
+ if ( ormTexture ?. getImageLoaded ( ) ) {
860
+ if ( checkDims ( ormTexture ) ) {
849
861
usedTextures . push (
850
- '_roughnessMap = textureSample(RoughnessTexture, RoughnessTextureSampler, input.tcoordVS);'
862
+ '_ambientOcclusionMap = textureSample(ORMTexture, ORMTextureSampler, input.tcoordVS).rrra;' ,
863
+ '_roughnessMap = textureSample(ORMTexture, ORMTextureSampler, input.tcoordVS).ggga;' ,
864
+ '_metallicMap = textureSample(ORMTexture, ORMTextureSampler, input.tcoordVS).bbba;'
851
865
) ;
852
866
}
853
- }
854
- if ( actor . getProperty ( ) . getMetallicTexture ?. ( ) ?. getImageLoaded ( ) ) {
855
- if ( checkDims ( actor . getProperty ( ) . getMetallicTexture ( ) ) ) {
867
+ } else if ( rmTexture ?. getImageLoaded ( ) ) {
868
+ if ( checkDims ( rmTexture ) ) {
856
869
usedTextures . push (
857
- '_metallicMap = textureSample(MetallicTexture, MetallicTextureSampler, input.tcoordVS);'
870
+ '_roughnessMap = textureSample(RMTexture, RMTextureSampler, input.tcoordVS).ggga;' ,
871
+ '_metallicMap = textureSample(RMTexture, RMTextureSampler, input.tcoordVS).bbba;'
858
872
) ;
859
873
}
860
- }
861
- if ( actor . getProperty ( ) . getNormalTexture ?. ( ) ?. getImageLoaded ( ) ) {
862
- if ( checkDims ( actor . getProperty ( ) . getNormalTexture ( ) ) ) {
863
- usedTextures . push (
864
- '_normalMap = textureSample(NormalTexture, NormalTextureSampler, input.tcoordVS);'
865
- ) ;
874
+ } else {
875
+ if ( roughnessTexture ?. getImageLoaded ( ) ) {
876
+ if ( checkDims ( roughnessTexture ) ) {
877
+ usedTextures . push (
878
+ '_roughnessMap = textureSample(RoughnessTexture, RoughnessTextureSampler, input.tcoordVS);'
879
+ ) ;
880
+ }
881
+ }
882
+ if ( metallicTexture ?. getImageLoaded ( ) ) {
883
+ if ( checkDims ( metallicTexture ) ) {
884
+ usedTextures . push (
885
+ '_metallicMap = textureSample(MetallicTexture, MetallicTextureSampler, input.tcoordVS);'
886
+ ) ;
887
+ }
888
+ }
889
+ if ( ambientOcclusionTexture ?. getImageLoaded ( ) ) {
890
+ if ( checkDims ( ambientOcclusionTexture ) ) {
891
+ usedTextures . push (
892
+ '_ambientOcclusionMap = textureSample(AmbientOcclusionTexture, AmbientOcclusionTextureSampler, input.tcoordVS);'
893
+ ) ;
894
+ }
866
895
}
867
896
}
868
- if ( actor . getProperty ( ) . getAmbientOcclusionTexture ?. ( ) ?. getImageLoaded ( ) ) {
869
- if ( checkDims ( actor . getProperty ( ) . getAmbientOcclusionTexture ( ) ) ) {
897
+ if ( emissionTexture ?. getImageLoaded ( ) ) {
898
+ if ( checkDims ( emissionTexture ) ) {
870
899
usedTextures . push (
871
- '_ambientOcclusionMap = textureSample(AmbientOcclusionTexture, AmbientOcclusionTextureSampler , input.tcoordVS);'
900
+ '_emissionMap = textureSample(EmissionTexture, EmissionTextureSampler , input.tcoordVS);'
872
901
) ;
873
902
}
874
903
}
875
- if ( actor . getProperty ( ) . getEmissionTexture ?. ( ) ?. getImageLoaded ( ) ) {
876
- if ( checkDims ( actor . getProperty ( ) . getEmissionTexture ( ) ) ) {
904
+ if ( normalTexture ?. getImageLoaded ( ) ) {
905
+ if ( checkDims ( normalTexture ) ) {
877
906
usedTextures . push (
878
- '_emissionMap = textureSample(EmissionTexture, EmissionTextureSampler , input.tcoordVS);'
907
+ '_normalMap = textureSample(NormalTexture, NormalTextureSampler , input.tcoordVS);'
879
908
) ;
880
909
}
881
910
}
@@ -1146,6 +1175,14 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
1146
1175
const pair = [ 'Diffuse' , model . colorTexture ] ;
1147
1176
textures . push ( pair ) ;
1148
1177
}
1178
+ if ( actor . getProperty ( ) . getORMTexture ?. ( ) ) {
1179
+ const pair = [ 'ORM' , actor . getProperty ( ) . getORMTexture ( ) ] ;
1180
+ textures . push ( pair ) ;
1181
+ }
1182
+ if ( actor . getProperty ( ) . getRMTexture ?. ( ) ) {
1183
+ const pair = [ 'RM' , actor . getProperty ( ) . getRMTexture ( ) ] ;
1184
+ textures . push ( pair ) ;
1185
+ }
1149
1186
if ( actor . getProperty ( ) . getRoughnessTexture ?. ( ) ) {
1150
1187
const pair = [ 'Roughness' , actor . getProperty ( ) . getRoughnessTexture ( ) ] ;
1151
1188
textures . push ( pair ) ;
0 commit comments