diff options
| author | Tony Wasserka <neobrainx@gmail.com> | 2014-06-21 12:17:26 +0200 |
|---|---|---|
| committer | Tony Wasserka <neobrainx@gmail.com> | 2014-06-21 12:17:26 +0200 |
| commit | fbca397c924e3906e9ab26ec3f967760385cc8d6 (patch) | |
| tree | b8c94b60ef5805ae0d36919d3183c6b122d59f36 /Source/Core/VideoCommon/VertexShaderManager.cpp | |
| parent | ddadb4f29dc96b988a004bda43becb621fe2ac7d (diff) | |
| parent | 924ad1ee9ff7bfa19163082ca203961d65788253 (diff) | |
Merge pull request #439 from degasus/lighting-fix
Lighting cleanup
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderManager.cpp | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index ede4ddd9c7..b09ff4d32a 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -247,32 +247,44 @@ void VertexShaderManager::SetConstants() // lights don't have a 1 to 1 mapping, the color component needs to be converted to 4 floats int istart = nLightsChanged[0] / 0x10; int iend = (nLightsChanged[1] + 15) / 0x10; - const float* xfmemptr = (const float*)&xfmem.lights[0x10 * istart]; for (int i = istart; i < iend; ++i) { - u32 color = *(const u32*)(xfmemptr + 3); - constants.light_colors[i][0] = (color >> 24) & 0xFF; - constants.light_colors[i][1] = (color >> 16) & 0xFF; - constants.light_colors[i][2] = (color >> 8) & 0xFF; - constants.light_colors[i][3] = (color) & 0xFF; - xfmemptr += 4; - - for (int j = 0; j < 4; ++j, xfmemptr += 3) + const Light& light = xfmem.lights[i]; + VertexShaderConstants::Light& dstlight = constants.lights[i]; + + // xfmem.light.color is packed as abgr in u8[4], so we have to swap the order + dstlight.color[0] = light.color[3]; + dstlight.color[1] = light.color[2]; + dstlight.color[2] = light.color[1]; + dstlight.color[3] = light.color[0]; + + dstlight.cosatt[0] = light.cosatt[0]; + dstlight.cosatt[1] = light.cosatt[1]; + dstlight.cosatt[2] = light.cosatt[2]; + + if (fabs(light.distatt[0]) < 0.00001f && + fabs(light.distatt[1]) < 0.00001f && + fabs(light.distatt[2]) < 0.00001f) { - if (j == 1 && - fabs(xfmemptr[0]) < 0.00001f && - fabs(xfmemptr[1]) < 0.00001f && - fabs(xfmemptr[2]) < 0.00001f) - { - // dist attenuation, make sure not equal to 0!!! - constants.lights[4*i+j][0] = 0.00001f; - } - else - constants.lights[4*i+j][0] = xfmemptr[0]; - constants.lights[4*i+j][1] = xfmemptr[1]; - constants.lights[4*i+j][2] = xfmemptr[2]; + // dist attenuation, make sure not equal to 0!!! + dstlight.distatt[0] = .00001f; } + else + { + dstlight.distatt[0] = light.distatt[0]; + } + dstlight.distatt[1] = light.distatt[1]; + dstlight.distatt[2] = light.distatt[2]; + + dstlight.pos[0] = light.dpos[0]; + 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]; } dirty = true; |
