diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag index 4eaa6a88f5..b551f5a67b 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag @@ -134,10 +134,12 @@ void main(){ vec4 albedo = Color; #endif + //ao in r channel, roughness in green channel, metallic in blue channel! + vec3 aoRoughnessMetallicValue = vec3(1.0, 1.0, 0.0); #ifdef USE_PACKED_MR - vec2 rm = texture2D(m_MetallicRoughnessMap, newTexCoord).gb; - float Roughness = rm.x * max(m_Roughness, 1e-4); - float Metallic = rm.y * max(m_Metallic, 0.0); + aoRoughnessMetallicValue = texture2D(m_MetallicRoughnessMap, newTexCoord).rgb; + float Roughness = aoRoughnessMetallicValue.g * max(m_Roughness, 1e-4); + float Metallic = aoRoughnessMetallicValue.b * max(m_Metallic, 0.0); #else #ifdef ROUGHNESSMAP float Roughness = texture2D(m_RoughnessMap, newTexCoord).r * max(m_Roughness, 1e-4); @@ -224,6 +226,9 @@ void main(){ specularColor.rgb *= lightMapColor; #endif + #if defined(AO_PACKED_IN_MR_MAP) && defined(USE_PACKED_MR) + ao = aoRoughnessMetallicValue.rrr; + #endif float ndotv = max( dot( normal, viewDir ),0.0); for( int i = 0;i < NB_LIGHTS; i+=3){ diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md index 7f0e970018..7d131ac92c 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md @@ -72,7 +72,7 @@ MaterialDef PBR Lighting { Boolean SeparateTexCoord // the light map is a gray scale ao map, on ly the r channel will be read. Boolean LightMapAsAOMap - + Boolean AoPackedInMRMap //shadows Int FilterMode Boolean HardwareShadows @@ -158,6 +158,7 @@ MaterialDef PBR Lighting { NORMAL_TYPE: NormalType VERTEX_COLOR : UseVertexColor AO_MAP: LightMapAsAOMap + AO_PACKED_IN_MR_MAP : AoPackedInMRMap NUM_MORPH_TARGETS: NumberOfMorphTargets NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers HORIZON_FADE: HorizonFade