GRIM: Disable specular lighting.

My initial idea that GRIM would use specular likely came from a difference
between DirectX and OpenGL lighting for spotlights: DirectX allows for an
extra penumbra angle, allowing stronger center spots while maintaining a
smooth fade (which I emulated with a fixed 2.0 exponent).
Also, specular involves an extra light color value and material definition
for specular reflection, which are not visible in game data files.
All this making the use of specular very unlikely to match original renderer.
This commit is contained in:
Vincent Pelletier 2015-03-15 22:02:26 +01:00
parent a518480359
commit 6e996d145b

View file

@ -158,8 +158,6 @@ byte *GfxOpenGL::setupScreen(int screenW, int screenH, bool fullscreen) {
GLfloat ambientSource[] = { 0.0f, 0.0f, 0.0f, 1.0f };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientSource);
GLfloat specularReflectance[] = { 0.3f, 0.3f, 0.3f, 1.0f };
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specularReflectance);
if (g_grim->getGameType() == GType_GRIM) {
glPolygonOffset(-6.0, -6.0);
@ -970,17 +968,16 @@ void GfxOpenGL::setupLight(Light *light, int lightId) {
}
glEnable(GL_LIGHTING);
GLfloat diffuse[] = { 0.0f, 0.0f, 0.0f, 1.0f };
GLfloat specular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
GLfloat lightColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
GLfloat lightPos[] = { 0.0f, 0.0f, 0.0f, 1.0f };
GLfloat lightDir[] = { 0.0f, 0.0f, -1.0f };
GLfloat cutoff = 180.0f;
GLfloat spot_exp = 0.0f;
GLfloat intensity = light->_intensity;
diffuse[0] = ((GLfloat)light->_color.getRed() / 15.0f) * intensity;
diffuse[1] = ((GLfloat)light->_color.getGreen() / 15.0f) * intensity;
diffuse[2] = ((GLfloat)light->_color.getBlue() / 15.0f) * intensity;
lightColor[0] = ((GLfloat)light->_color.getRed() / 15.0f) * intensity;
lightColor[1] = ((GLfloat)light->_color.getGreen() / 15.0f) * intensity;
lightColor[2] = ((GLfloat)light->_color.getBlue() / 15.0f) * intensity;
if (light->_type == Light::Omni) {
lightPos[0] = light->_pos.x();
@ -998,16 +995,12 @@ void GfxOpenGL::setupLight(Light *light, int lightId) {
lightDir[0] = light->_dir.x();
lightDir[1] = light->_dir.y();
lightDir[2] = light->_dir.z();
specular[0] = diffuse[0];
specular[1] = diffuse[1];
specular[2] = diffuse[2];
spot_exp = 2.0f;
cutoff = light->_penumbraangle;
}
glDisable(GL_LIGHT0 + lightId);
glLightfv(GL_LIGHT0 + lightId, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0 + lightId, GL_SPECULAR, specular);
glLightfv(GL_LIGHT0 + lightId, GL_DIFFUSE, lightColor);
glLightfv(GL_LIGHT0 + lightId, GL_POSITION, lightPos);
glLightfv(GL_LIGHT0 + lightId, GL_SPOT_DIRECTION, lightDir);
glLightf(GL_LIGHT0 + lightId, GL_SPOT_EXPONENT, spot_exp);