Browse Source

Bug fixing the new renderer

Panagiotis Christopoulos Charitos 15 years ago
parent
commit
6d02977294

File diff suppressed because it is too large
+ 442 - 351
build/debug/Makefile


+ 4 - 4
shaders/simple_vert.glsl

@@ -12,10 +12,10 @@ varying vec2 texCoords;
 
 void main()
 {
-	vec2 vert_pos = position; // the vert coords are {1.0,1.0}, {0.0,1.0}, {0.0,0.0}, {1.0,0.0}
-	texCoords = vert_pos;
-	vec2 vert_pos_ndc = vert_pos*2.0 - 1.0;
-	gl_Position = vec4( vert_pos_ndc, 0.0, 1.0 );
+	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 );
 }
 
 

+ 2 - 2
src/Main.cpp

@@ -231,11 +231,11 @@ void init()
 	point_lights[0] = new PointLight();
 	point_lights[0]->init( "maps/temple/light0.light" );
 	point_lights[0]->setLocalTransform( Transform( Vec3( -1.0, 2.4, 1.0 ), Mat3::getIdentity(), 1.0 ) );
-	/*point_lights[1] = new PointLight();
+	point_lights[1] = new PointLight();
 	point_lights[1]->init( "maps/temple/light1.light" );
 	point_lights[1]->setLocalTransform( Transform( Vec3( 2.5, 1.4, 1.0 ), Mat3::getIdentity(), 1.0 ) );
 
-	spot_lights[0] = new SpotLight();
+	/*spot_lights[0] = new SpotLight();
 	spot_lights[0]->init( "maps/temple/light2.light" );
 	spot_lights[0]->setLocalTransform( Transform( Vec3( 1.3, 4.3, 3.0 ), Mat3( Euler(toRad(-20), toRad(20), 0.0) ), 1.0 ) );
 	spot_lights[1] = new SpotLight();

+ 2 - 3
src/Renderer/Hdr.cpp

@@ -17,9 +17,9 @@ void Renderer::Pps::Hdr::initFbos( Fbo& fbo, Texture& fai, int internalFormat )
 	fbo.setNumOfColorAttachements(1);
 
 	// create the texes
-	fai.createEmpty2D( width, height, internalFormat, GL_RGB );
+	fai.createEmpty2D( width, height, internalFormat, GL_RGB, GL_FLOAT, false );
 	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	//fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	//fai_.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
 	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 
 	// attach
@@ -55,7 +55,6 @@ void Renderer::Pps::Hdr::init()
 	pps = "#define _PPS_HDR_PASS_0_\n#define IS_FAI_WIDTH " + Util::floatToStr(r.width) + "\n";
 	if( !pass0SProg.customLoad( shaderFname, pps.c_str() ) )
 		FATAL( "See prev error" );
-
 	pass0SProg.uniVars.fai = pass0SProg.findUniVar("fai");
 
 	pps = "#define _PPS_HDR_PASS_1_\n#define PASS0_HEIGHT " + Util::floatToStr(height) + "\n";

+ 1 - 1
src/Renderer/Is.cpp

@@ -114,7 +114,7 @@ void Renderer::Is::initFbo()
 	fbo.setNumOfColorAttachements( 1 );
 
 	// create the txtrs
-	if( !fai.createEmpty2D( r.width, r.height, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE ) )
+	if( !fai.createEmpty2D( r.width, r.height, GL_RGB, GL_RGB, GL_FLOAT, false ) )
 		FATAL( "Cannot create deferred shading illumination stage FAI" );
 
 	// attach

+ 3 - 2
src/Renderer/MainRenderer.cpp

@@ -44,7 +44,7 @@ void MainRenderer::init( const RendererInitializer& initializer_ )
 	//
 	// Set GL
 	//
-	glClearColor( 0.1, 0.1, 0.1, 0.0 );
+	glClearColor( 0.1, 0.1, 0.1, 1.0 );
 	glClearDepth( 1.0 );
 	glClearStencil( 0 );
 	glDepthFunc( GL_LEQUAL );
@@ -86,11 +86,12 @@ void MainRenderer::render( Camera& cam_ )
 	//
 	// Render the PPS FAI to the framebuffer
 	//
+	Fbo::unbind();
 	setViewport( 0, 0, app->getWindowWidth(), app->getWindowHeight() );
 	glDisable( GL_DEPTH_TEST );
 	glDisable( GL_BLEND );
 	sProg.bind();
-	sProg.findUniVar("rasterImage")->setTexture( pps.hdr.pass0Fai, 0 );
+	sProg.findUniVar("rasterImage")->setTexture( pps.fai, 0 );
 	drawQuad( 0 );
 }
 

+ 4 - 4
src/Renderer/Ms.cpp

@@ -19,11 +19,11 @@ void Renderer::Ms::init()
 
 	// create the FAIs
 	const int internal_format = GL_RGBA16F_ARB;
-	if( !normalFai.createEmpty2D( r.width, r.height, internal_format, GL_RGBA ) ||
-	    !diffuseFai.createEmpty2D( r.width, r.height, internal_format, GL_RGBA ) ||
-	    !specularFai.createEmpty2D( r.width, r.height, internal_format, GL_RGBA ) ||
+	if( !normalFai.createEmpty2D( r.width, r.height, internal_format, GL_RGBA, GL_FLOAT, false ) ||
+	    !diffuseFai.createEmpty2D( r.width, r.height, internal_format, GL_RGBA, GL_FLOAT, false ) ||
+	    !specularFai.createEmpty2D( r.width, r.height, internal_format, GL_RGBA, GL_FLOAT, false ) ||
 	    //!depthFai.createEmpty2D( r.width, r.height, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 ) )
-	    !depthFai.createEmpty2D( r.width, r.height, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT ) )
+	    !depthFai.createEmpty2D( r.width, r.height, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, false ) )
 	{
 		FATAL( "Failed to create one MS FAI. See prev error" );
 	}

+ 1 - 1
src/Renderer/Pps.cpp

@@ -14,7 +14,7 @@ void Renderer::Pps::init()
 	fbo.setNumOfColorAttachements( 1 );
 
 	// create the texes
-	fai.createEmpty2D( r.width, r.height, GL_RGB, GL_RGB );
+	fai.createEmpty2D( r.width, r.height, GL_RGB, GL_RGB, GL_FLOAT, false );
 
 	// attach
 	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );

+ 1 - 1
src/Renderer/Sm.cpp

@@ -14,7 +14,7 @@ void Renderer::Is::Sm::init()
 	fbo.bind();
 
 	// texture
-	shadowMap.createEmpty2D( resolution, resolution, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT );
+	shadowMap.createEmpty2D( resolution, resolution, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, true );
 	shadowMap.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 	if( bilinearEnabled )
 	{

+ 2 - 2
src/Renderer/Ssao.cpp

@@ -15,7 +15,7 @@ void Renderer::Pps::Ssao::initBlurFbo( Fbo& fbo, Texture& fai )
 	fbo.setNumOfColorAttachements( 1 );
 
 	// create the texes
-	fai.createEmpty2D( bwidth, bheight, GL_ALPHA8, GL_ALPHA );
+	fai.createEmpty2D( bwidth, bheight, GL_ALPHA8, GL_ALPHA, GL_FLOAT, false );
 	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
 	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 
@@ -54,7 +54,7 @@ void Renderer::Pps::Ssao::init()
 	pass0Fbo.setNumOfColorAttachements(1);
 
 	// create the FAI
-	pass0Fai.createEmpty2D( width, height, GL_ALPHA8, GL_ALPHA );
+	pass0Fai.createEmpty2D( width, height, GL_ALPHA8, GL_ALPHA, GL_FLOAT, false );
 	pass0Fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
 	pass0Fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 

+ 5 - 4
src/Resources/Texture.cpp

@@ -84,9 +84,10 @@ bool Texture::load( const char* filename )
 //======================================================================================================================
 // createEmpty2D                                                                                                       =
 //======================================================================================================================
-bool Texture::createEmpty2D( float width_, float height_, int internalFormat, int format_, GLenum type_ )
+bool Texture::createEmpty2D( float width_, float height_, int internalFormat, int format_, GLenum type_,
+                             bool mimapping )
 {
-	DEBUG_ERR( glGetError() != GL_NO_ERROR ); // dont enter the func holding an error
+	DEBUG_ERR( glGetError() != GL_NO_ERROR ); // dont enter the func with prev error
 
 	type = GL_TEXTURE_2D;
 	DEBUG_ERR( internalFormat>0 && internalFormat<=4 ); // deprecated internal format
@@ -96,7 +97,7 @@ bool Texture::createEmpty2D( float width_, float height_, int internalFormat, in
 	glGenTextures( 1, &glId );
 	bind();
 
-	if( mipmappingEnabled )
+	if( mimapping )
 		glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
 	else
 		glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
@@ -108,7 +109,7 @@ bool Texture::createEmpty2D( float width_, float height_, int internalFormat, in
 	// allocate to vram
 	glTexImage2D( type, 0, internalFormat, width_, height_, 0, format_, type_, NULL );
 
-	if( mipmappingEnabled )
+	if( mimapping )
 		glGenerateMipmap( type );
 
 	GLenum errid = glGetError();

+ 1 - 1
src/Resources/Texture.h

@@ -36,7 +36,7 @@ class Texture: public Resource
 
 		bool load( const char* filename );
 		void unload();
-		bool createEmpty2D( float width, float height, int internalFormat, int format, GLenum type_ = GL_FLOAT );
+		bool createEmpty2D( float width, float height, int internalFormat, int format, GLenum type_, bool mipmapping );
 		bool createEmpty2DMSAA( float width, float height, int samplesNum, int internalFormat );
 
 		void bind( uint unit=0 ) const;

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