Browse Source

ref: soft: adapt studio renderer to new gamma implementation

pull/2/head
Alibek Omarov 12 months ago
parent
commit
519c8a032a
  1. 66
      ref/soft/r_studio.c

66
ref/soft/r_studio.c

@ -107,7 +107,7 @@ typedef struct @@ -107,7 +107,7 @@ typedef struct
int numlocallights;
int lightage[MAXSTUDIOBONES];
dlight_t *locallight[MAX_LOCALLIGHTS];
color24 locallightcolor[MAX_LOCALLIGHTS];
uint locallightcolor[MAX_LOCALLIGHTS][3];
vec4_t lightpos[MAXSTUDIOVERTS][MAX_LOCALLIGHTS];
vec3_t lightbonepos[MAXSTUDIOBONES][MAX_LOCALLIGHTS];
float locallightR2[MAX_LOCALLIGHTS];
@ -1377,13 +1377,13 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight ) @@ -1377,13 +1377,13 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
{
VectorSet( lightDir, mv->skyvec_x, mv->skyvec_y, mv->skyvec_z );
light.r = gEngfuncs.LightToTexGamma( bound( 0, mv->skycolor_r, 255 ));
light.g = gEngfuncs.LightToTexGamma( bound( 0, mv->skycolor_g, 255 ));
light.b = gEngfuncs.LightToTexGamma( bound( 0, mv->skycolor_b, 255 ));
light.r = mv->skycolor_r;
light.g = mv->skycolor_g;
light.b = mv->skycolor_b;
}
}
if(( light.r + light.g + light.b ) < 16 ) // TESTTEST
if(( light.r + light.g + light.b ) == 0 )
{
colorVec gcolor;
float grad[4];
@ -1431,6 +1431,13 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight ) @@ -1431,6 +1431,13 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
}
}
if( ent->curstate.renderfx == kRenderFxLightMultiplier && ent->curstate.iuser4 != 10 )
{
light.r *= ent->curstate.iuser4 / 10.0f;
light.g *= ent->curstate.iuser4 / 10.0f;
light.b *= ent->curstate.iuser4 / 10.0f;
}
VectorSet( finalLight, light.r, light.g, light.b );
ent->cvFloorColor = light;
@ -1462,15 +1469,15 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight ) @@ -1462,15 +1469,15 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
VectorAdd( lightDir, dist, lightDir );
finalLight[0] += gEngfuncs.LightToTexGamma( dl->color.r ) * ( add / 256.0f ) * 2.0f;
finalLight[1] += gEngfuncs.LightToTexGamma( dl->color.g ) * ( add / 256.0f ) * 2.0f;
finalLight[2] += gEngfuncs.LightToTexGamma( dl->color.b ) * ( add / 256.0f ) * 2.0f;
finalLight[0] += dl->color.r * ( add / 256.0f );
finalLight[1] += dl->color.g * ( add / 256.0f );
finalLight[2] += dl->color.b * ( add / 256.0f );
}
}
if( FBitSet( ent->model->flags, STUDIO_AMBIENT_LIGHT ))
add = 0.6f;
else add = 0.9f;
else add = bound( 0.75f, v_direct->value, 1.0f );
VectorScale( lightDir, add, lightDir );
@ -1564,9 +1571,9 @@ void R_StudioEntityLight( alight_t *lightinfo ) @@ -1564,9 +1571,9 @@ void R_StudioEntityLight( alight_t *lightinfo )
if( k != -1 )
{
g_studio.locallightcolor[k].r = gEngfuncs.LightToTexGamma( el->color.r );
g_studio.locallightcolor[k].g = gEngfuncs.LightToTexGamma( el->color.g );
g_studio.locallightcolor[k].b = gEngfuncs.LightToTexGamma( el->color.b );
g_studio.locallightcolor[k][0] = gEngfuncs.LinearGammaTable( el->color.r << 2 );
g_studio.locallightcolor[k][1] = gEngfuncs.LinearGammaTable( el->color.g << 2 );
g_studio.locallightcolor[k][2] = gEngfuncs.LinearGammaTable( el->color.b << 2 );
g_studio.locallightR2[k] = r2;
g_studio.locallight[k] = el;
lstrength[k] = minstrength;
@ -1642,7 +1649,7 @@ void R_StudioLighting( float *lv, int bone, int flags, vec3_t normal ) @@ -1642,7 +1649,7 @@ void R_StudioLighting( float *lv, int bone, int flags, vec3_t normal )
r = SHADE_LAMBERT;
// do modified hemispherical lighting
// do modified hemispherical lighting
if( r <= 1.0f )
{
r += 1.0f;
@ -1661,7 +1668,8 @@ void R_StudioLighting( float *lv, int bone, int flags, vec3_t normal ) @@ -1661,7 +1668,8 @@ void R_StudioLighting( float *lv, int bone, int flags, vec3_t normal )
}
illum = Q_min( illum, 255.0f );
*lv = illum * (1.0f / 255.0f);
*lv = gEngfuncs.LightToTexGammaEx( illum * 4 ) / 1023.0f;
}
/*
@ -1681,11 +1689,11 @@ static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal, @@ -1681,11 +1689,11 @@ static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal,
return;
}
VectorCopy( color, finalLight );
VectorSet( finalLight, 0, 0, 0 );
for( i = 0; i < g_studio.numlocallights; i++ )
{
float r;
float r;
r = DotProduct( normal, light[i] );
if( likely( !tr.fFlipViewModel ))
@ -1705,21 +1713,29 @@ static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal, @@ -1705,21 +1713,29 @@ static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal,
else light[i][3] = 0.0001f;
}
temp = Q_min( r * light[i][3] / 255.0f, 1.0f );
localLight[0] = (float)g_studio.locallightcolor[i].r * temp;
localLight[1] = (float)g_studio.locallightcolor[i].g * temp;
localLight[2] = (float)g_studio.locallightcolor[i].b * temp;
temp = r * light[i][3];
VectorAddScalar( g_studio.locallightcolor[i], temp, localLight );
VectorAdd( finalLight, localLight, finalLight );
}
}
VectorScale( finalLight, 255.0f, finalLight );
if( !VectorIsNull( finalLight ))
{
for( i = 0; i < 3; i++ )
{
float c = finalLight[i] + gEngfuncs.LinearGammaTable( color[i] * 1023.0f );
out[0] = Q_min( (int)( finalLight[0] ), 255 );
out[1] = Q_min( (int)( finalLight[1] ), 255 );
out[2] = Q_min( (int)( finalLight[2] ), 255 );
if( c > 1023.0f )
out[i] = 255;
else
out[i] = gEngfuncs.ScreenGammaTable( c ) >> 2;
}
}
else
{
VectorScale( color, 255.0f, out );
}
}
static void R_StudioSetColorBegin(short *ptricmds, vec3_t *pstudionorms )

Loading…
Cancel
Save