Browse Source

- MAJOR: The Renderer's stages and passes are in different .h files. More clean this way
- Creating cpp for DebugDrawer
- Optimizing GaussianBlur.glsl
- HDR and SSAO are using the new way blur shader. Way better results and wey faster
- Building a few boost::python interfaces

Panagiotis Christopoulos Charitos 15 years ago
parent
commit
07e3082c53
47 changed files with 724 additions and 865 deletions
  1. 293 496
      build/debug/Makefile
  2. 2 2
      shaders/BsRefract.glsl
  3. 36 15
      shaders/GaussianBlurGeneric.glsl
  4. 2 2
      shaders/IsAp.glsl
  5. 2 2
      shaders/Pack.glsl
  6. 2 2
      shaders/PpsHdr.glsl
  7. 3 3
      shaders/PpsLscatt.glsl
  8. 3 3
      shaders/PpsPostPass.glsl
  9. 3 3
      shaders/PpsPrePass.glsl
  10. 6 6
      shaders/PpsSsao.glsl
  11. 3 3
      shaders/PpsSsaoBlur.glsl
  12. 4 4
      shaders/SimpleVert.glsl
  13. 4 2
      shaders/final.glsl
  14. 1 0
      src/Core/App.cpp
  15. 6 5
      src/Main.cpp
  16. 88 0
      src/Physics/DebugDrawer.cpp
  17. 2 82
      src/Physics/DebugDrawer.h
  18. 1 0
      src/Physics/PhyCharacter.cpp
  19. 1 0
      src/Physics/PhyCharacter.h
  20. 1 0
      src/Renderer/Bs.cpp
  21. 5 3
      src/Renderer/Bs.h
  22. 45 56
      src/Renderer/Dbg.cpp
  23. 13 11
      src/Renderer/Dbg.h
  24. 28 26
      src/Renderer/Hdr.cpp
  25. 14 10
      src/Renderer/Hdr.h
  26. 6 3
      src/Renderer/Is.cpp
  27. 3 0
      src/Renderer/MainRenderer.cpp
  28. 21 13
      src/Renderer/MainRenderer.h
  29. 0 2
      src/Renderer/Pps.cpp
  30. 8 0
      src/Renderer/Pps.h
  31. 1 4
      src/Renderer/Renderer.cpp
  32. 0 1
      src/Renderer/Renderer.h
  33. 2 1
      src/Renderer/RendererInitializer.h
  34. 3 3
      src/Renderer/Smo.cpp
  35. 61 71
      src/Renderer/Ssao.cpp
  36. 23 17
      src/Renderer/Ssao.h
  37. 0 2
      src/Resources/Material.h
  38. 2 2
      src/Scene/Camera.cpp
  39. 1 1
      src/Scene/Light.cpp
  40. 3 3
      src/Scene/ParticleEmitter.cpp
  41. 4 4
      src/Scene/SkelNode.cpp
  42. 5 0
      src/Scripting/BoostPythonInterfaces.cpp
  43. 5 0
      src/Scripting/Renderer/Hdr.bpi.h
  44. 4 0
      src/Scripting/Renderer/Pps.bpi.h
  45. 1 0
      src/Scripting/Renderer/Renderer.bpi.h
  46. 2 1
      src/Util/Object.h
  47. 1 1
      src/Util/Tokenizer/Scanner.cpp

File diff suppressed because it is too large
+ 293 - 496
build/debug/Makefile


+ 2 - 2
shaders/BsRefract.glsl

@@ -6,9 +6,9 @@
 
 uniform sampler2D fai;
 
-varying vec2 texCoords;
+varying vec2 vTexCoords;
 
 void main()
 {
-	gl_FragData[0] = texture2D(fai, texCoords);
+	gl_FragData[0] = texture2D(fai, vTexCoords);
 }

+ 36 - 15
shaders/GaussianBlurGeneric.glsl

@@ -1,8 +1,11 @@
 /**
  * @file
- * Generic shader program for Gausian blur inspired by Daniel Rákos' article
- * (http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/)
+ * Generic shader program for Gausian blur inspired by Daniel Rakos' article
+ * http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
+ *
  * Switches: VPASS or HPASS, COL_RGBA or COL_RGB or COL_R
+ *
+ * This is an optimized version. See the clean one at rev213
  */
 
 #pragma anki vertShaderBegins
@@ -10,9 +13,21 @@
 #pragma anki attribute position 0
 attribute vec2 position;
 
+uniform float imgDimension = 0.0; ///< the img width for hspass or the img height for vpass
+
+varying vec2 vTexCoords;
+varying float vOffsets[2]; ///< For side pixels
+
+const float _offset_[2] = float[](1.3846153846, 3.2307692308); ///< The offset of side pixels
+
 
 void main()
 {
+	vTexCoords = position;
+
+	vOffsets[0] = _offset_[0] / imgDimension;
+	vOffsets[1] = _offset_[1] / imgDimension;
+
 	gl_Position = vec4(position * 2.0 - 1.0, 0.0, 1.0);
 }
 
@@ -33,11 +48,10 @@ void main()
 
 
 uniform sampler2D img; ///< Input FAI
-uniform vec2 imgSize = vec2(0.0, 0.0);
-uniform float blurringDist = 1.0;
-
-varying vec2 texCoords;
+uniform float blurringDist = 0.0;
 
+varying vec2 vTexCoords;
+varying float vOffsets[2];
 
 /*
  * Determin color type
@@ -62,24 +76,31 @@ varying vec2 texCoords;
 #endif
 
 
-const float _offset_[3] = float[](0.0, 1.3846153846, 3.2307692308);
-const float _weight_[3] = float[](0.2255859375, 0.314208984375, 0.06982421875);
+const float _firstWeight_ = 0.2255859375;
+const float _weights_[2] = float[](0.314208984375, 0.06982421875);
 
 
 void main()
 {
-	COL_TYPE _col_ = texture2D(img, gl_FragCoord.xy / imgSize).TEX_FETCH * _weight_[0];
+	// the center (0,0) pixel
+	COL_TYPE _col_ = texture2D(img, vTexCoords).TEX_FETCH * _firstWeight_;
 
-	for(int i=1; i<3; i++)
+	// side pixels
+	for(int i=0; i<2; i++)
 	{
 		#if defined(HPASS)
-			vec2 _vecOffs_ = vec2(_offset_[i] + blurringDist, 0.0);
+			vec2 _texCoords_ = vec2(vTexCoords.x + blurringDist + vOffsets[i], vTexCoords.y);
+			_col_ += texture2D(img, _texCoords_).TEX_FETCH * _weights_[i];
+
+			_texCoords_.x = vTexCoords.x - blurringDist - vOffsets[i];
+			_col_ += texture2D(img, _texCoords_).TEX_FETCH * _weights_[i];
 		#elif defined(VPASS)
-			vec2 _vecOffs_ = vec2(0.0, _offset_[i] + blurringDist);
-		#endif
+			vec2 _texCoords_ = vec2(vTexCoords.x, vTexCoords.y + blurringDist + vOffsets[i]);
+			_col_ += texture2D(img, _texCoords_).TEX_FETCH * _weights_[i];
 
-		_col_ += texture2D(img, (gl_FragCoord.xy + _vecOffs_) / imgSize).TEX_FETCH * _weight_[i];
-		_col_ += texture2D(img, (gl_FragCoord.xy - _vecOffs_) / imgSize).TEX_FETCH * _weight_[i];
+			_texCoords_.y = vTexCoords.y - blurringDist - vOffsets[i];
+			_col_ += texture2D(img, _texCoords_).TEX_FETCH * _weights_[i];
+		#endif
 	}
 
 	gl_FragData[0].TEX_FETCH = _col_;

+ 2 - 2
shaders/IsAp.glsl

@@ -7,9 +7,9 @@
 uniform vec3 ambientCol;
 uniform sampler2D sceneColMap;
 
-varying vec2 texCoords;
+varying vec2 vTexCoords;
 
 void main()
 {
-	gl_FragData[0].rgb = texture2D( sceneColMap, texCoords ).rgb * ambientCol;
+	gl_FragData[0].rgb = texture2D( sceneColMap, vTexCoords ).rgb * ambientCol;
 }

+ 2 - 2
shaders/Pack.glsl

@@ -1,4 +1,4 @@
-/*
+/**
  * Pack 3D normal to 2D vector
  */
 vec2 packNormal( in vec3 _normal )
