Browse Source

Porting to GLES3

Panagiotis Christopoulos Charitos 12 years ago
parent
commit
61974f0871

+ 1 - 1
build/genmakefilevithar

@@ -1,2 +1,2 @@
 #!/bin/sh
 #!/bin/sh
-cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON -DANKI_ARCH=32 -DANKI_EXTRA_INCLUDE_DIRS="/work/halti/khronos/arm/winsys_fbdev;/work/halti;/work/halti/kernel/include" -DANKI_EXTRA_LIB_DIRS=/work/halti/progs -DANKI_WINDOW_BACKEND=EGLFBDEV ..
+cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON -DANKI_ARCH=32 -DANKI_EXTRA_INCLUDE_DIRS="/work/trunk/khronos/arm/winsys_fbdev;/work/halti;/work/halti/kernel/include" -DANKI_EXTRA_LIB_DIRS=/work/trunk/progs -DANKI_ENABLE_MATH_SIMD=OFF -DANKI_WINDOW_BACKEND=EGLFBDEV ..

+ 9 - 0
shaders/CommonFrag.glsl

@@ -0,0 +1,9 @@
+#ifndef ANKI_SHADERS_COMMON_FRAG_GLSL
+#define ANKI_SHADERS_COMMON_FRAG_GLSL
+
+#ifdef GL_ES
+precision mediump float;
+precision mediump int;
+#endif
+
+#endif

+ 1 - 0
shaders/Dbg.glsl

@@ -13,6 +13,7 @@ void main()
 }
 }
 
 
 #pragma anki start fragmentShader
 #pragma anki start fragmentShader
+#pragma anki include "shaders/CommonFrag.glsl"
 
 
 in vec3 vColor;
 in vec3 vColor;
 
 

+ 5 - 4
shaders/Final.glsl

@@ -5,19 +5,20 @@
 #pragma anki include shaders/SimpleVert.glsl
 #pragma anki include shaders/SimpleVert.glsl
 
 
 #pragma anki start fragmentShader
 #pragma anki start fragmentShader
+#pragma anki include shaders/CommonFrag.glsl
 
 
-uniform sampler2D rasterImage;
+uniform lowp sampler2D rasterImage;
 
 
 in vec2 vTexCoords;
 in vec2 vTexCoords;
-layout(location = 0) out vec3 fFragColor;
+layout(location = 0) out lowp vec3 fFragColor;
 
 
 void main()
 void main()
 {
 {
 #if 1
 #if 1
-	vec3 col = texture2D(rasterImage, vTexCoords).rgb;
+	lowp vec3 col = texture(rasterImage, vTexCoords).rgb;
 	fFragColor = col;
 	fFragColor = col;
 #else
 #else
-	uvec2 msAll = texture2D(rasterImage, vTexCoords).rg;
+	uvec2 msAll = texture(rasterImage, vTexCoords).rg;
 	vec4 diffuseAndSpec = unpackUnorm4x8(msAll[0]);
 	vec4 diffuseAndSpec = unpackUnorm4x8(msAll[0]);
 	fFragColor = vec3(diffuseAndSpec.rgb);
 	fFragColor = vec3(diffuseAndSpec.rgb);
 #endif
 #endif

+ 8 - 8
shaders/GaussianBlurGeneric.glsl

@@ -29,15 +29,15 @@ precision mediump float;
 
 
 // Preprocessor switches sanity checks
 // Preprocessor switches sanity checks
 #if !defined(VPASS) && !defined(HPASS)
 #if !defined(VPASS) && !defined(HPASS)
-#	error "See file"
+#	error See file
 #endif
 #endif
 
 
 #if !(defined(COL_RGBA) || defined(COL_RGB) || defined(COL_R))
 #if !(defined(COL_RGBA) || defined(COL_RGB) || defined(COL_R))
-#	error "See file"
+#	error See file
 #endif
 #endif
 
 
 #if !defined(IMG_DIMENSION)
 #if !defined(IMG_DIMENSION)
-#	error "See file"
+#	error See file
 #endif
 #endif
 
 
 uniform mediump sampler2D img; ///< Input FAI
 uniform mediump sampler2D img; ///< Input FAI
@@ -80,7 +80,7 @@ const float WEIGHTS[2] = float[](0.314208984375, 0.06982421875);
 void main()
 void main()
 {
 {
 	// the center (0,0) pixel
 	// the center (0,0) pixel
-	COL_TYPE col = texture2D(img, vTexCoords).TEX_FETCH * FIRST_WEIGHT;
+	COL_TYPE col = texture(img, vTexCoords).TEX_FETCH * FIRST_WEIGHT;
 
 
 	// side pixels
 	// side pixels
 	for(int i = 0; i < 2; i++)
 	for(int i = 0; i < 2; i++)
@@ -88,17 +88,17 @@ void main()
 #if defined(HPASS)
 #if defined(HPASS)
 		vec2 tc = vec2(vTexCoords.x + BLURRING_DIST + BLURRING_OFFSET[i], 
 		vec2 tc = vec2(vTexCoords.x + BLURRING_DIST + BLURRING_OFFSET[i], 
 			vTexCoords.y);
 			vTexCoords.y);
-		col += texture2D(img, tc).TEX_FETCH * WEIGHTS[i];
+		col += texture(img, tc).TEX_FETCH * WEIGHTS[i];
 
 
 		tc.x = vTexCoords.x - BLURRING_DIST - BLURRING_OFFSET[i];
 		tc.x = vTexCoords.x - BLURRING_DIST - BLURRING_OFFSET[i];
-		col += texture2D(img, tc).TEX_FETCH * WEIGHTS[i];
+		col += texture(img, tc).TEX_FETCH * WEIGHTS[i];
 #elif defined(VPASS)
 #elif defined(VPASS)
 		vec2 tc = vec2(vTexCoords.x, 
 		vec2 tc = vec2(vTexCoords.x, 
 			vTexCoords.y + BLURRING_DIST + BLURRING_OFFSET[i]);
 			vTexCoords.y + BLURRING_DIST + BLURRING_OFFSET[i]);
-		col += texture2D(img, tc).TEX_FETCH * WEIGHTS[i];
+		col += texture(img, tc).TEX_FETCH * WEIGHTS[i];
 
 
 		tc.y = vTexCoords.y - BLURRING_DIST - BLURRING_OFFSET[i];
 		tc.y = vTexCoords.y - BLURRING_DIST - BLURRING_OFFSET[i];
-		col += texture2D(img, tc).TEX_FETCH * WEIGHTS[i];
+		col += texture(img, tc).TEX_FETCH * WEIGHTS[i];
 #endif
 #endif
 	}
 	}
 
 

+ 28 - 33
shaders/IsLpGeneric.glsl

@@ -7,7 +7,7 @@
 #pragma anki include "shaders/IsLpVertex.glsl"
 #pragma anki include "shaders/IsLpVertex.glsl"
 
 
 #pragma anki start fragmentShader
 #pragma anki start fragmentShader
-
+#pragma anki include "shaders/CommonFrag.glsl"
 #pragma anki include "shaders/Pack.glsl"
 #pragma anki include "shaders/Pack.glsl"
 #pragma anki include "shaders/LinearDepth.glsl"
 #pragma anki include "shaders/LinearDepth.glsl"
 
 
@@ -19,7 +19,7 @@
 /// @{
 /// @{
 
 
 // Common uniforms between lights
 // Common uniforms between lights
-layout(std140, row_major, binding = 0) uniform commonBlock
+layout(std140, row_major) uniform commonBlock
 {
 {
 	/// Packs:
 	/// Packs:
 	/// - xy: Planes. For the calculation of frag pos in view space
 	/// - xy: Planes. For the calculation of frag pos in view space
@@ -47,12 +47,12 @@ struct SpotLight
 	mat4 texProjectionMat;
 	mat4 texProjectionMat;
 };
 };
 
 
-layout(std140, row_major, binding = 1) uniform pointLightsBlock
+layout(std140, row_major) uniform pointLightsBlock
 {
 {
 	Light plights[MAX_POINT_LIGHTS];
 	Light plights[MAX_POINT_LIGHTS];
 };
 };
 
 
-layout(std140, binding = 2) uniform spotLightsBlock
+layout(std140) uniform spotLightsBlock
 {
 {
 	SpotLight slights[MAX_SPOT_LIGHTS];
 	SpotLight slights[MAX_SPOT_LIGHTS];
 };
 };
@@ -63,16 +63,16 @@ struct Tile
 	uvec4 lightIndices[MAX_LIGHTS_PER_TILE / 4];
 	uvec4 lightIndices[MAX_LIGHTS_PER_TILE / 4];
 };
 };
 
 
