Browse Source

debugging uniforms.

Ben Houston 9 years ago
parent
commit
ad75704cd8

+ 111 - 0
src/renderers/shaders/ShaderChunk/light_pars.glsl

@@ -0,0 +1,111 @@
+
+#if MAX_DIR_LIGHTS > 0
+
+	//uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
+	//uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
+
+	struct DirectionalLight {
+	  vec3 color;
+	  vec3 direction;
+	};
+
+	uniform DirectionalLight directionalLights[ MAX_DIR_LIGHTS ];
+
+	void getDirLight( const in DirectionalLight directionalLight, out vec3 lightDir, out vec3 lightColor ) { 
+	
+		lightDir = directionalLight.direction; 
+		lightColor = directionalLight.color;
+
+	}
+
+#endif
+
+#if MAX_HEMI_LIGHTS > 0
+
+	//uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
+	//uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
+	//uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
+
+	struct HemisphericLight {
+	  vec3 skyColor;
+	  vec3 groundColor;
+	  vec3 direction;
+	};
+
+	uniform HemisphericLight hemisphericLights[ MAX_HEMI_LIGHTS ];
+
+#endif
+
+#if MAX_POINT_LIGHTS > 0
+
+	//uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
+	//uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
+	//uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
+	//uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
+
+	struct PointLight {
+	  vec3 color;
+	  vec3 position;
+	  float decay;
+	  float cutoffDistance;
+	};
+
+	uniform PointLight pointLights[ MAX_POINT_LIGHTS ];
+
+	void getPointLight( const in pointLight, out vec3 lightDir, out vec3 lightColor ) { 
+	
+		vec3 lightPosition = pointLight.position; 
+	
+		vec3 lVector = lightPosition + vViewPosition.xyz; 
+		lightDir = normalize( lVector ); 
+	
+		lightColor = pointLight.color[ pointIndex ]; 
+		lightColor *= calcLightAttenuation( length( lVector ), pointLight.cutoffDistance, pointLight.decay ); 
+	
+	}
+
+#endif
+
+#if MAX_SPOT_LIGHTS > 0
+
+	//uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];
+	//uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];
+	//uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];
+	//uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
+	//uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
+	//uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];
+	//uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];
+
+	struct SpotLight {
+	  vec3 color;
+	  vec3 position;
+	  vec3 direction;
+	  float angleCos;
+	  float exponent;
+	  float cutoffDistance;
+	  float decay;
+	};
+
+	uniform SpotLight spotLights[ MAX_SPOT_LIGHTS ];
+
+	void getSpotLight( const in SpotLight spotLight, out vec3 lightDir, out vec3 lightColor ) {
+	
+		vec3 lightPosition = spotLight.position;
+	
+		vec3 lVector = lightPosition + vViewPosition.xyz;
+		lightDir = normalize( lVector );
+	
+		float spotEffect = dot( spotLight.direction, lightDir );
+		spotEffect = saturate( pow( saturate( spotEffect ), spotLight.exponent ) );
+	
+		lightColor = spotLight.color;
+		lightColor *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLight.distance, spotLight.decay ) );
+
+	}
+
+#endif
+
+
+
+
+

+ 0 - 36
src/renderers/shaders/ShaderChunk/lights_lambert_pars_vertex.glsl

@@ -1,37 +1 @@
 uniform vec3 ambientLightColor;
-
-#if MAX_DIR_LIGHTS > 0
-
-	uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
-	uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
-
-#endif
-
-#if MAX_HEMI_LIGHTS > 0
-
-	uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
-	uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
-	uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
-
-#endif
-
-#if MAX_POINT_LIGHTS > 0
-
-	uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
-	uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
-	uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
-	uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
-
-#endif
-
-#if MAX_SPOT_LIGHTS > 0
-
-	uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];
-	uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];
-	uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];
-	uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];
-	uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
-	uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
-	uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];
-
-#endif

+ 0 - 75
src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl

@@ -13,78 +13,3 @@ varying vec3 vViewPosition;
 	varying vec3 vNormal;
 
 #endif
-
-#if MAX_DIR_LIGHTS > 0
-
-	uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
-	uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
-
-	#define getDirLight( directionalIndex, lightDir, lightIntensity ) { 
-	
-		lightDir = directionalLightDirection[ directionalIndex ]; 
-		lightIntensity = directionalLightColor[ directionalIndex ]; 
-	
-	}
-
-#endif
-
-#if MAX_HEMI_LIGHTS > 0
-
-	uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
-	uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
-	uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
-
-#endif
-
-#if MAX_POINT_LIGHTS > 0
-
-	uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
-	uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
-	uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
-	uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
-
-	#define getPointLight( pointIndex, lightDir, lightIntensity ) { 
-	
-		vec3 lightPosition = pointLightPosition[ pointIndex ]; 
-	
-		vec3 lVector = lightPosition + vViewPosition.xyz; 
-		lightDir = normalize( lVector ); 
-	
-		lightIntensity = pointLightColor[ pointIndex ]; 
-		lightIntensity *= calcLightAttenuation( length( lVector ), pointLightDistance[ pointIndex ], pointLightDecay[ pointIndex ] ); 
-	
-	}
-
-#endif
-
-#if MAX_SPOT_LIGHTS > 0
-
-	uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];
-	uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];
-	uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];
-	uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
-	uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
-	uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];
-	uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];
-
-	#define getSpotLight( spotIndex, lightDir, lightIntensity ) {
-	
-		vec3 lightPosition = spotLightPosition[ spotIndex ];
-	
-		vec3 lVector = lightPosition + vViewPosition.xyz;
-		lightDir = normalize( lVector );
-	
-		float spotEffect = dot( spotLightDirection[ spotIndex ], lightDir );
-		spotEffect = saturate( pow( saturate( spotEffect ), spotLightExponent[ spotIndex ] ) );
-	
-		lightIntensity = spotLightColor[ spotIndex ];
-		lightIntensity *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLightDistance[ spotIndex ], spotLightDecay[ spotIndex ] ) );
-
-	}
-
-#endif
-
-
-
-
-