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: 16 additions & 0 deletions package/Shaders/Lighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,9 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
material.Metallic = saturate(rawRMAOS.y);
material.AO = rawRMAOS.z;

// Apply vertex color to base color so PBR metals use it
baseColor.xyz *= input.Color.xyz;

if (!SharedData::linearLightingSettings.enableLinearLighting) {
material.F0 = lerp(rawRMAOS.w, Color::SrgbToLinear(baseColor.xyz), material.Metallic);
} else {
Expand Down Expand Up @@ -2752,6 +2755,12 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
{
float3 glowColor = Color::Glowmap(TexGlowSampler.Sample(SampGlowSampler, uv).xyz);
emitColor *= glowColor;
# if defined(TRUE_PBR)
// TRUE_PBR sets vertexColor=1 and adds emitColor directly to color (see below),
// so vertex tint must be applied here. Non-PBR folds emitColor into diffuseColor
// and the global color.xyz *= vertexColor (line 2918) already covers it.
emitColor *= input.Color.xyz;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
# endif
}
# endif

Expand Down Expand Up @@ -2853,8 +2862,15 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
float vertexAO = max(max(vertexColor.r, vertexColor.g), vertexColor.b);
// Modify skylightingDiffuse such that skylightingDiffuse * vertexAO = min(skylightingDiffuse, vertexAO)
skylightingDiffuse = saturate(skylightingDiffuse / max(vertexAO, 1e-5));
# if defined(TRUE_PBR)
vertexColor = 1;
# endif
# else
# if defined(TRUE_PBR)
float3 vertexColor = 1;
# else
float3 vertexColor = input.Color.xyz;
# endif
# endif // defined (HAIR)

float4 color = 0;
Expand Down
Loading