From 3e2f5a3976a4d69fae4b41a1edf00e455e2f577a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Ko=C5=82odziejski?= Date: Sun, 4 Apr 2021 11:36:12 +0200 Subject: [PATCH] STARK: A bit improved spot light type. --- engines/stark/gfx/opengl.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/engines/stark/gfx/opengl.cpp b/engines/stark/gfx/opengl.cpp index 8c054e65b77..954a1d6d9d1 100644 --- a/engines/stark/gfx/opengl.cpp +++ b/engines/stark/gfx/opengl.cpp @@ -121,6 +121,7 @@ void OpenGLDriver::setupLights(const LightEntryArray &lights) { GLfloat lightDir[] = { 0.0f, 0.0f, -1.0f }; GLfloat cutoff = 180.0f; GLfloat spotExp = 0.0f; + GLfloat l_attenuation = 0.0f; GLfloat q_attenuation = 0.0f; Math::Vector4d worldPosition; @@ -135,12 +136,6 @@ void OpenGLDriver::setupLights(const LightEntryArray &lights) { Math::Vector3d eyeDirection = viewMatrixRot * worldDirection; eyeDirection.normalize(); - Math::Vector4d params; - params.x() = l->falloffNear; - params.y() = l->falloffFar; - params.z() = l->innerConeAngle.getCosine(); - params.w() = l->outerConeAngle.getCosine(); - glDisable(GL_LIGHT0 + i); switch (l->type) { case LightEntry::kPoint: @@ -167,13 +162,14 @@ void OpenGLDriver::setupLights(const LightEntryArray &lights) { lightPos[0] = (GLfloat)eyePosition.x(); lightPos[1] = (GLfloat)eyePosition.y(); lightPos[2] = (GLfloat)eyePosition.z(); - lightDir[0] = (GLfloat)eyeDirection.x(); - lightDir[1] = (GLfloat)eyeDirection.y(); - lightDir[2] = (GLfloat)eyeDirection.z(); + lightDir[0] = -(GLfloat)eyeDirection.x(); + lightDir[1] = -(GLfloat)eyeDirection.y(); + lightDir[2] = -(GLfloat)eyeDirection.z(); // FIXME - q_attenuation = 1.0f; - spotExp = 1.0f; - cutoff = 180.f; + l_attenuation = 0.0000001f; + q_attenuation = 0.0000001f; + //spotExp = 0.0f; + //cutoff = (l->outerConeAngle.getDegrees() + l->innerConeAngle.getDegrees()) / 2.0f; break; case LightEntry::kAmbient: ambientColor[0] = (GLfloat)l->color.x(); @@ -190,6 +186,7 @@ void OpenGLDriver::setupLights(const LightEntryArray &lights) { glLightfv(GL_LIGHT0 + i, GL_SPOT_DIRECTION, lightDir); glLightf(GL_LIGHT0 + i, GL_SPOT_EXPONENT, spotExp); glLightf(GL_LIGHT0 + i, GL_SPOT_CUTOFF, cutoff); + glLightf(GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, l_attenuation); glLightf(GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, q_attenuation); glEnable(GL_LIGHT0 + i); }