Browse Source

*Changing the codding style in the shaders
*Changing some parts of the ShaderProg so that can be more logical and organized

Panagiotis Christopoulos Charitos 16 năm trước cách đây
mục cha
commit
119a2cb955

+ 3 - 0
TODO

@@ -0,0 +1,3 @@
+*Continue working on the new coding style in shaders
+*Changes in the blending objects problem. The BS will become one stage and the PPS will be divided in two steps. The first will apply the SSAO and the EdgeAA in the IS_FAI and the second will do the rest
+*See this to improve uniform handling http://www.opengl.org/wiki/GLSL_Uniforms

+ 2 - 2
shaders/bs_bp_volfog.glsl

@@ -14,9 +14,9 @@ uniform sampler2D ms_depth_fai;
 void main()
 {
 	vec2 tex_size_ = textureSize(ms_depth_fai, 0);
-	vec2 tex_coords_ = gl_FragCoord.xy/tex_size_;
+	vec2 texCoords_____________ = gl_FragCoord.xy/tex_size_;
 	
-	float depth_exp_ = texture2D( ms_depth_fai, tex_coords_ ).r;
+	float depth_exp_ = texture2D( ms_depth_fai, texCoords_____________ ).r;
 	if( depth_exp_ == 1 ) discard;
 	
 	float depth_ = LinearizeDepth( depth_exp_, 0.1, 10.0 );

+ 2 - 2
shaders/bs_refract.glsl

@@ -8,13 +8,13 @@
 #pragma anki uniform fai 0
 uniform sampler2D fai;
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 
 
 
 void main()
 {
-	vec4 _color = texture2D( fai, tex_coords );
+	vec4 _color = texture2D( fai, texCoords );
 	if( _color.a == 0.0 ) discard;
 
 	gl_FragData[0].rgb = _color.rgb;

+ 6 - 6
shaders/dp_generic.glsl

@@ -4,14 +4,14 @@
 #pragma anki include "shaders/hw_skinning.glsl"
 
 attribute vec3 position;
-attribute vec2 tex_coords;
+attribute vec2 texCoords;
 
-varying vec2 tex_coords_v2f;
+varying vec2 texCoords_v2f;
 
 void main()
 {
 	#if defined( _GRASS_LIKE_ )
-		tex_coords_v2f = tex_coords;
+		texCoords_v2f = texCoords;
 	#endif
 
 	#if defined( _HW_SKINNING_ )
@@ -29,13 +29,13 @@ void main()
 
 #pragma anki fragShaderBegins
 
-uniform sampler2D diffuse_map;
-varying vec2 tex_coords_v2f;
+uniform sampler2D diffuseMap;
+varying vec2 texCoords_v2f;
 
 void main()
 {
 	#if defined( _GRASS_LIKE_ )
-		vec4 _diff = texture2D( diffuse_map, tex_coords_v2f );
+		vec4 _diff = texture2D( diffuseMap, texCoords_v2f );
 		if( _diff.a == 0.0 ) discard;
 	#endif
 }

+ 5 - 5
shaders/final.glsl

@@ -6,18 +6,18 @@
 
 #pragma anki uniform raster_image 0
 uniform sampler2D raster_image;
-varying vec2 tex_coords;
+varying vec2 texCoords;
 
 void main()
 {
 	//if( gl_FragCoord.x > 0.5 ) discard;
 
-	gl_FragColor.rgb = texture2D( raster_image, tex_coords ).rgb;
+	gl_FragColor.rgb = texture2D( raster_image, texCoords ).rgb;
 
-	/*vec4 c = texture2D( raster_image, tex_coords );
+	/*vec4 c = texture2D( raster_image, texCoords );
 	if( c.r == 0.0 && c.g == 0.0 && c.b==0.0 && c.a != 0.0 )*/
-		//gl_FragColor.rgb = vec3( texture2D( raster_image, tex_coords ).a );
-	//gl_FragColor.rgb = MedianFilter( raster_image, tex_coords );
+		//gl_FragColor.rgb = vec3( texture2D( raster_image, texCoords ).a );
+	//gl_FragColor.rgb = MedianFilter( raster_image, texCoords );
 	//gl_FragColor.rgb = vec3( gl_FragCoord.xy/tex_size_, 0.0 );
 	//gl_FragColor.rgb = vec3( gl_FragCoord.xy*vec2( 1.0/R_W, 1.0/R_H ), 0.0 );
 	//gl_FragColor.rgb = texture2D( raster_image, gl_FragCoord.xy/textureSize(raster_image,0) ).rgb;

+ 2 - 2
shaders/is_ap.glsl

@@ -9,9 +9,9 @@ uniform vec3 ambient_color;
 #pragma anki uniform ms_diffuse_fai 1
 uniform sampler2D ms_diffuse_fai;
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 
 void main()
 {
-	gl_FragData[0].rgb = texture2D( ms_diffuse_fai, tex_coords ).rgb * ambient_color;
+	gl_FragData[0].rgb = texture2D( ms_diffuse_fai, texCoords ).rgb * ambient_color;
 }

+ 18 - 18
shaders/is_lp_generic.glsl

@@ -5,14 +5,14 @@ attribute vec3 view_vector;
 #pragma anki attribute position 0
 attribute vec2 position;
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 varying vec3 vpos;
 
 void main()
 {
 	vpos = view_vector;
 	vec2 vert_pos = position; // the vert coords are {1.0,1.0}, {0.0,1.0}, {0.0,0.0}, {1.0,0.0}
-	tex_coords = vert_pos;
+	texCoords = vert_pos;
 	vec2 vert_pos_ndc = vert_pos*2.0 - 1.0;
 	gl_Position = vec4( vert_pos_ndc, 0.0, 1.0 );
 }
@@ -33,7 +33,7 @@ uniform vec3 light_diffuse_col;
 uniform vec3 light_specular_col;
 uniform mat4 tex_projection_mat;
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 varying vec3 vpos; // for the calculation of frag pos in view space
 
 
@@ -45,7 +45,7 @@ return frag pos in view space
 */
 vec3 FragPosVSpace()
 {
-	float _depth = texture2D( ms_depth_fai, tex_coords ).r;
+	float _depth = texture2D( ms_depth_fai, texCoords ).r;
 
 	if( _depth == 1.0 ) discard;
 
@@ -189,8 +189,8 @@ vec3 Phong( in vec3 _frag_pos_vspace, out float _frag_light_dist )
 	vec3 _light_dir = _light_frag_vec * inversesqrt(_frag_light_dist); // ...because we want frag_light_dist for the calc of the attenuation
 
 	// read the normal
-	//vec3 _normal = texture2D( ms_normal_fai, tex_coords ).rgb;
-	vec3 _normal = UnpackNormal( texture2D( ms_normal_fai, tex_coords ).rg );
+	//vec3 _normal = texture2D( ms_normal_fai, texCoords ).rgb;
+	vec3 _normal = UnpackNormal( texture2D( ms_normal_fai, texCoords ).rg );
 
 	// the lambert term
 	float _lambert_term = dot( _normal, _light_dir );
@@ -199,12 +199,12 @@ vec3 Phong( in vec3 _frag_pos_vspace, out float _frag_light_dist )
 	//_lambert_term = max( 0.0, _lambert_term );
 
 	// diffuce lighting
-	vec3 _diffuse = texture2D( ms_diffuse_fai, tex_coords ).rgb;
+	vec3 _diffuse = texture2D( ms_diffuse_fai, texCoords ).rgb;
 	_diffuse = (_diffuse * light_diffuse_col);
 	vec3 _color = _diffuse * _lambert_term;
 
 	// specular lighting
-	vec4 _specular_mix = texture2D( ms_specular_fai, tex_coords );
+	vec4 _specular_mix = texture2D( ms_specular_fai, texCoords );
 	vec3 _specular = _specular_mix.xyz;
 	float _shininess = _specular_mix.w;
 
@@ -243,24 +243,24 @@ void main()
 	//===================================================================================================================================
 	#elif defined(_SPOT_LIGHT_)
 		vec4 _tex_coord2 = tex_projection_mat * vec4(_frag_pos_vspace, 1.0);
-		vec3 _tex_coords3 = _tex_coord2.xyz / _tex_coord2.w;
+		vec3 _texCoords3 = _tex_coord2.xyz / _tex_coord2.w;
 
 		if
 		(
 			_tex_coord2.w > 0.0 &&
-			_tex_coords3.x > 0.0 &&
-			_tex_coords3.x < 1.0 &&
-			_tex_coords3.y > 0.0 &&
-			_tex_coords3.y < 1.0 &&
+			_texCoords3.x > 0.0 &&
+			_texCoords3.x < 1.0 &&
+			_texCoords3.y > 0.0 &&
+			_texCoords3.y < 1.0 &&
 			_tex_coord2.w < 1.0/light_inv_radius
 		)
 		{
 			#if defined( _SHADOW_ )
 				#if defined( _SHADOW_MAPPING_PCF_ )
-					float _shadow_color = PCF_Low( _tex_coords3 );
-					//float _shadow_color = MedianFilterPCF( shadow_map, _tex_coords3 );
+					float _shadow_color = PCF_Low( _texCoords3 );
+					//float _shadow_color = MedianFilterPCF( shadow_map, _texCoords3 );
 				#else
-					float _shadow_color = PCF_Off( _tex_coords3 );
+					float _shadow_color = PCF_Off( _texCoords3 );
 				#endif
 
 				if( _shadow_color == 0.0 ) discard;
@@ -285,7 +285,7 @@ void main()
 	#endif // spot light
 
 	/*#if defined(_SPOT_LIGHT_)
-	gl_FragData[0] = vec4( UnpackNormal(texture2D( ms_normal_fai, tex_coords ).rg), 1.0 );
-	//gl_FragData[0] = vec4( texture2D( ms_depth_fai, tex_coords ).rg), 1.0 );
+	gl_FragData[0] = vec4( UnpackNormal(texture2D( ms_normal_fai, texCoords ).rg), 1.0 );
+	//gl_FragData[0] = vec4( texture2D( ms_depth_fai, texCoords ).rg), 1.0 );
 	#endif*/
 }

+ 8 - 8
shaders/median_filter.glsl

@@ -17,7 +17,7 @@ http://graphics.cs.williams.edu
 //=====================================================================================================================================
 // MedianFilterRGB                                                                                                                    =
 //=====================================================================================================================================
-vec3 MedianFilterRGB( in sampler2D tex, in vec2 tex_coords )
+vec3 MedianFilterRGB( in sampler2D tex, in vec2 texCoords )
 {
 	vec2 tex_inv_size = 1.0/vec2(textureSize(tex, 0));
   vec3 v[9];
@@ -32,7 +32,7 @@ vec3 MedianFilterRGB( in sampler2D tex, in vec2 tex_coords )
 			// If a pixel in the window is located at (x+dX, y+dY), put it at index (dX + R)(2R + 1) + (dY + R) of the
 			// pixel array. This will fill the pixel array, with the top left pixel of the window at pixel[0] and the
 			// bottom right pixel of the window at pixel[N-1].
-			v[(dX + 1) * 3 + (dY + 1)] = texture2D(tex, tex_coords + offset * tex_inv_size).rgb;
+			v[(dX + 1) * 3 + (dY + 1)] = texture2D(tex, texCoords + offset * tex_inv_size).rgb;
 		}
 	}
 
@@ -50,7 +50,7 @@ vec3 MedianFilterRGB( in sampler2D tex, in vec2 tex_coords )
 //=====================================================================================================================================
 // MedianFilterA                                                                                                                      =
 //=====================================================================================================================================
-float MedianFilterA( in sampler2D tex, in vec2 tex_coords )
+float MedianFilterA( in sampler2D tex, in vec2 texCoords )
 {
 	vec2 tex_inv_size = 1.0/vec2(textureSize(tex, 0));
   float v[9];
@@ -65,7 +65,7 @@ float MedianFilterA( in sampler2D tex, in vec2 tex_coords )
 			// If a pixel in the window is located at (x+dX, y+dY), put it at index (dX + R)(2R + 1) + (dY + R) of the
 			// pixel array. This will fill the pixel array, with the top left pixel of the window at pixel[0] and the
 			// bottom right pixel of the window at pixel[N-1].
-			v[(dX + 1) * 3 + (dY + 1)] = texture2D(tex, tex_coords + offset * tex_inv_size).a;
+			v[(dX + 1) * 3 + (dY + 1)] = texture2D(tex, texCoords + offset * tex_inv_size).a;
 		}
 	}
 
@@ -83,7 +83,7 @@ float MedianFilterA( in sampler2D tex, in vec2 tex_coords )
 //=====================================================================================================================================
 // MedianAndBlurA                                                                                                                     =
 //=====================================================================================================================================
-float MedianAndBlurA( in sampler2D tex, in vec2 tex_coords )
+float MedianAndBlurA( in sampler2D tex, in vec2 texCoords )
 {
 	vec2 tex_inv_size = 1.0/vec2(textureSize(tex, 0));
   float v[9];
@@ -99,7 +99,7 @@ float MedianAndBlurA( in sampler2D tex, in vec2 tex_coords )
 			// If a pixel in the window is located at (x+dX, y+dY), put it at index (dX + R)(2R + 1) + (dY + R) of the
 			// pixel array. This will fill the pixel array, with the top left pixel of the window at pixel[0] and the
 			// bottom right pixel of the window at pixel[N-1].
-			float f = texture2D(tex, tex_coords + offset * tex_inv_size).a;
+			float f = texture2D(tex, texCoords + offset * tex_inv_size).a;
 			v[(dX + 1) * 3 + (dY + 1)] = f;
 			sum += f;
 		}
@@ -119,7 +119,7 @@ float MedianAndBlurA( in sampler2D tex, in vec2 tex_coords )
 //=====================================================================================================================================
 // MedianFilterPCF                                                                                                                    =
 //=====================================================================================================================================
-float MedianFilterPCF( in sampler2DShadow tex, in vec3 tex_coords )
+float MedianFilterPCF( in sampler2DShadow tex, in vec3 texCoords )
 {
 	vec2 tex_inv_size = 1.0/vec2(textureSize(tex, 0));
   float v[9];
@@ -134,7 +134,7 @@ float MedianFilterPCF( in sampler2DShadow tex, in vec3 tex_coords )
 			// If a pixel in the window is located at (x+dX, y+dY), put it at index (dX + R)(2R + 1) + (dY + R) of the
 			// pixel array. This will fill the pixel array, with the top left pixel of the window at pixel[0] and the
 			// bottom right pixel of the window at pixel[N-1].
-			v[(dX + 1) * 3 + (dY + 1)] = shadow2D(tex, tex_coords + vec3(offset * tex_inv_size, 0.0)).r;
+			v[(dX + 1) * 3 + (dY + 1)] = shadow2D(tex, texCoords + vec3(offset * tex_inv_size, 0.0)).r;
 		}
 	}
 

+ 36 - 36
shaders/ms_mp_generic.glsl

@@ -37,7 +37,7 @@ varying vec3 normal_v2f;
 varying vec2 texCoords_v2f;
 varying vec3 tangent_v2f;
 varying float w_v2f;
-varying vec3 vert_pos_eye_space_v2f; ///< For env mapping. AKA view_vector
+varying vec3 vertPosEyeSpace_v2f; ///< For env mapping. AKA view_vector
 
 
 
@@ -89,7 +89,7 @@ void main()
 
 
 	#if defined( _ENVIRONMENT_MAPPING_ ) || defined( _PARALLAX_MAPPING_ )
-		vert_pos_eye_space_v2f = vec3( gl_ModelViewMatrix * vec4(position, 1.0) );
+		vertPosEyeSpace_v2f = vec3( gl_ModelViewMatrix * vec4(position, 1.0) );
 	#endif
 }
 
@@ -100,7 +100,7 @@ void main()
  * Note: The process of calculating the diffuse color for the diffuse MSFAI is divided into two parts. The first happens before the
  * normal calculation and the other just after it. In the first part we read the texture (or the gl_Color) and we set the _diff_color.
  * In case of grass we discard. In the second part we calculate a SEM color and we combine it with the _diff_color. We cannot put
- * the second part before normal calculation because SEM needs the _new_normal. Also we cannot put the first part after normal
+ * the second part before normal calculation because SEM needs the newNormal. Also we cannot put the first part after normal
  * calculation because in case of grass we will waste calculations for the normal. For that two reasons we split the diffuse
  * calculations in two parts
  */
@@ -113,21 +113,21 @@ VARS
 =======================================================================================================================================
 */
 
-uniform sampler2D diffuse_map;
-uniform sampler2D normal_map;
-uniform sampler2D specular_map;
+uniform sampler2D diffuseMap;
+uniform sampler2D notmalMap;
+uniform sampler2D specularMap;
 uniform sampler2D height_map;
-uniform sampler2D environment_map;
-uniform vec3 diffuse_color;
-uniform vec3 specular_color;
-uniform float shininess;
+uniform sampler2D environmentMap;
+uniform vec3 diffuseCol = vec3( 1.0, 1.0, 1.0 );
+uniform vec3 specularCol = vec3( 1.0, 1.0, 1.0 );
+uniform float shininess = 50.0;
 
 varying vec3 normal_v2f;
 varying vec3 tangent_v2f;
 varying float w_v2f;
 varying vec2 texCoords_v2f;
 varying vec3 eye;
-varying vec3 vert_pos_eye_space_v2f;
+varying vec3 vertPosEyeSpace_v2f;
 
 
 
@@ -151,31 +151,31 @@ void main()
 		float _h = texture2D( height_map, texCoords_v2f ).r;
 		float _height = _scale * _h - _bias;
 
-		vec2 _super_texCoords_v2f = _height * _norm_eye.xy + texCoords_v2f;*/
+		vec2 superTexCoords_v2f = _height * _norm_eye.xy + texCoords_v2f;*/
 
-		vec2 _super_texCoords = texCoords_v2f;
+		vec2 superTexCoords = texCoords_v2f;
 		const float maxStepCount = 100.0;
-		float nSteps = maxStepCount * length(_super_texCoords);
+		float nSteps = maxStepCount * length(superTexCoords);
 
-		vec3 dir = vert_pos_eye_space_v2f;
+		vec3 dir = vertPosEyeSpace_v2f;
 		dir.xy /= 8.0;
 		dir /= -nSteps * dir.z;
 
-		float diff0, diff1 = 1.0 - texture2D( height_map, _super_texCoords ).a;
+		float diff0, diff1 = 1.0 - texture2D( height_map, superTexCoords ).a;
 		if( diff1 > 0.0 )
 		{
 			do 
 			{
-				_super_texCoords += dir.xy;
+				superTexCoords += dir.xy;
 
 				diff0 = diff1;
-				diff1 = texture2D(height_map, _super_texCoords ).w;
+				diff1 = texture2D(height_map, superTexCoords ).w;
 			} while( diff1 > 0.0 );
 
-			_super_texCoords.xy += (diff1 / (diff0 - diff1)) * dir.xy;
+			superTexCoords.xy += (diff1 / (diff0 - diff1)) * dir.xy;
 		}
 	#else
-		#define _super_texCoords texCoords_v2f
+		#define superTexCoords texCoords_v2f
 	#endif
 
 
@@ -187,16 +187,16 @@ void main()
 	#if defined( _DIFFUSE_MAPPING_ )
 
 		#if defined( _GRASS_LIKE_ )
-			vec4 _diff_color4 = texture2D( diffuse_map, _super_texCoords );
+			vec4 _diff_color4 = texture2D( diffuseMap, superTexCoords );
 			if( _diff_color4.a == 0.0 ) discard;
 			_diff_color = _diff_color4.rgb;
 		#else
-			_diff_color = texture2D( diffuse_map, _super_texCoords ).rgb;
+			_diff_color = texture2D( diffuseMap, superTexCoords ).rgb;
 		#endif
 
-		_diff_color *= diffuse_color.rgb;
+		_diff_color *= diffuseCol.rgb;
 	#else
-		_diff_color = diffuse_color.rgb;
+		_diff_color = diffuseCol.rgb;
 	#endif
 
 
@@ -209,13 +209,13 @@ void main()
 		vec3 _t = normalize( tangent_v2f );
 		vec3 _b = cross(_n, _t) * w_v2f;
 
-		mat3 _tbn_mat = mat3(_t,_b,_n);
+		mat3 tbnMat = mat3(_t,_b,_n);
 
-		vec3 _n_at_tangentspace = ( texture2D( normal_map, _super_texCoords ).rgb - 0.5 ) * 2.0;
+		vec3 nAtTangentspace = ( texture2D( notmalMap, superTexCoords ).rgb - 0.5 ) * 2.0;
 
-		vec3 _new_normal = normalize( _tbn_mat * _n_at_tangentspace );
+		vec3 newNormal = normalize( tbnMat * nAtTangentspace );
 	#else
-		vec3 _new_normal = normalize(normal_v2f);
+		vec3 newNormal = normalize(normal_v2f);
 	#endif
 
 
@@ -224,16 +224,16 @@ void main()
 	// If SEM is enabled make some calculations and combine colors of SEM and the _diff_color                                           =
 	//===================================================================================================================================
 
-	// if SEM enabled make some aditional calculations using the vert_pos_eye_space_v2f, environment_map and the _new_normal
+	// if SEM enabled make some aditional calculations using the vertPosEyeSpace_v2f, environmentMap and the newNormal
 	#if defined( _ENVIRONMENT_MAPPING_ )
-		vec3 _u = normalize( vert_pos_eye_space_v2f );
-		vec3 _r = reflect( _u, _new_normal ); // In case of normal mapping I could play with vertex's normal but this gives better...
+		vec3 _u = normalize( vertPosEyeSpace_v2f );
+		vec3 _r = reflect( _u, newNormal ); // In case of normal mapping I could play with vertex's normal but this gives better...
 		                                      // ...results and its allready computed
 		_r.z += 1.0;
 		float _m = 2.0 * length(_r);
 		vec2 _sem_texCoords = _r.xy/_m + 0.5;
 
-		vec3 _sem_col = texture2D( environment_map, _sem_texCoords ).rgb;
+		vec3 _sem_col = texture2D( environmentMap, _sem_texCoords ).rgb;
 		_diff_color = _diff_color + _sem_col; // blend existing color with the SEM texture map
 	#endif
 
@@ -244,18 +244,18 @@ void main()
 
 	// has specular map
 	#if defined( _SPECULAR_MAPPING_ )
-		vec4 _specular = vec4(texture2D( specular_map, _super_texCoords ).rgb * specular_color, shininess);
+		vec4 _specular = vec4(texture2D( specularMap, superTexCoords ).rgb * specularCol, shininess);
 	// no specular map
 	#else
-		vec4 _specular = vec4(specular_color, shininess);
+		vec4 _specular = vec4(specularCol, shininess);
 	#endif
 
 
 	//===================================================================================================================================
 	// Final Stage. Write all data                                                                                                      =
 	//===================================================================================================================================
-	//gl_FragData[0].rgb = _new_normal;
-	gl_FragData[0].rg = PackNormal( _new_normal );
+	//gl_FragData[0].rgb = newNormal;
+	gl_FragData[0].rg = PackNormal( newNormal );
 	gl_FragData[1].rgb = _diff_color;
 	gl_FragData[2] = _specular;
 

+ 18 - 28
shaders/pps.glsl

@@ -13,7 +13,7 @@ uniform sampler2D ms_normal_fai;
 uniform sampler2D pps_hdr_fai;
 uniform sampler2D pps_lscatt_fai;
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 
 
 /*
@@ -49,28 +49,18 @@ EdgeAA
 */
 #if defined(_EDGEAA_)
 
-//float LinearizeDepth( in float _depth )
-//{
-//	return (2.0 * camerarange.x) / (camerarange.y + camerarange.x - _depth * (camerarange.y - camerarange.x));
-//}
-//
-//float ReadLinearDepth( in vec2 coord )
-//{
-//	return LinearizeDepth( texture2D( depth_map, coord ).r );
-//}
-
 vec3 EdgeAA()
 {
 	const vec2 pixelsize = vec2( 1.0/(R_W*R_Q), 1.0/(R_H*R_Q) );
 	const vec2 kernel[8] = vec2[]( vec2(-1.0,1.0), vec2(1.0,-1.0), vec2(-1.0,-1.0), vec2(1.0,1.0), vec2(-1.0,0.0), vec2(1.0,0.0), vec2(0.0,-1.0), vec2(0.0,1.0) );
 	const float weight = 1.0;
 
-	vec3 tex = texture2D( ms_normal_fai, tex_coords ).rgb;
+	vec3 tex = texture2D( ms_normal_fai, texCoords ).rgb;
 	float factor = -0.5;
 
 	for( int i=0; i<4; i++ )
 	{
-		vec3 t = texture2D( ms_normal_fai, tex_coords + kernel[i]*pixelsize ).rgb;
+		vec3 t = texture2D( ms_normal_fai, texCoords + kernel[i]*pixelsize ).rgb;
 		t -= tex;
 		factor += dot(t, t);
 	}
@@ -78,16 +68,16 @@ vec3 EdgeAA()
 	factor = min(1.0, factor) * weight;
 
 	//return vec3(factor);
-	//if( factor < 0.01 ) return texture2D( is_fai, tex_coords ).rgb;
+	//if( factor < 0.01 ) return texture2D( is_fai, texCoords ).rgb;
 
 	vec3 color = vec3(0.0);
 
 	for( int i=0; i<8; i++ )
 	{
-		color += texture2D( is_fai, tex_coords + kernel[i]*pixelsize*factor ).rgb;
+		color += texture2D( is_fai, texCoords + kernel[i]*pixelsize*factor ).rgb;
 	}
 
-	color += 2.0 * texture2D( is_fai, tex_coords ).rgb;
+	color += 2.0 * texture2D( is_fai, texCoords ).rgb;
 
 	return color*(1.0/9.0);
 
@@ -105,14 +95,14 @@ vec3 EdgeAA()
 //
 //	vec2 pixelsize = vec2( 1.0/R_W, 1.0/R_H );
 //
-//	float d = ReadLinearDepth( tex_coords );
+//	float d = ReadLinearDepth( texCoords );
 //	float factor = 0.0;
 //
 //	const float weight = 8.0;
 //
 //	for( int i=0; i<4; i++ )
 //	{
-//		float ds = ReadLinearDepth( tex_coords + kernel[i]*pixelsize );
+//		float ds = ReadLinearDepth( texCoords + kernel[i]*pixelsize );
 //
 //		factor += abs(d - ds);
 //	}
@@ -123,17 +113,17 @@ vec3 EdgeAA()
 //
 //	/*if( factor < 0.001 )
 //	{
-//		return texture2D( is_fai, tex_coords ).rgb;
+//		return texture2D( is_fai, texCoords ).rgb;
 //	}*/
 //
 //	vec3 color = vec3(0.0);
 //
 //	for( int i=0; i<8; i++ )
 //	{
-//		color += texture2D( is_fai, tex_coords + kernel[i]*pixelsize*factor ).rgb;
+//		color += texture2D( is_fai, texCoords + kernel[i]*pixelsize*factor ).rgb;
 //	}
 //
-//	color += 2.0 * texture2D( is_fai, tex_coords ).rgb;
+//	color += 2.0 * texture2D( is_fai, texCoords ).rgb;
 //
 //	return color*(1.0/10.0);
 }
@@ -152,7 +142,7 @@ void main (void)
 	#if defined(_EDGEAA_)
 		color = EdgeAA();
 	#else
-		color = texture2D( is_fai, tex_coords ).rgb;
+		color = texture2D( is_fai, texCoords ).rgb;
 	#endif
 
 	/*const float gamma = 0.7;
@@ -161,17 +151,17 @@ void main (void)
 	color.b = pow(color.b, 1.0 / gamma);*/
 
 	#if defined(_SSAO_)
-		float ssao_factor = texture2D( pps_ssao_fai, tex_coords ).a;
+		float ssao_factor = texture2D( pps_ssao_fai, texCoords ).a;
 		color *= ssao_factor;
 	#endif
 
 	#if defined(_LSCATT_)
-		vec3 lscatt = texture2D( pps_lscatt_fai, tex_coords ).rgb;
+		vec3 lscatt = texture2D( pps_lscatt_fai, texCoords ).rgb;
 		color += lscatt;
 	#endif
 
 	#if defined(_HDR_)
-		vec3 hdr = texture2D( pps_hdr_fai, tex_coords ).rgb;
+		vec3 hdr = texture2D( pps_hdr_fai, texCoords ).rgb;
 		color += hdr;
 	#endif
 
@@ -185,9 +175,9 @@ void main (void)
 	//gl_FragData[0] = vec4( lscatt, 1.0 );
 	//gl_FragData[0] = vec4( bloom_factor );
 	//gl_FragColor = vec4( EdgeAA(), 1.0 );
-	//gl_FragColor = texture2D( pps_boom_fai, tex_coords );
-	//gl_FragColor = texture2D( is_fai, tex_coords );
-	//gl_FragData[0].rgb = UnpackNormal( texture2D( ms_normal_fai, tex_coords ).rg );
+	//gl_FragColor = texture2D( pps_boom_fai, texCoords );
+	//gl_FragColor = texture2D( is_fai, texCoords );
+	//gl_FragData[0].rgb = UnpackNormal( texture2D( ms_normal_fai, texCoords ).rg );
 	//gl_FragData[0] = vec4( hdr, 1.0 );
 }
 

