Commits

Anonymous committed c07f69a

SH-1527 FIXED Fix for black alpha objects with lighting and shadows enabled and no lights around.

  • Participants
  • Parent commits 4140125

Comments (0)

Files changed (6)

indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl

 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }

indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl

 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }

indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl

 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }

indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl

 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }

indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl

 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }

indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl

 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }