Parcourir la source

Working on the ParticleEmitter

Panagiotis Christopoulos Charitos il y a 16 ans
Parent
commit
dad1b7bc79

Fichier diff supprimé car celui-ci est trop grand
+ 430 - 383
build/debug/Makefile


+ 52 - 17
shaders/PpsHdr.glsl

@@ -1,6 +1,6 @@
 /**
  * Pass 0 horizontal blur, pass 1 vertical, pass 2 median
- * The offset of the bluring depends on the luminance of the current fragment
+ * The offset of the blurring depends on the luminance of the current fragment
  */
 
 #pragma anki vertShaderBegins
@@ -26,10 +26,39 @@ void main()
 	return;*/
 
 	#if defined( _PPS_HDR_PASS_0_ ) || defined( _PPS_HDR_PASS_1_ )
-		/*vec3 color = texture2D( fai, texCoords ).rgb
-		float luminance = dot( vec3(0.30, 0.59, 0.11) * color ); 
-	
-		const float maxAdditionalOffset = 2.0;
+		vec3 color = texture2D( fai, texCoords ).rgb;
+		//float luminance = dot( vec3(0.30, 0.59, 0.11), color );
+
+		const float additionalOffset = 2.0;
+
+		#if defined( _PPS_HDR_PASS_0_ )
+			const float offset = 1.0 / IS_FAI_WIDTH * additionalOffset;
+		#else
+			const float offset = 1.0 / PASS0_HEIGHT * additionalOffset;
+		#endif
+
+		const int SAMPLES_NUM = 6;
+		const float kernel[] = float[]( -1.0 * offset, 1.0 * offset, -2.0 * offset, 2.0 * offset,
+				                            -3.0 * offset, 3.0 * offset, -4.0 * offset, 4.0 * offset,
+				                            -5.0 * offset, 5.0 * offset, -6.0 * offset, 6.0 * offset );
+
+		for( int i=0; i<SAMPLES_NUM; i++ )
+		{
+			#if defined( _PPS_HDR_PASS_0_ )
+				color += texture2D( fai, texCoords + vec2(kernel[i], 0.0) ).rgb;
+			#else // _PPS_HDR_PASS_1_
+				color += texture2D( fai, texCoords + vec2(0.0, kernel[i]) ).rgb;
+			#endif
+		}
+
+		const float denominator = 1.0 / (SAMPLES_NUM + 1); // Opt to make sure its const
+		gl_FragData[0].rgb = color * denominator;
+
+
+		/*vec3 color = texture2D( fai, texCoords ).rgb;
+		float luminance = dot( vec3(0.30, 0.59, 0.11), color );
+
+		const float maxAdditionalOffset = 1.0;
 		float additionalOffset = luminance * maxAdditionalOffset;
 
 		#if defined( _PPS_HDR_PASS_0_ )
@@ -38,11 +67,11 @@ void main()
 			float offset = 1.0 / PASS0_HEIGHT * additionalOffset;
 		#endif
 
-		const int KERNEL_SIZE = 8;
-		float kernel[KERNEL_SIZE] = float[]( -3.0 * offset, -2.0 * offset, -1.0 * offset, 1.0 * offset, 2.0 * offset,
+		const int SAMPLES_NUM = 8;
+		float kernel[SAMPLES_NUM] = float[]( -3.0 * offset, -2.0 * offset, -1.0 * offset, 1.0 * offset, 2.0 * offset,
 				                                  3.0 * offset, -4.0 * offset, 4.0 * offset );
 
-		for( int i=0; i<KERNEL_SIZE; i++ )
+		for( int i=0; i<SAMPLES_NUM; i++ )
 		{
 			#if defined( _PPS_HDR_PASS_0_ )
 				color += texture2D( fai, texCoords + vec2(kernel[i], 0.0) ).rgb;
@@ -51,32 +80,38 @@ void main()
 			#endif
 		}
 
-		const float denominator = 1.0 / (KERNEL_SIZE + 1); // Opt to make sure its const
+		const float denominator = 1.0 / (SAMPLES_NUM + 1); // Opt to make sure its const
 		gl_FragData[0].rgb = color * denominator;*/