@@ -16,7 +16,7 @@ vec2 packNormal( in vec3 _normal )
 }
 
 
-/*
+/**
  * Reverse the packNormal
  */
 vec3 unpackNormal(in vec2 _enc_)

+ 2 - 2
shaders/PpsHdr.glsl

@@ -11,12 +11,12 @@
 
 uniform sampler2D fai; ///< Its the IS FAI
 
-varying vec2 texCoords;
+varying vec2 vTexCoords;
 
 
 void main()
 {
-	vec3 _color_ = texture2D(fai, texCoords).rgb;
+	vec3 _color_ = texture2D(fai, vTexCoords).rgb;
 	float _luminance_ = dot(vec3(0.30, 0.59, 0.11), _color_); // AKA luminance
 	const float _exposure_ = 4.0;
 	const float _brightMax_ = 4.0;

+ 3 - 3
shaders/PpsLscatt.glsl

@@ -15,14 +15,14 @@ uniform vec2 lightPosScreenSpace = vec2(0.5, 0.5);
 uniform sampler2D msDepthFai;
 uniform sampler2D isFai;
 
-varying vec2 texCoords;
+varying vec2 vTexCoords;
 
 
 
 void main()
 {
-	vec2 delta_tex_coord = texCoords - lightPosScreenSpace;
-	vec2 texCoords2 = texCoords;
+	vec2 delta_tex_coord = vTexCoords - lightPosScreenSpace;
+	vec2 texCoords2 = vTexCoords;
 	delta_tex_coord *= 1.0 / float(SAMPLES_NUM) * density;
 	float illumination_decay = 1.0;
 

+ 3 - 3
shaders/PpsPostPass.glsl

@@ -10,7 +10,7 @@
 uniform sampler2D ppsPrePassFai;
 uniform sampler2D ppsHdrFai;
 
-varying vec2 texCoords;
+varying vec2 vTexCoords;
 
 
 //======================================================================================================================
@@ -40,7 +40,7 @@ vec3 saturation(in vec3 col, in float factor)
 //======================================================================================================================
 void main(void)
 {
-	vec3 color = texture2D(ppsPrePassFai, texCoords).rgb;
+	vec3 color = texture2D(ppsPrePassFai, vTexCoords).rgb;
 
 	/*const float gamma = 0.7;
 	color.r = pow(color.r, 1.0 / gamma);
@@ -48,7 +48,7 @@ void main(void)
 	color.b = pow(color.b, 1.0 / gamma);*/
 
 	#if defined(HDR_ENABLED)
-		vec3 hdr = texture2D(ppsHdrFai, texCoords).rgb;
+		vec3 hdr = texture2D(ppsHdrFai, vTexCoords).rgb;
 		color += hdr;
 	#endif
 

+ 3 - 3
shaders/PpsPrePass.glsl

@@ -7,7 +7,7 @@
 uniform sampler2D isFai;
 uniform sampler2D ppsSsaoFai;
 
-varying vec2 texCoords;
+varying vec2 vTexCoords;
 
 
 //======================================================================================================================
@@ -15,10 +15,10 @@ varying vec2 texCoords;
 //======================================================================================================================
 void main(void)
 {
-	vec3 color = texture2D(isFai, texCoords).rgb;
+	vec3 color = texture2D(isFai, vTexCoords).rgb;
 
 	#if defined(SSAO_ENABLED)
-		float ssaoFactor = texture2D(ppsSsaoFai, texCoords).a;
+		float ssaoFactor = texture2D(ppsSsaoFai, vTexCoords).r;
 		color *= ssaoFactor;
 	#endif
 

+ 6 - 6
shaders/PpsSsao.glsl

@@ -12,7 +12,7 @@ uniform sampler2D msDepthFai;
 uniform sampler2D noiseMap;
 uniform sampler2D msNormalFai;
 
-varying vec2 texCoords;
+varying vec2 vTexCoords;
 const float totStrength = 1.7;
 const float strength = 0.07;
 const float offset = 18.0;
@@ -33,21 +33,21 @@ void main(void)
 	// grab a normal for reflecting the sample rays later on
 
 
-	float currentPixelDepth = ReadFromTexAndLinearizeDepth( msDepthFai, texCoords, camerarange.x, camerarange.y );
+	float currentPixelDepth = ReadFromTexAndLinearizeDepth( msDepthFai, vTexCoords, camerarange.x, camerarange.y );
 	/*if( currentPixelDepth * camerarange.y > MAX_SSAO_DISTANCE )
 	{
 		gl_FragColor.a = 1.0;
 		return;
 	}*/
 
-	vec3 fres = normalize((texture2D(noiseMap,texCoords*offset).xyz*2.0) - vec3(1.0));
+	vec3 fres = normalize((texture2D(noiseMap,vTexCoords*offset).xyz*2.0) - vec3(1.0));
 
-	vec4 currentPixelSample = texture2D(msNormalFai,texCoords);
+	vec4 currentPixelSample = texture2D(msNormalFai,vTexCoords);
 
 
 
 	// current fragment coords in screen space
-	vec3 ep = vec3( texCoords.xy, currentPixelDepth );
+	vec3 ep = vec3( vTexCoords.xy, currentPixelDepth );
 	// get the normal of current fragment
 	vec3 norm = unpackNormal(currentPixelSample.xy);
 
@@ -84,5 +84,5 @@ void main(void)
 
 	// output the result
 	float ao = 1.0-totStrength*bl*invSamples;
-	gl_FragColor.a = ao /** MAX_SSAO_DISTANCE*/;
+	gl_FragColor.r = ao /** MAX_SSAO_DISTANCE*/;
 }

+ 3 - 3
shaders/PpsSsaoBlur.glsl

@@ -6,7 +6,7 @@
 
 #pragma anki include "shaders/median_filter.glsl"
 
-varying vec2 texCoords;
+varying vec2 vTexCoords;
 
 uniform sampler2D tex;
 
@@ -30,9 +30,9 @@ void main()
 	for( int i=0; i<KERNEL_SIZE; i++ )
 	{
 		#if defined( _PPS_SSAO_PASS_0_ )
-			factor += texture2D( tex, texCoords + vec2(kernel[i], 0.0) ).a;
+			factor += texture2D( tex, vTexCoords + vec2(kernel[i], 0.0) ).a;
 		#else
-			factor += texture2D( tex, texCoords + vec2(0.0, kernel[i]) ).a;
+			factor += texture2D( tex, vTexCoords + vec2(0.0, kernel[i]) ).a;
 		#endif		
 	}
 	gl_FragData[0].a = factor / float(KERNEL_SIZE);

+ 4 - 4
shaders/SimpleVert.glsl

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

+ 4 - 2
shaders/final.glsl

@@ -5,14 +5,16 @@
 #pragma anki fragShaderBegins
 
 uniform sampler2D rasterImage;
-varying vec2 texCoords;
+varying vec2 vTexCoords;
 
 void main()
 {
 	//if( gl_FragCoord.x > 0.5 ) discard;
 
-	gl_FragColor.rgb = texture2D( rasterImage, texCoords ).rgb;
+	gl_FragColor.rgb = texture2D(rasterImage, vTexCoords).rgb;
 
+
+	//gl_FragColor.rgb = vec3(texture2D(rasterImage, vTexCoords).r);
 	/*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( rasterImage, texCoords ).a );

+ 1 - 0
src/Core/App.cpp

@@ -68,6 +68,7 @@ App::App(int argc, char* argv[], Object* parent):
 	cachePath = settingsPath / "cache";
 	if(filesystem::exists(cachePath))
 	{
+		INFO("Deleting dir \"" << cachePath << "\"");
 		filesystem::remove_all(cachePath);
 	}
 

+ 6 - 5
src/Main.cpp

@@ -131,10 +131,11 @@ void init()
 	initializer.is.sm.resolution = 512;
 	initializer.pps.hdr.enabled = true;
 	initializer.pps.hdr.renderingQuality = 0.25;
-	initializer.pps.hdr.blurringDist = 2.0;
-	initializer.pps.ssao.bluringQuality = 1.0;
+	initializer.pps.hdr.blurringDist = 0.0;
+	initializer.pps.hdr.blurringIterations = 2;
+	initializer.pps.ssao.blurringIterations = 2;
 	initializer.pps.ssao.enabled = true;
-	initializer.pps.ssao.renderingQuality = 0.5;
+	initializer.pps.ssao.renderingQuality = 0.25;
 	initializer.mainRendererQuality = 1.0;
 	app->getMainRenderer().init(initializer);
 	Ui::init();
@@ -198,8 +199,8 @@ void init()
 	}*/
 
 	// sponza map
-	/*MeshNode* node = new MeshNode();
-	node->init("maps/sponza/sponza.mesh");*/
+	MeshNode* node = new MeshNode();
+	node->init("maps/sponza/sponza.mesh");
 	//node->setLocalTransform(Transform(Vec3(0.0, -0.0, 0.0), Mat3::getIdentity(), 0.01));
 
 	// particle emitter

+ 88 - 0
src/Physics/DebugDrawer.cpp

@@ -0,0 +1,88 @@
+#include "DebugDrawer.h"
+#include "MainRenderer.h"
+#include "App.h"
+#include "BtAndAnkiConvertors.h"
+
+
+//======================================================================================================================
+// drawLine                                                                                                            =
+//======================================================================================================================
+void DebugDrawer::drawLine(const btVector3& from, const btVector3& to, const btVector3& color)
+{
+	app->getMainRenderer().dbg.drawLine(toAnki(from), toAnki(to), Vec4(toAnki(color), 1.0));
+}
+
+
+//======================================================================================================================
+// drawSphere                                                                                                          =
+//======================================================================================================================
+void DebugDrawer::drawSphere(btScalar radius, const btTransform& transform, const btVector3& color)
+{
+	app->getMainRenderer().dbg.drawSphere(radius, Transform(toAnki(transform)), Vec4(toAnki(color), 1.0));
+}
+
+
+//======================================================================================================================
+// drawBox                                                                                                             =
+//======================================================================================================================
+void DebugDrawer::drawBox(const btVector3& min, const btVector3& max, const btVector3& color)
+{
+	Mat4 trf(Mat4::getIdentity());
+	trf(0, 0) = max.getX() - min.getX();
+	trf(1, 1) = max.getY() - min.getY();
+	trf(2, 2) = max.getZ() - min.getZ();
+	trf(0, 3) = (max.getX() + min.getX()) / 2.0;
+	trf(1, 3) = (max.getY() + min.getY()) / 2.0;
+	trf(2, 3) = (max.getZ() + min.getZ()) / 2.0;
+	app->getMainRenderer().dbg.setModelMat(trf);
+	app->getMainRenderer().dbg.setColor(Vec4(toAnki(color), 1.0));
+	app->getMainRenderer().dbg.drawCube(1.0);
+}
+
+
+//======================================================================================================================
+// drawBox                                                                                                             =
+//======================================================================================================================
+void DebugDrawer::drawBox(const btVector3& min, const btVector3& max, const btTransform& trans,
+                                 const btVector3& color)
+{
+	Mat4 trf(Mat4::getIdentity());
+	trf(0, 0) = max.getX() - min.getX();
+	trf(1, 1) = max.getY() - min.getY();
+	trf(2, 2) = max.getZ() - min.getZ();
+	trf(0, 3) = (max.getX() + min.getX()) / 2.0;
+	trf(1, 3) = (max.getY() + min.getY()) / 2.0;
+	trf(2, 3) = (max.getZ() + min.getZ()) / 2.0;
+	trf = Mat4::combineTransformations(Mat4(toAnki(trans)), trf);
+	app->getMainRenderer().dbg.setModelMat(trf);
+	app->getMainRenderer().dbg.setColor(Vec4(toAnki(color), 1.0));
+	app->getMainRenderer().dbg.drawCube(1.0);
+}
+
+
+//======================================================================================================================
+// drawContactPoint                                                                                                    =
+//======================================================================================================================
+void DebugDrawer::drawContactPoint(const btVector3& /*pointOnB*/, const btVector3& /*normalOnB*/,
+                                          btScalar /*distance*/, int /*lifeTime*/, const btVector3& /*color*/)
+{
+	WARNING("Unimplemented");
+}
+
+
+//======================================================================================================================
+// reportErrorWarning                                                                                                  =
+//======================================================================================================================
+void DebugDrawer::reportErrorWarning(const char* warningString)
+{
+	ERROR(warningString);
+}
+
+
+//======================================================================================================================
+// draw3dText                                                                                                          =
+//======================================================================================================================
+void DebugDrawer::draw3dText(const btVector3& /*location*/, const char* /*textString*/)
+{
+	WARNING("Unimplemented");
+}

+ 2 - 82
src/Physics/DebugDrawer.h

@@ -3,8 +3,6 @@
 
 #include <LinearMath/btIDebugDraw.h>
 #include "Common.h"
-#include "Renderer.h"
-#include "BtAndAnkiConvertors.h"
 
 
 /**
@@ -21,90 +19,12 @@ class DebugDrawer: public btIDebugDraw
 		void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btTransform& trans, const btVector3& color);
 		void reportErrorWarning(const char* warningString);
 		void draw3dText(const btVector3& location, const char* textString);
-		void setDebugMode(int debugMode_);
-		int getDebugMode() const;
+		void setDebugMode(int debugMode_) {debugMode = debugMode_;}
+		int getDebugMode() const {return debugMode;}
 
 	private:
 		int debugMode;
 };
 
 
-//======================================================================================================================
-// Inlines                                                                                                             =
-//======================================================================================================================
-
-inline void DebugDrawer::drawLine(const btVector3& from, const btVector3& to, const btVector3& color)
-{
-	Dbg::drawLine(toAnki(from), toAnki(to), Vec4(toAnki(color), 1.0));
-}
-
-
-inline void DebugDrawer::drawSphere(btScalar radius, const btTransform& transform, const btVector3& color)
-{
-	Dbg::drawSphere(radius, Transform(toAnki(transform)), Vec4(toAnki(color), 1.0));
-}
-
-
-inline void DebugDrawer::drawBox(const btVector3& min, const btVector3& max, const btVector3& color)
-{
-	Mat4 trf(Mat4::getIdentity());
-	trf(0, 0) = max.getX() - min.getX();
-	trf(1, 1) = max.getY() - min.getY();
-	trf(2, 2) = max.getZ() - min.getZ();
-	trf(0, 3) = (max.getX() + min.getX()) / 2.0;
-	trf(1, 3) = (max.getY() + min.getY()) / 2.0;
-	trf(2, 3) = (max.getZ() + min.getZ()) / 2.0;
-	Dbg::setModelMat(trf);
-	Dbg::setColor(Vec4(toAnki(color), 1.0));
-	Dbg::drawCube(1.0);
-}
-
-
-inline void DebugDrawer::drawBox(const btVector3& min, const btVector3& max, const btTransform& trans,
-                                 const btVector3& color)
-{
-	Mat4 trf(Mat4::getIdentity());
-	trf(0, 0) = max.getX() - min.getX();
-	trf(1, 1) = max.getY() - min.getY();
-	trf(2, 2) = max.getZ() - min.getZ();
-	trf(0, 3) = (max.getX() + min.getX()) / 2.0;
-	trf(1, 3) = (max.getY() + min.getY()) / 2.0;
-	trf(2, 3) = (max.getZ() + min.getZ()) / 2.0;
-	trf = Mat4::combineTransformations(Mat4(toAnki(trans)), trf);
-	Dbg::setModelMat(trf);
-	Dbg::setColor(Vec4(toAnki(color), 1.0));
-	Dbg::drawCube(1.0);
-}
-
-
-inline void DebugDrawer::drawContactPoint(const btVector3& /*pointOnB*/, const btVector3& /*normalOnB*/,
-                                          btScalar /*distance*/, int /*lifeTime*/, const btVector3& /*color*/)
-{
-	WARNING("Unimplemented");
-}
-
-
-inline void DebugDrawer::reportErrorWarning(const char* warningString)
-{
-	ERROR(warningString);
-}
-
-
-inline void DebugDrawer::draw3dText(const btVector3& /*location*/, const char* /*textString*/)
-{
-	WARNING("Unimplemented");
-}
-
-
-inline void DebugDrawer::setDebugMode(int debugMode_)
-{
-	debugMode = debugMode_;
-}
-
-
-inline int DebugDrawer::getDebugMode() const
-{
-	return debugMode;
-}
-
 #endif

+ 1 - 0
src/Physics/PhyCharacter.cpp

@@ -1,3 +1,4 @@
+#include <algorithm>
 #include <btBulletCollisionCommon.h>
 #include <btBulletDynamicsCommon.h>
 #include <BulletCollision/CollisionDispatch/btGhostObject.h>

+ 1 - 0
src/Physics/PhyCharacter.h

@@ -13,6 +13,7 @@ class btConvexShape;
 class btKinematicCharacterController;
 class btGhostPairCallback;
 class MotionState;
+class SceneNode;
 
 
 /**

+ 1 - 0
src/Renderer/Bs.cpp

@@ -3,6 +3,7 @@
 #include "App.h"
 #include "Scene.h"
 #include "MeshNode.h"
+#include "ShaderProg.h"
 
 
 //======================================================================================================================

+ 5 - 3
src/Renderer/Bs.h

@@ -4,11 +4,13 @@
 #include "Common.h"
 #include "RenderingStage.h"
 #include "Fbo.h"
-#include "ShaderProg.h"
 #include "RsrcPtr.h"
 #include "Texture.h"
 
 
+class ShaderProg;
+
+
 /**
  * Blending stage
  */
@@ -20,8 +22,8 @@ class Bs: public RenderingStage
 		void run();
 
 	private:
-		Fbo fbo;
-		Fbo refractFbo;
+		Fbo fbo; ///< Writes to pps.prePassFai
+		Fbo refractFbo; ///< Writes to refractFai
 		RsrcPtr<ShaderProg> refractSProg;
 		Texture refractFai;
 

+ 45 - 56
src/Renderer/Dbg.cpp

@@ -8,15 +8,6 @@
 #include "RendererInitializer.h"
 
 
-//======================================================================================================================
-// Statics                                                                                                             =
-//======================================================================================================================
-RsrcPtr<ShaderProg> Dbg::sProg;
-Mat4 Dbg::viewProjectionMat;
-const ShaderProg::UniVar* Dbg::colorUniVar;
-const ShaderProg::UniVar* Dbg::modelViewProjectionMat;
-
-
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
@@ -26,8 +17,7 @@ Dbg::Dbg(Renderer& r_):
 	showLightsEnabled(true),
 	showSkeletonsEnabled(true),
 	showCamerasEnabled(true)
-{
-}
+{}
 
 
 //======================================================================================================================
@@ -40,10 +30,10 @@ void Dbg::drawLine(const Vec3& from, const Vec3& to, const Vec4& color)
 	setColor(color);
 	setModelMat(Mat4::getIdentity());
 
-	glEnableVertexAttribArray(0);
+	glEnableVertexAttribArray(POSITION_ATTRIBUTE_ID);
 	glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, posBuff);
 	glDrawArrays(GL_LINES, 0, 2);
-	glDisableVertexAttribArray(0);
+	glDisableVertexAttribArray(POSITION_ATTRIBUTE_ID);
 }
 
 
@@ -52,41 +42,44 @@ void Dbg::drawLine(const Vec3& from, const Vec3& to, const Vec4& color)
 //======================================================================================================================
 void Dbg::renderGrid()
 {
-	float col0[] = { 0.5, 0.5, 0.5 };
-	float col1[] = { 0.0, 0.0, 1.0 };
-	float col2[] = { 1.0, 0.0, 0.0 };
-
-	glDisable(GL_TEXTURE_2D);
-	glDisable(GL_LIGHTING);
-	glDisable(GL_LINE_STIPPLE);
-	//glLineWidth(1.0);
-	glColor3fv(col0);
-
-	const float space = 1.0; // space between lines
-	const int num = 57;  // lines number. must be odd
-
-	float opt = ((num-1)*space/2);
-	glBegin(GL_LINES);
-		for(int x=0; x<num; x++)
-		{
-			if(x==num/2) // if the middle line then change color
-				glColor3fv(col1);
-			else if(x==(num/2)+1) // if the next line after the middle one change back to default col
-				glColor3fv(col0);
-
-			float opt1 = (x*space);
-			// line in z
-			glVertex3f(opt1-opt, 0.0, -opt);
-			glVertex3f(opt1-opt, 0.0, opt);
-
-			if(x==num/2) // if middle line change col so you can highlight the x-axis
-				glColor3fv(col2);
-
-			// line in the x
-			glVertex3f(-opt, 0.0, opt1-opt);
-			glVertex3f(opt, 0.0, opt1-opt);
-		}
-	glEnd();
+	Vec4 col0(0.5, 0.5, 0.5, 1.0);
+	Vec4 col1(0.0, 0.0, 1.0, 1.0);
+	Vec4 col2(1.0, 0.0, 0.0, 1.0);
+
+	const float SPACE = 1.0; // space between lines
+	const int NUM = 57;  // lines number. must be odd
+
+	float OPT = ((NUM - 1) * SPACE / 2);
+
+	Vec<Vec3> positions;
+	Vec<Vec4> colors;
+
+	for(int x=0; x<NUM; x++)
+	{
+		if(x == NUM / 2) // if the middle line then change color
+			colors.push_back(col1);
+		else if(x == (NUM / 2) + 1) // if the next line after the middle one change back to default col
+			colors.push_back(col0);
+
+		float opt1 = x * SPACE;
+		// line in z
+		positions.push_back(Vec3(opt1 - OPT, 0.0, -OPT));
+		positions.push_back(Vec3(opt1 - OPT, 0.0, OPT));
+
+		if(x==NUM/2) // if middle line change col so you can highlight the x-axis
+			colors.push_back(col2);
+
+		// line in the x
+		positions.push_back(Vec3(-OPT, 0.0, opt1 - OPT));
+		positions.push_back(Vec3(OPT, 0.0, opt1 - OPT));
+	}
+
+	// render
+	setColor(col0);
+	glEnableVertexAttribArray(POSITION_ATTRIBUTE_ID);
+	glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, &positions[0]);
+	glDrawArrays(GL_LINES, 0, positions.size());
+	glDisableVertexAttribArray(POSITION_ATTRIBUTE_ID);
 }
 
 
