Skip to content
Merged
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
16 changes: 8 additions & 8 deletions package/Shaders/Lighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
# if defined(EMAT_ENVMAP)
complexMaterial = complexMaterial && complexMaterialColor.y > (4.0 / 255.0) && (complexMaterialColor.y < (1.0 - (4.0 / 255.0)));
shininess = lerp(shininess, shininess * complexMaterialColor.y, complexMaterial);
float3 complexSpecular = lerp(1.0, lerp(1.0, baseColor.xyz, complexMaterialColor.z), complexMaterial);
float3 complexSpecular = lerp(1.0, lerp(1.0, Color::GammaToLinear(baseColor.xyz), complexMaterialColor.z), complexMaterial);
baseColor.xyz = lerp(baseColor.xyz, lerp(baseColor.xyz, 0.0, complexMaterialColor.z), complexMaterial);
# endif // defined (EMAT) && defined(ENVMAP)

Expand Down Expand Up @@ -2292,8 +2292,6 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
float3 directionalAmbientColor = max(0, mul(DirectionalAmbient, modelNormal));
float3 directionalAmbientColorDirect = 0;

float3 reflectionDiffuseColor = diffuseColor + directionalAmbientColor;

# if defined(SKYLIGHTING)
float skylightingDiffuse = 1;
if (!SharedData::InInterior) {
Expand All @@ -2315,6 +2313,8 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
}
# endif

float3 reflectionDiffuseColor = diffuseColor + directionalAmbientColor;

# if defined(TRUE_PBR) && defined(LOD_LAND_BLEND) && !defined(DEFERRED)
lodLandDiffuseColor += directionalAmbientColor;
# endif
Expand Down Expand Up @@ -2398,7 +2398,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
# if defined(EMAT)
float complexMaterialRoughness = 1.0 - complexMaterialColor.y;
envRoughness = lerp(envRoughness, pow(complexMaterialRoughness, 1.5), complexMaterial);
F0 = lerp(F0, Color::GammaToLinear(complexSpecular), complexMaterial);
F0 = lerp(F0, complexSpecular, complexMaterial);
# endif

if (any(F0 > 0.0))
Expand All @@ -2414,7 +2414,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
# endif

if (!dynamicCubemap) {
float3 envColorBase = TexEnvSampler.Sample(SampEnvSampler, envSamplingPoint);
float3 envColorBase = Color::GammaToLinear(TexEnvSampler.Sample(SampEnvSampler, envSamplingPoint));
envColor = envColorBase.xyz * envMask;
}
}
Expand Down Expand Up @@ -2557,9 +2557,9 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace

# if defined(SPECULAR)
# if defined(EMAT_ENVMAP)
specularColor = (specularColor * glossiness * MaterialData.yyy) * lerp(SpecularColor.xyz, complexSpecular, complexMaterial);
specularColor = (specularColor * glossiness * MaterialData.yyy) * lerp(Color::GammaToLinear(SpecularColor.xyz), complexSpecular, complexMaterial);
# else
specularColor = (specularColor * glossiness * MaterialData.yyy) * SpecularColor.xyz;
specularColor = (specularColor * glossiness * MaterialData.yyy) * Color::GammaToLinear(SpecularColor.xyz);
# endif
# elif defined(SPARKLE)
specularColor *= glossiness;
Expand All @@ -2576,7 +2576,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
# if defined(DYNAMIC_CUBEMAPS)
if (!dynamicCubemap)
# endif
specularColor += envColor * diffuseColor;
specularColor += envColor * Color::GammaToLinear(diffuseColor);
# endif

# if defined(EMAT_ENVMAP)
Expand Down