OpenGL2: Clamp entity lighting to more resemble OpenGL1.

This commit is contained in:
SmileTheory 2016-09-14 04:19:46 -07:00
parent 8749d62bbd
commit 8417c184b4
1 changed files with 32 additions and 6 deletions

View File

@ -385,16 +385,42 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) {
VectorMA( lightDir, d, dir, lightDir ); VectorMA( lightDir, d, dir, lightDir );
} }
// clamp ambient // clamp lights
if ( !r_hdr->integer ) // FIXME: old renderer clamps (ambient + NL * directed) per vertex
// check if that's worth implementing
{ {
for ( i = 0 ; i < 3 ; i++ ) { float r, g, b, max;
if ( ent->ambientLight[i] > tr.identityLightByte ) {
ent->ambientLight[i] = tr.identityLightByte; r = ent->ambientLight[0];
} g = ent->ambientLight[1];
b = ent->ambientLight[2];
max = MAX(MAX(r, g), b);
if (max > 255.0f)
{
max = 255.0f / max;
ent->ambientLight[0] *= max;
ent->ambientLight[1] *= max;
ent->ambientLight[2] *= max;
}
r = ent->directedLight[0];
g = ent->directedLight[1];
b = ent->directedLight[2];
max = MAX(MAX(r, g), b);
if (max > 255.0f)
{
max = 255.0f / max;
ent->directedLight[0] *= max;
ent->directedLight[1] *= max;
ent->directedLight[2] *= max;
} }
} }
if ( r_debugLight->integer ) { if ( r_debugLight->integer ) {
LogLight( ent ); LogLight( ent );
} }