diff --git a/engine/src/core-data/Common/MatDefs/Light/Lighting.frag b/engine/src/core-data/Common/MatDefs/Light/Lighting.frag index 0c50b072c..ee0216dd6 100644 --- a/engine/src/core-data/Common/MatDefs/Light/Lighting.frag +++ b/engine/src/core-data/Common/MatDefs/Light/Lighting.frag @@ -2,7 +2,7 @@ #define ATTENUATION //#define HQ_ATTENUATION -uniform vec4 g_LightDirection; + varying vec2 texCoord; #ifdef SEPARATE_TEXCOORD varying vec2 texCoord2; @@ -13,9 +13,11 @@ varying vec4 DiffuseSum; varying vec3 SpecularSum; #ifndef VERTEX_LIGHTING + uniform vec4 g_LightDirection; varying vec3 vPosition; varying vec3 vViewDir; varying vec4 vLightDir; + varying vec3 lightVec; #else varying vec2 vertexLightValues; #endif @@ -51,7 +53,7 @@ varying vec3 SpecularSum; #endif uniform float m_AlphaDiscardThreshold; -varying vec3 lightVec; + #ifndef VERTEX_LIGHTING uniform float m_Shininess; diff --git a/engine/src/core-data/Common/MatDefs/Light/Lighting.vert b/engine/src/core-data/Common/MatDefs/Light/Lighting.vert index 031633efe..238ffd21c 100644 --- a/engine/src/core-data/Common/MatDefs/Light/Lighting.vert +++ b/engine/src/core-data/Common/MatDefs/Light/Lighting.vert @@ -13,7 +13,6 @@ uniform float m_Shininess; uniform vec4 g_LightColor; uniform vec4 g_LightPosition; -//uniform vec4 g_LightDirection; uniform vec4 g_AmbientLightColor; varying vec2 texCoord; @@ -48,6 +47,7 @@ varying vec3 lightVec; varying vec4 vLightDir; #else varying vec2 vertexLightValues; + uniform vec4 g_LightDirection; #endif #ifdef USE_REFLECTION @@ -114,12 +114,12 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec4 w vec4 lightDir; lightComputeDir(wvPos, g_LightColor, wvLightPos, lightDir); float spotFallOff = 1.0; - if(spotVec.w != 0.0){ + if(g_LightDirection.w != 0.0){ vec3 L=normalize(lightVec.xyz); - vec3 spotdir = normalize(spotVec.xyz); - float curAngleCos = dot(-L, spotdir); - float innerAngleCos = spotVec.w; - float outerAngleCos = lightVec.w; + vec3 spotdir = normalize(g_LightDirection.xyz); + float curAngleCos = dot(-L, spotdir); + float innerAngleCos = floor(g_LightDirection.w) * 0.001; + float outerAngleCos = fract(g_LightDirection.w); float innerMinusOuter = innerAngleCos - outerAngleCos; spotFallOff = clamp((curAngleCos - outerAngleCos) / innerMinusOuter, 0.0, 1.0); }