-		
-		vec3 color = texture2D( fai, texCoords ).rgb
-		float luminance = dot( vec3(0.30, 0.59, 0.11) * color ); 
-	
+
+	/*	vec3 color = texture2D( fai, texCoords ).rgb;
+		float luminance = dot( vec3(0.30, 0.59, 0.11), color );
+
 		#if defined( _PPS_HDR_PASS_0_ )
 			const float OFFSET = 1.0 / IS_FAI_WIDTH;
 		#else
 			const float OFFSET = 1.0 / PASS0_HEIGHT;
 		#endif
 
-		const float MAX_SAMPLES_NUM = 12.0;
+		const float MAX_SAMPLES_NUM = 50.0;
 		float samplesNum = MAX_SAMPLES_NUM * luminance;
 		float samplesNumDiv2 = samplesNum/2.0;
 
+		int i = 0;
 		for( float s=-samplesNumDiv2; s<=samplesNumDiv2; s += 1.0 )
 		{
+			++ i;
 			#if defined( _PPS_HDR_PASS_0_ )
 				color += texture2D( fai, texCoords + vec2( s * OFFSET, 0.0 ) ).rgb;
 			#else // _PPS_HDR_PASS_1_
-				color += texture2D( fai, texCoords + vec2( 0.0, OFFSET * offset ) ).rgb;
+				color += texture2D( fai, texCoords + vec2( 0.0, s * OFFSET ) ).rgb;
 			#endif
 		}
-		
-		gl_FragData[0].rgb = color / ( floor(samplesNum) + 1.0 );
+
+		gl_FragData[0].rgb = color / ( i + 1.0 );*/
+
+
+		//gl_FragData[0].rgb = vec3( dot( vec3(0.30, 0.59, 0.11), gl_FragData[0].rgb ) );
+
 
 	#else // _PPS_HDR_PASS_2_
 		//vec3 color = MedianFilterRGB( fai, texCoords );

+ 4 - 2
src/Main.cpp

@@ -316,6 +316,8 @@ int main( int /*argc*/, char* /*argv*/[] )
 
 		mover->rotationLspace.reorthogonalize();
 
+		//static_cast<btRigidBody*>(dynamicsWorld->getCollisionObjectArray()[1])->getMotionState()->setWorldTransform( toBt(point_lights[0]->transformationWspace) );
+		//dynamicsWorld->getCollisionObjectArray()[3]->setWorldTransform( toBt(point_lights[0]->transformationWspace) );
 
 		app->scene->updateAllControllers();
 		app->scene->updateAllWorldStuff();
@@ -332,7 +334,7 @@ int main( int /*argc*/, char* /*argv*/[] )
 		Ui::setColor( Vec4(1.0, 1.0, 1.0, 1.0) );
 		Ui::setPos( -0.98, 0.95 );
 		Ui::setFontWidth( 0.03 );
-		Ui::printf( "frame:%d time:%dms\n", R::framesNum, App::getTicks()-ticks_ );
+		Ui::printf( "frame:%d fps:%dms\n", R::framesNum, (App::getTicks()-ticks_) );
 		//Ui::print( "Movement keys: arrows,w,a,s,d,q,e,shift,space\nSelect objects: keys 1 to 5\n" );
 		Ui::printf( "Mover: Pos(%.2f %.2f %.2f) Angs(%.2f %.2f %.2f)", mover->translationWspace.x, mover->translationWspace.y, mover->translationWspace.z,
 								 toDegrees(Euler(mover->rotationWspace).x), toDegrees(Euler(mover->rotationWspace).y), toDegrees(Euler(mover->rotationWspace).z) );
@@ -350,7 +352,7 @@ int main( int /*argc*/, char* /*argv*/[] )
 		R::printLastError();
 		if( 1 )
 		{
-			if( R::framesNum == 50 ) R::takeScreenshot("gfx/screenshot.tga");
+			//if( R::framesNum == 10 ) R::takeScreenshot("gfx/screenshot.tga");
 			app->waitForNextFrame();
 		}
 		else

+ 21 - 5
src/Renderer/Dbg.cpp

@@ -153,33 +153,49 @@ void runStage( const Camera& cam )
 	renderscene(1);
 
 
+	glDisable( GL_DEPTH_TEST );
+
 	glPushMatrix();
 	R::multMatrix( Mat4( Vec3(5.0, 2.0, 2.0), Mat3::getIdentity(), 1.0 ) );