+ 7 - 7
shaders/pps_hdr_generic.glsl

@@ -6,16 +6,16 @@
 
 #pragma anki include "shaders/median_filter.glsl"
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 
 #pragma anki uniform tex 0
 uniform sampler2D tex;
 
 void main()
 {
-	//gl_FragData[0].rgb = texture2D( tex, tex_coords).rgb;return;
+	//gl_FragData[0].rgb = texture2D( tex, texCoords).rgb;return;
 
-	/*if( tex_coords.x*R_W > textureSize(tex,0).x/2 )
+	/*if( texCoords.x*R_W > textureSize(tex,0).x/2 )
 		gl_FragData[0].rgb = vec3( 1, 0, 0 );
 	else
 		gl_FragData[0].rgb = vec3( 0, 1, 0 );
@@ -39,17 +39,17 @@ void main()
 		for( int i=0; i<KERNEL_SIZE; i++ )
 		{
 			#if defined( _PPS_HDR_PASS_0_ )
-				color += texture2D( tex, tex_coords + vec2(kernel[i], 0.0) ).rgb;
+				color += texture2D( tex, texCoords + vec2(kernel[i], 0.0) ).rgb;
 			#else // _PPS_HDR_PASS_1_
-				color += texture2D( tex, tex_coords + vec2(0.0, kernel[i]) ).rgb;
+				color += texture2D( tex, texCoords + vec2(0.0, kernel[i]) ).rgb;
 			#endif
 		}
 
 		gl_FragData[0].rgb = color / KERNEL_SIZE;
 
 	#else // _PPS_HDR_PASS_2_
-		vec3 color = MedianFilterRGB( tex, tex_coords );
-		//vec3 color = texture2D( tex, tex_coords ).rgb;
+		vec3 color = MedianFilterRGB( tex, texCoords );
+		//vec3 color = texture2D( tex, texCoords ).rgb;
 
 		float Y = dot(vec3(0.30, 0.59, 0.11), color);
 		const float exposure = 4.0;

+ 7 - 7
shaders/pps_lscatt.glsl

@@ -17,14 +17,14 @@ uniform sampler2D ms_depth_fai;
 #pragma anki uniform is_fai 1
 uniform sampler2D is_fai;
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 
 
 
 void main()
 {
-	vec2 delta_tex_coord = tex_coords - light_pos_screen_space;
-	vec2 tex_coords2 = tex_coords;
+	vec2 delta_tex_coord = texCoords - light_pos_screen_space;
+	vec2 texCoords2 = texCoords;
 	delta_tex_coord *= 1.0 / float(SAMPLES_NUM) * density;
 	float illumination_decay = 1.0;
 
@@ -32,16 +32,16 @@ void main()
 
 	for( int i=0; i<SAMPLES_NUM; i++ )
 	{
-		tex_coords2 -= delta_tex_coord;
+		texCoords2 -= delta_tex_coord;
 
-		float depth = texture2D( ms_depth_fai, tex_coords2 ).r;
+		float depth = texture2D( ms_depth_fai, texCoords2 ).r;
 		if( depth != 1.0 ) // if the fragment is not part of the skybox dont bother continuing
 		{
 			illumination_decay *= decay;
 			continue;
 		}
 
-		vec3 sample = texture2D( is_fai, tex_coords2 ).rgb;			
+		vec3 sample = texture2D( is_fai, texCoords2 ).rgb;			
 		sample *= illumination_decay * weight;
 		gl_FragData[0].rgb += sample;
 		illumination_decay *= decay;
@@ -49,6 +49,6 @@ void main()
 
 	gl_FragData[0].rgb *= exposure;
 	
-	//gl_FragData[0].rgb = texture2D( is_fai, tex_coords ).rgb;
+	//gl_FragData[0].rgb = texture2D( is_fai, texCoords ).rgb;
 	//gl_FragData[0].rgb = vec3(1, 1, 0);
 }

+ 5 - 5
shaders/pps_ssao.glsl

@@ -16,7 +16,7 @@ uniform sampler2D noise_map;
 #pragma anki uniform ms_normal_fai 3
 uniform sampler2D ms_normal_fai;
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 const float totStrength = 1.7;
 const float strength = 0.07;
 const float offset = 18.0;
@@ -33,14 +33,14 @@ void main(void)
 	//const vec3 pSphere[12] = vec3[](vec3(-0.13657719, 0.30651027, 0.16118456),vec3(-0.14714938, 0.33245975, -0.113095455),vec3(0.030659059, 0.27887347, -0.7332209),vec3(0.009913514, -0.89884496, 0.07381549),vec3(0.040318526, 0.40091, 0.6847858),vec3(0.22311053, -0.3039437, -0.19340435),vec3(0.36235332, 0.21894878, -0.05407306),vec3(-0.15198798, -0.38409665, -0.46785462),vec3(-0.013492276, -0.5345803, 0.11307949),vec3(-0.4972847, 0.037064247, -0.4381323),vec3(-0.024175806, -0.008928787, 0.17719103),vec3(0.694014, -0.122672155, 0.33098832));
 	//const vec3 pSphere[10] = vec3[](vec3(-0.010735935, 0.01647018, 0.0062425877),vec3(-0.06533369, 0.3647007, -0.13746321),vec3(-0.6539235, -0.016726388, -0.53000957),vec3(0.40958285, 0.0052428036, -0.5591124),vec3(-0.1465366, 0.09899267, 0.15571679),vec3(-0.44122112, -0.5458797, 0.04912532),vec3(0.03755566, -0.10961345, -0.33040273),vec3(0.019100213, 0.29652783, 0.066237666),vec3(0.8765323, 0.011236004, 0.28265962),vec3(0.29264435, -0.40794238, 0.15964167));
 	// grab a normal for reflecting the sample rays later on
-	vec3 fres = normalize((texture2D(noise_map,tex_coords*offset).xyz*2.0) - vec3(1.0));
+	vec3 fres = normalize((texture2D(noise_map,texCoords*offset).xyz*2.0) - vec3(1.0));
 
-	vec4 currentPixelSample = texture2D(ms_normal_fai,tex_coords);
+	vec4 currentPixelSample = texture2D(ms_normal_fai,texCoords);
 
-	float currentPixelDepth = ReadFromTexAndLinearizeDepth( ms_depth_fai, tex_coords, camerarange.x, camerarange.y );
+	float currentPixelDepth = ReadFromTexAndLinearizeDepth( ms_depth_fai, texCoords, camerarange.x, camerarange.y );
 
 	// current fragment coords in screen space
-	vec3 ep = vec3( tex_coords.xy, currentPixelDepth );
+	vec3 ep = vec3( texCoords.xy, currentPixelDepth );
 	// get the normal of current fragment
 	vec3 norm = UnpackNormal(currentPixelSample.xy);
 

+ 3 - 3
shaders/pps_ssao_blur.glsl

@@ -6,14 +6,14 @@
 
 #pragma anki include "shaders/median_filter.glsl"
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 
 #pragma anki uniform tex 0
 uniform sampler2D tex;
 
 void main()
 {
-	//gl_FragData[0].a = MedianAndBlurA( tex, tex_coords );
+	//gl_FragData[0].a = MedianAndBlurA( tex, texCoords );
 	float offset = 1.0 / float(textureSize(tex,0).x);
 	const int KERNEL_SIZE = 9;
 	float kernel[KERNEL_SIZE] = float[]( -3.0 * offset, -2.0 * offset, -1.0 * offset, 0.0 * offset, 1.0 * offset, 2.0 * offset,
@@ -22,7 +22,7 @@ void main()
 	float factor = 0.0;
 	for( int i=0; i<KERNEL_SIZE; i++ )
 	{
-		factor += texture2D( tex, tex_coords + vec2(kernel[i], 0.0) ).a;
+		factor += texture2D( tex, texCoords + vec2(kernel[i], 0.0) ).a;
 	}
 	gl_FragData[0].a = factor / KERNEL_SIZE;
 }

+ 3 - 3
shaders/pps_ssao_blur2.glsl

@@ -6,14 +6,14 @@
 
 #pragma anki include "shaders/median_filter.glsl"
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 
 #pragma anki uniform tex 0
 uniform sampler2D tex;
 
 void main()
 {
-	//gl_FragData[0].a = MedianAndBlurA( tex, tex_coords );
+	//gl_FragData[0].a = MedianAndBlurA( tex, texCoords );
 	float offset = 1.0 / float(textureSize(tex,0).y);
 	const int KERNEL_SIZE = 9;
 	float kernel[KERNEL_SIZE] = float[]( -3.0 * offset, -2.0 * offset, -1.0 * offset, 0.0 * offset, 1.0 * offset, 2.0 * offset,
@@ -22,7 +22,7 @@ void main()
 	float factor = 0.0;
 	for( int i=0; i<KERNEL_SIZE; i++ )
 	{
-		factor += texture2D( tex, tex_coords + vec2(0.0, kernel[i]) ).a;
+		factor += texture2D( tex, texCoords + vec2(0.0, kernel[i]) ).a;
 	}
 	gl_FragData[0].a = factor / KERNEL_SIZE;
 }

+ 3 - 3
shaders/simple_texturing.glsl

@@ -18,7 +18,7 @@ void main()
 
 #pragma anki include "shaders/pack.glsl"
 
-uniform sampler2D diffuse_map, noise_map;
+uniform sampler2D diffuseMap, noise_map;
 //varying vec2 texCoords_v2f;
 varying vec3 normal_v2f;
 
@@ -28,8 +28,8 @@ void main()
 	_noise = _noise * 2 - 1;
 	_noise *= 7.0;*/
 
-	vec4 _texel = texture2D( diffuse_map, (gl_FragCoord.xy+(normal_v2f.z*50))*vec2( 1.0/R_W, 1.0/R_H ) ) * 0.75;
-	//vec4 _texel = texture2D( diffuse_map, gl_FragCoord.xy*vec2( 1.0/R_W, 1.0/R_H ) );
+	vec4 _texel = texture2D( diffuseMap, (gl_FragCoord.xy+(normal_v2f.z*50))*vec2( 1.0/R_W, 1.0/R_H ) ) * 0.75;
+	//vec4 _texel = texture2D( diffuseMap, gl_FragCoord.xy*vec2( 1.0/R_W, 1.0/R_H ) );
 
 	gl_FragData[0] = _texel;
 

+ 2 - 2
shaders/simple_vert.glsl

@@ -8,12 +8,12 @@
 #pragma anki attribute position 0
 attribute vec2 position;
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 
 void main()
 {
 	vec2 vert_pos = position; // the vert coords are {1.0,1.0}, {0.0,1.0}, {0.0,0.0}, {1.0,0.0}
-	tex_coords = vert_pos;
+	texCoords = vert_pos;
 	vec2 vert_pos_ndc = vert_pos*2.0 - 1.0;
 	gl_Position = vec4( vert_pos_ndc, 0.0, 1.0 );
 }

+ 8 - 8
shaders/txt.glsl

@@ -1,25 +1,25 @@
 #pragma anki vertShaderBegins
 
-varying vec2 tex_coords;
+varying vec2 texCoords;
 
 void main(void)
 {
-	tex_coords = gl_MultiTexCoord0.xy;
+	texCoords = gl_MultiTexCoord0.xy;
 	gl_FrontColor = gl_Color;
 	gl_Position = ftransform();
 }
 
 #pragma anki fragShaderBegins
 
-#pragma anki uniform font_map 0
-uniform sampler2D font_map;
-varying vec2 tex_coords;
+#pragma anki uniform fontMap 0
+uniform sampler2D fontMap;
+varying vec2 texCoords;
 
 void main()
 {
-	vec2 tex_col = texture2D( font_map, tex_coords ).ra; // get only one value and the alpha
+	vec2 texCol = texture2D( fontMap, texCoords ).ra; // get only one value and the alpha
 
-	if( tex_col.y == 0.0 ) discard;
+	if( texCol.y == 0.0 ) discard;
 
-	gl_FragColor = vec4(tex_col.x) * gl_Color;
+	gl_FragColor = vec4(texCol.x) * gl_Color;
 }

+ 12 - 4
src/NAMING

@@ -3,17 +3,25 @@ This file contains some of the naming convention we use in AnKi
 Shader Program     : shaderProg or sProg
 Material           : mtl
 Property           : prop
-Controller         : ctrl
-Skeleton           : skel
 Animation          : anim
-Skeletal Animation : sAnim
 Application        : app
+Camera             : cam
+Color              : col
+Controller         : ctrl
+Skeletal Animation : sAnim
+Skeleton           : skel
 Transformation     : trf
 Translation        : tsl
 Rotation           : rot
 Vector             : vec
+Quaternion         : quat
 Matrix             : mat
-Camera             : cam
 Utility            : util
 Texture            : tex
 Text               : txt
+Location           : loc
+Variable           : var
+Resource           : rsrc
+Fragment           : frag
+Vertex             : vert
+Triangle           : tri

+ 1 - 1
src/renderer/Bs2.cpp

@@ -101,7 +101,7 @@ void runStage2( const Camera& cam )
 			fbo.bind();
 			glDisable( GL_DEPTH_TEST );
 			shader_prog->bind();
-			shader_prog->locTexUnit( shader_prog->GetUniLoc(0), fai, 0 );
+			shader_prog->locTexUnit( shader_prog->getUniLoc(0), fai, 0 );
 			R::DrawQuad( shader_prog->getAttribLoc(0) );
 		}
 	}

