|
|
|
@ -14,7 +14,7 @@ varying vec3 SpecularSum; |
|
|
|
|
|
|
|
|
|
#ifndef VERTEX_LIGHTING |
|
|
|
|
uniform vec4 g_LightDirection; |
|
|
|
|
varying vec3 vPosition; |
|
|
|
|
//varying vec3 vPosition; |
|
|
|
|
varying vec3 vViewDir; |
|
|
|
|
varying vec4 vLightDir; |
|
|
|
|
varying vec3 lightVec; |
|
|
|
@ -116,7 +116,7 @@ float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in f |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 wvLightDir){ |
|
|
|
|
vec2 computeLighting(in vec3 wvNorm, in vec3 wvViewDir, in vec3 wvLightDir){ |
|
|
|
|
float diffuseFactor = lightComputeDiffuse(wvNorm, wvLightDir, wvViewDir); |
|
|
|
|
float specularFactor = lightComputeSpecular(wvNorm, wvViewDir, wvLightDir, m_Shininess); |
|
|
|
|
|
|
|
|
@ -250,7 +250,7 @@ void main(){ |
|
|
|
|
vec4 lightDir = vLightDir; |
|
|
|
|
lightDir.xyz = normalize(lightDir.xyz); |
|
|
|
|
|
|
|
|
|
vec2 light = computeLighting(vPosition, normal, vViewDir.xyz, lightDir.xyz) * spotFallOff; |
|
|
|
|
vec2 light = computeLighting(normal, vViewDir.xyz, lightDir.xyz) * spotFallOff; |
|
|
|
|
#ifdef COLORRAMP |
|
|
|
|
diffuseColor.rgb *= texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb; |
|
|
|
|
specularColor.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb; |
|
|
|
|