LightingShaderGen: Always calculate lighting for both color channels

Cel-damage uses the color from the lighting stage of the vertex pipeline
as texture coordinates, but sets numColorChans to zero.

We now calculate the colors in all cases, but override the color before
writing it from the vertex shader if numColorChans is set to a lower value.
This commit is contained in:
Stenzek
2017-11-21 18:54:11 +10:00
parent 18c1bf19ca
commit efb9759862
7 changed files with 38 additions and 29 deletions

View File

@ -79,9 +79,9 @@ static void GenerateLightShader(ShaderCode& object, const LightingUidData& uid_d
// inColorName is color in vs and colors_ in ps
// dest is o.colors_ in vs and colors_ in ps
void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data, int components,
u32 numColorChans, const char* inColorName, const char* dest)
const char* inColorName, const char* dest)
{
for (unsigned int j = 0; j < numColorChans; j++)
for (unsigned int j = 0; j < NUM_XF_COLOR_CHANNELS; j++)
{
object.Write("{\n");
@ -185,7 +185,7 @@ void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_d
void GetLightingShaderUid(LightingUidData& uid_data)
{
for (unsigned int j = 0; j < xfmem.numChan.numColorChans; j++)
for (unsigned int j = 0; j < NUM_XF_COLOR_CHANNELS; j++)
{
uid_data.matsource |= xfmem.color[j].matsource << j;
uid_data.matsource |= xfmem.alpha[j].matsource << (j + 2);