瀏覽代碼

Redesining the ShaderProg

Panagiotis Christopoulos Charitos 16 年之前
父節點
當前提交
bf1ca1341c

+ 0 - 1
shaders/bs_refract.glsl

@@ -5,7 +5,6 @@
 
 #pragma anki fragShaderBegins
 
-#pragma anki uniform fai 0
 uniform sampler2D fai;
 
 varying vec2 texCoords;

+ 0 - 2
shaders/dp_hw_skinning.glsl

@@ -1,7 +1,5 @@
 #define _HW_SKINNING_
 
-#pragma anki uniform skinningRotations 0
-#pragma anki uniform skinningTranslations 1
 #pragma anki attribute vertWeightBonesNum 0
 #pragma anki attribute vertWeightBoneIds 1
 #pragma anki attribute vertWeightWeights 2

+ 6 - 7
shaders/final.glsl

@@ -4,21 +4,20 @@
 
 #pragma anki fragShaderBegins
 
-#pragma anki uniform raster_image 0
-uniform sampler2D raster_image;
+uniform sampler2D rasterImage;
 varying vec2 texCoords;
 
 void main()
 {
 	//if( gl_FragCoord.x > 0.5 ) discard;
 
-	gl_FragColor.rgb = texture2D( raster_image, texCoords ).rgb;
+	gl_FragColor.rgb = texture2D( rasterImage, texCoords ).rgb;
 
-	/*vec4 c = texture2D( raster_image, texCoords );
+	/*vec4 c = texture2D( rasterImage, 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, texCoords ).a );
-	//gl_FragColor.rgb = MedianFilter( raster_image, texCoords );
+		//gl_FragColor.rgb = vec3( texture2D( rasterImage, texCoords ).a );
+	//gl_FragColor.rgb = MedianFilter( rasterImage, 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;
+	//gl_FragColor.rgb = texture2D( rasterImage, gl_FragCoord.xy/textureSize(rasterImage,0) ).rgb;
 }

+ 3 - 5
shaders/is_ap.glsl

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

+ 76 - 76
shaders/is_lp_generic.glsl

@@ -23,15 +23,15 @@ void main()
 #pragma anki include "shaders/pack.glsl"
 
 // uniforms
-uniform sampler2D ms_normal_fai, ms_diffuse_fai, ms_specular_fai, ms_depth_fai;
+uniform sampler2D msNormalFai, msDiffuseFai, msSpecularFai, msDepthFai;
 uniform vec2 planes; // for the calculation of frag pos in view space
-uniform sampler2D light_tex;
-uniform sampler2DShadow shadow_map;
-uniform vec3 light_pos;
-uniform float light_inv_radius;
-uniform vec3 light_diffuse_col;
-uniform vec3 light_specular_col;
-uniform mat4 tex_projection_mat;
+uniform sampler2D lightTex;
+uniform sampler2DShadow shadowMap;
+uniform vec3 lightPos;
+uniform float lightInvRadius;
+uniform vec3 lightDiffuseCol;
+uniform vec3 lightSpecularCol;
+uniform mat4 texProjectionMat;
 
 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, texCoords ).r;
+	float _depth = texture2D( msDepthFai, texCoords ).r;
 
 	if( _depth == 1.0 ) discard;
 
@@ -65,7 +65,7 @@ return the attenuation factor fiven the distance from the frag to the light sour
 */
 float Attenuation( in float _frag_light_dist )
 {
-	return clamp(1.0 - light_inv_radius * sqrt(_frag_light_dist), 0.0, 1.0);
+	return clamp(1.0 - lightInvRadius * sqrt(_frag_light_dist), 0.0, 1.0);
 	//return 1.0 - _frag_light_dist * _inv_light_radius;
 }
 
@@ -80,23 +80,23 @@ it returns a blured shadow
 
 float PCF_Off( in vec3 _shadow_uv )
 {
-	return shadow2D(shadow_map, _shadow_uv ).r;
+	return shadow2D(shadowMap, _shadow_uv ).r;
 }
 
 
 float PCF_Low( in vec3 _shadow_uv )
 {
-	float _shadow_col = shadow2D(shadow_map, _shadow_uv ).r;
+	float _shadow_col = shadow2D(shadowMap, _shadow_uv ).r;
 	const float _map_scale = 1.0 / SHADOWMAP_SIZE;
 
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale, -_map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale,         0.0, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale, -_map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale,         0.0, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(        0.0,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(        0.0, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale,         0.0, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale,         0.0, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(        0.0,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(        0.0, -_map_scale, 0.0)).r;
 	_shadow_col *= 1.0/9.0;
 
 	return _shadow_col;
@@ -105,28 +105,28 @@ float PCF_Low( in vec3 _shadow_uv )
 
 float PCF_Medium( in vec3 _shadow_uv )
 {
-	float _shadow_col = shadow2D(shadow_map, _shadow_uv ).r;
+	float _shadow_col = shadow2D(shadowMap, _shadow_uv ).r;
 	float _map_scale = 1.0 / SHADOWMAP_SIZE;
 
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale, -_map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale,         0.0, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale, -_map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale,         0.0, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(        0.0,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(        0.0, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale,         0.0, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale,         0.0, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(        0.0,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(        0.0, -_map_scale, 0.0)).r;
 
 	_map_scale *= 2.0;
 
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale, -_map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale,         0.0, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale, -_map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale,         0.0, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(        0.0,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(        0.0, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale,         0.0, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale,         0.0, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(        0.0,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(        0.0, -_map_scale, 0.0)).r;
 
 	_shadow_col *= 0.058823529; // aka: _shadow_col /= 17.0;
 	return _shadow_col;
@@ -135,37 +135,37 @@ float PCF_Medium( in vec3 _shadow_uv )
 
 float PCF_High( in vec3 _shadow_uv )
 {
-	float _shadow_col = shadow2D(shadow_map, _shadow_uv ).r;
+	float _shadow_col = shadow2D(shadowMap, _shadow_uv ).r;
 	float _map_scale = 1.0 / SHADOWMAP_SIZE;
 
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale, -_map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3( _map_scale,  	     0.0, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale, -_map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale,  	     0.0, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(        0.0,  _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(        0.0, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3( _map_scale,  	     0.0, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale,  	     0.0, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(        0.0,  _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(        0.0, -_map_scale, 0.0)).r;
 
 
 	float _map_scale_2 = 2.0 * _map_scale;
 
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(_map_scale_2, _map_scale_2, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(_map_scale, _map_scale_2, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(0.0, _map_scale_2, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale, _map_scale_2, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale_2, _map_scale_2, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale_2, _map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale_2, 0.0, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale_2, -_map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale_2, -_map_scale_2, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(-_map_scale, -_map_scale_2, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(0.0, -_map_scale_2, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(_map_scale, -_map_scale_2, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(_map_scale_2, -_map_scale_2, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(_map_scale_2, -_map_scale, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(_map_scale_2, 0.0, 0.0)).r;
-	_shadow_col += shadow2D(shadow_map, _shadow_uv.xyz + vec3(_map_scale_2, _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(_map_scale_2, _map_scale_2, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(_map_scale, _map_scale_2, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(0.0, _map_scale_2, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale, _map_scale_2, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale_2, _map_scale_2, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale_2, _map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale_2, 0.0, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale_2, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale_2, -_map_scale_2, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(-_map_scale, -_map_scale_2, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(0.0, -_map_scale_2, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(_map_scale, -_map_scale_2, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(_map_scale_2, -_map_scale_2, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(_map_scale_2, -_map_scale, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(_map_scale_2, 0.0, 0.0)).r;
+	_shadow_col += shadow2D(shadowMap, _shadow_uv.xyz + vec3(_map_scale_2, _map_scale, 0.0)).r;
 
 	_shadow_col /= 25.0;
 	return _shadow_col;
@@ -182,15 +182,15 @@ Phong
 vec3 Phong( in vec3 _frag_pos_vspace, out float _frag_light_dist )
 {
 	// get the lambert term
-	vec3 _light_pos_eyespace = light_pos;
-	vec3 _light_frag_vec = _light_pos_eyespace - _frag_pos_vspace;
+	vec3 _lightPos_eyespace = lightPos;
+	vec3 _light_frag_vec = _lightPos_eyespace - _frag_pos_vspace;
 
 	_frag_light_dist = dot( _light_frag_vec, _light_frag_vec ); // instead of using normalize(_frag_light_dist) we brake the operation...
 	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, texCoords ).rgb;
-	vec3 _normal = UnpackNormal( texture2D( ms_normal_fai, texCoords ).rg );
+	//vec3 _normal = texture2D( msNormalFai, texCoords ).rgb;
+	vec3 _normal = UnpackNormal( texture2D( msNormalFai, texCoords ).rg );
 
 	// the lambert term
 	float _lambert_term = dot( _normal, _light_dir );
@@ -199,19 +199,19 @@ 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, texCoords ).rgb;
-	_diffuse = (_diffuse * light_diffuse_col);
+	vec3 _diffuse = texture2D( msDiffuseFai, texCoords ).rgb;
+	_diffuse = (_diffuse * lightDiffuseCol);
 	vec3 _color = _diffuse * _lambert_term;
 
 	// specular lighting
-	vec4 _specular_mix = texture2D( ms_specular_fai, texCoords );
+	vec4 _specular_mix = texture2D( msSpecularFai, texCoords );
 	vec3 _specular = _specular_mix.xyz;
 	float _shininess = _specular_mix.w;
 
 	vec3 _eye_vec = normalize( -_frag_pos_vspace );
 	vec3 _h = normalize( _light_dir + _eye_vec );
 	float _spec_intensity = pow(max(0.0, dot(_normal, _h)), _shininess);
-	_color += _specular * light_specular_col * (_spec_intensity * _lambert_term);
+	_color += _specular * lightSpecularCol * (_spec_intensity * _lambert_term);
 
 	return _color;
 }
@@ -242,7 +242,7 @@ void main()
 	// SPOT LIGHT                                                                                                                       =
 	//===================================================================================================================================
 	#elif defined(_SPOT_LIGHT_)
-		vec4 _tex_coord2 = tex_projection_mat * vec4(_frag_pos_vspace, 1.0);
+		vec4 _tex_coord2 = texProjectionMat * vec4(_frag_pos_vspace, 1.0);
 		vec3 _texCoords3 = _tex_coord2.xyz / _tex_coord2.w;
 
 		if
@@ -252,13 +252,13 @@ void main()
 			_texCoords3.x < 1.0 &&
 			_texCoords3.y > 0.0 &&
 			_texCoords3.y < 1.0 &&
-			_tex_coord2.w < 1.0/light_inv_radius
+			_tex_coord2.w < 1.0/lightInvRadius
 		)
 		{
 			#if defined( _SHADOW_ )
 				#if defined( _SHADOW_MAPPING_PCF_ )
 					float _shadow_color = PCF_Low( _texCoords3 );
-					//float _shadow_color = MedianFilterPCF( shadow_map, _texCoords3 );
+					//float _shadow_color = MedianFilterPCF( shadowMap, _texCoords3 );
 				#else
 					float _shadow_color = PCF_Off( _texCoords3 );
 				#endif
@@ -269,7 +269,7 @@ void main()
 			float _frag_light_dist;
 			vec3 _color = Phong( _frag_pos_vspace, _frag_light_dist );
 
-			vec3 _texel = texture2DProj( light_tex, _tex_coord2.xyz ).rgb;
+			vec3 _texel = texture2DProj( lightTex, _tex_coord2.xyz ).rgb;
 			float _att = Attenuation(_frag_light_dist);
 
 			#if defined( _SHADOW_ )
@@ -285,7 +285,7 @@ void main()
 	#endif // spot light
 
 	/*#if defined(_SPOT_LIGHT_)
-	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 );
+	gl_FragData[0] = vec4( UnpackNormal(texture2D( msNormalFai, texCoords ).rg), 1.0 );
+	//gl_FragData[0] = vec4( texture2D( msDepthFai, texCoords ).rg), 1.0 );
 	#endif*/
 }

+ 0 - 10
shaders/is_lp_point.glsl

@@ -1,13 +1,3 @@
 #define _POINT_LIGHT_
 
-#pragma anki uniform ms_normal_fai 0
-#pragma anki uniform ms_diffuse_fai 1
-#pragma anki uniform ms_specular_fai 2
-#pragma anki uniform ms_depth_fai 3
-#pragma anki uniform planes 4
-#pragma anki uniform light_pos 5
-#pragma anki uniform light_inv_radius 6
-#pragma anki uniform light_diffuse_col 7
-#pragma anki uniform light_specular_col 8
-
 #pragma anki include "shaders/is_lp_generic.glsl"

+ 0 - 12
shaders/is_lp_spot.glsl

@@ -1,15 +1,3 @@
 #define _SPOT_LIGHT_
 
-#pragma anki uniform ms_normal_fai 0
-#pragma anki uniform ms_diffuse_fai 1
-#pragma anki uniform ms_specular_fai 2
-#pragma anki uniform ms_depth_fai 3
-#pragma anki uniform planes 4
-#pragma anki uniform light_pos 5
-#pragma anki uniform light_inv_radius 6
-#pragma anki uniform light_diffuse_col 7
-#pragma anki uniform light_specular_col 8
-#pragma anki uniform light_tex 9
-#pragma anki uniform tex_projection_mat 10
-
 #pragma anki include "shaders/is_lp_generic.glsl"

+ 0 - 13
shaders/is_lp_spot_shad.glsl

@@ -1,17 +1,4 @@
 #define _SPOT_LIGHT_
 #define _SHADOW_
 
-#pragma anki uniform ms_normal_fai 0
-#pragma anki uniform ms_diffuse_fai 1
-#pragma anki uniform ms_specular_fai 2
-#pragma anki uniform ms_depth_fai 3
-#pragma anki uniform planes 4
-#pragma anki uniform light_pos 5
-#pragma anki uniform light_inv_radius 6
-#pragma anki uniform light_diffuse_col 7
-#pragma anki uniform light_specular_col 8
-#pragma anki uniform light_tex 9
-#pragma anki uniform tex_projection_mat 10
-#pragma anki uniform shadow_map 11
-
 #pragma anki include "shaders/is_lp_generic.glsl"

+ 6 - 6
shaders/ms_mp_generic.glsl

@@ -114,9 +114,9 @@ VARS
 */
 
 uniform sampler2D diffuseMap;
-uniform sampler2D notmalMap;
+uniform sampler2D normalMap;
 uniform sampler2D specularMap;
-uniform sampler2D height_map;
+uniform sampler2D heightMap;
 uniform sampler2D environmentMap;
 uniform vec3 diffuseCol = vec3( 1.0, 1.0, 1.0 );
 uniform vec3 specularCol = vec3( 1.0, 1.0, 1.0 );
@@ -148,7 +148,7 @@ void main()
 
 		vec3 _norm_eye = normalize( eye );
 
-		float _h = texture2D( height_map, texCoords_v2f ).r;
+		float _h = texture2D( heightMap, texCoords_v2f ).r;
 		float _height = _scale * _h - _bias;
 
 		vec2 superTexCoords_v2f = _height * _norm_eye.xy + texCoords_v2f;*/
@@ -161,7 +161,7 @@ void main()
 		dir.xy /= 8.0;
 		dir /= -nSteps * dir.z;
 
-		float diff0, diff1 = 1.0 - texture2D( height_map, superTexCoords ).a;
+		float diff0, diff1 = 1.0 - texture2D( heightMap, superTexCoords ).a;
 		if( diff1 > 0.0 )
 		{
 			do 
@@ -169,7 +169,7 @@ void main()
 				superTexCoords += dir.xy;
 
 				diff0 = diff1;
-				diff1 = texture2D(height_map, superTexCoords ).w;
+				diff1 = texture2D(heightMap, superTexCoords ).w;
 			} while( diff1 > 0.0 );
 
 			superTexCoords.xy += (diff1 / (diff0 - diff1)) * dir.xy;
@@ -211,7 +211,7 @@ void main()
 
 		mat3 tbnMat = mat3(_t,_b,_n);
 
-		vec3 nAtTangentspace = ( texture2D( notmalMap, superTexCoords ).rgb - 0.5 ) * 2.0;
+		vec3 nAtTangentspace = ( texture2D( normalMap, superTexCoords ).rgb - 0.5 ) * 2.0;
 
 		vec3 newNormal = normalize( tbnMat * nAtTangentspace );
 	#else

+ 2 - 6
shaders/ms_mp_skybox.glsl

@@ -10,14 +10,10 @@ void main()
 
 #pragma anki fragShaderBegins
 
-#pragma anki uniform colormap 0
 uniform sampler2D colormap;
-#pragma anki uniform noisemap 1
 uniform sampler2D noisemap;
-#pragma anki uniform timer 2
 uniform float timer;
-#pragma anki uniform scene_ambient_color 3
-uniform vec3 scene_ambient_color;
+uniform vec3 sceneAmbientCol;
 varying vec2 txtr_coords;
 
 #define PI 3.14159265358979323846
@@ -47,6 +43,6 @@ void main()
 
 	_noise_vec = _noise_vec * _strength_factor * _edge_factor;
 
-	gl_FragData[1].rgb = texture2D(colormap, txtr_coords + _noise_vec.xy).rgb * scene_ambient_color; // write to the diffuse buffer
+	gl_FragData[1].rgb = texture2D(colormap, txtr_coords + _noise_vec.xy).rgb * sceneAmbientCol; // write to the diffuse buffer
 }
 

+ 0 - 1
shaders/pps_hdr_generic.glsl

@@ -8,7 +8,6 @@
 
 varying vec2 texCoords;
 
-#pragma anki uniform tex 0
 uniform sampler2D tex;
 
 void main()

+ 8 - 12
shaders/pps_ssao.glsl

@@ -7,14 +7,10 @@
 #pragma anki include "shaders/linear_depth.glsl"
 #pragma anki include "shaders/pack.glsl"
 
-#pragma anki uniform camerarange 0
 uniform vec2 camerarange;  // = vec2( znear, zfar )
-#pragma anki uniform ms_depth_fai 1
-uniform sampler2D ms_depth_fai;
-#pragma anki uniform noise_map 2
-uniform sampler2D noise_map;
-#pragma anki uniform ms_normal_fai 3
-uniform sampler2D ms_normal_fai;
+uniform sampler2D msDepthFai;
+uniform sampler2D noiseMap;
+uniform sampler2D msNormalFai;
 
 varying vec2 texCoords;
 const float totStrength = 1.7;
@@ -33,11 +29,11 @@ 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,texCoords*offset).xyz*2.0) - vec3(1.0));
+	vec3 fres = normalize((texture2D(noiseMap,texCoords*offset).xyz*2.0) - vec3(1.0));
 
-	vec4 currentPixelSample = texture2D(ms_normal_fai,texCoords);
+	vec4 currentPixelSample = texture2D(msNormalFai,texCoords);
 
-	float currentPixelDepth = ReadFromTexAndLinearizeDepth( ms_depth_fai, texCoords, camerarange.x, camerarange.y );
+	float currentPixelDepth = ReadFromTexAndLinearizeDepth( msDepthFai, texCoords, camerarange.x, camerarange.y );
 
 	// current fragment coords in screen space
 	vec3 ep = vec3( texCoords.xy, currentPixelDepth );
@@ -60,13 +56,13 @@ void main(void)
 		se = ep + sign(dot(ray,norm) )*ray;
 
 		// get the depth of the occluder fragment
-		vec4 occluderFragment = texture2D(ms_normal_fai,se.xy);
+		vec4 occluderFragment = texture2D(msNormalFai,se.xy);
 
 		// get the normal of the occluder fragment
 		occNorm = UnpackNormal(occluderFragment.xy);
 
 		// if depthDifference is negative = occluder is behind current fragment
-		depthDifference = currentPixelDepth - ReadFromTexAndLinearizeDepth( ms_depth_fai, se.xy, camerarange.x, camerarange.y );;
+		depthDifference = currentPixelDepth - ReadFromTexAndLinearizeDepth( msDepthFai, se.xy, camerarange.x, camerarange.y );;
 
 		// calculate the difference between the normals as a weight
 

+ 0 - 1
shaders/pps_ssao_blur.glsl

@@ -8,7 +8,6 @@
 
 varying vec2 texCoords;
 
-#pragma anki uniform tex 0
 uniform sampler2D tex;
 
 void main()

+ 0 - 1
shaders/pps_ssao_blur2.glsl

@@ -8,7 +8,6 @@
 
 varying vec2 texCoords;
 
-#pragma anki uniform tex 0
 uniform sampler2D tex;
 
 void main()

+ 0 - 1
shaders/txt.glsl

@@ -11,7 +11,6 @@ void main(void)
 
 #pragma anki fragShaderBegins
 
-#pragma anki uniform fontMap 0
 uniform sampler2D fontMap;
 varying vec2 texCoords;
 

+ 0 - 4
src/main.cpp

@@ -249,16 +249,12 @@ void init()
 //=====================================================================================================================================
 int main( int /*argc*/, char* /*argv*/[] )
 {
-	float f = M::sin( 10.0 );
-	PRINT( f );
-
 	App::printAppInfo();
 
 	init();
 
 	PRINT( "Entering main loop" );
 	int ticks = App::getTicks();
-	uint ms = 0;
 	do
 	{
 		int ticks_ = App::getTicks();

+ 5 - 5
src/renderer/Bs2.cpp

@@ -22,7 +22,7 @@ namespace Bs {
 static Fbo intermid_fbo, fbo;
 
 static Texture fai; ///< RGB for color and A for mask (0 doesnt pass, 1 pass)
-static ShaderProg* shader_prog;
+static ShaderProg* shaderProg;
 
 
 //=====================================================================================================================================
@@ -69,7 +69,7 @@ void init2()
 	// unbind
 	intermid_fbo.Unbind();
 
-	shader_prog = rsrc::shaders.load( "shaders/bs_refract.glsl" );
+	shaderProg = rsrc::shaders.load( "shaders/bs_refract.glsl" );
 }
 
 
@@ -100,9 +100,9 @@ void runStage2( const Camera& cam )
 
 			fbo.bind();
 			glDisable( GL_DEPTH_TEST );
-			shader_prog->bind();
-			shader_prog->locTexUnit( shader_prog->getUniLoc(0), fai, 0 );
-			R::DrawQuad( shader_prog->getAttribLoc(0) );
+			shaderProg->bind();
+			shaderProg->locTexUnit( shaderProg->getUniVar("fai").getLoc(), fai, 0 );
+			R::DrawQuad( 0 );
 		}
 	}
 

+ 0 - 1
src/renderer/Dbg.cpp

@@ -19,7 +19,6 @@ extern btDiscreteDynamicsWorld* dynamicsWorld;
 
 void renderscene( int pass )
 {
-	return;
 	btScalar m[16];
 	btMatrix3x3 rot;
 	rot.setIdentity();

+ 6 - 6
src/renderer/Hdr.cpp

@@ -103,10 +103,10 @@ void runPass( const Camera& /*cam*/ )
 
 	pass0_shdr->bind();
 
-	pass0_shdr->locTexUnit( pass0_shdr->getUniLoc(0), R::Is::fai, 0 );
+	pass0_shdr->locTexUnit( pass0_shdr->getUniVar("tex").getLoc(), R::Is::fai, 0 );
 
 	// Draw quad
-	R::DrawQuad( pass0_shdr->getAttribLoc(0) );
+	R::DrawQuad( 0 );
 
 
 	// pass 1
@@ -114,10 +114,10 @@ void runPass( const Camera& /*cam*/ )
 
 	pass1_shdr->bind();
 
-	pass1_shdr->locTexUnit( pass1_shdr->getUniLoc(0), pass0Fai, 0 );
+	pass1_shdr->locTexUnit( pass1_shdr->getUniVar("tex").getLoc(), pass0Fai, 0 );
 
 	// Draw quad
-	R::DrawQuad( pass1_shdr->getAttribLoc(0) );
+	R::DrawQuad( 0 );
 
 
 	// pass 2
@@ -125,10 +125,10 @@ void runPass( const Camera& /*cam*/ )
 
 	pass2_shdr->bind();
 
-	pass2_shdr->locTexUnit( pass2_shdr->getUniLoc(0), pass1Fai, 0 );
+	pass2_shdr->locTexUnit( pass2_shdr->getUniVar("tex").getLoc(), pass1Fai, 0 );
 
 	// Draw quad
-	R::DrawQuad( pass2_shdr->getAttribLoc(0) );
+	R::DrawQuad( 0 );
 
 	// end
 	Fbo::Unbind();

+ 36 - 36
src/renderer/Is.cpp

@@ -189,11 +189,11 @@ 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->getUniVar("ambientCol").getLoc(), 1, &((Vec3)color)[0] );
+	ambientSProg->locTexUnit( ambientSProg->getUniVar("sceneColMap").getLoc(), R::Ms::diffuseFai, 0 );
 
 	// Draw quad
-	R::DrawQuad( ambientSProg->getAttribLoc(0) );
+	R::DrawQuad( 0 );
 }
 
 
@@ -329,29 +329,29 @@ 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.getUniVar("msNormalFai").getLoc(), R::Ms::normalFai, 0 );
+	shader.locTexUnit( shader.getUniVar("msDiffuseFai").getLoc(), R::Ms::diffuseFai, 1 );
+	shader.locTexUnit( shader.getUniVar("msSpecularFai").getLoc(), R::Ms::specularFai, 2 );
+	shader.locTexUnit( shader.getUniVar("msDepthFai").getLoc(), R::Ms::depthFai, 3 );
+	glUniform2fv( shader.getUniVar("planes").getLoc(), 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.getUniVar("lightPos").getLoc(), 1, &light_pos_eye_space[0] );
+	glUniform1f( shader.getUniVar("lightInvRadius").getLoc(), 1.0/light.radius );
+	glUniform3fv( shader.getUniVar("lightDiffuseCol").getLoc(), 1, &Vec3(light.lightProps->getDiffuseColor())[0] );
+	glUniform3fv( shader.getUniVar("lightSpecularCol").getLoc(), 1, &Vec3(light.lightProps->getSpecularColor())[0] );
 
 	//** render quad **
-	glEnableVertexAttribArray( shader.getAttribLoc(0) );
-	glEnableVertexAttribArray( shader.getAttribLoc(1) );
+	glEnableVertexAttribArray( 0 );
+	glEnableVertexAttribArray( 1 );
 
-	glVertexAttribPointer( shader.getAttribLoc(0), 2, GL_FLOAT, false, 0, &R::quad_vert_cords[0] );
-	glVertexAttribPointer( shader.getAttribLoc(1), 3, GL_FLOAT, false, 0, &view_vectors[0] );
+	glVertexAttribPointer( 0, 2, GL_FLOAT, false, 0, &R::quad_vert_cords[0] );
+	glVertexAttribPointer( 1, 3, GL_FLOAT, false, 0, &view_vectors[0] );
 
 	glDrawArrays( GL_QUADS, 0, 4 );
 
-	glDisableVertexAttribArray( shader.getAttribLoc(0) );
-	glDisableVertexAttribArray( shader.getAttribLoc(1) );
+	glDisableVertexAttribArray( 0 );
+	glDisableVertexAttribArray( 1 );
 
 	//glDisable( GL_SCISSOR_TEST );
 	glDisable( GL_STENCIL_TEST );
@@ -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->getUniVar("msNormalFai").getLoc(), R::Ms::normalFai, 0 );
+	shdr->locTexUnit( shdr->getUniVar("msDiffuseFai").getLoc(), R::Ms::diffuseFai, 1 );
+	shdr->locTexUnit( shdr->getUniVar("msSpecularFai").getLoc(), R::Ms::specularFai, 2 );
+	shdr->locTexUnit( shdr->getUniVar("msDepthFai").getLoc(), 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->getUniVar("planes").getLoc(), 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->getUniVar("lightPos").getLoc(), 1, &light_pos_eye_space[0] );
+	glUniform1f( shdr->getUniVar("lightInvRadius").getLoc(), 1.0/light.getDistance() );
+	glUniform3fv( shdr->getUniVar("lightDiffuseCol").getLoc(), 1, &Vec3(light.lightProps->getDiffuseColor())[0] );
+	glUniform3fv( shdr->getUniVar("lightSpecularCol").getLoc(), 1, &Vec3(light.lightProps->getSpecularColor())[0] );
 
 	// set the light texture
-	shdr->locTexUnit( shdr->getUniLoc(9), *light.lightProps->getTexture(), 4 );
+	shdr->locTexUnit( shdr->getUniVar("lightTex").getLoc(), *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->getUniVar("texProjectionMat").getLoc(), 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,20 +442,20 @@ 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->getUniVar("shadowMap").getLoc(), R::Is::Shad::shadowMap, 5 );
 	}
 
 	//** render quad **
-	glEnableVertexAttribArray( shdr->getAttribLoc(0) );
-	glEnableVertexAttribArray( shdr->getAttribLoc(1) );
+	glEnableVertexAttribArray( 0 );
+	glEnableVertexAttribArray( 1 );
 
-	glVertexAttribPointer( shdr->getAttribLoc(0), 2, GL_FLOAT, false, 0, &R::quad_vert_cords[0] );
-	glVertexAttribPointer( shdr->getAttribLoc(1), 3, GL_FLOAT, false, 0, &view_vectors[0] );
+	glVertexAttribPointer( 0, 2, GL_FLOAT, false, 0, &R::quad_vert_cords[0] );
+	glVertexAttribPointer( 1, 3, GL_FLOAT, false, 0, &view_vectors[0] );
 
 	glDrawArrays( GL_QUADS, 0, 4 );
 
-	glDisableVertexAttribArray( shdr->getAttribLoc(0) );
-	glDisableVertexAttribArray( shdr->getAttribLoc(1) );
+	glDisableVertexAttribArray( 0 );
+	glDisableVertexAttribArray( 1 );
 
 	// restore texture matrix
 	glMatrixMode( GL_TEXTURE );

+ 1 - 1
src/renderer/Lscatt.cpp

@@ -95,7 +95,7 @@ void runPass( const Camera& cam )
 	glUniform2fv( shdr->getUniVar("light_pos_screen_space").getLoc(), 1, &p[0] );
 
 	// Draw quad
-	R::DrawQuad( shdr->getAttribLoc(0) );
+	R::DrawQuad( 0 );
 
 	// end
 	fbo.Unbind();

+ 1 - 1
src/renderer/Pps.cpp

@@ -148,7 +148,7 @@ void runStage( const Camera& cam )
 
 
 	// draw quad
-	R::DrawQuad( sProg->getAttribLoc(0) );
+	R::DrawQuad( 0 );
 
 	// unbind FBO
 	fbo.Unbind();

+ 7 - 7
src/renderer/Renderer.cpp

@@ -66,7 +66,7 @@ BuildStdShaderPreProcStr
 I pass all the static vars (vars that do not change at all) with defines so I dont have to update uniform vars                        =
 =======================================================================================================================================
 */
-static void BuildStdShaderPreProcStr()
+static void buildStdShaderPreProcStr()
 {
 	string& tmp = std_shader_preproc_defines;
 
@@ -162,10 +162,7 @@ void init()
 	//glHint( GL_TEXTURE_COMPRESSION_HINT, GL_NICEST );
 
 	// execute this after the cvars are set and before the other inits (be cause these inits contain shader loads)
-	BuildStdShaderPreProcStr();
-
-	// misc
-	shdr_final = rsrc::shaders.load( "shaders/final.glsl" );
+	buildStdShaderPreProcStr();
 
 	// init deferred stages
 	// WARNING: the order of the inits is crucial!!!!!
@@ -176,6 +173,9 @@ void init()
 	R::Bs::init2();
 	R::Dbg::init();
 
+	// misc
+	shdr_final = rsrc::shaders.load( "shaders/final.glsl" );
+
 	PRINT( "Renderer initialization ends" );
 }
 
@@ -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->getUniVar("rasterImage").getLoc(), R::Pps::fai, 0 );
 
 	/*const int step = 100;
 	if( R::framesNum < step )
@@ -222,7 +222,7 @@ void render( const Camera& cam )
 		shdr_final->locTexUnit( shdr_final->getUniLoc(0), R::pps::fai, 0 );*/
 
 
-	R::DrawQuad( shdr_final->getAttribLoc(0) );
+	R::DrawQuad( 0 );
 }
 
 

+ 9 - 9
src/renderer/Ssao.cpp

@@ -159,24 +159,24 @@ 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 );
-	R::DrawQuad( ssaoSProg->getAttribLoc(0) ); // Draw quad
+	glUniform2fv( ssaoSProg->getUniVar("camerarange").getLoc(), 1, &(Vec2(cam.getZNear(), cam.getZFar()))[0] );
+	ssaoSProg->locTexUnit( ssaoSProg->getUniVar("msDepthFai").getLoc(), R::Ms::depthFai, 0 );
+	ssaoSProg->locTexUnit( ssaoSProg->getUniVar("noiseMap").getLoc(), *noise_map, 1 );
+	ssaoSProg->locTexUnit( ssaoSProg->getUniVar("msNormalFai").getLoc(), R::Ms::normalFai, 2 );
+	R::DrawQuad( 0 ); // Draw quad
 
 
 	// second pass. blur
 	blurFbo.bind();
 	blurSProg->bind();
-	blurSProg->locTexUnit( blurSProg->getUniLoc(0), fai, 0 );
-	R::DrawQuad( blurSProg->getAttribLoc(0) ); // Draw quad
+	blurSProg->locTexUnit( blurSProg->getUniVar("tex").getLoc(), fai, 0 );
+	R::DrawQuad( 0 ); // Draw quad
 
 	// third pass. blur
 	blurFbo2.bind();
 	blurSProg2->bind();
-	blurSProg2->locTexUnit( blurSProg2->getUniLoc(0), bluredFai, 0 );
-	R::DrawQuad( blurSProg2->getAttribLoc(0) ); // Draw quad
+	blurSProg2->locTexUnit( blurSProg2->getUniVar("tex").getLoc(), bluredFai, 0 );
+	R::DrawQuad( 0 ); // Draw quad
 
 
 	// end

+ 2 - 0
src/renderer/Vbo.h

@@ -70,6 +70,8 @@ class Vbo
 		 */
 		void bind() const
 		{
+			if( glId==0 )
+				PRINT( "-" );
 			DEBUG_ERR( glId==0 ); // VBO unitialized
 			glBindBuffer( target, glId );
 		}

+ 1 - 1
src/resources/Material.cpp

@@ -369,7 +369,7 @@ bool Material::additionalInit()
 	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;
+	attribLocs.texCoords = shaderProg->attribVarExists( "texCoords" ) ?  shaderProg->getAttribVar( "texCoords" ).getLoc() : -1;
 
 	// vertex weights
 	if( shaderProg->attribVarExists( "vertWeightBonesNum" ) )

+ 0 - 38
src/resources/ShaderParser.cpp

@@ -23,10 +23,6 @@ void ShaderParser::printSourceLines() const
 void ShaderParser::printShaderVars() const
 {
 	PRINT( "TYPE" << setw(20) << "NAME" << setw(4) << "LOC" );
-	for( uint i=0; i<output.uniforms.size(); ++i )
-	{
-		PRINT( setw(4) << "U" << setw(20) << output.uniforms[i].name << setw(4) << output.uniforms[i].customLoc );
-	}
 	for( uint i=0; i<output.attributes.size(); ++i )
 	{
 		PRINT( setw(4) << "A" << setw(20) << output.attributes[i].name << setw(4) << output.attributes[i].customLoc );
@@ -144,40 +140,6 @@ bool ShaderParser::parseFileForPragmas( const string& filename, int id )
 							return false;
 						}
 					}
-/* uniform */
-					else if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "uniform") == 0 )
-					{
-						token = &scanner.getNextToken();
-						if( token->code == Scanner::TC_IDENTIFIER )
-						{
-							string var_name = token->value.string;
-							token = &scanner.getNextToken();
-							if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_INT )
-							{
-								// play
-								Vec<ShaderVarPragma>::iterator uniform = findShaderVar( output.uniforms, var_name );
-								if( uniform != output.uniforms.end() )
-								{
-									PARSE_ERR( "Uniform already defined at " << uniform->definedInFile << ":" << uniform->definedInLine );
-									return false;
-								}
-								
-								output.uniforms.push_back( ShaderVarPragma( filename, scanner.getLineNmbr(), var_name, token->value.int_ ) );
-								sourceLines.push_back( lines[scanner.getLineNmbr()-1] );
-								// stop play
-							}
-							else
-							{
-								PARSE_ERR_EXPECTED( "integer" );
-								return false;
-							}
-						}
-						else
-						{
-							PARSE_ERR_EXPECTED( "identifier" );
-							return false;
-						}
-					}
 /* attribute */
 					else if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "attribute") == 0 )
 					{

+ 0 - 2
src/resources/ShaderParser.h

@@ -78,13 +78,11 @@ class ShaderParser
 			friend class ShaderParser;
 
 			private:
-				Vec<ShaderVarPragma> uniforms;  ///< It holds the name and the custom location
 				Vec<ShaderVarPragma> attributes;  ///< It holds the name and the custom location
 				string vertShaderSource; ///< This is the vert shader source
 				string fragShaderSource; ///< This is the frag shader source
 
 			public:
-				const Vec<ShaderVarPragma>& getUniLocs() const { return uniforms; }
 				const Vec<ShaderVarPragma>& getAttribLocs() const { return attributes; }
 				const string& getVertShaderSource() const { return vertShaderSource; }
 				const string& getFragShaderSource() const { return fragShaderSource; }

+ 7 - 91
src/resources/ShaderProg.cpp

@@ -109,6 +109,7 @@ void ShaderProg::getUniAndAttribVars()
 
 	// attrib locations
 	glGetProgramiv( glId, GL_ACTIVE_ATTRIBUTES, &num );
+	attribVars.reserve( num );
 	for( int i=0; i<num; i++ ) // loop all attributes
 	{
 		glGetActiveAttrib( glId, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_ );
@@ -122,7 +123,6 @@ void ShaderProg::getUniAndAttribVars()
 			continue;
 		}
 
-		attribNameToLoc[ name_ ] = loc; //ToDo to be removed
 		attribVars.push_back( Var( loc, name_, type, Var::LT_ATTRIBUTE ) );
 		attribNameToVar[ name_ ] = &attribVars.back();
 	}
@@ -130,6 +130,7 @@ void ShaderProg::getUniAndAttribVars()
 
 	// uni locations
 	glGetProgramiv( glId, GL_ACTIVE_UNIFORMS, &num );
+	uniVars.reserve( num );
 	for( int i=0; i<num; i++ ) // loop all uniforms
 	{
 		glGetActiveUniform( glId, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_ );
@@ -143,76 +144,12 @@ void ShaderProg::getUniAndAttribVars()
 			continue;
 		}
 
-		uniNameToLoc[ name_ ] = loc;
 		uniVars.push_back( Var( loc, name_, type, Var::LT_UNIFORM ) );
 		uniNameToVar[ name_ ] = &uniVars.back();
 	}
 }
 
 
-//=====================================================================================================================================
-// fillTheCustomLocationsVectors                                                                                                      =
-//=====================================================================================================================================
-bool ShaderProg::fillTheCustomLocationsVectors( const ShaderParser& pars )
-{
-	bind();
-	uint max = 0;
-
-	// uniforms
-	for( uint i=0; i<pars.getOutput().getUniLocs().size(); ++i )
-	{
-		if( pars.getOutput().getUniLocs()[i].customLoc > max )
-			max = pars.getOutput().getUniLocs()[i].customLoc;
-	}
-	customUniLocToRealLoc.assign( max + 1, -1 );
-
-	for( uint i=0; i<pars.getOutput().getUniLocs().size(); ++i )
-	{
-		if( customUniLocToRealLoc[ pars.getOutput().getUniLocs()[i].customLoc ] != -1 )
-		{
-			SHADER_ERROR( "The uniform \"" << pars.getOutput().getUniLocs()[i].name << "\" has the same value with another one" );
-			return false;
-		}
-		int loc = getUniVar( pars.getOutput().getUniLocs()[i].name.c_str() ).getLoc();
-		if( loc == -1 )
-		{
-			SHADER_WARNING( "Check the previous error" );
-			continue;
-		}
-		customUniLocToRealLoc[pars.getOutput().getUniLocs()[i].customLoc] = loc;
-	}
-	
-	
-	// attributes
-	max = 0;
-	
-	for( uint i=0; i<pars.getOutput().getAttribLocs().size(); ++i )
-	{
-		if( pars.getOutput().getAttribLocs()[i].customLoc > max )
-			max = pars.getOutput().getAttribLocs()[i].customLoc;
-	}
-	customAttribLocToRealLoc.assign( max + 1, -1 );
-
-	for( uint i=0; i<pars.getOutput().getAttribLocs().size(); ++i )
-	{
-		if( customAttribLocToRealLoc[ pars.getOutput().getAttribLocs()[i].customLoc ] != -1 )
-		{
-			SHADER_ERROR( "The attribute \"" << pars.getOutput().getAttribLocs()[i].name << "\" has the same value with another one" );
-			return false;
-		}
-		int loc = getAttribVar( pars.getOutput().getAttribLocs()[i].name.c_str() ).getLoc();
-		if( loc == -1 )
-		{
-			SHADER_ERROR( "Check the previous error" );
-			return false;
-		}
-		customAttribLocToRealLoc[pars.getOutput().getAttribLocs()[i].customLoc] = loc;
-	}
-
-	return true;
-}
-
-
 //=====================================================================================================================================
 // bindCustomAttribLocs                                                                                                               =
 //=====================================================================================================================================
@@ -262,11 +199,11 @@ bool ShaderProg::customload( const char* filename, const char* extraSource )
 	if( !pars.parseFile( filename ) ) 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 );
+	string preprocSource = R::getStdShaderPreprocDefines() + extraSource;
+	uint vertGlId = createAndCompileShader( pars.getOutput().getVertShaderSource().c_str(), preprocSource.c_str(), GL_VERTEX_SHADER );
 	if( vertGlId == 0 ) return false;
 
-	uint fragGlId = createAndCompileShader( pars.getOutput().getFragShaderSource().c_str(), preproc_source.c_str(), GL_FRAGMENT_SHADER );
+	uint fragGlId = createAndCompileShader( pars.getOutput().getFragShaderSource().c_str(), preprocSource.c_str(), GL_FRAGMENT_SHADER );
 	if( fragGlId == 0 ) return false;
 
 	// 2) create program and attach shaders
@@ -283,34 +220,11 @@ bool ShaderProg::customload( const char* filename, const char* extraSource )
 
 	// init the rest
 	getUniAndAttribVars();
-	if( !fillTheCustomLocationsVectors( pars ) ) return false;
 
 	return true;
 }
 
 
-//=====================================================================================================================================
-// getUniLoc                                                                                                                          =
-//=====================================================================================================================================
-int ShaderProg::getUniLoc( int id ) const
-{
-	DEBUG_ERR( uint(id) >= customUniLocToRealLoc.size() );
-	DEBUG_ERR( customUniLocToRealLoc[id] == -1 );
-	return customUniLocToRealLoc[id];
-}
-
-
-//=====================================================================================================================================
-// getAttribLoc                                                                                                                       =
-//=====================================================================================================================================
-int ShaderProg::getAttribLoc( int id ) const
-{
-	DEBUG_ERR( uint(id) >= customAttribLocToRealLoc.size() );
-	DEBUG_ERR( customAttribLocToRealLoc[id] == -1 );
-	return customAttribLocToRealLoc[id];
-}
-
-
 //=====================================================================================================================================
 // getUniVar                                                                                                                          =
 //=====================================================================================================================================
@@ -320,6 +234,7 @@ const ShaderProg::Var& ShaderProg::getUniVar( const char* name ) const
 	if( it == uniNameToVar.end() )
 	{
 		SHADER_ERROR( "Cannot get uniform loc \"" << name << '\"' );
+		return dummyVar;
 	}
 	return *(it->second);
 }
@@ -334,6 +249,7 @@ const ShaderProg::Var& ShaderProg::getAttribVar( const char* name ) const
 	if( it == attribNameToVar.end() )
 	{
 		SHADER_ERROR( "Cannot get attribute loc \"" << name << '\"' );
+		return dummyVar;
 	}
 	return *(it->second);
 }

+ 2 - 12
src/resources/ShaderProg.h

@@ -38,27 +38,20 @@ class ShaderProg: public Resource
 				{}
 		};
 
+		Var dummyVar; ///< Returned on error
 		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;
-		Vec<int> customAttribLocToRealLoc;
-		map<string,int> uniNameToLoc;
-		map<string,int> attribNameToLoc;
-		
 		void getUniAndAttribVars(); ///< After the linking of the shader prog is done gather all the vars in custom containers
-		bool fillTheCustomLocationsVectors( const ShaderParser& pars );
 		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) {}
+		ShaderProg(): glId(0), dummyVar(-1, "dummyVar", 0, 0) {}
 		virtual ~ShaderProg() {}
 		
 		inline void bind() const { DEBUG_ERR( glId==0 ); glUseProgram(glId); }
@@ -72,9 +65,6 @@ class ShaderProg: public Resource
 		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 getAttribLoc( int id ) 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

+ 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->getUniVar("fontMap").getLoc(), *fontMap, 0 );
 
 	glEnable( GL_BLEND );
 	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

+ 1 - 1
src/uncategorized/skybox.cpp

@@ -62,7 +62,7 @@ void Skybox::Render( const Mat3& rotation )
 	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] );
+	glUniform3fv( shader->getUniVar("sceneAmbientCol").getLoc(), 1, &(Vec3( 1.0, 1.0, 1.0 ) / Scene::getAmbientColor())[0] );
 
 	// set the rotation matrix
 	Mat3 tmp( rotation );