Skip to content

Commit d49733f

Browse files
authored
Merge pull request #19489 from hrydgard/specular-math-fix
Hardware transform: Clamp the specular coefficient to 0.0 before calling pow()
2 parents ccb9689 + 702e774 commit d49733f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

GPU/Common/VertexShaderGenerator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
11261126
case GE_LIGHTTYPE_UNKNOWN:
11271127
p.F(" angle = dot(u_lightdir%s, toLight);\n", iStr, iStr);
11281128
p.F(" if (angle >= u_lightangle_spotCoef%s.x) {\n", iStr);
1129-
p.F(" lightScale = clamp(1.0 / dot(u_lightatt%s, vec3(1.0, distance, distance*distance)), 0.0, 1.0) * (u_lightangle_spotCoef%s.y <= 0.0 ? 1.0 : pow(angle, u_lightangle_spotCoef%s.y));\n", iStr, iStr, iStr);
1129+
p.F(" lightScale = clamp(1.0 / dot(u_lightatt%s, vec3(1.0, distance, distance*distance)), 0.0, 1.0) * (u_lightangle_spotCoef%s.y <= 0.0 ? 1.0 : pow(max(angle, 0.0), u_lightangle_spotCoef%s.y));\n", iStr, iStr, iStr);
11301130
p.C(" } else {\n");
11311131
p.C(" lightScale = 0.0;\n");
11321132
p.C(" }\n");

0 commit comments

Comments
 (0)