diff options
| author | degasus <wickmarkus@web.de> | 2014-06-27 10:40:45 +0200 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2014-07-03 21:08:19 +0200 |
| commit | 02ac5e95c84a1d9a46df1dc4102342fb653e36ee (patch) | |
| tree | 552ed4564156d75c0e4491a12029303cb3e09d10 /Source/Core/VideoCommon/VertexShaderManager.cpp | |
| parent | be1fe80bb63ff98dab206b8ac3a7f1924042d814 (diff) | |
VideoCommon: normalize lighting direction.
It seems that the lighting direction must be normalized. This fixes lots of lighting issues mostly shown in the d3d backend.
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderManager.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index b09ff4d32a..6e419a3313 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -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; |