+ 3 - 3
src/renderer/Hdr.cpp

@@ -103,7 +103,7 @@ void runPass( const Camera& /*cam*/ )
 
 	pass0_shdr->bind();
 
-	pass0_shdr->locTexUnit( pass0_shdr->GetUniLoc(0), R::Is::fai, 0 );
+	pass0_shdr->locTexUnit( pass0_shdr->getUniLoc(0), R::Is::fai, 0 );
 
 	// Draw quad
 	R::DrawQuad( pass0_shdr->getAttribLoc(0) );
@@ -114,7 +114,7 @@ void runPass( const Camera& /*cam*/ )
 
 	pass1_shdr->bind();
 
-	pass1_shdr->locTexUnit( pass1_shdr->GetUniLoc(0), pass0Fai, 0 );
+	pass1_shdr->locTexUnit( pass1_shdr->getUniLoc(0), pass0Fai, 0 );
 
 	// Draw quad
 	R::DrawQuad( pass1_shdr->getAttribLoc(0) );
@@ -125,7 +125,7 @@ void runPass( const Camera& /*cam*/ )
 
 	pass2_shdr->bind();
 
-	pass2_shdr->locTexUnit( pass2_shdr->GetUniLoc(0), pass1Fai, 0 );
+	pass2_shdr->locTexUnit( pass2_shdr->getUniLoc(0), pass1Fai, 0 );
 
 	// Draw quad
 	R::DrawQuad( pass2_shdr->getAttribLoc(0) );

