@@ -819,6 +819,7 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
819819 code = fDesc . getCode ( ) ;
820820
821821 const actor = model . WebGPUActor . getRenderable ( ) ;
822+ const property = actor . getProperty ( ) ;
822823
823824 const checkDims = ( texture ) => {
824825 if ( ! texture ) return false ;
@@ -827,15 +828,16 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
827828 } ;
828829
829830 const usedTextures = [ ] ;
831+ const diffuseTexture = property . getDiffuseTexture ?. ( ) ;
830832
831833 if (
832- actor . getProperty ( ) . getDiffuseTexture ?. ( ) ?. getImageLoaded ( ) ||
834+ diffuseTexture ?. getImageLoaded ( ) ||
833835 actor . getTextures ( ) [ 0 ] ||
834836 model . colorTexture
835837 ) {
836838 if (
837839 // Chained or statements here are questionable
838- checkDims ( actor . getProperty ( ) . getDiffuseTexture ?. ( ) ) ||
840+ checkDims ( diffuseTexture ) ||
839841 checkDims ( actor . getTextures ( ) [ 0 ] ) ||
840842 checkDims ( model . colorTexture )
841843 ) {
@@ -844,38 +846,65 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
844846 ) ;
845847 }
846848 }
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 ) ) {
849861 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;'
851865 ) ;
852866 }
853- }
854- if ( actor . getProperty ( ) . getMetallicTexture ?. ( ) ?. getImageLoaded ( ) ) {
855- if ( checkDims ( actor . getProperty ( ) . getMetallicTexture ( ) ) ) {
867+ } else if ( rmTexture ?. getImageLoaded ( ) ) {
868+ if ( checkDims ( rmTexture ) ) {
856869 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;'
858872 ) ;
859873 }
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+ }
866895 }
867896 }
868- if ( actor . getProperty ( ) . getAmbientOcclusionTexture ?. ( ) ?. getImageLoaded ( ) ) {
869- if ( checkDims ( actor . getProperty ( ) . getAmbientOcclusionTexture ( ) ) ) {
897+ if ( emissionTexture ?. getImageLoaded ( ) ) {
898+ if ( checkDims ( emissionTexture ) ) {
870899 usedTextures . push (
871- '_ambientOcclusionMap = textureSample(AmbientOcclusionTexture, AmbientOcclusionTextureSampler , input.tcoordVS);'
900+ '_emissionMap = textureSample(EmissionTexture, EmissionTextureSampler , input.tcoordVS);'
872901 ) ;
873902 }
874903 }
875- if ( actor . getProperty ( ) . getEmissionTexture ?. ( ) ?. getImageLoaded ( ) ) {
876- if ( checkDims ( actor . getProperty ( ) . getEmissionTexture ( ) ) ) {
904+ if ( normalTexture ?. getImageLoaded ( ) ) {
905+ if ( checkDims ( normalTexture ) ) {
877906 usedTextures . push (
878- '_emissionMap = textureSample(EmissionTexture, EmissionTextureSampler , input.tcoordVS);'
907+ '_normalMap = textureSample(NormalTexture, NormalTextureSampler , input.tcoordVS);'
879908 ) ;
880909 }
881910 }
@@ -1146,6 +1175,14 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
11461175 const pair = [ 'Diffuse' , model . colorTexture ] ;
11471176 textures . push ( pair ) ;
11481177 }
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+ }
11491186 if ( actor . getProperty ( ) . getRoughnessTexture ?. ( ) ) {
11501187 const pair = [ 'Roughness' , actor . getProperty ( ) . getRoughnessTexture ( ) ] ;
11511188 textures . push ( pair ) ;
0 commit comments