فهرست منبع

- Working on the new renderer
- Added a flow of the new renderer in OpenOffice.org format

Panagiotis Christopoulos Charitos 15 سال پیش
والد
کامیت
4412b6b281
4فایلهای تغییر یافته به همراه126 افزوده شده و 10 حذف شده
  1. BIN
      docs/renderer-flow.odg
  2. 95 0
      src/Renderer2/Pps.cpp
  3. 28 7
      src/Renderer2/Renderer.hpp
  4. 3 3
      src/Renderer2/Ssao.cpp

BIN
docs/renderer-flow.odg


+ 95 - 0
src/Renderer2/Pps.cpp

@@ -1 +1,96 @@
 #include "Renderer.hpp"
 #include "Renderer.hpp"
+
+
+//=====================================================================================================================================
+// init                                                                                                                               =
+//=====================================================================================================================================
+void Renderer::Pps::init()
+{
+	// create FBO
+	fbo.create();
+	fbo.bind();
+
+	// inform in what buffers we draw
+	fbo.setNumOfColorAttachements( 1 );
+
+	// create the texes
+	fai.createEmpty2D( r.width, r.height, GL_RGB, GL_RGB );
+
+	// attach
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
+
+	// test if success
+	if( !fbo.isGood() )
+		FATAL( "Cannot create post-processing stage FBO" );
+
+	fbo.unbind();
+
+
+	// init the shader and it's vars
+	sProg.customLoad( "shaders/Pps.glsl" );
+	sProg.bind();
+
+	sProg.uniLocs.isFai = sProg.getUniVar( "isFai" )->getLoc();
+
+	if( ssao.enabled )
+	{
+		ssao.init();
+		sProg.uniLocs.ppsSsaoFai = sProg.getUniVar( "ppsSsaoFai" )->getLoc();
+	}
+
+	if( hdr.enabled )
+	{
+		hdr.init();
+		sProg.uniLocs.hdrFai = sProg.getUniVar( "ppsHdrFai" )->getLoc();
+	}
+
+	/// @ todo enable lscatt
+	/*if( R::Pps::Lscatt::enabled )
+	{
+		R::Pps::Lscatt::init();
+		sProg.uniLocs.lscattFai = sProg.getUniVar( "ppsLscattFai" )->getLoc();
+	}*/
+
+}
+
+
+//=====================================================================================================================================
+// run                                                                                                                                =
+//=====================================================================================================================================
+void Renderer::Pps::run()
+{
+	if( ssao.enabled )
+		ssao.run();
+
+	if( hdr.enabled )
+		hdr.run();
+
+	fbo.bind();
+
+	// set GL
+	glDisable( GL_DEPTH_TEST );
+	glDisable( GL_BLEND );
+
+	Renderer::setViewport( 0, 0, r.width, r.height );
+
+	// set shader
+	sProg.bind();
+
+	sProg.locTexUnit( sProg.uniLocs.isFai, r.is.fai, 0 ); // the IS FAI
+
+	if( hdr.enabled )
+	{
+		sProg.locTexUnit( sProg.uniLocs.hdrFai, hdr.fai, 1 );
+	}
+
+	if( ssao.enabled )
+	{
+		sProg.locTexUnit( sProg.uniLocs.ppsSsaoFai, ssao.fai, 2 );
+	}
+
+	// draw quad
+	Renderer::drawQuad( 0 );
+
+	// unbind FBO
+	fbo.unbind();
+}

+ 28 - 7
src/Renderer2/Renderer.hpp