+ 23 - 23
src/renderer/Is.cpp

@@ -189,8 +189,8 @@ static void AmbientPass( const Camera& /*cam*/, const Vec3& color )
 	ambientSProg->bind();
 
 	// set the uniforms
-	glUniform3fv( ambientSProg->GetUniLoc(0), 1, &((Vec3)color)[0] );
-	ambientSProg->locTexUnit( ambientSProg->GetUniLoc(1), R::Ms::diffuseFai, 0 );
+	glUniform3fv( ambientSProg->getUniLoc(0), 1, &((Vec3)color)[0] );
+	ambientSProg->locTexUnit( ambientSProg->getUniLoc(1), R::Ms::diffuseFai, 0 );
 
 	// Draw quad
 	R::DrawQuad( ambientSProg->getAttribLoc(0) );
@@ -329,17 +329,17 @@ static void PointLightPass( const Camera& cam, const PointLight& light )
 	shader.bind();
 
 	// bind the material stage framebuffer attachable images
-	shader.locTexUnit( shader.GetUniLoc(0), R::Ms::normalFai, 0 );
-	shader.locTexUnit( shader.GetUniLoc(1), R::Ms::diffuseFai, 1 );
-	shader.locTexUnit( shader.GetUniLoc(2), R::Ms::specularFai, 2 );
-	shader.locTexUnit( shader.GetUniLoc(3), R::Ms::depthFai, 3 );
-	glUniform2fv( shader.GetUniLoc(4), 1, &planes[0] );
+	shader.locTexUnit( shader.getUniLoc(0), R::Ms::normalFai, 0 );
+	shader.locTexUnit( shader.getUniLoc(1), R::Ms::diffuseFai, 1 );
+	shader.locTexUnit( shader.getUniLoc(2), R::Ms::specularFai, 2 );
+	shader.locTexUnit( shader.getUniLoc(3), R::Ms::depthFai, 3 );
+	glUniform2fv( shader.getUniLoc(4), 1, &planes[0] );
 
 	Vec3 light_pos_eye_space = light.translationWspace.getTransformed( cam.getViewMatrix() );