-layout(std140, row_major, binding = 3) uniform tilesBlock
+layout(std140, row_major) uniform tilesBlock
 {
 {
 	Tile tiles[TILES_X_COUNT * TILES_Y_COUNT];
 	Tile tiles[TILES_X_COUNT * TILES_Y_COUNT];
 };
 };
 
 
-uniform usampler2D msFai0;
+uniform highp usampler2D msFai0;
 uniform sampler2D msDepthFai;
 uniform sampler2D msDepthFai;
 
 
 //uniform sampler2D lightTextures[MAX_SPOT_LIGHTS];
 //uniform sampler2D lightTextures[MAX_SPOT_LIGHTS];
-uniform sampler2DArrayShadow shadowMapArr;
+uniform mediump sampler2DArrayShadow shadowMapArr;
 /// @}
 /// @}
 
 
 /// @name Varyings
 /// @name Varyings
@@ -91,7 +91,7 @@ out vec3 fColor;
 /// @return frag pos in view space
 /// @return frag pos in view space
 vec3 getFragPosVSpace()
 vec3 getFragPosVSpace()
 {
 {
-	const float depth = texture(msDepthFai, vTexCoords).r;
+	float depth = texture(msDepthFai, vTexCoords).r;
 
 
 	vec3 fragPosVspace;
 	vec3 fragPosVspace;
 	fragPosVspace.z = planes.y / (planes.x + depth);
 	fragPosVspace.z = planes.y / (planes.x + depth);
@@ -108,15 +108,15 @@ float calcAttenuationFactor(
 	out vec3 rayDir)
 	out vec3 rayDir)
 {
 {
 	// get the vector from the frag to the light
 	// get the vector from the frag to the light
-	const vec3 frag2LightVec = light.posAndRadius.xyz - fragPosVspace;
+	vec3 frag2LightVec = light.posAndRadius.xyz - fragPosVspace;
 
 
 	// Instead of using normalize(frag2LightVec) we brake the operation 
 	// Instead of using normalize(frag2LightVec) we brake the operation 
 	// because we want fragLightDist for the calc of the attenuation
 	// because we want fragLightDist for the calc of the attenuation
-	const float fragLightDistSquared = dot(frag2LightVec, frag2LightVec);
-	const float fragLightDist = sqrt(fragLightDistSquared);
+	float fragLightDistSquared = dot(frag2LightVec, frag2LightVec);
+	float fragLightDist = sqrt(fragLightDistSquared);
 	rayDir = frag2LightVec / fragLightDist;
 	rayDir = frag2LightVec / fragLightDist;
 
 
-	const float att = max((1.0 + ATTENUATION_BOOST) 
+	float att = max((1.0 + ATTENUATION_BOOST) 
 		- fragLightDist / light.posAndRadius.w, 0.0);
 		- fragLightDist / light.posAndRadius.w, 0.0);
 
 
 	return att;
 	return att;
@@ -181,7 +181,7 @@ float pcfLow(in sampler2DArrayShadow shadowMap, in vec3 shadowUv)
 
 
 //==============================================================================
 //==============================================================================
 float calcShadowFactor(in SpotLight light, in vec3 fragPosVspace, 
 float calcShadowFactor(in SpotLight light, in vec3 fragPosVspace, 
-	in sampler2DArrayShadow shadowMapArr, in float layer)
+	in mediump sampler2DArrayShadow shadowMapArr, in float layer)
 {
 {
 	vec4 texCoords4 = light.texProjectionMat * vec4(fragPosVspace, 1.0);
 	vec4 texCoords4 = light.texProjectionMat * vec4(fragPosVspace, 1.0);
 	vec3 texCoords3 = texCoords4.xyz / texCoords4.w;
 	vec3 texCoords3 = texCoords4.xyz / texCoords4.w;
@@ -203,7 +203,7 @@ void main()
 	uvec2 msAll = texture(msFai0, vTexCoords).rg;
 	uvec2 msAll = texture(msFai0, vTexCoords).rg;
 
 
 	// get frag pos in view space
 	// get frag pos in view space
-	const vec3 fragPosVspace = getFragPosVSpace();
+	vec3 fragPosVspace = getFragPosVSpace();
 
 
 	// Decode MS
 	// Decode MS
 	vec3 normal = unpackNormal(unpackHalf2x16(msAll[1]));
 	vec3 normal = unpackNormal(unpackHalf2x16(msAll[1]));
@@ -220,10 +220,10 @@ void main()
 		uint lightId = tiles[vInstanceId].lightIndices[i / 4U][i % 4U];
 		uint lightId = tiles[vInstanceId].lightIndices[i / 4U][i % 4U];
 
 
 		vec3 ray;
 		vec3 ray;
-		const float att = calcAttenuationFactor(fragPosVspace, 
+		float att = calcAttenuationFactor(fragPosVspace, 
 			plights[lightId], ray);
 			plights[lightId], ray);
 
 
-		const float lambert = calcLambertTerm(normal, ray);
+		float lambert = calcLambertTerm(normal, ray);
 
 
 		fColor += calcPhong(fragPosVspace, diffuseAndSpec.rgb, 
 		fColor += calcPhong(fragPosVspace, diffuseAndSpec.rgb, 
 			specularAll, normal, plights[lightId], ray) * (att * lambert);
 			specularAll, normal, plights[lightId], ray) * (att * lambert);
@@ -238,21 +238,21 @@ void main()
 		uint lightId = tiles[vInstanceId].lightIndices[i / 4U][i % 4U];
 		uint lightId = tiles[vInstanceId].lightIndices[i / 4U][i % 4U];
 
 
 		vec3 ray;
 		vec3 ray;
-		const float att = calcAttenuationFactor(fragPosVspace, 
+		float att = calcAttenuationFactor(fragPosVspace, 
 			slights[lightId].light, ray);
 			slights[lightId].light, ray);
 
 
-		const float lambert = calcLambertTerm(normal, ray);
+		float lambert = calcLambertTerm(normal, ray);
 
 
-		const float spot = calcSpotFactor(slights[lightId], fragPosVspace);
+		float spot = calcSpotFactor(slights[lightId], fragPosVspace);
 
 
-		const vec3 col = calcPhong(fragPosVspace, diffuseAndSpec.rgb, 
+		vec3 col = calcPhong(fragPosVspace, diffuseAndSpec.rgb, 
 			specularAll, normal, slights[lightId].light, ray);
 			specularAll, normal, slights[lightId].light, ray);
 
 
 		fColor += col * (att * lambert * spot);
 		fColor += col * (att * lambert * spot);
 	}
 	}
 
 
 	// Spot lights with shadow
 	// Spot lights with shadow
-	const uint spotLightsShadowCount = tiles[vInstanceId].lightsCount[2];
+	uint spotLightsShadowCount = tiles[vInstanceId].lightsCount[2];
 	opt = pointLightsCount + spotLightsCount;
 	opt = pointLightsCount + spotLightsCount;
 
 
 	for(uint i = 0U; i < spotLightsShadowCount; ++i)
 	for(uint i = 0U; i < spotLightsShadowCount; ++i)
@@ -261,24 +261,24 @@ void main()
 		uint lightId = tiles[vInstanceId].lightIndices[id / 4U][id % 4U];
 		uint lightId = tiles[vInstanceId].lightIndices[id / 4U][id % 4U];
 
 
 		vec3 ray;
 		vec3 ray;
-		const float att = calcAttenuationFactor(fragPosVspace, 
+		float att = calcAttenuationFactor(fragPosVspace, 
 			slights[lightId].light, ray);
 			slights[lightId].light, ray);
 
 
-		const float lambert = calcLambertTerm(normal, ray);
+		float lambert = calcLambertTerm(normal, ray);
 
 
-		const float spot = calcSpotFactor(slights[lightId], fragPosVspace);
+		float spot = calcSpotFactor(slights[lightId], fragPosVspace);
 
 
-		const float midFactor = att * lambert * spot;
+		float midFactor = att * lambert * spot;
 
 
 		//if(midFactor > 0.0)
 		//if(midFactor > 0.0)
 		{
 		{
-			const float shadowmapLayerId = 
+			float shadowmapLayerId = 
 				slights[lightId].light.diffuseColorShadowmapId.w;
 				slights[lightId].light.diffuseColorShadowmapId.w;
 
 
-			const float shadow = calcShadowFactor(slights[lightId], 
+			float shadow = calcShadowFactor(slights[lightId], 
 				fragPosVspace, shadowMapArr, shadowmapLayerId);
 				fragPosVspace, shadowMapArr, shadowmapLayerId);
 
 
-			const vec3 col = calcPhong(fragPosVspace, diffuseAndSpec.rgb, 
+			vec3 col = calcPhong(fragPosVspace, diffuseAndSpec.rgb, 
 				specularAll, normal, slights[lightId].light, ray);
 				specularAll, normal, slights[lightId].light, ray);
 
 
 			fColor += col * (midFactor * shadow);
 			fColor += col * (midFactor * shadow);
@@ -291,11 +291,6 @@ void main()
 #endif
 #endif
 
 
 #if 0
 #if 0
-	if(tiles[vInstanceId].lightsCount[3] > 0)
-	{
-		fColor += vec3(0.0, 0.2, 0.0);
-	}
-
 	if(tiles[vInstanceId].lightsCount[0] > 0)
 	if(tiles[vInstanceId].lightsCount[0] > 0)
 	{
 	{
 		fColor += vec3(0.2, 0.0, 0.0);
 		fColor += vec3(0.2, 0.0, 0.0);

+ 3 - 2
shaders/IsLpVertex.glsl

@@ -1,5 +1,5 @@
 #if !TILES_X_COUNT || !TILES_Y_COUNT
 #if !TILES_X_COUNT || !TILES_Y_COUNT
-#	error "See file"
+#	error See file
 #endif
 #endif
 
 
 layout(location = 0) in vec2 position;
 layout(location = 0) in vec2 position;
@@ -18,7 +18,8 @@ void main()
 
 
 	vInstanceId = int(gl_InstanceID);
 	vInstanceId = int(gl_InstanceID);
 
 
-	const vec2 SIZES = vec2(1.0 / TILES_X_COUNT, 1.0 / TILES_Y_COUNT);
+	const vec2 SIZES = 
+		vec2(1.0 / float(TILES_X_COUNT), 1.0 / float(TILES_Y_COUNT));
 
 
 	vTexCoords = (position + ij) * SIZES;
 	vTexCoords = (position + ij) * SIZES;
 	vec2 vertPosNdc = vTexCoords * 2.0 - 1.0;
 	vec2 vertPosNdc = vTexCoords * 2.0 - 1.0;

+ 14 - 1
shaders/Pack.glsl

@@ -1,5 +1,5 @@
 /// Pack 3D normal to 2D vector
 /// Pack 3D normal to 2D vector
-/// See the clean code in commends in revision < r467
+/// See the clean code in comments in revision < r467
 vec2 packNormal(in vec3 normal)
 vec2 packNormal(in vec3 normal)
 {
 {
     const float SCALE = 1.7777;
     const float SCALE = 1.7777;
@@ -67,3 +67,16 @@ vec4 unpackFloatTo4x8(in float val)
 	result -= result.xxyz * bitMsk;
 	result -= result.xxyz * bitMsk;
 	return result;
 	return result;
 }
 }
+
+//#if GL_ES
+uint _packUnorm4x8(in vec4 v)
+{
+	return floatBitsToUint(pack4x8ToFloat(v));
+}
+
+vec4 _unpackUnorm4x8(in uint u)
+{
+	return unpackFloatTo4x8(uintBitsToFloat(u));
+}
+
+//#endif

+ 4 - 4
shaders/Pps.glsl

@@ -3,7 +3,7 @@
 #pragma anki include "shaders/SimpleVert.glsl"
 #pragma anki include "shaders/SimpleVert.glsl"
 
 
 #pragma anki start fragmentShader
 #pragma anki start fragmentShader
-
+#pragma anki include "shaders/CommonFrag.glsl"
 #pragma anki include "shaders/photoshop_filters.glsl"
 #pragma anki include "shaders/photoshop_filters.glsl"
 #pragma anki include "shaders/LinearDepth.glsl"
 #pragma anki include "shaders/LinearDepth.glsl"
 
 
@@ -47,15 +47,15 @@ vec3 gammaCorrectionRgb(in vec3 gamma, in vec3 col)
 //==============================================================================
 //==============================================================================
 void main(void)
 void main(void)
 {
 {
-	fColor = texture2D(isFai, vTexCoords).rgb;
+	fColor = texture(isFai, vTexCoords).rgb;
 
 
 #if defined(HDR_ENABLED)
 #if defined(HDR_ENABLED)
-	vec3 hdr = texture2D(ppsHdrFai, vTexCoords).rgb;
+	vec3 hdr = texture(ppsHdrFai, vTexCoords).rgb;
 	fColor += hdr;
 	fColor += hdr;
 #endif
 #endif
 
 
 #if defined(SSAO_ENABLED)
 #if defined(SSAO_ENABLED)
-	float ssao = texture2D(ppsSsaoFai, vTexCoords).r;
+	float ssao = texture(ppsSsaoFai, vTexCoords).r;
 	fColor *= ssao;
 	fColor *= ssao;
 #endif
 #endif
 
 

+ 4 - 5
shaders/PpsHdr.glsl

@@ -3,12 +3,11 @@
 #pragma anki include "shaders/SimpleVert.glsl"
 #pragma anki include "shaders/SimpleVert.glsl"
 
 
 #pragma anki start fragmentShader
 #pragma anki start fragmentShader
+#pragma anki include "shaders/CommonFrag.glsl"
 
 
-precision mediump float;
+uniform lowp sampler2D fai; ///< Its the IS FAI
 
 
-uniform sampler2D mediump fai; ///< Its the IS FAI
-
-layout(std140, binding = 0) uniform commonBlock
+layout(std140) uniform commonBlock
 {
 {
 	vec4 exposure_;
 	vec4 exposure_;
 };
 };
@@ -23,7 +22,7 @@ const float brightMax = 4.0;
 
 
 void main()
 void main()
 {
 {
-	vec3 color = texture2D(fai, vTexCoords).rgb;
+	vec3 color = texture(fai, vTexCoords).rgb;
 
 
 	float luminance = dot(vec3(0.30, 0.59, 0.11), color);
 	float luminance = dot(vec3(0.30, 0.59, 0.11), color);
 	float yd = exposure * (exposure / brightMax + 1.0) /
 	float yd = exposure * (exposure / brightMax + 1.0) /

+ 10 - 8
shaders/PpsSsao.glsl

@@ -3,7 +3,7 @@
 #pragma anki include "shaders/SimpleVert.glsl"
 #pragma anki include "shaders/SimpleVert.glsl"
 
 
 #pragma anki start fragmentShader
 #pragma anki start fragmentShader
-
+#pragma anki include "shaders/CommonFrag.glsl"
 #pragma anki include "shaders/Pack.glsl"
 #pragma anki include "shaders/Pack.glsl"
 
 
 /// @name Varyings
 /// @name Varyings
@@ -19,7 +19,7 @@ layout(location = 0) out float fColor;
 
 
 /// @name Uniforms
 /// @name Uniforms
 /// @{
 /// @{
-layout(std140, row_major, binding = 0) uniform commonBlock
+layout(std140, row_major) uniform commonBlock
 {
 {
 	/// Packs:
 	/// Packs:
 	/// - x: zNear. For the calculation of frag pos in view space
 	/// - x: zNear. For the calculation of frag pos in view space
@@ -38,7 +38,7 @@ layout(std140, row_major, binding = 0) uniform commonBlock
 #define limitsOfNearPlane2 limitsOfNearPlane_.zw
 #define limitsOfNearPlane2 limitsOfNearPlane_.zw
 
 
 uniform sampler2D msDepthFai;
 uniform sampler2D msDepthFai;
-uniform usampler2D msGFai;
+uniform highp usampler2D msGFai;
 uniform sampler2D noiseMap; 
 uniform sampler2D noiseMap; 
 /// @}
 /// @}
 
 
@@ -56,21 +56,23 @@ vec3 getNormal(in vec2 uv)
 
 
 vec2 getRandom(in vec2 uv)
 vec2 getRandom(in vec2 uv)
 {
 {
-	vec2 noise = texture2D(
-		noiseMap, vec2(WIDTH, HEIGHT) * uv / NOISE_MAP_SIZE / 2.0).xy;
+	vec2 noise = texture(
+		noiseMap, 
+		vec2(float(WIDTH), float(HEIGHT)) 
+		* uv / float(NOISE_MAP_SIZE) / 2.0).xy;
 	return normalize(noise * 2.0 - 1.0);
 	return normalize(noise * 2.0 - 1.0);
 }
 }
 
 
 vec3 getPosition(in vec2 uv)
 vec3 getPosition(in vec2 uv)
 {
 {
-	float depth = texture2D(msDepthFai, uv).r;
+	float depth = texture(msDepthFai, uv).r;
 
 
 	vec3 fragPosVspace;
 	vec3 fragPosVspace;
 	fragPosVspace.z = -planes.y / (planes.x + depth);
 	fragPosVspace.z = -planes.y / (planes.x + depth);
 	
 	
 	fragPosVspace.xy = (uv * limitsOfNearPlane2) - limitsOfNearPlane;
 	fragPosVspace.xy = (uv * limitsOfNearPlane2) - limitsOfNearPlane;
 	
 	
-	const float sc = -fragPosVspace.z;
+	float sc = -fragPosVspace.z;
 	fragPosVspace.xy *= sc;
 	fragPosVspace.xy *= sc;
 
 
 	return fragPosVspace;
 	return fragPosVspace;
@@ -113,6 +115,6 @@ void main(void)
 		fColor += calcAmbientOcclusionFactor(vTexCoords + coord, p, n);
 		fColor += calcAmbientOcclusionFactor(vTexCoords + coord, p, n);
 	}
 	}
 
 
-	fColor = 1.0 - fColor / KERNEL_SIZE;
+	fColor = 1.0 - fColor / float(KERNEL_SIZE);
 }
 }
 
 

+ 9 - 2
shaders/TilerMinMax.glsl

@@ -3,9 +3,10 @@
 #pragma anki include "shaders/SimpleVert.glsl"
 #pragma anki include "shaders/SimpleVert.glsl"
 
 
 #pragma anki start fragmentShader
 #pragma anki start fragmentShader
+#pragma anki include shaders/CommonFrag.glsl
 
 
 #if !defined(TILES_X_COUNT) || !defined(TILES_Y_COUNT) || !defined(RENDERER_WIDTH) || !defined(RENDERER_HEIGHT)
 #if !defined(TILES_X_COUNT) || !defined(TILES_Y_COUNT) || !defined(RENDERER_WIDTH) || !defined(RENDERER_HEIGHT)
-#	error "See file"
+#error Forgot to define something
 #endif
 #endif
 
 
 uniform sampler2D depthMap;
 uniform sampler2D depthMap;
@@ -14,7 +15,9 @@ in vec2 vTexCoords;
 
 
 out uvec2 fColor;
 out uvec2 fColor;
 
 
+#ifndef GL_ES
 layout(pixel_center_integer) in vec4 gl_FragCoord;
 layout(pixel_center_integer) in vec4 gl_FragCoord;
+#endif
 
 
 #define W (RENDERER_WIDTH / TILES_X_COUNT)
 #define W (RENDERER_WIDTH / TILES_X_COUNT)
 #define H (RENDERER_HEIGHT / TILES_Y_COUNT)
 #define H (RENDERER_HEIGHT / TILES_Y_COUNT)
@@ -22,7 +25,11 @@ layout(pixel_center_integer) in vec4 gl_FragCoord;
 //==============================================================================
 //==============================================================================
 void main()
 void main()
 {
 {
-	const ivec2 coord = ivec2(gl_FragCoord.xy * vec2(W, H));
+#ifndef GL_ES
+	ivec2 coord = ivec2(gl_FragCoord.xy * vec2(W, H));
+#else
+	ivec2 coord = ivec2((gl_FragCoord.xy - vec2(0.5)) * vec2(W, H));
+#endif
 
 
 	float maxDepth = -10000.0;
 	float maxDepth = -10000.0;
 	float minDepth = 100000.0;
 	float minDepth = 100000.0;

+ 1 - 1
src/event/MovableEvent.cpp

@@ -10,7 +10,7 @@ MovableEvent::MovableEvent(F32 startTime, F32 duration, EventManager* manager,
 	U8 flags, const MovableEventData& data)
 	U8 flags, const MovableEventData& data)
 	: Event(startTime, duration, manager, flags)
 	: Event(startTime, duration, manager, flags)
 {
 {
-	ANKI_ASSERT(data.movableSceneNode.getMovable());
+	ANKI_ASSERT(data.movableSceneNode->getMovable());
 
 
 	*static_cast<MovableEventData*>(this) = data;
 	*static_cast<MovableEventData*>(this) = data;
 
 

+ 5 - 4
src/gl/GlState.cpp

@@ -133,8 +133,9 @@ void GlState::sync()
 	glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencilValue);
 	glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencilValue);
 
 
 	// blend funcs
 	// blend funcs
-	glGetIntegerv(GL_BLEND_SRC, (GLint*)&blendFuncs[0]);
-	glGetIntegerv(GL_BLEND_DST, (GLint*)&blendFuncs[1]);
+	// XXX fix that. Separate alpha with RGB
+	glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&blendFuncs[0]);
+	glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&blendFuncs[1]);
 
 
 	// depth mask
 	// depth mask
 	glGetIntegerv(GL_DEPTH_WRITEMASK, &depthMask);
 	glGetIntegerv(GL_DEPTH_WRITEMASK, &depthMask);
@@ -209,9 +210,9 @@ void GlState::setBlendFunctions(const GLenum sFactor, const GLenum dFactor)
 {
 {
 #if ANKI_DEBUG
 #if ANKI_DEBUG
 	GLint real;
 	GLint real;
-	glGetIntegerv(GL_BLEND_SRC, &real);
+	glGetIntegerv(GL_BLEND_SRC_ALPHA, &real);
 	ANKI_ASSERT(blendFuncs[0] == (GLenum)real);
 	ANKI_ASSERT(blendFuncs[0] == (GLenum)real);
-	glGetIntegerv(GL_BLEND_DST, &real);
+	glGetIntegerv(GL_BLEND_DST_ALPHA, &real);
 	ANKI_ASSERT(blendFuncs[1] == (GLenum)real);
 	ANKI_ASSERT(blendFuncs[1] == (GLenum)real);
 #endif
 #endif
 
 

+ 2 - 0
src/gl/Texture.cpp

@@ -14,11 +14,13 @@ static Bool isCompressedInternalFormat(const GLenum internalFormat)
 	Bool out = false;
 	Bool out = false;
 	switch(internalFormat)
 	switch(internalFormat)
 	{
 	{
+#if ANKI_GL == ANKI_GL_DESKTOP
 	case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
 	case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
 	case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
 	case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
 	case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
 	case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
 		out = true;
 		out = true;
 		break;
 		break;
+#endif
 	default:
 	default:
 		out = false;
 		out = false;
 	}
 	}

+ 18 - 0
src/input/InputDummy.cpp

@@ -8,5 +8,23 @@ void Input::handleEvents()
 	// You are dummy... do nothing
 	// You are dummy... do nothing
 }
 }
 
 
+//==============================================================================
+void Input::init(NativeWindow* nativeWindow)
+{
+	// You are dummy... do nothing
+}
+
+//==============================================================================
+void Input::moveMouse(const Vec2& posNdc)
+{
+	// You are dummy... do nothing
+}
+
+//==============================================================================
+void Input::hideCursor(Bool hide)
+{
+	// You are dummy... do nothing
+}
+
 } // end namespace anki
 } // end namespace anki
 
 

+ 11 - 0
src/renderer/Drawer.cpp

@@ -317,11 +317,22 @@ void RenderableDrawer::render(SceneNode& frsn, RenderingStage stage,
 		}
 		}
 		else
 		else
 		{
 		{
+#if ANKI_GL == ANKI_GL_DESKTOP
 			glMultiDrawElements(GL_TRIANGLES, 
 			glMultiDrawElements(GL_TRIANGLES, 
 				(GLsizei*)indicesCountArray, 
 				(GLsizei*)indicesCountArray, 
 				GL_UNSIGNED_SHORT, 
 				GL_UNSIGNED_SHORT, 
 				(const void**)indicesOffsetArray, 
 				(const void**)indicesOffsetArray, 
 				primCount);
 				primCount);
+#else
+			for(U i = 0; i < primCount; i++)
+			{
+				glDrawElements(
+					GL_TRIANGLES, 
+					indicesCountArray[i],
+					GL_UNSIGNED_SHORT,
+					indicesOffsetArray[i]);
+			}
+#endif
 		}
 		}
 	}
 	}
 	else
 	else

+ 2 - 1
src/renderer/Hdr.cpp

@@ -10,7 +10,7 @@ Hdr::~Hdr()
 //==============================================================================
 //==============================================================================
 void Hdr::initFbo(Fbo& fbo, Texture& fai)
 void Hdr::initFbo(Fbo& fbo, Texture& fai)
 {
 {
-	Renderer::createFai(width, height, GL_RGB8, GL_RGB, GL_FLOAT, fai);
+	Renderer::createFai(width, height, GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, fai);
 	fai.setFiltering(Texture::TFT_LINEAR);
 	fai.setFiltering(Texture::TFT_LINEAR);
 
 
 	// create FBO
 	// create FBO
@@ -48,6 +48,7 @@ void Hdr::initInternal(const Renderer::Initializer& initializer)
 	commonUbo.create(sizeof(Vec4), &block);
 	commonUbo.create(sizeof(Vec4), &block);
 
 
 	toneSProg.load("shaders/PpsHdr.glsl");
 	toneSProg.load("shaders/PpsHdr.glsl");
+	toneSProg->findUniformBlock("commonBlock").setBinding(0);
 
 
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 
 

+ 9 - 8
src/renderer/Is.cpp

@@ -311,6 +311,10 @@ void Is::initInternal(const RendererInitializer& initializer)
 	{
 	{
 		pps += "#define PCF 1\n";
 		pps += "#define PCF 1\n";
 	}
 	}
+	else
+	{
+		pps += "#define PCF 0\n";
+	}
 
 
 	// point light
 	// point light
 	lightPassProg.load(ShaderProgramResource::createSrcCodeToCache(
 	lightPassProg.load(ShaderProgramResource::createSrcCodeToCache(
@@ -322,7 +326,7 @@ void Is::initInternal(const RendererInitializer& initializer)
 
 
 	// IS FBO
 	// IS FBO
 	Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGB8,
 	Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGB8,
-		GL_RGB, GL_UNSIGNED_INT, fai);
+		GL_RGB, GL_UNSIGNED_BYTE, fai);
 	fbo.create();
 	fbo.create();
 	fbo.setColorAttachments({&fai});
 	fbo.setColorAttachments({&fai});
 	fbo.setOtherAttachment(GL_DEPTH_ATTACHMENT, r->getMs().getDepthFai());
 	fbo.setOtherAttachment(GL_DEPTH_ATTACHMENT, r->getMs().getDepthFai());
@@ -368,6 +372,7 @@ void Is::initInternal(const RendererInitializer& initializer)
 	const ShaderProgramUniformBlock* ublock;
 	const ShaderProgramUniformBlock* ublock;
 
 
 	ublock = &lightPassProg->findUniformBlock("commonBlock");
 	ublock = &lightPassProg->findUniformBlock("commonBlock");
+	ublock->setBinding(COMMON_UNIFORMS_BLOCK_BINDING);
 	if(ublock->getSize() != sizeof(ShaderCommonUniforms)
 	if(ublock->getSize() != sizeof(ShaderCommonUniforms)
 		|| ublock->getBinding() != COMMON_UNIFORMS_BLOCK_BINDING)
 		|| ublock->getBinding() != COMMON_UNIFORMS_BLOCK_BINDING)
 	{
 	{
@@ -375,6 +380,7 @@ void Is::initInternal(const RendererInitializer& initializer)
 	}
 	}
 
 
 	ublock = &lightPassProg->findUniformBlock("pointLightsBlock");
 	ublock = &lightPassProg->findUniformBlock("pointLightsBlock");
+	ublock->setBinding(POINT_LIGHTS_BLOCK_BINDING);
 	if(ublock->getSize() != sizeof(ShaderPointLights)
 	if(ublock->getSize() != sizeof(ShaderPointLights)
 		|| ublock->getBinding() != POINT_LIGHTS_BLOCK_BINDING)
 		|| ublock->getBinding() != POINT_LIGHTS_BLOCK_BINDING)
 	{
 	{
@@ -382,13 +388,7 @@ void Is::initInternal(const RendererInitializer& initializer)
 	}
 	}
 
 
 	ublock = &lightPassProg->findUniformBlock("spotLightsBlock");
 	ublock = &lightPassProg->findUniformBlock("spotLightsBlock");
-	if(ublock->getSize() != sizeof(ShaderSpotLights)
-		|| ublock->getBinding() != SPOT_LIGHTS_BLOCK_BINDING)
-	{
-		throw ANKI_EXCEPTION("Problem with the spotLightsBlock");
-	}
-
-	ublock = &lightPassProg->findUniformBlock("spotLightsBlock");
+	ublock->setBinding(SPOT_LIGHTS_BLOCK_BINDING);
 	if(ublock->getSize() != sizeof(ShaderSpotLights)
 	if(ublock->getSize() != sizeof(ShaderSpotLights)
 		|| ublock->getBinding() != SPOT_LIGHTS_BLOCK_BINDING)
 		|| ublock->getBinding() != SPOT_LIGHTS_BLOCK_BINDING)
 	{
 	{
@@ -396,6 +396,7 @@ void Is::initInternal(const RendererInitializer& initializer)
 	}
 	}
 
 
 	ublock = &lightPassProg->findUniformBlock("tilesBlock");
 	ublock = &lightPassProg->findUniformBlock("tilesBlock");
+	ublock->setBinding(TILES_BLOCK_BINDING);
 	if(ublock->getSize() != sizeof(ShaderTiles)
 	if(ublock->getSize() != sizeof(ShaderTiles)
 		|| ublock->getBinding() != TILES_BLOCK_BINDING)
 		|| ublock->getBinding() != TILES_BLOCK_BINDING)
 	{
 	{

+ 1 - 1
src/renderer/Pps.cpp

@@ -26,7 +26,7 @@ void Pps::initInternal(const RendererInitializer& initializer)
 
 
 	// FBO
 	// FBO
 	Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGB, GL_RGB,
 	Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGB, GL_RGB,
-		GL_FLOAT, fai);
+		GL_UNSIGNED_BYTE, fai);
 
 
 	fbo.create();
 	fbo.create();
 	fbo.setColorAttachments({&fai});
 	fbo.setColorAttachments({&fai});

+ 1 - 1
src/renderer/Sm.cpp

@@ -37,7 +37,7 @@ void Sm::init(const RendererInitializer& initializer)
 	sminit.depth = initializer.is.sm.maxLights;
 	sminit.depth = initializer.is.sm.maxLights;
 	sminit.format = GL_DEPTH_COMPONENT;
 	sminit.format = GL_DEPTH_COMPONENT;
 	sminit.internalFormat = GL_DEPTH_COMPONENT16;
 	sminit.internalFormat = GL_DEPTH_COMPONENT16;
-	sminit.type = GL_FLOAT;
+	sminit.type = GL_UNSIGNED_SHORT;
 	if(bilinearEnabled)
 	if(bilinearEnabled)
 	{
 	{
 		sminit.filteringType = Texture::TFT_LINEAR;
 		sminit.filteringType = Texture::TFT_LINEAR;

+ 2 - 0
src/renderer/Ssao.cpp

@@ -92,6 +92,8 @@ void Ssao::initInternal(const RendererInitializer& initializer)
 	ssaoSProg.load(ShaderProgramResource::createSrcCodeToCache(
 	ssaoSProg.load(ShaderProgramResource::createSrcCodeToCache(
 		"shaders/PpsSsao.glsl", pps.c_str()).c_str());
 		"shaders/PpsSsao.glsl", pps.c_str()).c_str());
 
 
+	ssaoSProg->findUniformBlock("commonBlock").setBinding(0);
+
 	// blurring progs
 	// blurring progs
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 
 

+ 5 - 1
src/resource/TextureResource.cpp

@@ -31,8 +31,9 @@ void TextureResource::load(const Image& img)
 	init.height = img.getHeight();
 	init.height = img.getHeight();
 	init.dataSize = img.getDataSize();
 	init.dataSize = img.getDataSize();
 
 
-	bool compressionEnabled = 
+	Bool compressionEnabled = 
 		TextureManagerSingleton::get().getCompressionEnabled();
 		TextureManagerSingleton::get().getCompressionEnabled();
+	(void)compressionEnabled;
 
 
 	switch(img.getColorType())
 	switch(img.getColorType())
 	{
 	{
@@ -90,6 +91,9 @@ void TextureResource::load(const Image& img)
 	case Image::DC_DXT5:
 	case Image::DC_DXT5:
 		init.internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
 		init.internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
 		break;
 		break;
+#else
+	default:
+		ANKI_ASSERT(0);
 #endif
 #endif
 	}
 	}
 
 

+ 1 - 1
src/util/Exception.cpp

@@ -3,7 +3,7 @@
 #include <iostream>
 #include <iostream>
 
 
 // Instead of throwing abort. Its easier to debug
 // Instead of throwing abort. Its easier to debug
-#define ANKI_ABORT_ON_THROW 0
+#define ANKI_ABORT_ON_THROW ANKI_DEBUG
 
 
 namespace anki {
 namespace anki {
 
 

+ 2 - 2
testapp/Main.cpp

@@ -141,7 +141,7 @@ void init()
 	scene.setActiveCamera(cam);
 	scene.setActiveCamera(cam);
 
 
 	// lights
 	// lights
-#if 0
+#if 1
 	Vec3 lpos(-24.0, 0.1, -10.0);
 	Vec3 lpos(-24.0, 0.1, -10.0);
 	for(int i = 0; i < 50; i++)
 	for(int i = 0; i < 50; i++)
 	{
 	{
@@ -466,7 +466,7 @@ void mainLoop()
 
 
 		// Sleep
 		// Sleep
 		//
 		//
-#if 1
+#if 0
 		timer.stop();
 		timer.stop();
 		if(timer.getElapsedTime() < AppSingleton::get().getTimerTick())
 		if(timer.getElapsedTime() < AppSingleton::get().getTimerTick())
 		{
 		{