@@ -220,13 +213,9 @@ void Dbg::init(const RendererInitializer& initializer)
 	fbo.unbind();
 
 	// shader
-	if(sProg.get() == NULL)
-	{
-		sProg.loadRsrc("shaders/Dbg.glsl");
-		colorUniVar = sProg->findUniVar("color");
-		modelViewProjectionMat = sProg->findUniVar("modelViewProjectionMat");
-	}
-
+	sProg.loadRsrc("shaders/Dbg.glsl");
+	colorUniVar = sProg->findUniVar("color");
+	modelViewProjectionMatUniVar = sProg->findUniVar("modelViewProjectionMat");
 }
 
 
@@ -296,6 +285,6 @@ void Dbg::setColor(const Vec4& color)
 void Dbg::setModelMat(const Mat4& modelMat)
 {
 	Mat4 pmv = viewProjectionMat * modelMat;
-	modelViewProjectionMat->setMat4(&pmv);
+	modelViewProjectionMatUniVar->setMat4(&pmv);
 }
 

+ 13 - 11
src/Renderer/Dbg.h

@@ -16,36 +16,38 @@ class Dbg: public RenderingStage
 {
 	public:
 		Dbg(Renderer& r_);
-		void renderGrid();
 		void init(const RendererInitializer& initializer);
 		void run();
-		static void drawSphere(float radius, const Transform& trf, const Vec4& col, int complexity = 8);
-		static void drawCube(float size = 1.0);
-		static void setColor(const Vec4& color);
-		static void setModelMat(const Mat4& modelMat);
-		static void drawLine(const Vec3& from, const Vec3& to, const Vec4& color);
+		void renderGrid();
+		void drawSphere(float radius, const Transform& trf, const Vec4& col, int complexity = 8);
+		void drawCube(float size = 1.0);
+		void setColor(const Vec4& color);
+		void setModelMat(const Mat4& modelMat);
+		void drawLine(const Vec3& from, const Vec3& to, const Vec4& color);
 
 		/**
 		 * @name Setters & getters
 		 */
 		/**@{*/
 		bool isEnabled() const {return enabled;}
-		void enable() {enabled = true;}
+		void setEnabled(bool flag) {enabled = flag;}
 		bool isShowSkeletonsEnabled() const {return showSkeletonsEnabled;}
+		void setShowSkeletonsEnabled(bool flag) {showSkeletonsEnabled = flag;}
 		/// @todo add others
 		/**@}*/
 
 	private:
+		static const uint POSITION_ATTRIBUTE_ID = 0; ///< The glId of the attribute var for position in the dbg shader
 		bool enabled;
 		bool showAxisEnabled;
 		bool showLightsEnabled;
 		bool showSkeletonsEnabled;
 		bool showCamerasEnabled;
 		Fbo fbo;
-		static RsrcPtr<ShaderProg> sProg;
-		static const ShaderProg::UniVar* colorUniVar;
-		static const ShaderProg::UniVar* modelViewProjectionMat;
-		static Mat4 viewProjectionMat;
+		RsrcPtr<ShaderProg> sProg;
+		const ShaderProg::UniVar* colorUniVar;
+		const ShaderProg::UniVar* modelViewProjectionMatUniVar;
+		Mat4 viewProjectionMat;
 };
 
 

