mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Restore some model lighting code that went gone in the shaders code
This commit is contained in:
parent
5d3d031db3
commit
33152ee6fa
2 changed files with 49 additions and 19 deletions
|
|
@ -4908,6 +4908,7 @@ static void HWR_DrawSprites(void)
|
||||||
if (gr_visspritecount > 0)
|
if (gr_visspritecount > 0)
|
||||||
{
|
{
|
||||||
gr_vissprite_t *spr;
|
gr_vissprite_t *spr;
|
||||||
|
HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, cv_grmodellighting.value);
|
||||||
|
|
||||||
// draw all vissprites back to front
|
// draw all vissprites back to front
|
||||||
for (spr = gr_vsprsortedhead.next;
|
for (spr = gr_vsprsortedhead.next;
|
||||||
|
|
@ -4947,6 +4948,8 @@ static void HWR_DrawSprites(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6116,7 +6119,6 @@ static CV_PossibleValue_t grsoftwarefog_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "
|
||||||
static CV_PossibleValue_t grmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Sometimes"}, {2, "Always"}, {0, NULL}};
|
static CV_PossibleValue_t grmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Sometimes"}, {2, "Always"}, {0, NULL}};
|
||||||
static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}};
|
static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}};
|
||||||
|
|
||||||
static void CV_grmodellighting_OnChange(void);
|
|
||||||
static void CV_grfiltermode_OnChange(void);
|
static void CV_grfiltermode_OnChange(void);
|
||||||
static void CV_granisotropic_OnChange(void);
|
static void CV_granisotropic_OnChange(void);
|
||||||
static void CV_grfogdensity_OnChange(void);
|
static void CV_grfogdensity_OnChange(void);
|
||||||
|
|
@ -6144,7 +6146,7 @@ consvar_t cv_grcoronasize = {"gr_coronasize", "1", CV_SAVE|CV_FLOAT, 0, NULL, 0,
|
||||||
|
|
||||||
consvar_t cv_grmodels = {"gr_models", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_grmodels = {"gr_models", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_grmodelinterpolation = {"gr_modelinterpolation", "Sometimes", CV_SAVE, grmodelinterpolation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_grmodelinterpolation = {"gr_modelinterpolation", "Sometimes", CV_SAVE, grmodelinterpolation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_grmodellighting = {"gr_modellighting", "Off", CV_SAVE|CV_CALL, CV_OnOff, CV_grmodellighting_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_grmodellighting = {"gr_modellighting", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
consvar_t cv_grshearing = {"gr_shearing", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_grshearing = {"gr_shearing", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
@ -6164,12 +6166,6 @@ consvar_t cv_granisotropicmode = {"gr_anisotropicmode", "1", CV_CALL, granisotro
|
||||||
consvar_t cv_grcorrecttricks = {"gr_correcttricks", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_grcorrecttricks = {"gr_correcttricks", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
static void CV_grmodellighting_OnChange(void)
|
|
||||||
{
|
|
||||||
if (rendermode == render_opengl)
|
|
||||||
HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, cv_grmodellighting.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CV_grfogdensity_OnChange(void)
|
static void CV_grfogdensity_OnChange(void)
|
||||||
{
|
{
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
|
|
@ -6272,7 +6268,6 @@ void HWR_Startup(void)
|
||||||
void HWR_Switch(void)
|
void HWR_Switch(void)
|
||||||
{
|
{
|
||||||
// Set special states from CVARs
|
// Set special states from CVARs
|
||||||
HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, cv_grmodellighting.value);
|
|
||||||
HWD.pfnSetSpecialState(HWD_SET_FOG_DENSITY, cv_grfogdensity.value);
|
HWD.pfnSetSpecialState(HWD_SET_FOG_DENSITY, cv_grfogdensity.value);
|
||||||
HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_grfiltermode.value);
|
HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_grfiltermode.value);
|
||||||
HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_granisotropicmode.value);
|
HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_granisotropicmode.value);
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ static GLboolean MipMap = GL_FALSE;
|
||||||
static GLint min_filter = GL_LINEAR;
|
static GLint min_filter = GL_LINEAR;
|
||||||
static GLint mag_filter = GL_LINEAR;
|
static GLint mag_filter = GL_LINEAR;
|
||||||
static GLint anisotropic_filter = 0;
|
static GLint anisotropic_filter = 0;
|
||||||
static boolean model_lighting = true;
|
static boolean model_lighting = false;
|
||||||
|
|
||||||
const GLubyte *gl_version = NULL;
|
const GLubyte *gl_version = NULL;
|
||||||
const GLubyte *gl_renderer = NULL;
|
const GLubyte *gl_renderer = NULL;
|
||||||
|
|
@ -2583,8 +2583,12 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Because Otherwise, scaling the screen negatively vertically breaks the lighting
|
// Because otherwise, scaling the screen negatively vertically breaks the lighting
|
||||||
GLfloat LightPos[] = {0.0f, 1.0f, 0.0f, 0.0f};
|
GLfloat LightPos[] = {0.0f, 1.0f, 0.0f, 0.0f};
|
||||||
|
#ifdef GL_LIGHT_MODEL_AMBIENT
|
||||||
|
GLfloat ambient[4];
|
||||||
|
GLfloat diffuse[4];
|
||||||
|
#endif
|
||||||
|
|
||||||
// Affect input model scaling
|
// Affect input model scaling
|
||||||
scale *= 0.5f;
|
scale *= 0.5f;
|
||||||
|
|
@ -2610,10 +2614,39 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
|
||||||
poly.blue = byte2float[Surface->PolyColor.s.blue];
|
poly.blue = byte2float[Surface->PolyColor.s.blue];
|
||||||
poly.alpha = byte2float[Surface->PolyColor.s.alpha];
|
poly.alpha = byte2float[Surface->PolyColor.s.alpha];
|
||||||
|
|
||||||
SetBlend((poly.alpha < 1 ? PF_Translucent : (PF_Masked|PF_Occlude))|PF_Modulated);
|
#ifdef GL_LIGHT_MODEL_AMBIENT
|
||||||
|
if (model_lighting && (!gl_shadersenabled)) // doesn't work with shaders anyway
|
||||||
|
{
|
||||||
|
ambient[0] = poly.red;
|
||||||
|
ambient[1] = poly.green;
|
||||||
|
ambient[2] = poly.blue;
|
||||||
|
ambient[3] = poly.alpha;
|
||||||
|
|
||||||
|
diffuse[0] = poly.red;
|
||||||
|
diffuse[1] = poly.green;
|
||||||
|
diffuse[2] = poly.blue;
|
||||||
|
diffuse[3] = poly.alpha;
|
||||||
|
|
||||||
|
if (ambient[0] > 0.75f)
|
||||||
|
ambient[0] = 0.75f;
|
||||||
|
if (ambient[1] > 0.75f)
|
||||||
|
ambient[1] = 0.75f;
|
||||||
|
if (ambient[2] > 0.75f)
|
||||||
|
ambient[2] = 0.75f;
|
||||||
|
|
||||||
|
pglLightfv(GL_LIGHT0, GL_POSITION, LightPos);
|
||||||
|
pglShadeModel(GL_SMOOTH);
|
||||||
|
|
||||||
|
pglEnable(GL_LIGHTING);
|
||||||
|
pglMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
|
||||||
|
pglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else
|
||||||
pglColor4ubv((GLubyte*)&Surface->PolyColor.s);
|
pglColor4ubv((GLubyte*)&Surface->PolyColor.s);
|
||||||
|
|
||||||
|
SetBlend((poly.alpha < 1 ? PF_Translucent : (PF_Masked|PF_Occlude))|PF_Modulated);
|
||||||
|
|
||||||
tint.red = byte2float[Surface->TintColor.s.red];
|
tint.red = byte2float[Surface->TintColor.s.red];
|
||||||
tint.green = byte2float[Surface->TintColor.s.green];
|
tint.green = byte2float[Surface->TintColor.s.green];
|
||||||
tint.blue = byte2float[Surface->TintColor.s.blue];
|
tint.blue = byte2float[Surface->TintColor.s.blue];
|
||||||
|
|
@ -2653,12 +2686,6 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (model_lighting)
|
|
||||||
{
|
|
||||||
pglLightfv(GL_LIGHT0, GL_POSITION, LightPos);
|
|
||||||
pglShadeModel(GL_SMOOTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
pglPushMatrix(); // should be the same as glLoadIdentity
|
pglPushMatrix(); // should be the same as glLoadIdentity
|
||||||
//Hurdler: now it seems to work
|
//Hurdler: now it seems to work
|
||||||
pglTranslatef(pos->x, pos->z, pos->y);
|
pglTranslatef(pos->x, pos->z, pos->y);
|
||||||
|
|
@ -2798,6 +2825,14 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
|
||||||
pglDisable(GL_CULL_FACE);
|
pglDisable(GL_CULL_FACE);
|
||||||
pglDisable(GL_NORMALIZE);
|
pglDisable(GL_NORMALIZE);
|
||||||
|
|
||||||
|
#ifdef GL_LIGHT_MODEL_AMBIENT
|
||||||
|
if (model_lighting && (!gl_shadersenabled))
|
||||||
|
{
|
||||||
|
pglDisable(GL_LIGHTING);
|
||||||
|
pglShadeModel(GL_FLAT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef GL_SHADERS
|
#ifdef GL_SHADERS
|
||||||
pglUseProgram(0);
|
pglUseProgram(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue