Skip to content

Commit

Permalink
SoftGPU: Normalize 0,0,0 as 0,0,1 for shade map.
Browse files Browse the repository at this point in the history
Takes care of #4155 for software rendering.
  • Loading branch information
unknownbrackets committed Nov 18, 2018
1 parent 6600896 commit 986371c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion GPU/Software/Lighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ void Process(VertexData& vertex, bool hasColor)
// TODO: Not sure if this really should be done even if lighting is disabled altogether
if (gstate.getUVGenMode() == GE_TEXMAP_ENVIRONMENT_MAP) {
Vec3<float> L = Vec3<float>(getFloat24(gstate.lpos[3 * light]), getFloat24(gstate.lpos[3 * light + 1]),getFloat24(gstate.lpos[3 * light + 2]));
float diffuse_factor = Dot(L.Normalized(), vertex.worldnormal);
// In other words, L.Length() == 0.0f means Dot({0, 0, 1}, worldnormal).
float diffuse_factor = L.Length() == 0.0f ? vertex.worldnormal.z : Dot(L.Normalized(), vertex.worldnormal);

if (gstate.getUVLS0() == (int)light)
vertex.texturecoords.s() = (diffuse_factor + 1.f) / 2.f;
Expand Down

0 comments on commit 986371c

Please sign in to comment.