+ 28 - 26
src/Renderer/Hdr.cpp

@@ -5,9 +5,9 @@
 
 
 //======================================================================================================================
-// initFbos                                                                                                            =
+// initFbo                                                                                                            =
 //======================================================================================================================
-void Hdr::initFbos(Fbo& fbo, Texture& fai, int internalFormat)
+void Hdr::initFbo(Fbo& fbo, Texture& fai)
 {
 	int width = renderingQuality * r.getWidth();
 	int height = renderingQuality * r.getHeight();
@@ -20,7 +20,7 @@ void Hdr::initFbos(Fbo& fbo, Texture& fai, int internalFormat)
 	fbo.setNumOfColorAttachements(1);
 
 	// create the texes
-	fai.createEmpty2D(width, height, internalFormat, GL_RGB, GL_FLOAT);
+	fai.createEmpty2D(width, height, GL_RGB, GL_RGB, GL_FLOAT);
 	fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 	fai.setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
@@ -48,10 +48,11 @@ void Hdr::init(const RendererInitializer& initializer)
 
 	renderingQuality = initializer.pps.hdr.renderingQuality;
 	blurringDist = initializer.pps.hdr.blurringDist;
+	blurringIterations = initializer.pps.hdr.blurringIterations;
 
-	initFbos(toneFbo, pass0Fai, GL_RGB);
-	initFbos(pass1Fbo, pass1Fai, GL_RGB);
-	initFbos(pass2Fbo, fai, GL_RGB);
+	initFbo(toneFbo, toneFai);
+	initFbo(hblurFbo, hblurFai);
+	initFbo(vblurFbo, fai);
 
 	fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
@@ -63,14 +64,14 @@ void Hdr::init(const RendererInitializer& initializer)
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 
 	string pps = "#define HPASS\n#define COL_RGB\n";
-	string prefix = "HRGB";
-	pass1SProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str(), prefix.c_str()).c_str());
-	pass1SProgFaiUniVar = pass1SProg->findUniVar("img");
+	string prefix = "HorizontalRgb";
+	hblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str(), prefix.c_str()).c_str());
+	hblurSProgFaiUniVar = hblurSProg->findUniVar("img");
 
 	pps = "#define VPASS\n#define COL_RGB\n";