-	glUniform3fv( shader.GetUniLoc(5), 1, &light_pos_eye_space[0] );
-	glUniform1f( shader.GetUniLoc(6), 1.0/light.radius );
-	glUniform3fv( shader.GetUniLoc(7), 1, &Vec3(light.lightProps->getDiffuseColor())[0] );
-	glUniform3fv( shader.GetUniLoc(8), 1, &Vec3(light.lightProps->getSpecularColor())[0] );
+	glUniform3fv( shader.getUniLoc(5), 1, &light_pos_eye_space[0] );
+	glUniform1f( shader.getUniLoc(6), 1.0/light.radius );
+	glUniform3fv( shader.getUniLoc(7), 1, &Vec3(light.lightProps->getDiffuseColor())[0] );
+	glUniform3fv( shader.getUniLoc(8), 1, &Vec3(light.lightProps->getSpecularColor())[0] );
 
 	//** render quad **
 	glEnableVertexAttribArray( shader.getAttribLoc(0) );
@@ -394,27 +394,27 @@ static void SpotLightPass( const Camera& cam, const SpotLight& light )
 	shdr->bind();
 
 	// bind the framebuffer attachable images
-	shdr->locTexUnit( shdr->GetUniLoc(0), R::Ms::normalFai, 0 );
-	shdr->locTexUnit( shdr->GetUniLoc(1), R::Ms::diffuseFai, 1 );
-	shdr->locTexUnit( shdr->GetUniLoc(2), R::Ms::specularFai, 2 );
-	shdr->locTexUnit( shdr->GetUniLoc(3), R::Ms::depthFai, 3 );
+	shdr->locTexUnit( shdr->getUniLoc(0), R::Ms::normalFai, 0 );
+	shdr->locTexUnit( shdr->getUniLoc(1), R::Ms::diffuseFai, 1 );
+	shdr->locTexUnit( shdr->getUniLoc(2), R::Ms::specularFai, 2 );
+	shdr->locTexUnit( shdr->getUniLoc(3), R::Ms::depthFai, 3 );
 
 	if( light.lightProps->getTexture() == NULL )
 		ERROR( "No texture is attached to the light. light_props name: " << light.lightProps->getRsrcName() );
 
 	// the planes
 	//glUniform2fv( shdr->getUniLoc("planes"), 1, &planes[0] );
-	glUniform2fv( shdr->GetUniLoc(4), 1, &planes[0] );
+	glUniform2fv( shdr->getUniLoc(4), 1, &planes[0] );
 
 	// the light params
 	Vec3 light_pos_eye_space = light.translationWspace.getTransformed( cam.getViewMatrix() );
-	glUniform3fv( shdr->GetUniLoc(5), 1, &light_pos_eye_space[0] );
-	glUniform1f( shdr->GetUniLoc(6), 1.0/light.getDistance() );
-	glUniform3fv( shdr->GetUniLoc(7), 1, &Vec3(light.lightProps->getDiffuseColor())[0] );
-	glUniform3fv( shdr->GetUniLoc(8), 1, &Vec3(light.lightProps->getSpecularColor())[0] );
+	glUniform3fv( shdr->getUniLoc(5), 1, &light_pos_eye_space[0] );
+	glUniform1f( shdr->getUniLoc(6), 1.0/light.getDistance() );
+	glUniform3fv( shdr->getUniLoc(7), 1, &Vec3(light.lightProps->getDiffuseColor())[0] );
+	glUniform3fv( shdr->getUniLoc(8), 1, &Vec3(light.lightProps->getSpecularColor())[0] );
 
 	// set the light texture
