Fixed vertex lighting broken since last spot light changes

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7981 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent 2d2ce703d9
commit 20f5e9d200
  1. 6
      engine/src/core-data/Common/MatDefs/Light/Lighting.frag
  2. 10
      engine/src/core-data/Common/MatDefs/Light/Lighting.vert

@ -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;

@ -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);
vec3 spotdir = normalize(g_LightDirection.xyz);
float curAngleCos = dot(-L, spotdir);
float innerAngleCos = spotVec.w;
float outerAngleCos = lightVec.w;
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);
}

Loading…
Cancel
Save