-	prefix = "VRGB";
-	pass2SProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str(), prefix.c_str()).c_str());
-	pass2SProgFaiUniVar = pass2SProg->findUniVar("img");
+	prefix = "VerticalRgb";
+	vblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str(), prefix.c_str()).c_str());
+	vblurSProgFaiUniVar = vblurSProg->findUniVar("img");
 }
 
 #include "App.h"
@@ -90,35 +91,36 @@ void Hdr::run()
 	// pass 0
 	toneFbo.bind();
 	toneSProg->bind();
-	r.is.fai.setRepeat(false);
 	toneProgFaiUniVar->setTexture(r.pps.prePassFai, 0);
 	Renderer::drawQuad(0);
 
-	Vec2 imgSize(w, h);
 
-	for(uint i=0; i<2; i++)
+	// blurring passes
+	hblurFai.setRepeat(false);
+	fai.setRepeat(false);
+	for(uint i=0; i<blurringIterations; i++)
 	{
 		// hpass
-		pass1Fbo.bind();
-		pass1SProg->bind();
+		hblurFbo.bind();
+		hblurSProg->bind();
 		if(i == 0)
 		{
-			pass1SProgFaiUniVar->setTexture(pass0Fai, 0);
+			hblurSProgFaiUniVar->setTexture(toneFai, 0);
 		}
 		else
 		{
-			pass1SProgFaiUniVar->setTexture(fai, 0);
+			hblurSProgFaiUniVar->setTexture(fai, 0);
 		}
-		pass1SProg->findUniVar("imgSize")->setVec2(&imgSize);
-		pass1SProg->findUniVar("blurringDist")->setFloat(blurringDist);
+		hblurSProg->findUniVar("imgDimension")->setFloat(w);
+		hblurSProg->findUniVar("blurringDist")->setFloat(blurringDist / w);
 		Renderer::drawQuad(0);
 
 		// vpass
-		pass2Fbo.bind();
-		pass2SProg->bind();
-		pass2SProgFaiUniVar->setTexture(pass1Fai, 0);
-		pass2SProg->findUniVar("imgSize")->setVec2(&imgSize);
-		pass2SProg->findUniVar("blurringDist")->setFloat(blurringDist);
+		vblurFbo.bind();
+		vblurSProg->bind();
+		vblurSProgFaiUniVar->setTexture(hblurFai, 0);
+		vblurSProg->findUniVar("imgDimension")->setFloat(h);
+		vblurSProg->findUniVar("blurringDist")->setFloat(blurringDist / h);
 		Renderer::drawQuad(0);
 	}
 

+ 14 - 10
src/Renderer/Hdr.h

@@ -15,8 +15,8 @@
 class Hdr: private RenderingStage
 {
 	public:
-		Texture pass0Fai; ///< Vertical blur pass FAI
-		Texture pass1Fai; ///< pass0Fai with the horizontal blur FAI
+		Texture toneFai; ///< Vertical blur pass FAI
+		Texture hblurFai; ///< pass0Fai with the horizontal blur FAI
 		Texture fai; ///< The final FAI
 
 		Hdr(Renderer& r_): RenderingStage(r_) {}
@@ -27,27 +27,31 @@ class Hdr: private RenderingStage
 		 * Setters & getters
 		 */
 		/**@{*/
-		float& getBlurringDist() {return blurringDist;}
+		float getBlurringDist() {return blurringDist;}
 		void setBlurringDist(float f) {blurringDist = f;}
+		uint getBlurringIterations() {return blurringIterations;}
+		void setBlurringIterations(uint i) {blurringIterations = i;}
 		bool isEnabled() const {return enabled;}
 		float getRenderingQuality() const {return renderingQuality;}
 		/**@}*/
 
 	private:
 		Fbo toneFbo;
-		Fbo pass1Fbo;
-		Fbo pass2Fbo;
+		Fbo hblurFbo;
+		Fbo vblurFbo;
 		RsrcPtr<ShaderProg> toneSProg;
-		RsrcPtr<ShaderProg> pass1SProg;
-		RsrcPtr<ShaderProg> pass2SProg;
+		RsrcPtr<ShaderProg> hblurSProg;
+		RsrcPtr<ShaderProg> vblurSProg;
 		const ShaderProg::UniVar* toneProgFaiUniVar;
-		const ShaderProg::UniVar* pass1SProgFaiUniVar;
-		const ShaderProg::UniVar* pass2SProgFaiUniVar;
+		const ShaderProg::UniVar* hblurSProgFaiUniVar;
+		const ShaderProg::UniVar* vblurSProgFaiUniVar;
 		float blurringDist;
+		uint blurringIterations;
+		float overExposure; ///< @todo
 		bool enabled;
 		float renderingQuality;
 
-		void initFbos(Fbo& fbo, Texture& fai, int internalFormat);
+		void initFbo(Fbo& fbo, Texture& fai);
 };
 
 

+ 6 - 3
src/Renderer/Is.cpp