-	shdr->locTexUnit( shdr->GetUniLoc(9), *light.lightProps->getTexture(), 4 );
+	shdr->locTexUnit( shdr->getUniLoc(9), *light.lightProps->getTexture(), 4 );
 	// before we render disable anisotropic in the light.texture because it produces artefacts. ToDo: see if this is unececeary in future drivers
 	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
@@ -426,7 +426,7 @@ static void SpotLightPass( const Camera& cam, const SpotLight& light )
 	static Mat4 bias_m4( 0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0 );
 	Mat4 tex_projection_mat;
 	tex_projection_mat = bias_m4 * light.camera.getProjectionMatrix() * light.camera.getViewMatrix() * cam.transformationWspace;
-	glUniformMatrix4fv( shdr->GetUniLoc(10), 1, true, &tex_projection_mat[0] );
+	glUniformMatrix4fv( shdr->getUniLoc(10), 1, true, &tex_projection_mat[0] );
 
 	/*
 	const float mBias[] = {0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0};
@@ -442,7 +442,7 @@ static void SpotLightPass( const Camera& cam, const SpotLight& light )
 	// render depth to texture and then bind it
 	if( light.castsShadow )
 	{
-		shdr->locTexUnit( shdr->GetUniLoc(11), R::Is::Shad::shadowMap, 5 );
+		shdr->locTexUnit( shdr->getUniLoc(11), R::Is::Shad::shadowMap, 5 );
 	}
 
 	//** render quad **

+ 3 - 3
src/renderer/Lscatt.cpp

@@ -62,8 +62,8 @@ void init()
 
 	// init shaders
 	shdr = rsrc::shaders.load( "shaders/pps_lscatt.glsl" );
-	ms_depth_fai_uni_loc = shdr->getUniLoc( "ms_depth_fai" );
-	is_fai_uni_loc = shdr->getUniLoc( "is_fai" );
+	ms_depth_fai_uni_loc = shdr->getUniVar( "ms_depth_fai" ).getLoc();
+	is_fai_uni_loc = shdr->getUniVar( "is_fai" ).getLoc();
 }
 
 
@@ -92,7 +92,7 @@ void runPass( const Camera& cam )
 	p = cam.getProjectionMatrix() * (cam.getViewMatrix() * p);
 	p /= p.w;
 	p = p/2 + 0.5;
-	glUniform2fv( shdr->getUniLoc("light_pos_screen_space"), 1, &p[0] );
+	glUniform2fv( shdr->getUniVar("light_pos_screen_space").getLoc(), 1, &p[0] );
 
 	// Draw quad
 	R::DrawQuad( shdr->getAttribLoc(0) );

+ 5 - 5
src/renderer/Pps.cpp

@@ -64,27 +64,27 @@ void init()
 	sProg = rsrc::shaders.load( "shaders/pps.glsl" );
 	sProg->bind();
 
-	shdrVars::isFai = sProg->getUniLoc( "is_fai" );
+	shdrVars::isFai = sProg->getUniVar( "is_fai" ).getLoc();
 
 	if( R::Pps::Ssao::enabled )
 	{
 		R::Pps::Ssao::init();
-		shdrVars::ppsSsaoFai = sProg->getUniLoc( "pps_ssao_fai" );
+		shdrVars::ppsSsaoFai = sProg->getUniVar( "pps_ssao_fai" ).getLoc();
 	}
 
 	if( R::Pps::Hdr::enabled )
 	{
 		R::Pps::Hdr::init();
-		shdrVars::hdrFai = sProg->getUniLoc( "pps_hdr_fai" );
+		shdrVars::hdrFai = sProg->getUniVar( "pps_hdr_fai" ).getLoc();
 	}
 
 	if( R::Pps::edgeaa::enabled )
-		shdrVars::msNormalFai = sProg->getUniLoc( "ms_normal_fai" );
+		shdrVars::msNormalFai = sProg->getUniVar( "ms_normal_fai" ).getLoc();
 
 	if( R::Pps::Lscatt::enabled )
 	{
 		R::Pps::Lscatt::init();
-		shdrVars::lscattFai = sProg->getUniLoc( "pps_lscatt_fai" );
+		shdrVars::lscattFai = sProg->getUniVar( "pps_lscatt_fai" ).getLoc();
 	}
 
 }

+ 1 - 1
src/renderer/Renderer.cpp

@@ -201,7 +201,7 @@ void render( const Camera& cam )
 	glDisable( GL_BLEND );
 
 	shdr_final->bind();
-	shdr_final->locTexUnit( shdr_final->GetUniLoc(0), R::Pps::fai, 0 );
+	shdr_final->locTexUnit( shdr_final->getUniLoc(0), R::Pps::fai, 0 );
 
 	/*const int step = 100;
 	if( R::framesNum < step )

+ 6 - 6
src/renderer/Ssao.cpp

@@ -159,23 +159,23 @@ void runPass( const Camera& cam )
 
 	// fill SSAO FAI
 	ssaoSProg->bind();
-	glUniform2fv( ssaoSProg->GetUniLoc(0), 1, &(Vec2(cam.getZNear(), cam.getZFar()))[0] );
-	ssaoSProg->locTexUnit( ssaoSProg->GetUniLoc(1), R::Ms::depthFai, 0 );
-	ssaoSProg->locTexUnit( ssaoSProg->GetUniLoc(2), *noise_map, 1 );
-	ssaoSProg->locTexUnit( ssaoSProg->GetUniLoc(3), R::Ms::normalFai, 2 );
+	glUniform2fv( ssaoSProg->getUniLoc(0), 1, &(Vec2(cam.getZNear(), cam.getZFar()))[0] );
+	ssaoSProg->locTexUnit( ssaoSProg->getUniLoc(1), R::Ms::depthFai, 0 );
+	ssaoSProg->locTexUnit( ssaoSProg->getUniLoc(2), *noise_map, 1 );
+	ssaoSProg->locTexUnit( ssaoSProg->getUniLoc(3), R::Ms::normalFai, 2 );
 	R::DrawQuad( ssaoSProg->getAttribLoc(0) ); // Draw quad
 
 
 	// second pass. blur
 	blurFbo.bind();
 	blurSProg->bind();
-	blurSProg->locTexUnit( blurSProg->GetUniLoc(0), fai, 0 );
+	blurSProg->locTexUnit( blurSProg->getUniLoc(0), fai, 0 );
 	R::DrawQuad( blurSProg->getAttribLoc(0) ); // Draw quad
 
 	// third pass. blur
 	blurFbo2.bind();
 	blurSProg2->bind();
-	blurSProg2->locTexUnit( blurSProg2->GetUniLoc(0), bluredFai, 0 );
+	blurSProg2->locTexUnit( blurSProg2->getUniLoc(0), bluredFai, 0 );
 	R::DrawQuad( blurSProg2->getAttribLoc(0) ); // Draw quad
 
 

+ 16 - 11
src/resources/Material.cpp

@@ -354,7 +354,7 @@ bool Material::additionalInit()
 	shaderProg->bind();
 	for( uint i=0; i<userDefinedVars.size(); i++ )
 	{
-		int loc = shaderProg->getUniLoc( userDefinedVars[i].name.c_str() );
+		int loc = shaderProg->getUniVar( userDefinedVars[i].name.c_str() ).getLoc();
 		if( loc == -1 )
 		{
 			MTL_ERROR( "Shader \"" << shaderProg->getRsrcName() << "\" and user defined var \"" << userDefinedVars[i].name <<
@@ -366,19 +366,24 @@ bool Material::additionalInit()
 	shaderProg->unbind();
 
 	// init the attribute locations
-	attribLocs.tanget = shaderProg->getAttribLocSilently( "tangent" );
-	attribLocs.position = shaderProg->getAttribLocSilently( "position" );
-	attribLocs.normal = shaderProg->getAttribLocSilently( "normal" );
-	attribLocs.texCoords = shaderProg->getAttribLocSilently( "texCoords" );
+	attribLocs.tanget = shaderProg->attribVarExists( "tangent" ) ?  shaderProg->getAttribVar( "tangent" ).getLoc() : -1;
+	attribLocs.position = shaderProg->attribVarExists( "position" ) ?  shaderProg->getAttribVar( "position" ).getLoc() : -1;
+	attribLocs.normal = shaderProg->attribVarExists( "normal" ) ?  shaderProg->getAttribVar( "normal" ).getLoc() : -1;
+	attribLocs.normal = shaderProg->attribVarExists( "normal" ) ?  shaderProg->getAttribVar( "normal" ).getLoc() : -1;
 
 	// vertex weights
-	attribLocs.vertWeightBonesNum = shaderProg->getAttribLocSilently( "vertWeightBonesNum" );
-	if( attribLocs.vertWeightBonesNum != -1 )
+	if( shaderProg->attribVarExists( "vertWeightBonesNum" ) )
 	{
-		attribLocs.vertWeightBoneIds = shaderProg->getAttribLoc( "vertWeightBoneIds" );
-		attribLocs.vertWeightWeights = shaderProg->getAttribLoc( "vertWeightWeights" );
-		uniLocs.skinningRotations = shaderProg->getUniLoc( "skinningRotations" );
-		uniLocs.skinningTranslations = shaderProg->getUniLoc( "skinningTranslations" );
+		attribLocs.vertWeightBonesNum = shaderProg->getAttribVar( "vertWeightBonesNum" ).getLoc();
+		attribLocs.vertWeightBoneIds = shaderProg->getAttribVar( "vertWeightBoneIds" ).getLoc();
+		attribLocs.vertWeightWeights = shaderProg->getAttribVar( "vertWeightWeights" ).getLoc();
+		uniLocs.skinningRotations = shaderProg->getUniVar( "skinningRotations" ).getLoc();
+		uniLocs.skinningTranslations = shaderProg->getUniVar( "skinningTranslations" ).getLoc();
+	}
+	else
+	{
+		attribLocs.vertWeightBonesNum = attribLocs.vertWeightBoneIds = attribLocs.vertWeightWeights = uniLocs.skinningRotations =
+		uniLocs.skinningTranslations = -1;
 	}
 
 	return true;

+ 85 - 67
src/resources/ShaderProg.cpp

@@ -12,7 +12,7 @@
 //=====================================================================================================================================
 // createAndCompileShader                                                                                                             =
 //=====================================================================================================================================
-uint ShaderProg::createAndCompileShader( const char* source_code, const char* preproc, int type ) const
+uint ShaderProg::createAndCompileShader( const char* sourceCode, const char* preproc, int type ) const
 {
 	uint glId = 0;
 	const char* source_strs[2] = {NULL, NULL};
@@ -21,7 +21,7 @@ uint ShaderProg::createAndCompileShader( const char* source_code, const char* pr
 	glId = glCreateShader( type );
 
 	// attach the source
-	source_strs[1] = source_code;
+	source_strs[1] = sourceCode;
 	source_strs[0] = preproc;
 
 	// compile
@@ -96,9 +96,9 @@ bool ShaderProg::link()
 
 
 //=====================================================================================================================================
-// getUniAndAttribLocs                                                                                                                =
+// getUniAndAttribVars                                                                                                                =
 //=====================================================================================================================================
-void ShaderProg::getUniAndAttribLocs()
+void ShaderProg::getUniAndAttribVars()
 {
 	int num;
 	char name_[256];
@@ -116,13 +116,15 @@ void ShaderProg::getUniAndAttribLocs()
 
 		// check if its FFP location
 		int loc = glGetAttribLocation(glId, name_);
-		if( loc == -1 )
+		if( loc == -1 ) // if -1 it means that its an FFP var
 		{
 			//SHADER_WARNING( "You are using FFP vertex attributes (\"" << name_ << "\")" );
 			continue;
 		}
 
-		attribNameToLoc[ name_ ] = loc;
+		attribNameToLoc[ name_ ] = loc; //ToDo to be removed
+		attribVars.push_back( Var( loc, name_, type, Var::LT_ATTRIBUTE ) );
+		attribNameToVar[ name_ ] = &attribVars.back();
 	}
 
 
@@ -135,13 +137,15 @@ void ShaderProg::getUniAndAttribLocs()
 
 		// check if its FFP location
 		int loc = glGetUniformLocation(glId, name_);
-		if( loc == -1 )
+		if( loc == -1 ) // if -1 it means that its an FFP var
 		{
 			//SHADER_WARNING( "You are using FFP uniforms (\"" << name_ << "\")" );
 			continue;
 		}
 
 		uniNameToLoc[ name_ ] = loc;
+		uniVars.push_back( Var( loc, name_, type, Var::LT_UNIFORM ) );
+		uniNameToVar[ name_ ] = &uniVars.back();
 	}
 }
 
@@ -169,7 +173,7 @@ bool ShaderProg::fillTheCustomLocationsVectors( const ShaderParser& pars )
 			SHADER_ERROR( "The uniform \"" << pars.getOutput().getUniLocs()[i].name << "\" has the same value with another one" );
 			return false;
 		}
-		int loc = getUniLoc( pars.getOutput().getUniLocs()[i].name.c_str() );
+		int loc = getUniVar( pars.getOutput().getUniLocs()[i].name.c_str() ).getLoc();
 		if( loc == -1 )
 		{
 			SHADER_WARNING( "Check the previous error" );
@@ -196,7 +200,7 @@ bool ShaderProg::fillTheCustomLocationsVectors( const ShaderParser& pars )
 			SHADER_ERROR( "The attribute \"" << pars.getOutput().getAttribLocs()[i].name << "\" has the same value with another one" );
 			return false;
 		}
-		int loc = getAttribLoc( pars.getOutput().getAttribLocs()[i].name.c_str() );
+		int loc = getAttribVar( pars.getOutput().getAttribLocs()[i].name.c_str() ).getLoc();
 		if( loc == -1 )
 		{
 			SHADER_ERROR( "Check the previous error" );
@@ -209,6 +213,29 @@ bool ShaderProg::fillTheCustomLocationsVectors( const ShaderParser& pars )
 }
 
 
+//=====================================================================================================================================
+// bindCustomAttribLocs                                                                                                               =
+//=====================================================================================================================================
+bool ShaderProg::bindCustomAttribLocs( const ShaderParser& pars ) const
+{
+	for( uint i=0; i<pars.getOutput().getAttribLocs().size(); ++i )
+	{
+		const string& name = pars.getOutput().getAttribLocs()[i].name;
+		int loc = pars.getOutput().getAttribLocs()[i].customLoc;
+		glBindAttribLocation( glId, loc, name.c_str() );
+
+		// check for error
+		GLenum errId = glGetError();
+		if( errId != GL_NO_ERROR )
+		{
+			SHADER_ERROR( "Something went wrong for attrib \"" << name << "\" and location " << loc << " (" << gluErrorString( errId ) << ")" );
+			return false;
+		}
+	}
+	return true;
+}
+
+
 //=====================================================================================================================================
 // load                                                                                                                               =
 //=====================================================================================================================================
@@ -222,7 +249,7 @@ bool ShaderProg::load( const char* filename )
 //=====================================================================================================================================
 // customload                                                                                                                         =
 //=====================================================================================================================================
-bool ShaderProg::customload( const char* filename, const char* extra_source )
+bool ShaderProg::customload( const char* filename, const char* extraSource )
 {
 	if( getRsrcName().length() == 0 )
 	{
@@ -234,23 +261,28 @@ bool ShaderProg::customload( const char* filename, const char* extra_source )
 
 	if( !pars.parseFile( filename ) ) return false;
 
-	// create, compile, attach and link
-	string preproc_source = R::getStdShaderPreprocDefines() + extra_source;
-	uint vert_glId = createAndCompileShader( pars.getOutput().getVertShaderSource().c_str(), preproc_source.c_str(), GL_VERTEX_SHADER );
-	if( vert_glId == 0 ) return false;
+	// 1) create and compile the shaders
+	string preproc_source = R::getStdShaderPreprocDefines() + extraSource;
+	uint vertGlId = createAndCompileShader( pars.getOutput().getVertShaderSource().c_str(), preproc_source.c_str(), GL_VERTEX_SHADER );
+	if( vertGlId == 0 ) return false;
 
-	uint frag_glId = createAndCompileShader( pars.getOutput().getFragShaderSource().c_str(), preproc_source.c_str(), GL_FRAGMENT_SHADER );
-	if( frag_glId == 0 ) return false;
+	uint fragGlId = createAndCompileShader( pars.getOutput().getFragShaderSource().c_str(), preproc_source.c_str(), GL_FRAGMENT_SHADER );
+	if( fragGlId == 0 ) return false;
 
+	// 2) create program and attach shaders
 	glId = glCreateProgram();
-	glAttachShader( glId, vert_glId );
-	glAttachShader( glId, frag_glId );
+	glAttachShader( glId, vertGlId );
+	glAttachShader( glId, fragGlId );
+
+	// 3) bind the custom attrib locs
+	if( !bindCustomAttribLocs( pars ) ) return false;
 
+	// 5) link
 	if( !link() ) return false;
 	
-	
+
 	// init the rest
-	getUniAndAttribLocs();
+	getUniAndAttribVars();
 	if( !fillTheCustomLocationsVectors( pars ) ) return false;
 
 	return true;
@@ -258,86 +290,72 @@ bool ShaderProg::customload( const char* filename, const char* extra_source )
 
 
 //=====================================================================================================================================
-// getUniLoc                                                                                                                 =
+// getUniLoc                                                                                                                          =
 //=====================================================================================================================================
-int ShaderProg::getUniLoc( const char* name ) const
+int ShaderProg::getUniLoc( int id ) const
 {
-	DEBUG_ERR( glId == 0 ); // not initialized
-	NameToLocIterator it = uniNameToLoc.find( name );
-	if( it == uniNameToLoc.end() )
-	{
-		SHADER_ERROR( "Cannot get uniform loc \"" << name << '\"' );
-		return -1;
-	}
-	return it->second;
+	DEBUG_ERR( uint(id) >= customUniLocToRealLoc.size() );
+	DEBUG_ERR( customUniLocToRealLoc[id] == -1 );
+	return customUniLocToRealLoc[id];
 }
 
 
 //=====================================================================================================================================
-// getAttribLoc                                                                                                               =
+// getAttribLoc                                                                                                                       =
 //=====================================================================================================================================
-int ShaderProg::getAttribLoc( const char* name ) const
+int ShaderProg::getAttribLoc( int id ) const
 {
-	DEBUG_ERR( glId == 0 ); // not initialized
-	NameToLocIterator it = attribNameToLoc.find( name );
-	if( it == attribNameToLoc.end() )
-	{
-		SHADER_ERROR( "Cannot get attrib loc \"" << name << '\"' );
-		return -1;
-	}
-	return it->second;
+	DEBUG_ERR( uint(id) >= customAttribLocToRealLoc.size() );
+	DEBUG_ERR( customAttribLocToRealLoc[id] == -1 );
+	return customAttribLocToRealLoc[id];
 }
 
 
 //=====================================================================================================================================
-// getUniLocSilently                                                                                                         =
+// getUniVar                                                                                                                          =
 //=====================================================================================================================================
-int ShaderProg::getUniLocSilently( const char* name ) const
+const ShaderProg::Var& ShaderProg::getUniVar( const char* name ) const
 {
-	DEBUG_ERR( glId == 0 ); // not initialized
-	NameToLocIterator it = uniNameToLoc.find( name );
-	if( it == uniNameToLoc.end() )
+	NameToVarIterator it = uniNameToVar.find( name );
+	if( it == uniNameToVar.end() )
 	{
-		return -1;
+		SHADER_ERROR( "Cannot get uniform loc \"" << name << '\"' );
 	}
-	return it->second;
+	return *(it->second);
 }
 
 
 //=====================================================================================================================================
-// getAttribLocSilently                                                                                                       =
+// getAttribVar                                                                                                                       =
 //=====================================================================================================================================
-int ShaderProg::getAttribLocSilently( const char* name ) const
+const ShaderProg::Var& ShaderProg::getAttribVar( const char* name ) const
 {
-	DEBUG_ERR( glId == 0 ); // not initialized
-	NameToLocIterator it = attribNameToLoc.find( name );
-	if( it == attribNameToLoc.end() )
+	NameToVarIterator it = attribNameToVar.find( name );
+	if( it == attribNameToVar.end() )
 	{
-		return -1;
+		SHADER_ERROR( "Cannot get attribute loc \"" << name << '\"' );
 	}
-	return it->second;
+	return *(it->second);
 }
 
 
 //=====================================================================================================================================
-// getUniLoc                                                                                                                 =
+// uniVarExists                                                                                                                       =
 //=====================================================================================================================================
-int ShaderProg::GetUniLoc( int id ) const
+bool ShaderProg::uniVarExists( const char* name ) const
 {
-	DEBUG_ERR( uint(id) >= customUniLocToRealLoc.size() );
-	DEBUG_ERR( customUniLocToRealLoc[id] == -1 );
-	return customUniLocToRealLoc[id];
+	NameToVarIterator it = uniNameToVar.find( name );
+	return it != uniNameToVar.end();
 }
 
 
 //=====================================================================================================================================
-// getAttribLoc                                                                                                               =
+// attribVarExists                                                                                                                    =
 //=====================================================================================================================================
-int ShaderProg::getAttribLoc( int id ) const
+bool ShaderProg::attribVarExists( const char* name ) const
 {
-	DEBUG_ERR( uint(id) >= customAttribLocToRealLoc.size() );
-	DEBUG_ERR( customAttribLocToRealLoc[id] == -1 );
-	return customAttribLocToRealLoc[id];
+	NameToVarIterator it = attribNameToVar.find( name );
+	return it != attribNameToVar.end();
 }
 
 
@@ -347,14 +365,14 @@ int ShaderProg::getAttribLoc( int id ) const
 void ShaderProg::locTexUnit( int loc, const Texture& tex, uint tex_unit ) const
 {
 	DEBUG_ERR( loc == -1 );
-	DEBUG_ERR( getCurrentProgram() != glId );
+	DEBUG_ERR( getCurrentProgramGlId() != glId );
 	tex.bind( tex_unit );
 	glUniform1i( loc, tex_unit );
 }
 
 void ShaderProg::locTexUnit( const char* loc, const Texture& tex, uint tex_unit ) const
 {
-	DEBUG_ERR( getCurrentProgram() != glId );
+	DEBUG_ERR( getCurrentProgramGlId() != glId );
 	tex.bind( tex_unit );
-	glUniform1i( getUniLoc(loc), tex_unit );
+	glUniform1i( getUniVar(loc).getLoc(), tex_unit );
 }

+ 56 - 14
src/resources/ShaderProg.h

@@ -9,12 +9,41 @@
 class ShaderParser;
 class Texture;
 
-/// Shader program. Combines a fragment and a vertex shader
+/**
+ * Shader program. Combines a fragment and a vertex shader. Every shader program consist of one OpenGL ID, a vector of uniform variables
+ * and a vector of attribute variables. Every variable is a struct that contains the variable's name, location, OpenGL data type and
+ * if it is a uniform or an attribute var.
+ */
 class ShaderProg: public Resource
 {
 	PROPERTY_R( uint, glId, getGlId )
 	
 	private:
+		class Var
+		{
+			PROPERTY_R( int, loc, getLoc );
+			PROPERTY_R( string, name, getName );
+			PROPERTY_R( GLenum, glDataType, getGlDataType ); ///< GL_FLOAT, GL_FLOAT_VEC2... etc
+			PROPERTY_R( uint, type, getType ); ///< LT_ATTRIBUTE or LT_UNIFORM
+
+			public:
+				enum
+				{
+					LT_ATTRIBUTE,
+					LT_UNIFORM
+				};
+
+				Var( int loc_, const char* name_, GLenum glDataType_, uint type_ ):
+					loc(loc_), name(name_), glDataType(glDataType_), type(type_)
+				{}
+		};
+
+		Vec<Var> uniVars;
+		Vec<Var> attribVars;
+		map<string,Var*> uniNameToVar;  ///< A map for quick searching
+		map<string,Var*> attribNameToVar; ///< @see uniNameToVar
+		typedef map<string,Var*>::const_iterator NameToVarIterator; ///< Variable name to variable iterator
+
 		typedef map<string,int>::const_iterator NameToLocIterator; ///< name to location iterator
 	
 		Vec<int> customUniLocToRealLoc;
@@ -22,10 +51,11 @@ class ShaderProg: public Resource
 		map<string,int> uniNameToLoc;
 		map<string,int> attribNameToLoc;
 		
-		void getUniAndAttribLocs();
+		void getUniAndAttribVars(); ///< After the linking of the shader prog is done gather all the vars in custom containers
 		bool fillTheCustomLocationsVectors( const ShaderParser& pars );
-		uint createAndCompileShader( const char* source_code, const char* preproc, int type ) const; ///< @return Returns zero on falure
-		bool link();
+		bool bindCustomAttribLocs( const ShaderParser& pars ) const; ///< Uses glBindAttribLocation for every parser attrib location
+		uint createAndCompileShader( const char* sourceCode, const char* preproc, int type ) const; ///< @return Returns zero on failure
+		bool link(); ///< Link the shader prog
 		
 	public:
 		ShaderProg(): glId(0) {}
@@ -33,23 +63,35 @@ class ShaderProg: public Resource
 		
 		inline void bind() const { DEBUG_ERR( glId==0 ); glUseProgram(glId); }
 		static void unbind() { glUseProgram(0); }
-		static uint getCurrentProgram() { int i; glGetIntegerv( GL_CURRENT_PROGRAM, &i ); return i; }
+		static uint getCurrentProgramGlId() { int i; glGetIntegerv( GL_CURRENT_PROGRAM, &i ); return i; }
 
 		bool load( const char* filename );
-		bool customload( const char* filename, const char* extra_source );
+		bool customload( const char* filename, const char* extraSource ); ///< Used by the renderer's shader programs
 		void unload() { /* ToDo: add code */ }
 
-		int getUniLoc( const char* name ) const; ///< Returns -1 if fail and throws error
-		int getAttribLoc( const char* name ) const; ///< Returns -1 if fail and throws error
-		int getUniLocSilently( const char* name ) const;
-		int getAttribLocSilently( const char* name ) const;
+		const Vec<Var>& getUniVars() const { return uniVars; } ///< Accessor to uniform vars vector
+		const Vec<Var>& getAttribVars() const { return attribVars; } ///< Accessor to attribute vars vector
 
-		int GetUniLoc( int id ) const;
+		int getUniLoc( int id ) const;
 		int getAttribLoc( int id ) const;
 
-		// The function's code is being used way to often so a function has to be made
-		void locTexUnit( int location, const Texture& tex, uint tex_unit ) const;
-		void locTexUnit( const char* name, const Texture& tex, uint tex_unit ) const;
+		/**
+		 * @param name The name of the var
+		 * @return It returns a uniform variable and on failure it throws an error and returns something random
+		 */
+		const Var& getUniVar( const char* varName ) const;
+		const Var& getAttribVar( const char* varName ) const; ///< @see getUniVar
+		bool uniVarExists( const char* varName ) const;
+		bool attribVarExists( const char* varName ) const;
+
+		/**
+		 * The function's code is being used way to often so a function has to be made. It connects a location a texture and a texture unit
+		 * @param location Shader program variable location
+		 * @param tex The texture
+		 * @param texUnit The number of the texture unit
+		 */
+		void locTexUnit( int varLoc, const Texture& tex, uint texUnit ) const;
+		void locTexUnit( const char* varName, const Texture& tex, uint texUnit ) const; ///< @see locTexUnit
 }; 
 
 #endif

