Sparks Effect

This topic is 1706 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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:

">

Share on other sites

Are you using point-sprite billboards? lol

Share on other sites

Well are you? Don't downvote me. I'm trying to help. Common...

Edited by Reflexus

Share on other sites

Hi,

It's the first time to see your comment now, I'm not using point sprites, I'm using billboards.

Share on other sites

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 on other sites

Do I have to use camera facing wide lines to create any realistic sparks effect?

Any example?

Share on other sites

You got something here Volumetric lines.

Share on other sites

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

Share on other sites

@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 on other sites

Who says it can't be used in particle systems?

Share on other sites

The example is showing how to do it using effect file, how do I accomplish that without using effect file? I want a pure C++/D3D9 way.

Share on other sites

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 on other sites

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 on other sites

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 on other sites

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 on other sites

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 on other sites

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();

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 on other sites

Up, need some assistance.

Share on other sites

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 on other sites

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 on other sites

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.

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

point sprites = billboards which are oriented about a point.

linear billboards = billboards which are oriented about a line.

Edited by Reflexus

Share on other sites

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 on other sites

Show me the actual code involving ->SetMatrix()

Share on other sites

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 on other sites

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