LightingShader: hard code const variable

This commit is contained in:
degasus
2014-05-30 16:17:30 +02:00
parent e456a5e64f
commit 924ad1ee9f
9 changed files with 133 additions and 105 deletions

View File

@ -251,29 +251,40 @@ void VertexShaderManager::SetConstants()
for (int i = istart; i < iend; ++i)
{
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
constants.light_colors[i][0] = light.color[3];
constants.light_colors[i][1] = light.color[2];
constants.light_colors[i][2] = light.color[1];
constants.light_colors[i][3] = light.color[0];
const float* xfmemptr = light.cosatt;
dstlight.color[0] = light.color[3];
dstlight.color[1] = light.color[2];
dstlight.color[2] = light.color[1];
dstlight.color[3] = light.color[0];
for (int j = 0; j < 4; ++j, xfmemptr += 3)
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;