@@ -97,6 +97,10 @@ void Is::initFbo()
 //======================================================================================================================
 void Is::init(const RendererInitializer& initializer)
 {
+	// init passes
+	smo.init(initializer);
+	sm.init(initializer);
+
 	// load the shaders
 	ambientPassSProg.loadRsrc("shaders/IsAp.glsl");
 	ambientColUniVar = ambientPassSProg->findUniVar("ambientCol");
@@ -136,7 +140,7 @@ void Is::init(const RendererInitializer& initializer)
 	// spot light w/t shadow
 	string pps = string("\n#define SPOT_LIGHT_ENABLED\n#define SHADOW_ENABLED\n") +
 	                    "#define SHADOWMAP_SIZE " + lexical_cast<string>(sm.getResolution()) + "\n";
-	string prefix = "SpotShadowSms" + lexical_cast<string>(sm.getResolution());
+	string prefix = "SpotShadowSmSize" + lexical_cast<string>(sm.getResolution());
 	if(sm.isPcfEnabled())
 	{
 		pps += "#define PCF_ENABLED\n";
@@ -160,7 +164,6 @@ void Is::init(const RendererInitializer& initializer)
 
 	// init the rest
 	initFbo();
-	smo.init(initializer);
 }
 
 
@@ -208,7 +211,7 @@ void Is::pointLightPass(const PointLight& light)
 	pointLightSProgUniVars.planes->setVec2(&planes);
 	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed(cam.getViewMatrix());
 	pointLightSProgUniVars.lightPos->setVec3(&lightPosEyeSpace);
-	pointLightSProgUniVars.lightRadius->setFloat(1.0/light.getRadius());
+	pointLightSProgUniVars.lightRadius->setFloat(light.getRadius());
 	Vec3 ll = light.lightProps->getDiffuseColor();
 	pointLightSProgUniVars.lightDiffuseCol->setVec3(&light.lightProps->getDiffuseColor());
 	pointLightSProgUniVars.lightSpecularCol->setVec3(&light.lightProps->getSpecularColor());

+ 3 - 0
src/Renderer/MainRenderer.cpp

@@ -28,6 +28,7 @@ void MainRenderer::init(const RendererInitializer& initializer_)
 	initializer.width = app->getWindowWidth() * renderingQuality;
 	initializer.height = app->getWindowHeight() * renderingQuality;
 	Renderer::init(initializer);
+	dbg.init(initializer);
 
 	INFO("Main renderer initialization ends");
 }
@@ -77,6 +78,7 @@ void MainRenderer::initGl()
 void MainRenderer::render(Camera& cam_)
 {
 	Renderer::render(cam_);
+	dbg.run();
 
 	//
 	// Render the PPS FAI to the framebuffer
@@ -87,6 +89,7 @@ void MainRenderer::render(Camera& cam_)
 	glDisable(GL_BLEND);
 	sProg->bind();
 	//sProg->findUniVar("rasterImage")->setTexture(pps.hdr.fai, 0);
+	//sProg->findUniVar("rasterImage")->setTexture(pps.ssao.fai, 0);
 	sProg->findUniVar("rasterImage")->setTexture(pps.postPassFai, 0);
 	drawQuad(0);
 }

+ 21 - 13
src/Renderer/MainRenderer.h

@@ -1,5 +1,5 @@
-#ifndef _MAINRENDERER_H_
-#define _MAINRENDERER_H_
+#ifndef MAIN_RENDERER_H
+#define MAIN_RENDERER_H
 
 #include "Common.h"
 #include "Renderer.h"
@@ -10,19 +10,19 @@
  */
 class MainRenderer: public Renderer
 {
-	/**
-	 * The quality of the JPEG screenshots. From 0 to 100
-	 */
-	PROPERTY_RW(int, screenshotJpegQuality, setScreenshotJpegQuality, getScreenshotJpegQuality)
+	public:
+		Dbg dbg; ///< Debugging rendering stage. Only the main renderer has it
 
-	/**
-	 * The global rendering quality of the raster image. Its a percentage of the application's window size. From 0.0(low)
-	 * to 1.0(high)
-	 */
-	PROPERTY_R(float, renderingQuality, getRenderingQuality)
+		MainRenderer(Object* parent); ///< The quality of the JPEG screenshots. From 0 to 100
 
-	public:
-		MainRenderer(Object* parent);
+		/**
+		 * @name Setters & getters
+		 */
+		/**@{*/
+		int& getScreenshotJpegQuality() {return screenshotJpegQuality;}
+		void setScreenshotJpegQuality(int i) {screenshotJpegQuality = i;}
+		float getRenderingQuality() const {return renderingQuality;}
+		/**@}*/
 
 		/**
 		 * The same as Renderer::init but with additional initialization. @see Renderer::init
@@ -43,6 +43,13 @@ class MainRenderer: public Renderer
 
 	private:
 		RsrcPtr<ShaderProg> sProg; ///< Final pass' shader program
+		int screenshotJpegQuality; ///< The quality of the JPEG screenshots. From 0 to 100
+
+		/**
+		 * The global rendering quality of the raster image. Its a percentage of the application's window size. From
+		 * 0.0(low) to 1.0(high)
+		 */
+		float renderingQuality;
 
 		bool takeScreenshotTga(const char* filename);
 		bool takeScreenshotJpeg(const char* filename);
@@ -52,6 +59,7 @@ class MainRenderer: public Renderer
 
 inline MainRenderer::MainRenderer(Object* parent):
 	Renderer(parent),
+	dbg(*this),
 	screenshotJpegQuality(90)
 {}
 

+ 0 - 2
src/Renderer/Pps.cpp

@@ -117,8 +117,6 @@ void Pps::runPrePass()
 	Renderer::drawQuad(0);
 
 	Fbo::unbind();
-
-	prePassFai.genMipmap();
 }
 
 

+ 8 - 0
src/Renderer/Pps.h

@@ -44,7 +44,15 @@ class Pps: private RenderingStage
 		UniVars postPassSProgUniVars;
 
 		void initPassFbo(Fbo& fbo, Texture& fai, const char* msg);
+
+		/**
+		 * before BS pass
+		 */
 		void initPrePassSProg();
+
+		/**
+		 * after BS pass
+		 */
 		void initPostPassSProg();
 };
 

+ 1 - 4
src/Renderer/Renderer.cpp

@@ -23,8 +23,7 @@ Renderer::Renderer(Object* parent):
 	ms(*this),
 	is(*this),
 	pps(*this),
-	bs(*this),
-	dbg(*this)
+	bs(*this)
 {
 }
 
@@ -51,7 +50,6 @@ void Renderer::init(const RendererInitializer& initializer)
 	is.init(initializer);
 	pps.init(initializer);
 	bs.init(initializer);
-	dbg.init(initializer);
 }
 
 
@@ -69,7 +67,6 @@ void Renderer::render(Camera& cam_)
 	pps.runPrePass();
 	bs.run();
 	pps.runPostPass();
-	dbg.run();
 
 	++framesNum;
 }

+ 0 - 1
src/Renderer/Renderer.h

@@ -47,7 +47,6 @@ class Renderer: public Object
 		Is is; ///< Illumination rendering stage
 		Pps pps; ///< Postprocessing rendering stage
 		Bs bs; ///< Blending stage
-		Dbg dbg; ///< Debugging rendering stage
 		/**@}*/
 
 		static float quadVertCoords [][2];

+ 2 - 1
src/Renderer/RendererInitializer.h

@@ -41,6 +41,7 @@ struct RendererInitializer
 			bool enabled;
 			float renderingQuality;
 			float blurringDist;
+			float blurringIterations;
 		} hdr;
 
 		// Ssao
@@ -48,7 +49,7 @@ struct RendererInitializer
 		{
 			bool enabled;
 			float renderingQuality;
-			float bluringQuality;
+			float blurringIterations;
 		} ssao;
 	} pps;
 

+ 3 - 3
src/Renderer/Smo.cpp

@@ -84,9 +84,9 @@ void Smo::run(const SpotLight& light)
 	float y = tan(lcam.getFovY()/2) * lcam.getZFar();
 	float z = -lcam.getZFar();
 
-	const int trisNum = 6;
+	const int TRIS_NUM = 6;
 