-	R::Dbg::renderSphere( 1.0, 16 );
+	R::Dbg::renderSphere( 1.2, 16 );
 	glPopMatrix();
 
 
 	glMatrixMode( GL_PROJECTION );
 	glPushMatrix();
 	glLoadIdentity();
-	glOrtho( 0, 1, 0, 1, -1, 1 );
+	glOrtho( -1, 1, -1, 1, -1, 1 );
 	glMatrixMode( GL_MODELVIEW );
 	glPushMatrix();
 	glLoadIdentity();
 
 
-	Vec4 p = Vec4( Vec3(5.0, 2.0, 2.0), 1.0 );
+	Vec3 c = Vec3(5.0, 2.0, 2.0);
+	float r = 1.2;
+
+	Vec4 p = Vec4( c, 1.0 );
 	p = app->activeCam->getProjectionMatrix() * (app->activeCam->getViewMatrix() * p);
 	p /= p.w;
-	p = p/2 + 0.5;
+	//p = p/2 + 0.5;
 
 	glPointSize( 10 );
 	glBegin( GL_POINTS );
 		R::color3( Vec3(0.0,1.0,0.0) );
-		glVertex3fv( &p[0] );
+		glVertex2fv( &p[0] );
 	glEnd();
 
 
+	Vec4 g = Vec4( Vec3(c) + Vec3(r,0,0), 1.0 );
+	g = app->activeCam->getProjectionMatrix() * (app->activeCam->getViewMatrix() * g);
+	g /= g.w;
+	float len = Vec2(p-g).getLength();
+	//g = g/2 + 0.5;
+
+	glPointSize( 10 );
+	glBegin( GL_POINTS );
+		R::color3( Vec3(1.0,1.0,1.0) );
+		glVertex2fv( &(g)[0] );
+	glEnd();
 
 	glPopMatrix();
 	glMatrixMode( GL_PROJECTION );

+ 1 - 0
src/Renderer/PpsHdr.cpp

@@ -55,6 +55,7 @@ static void initFbos( Fbo& fbo, Texture& fai, int internalFormat )
 	// create the texes
 	fai.createEmpty2D( w, h, internalFormat, GL_RGB );
 	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	//fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
 	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 
 	// attach

+ 1 - 1
src/Renderer/PpsSsao.cpp

@@ -17,7 +17,7 @@ namespace Ssao {
 //=====================================================================================================================================
 // VARS                                                                                                                               =
 //=====================================================================================================================================
-bool enabled = true;
+bool enabled = false;
 
 static Fbo pass0Fbo, pass1Fbo, pass2Fbo;
 

+ 27 - 0
src/Scene/ParticleEmitter.cpp

@@ -0,0 +1,27 @@
+#include "ParticleEmitter.h"
+#include "Renderer.h"
+
+
+//=====================================================================================================================================
+//                                                                                                                                    =
+//=====================================================================================================================================
+void ParticleEmitter::Particle::render()
+{
+	glPushMatrix();
+	R::multMatrix( transformationWspace );
+
+	glBegin( GL_POINTS );
+		glVertex3fv( &(Vec3(0.0))[0] );
+	glEnd();
+
+	glPopMatrix();
+}
+
+
+//=====================================================================================================================================
+//                                                                                                                                    =
+//=====================================================================================================================================
+void ParticleEmitter::init( const char* filename )
+{
+
+}

+ 16 - 0
src/Scene/ParticleEmitter.h

@@ -3,6 +3,8 @@
 
 #include "Common.h"
 #include "Node.h"
+#include "MeshNode.h"
+
 
 /**
  *
@@ -15,9 +17,23 @@ class ParticleEmitter: public Node
 		{
 			public:
 				int life; ///< Life in ms
+
+				void render();
+				void renderDepth() {};
 		};
 
 		Vec<Particle*> particles;
+		int maxParticlesLife;
+		int minParticlesLife;
+		Euler maxAngle;
+		Euler minAngle;
+		int maxNumOfParticlesInScreen;
+
+		ParticleEmitter(): Node( NT_PARTICLE_EMITTER ) {}
+		void render() {}
+		void renderDepth() {}
+		void init( const char* filename );
+		void deinit() {}
 };
 
 #endif

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff