• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
ankhd

Home Made GPU Blast Wake Need Some Advice

0 posts in this topic

Hey ya all.

I'm trying to model a blast wake using my gpu particle shader that takes points and creates quads.

I have it functioning, but I had to hard code timming values and opacity and the bit to expand the size.

 

I cant use my time delta its too small I set it to 1.5. Some Problem here

 

I tryed this for the alpha but its always 0.0
1.0f - smoothstep(0.0f, 1.0f, 1.0f/gGameTime); gGameTime is the whole time the game has been running  big value
1.0f - smoothstep(0.0f, 1.0f, t1/1.0f);//t1 is the particles age and the age is updated with the time delta = 1.5 every time its rendered.

 

Don't Know How to fix it, Any Ideas.

 

oh and there is a problem when I rase the camera up high the wake goes into the terrain, it may be z fighting but I have it rased of the terrain by 100 units or it could be from with in my shader where I try to aline it to the world and not the screen.

here is the bit where I do the dody scaling and  alpha reduction

Its done in the spawning new particle GS its the only place I can save the value in the vetex for this particel(Wake).
//we need to update our size here fSpeed is set to 1.5 (gParticleWidth and gParticleHeight) are set to 10.0
gIn[0].sizeW += float2(gParticleWidth, gParticleHeight) * fSpeed * gIn[0].age;	

// Specify conditions to keep particle; this may vary from system to system.
//this is done on the alpha for this system		
gIn[0].initialVelW.x -= ggrowamount;//grow amount is out value increaser set to 0.06
if( gIn[0].initialVelW.x > 0.0)//using the initialvelw.x for alpha and when it gets to 0 or less we stop
        ptStream.Append(gIn[0]);

//this bit is to align it to the up direction May be wrong????????

//this will align it to the up +y direction OR OUR PASSED IN DIRECTION
float3 look  = normalize(gEmitDirW);
float3 right = normalize(cross(float3(1,0,0), look));//maybe here 1 for x and 1 for z work 1 for y does not render 
float3 up    = cross(look, right);     
		
	
float4x4 W;
W[0] = float4(right,       0.0f);
W[1] = float4(up,          0.0f);
W[2] = float4(look,        0.0f);
W[3] = float4(gIn[0].posW, 1.0f);

The Shader

heres the parts of the shaders needs looking at.

Spawns and updates particles
// The stream-out GS is just responsible for emitting 
// new particles and destroying old particles.  The logic
// programed here will generally vary from particle system
// to particle system, as the destroy/spawn rules will be 
// different.
[maxvertexcount(2)]
void StreamOutGS(point Particle gIn[1], 
                 inout PointStream<Particle> ptStream)
{	
	gIn[0].age += gTimeStep;//0.005;//
	
	
			
	if( gIn[0].type == PT_EMITTER )
	{	
		
		// time to emit a new particle?
		if( gIn[0].age > 0.1)//gSpawnNewParticalTime )
		{
			float3 vRandom = RandUnitVec3(4.0f);
			
			//vRandom *=  gParticleSpreadAmount;
			float3 offsettarget = gEmitDirW.xyz;// + vRandom;
			Particle p;
			p.initialPosW   = gEmitPosW.xyz;// + vRandom;
			
	

			
			p.pDirW		  =	gEmitDirW.xyz;//normalize(offsettarget - p.initialPosW) ;//
			p.sizeW       = float2(0.5, 0.5);//very small to start
			p.age         = 0.1f;//vRandom.x;
			p.type        = PT_FLARE;
			p.arrayid     = 0;//vRandom.x % 2;//our array has 2 elements for testing
			p.initialVelW.x =  1.0;//using this to fade our and stop the particle when it gets to 0 or less
			p.initialVelW.y =  1.0;
			p.initialVelW.z =  1.0;

				
			//add new particle
			ptStream.Append(p);
			// reset the time to emit
			gIn[0].age = 0.0f;
		}
	
		//dont keep the emitter all the time 
		//ptStream.Append(gIn[0]);
		
				
				
		
	}
	else
	{
		//we need to update our size here
		gIn[0].sizeW += float2(gParticleWidth, gParticleHeight) * fSpeed * gIn[0].age;	

		// Specify conditions to keep particle; this may vary from system to system.
		gIn[0].initialVelW.x -= ggrowamount;//grow amount is out value increaser
		if( gIn[0].initialVelW.x > 0.0)//using the initialvelw.x for alpha and when it gets to 0 or less we stop
			ptStream.Append(gIn[0]);
		
	
	}		
}//end
///////////////////////////////////////////////////////////////////////////////////////////////////



//draws the quad
// The draw GS just expands points into camera facing quads.
[maxvertexcount(4)]
void DrawGS(point VS_OUT gIn[1], 
            inout TriangleStream<GS_OUT> triStream)
{	
	// do not draw emitter particles.
	if( gIn[0].type != PT_EMITTER )
	{
		//not using this her to compare so I dont forget later
		// Compute world matrix so that billboard faces the camera.
		//
		//float3 look  = normalize(gEyePosW.xyz - gIn[0].posW);
		//float3 right = normalize(cross(float3(0,1,0), look));
		//float3 up    = cross(look, right);
		
		//rotate the particle on the z 
	
		float r = gIn[0].angle;
		float4x4 rotateZ = { cos(r), -sin(r), 0.0, 0.0,                
							 sin(r), cos(r), 0.0, 0.0, 
							 0.0, 0.0, 1.0, 0.0,                
							 0.0, 0.0, 0.0, 1.0   };
	
							 



//this will align it to the up +y direction OR OUR PASSED IN DIRECTION
		float3 look  = normalize(gEmitDirW);// - gIn[0].posW);//gEmitPosW);//
		float3 right = normalize(cross(float3(1,0,0), look));
		float3 up    = cross(look, right);     
		
	
		float4x4 W;
		W[0] = float4(right,       0.0f);
		W[1] = float4(up,          0.0f);
		W[2] = float4(look,        0.0f);
		W[3] = float4(gIn[0].posW, 1.0f);//rotatedpos, 1.0f);//

//rotate about the z so the image move around while still faceing its direction we set
W = mul(rotateZ ,W );


		float4x4 WVP = mul(W, gViewProj);
		
		//
		// Compute 4 triangle strip vertices (quad) in local space.
		// The quad faces down the +z axis in local space.
		//
		float halfWidth  = (gIn[0].sizeW.x);
		float halfHeight = (gIn[0].sizeW.y);
	
		float4 v[4];
		v[0] = float4(-halfWidth, -halfHeight, 0.0f, 1.0f);
		v[1] = float4(+halfWidth, -halfHeight, 0.0f, 1.0f);
		v[2] = float4(-halfWidth, +halfHeight, 0.0f, 1.0f);
		v[3] = float4(+halfWidth, +halfHeight, 0.0f, 1.0f);
		
		//
		// Transform quad vertices to world space and output 
		// them as a triangle strip.
		//
		GS_OUT gOut;
		[unroll]
		for(int i = 0; i < 4; ++i)
		{
			gOut.posH		 = mul(v[i], WVP);
			gOut.texC		= gQuadTexC[i];
			gOut.color		= gIn[0].color;
			gOut.arrayid	= gIn[0].arrayid;

			triStream.Append(gOut);
		}	
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0