-	float verts[trisNum][3][3] = {
+	float verts[TRIS_NUM][3][3] = {
 		{{0.0, 0.0, 0.0}, {x, -y, z}, {x,  y, z}}, // right triangle
 		{{0.0, 0.0, 0.0}, {x,  y, z}, {-x,  y, z}}, // top
 		{{0.0, 0.0, 0.0}, {-x,  y, z}, {-x, -y, z}}, // left
@@ -105,7 +105,7 @@ void Smo::run(const SpotLight& light)
 	const int loc = 0;
 	glEnableVertexAttribArray(loc);
 	glVertexAttribPointer(loc, 3, GL_FLOAT, false, 0, verts);
-	glDrawArrays(GL_TRIANGLES, 0, trisNum*3);
+	glDrawArrays(GL_TRIANGLES, 0, TRIS_NUM * 3);
 	glDisableVertexAttribArray(loc);
 
 	// restore GL state

+ 61 - 71
src/Renderer/Ssao.cpp

@@ -6,11 +6,14 @@
 
 
 //======================================================================================================================
-// initBlurFbos                                                                                                        =
+// createFbo                                                                                                           =
 //======================================================================================================================
-void Ssao::initBlurFbo(Fbo& fbo, Texture& fai)
+void Ssao::createFbo(Fbo& fbo, Texture& fai)
 {
-	// create FBO
+	int width = renderingQuality * r.getWidth();
+	int height = renderingQuality * r.getHeight();
+
+	// create
 	fbo.create();
 	fbo.bind();
 
@@ -18,9 +21,10 @@ void Ssao::initBlurFbo(Fbo& fbo, Texture& fai)
 	fbo.setNumOfColorAttachements(1);
 
 	// create the texes
-	fai.createEmpty2D(bwidth, bheight, GL_ALPHA8, GL_ALPHA, GL_FLOAT);
-	fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-	fai.setTexParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+	fai.createEmpty2D(width, height, GL_RED, GL_RED, GL_FLOAT);
+	fai.setRepeat(false);
+	fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	fai.setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
 	// attach
 	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fai.getGlId(), 0);
@@ -45,68 +49,38 @@ void Ssao::init(const RendererInitializer& initializer)
 		return;
 
 	renderingQuality = initializer.pps.ssao.renderingQuality;
-	bluringQuality = initializer.pps.ssao.bluringQuality;
-
-	width = renderingQuality * r.getWidth();
-	height = renderingQuality * r.getHeight();
-	bwidth = height * bluringQuality;
-	bheight = height * bluringQuality;
-
-	//
-	// init FBOs
-	//
-
-	// create FBO
-	pass0Fbo.create();
-	pass0Fbo.bind();
-
-	// inform in what buffers we draw
-	pass0Fbo.setNumOfColorAttachements(1);
-
-	// create the FAI
-	pass0Fai.createEmpty2D(width, height, GL_ALPHA8, GL_ALPHA, GL_FLOAT);
-	pass0Fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-	pass0Fai.setTexParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-	// attach
-	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pass0Fai.getGlId(), 0);
-
-	// test if success
-	if(!pass0Fbo.isGood())
-		FATAL("Cannot create deferred shading post-processing stage SSAO pass FBO");
-
-	// unbind
-	pass0Fbo.unbind();
-
-	initBlurFbo(pass1Fbo, pass1Fai);
-	initBlurFbo(pass2Fbo, fai);
+	blurringIterations = initializer.pps.ssao.blurringIterations;
 
+	// create FBOs
+	createFbo(ssaoFbo, ssaoFai);
+	createFbo(hblurFbo, hblurFai);
+	createFbo(vblurFbo, fai);
 
 	//
 	// Shaders
 	//
 
+	// first pass prog
 	ssaoSProg.loadRsrc("shaders/PpsSsao.glsl");
-
-	string pps = "#define _PPS_SSAO_PASS_0_\n#define PASS0_FAI_WIDTH " + lexical_cast<string>(static_cast<float>(width)) +
-	             "\n";
-	string prefix = "Pass0Width" + lexical_cast<string>(width);
-	blurSProg.loadRsrc(ShaderProg::createSrcCodeToCache("shaders/PpsSsaoBlur.glsl", pps.c_str(), prefix.c_str()).c_str());
-
-
-	pps = "#define _PPS_SSAO_PASS_1_\n#define PASS1_FAI_HEIGHT " + lexical_cast<string>(static_cast<float>(bheight)) +
-	      "\n";
-	prefix = "Pass1Height" + lexical_cast<string>(bheight);
-	blurSProg2.loadRsrc(ShaderProg::createSrcCodeToCache("shaders/PpsSsaoBlur.glsl", pps.c_str(),
-	                                                     prefix.c_str()).c_str());
-
 	camerarangeUniVar = ssaoSProg->findUniVar("camerarange");
 	msDepthFaiUniVar = ssaoSProg->findUniVar("msDepthFai");
 	noiseMapUniVar = ssaoSProg->findUniVar("noiseMap");
 	msNormalFaiUniVar = ssaoSProg->findUniVar("msNormalFai");
-	blurSProgFaiUniVar = blurSProg->findUniVar("tex"); /// @todo rename the tex in the shader
-	blurSProg2FaiUniVar = blurSProg2->findUniVar("tex"); /// @todo rename the tex in the shader
 
+	// blurring progs
+	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
+
+	string pps = "#define HPASS\n#define COL_R\n";
+	string prefix = "HorizontalR";
+	hblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str(), prefix.c_str()).c_str());
+	imgHblurSProgUniVar = hblurSProg->findUniVar("img");
+	dimensionHblurSProgUniVar = hblurSProg->findUniVar("imgDimension");
+
+	pps = "#define VPASS\n#define COL_R\n";
+	prefix = "VerticalR";
+	vblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str(), prefix.c_str()).c_str());
+	imgVblurSProgUniVar = vblurSProg->findUniVar("img");
+	dimensionVblurSProgUniVar = vblurSProg->findUniVar("imgDimension");
 
 	//
 	// noise map
@@ -135,15 +109,18 @@ void Ssao::init(const RendererInitializer& initializer)
 //======================================================================================================================
 void Ssao::run()
 {
+	int width = renderingQuality * r.getWidth();
+	int height = renderingQuality * r.getHeight();
 	const Camera& cam = r.getCamera();
 
 	glDisable(GL_BLEND);
 	glDisable(GL_DEPTH_TEST);
 
 
-	// 1st pass
 	Renderer::setViewport(0, 0, width, height);
-	pass0Fbo.bind();
+
+	// 1st pass
+	ssaoFbo.bind();
 	ssaoSProg->bind();
 	Vec2 camRange(cam.getZNear(), cam.getZFar());
 	camerarangeUniVar->setVec2(&camRange);
@@ -152,20 +129,33 @@ void Ssao::run()
 	msNormalFaiUniVar->setTexture(r.ms.normalFai, 2);
 	Renderer::drawQuad(0);
 
-	// for 2nd and 3rd passes
-	Renderer::setViewport(0, 0, bwidth, bheight);
 
-	// 2nd pass
-	pass1Fbo.bind();
-	blurSProg->bind();
-	blurSProgFaiUniVar->setTexture(pass0Fai, 0);
-	Renderer::drawQuad(0);
-
-	// 3rd pass
-	pass2Fbo.bind();
-	blurSProg2->bind();
-	blurSProg2FaiUniVar->setTexture(pass1Fai, 0);
-	Renderer::drawQuad(0);
+	// blurring passes
+	hblurFai.setRepeat(false);
+	fai.setRepeat(false);
+	for(uint i=0; i<blurringIterations; i++)
+	{
+		// hpass
+		hblurFbo.bind();
+		hblurSProg->bind();
+		if(i == 0)
+		{
+			imgHblurSProgUniVar->setTexture(ssaoFai, 0);
+		}
+		else
+		{
+			imgHblurSProgUniVar->setTexture(fai, 0);
+		}
+		dimensionHblurSProgUniVar->setFloat(width);
+		Renderer::drawQuad(0);
+
+		// vpass
+		vblurFbo.bind();
+		vblurSProg->bind();
+		imgVblurSProgUniVar->setTexture(hblurFai, 0);
+		dimensionVblurSProgUniVar->setFloat(height);
+		Renderer::drawQuad(0);
+	}
 
 	// end
 	Fbo::unbind();

+ 23 - 17
src/Renderer/Ssao.h

@@ -13,16 +13,16 @@
  * Screen space ambient occlusion pass
  *
  * Three passes:
- * - Calc ssao factor
- * - Blur vertically
- * - Blur horizontally
+ * 1) Calc ssao factor
+ * 2) Blur vertically
+ * 3) Blur horizontally repeat 2, 3
  */
 class Ssao: private RenderingStage
 {
 	public:
-		Texture pass0Fai;
-		Texture pass1Fai;
-		Texture fai;  ///< The final FAI
+		Texture ssaoFai; ///< It contains the unblurred SSAO factor
+		Texture hblurFai;
+		Texture fai;  ///< AKA vblurFai The final FAI
 
 		Ssao(Renderer& r_): RenderingStage(r_) {}
 		void init(const RendererInitializer& initializer);
@@ -34,29 +34,35 @@ class Ssao: private RenderingStage
 		/**@{*/
 		bool isEnabled() const {return enabled;}
 		float getRenderingQuality() const {return renderingQuality;}
-		float getBluringQuality() const {return bluringQuality;}
 		/**@}*/
 
 	private:
 		bool enabled;
 		float renderingQuality;
-		float bluringQuality;
-		Fbo pass0Fbo;
-		Fbo pass1Fbo;
-		Fbo pass2Fbo;
-		uint width, height, bwidth, bheight;
+		float blurringIterations;
+		Fbo ssaoFbo;
+		Fbo hblurFbo;
+		Fbo vblurFbo;
 		RsrcPtr<Texture> noiseMap;
 		RsrcPtr<ShaderProg> ssaoSProg;
-		RsrcPtr<ShaderProg> blurSProg;
-		RsrcPtr<ShaderProg> blurSProg2;
+		RsrcPtr<ShaderProg> hblurSProg;
+		RsrcPtr<ShaderProg> vblurSProg;
+
+		/**
+		 * Pointers to some uniforms
+		 */
+		/**@{*/
 		const ShaderProg::UniVar* camerarangeUniVar;
 		const ShaderProg::UniVar* msDepthFaiUniVar;
 		const ShaderProg::UniVar* noiseMapUniVar;
 		const ShaderProg::UniVar* msNormalFaiUniVar;
-		const ShaderProg::UniVar* blurSProgFaiUniVar;
-		const ShaderProg::UniVar* blurSProg2FaiUniVar;
+		const ShaderProg::UniVar* imgHblurSProgUniVar;
+		const ShaderProg::UniVar* dimensionHblurSProgUniVar;
+		const ShaderProg::UniVar* imgVblurSProgUniVar;
+		const ShaderProg::UniVar* dimensionVblurSProgUniVar;
+		/**@}*/
 
-		void initBlurFbo(Fbo& fbo, Texture& fai);
+		void createFbo(Fbo& fbo, Texture& fai);
 };
 
 