@@ -63,7 +63,7 @@ class Renderer
 		{
 		{
 			public:
 			public:
 				/**
 				/**
-				 * Shadowmapping sub-stage
+				 * Shadowmapping pass
 				 */
 				 */
 				class Sm: private RenderingStage
 				class Sm: private RenderingStage
 				{
 				{
@@ -144,15 +144,19 @@ class Renderer
 
 
 		/**
 		/**
 		 * Post-processing stage
 		 * Post-processing stage
+		 *
+		 * This stage is divided into 2 two parts. The first happens before blending stage and the second after.
 		 */
 		 */
 		class Pps: private RenderingStage
 		class Pps: private RenderingStage
 		{
 		{
 			public:
 			public:
 				/**
 				/**
-				 * High dynamic range lighting stage
+				 * High dynamic range lighting pass
 				 */
 				 */
 				class Hdr: private RenderingStage
 				class Hdr: private RenderingStage
 				{
 				{
+					friend class Pps;
+
 					private:
 					private:
 						Fbo pass0Fbo, pass1Fbo, pass2Fbo;
 						Fbo pass0Fbo, pass1Fbo, pass2Fbo;
 						ShaderProg pass0SProg, pass1SProg, pass2SProg;
 						ShaderProg pass0SProg, pass1SProg, pass2SProg;
@@ -179,23 +183,26 @@ class Renderer
 					public:
 					public:
 						bool enabled;
 						bool enabled;
 						float renderingQuality;
 						float renderingQuality;
-						Texture pass0Fai; ///< Vertical blur pass
-						Texture pass1Fai; ///< pass0Fai with the horizontal blur
+						Texture pass0Fai; ///< Vertical blur pass FAI
+						Texture pass1Fai; ///< pass0Fai with the horizontal blur FAI
 						Texture fai; ///< The final FAI
 						Texture fai; ///< The final FAI
 
 
 						Hdr( Renderer& r_ ): RenderingStage(r_) {}
 						Hdr( Renderer& r_ ): RenderingStage(r_) {}
 				}; // end Hrd
 				}; // end Hrd
 
 
+
 				/**
 				/**
-				 * Screen space ambient occlusion stage
+				 * Screen space ambient occlusion pass
 				 *
 				 *
 				 * Three passes:
 				 * Three passes:
 				 * - Calc ssao factor
 				 * - Calc ssao factor
 				 * - Blur vertically
 				 * - Blur vertically
 				 * - Blur horizontally
 				 * - Blur horizontally
 				 */
 				 */
-				class Saao: private RenderingStage
+				class Ssao: private RenderingStage
 				{
 				{
+					friend class Pps;
+
 					private:
 					private:
 						Fbo pass0Fbo, pass1Fbo, pass2Fbo;
 						Fbo pass0Fbo, pass1Fbo, pass2Fbo;
 						uint width, height, bwidth, bheight;
 						uint width, height, bwidth, bheight;
@@ -221,12 +228,13 @@ class Renderer
 						void run();
 						void run();
 
 
 					public:
 					public:
+						bool enabled;
 						float renderingQuality;
 						float renderingQuality;
 						float bluringQuality;
 						float bluringQuality;
 						Texture pass0Fai, pass1Fai, fai /** The final FAI */;
 						Texture pass0Fai, pass1Fai, fai /** The final FAI */;
 						ShaderProg ssaoSProg, blurSProg, blurSProg2;
 						ShaderProg ssaoSProg, blurSProg, blurSProg2;
 
 
-						Saao( Renderer& r_ ): RenderingStage(r_) {}
+						Ssao( Renderer& r_ ): RenderingStage(r_) {}
 				}; // end Ssao
 				}; // end Ssao
 
 
 				private:
 				private:
@@ -246,9 +254,22 @@ class Renderer
 
 
 				public:
 				public:
 					Texture fai;
 					Texture fai;
+					Hdr hdr;
+					Ssao ssao;
 
 
+					Pps( Renderer& r_ ): RenderingStage(r_), hdr(r_), ssao(r_) {}
 		}; // end Pps
 		}; // end Pps
 
 
+		/**
+		 * Debugging stage
+		 */
+		class Dbg: public RenderingStage
+		{
+			private:
+			public:
+				bool enabled;
+		};
+
 		// the stages as data members
 		// the stages as data members
 		Ms ms; ///< Material rendering stage
 		Ms ms; ///< Material rendering stage
 		Is is; ///< Illumination rendering stage
 		Is is; ///< Illumination rendering stage

+ 3 - 3
src/Renderer2/Ssao.cpp

@@ -5,7 +5,7 @@
 //=====================================================================================================================================
 //=====================================================================================================================================
 // initBlurFbos                                                                                                                       =
 // initBlurFbos                                                                                                                       =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void Renderer::Pps::Saao::initBlurFbo( Fbo& fbo, Texture& fai )
+void Renderer::Pps::Ssao::initBlurFbo( Fbo& fbo, Texture& fai )
 {
 {
 	// create FBO
 	// create FBO
 	fbo.create();
 	fbo.create();
@@ -34,7 +34,7 @@ void Renderer::Pps::Saao::initBlurFbo( Fbo& fbo, Texture& fai )
 //=====================================================================================================================================
 //=====================================================================================================================================
 // init                                                                                                                               =
 // init                                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void Renderer::Pps::Saao::init()
+void Renderer::Pps::Ssao::init()
 {
 {
 	width = renderingQuality * r.width;
 	width = renderingQuality * r.width;
 	height = renderingQuality * r.height;
 	height = renderingQuality * r.height;
@@ -111,7 +111,7 @@ void Renderer::Pps::Saao::init()
 //=====================================================================================================================================
 //=====================================================================================================================================
 // run                                                                                                                                =
 // run                                                                                                                                =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void Renderer::Pps::Saao::run()
+void Renderer::Pps::Ssao::run()
 {
 {
 	const Camera& cam = *r.cam;
 	const Camera& cam = *r.cam;