glsl_shader_fs_gen: Apply shadow before ambient light (#7404)
This commit is contained in:
parent
63feac6bb3
commit
480604ec72
|
@ -285,19 +285,20 @@ std::pair<Common::Vec4<u8>, Common::Vec4<u8>> ComputeFragmentsColors(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto diffuse =
|
const bool shadow_primary_enable =
|
||||||
(light_config.diffuse.ToVec3f() * dot_product + light_config.ambient.ToVec3f()) *
|
lighting.config0.shadow_primary && !lighting.IsShadowDisabled(num);
|
||||||
dist_atten * spot_atten;
|
const bool shadow_secondary_enable =
|
||||||
auto specular = (specular_0 + specular_1) * clamp_highlights * dist_atten * spot_atten;
|
lighting.config0.shadow_secondary && !lighting.IsShadowDisabled(num);
|
||||||
|
const auto shadow_primary =
|
||||||
|
shadow_primary_enable ? shadow.xyz() : Common::MakeVec(1.f, 1.f, 1.f);
|
||||||
|
const auto shadow_secondary =
|
||||||
|
shadow_secondary_enable ? shadow.xyz() : Common::MakeVec(1.f, 1.f, 1.f);
|
||||||
|
|
||||||
if (!lighting.IsShadowDisabled(num)) {
|
const auto diffuse = (light_config.diffuse.ToVec3f() * dot_product * shadow_primary +
|
||||||
if (lighting.config0.shadow_primary) {
|
light_config.ambient.ToVec3f()) *
|
||||||
diffuse = diffuse * shadow.xyz();
|
dist_atten * spot_atten;
|
||||||
}
|
const auto specular = (specular_0 + specular_1) * clamp_highlights * dist_atten *
|
||||||
if (lighting.config0.shadow_secondary) {
|
spot_atten * shadow_secondary;
|
||||||
specular = specular * shadow.xyz();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diffuse_sum += Common::MakeVec(diffuse, 0.0f);
|
diffuse_sum += Common::MakeVec(diffuse, 0.0f);
|
||||||
specular_sum += Common::MakeVec(specular, 0.0f);
|
specular_sum += Common::MakeVec(specular, 0.0f);
|
||||||
|
|
|
@ -810,8 +810,8 @@ void FragmentModule::WriteLighting() {
|
||||||
|
|
||||||
// Compute primary fragment color (diffuse lighting) function
|
// Compute primary fragment color (diffuse lighting) function
|
||||||
out += fmt::format(
|
out += fmt::format(
|
||||||
"diffuse_sum.rgb += (({}.diffuse * dot_product) + {}.ambient) * {} * {}{};\n",
|
"diffuse_sum.rgb += (({}.diffuse * dot_product{}) + {}.ambient) * {} * {};\n",
|
||||||
light_src, light_src, dist_atten, spot_atten, shadow_primary);
|
light_src, shadow_primary, light_src, dist_atten, spot_atten);
|
||||||
|
|
||||||
// Compute secondary fragment color (specular lighting) function
|
// Compute secondary fragment color (specular lighting) function
|
||||||
out += fmt::format("specular_sum.rgb += ({} + {}) * clamp_highlights * {} * {}{};\n",
|
out += fmt::format("specular_sum.rgb += ({} + {}) * clamp_highlights * {} * {}{};\n",
|
||||||
|
|
Loading…
Reference in a new issue