@@ -635,13 +635,16 @@ public Material readMaterial(int materialIndex) throws IOException {
635
635
setDefaultParams (adapter .getMaterial ());
636
636
}
637
637
638
+ Integer metallicRoughnessIndex = null ;
638
639
if (pbrMat != null ) {
639
640
adapter .setParam ("baseColorFactor" , getAsColor (pbrMat , "baseColorFactor" , ColorRGBA .White ));
640
641
adapter .setParam ("metallicFactor" , getAsFloat (pbrMat , "metallicFactor" , 1f ));
641
642
adapter .setParam ("roughnessFactor" , getAsFloat (pbrMat , "roughnessFactor" , 1f ));
642
643
adapter .setParam ("baseColorTexture" , readTexture (pbrMat .getAsJsonObject ("baseColorTexture" )));
643
644
adapter .setParam ("metallicRoughnessTexture" ,
644
645
readTexture (pbrMat .getAsJsonObject ("metallicRoughnessTexture" )));
646
+ JsonObject metallicRoughnessJson = pbrMat .getAsJsonObject ("metallicRoughnessTexture" );
647
+ metallicRoughnessIndex = metallicRoughnessJson != null ? getAsInteger (metallicRoughnessJson , "index" ) : null ;
645
648
}
646
649
647
650
adapter .getMaterial ().setName (getAsString (matData , "name" ));
@@ -657,7 +660,13 @@ public Material readMaterial(int materialIndex) throws IOException {
657
660
if (normal != null ) {
658
661
useNormalsFlag = true ;
659
662
}
660
- adapter .setParam ("occlusionTexture" , readTexture (matData .getAsJsonObject ("occlusionTexture" )));
663
+ JsonObject occlusionJson = matData .getAsJsonObject ("occlusionTexture" );
664
+ Integer occlusionIndex = occlusionJson != null ? getAsInteger (occlusionJson , "index" ) : null ;
665
+ if (occlusionIndex != null && occlusionIndex .equals (metallicRoughnessIndex )) {
666
+ adapter .getMaterial ().setBoolean ("AoPackedInMRMap" , true );
667
+ } else {
668
+ adapter .setParam ("occlusionTexture" , readTexture (matData .getAsJsonObject ("occlusionTexture" )));
669
+ }
661
670
adapter .setParam ("emissiveTexture" , readTexture (matData .getAsJsonObject ("emissiveTexture" )));
662
671
663
672
return adapter .getMaterial ();
0 commit comments