naomi2: use diffuse/specular color before light routing

fixes lion's jacket color and shun's face glitch (vf4)
This commit is contained in:
Flyinghead 2022-04-20 14:13:42 +02:00
parent aa6c9e2106
commit 50f5dabf4a
3 changed files with 36 additions and 43 deletions

View File

@ -222,7 +222,7 @@ void computeColors(inout float4 baseCol, inout float4 offsetCol, in int volIdx,
float diffuseAlpha = 0.f;
float specularAlpha = 0.f;
float3 reflectDir = reflect(normalize(position), normal);
const float BASE_FACTOR = 1.45f;
const float BASE_FACTOR = 2.0f;
for (int i = 0; i < lightCount; i++)
{
@ -268,9 +268,9 @@ void computeColors(inout float4 baseCol, inout float4 offsetCol, in int volIdx,
else
{
if ((routing & ROUTING_DIFF_TO_OFFSET) == 0)
diffuse += lightColor * factor;
diffuse += lightColor * factor * baseCol.rgb;
else
specular += lightColor * factor;
specular += lightColor * factor * baseCol.rgb;
}
}
if (light.diffuse_specular[2 + volIdx] == 1) // If light contributes to specular
@ -290,28 +290,26 @@ void computeColors(inout float4 baseCol, inout float4 offsetCol, in int volIdx,
else
{
if ((routing & ROUTING_SPEC_TO_OFFSET) == 0)
diffuse += lightColor * factor;
diffuse += lightColor * factor * offsetCol.rgb;
else
specular += lightColor * factor;
specular += lightColor * factor * offsetCol.rgb;
}
}
}
// ambient with material
// ambient light
if (ambientMaterial[volIdx] == 1)
diffuse += ambientBase[volIdx].rgb * baseCol.rgb;
else
diffuse += ambientBase[volIdx].rgb;
if (ambientMaterial[volIdx + 2] == 1)
specular += ambientOffset[volIdx].rgb * offsetCol.rgb;
else
specular += ambientOffset[volIdx].rgb;
if (model_diff_spec[volIdx] == 1)
baseCol.rgb *= diffuse;
baseCol.rgb = diffuse;
if (model_diff_spec[volIdx + 2] == 1)
offsetCol.rgb *= specular;
// ambient w/o material
if (ambientMaterial[volIdx] == 0 && model_diff_spec[volIdx] == 1)
baseCol.rgb += ambientBase[volIdx].rgb;
if (ambientMaterial[volIdx + 2] == 0 && model_diff_spec[volIdx + 2] == 1)
offsetCol.rgb += ambientOffset[volIdx].rgb;
offsetCol.rgb = specular;
baseCol.a += diffuseAlpha;
offsetCol.a += specularAlpha;

View File

@ -195,7 +195,7 @@ void computeColors(inout vec4 baseCol, inout vec4 offsetCol, int volIdx, vec3 po
float diffuseAlpha = 0.0;
float specularAlpha = 0.0;
vec3 reflectDir = reflect(normalize(position), normal);
const float BASE_FACTOR = 1.45;
const float BASE_FACTOR = 2.0;
for (int i = 0; i < lightCount; i++)
{
@ -235,9 +235,9 @@ void computeColors(inout vec4 baseCol, inout vec4 offsetCol, int volIdx, vec3 po
else
{
if ((lights[i].routing & ROUTING_DIFF_TO_OFFSET) == 0)
diffuse += lightColor * factor;
diffuse += lightColor * factor * baseCol.rgb;
else
specular += lightColor * factor;
specular += lightColor * factor * baseCol.rgb;
}
}
if (lights[i].specular[volIdx] == 1)
@ -253,28 +253,26 @@ void computeColors(inout vec4 baseCol, inout vec4 offsetCol, int volIdx, vec3 po
else
{
if ((lights[i].routing & ROUTING_SPEC_TO_OFFSET) == 0)
diffuse += lightColor * factor;
diffuse += lightColor * factor * offsetCol.rgb;
else
specular += lightColor * factor;
specular += lightColor * factor * offsetCol.rgb;
}
}
}
// ambient with material
// ambient light
if (ambientMaterialBase[volIdx] == 1)
diffuse += ambientBase[volIdx].rgb * baseCol.rgb;
else
diffuse += ambientBase[volIdx].rgb;
if (ambientMaterialOffset[volIdx] == 1)
specular += ambientOffset[volIdx].rgb * offsetCol.rgb;
else
specular += ambientOffset[volIdx].rgb;
if (modelDiffuse[volIdx] == 1)
baseCol.rgb *= diffuse;
baseCol.rgb = diffuse;
if (modelSpecular[volIdx] == 1)
offsetCol.rgb *= specular;
// ambient w/o material
if (ambientMaterialBase[volIdx] == 0 && modelDiffuse[volIdx] == 1)
baseCol.rgb += ambientBase[volIdx].rgb;
if (ambientMaterialOffset[volIdx] == 0 && modelSpecular[volIdx] == 1)
offsetCol.rgb += ambientOffset[volIdx].rgb;
offsetCol.rgb = specular;
baseCol.a += diffuseAlpha;
offsetCol.a += specularAlpha;

View File

@ -405,7 +405,7 @@ void computeColors(inout vec4 baseCol, inout vec4 offsetCol, in int volIdx, in v
float diffuseAlpha = 0.0;
float specularAlpha = 0.0;
vec3 reflectDir = reflect(normalize(position), normal);
const float BASE_FACTOR = 1.45;
const float BASE_FACTOR = 2.0;
for (int i = 0; i < n2Lights.lightCount; i++)
{
@ -445,9 +445,9 @@ void computeColors(inout vec4 baseCol, inout vec4 offsetCol, in int volIdx, in v
else
{
if ((n2Lights.lights[i].routing & ROUTING_DIFF_TO_OFFSET) == 0)
diffuse += lightColor * factor;
diffuse += lightColor * factor * baseCol.rgb;
else
specular += lightColor * factor;
specular += lightColor * factor * baseCol.rgb;
}
}
if (n2Lights.lights[i].specular[volIdx] == 1)
@ -463,28 +463,25 @@ void computeColors(inout vec4 baseCol, inout vec4 offsetCol, in int volIdx, in v
else
{
if ((n2Lights.lights[i].routing & ROUTING_SPEC_TO_OFFSET) == 0)
diffuse += lightColor * factor;
diffuse += lightColor * factor * offsetCol.rgb;
else
specular += lightColor * factor;
specular += lightColor * factor * offsetCol.rgb;
}
}
}
// ambient with material
// ambient light
if (n2Lights.ambientMaterialBase[volIdx] == 1)
diffuse += n2Lights.ambientBase[volIdx].rgb * baseCol.rgb;
else
diffuse += n2Lights.ambientBase[volIdx].rgb;
if (n2Lights.ambientMaterialOffset[volIdx] == 1)
specular += n2Lights.ambientOffset[volIdx].rgb * offsetCol.rgb;
else
specular += n2Lights.ambientOffset[volIdx].rgb;
if (n2Uniform.modelDiffuse[volIdx] == 1)
baseCol.rgb *= diffuse;
baseCol.rgb = diffuse;
if (n2Uniform.modelSpecular[volIdx] == 1)
offsetCol.rgb *= specular;
// ambient w/o material
if (n2Lights.ambientMaterialBase[volIdx] == 0 && n2Uniform.modelDiffuse[volIdx] == 1)
baseCol.rgb += n2Lights.ambientBase[volIdx].rgb;
if (n2Lights.ambientMaterialOffset[volIdx] == 0 && n2Uniform.modelSpecular[volIdx] == 1)
offsetCol.rgb += n2Lights.ambientOffset[volIdx].rgb;
offsetCol.rgb = specular;
baseCol.a += diffuseAlpha;
offsetCol.a += specularAlpha;