remove useless normalization in lighting shaders

in-pass-shadows
Kirill Vainer 7 years ago
parent fca6d4a8b2
commit 628fa23059
  1. 2
      jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag
  2. 2
      jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.vert
  3. 3
      jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
  4. 2
      jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag
  5. 2
      jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert
  6. 4
      jme3-core/src/main/resources/Common/ShaderLib/Lighting.glsllib

@ -173,7 +173,7 @@ void main(){
// allow use of control flow // allow use of control flow
if(g_LightDirection.w != 0.0){ if(g_LightDirection.w != 0.0){
#endif #endif
spotFallOff = computeSpotFalloff(g_LightDirection, lightVec); spotFallOff = computeSpotFalloff(g_LightDirection, lightDir.xyz);
#if __VERSION__ >= 110 #if __VERSION__ >= 110
if(spotFallOff <= 0.0){ if(spotFallOff <= 0.0){
gl_FragColor.rgb = AmbientSum * diffuseColor.rgb; gl_FragColor.rgb = AmbientSum * diffuseColor.rgb;

@ -158,7 +158,7 @@ void main(){
// allow use of control flow // allow use of control flow
if(lightColor.w > 1.0){ if(lightColor.w > 1.0){
#endif #endif
spotFallOff = computeSpotFalloff(g_LightDirection, lightVec); spotFallOff = computeSpotFalloff(g_LightDirection, vLightDir.xyz);
#if __VERSION__ >= 110 #if __VERSION__ >= 110
} }
#endif #endif

@ -223,14 +223,13 @@ void main(){
// allow use of control flow // allow use of control flow
if(lightColor.w > 1.0){ if(lightColor.w > 1.0){
#endif #endif
fallOff = computeSpotFalloff(g_LightData[i+2], lightVec); fallOff = computeSpotFalloff(g_LightData[i+2], lightDir.xyz);
#if __VERSION__ >= 110 #if __VERSION__ >= 110
} }
#endif #endif
//point light attenuation //point light attenuation
fallOff *= lightDir.w; fallOff *= lightDir.w;
lightDir.xyz = normalize(lightDir.xyz);
vec3 directDiffuse; vec3 directDiffuse;
vec3 directSpecular; vec3 directSpecular;

@ -188,7 +188,7 @@ void main(){
// allow use of control flow // allow use of control flow
if(lightColor.w > 1.0){ if(lightColor.w > 1.0){
#endif #endif
spotFallOff = computeSpotFalloff(g_LightData[i+2], lightVec); spotFallOff = computeSpotFalloff(g_LightData[i+2], lightDir.xyz);
#if __VERSION__ >= 110 #if __VERSION__ >= 110
} }
#endif #endif

@ -155,7 +155,7 @@ void main(){
if(lightColor.w > 1.0){ if(lightColor.w > 1.0){
#endif #endif
vec4 lightDirection = g_LightData[i+2]; vec4 lightDirection = g_LightData[i+2];
spotFallOff = computeSpotFalloff(lightDirection, lightVec); spotFallOff = computeSpotFalloff(lightDirection, lightDir.xyz);
#if __VERSION__ >= 110 #if __VERSION__ >= 110
} }
#endif #endif

@ -24,8 +24,8 @@ void lightComputeDir(in vec3 worldPos, in float lightType, in vec4 position, out
* Computes the spot falloff for a spotlight * Computes the spot falloff for a spotlight
*/ */
float computeSpotFalloff(in vec4 lightDirection, in vec3 lightVector) { float computeSpotFalloff(in vec4 lightDirection, in vec3 lightVector) {
vec3 L=normalize(lightVector); vec3 L = lightVector;
vec3 spotdir = normalize(lightDirection.xyz); vec3 spotdir = lightDirection.xyz;
float curAngleCos = dot(-L, spotdir); float curAngleCos = dot(-L, spotdir);
float innerAngleCos = floor(lightDirection.w) * 0.001; float innerAngleCos = floor(lightDirection.w) * 0.001;
float outerAngleCos = fract(lightDirection.w); float outerAngleCos = fract(lightDirection.w);

Loading…
Cancel
Save