Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down