Skip to content

Commit

Permalink
Fix minor difference between ubershader and specialized vshaders
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jul 24, 2024
1 parent cc5763c commit c6bbe49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions GPU/Common/ShaderUniforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
}

// For "light ubershader" bits.
// TODO: We pack these bits even when not using ubershader lighting. Maybe not bother.
uint32_t PackLightControlBits() {
// Bit organization
// Bottom 4 bits are enable bits for each light.
Expand Down
3 changes: 2 additions & 1 deletion GPU/Common/VertexShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
}
}

// NOTE: Can't change this without updaing uniform buffer declarations (for D3D11 and VK, the one in ShaderUniforms.h).
bool useIndexing = compat.shaderLanguage == HLSL_D3D11 || compat.shaderLanguage == GLSL_VULKAN;

char iStr[4];
Expand Down Expand Up @@ -1062,7 +1063,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
p.C(" ldot = u_matspecular.a > 0.0 ? pow(max(ldot, 0.0), u_matspecular.a) : 1.0;\n");
p.C(" }\n");
p.F(" diffuse = (u_lightdiffuse%s * diffuseColor) * max(ldot, 0.0);\n", iStr);
p.C(" if (comp == 0x1u && ldot > 0.0) {\n"); // do specular
p.C(" if (comp == 0x1u && ldot >= 0.0) {\n"); // do specular. note - must allow for the >= case, since the u_matspecular.a <= 0.0 case relies on it.
p.C(" if (u_matspecular.a > 0.0) {\n");
p.C(" ldot = dot(normalize(toLight + vec3(0.0, 0.0, 1.0)), worldnormal);\n");
p.C(" ldot = pow(max(ldot, 0.0), u_matspecular.a);\n");
Expand Down

0 comments on commit c6bbe49

Please sign in to comment.