Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #394 from degasus/d3d_lighting_fix
VideoCommon: normalize light direction
  • Loading branch information
delroth committed Aug 4, 2014
2 parents 4c42b38 + 02ac5e9 commit 15920d0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Source/Core/VideoCommon/VertexShaderManager.cpp
Expand Up @@ -281,10 +281,13 @@ void VertexShaderManager::SetConstants()
dstlight.pos[1] = light.dpos[1];
dstlight.pos[2] = light.dpos[2];

// TODO: these likely have to be normalized
dstlight.dir[0] = light.ddir[0];
dstlight.dir[1] = light.ddir[1];
dstlight.dir[2] = light.ddir[2];
double norm = double(light.ddir[0]) * double(light.ddir[0]) +
double(light.ddir[1]) * double(light.ddir[1]) +
double(light.ddir[2]) * double(light.ddir[2]);
norm = 1.0 / sqrt(norm);
dstlight.dir[0] = light.ddir[0] * norm;
dstlight.dir[1] = light.ddir[1] * norm;
dstlight.dir[2] = light.ddir[2] * norm;
}
dirty = true;

Expand Down

0 comments on commit 15920d0

Please sign in to comment.