+ 0 - 2
src/Resources/Material.h

@@ -83,7 +83,6 @@ class Material: public Resource
 			SUV_NUM ///< The number of standard uniform variables
 		};
 
-
 		/**
 		 * Information for the standard shader program variables
 		 */
@@ -93,7 +92,6 @@ class Material: public Resource
 			GLenum dataType; ///< aka GL data type
 		};
 
-
 		/**
 		 * Class for user defined material variables that will be passes in to the shader
 		 */

+ 2 - 2
src/Scene/Camera.cpp

@@ -22,8 +22,8 @@ void Camera::setAll(float fovx_, float fovy_, float znear_, float zfar_)
 //======================================================================================================================
 void Camera::render()
 {
-	Dbg::setColor(Vec4(1.0, 0.0, 1.0, 1.0));
-	Dbg::setModelMat(Mat4(getWorldTransform()));
+	app->getMainRenderer().dbg.setColor(Vec4(1.0, 0.0, 1.0, 1.0));
+	app->getMainRenderer().dbg.setModelMat(Mat4(getWorldTransform()));
 
 	const float camLen = 1.0;
 	float tmp0 = camLen / tan((M::PI - fovX)*0.5) + 0.001;

+ 1 - 1
src/Scene/Light.cpp

@@ -37,7 +37,7 @@ void SpotLight::init(const char* filename)
 //======================================================================================================================
 void Light::render()
 {
-	Dbg::drawSphere(0.1, getWorldTransform(), Vec4(lightProps->getDiffuseColor(), 1.0));
+	app->getMainRenderer().dbg.drawSphere(0.1, getWorldTransform(), Vec4(lightProps->getDiffuseColor(), 1.0));
 	//Dbg::drawSphere(0.1, Transform::getIdentity(), Vec4(lightProps->getDiffuseColor(), 1.0));
 }
 

+ 3 - 3
src/Scene/ParticleEmitter.cpp

@@ -212,8 +212,8 @@ void ParticleEmitter::update()
 void ParticleEmitter::render()
 {
 	glPolygonMode(GL_FRONT, GL_LINE);
-	Dbg::setColor(Vec4(1.0));
-	Dbg::setModelMat(Mat4(getWorldTransform()));
-	Dbg::drawCube();
+	app->getMainRenderer().dbg.setColor(Vec4(1.0));
+	app->getMainRenderer().dbg.setModelMat(Mat4(getWorldTransform()));
+	app->getMainRenderer().dbg.drawCube();
 	glPolygonMode(GL_FRONT, GL_FILL);
 }

+ 4 - 4
src/Scene/SkelNode.cpp

@@ -32,14 +32,14 @@ void SkelNode::init(const char* filename)
 //======================================================================================================================
 void SkelNode::render()
 {
-	Dbg::setModelMat(Mat4(getWorldTransform()));
-	Dbg::setColor(Vec4(1.0, 0.0, 0.0, 1.0));
-	Dbg::setModelMat(Mat4(getWorldTransform()));
+	app->getMainRenderer().dbg.setModelMat(Mat4(getWorldTransform()));
+	app->getMainRenderer().dbg.setColor(Vec4(1.0, 0.0, 0.0, 1.0));
+	app->getMainRenderer().dbg.setModelMat(Mat4(getWorldTransform()));
 
 	Vec<Vec3> positions;
 
 	for(uint i=0; i<skeleton->bones.size(); i++)
 	{
-		Dbg::drawLine(heads[i], tails[i], Vec4(1.0));
+		app->getMainRenderer().dbg.drawLine(heads[i], tails[i], Vec4(1.0));
 	}
 }

+ 5 - 0
src/Scripting/BoostPythonInterfaces.cpp

@@ -15,9 +15,14 @@ BOOST_PYTHON_MODULE(Anki)
 	#include "Vec2.bpi.h"
 	#include "Vec3.bpi.h"
 	#include "Vec4.bpi.h"
+
 	#include "Scene.bpi.h"
+
+	#include "Hdr.bpi.h"
+	#include "Pps.bpi.h"
 	#include "Renderer.bpi.h"
 	#include "MainRenderer.bpi.h"
+
 	#include "App.bpi.h"
 }
 

+ 5 - 0
src/Scripting/Renderer/Hdr.bpi.h

@@ -0,0 +1,5 @@
+
+class_<Hdr, noncopyable>("Hdr", no_init)
+	.add_property("blurringIterations", &Hdr::getBlurringIterations, &Hdr::setBlurringIterations)
+	.add_property("blurringDist", &Hdr::getBlurringDist, &Hdr::setBlurringDist)
+;

+ 4 - 0
src/Scripting/Renderer/Pps.bpi.h

@@ -0,0 +1,4 @@
+
+class_<Pps, noncopyable>("Pps", no_init)
+	.def_readonly("hdr", &Pps::hdr)
+;

+ 1 - 0
src/Scripting/Renderer/Renderer.bpi.h

@@ -8,4 +8,5 @@
 
 class_<Renderer, noncopyable>("Renderer", no_init)
 	.def("getFramesNum", &Renderer::getFramesNum)
+	.def_readonly("pps", &Renderer::pps)
 ;

+ 2 - 1
src/Util/Object.h

@@ -6,7 +6,8 @@
 
 
 /**
- * A class for automatic garbage collection. Cause we -the programmers- get bored when it comes to deallocation
+ * A class for automatic garbage collection. Cause we -the programmers- get bored when it comes to deallocation. Dont
+ * even think to put as a parent an object that has not created dynamically
  */
 class Object
 {

+ 1 - 1
src/Util/Tokenizer/Scanner.cpp

@@ -209,7 +209,7 @@ char Scanner::getNextChar()
 	}
 	else if(lookupAscii(*pchar) == AC_ERROR)
 	{
-		SERROR("Unacceptable char '" << *pchar << "' 0x" << int(*pchar));
+		SERROR("Unacceptable char '" << *pchar << "' 0x" << uint(*pchar));
 	}
 
 	return *pchar;

Some files were not shown because too many files changed in this diff