Sign in to follow this  
Medo Mex

Sparks Effect

Recommended Posts

Medo Mex    891

How do I create realistic sparks effect?

 

I used different textures but I couldn't get it to look like realistic sparks.

 

Can someone show me a simple texture for sparks? I'm not sure how the texture should look like (1 spark texture, few sparks texture, etc...)

 

I'm trying to accomplish something like this:

http://www.youtube.com/watch?v=237z9rh4wgs

Share this post


Link to post
Share on other sites
kauna    2922

If you look closely the sparks you can see that they aren't just camera facing quads (billboards), so you can't make the effect with just a texture. You'll need to use something like camera facing wide lines in order to give the sense of trail. 

 

Cheers!

Share this post


Link to post
Share on other sites
JTippetts    12950

@belfegor: What I know is that Volumetric lines can be used for laser beam, what that has to do with the particles engine?

 

 They're also useful for elongating particles to simulate motion blur of particles moving faster than the frame-rate can depict.

 

Edit: The posted video was rendered in Blender which can simulate motion blur during the render process. For a real-time application such as a game, however, such motion blur tricks as Blender uses might not be feasible. In that case, you can use elongation of the particles to fake it.

Edited by JTippetts

Share this post


Link to post
Share on other sites
belfegor    2834

I really don't know if it is possible with FFP, but my guess is that it would be very difficult and limiting on what you could achieve against shader approach which is by far better, flexible and standard for many years from now.

Why are you avoiding to learn shaders? There is no reason not to use them and they are not that difficult once you grasp basic concept.

Share this post


Link to post
Share on other sites
Medo Mex    891

The thing that frustrated me is that I can't use FFP light and that I'll be forced to create light using Shader.

 

Can you show me a simple texture that could be used for sparks? I'm not sure how the texture should look like.

Edited by Medo3337

Share this post


Link to post
Share on other sites
kauna    2922

You may create the required geometry on the CPU and feed it to a vertex buffer. That way you don't have to use a shader. 

 

"The simple texture" method (if there is one) won't give you the effect you are looking for. 

 

Cheers!

Share this post


Link to post
Share on other sites
Hodgman    51234

The thing that frustrated me is that I can't use FFP light and that I'll be forced to create light using Shader.

Sparks are emissive (they are lights) so they don't need to be lit.

Can you show me a simple texture that could be used for sparks? I'm not sure how the texture should look like.

I would render them as lines, as mentioned above, and colour them with a gradient from the front to the back of the line.

You could either do this with a 1D texture, or by simply using vertex colours:

[attachment=15721:spark.png]

What I know is that Volumetric lines can be used for laser beam, what that has to do with the particles engine?

There's many ways to draw particles.

Instead of drawing a quad where the particle currently is right now, you can draw a line between where it is now, where it was a moment ago, and where it was a moment before that. This gives you a curved line. If you colour that line with a gradient like above, and render it with additive blending, then you get the impression of a very fast moving bright object.

Share this post


Link to post
Share on other sites
ankhd    2304

Hello there. one of the older directx 9 sdks has what you want. its the pointSprite demo looks like thats would be a good start for you

they look nice. early 2007 DirectX SDK.

Share this post


Link to post
Share on other sites
Medo Mex    891

When I use the following code to create volumateric lines, I see the lines are stuck on the camera all the time.

 

How do I position the lines at certain position in the 3D space?

FLOAT g_fSpinX = 0.f;
FLOAT g_fSpinY = 0.f;
FLOAT g_fTX = 0.f;
FLOAT g_fTY = 0.f;
FLOAT g_fTZ = 14.f;

D3DXMATRIX mWorld;
D3DXMATRIX mWorldProjection;
D3DXMATRIX mTranslation;
D3DXMATRIX mRotation;

D3DXMATRIX g_mProjection = camera->GetProjectionMatrix();

D3DXMatrixRotationYawPitchRoll( &mRotation, D3DXToRadian( g_fSpinX ),
D3DXToRadian( g_fSpinY ), 0.f );
D3DXMatrixTranslation( &mTranslation, g_fTX, g_fTY, g_fTZ );//0.f, 0.f, 14.f );
mWorld = mRotation * mTranslation;

mWorldProjection = mWorld * g_mProjection;

// We will not be using a viewing transformation, so the view matrix will be identity.
effect->SetMatrix( "mWV", &mWorld );
effect->SetMatrix( "mWVP", &mWorldProjection );

