Model lighting

This commit is contained in:
Jaime Passos 2019-12-12 17:48:29 -03:00
parent 9246526e8a
commit a4b0195430
2 changed files with 28 additions and 14 deletions

View file

@ -6539,6 +6539,7 @@ static void HWR_FoggingOn(void)
static CV_PossibleValue_t grsoftwarefog_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "LightPlanes"}, {0, NULL}};
static CV_PossibleValue_t grmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Sometimes"}, {2, "Always"}, {0, NULL}};
static void CV_grmodellighting_OnChange(void);
static void CV_grfiltermode_OnChange(void);
static void CV_granisotropic_OnChange(void);
static void CV_grfogdensity_OnChange(void);
@ -6567,6 +6568,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_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_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grskydome = {"gr_skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@ -6584,6 +6586,12 @@ consvar_t cv_granisotropicmode = {"gr_anisotropicmode", "1", CV_SAVE|CV_CALL, gr
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};
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)
{
if (rendermode == render_opengl)
@ -6626,8 +6634,10 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_grcoronas);
#endif
CV_RegisterVar(&cv_grmodellighting);
CV_RegisterVar(&cv_grmodelinterpolation);
CV_RegisterVar(&cv_grmodels);
CV_RegisterVar(&cv_grskydome);
CV_RegisterVar(&cv_grspritebillboarding);

View file

@ -85,6 +85,7 @@ static GLboolean MipMap = GL_FALSE;
static GLint min_filter = GL_LINEAR;
static GLint mag_filter = GL_LINEAR;
static GLint anisotropic_filter = 0;
static boolean model_lighting = true;
const GLubyte *gl_extensions = NULL;
@ -1658,16 +1659,9 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
{
switch (IdState)
{
#if 0
case 77:
{
//08/01/00: Hurdler this is a test for mirror
if (!Value)
ClearBuffer(false, true, 0); // clear depth buffer
case HWD_SET_MODEL_LIGHTING:
model_lighting = Value;
break;
}
#endif
case HWD_SET_FOG_COLOR:
{
@ -1680,6 +1674,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
pglFogfv(GL_FOG_COLOR, fogcolor);
break;
}
case HWD_SET_FOG_DENSITY:
pglFogf(GL_FOG_DENSITY, Value*1200/(500*1000000.0f));
break;
@ -2044,16 +2039,25 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
}
#endif
pglLightfv(GL_LIGHT0, GL_POSITION, LightPos);
if (model_lighting)
{
pglLightfv(GL_LIGHT0, GL_POSITION, LightPos);
pglShadeModel(GL_SMOOTH);
}
pglShadeModel(GL_SMOOTH);
if (color)
{
#ifdef GL_LIGHT_MODEL_AMBIENT
pglEnable(GL_LIGHTING);
pglMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
pglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
if (model_lighting)
{
pglEnable(GL_LIGHTING);
pglMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
pglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
}
else
#endif
pglColor4ubv((GLubyte*)color);
if (color[3] < 255)
SetBlend(PF_Translucent|PF_Modulated|PF_Clip);
else