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 ATTENUATION
//#define HQ_ATTENUATION //#define HQ_ATTENUATION
uniform vec4 g_LightDirection;
varying vec2 texCoord; varying vec2 texCoord;
#ifdef SEPARATE_TEXCOORD #ifdef SEPARATE_TEXCOORD
varying vec2 texCoord2; varying vec2 texCoord2;
@ -13,9 +13,11 @@ varying vec4 DiffuseSum;
varying vec3 SpecularSum; varying vec3 SpecularSum;
#ifndef VERTEX_LIGHTING #ifndef VERTEX_LIGHTING
uniform vec4 g_LightDirection;
varying vec3 vPosition; varying vec3 vPosition;
varying vec3 vViewDir; varying vec3 vViewDir;
varying vec4 vLightDir; varying vec4 vLightDir;
varying vec3 lightVec;
#else #else
varying vec2 vertexLightValues; varying vec2 vertexLightValues;
#endif #endif
@ -51,7 +53,7 @@ varying vec3 SpecularSum;
#endif #endif
uniform float m_AlphaDiscardThreshold; uniform float m_AlphaDiscardThreshold;
varying vec3 lightVec;
#ifndef VERTEX_LIGHTING #ifndef VERTEX_LIGHTING
uniform float m_Shininess; uniform float m_Shininess;

@ -13,7 +13,6 @@ uniform float m_Shininess;
uniform vec4 g_LightColor; uniform vec4 g_LightColor;
uniform vec4 g_LightPosition; uniform vec4 g_LightPosition;
//uniform vec4 g_LightDirection;
uniform vec4 g_AmbientLightColor; uniform vec4 g_AmbientLightColor;
varying vec2 texCoord; varying vec2 texCoord;
@ -48,6 +47,7 @@ varying vec3 lightVec;
varying vec4 vLightDir; varying vec4 vLightDir;
#else #else
varying vec2 vertexLightValues; varying vec2 vertexLightValues;
uniform vec4 g_LightDirection;
#endif #endif
#ifdef USE_REFLECTION #ifdef USE_REFLECTION
@ -114,12 +114,12 @@ vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec4 w
vec4 lightDir; vec4 lightDir;
lightComputeDir(wvPos, g_LightColor, wvLightPos, lightDir); lightComputeDir(wvPos, g_LightColor, wvLightPos, lightDir);
float spotFallOff = 1.0; float spotFallOff = 1.0;
if(spotVec.w != 0.0){ if(g_LightDirection.w != 0.0){
vec3 L=normalize(lightVec.xyz); vec3 L=normalize(lightVec.xyz);
vec3 spotdir = normalize(spotVec.xyz); vec3 spotdir = normalize(g_LightDirection.xyz);
float curAngleCos = dot(-L, spotdir); float curAngleCos = dot(-L, spotdir);
float innerAngleCos = spotVec.w; float innerAngleCos = floor(g_LightDirection.w) * 0.001;
float outerAngleCos = lightVec.w; float outerAngleCos = fract(g_LightDirection.w);
float innerMinusOuter = innerAngleCos - outerAngleCos; float innerMinusOuter = innerAngleCos - outerAngleCos;
spotFallOff = clamp((curAngleCos - outerAngleCos) / innerMinusOuter, 0.0, 1.0); spotFallOff = clamp((curAngleCos - outerAngleCos) / innerMinusOuter, 0.0, 1.0);
} }

Loading…
Cancel
Save