UINT passes = 0;
if( SUCCEEDED( effect->Begin( &passes, 0 ) ) )
{
effect->BeginPass( 0 );
device->SetFVF( TVertex::FVF );
for( UINT i=0; i < ARRAY_SIZE( g_aLines ) / 2; i++ )
RenderLine( g_aLines[i*2], g_aLines[i*2 + 1] );
effect->EndPass();
effect->End();
}

Share this post


Link to post
Share on other sites
belfegor    2834

Did you see something here?

// We will not be using a viewing transformation, so the view matrix will be identity.
effect->SetMatrix( "mWV", &mWorld );
effect->SetMatrix( "mWVP", &mWorldProjection );

Share this post


Link to post
Share on other sites
Medo Mex    891

Yes, I tried to change it.

 

I tried setting mWorldProjection to the camera projection and mWorld to the transformation of the volumetric lines.

 

When I do that I don't see the lines anymore.

Edited by Medo3337

Share this post


Link to post
Share on other sites
Ben Bowen    115

I tried setting mWorldProjection to the camera projection and mWorld to the transformation of the volumetric lines.

 

worldProjection = world * projection. Got that right?

 

To be crabby... Those aren't even volumetric lines. They're just fancy linear billboards with UV selection based on orientation... in an outrageously terrible implementation at that! You probably could write up proper volumetric lines if you're competent, which I recommend. When you integrate over the path through an OBB, I don't think you'll want to base it on sqrt() distance, which would be pretty (INSANELY) naive considering performance, but won't provide a fully realistic distribution anyway. I'll reply again if I can think of a good way to do this. Others can throw in their suggestions too if they want. biggrin.png

 

EDIT:
This might be helpful. I'm reading it myself and I'll try to put it into useful terms (appropriate for your needs). smile.png

 

http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=5FFDAF33F6C101694D4F9987AFA25C3D?doi=10.1.1.96.5955&rep=rep1&type=pdf

 

 

One last additional remark

 

point sprites = billboards which are oriented about a point.

linear billboards = billboards which are oriented about a line.

Edited by Reflexus

Share this post


Link to post
Share on other sites
Medo Mex    891

worldProjection = world * projection. Got that right?

 

When I do that, the lines are stuck on the camera all the time, they appear like sprites.

 

I believe this can accomplish what I need which is (sparks particles).

 

So, my only problem right now is setting the transformation, I have the problem that I mentioned earlier.

 

worldProjection = world * projection                  // --> Stuck on the camera all the time
worldProjection = camera->GetProjectionMatrix();      // --> I don't see the lines anymore

Share this post


Link to post
Share on other sites
Medo Mex    891

I tried doing the following:

D3DXMATRIX mWorld;
D3DXMatrixIdentity(&mWorld);

mWorldProjection = camera->getProjectionMatrix();

effect->SetMatrix( "mWV", &mWorld );
effect->SetMatrix( "mWVP", &mWorldProjection );

When I do that I don't see the lines.

Share this post


Link to post
Share on other sites
Ben Bowen    115

When I do that I don't see the lines.

Where are their positions defined anyway? If you're just using identity then you should make sure they're in that small limited frustum which is tanget to the XY plane (i.e. screen space), and make sure your Z-clipping fits. lol, otherwise, actually use the right matrices. I'll try to explain below. This is the code you showed me:

 

D3DXMATRIX mWorld;
D3DXMatrixIdentity(&mWorld);

mWorldProjection = camera->getProjectionMatrix();

effect->SetMatrix( "mWV", &mWorld );
effect->SetMatrix( "mWVP", &mWorldProjection );

 

mWorld should be world * view, and mWorldProjection should be mWorld * your projection. What is the name of your matrix for viewspace? You don't seem to have any clue of what your own matrices are or what they do anyway. I think you need to go back and properly understand how transformation matrices are used to render 3D scenes.

 

Do you understand what a world matrix really is, and what a view matrix is?


WVP = world * view * projection. In simpleton terms, world refers to how individual content is transformed. View is how the virtual camera is positioned/oriented. Projection is how things are projected onto the screen plane. D3d9 abstracts these, but eventually it really just concatenates them into a single matrix and multiplies geometry by this to get it into its final position in camera space (pretty much screen space; the difference is somewhat trivial). So here, it asks for two matrices, WV and WVP. WV is world * view, and WVP is just WV * projection. Got it?

 

By the way, I may have thought of a good and fast way to do real volumetric lines, but I'll need to try it for myself before I start spewing nonsense.

Edited by Reflexus

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