+ 1 - 1
src/ui/Ui.cpp

@@ -38,7 +38,7 @@ static funcs
 static void SetGL()
 {
 	shader->bind();
-	shader->locTexUnit( shader->GetUniLoc(0), *fontMap, 0 );
+	shader->locTexUnit( shader->getUniLoc(0), *fontMap, 0 );
 
 	glEnable( GL_BLEND );
 	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

+ 4 - 4
src/uncategorized/skybox.cpp

@@ -59,10 +59,10 @@ void Skybox::Render( const Mat3& rotation )
 	glPushMatrix();
 
 	shader->bind();
-	glUniform1i( shader->getUniLoc("colormap"), 0 );
-	shader->locTexUnit( shader->getUniLoc("noisemap"), *noise, 1 );
-	glUniform1f( shader->getUniLoc("timer"), (rotation_ang/(2*PI))*100 );
-	glUniform3fv( shader->getUniLoc("scene_ambient_color"), 1, &(Vec3( 1.0, 1.0, 1.0 ) / Scene::getAmbientColor())[0] );
+	glUniform1i( shader->getUniVar("colormap").getLoc(), 0 );
+	shader->locTexUnit( shader->getUniVar("noisemap").getLoc(), *noise, 1 );
+	glUniform1f( shader->getUniVar("timer").getLoc(), (rotation_ang/(2*PI))*100 );
+	glUniform3fv( shader->getUniVar("scene_ambient_color").getLoc(), 1, &(Vec3( 1.0, 1.0, 1.0 ) / Scene::getAmbientColor())[0] );
 
 	// set the rotation matrix
 	Mat3 tmp( rotation );