Skip to content

Commit

Permalink
GPU: Correct powered diffuse with exp=0.
Browse files Browse the repository at this point in the history
Just to ensure negative factors are handled too, as they are on hardware.
  • Loading branch information
unknownbrackets committed Nov 22, 2018
1 parent 1cec9f5 commit 6e46d6c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion GPU/Directx9/VertexShaderGeneratorDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ void GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
if (poweredDiffuse) {
// pow(0.0, 0.0) may be undefined, but the PSP seems to treat it as 1.0.
// Seen in Tales of the World: Radiant Mythology (#2424.)
WRITE(p, " if (ldot == 0.0 && u_matspecular.a == 0.0) {\n");
WRITE(p, " if (u_matspecular.a == 0.0) {\n");
WRITE(p, " ldot = 1.0;\n");
WRITE(p, " } else {\n");
WRITE(p, " ldot = pow(ldot, u_matspecular.a);\n");
Expand Down
2 changes: 1 addition & 1 deletion GPU/GLES/VertexShaderGeneratorGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
if (poweredDiffuse) {
// pow(0.0, 0.0) may be undefined, but the PSP seems to treat it as 1.0.
// Seen in Tales of the World: Radiant Mythology (#2424.)
WRITE(p, " if (ldot == 0.0 && u_matspecular.a == 0.0) {\n");
WRITE(p, " if (u_matspecular.a == 0.0) {\n");
WRITE(p, " ldot = 1.0;\n");
WRITE(p, " } else {\n");
WRITE(p, " ldot = pow(ldot, u_matspecular.a);\n");
Expand Down
8 changes: 1 addition & 7 deletions GPU/Software/Lighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,7 @@ void Process(VertexData& vertex, bool hasColor) {
float diffuse_factor = Dot(L, vertex.worldnormal);
if (gstate.isUsingPoweredDiffuseLight(light)) {
float k = gstate.getMaterialSpecularCoef();
// TODO: Validate Tales of the World: Radiant Mythology (#2424.)
// pow(0.0, 0.0) may be undefined, but the PSP seems to treat it as 1.0.
if (diffuse_factor <= 0.0f && k == 0.0f) {
diffuse_factor = 1.0f;
} else {
diffuse_factor = pow(diffuse_factor, k);
}
diffuse_factor = pspLightPow(diffuse_factor, k);
}

if (diffuse_factor > 0.f) {
Expand Down
2 changes: 1 addition & 1 deletion GPU/Vulkan/VertexShaderGeneratorVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
if (poweredDiffuse) {
// pow(0.0, 0.0) may be undefined, but the PSP seems to treat it as 1.0.
// Seen in Tales of the World: Radiant Mythology (#2424.)
WRITE(p, " if (dot%i == 0.0 && light.matspecular.a == 0.0) {\n", i);
WRITE(p, " if (light.matspecular.a == 0.0) {\n");
WRITE(p, " dot%i = 1.0;\n", i);
WRITE(p, " } else {\n");
WRITE(p, " dot%i = pow(dot%i, light.matspecular.a);\n", i, i);
Expand Down

0 comments on commit 6e46d6c

Please sign in to comment.