Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Sparks Effect


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
37 replies to this topic

#21 Rhetorician   Members   -  Reputation: 115

Like
0Likes
Like

Posted 15 May 2013 - 07:28 PM

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, 15 May 2013 - 07:38 PM.


Sponsor:

#22 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 15 May 2013 - 07:52 PM

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


#23 Rhetorician   Members   -  Reputation: 115

Like
0Likes
Like

Posted 15 May 2013 - 08:19 PM

Show me the actual code involving ->SetMatrix()



#24 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 16 May 2013 - 08:21 AM

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.



#25 Rhetorician   Members   -  Reputation: 115

Like
1Likes
Like

Posted 16 May 2013 - 11:29 AM

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, 16 May 2013 - 11:46 AM.


#26 Medo3337   Members   -  Reputation: 680

Like
1Likes
Like

Posted 16 May 2013 - 12:11 PM

Great!

 

The transformation issue is now resolved, now I'm trying to draw all the lines with only a single draw call, so I tried changing the following code:

 

 

// The following code draw line per draw call (I don't want that)
TVertex vrts[4];
vrts[0].pos = v0; vrts[0].otherPos = v1;
vrts[1].pos = v1; vrts[1].otherPos = v0;
vrts[2].pos = v0; vrts[2].otherPos = v1;
vrts[3].pos = v1; vrts[3].otherPos = v0;

vrts[0].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[1].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[2].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[3].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );

vrts[0].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.f );
vrts[1].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.f );
vrts[2].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.25f );
vrts[3].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.25f );

d3ddev->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, vrts, sizeof( TVertex ) );

 

 

To:

// In this code, I'm trying to draw multiple lines with one single draw call
TVertex vrts[8]; // 8 instead of 4 (8 = 2 lines)

// Line 1
D3DXVECTOR3 v0(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 v1(0.0f, 100.0f, 0.0f);

vrts[0].pos = v0; vrts[0].otherPos = v1;
vrts[1].pos = v1; vrts[1].otherPos = v0;
vrts[2].pos = v0; vrts[2].otherPos = v1;
vrts[3].pos = v1; vrts[3].otherPos = v0;
vrts[0].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[1].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[2].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[3].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[0].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.f );
vrts[1].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.f );
vrts[2].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.25f );
vrts[3].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.25f );

// Line 2
D3DXVECTOR3 pV0(200.0f, 0.0f, 0.0f);
D3DXVECTOR3 pV1(200.0f, 100.0f, 0.0f);

vrts[4].pos = pV0; vrts[4].otherPos = pV1;
vrts[5].pos = pV1; vrts[5].otherPos = pV0;
vrts[6].pos = pV0; vrts[6].otherPos = pV1;
vrts[7].pos = pV1; vrts[7].otherPos = pV0;
vrts[4].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[5].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[6].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[7].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[4].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.f );
vrts[5].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.f );
vrts[6].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.25f );
vrts[7].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.25f );

// Draw all lines
d3ddev->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 4, vrts, sizeof( TVertex ) );

 

Now, the two lines are connected with each others, which of course undesired since I want to draw multiple separate lines with one draw call.

 

Do I have to set index buffer to draw multiple lines with one draw call? If yes, how do I fill the index buffer?



#27 Rhetorician   Members   -  Reputation: 115

Like
0Likes
Like

Posted 16 May 2013 - 02:22 PM

No it's a triangle strip, so even with an index layer you can't specify breaks between the lines. Try to use a triangle list instead. For this I guess you can use http://msdn.microsoft.com/en-us/library/windows/desktop/bb174370%28v=vs.85%29.aspx



#28 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 16 May 2013 - 08:18 PM

 
I tried the following code, but it's not working as expected:
// Create index buffer
DWORD* index = new DWORD[indicesCount];
DWORD j = 0;
indexBuffer->Lock(0, sizeof(index), (void**)&index, 0);
for(USHORT i = 0; i < indicesCount; i += 6)
{
    index[0+i] = 0+j;
    index[1+i] = 2+j;
    index[2+i] = 1+j;
    index[3+i] = 0+j;
    index[4+i] = 3+j;
    index[5+i] = 2+j;
    j += 4;
}
indexBuffer->Unlock();

 

// Draw
device->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, 0, 4, 2, indexBuffer, D3DFMT_INDEX32, vrts, sizeof( TVertex ) );

 

What's wrong?


Edited by Medo3337, 16 May 2013 - 08:28 PM.


#29 Rhetorician   Members   -  Reputation: 115

Like
1Likes
Like

Posted 17 May 2013 - 04:24 PM

it's not working as expected:

 

I'll assume you don't know how to describe the problem. No, errors, it just looks funny, right?


1. The first issue I see is, to account for every line-segment you batch, make sure you do something like this (notice *lineNum):

device->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, 0, 4*lineNum, 2*lineNum, indexBuffer, D3DFMT_INDEX32, vrts, sizeof( TVertex ) );

 

Or you can increment a variable to use for the arguments, just as you probably do with 'vrts'.

 

2. Why are you making an allocation for the buffer? The following code you have written is unnecessary and bad: DWORD* index = new DWORD[indicesCount];

 

The Lock() function will modify your pointer to point somewhere used in the write-combining process. Not only is this memory allocation unnecessary, but you're creating a memory leak.

3. How do you determine "indicesCount" ?
4. My suggestions:

Construct your index layer in explicit terms of line segments. e.g.

 

uint i = 0;
uint vI = 0;
for (uint lineI = 0; lineI != lineQ; ++lineI)
{
	index[i++] = vI;
	index[i++] = vI + 2;
	index[i++] = vI + 1;
	index[i++] = vI + 1;
	index[i++] = vI + 2;
	index[i++] = vI + 3;
	vI += 4;
}

 

indicesCount can be determined just like this: lineQ * 6;

Notation info: I have a personal habit of appending a capital letter i to denote an index and Q to denote a quantity.

Hopefully these tips get you somewhere. biggrin.png


Edited by Reflexus, 17 May 2013 - 04:27 PM.


#30 Norman Barrows   Crossbones+   -  Reputation: 2332

Like
0Likes
Like

Posted 17 May 2013 - 08:53 PM

if you can't get what you're working on going, check out the point sprite demo mentioned in one of the previous posts. its in the directx 8 sdk (and perhaps later ones). it REALLY looks nice! JUST what you want. <g>

 

not sure how they do it. they may be lines, or thin tri's with gradient texture and lots of emissive on the material. never looked at the code. but the demo is killer.

 

and if dx8 will do, dx9 will do it for sure.


Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

 

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

 

 


#31 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 19 May 2013 - 08:43 AM

@Reflexus: Are you sure this is a valid indices list for the volumetric lines?

 

It's not working.



#32 Rhetorician   Members   -  Reputation: 115

Like
0Likes
Like

Posted 23 May 2013 - 04:51 PM

It's not working.

 

How so? Please explain the problem, as I asked before. I just left you with tips and example code to get you pointed in the right direction -- but it was a guess nevertheless -- because you have not explained the debugging results.


Edited by Reflexus, 23 May 2013 - 04:53 PM.


#33 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 23 May 2013 - 05:09 PM

The lines are deformed, it seems that the index buffer is not valid.



#34 Rhetorician   Members   -  Reputation: 115

Like
0Likes
Like

Posted 23 May 2013 - 05:51 PM

So it doesn't have any crashing issues? (edit: Hey, I'm just expecting the worse laugh.png)


Edited by Reflexus, 23 May 2013 - 05:53 PM.


#35 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 23 May 2013 - 06:10 PM

No, nothing more than just deformed lines, you might want to look at the effect file to see how the indices should be like.



#36 Rhetorician   Members   -  Reputation: 115

Like
0Likes
Like

Posted 23 May 2013 - 08:51 PM

you might want to look at the effect file to see how the indices should be like.


Really... If you're not sure how to get them right yourself, just try different combinations. Really. There aren't too many to try. You could have fixed it by now.

Edit: Oh, sorry. I sound sour. I am not able to help you further. My time!


Edited by Reflexus, 23 May 2013 - 08:52 PM.


#37 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 24 May 2013 - 06:27 AM

Yes, I have been trying to use different indices but couldn't get it to work.

 

Anyway, consider the question closed, I'll look for a way to resolve the issue.



#38 Medo3337   Members   -  Reputation: 680

Like
1Likes
Like

Posted 24 May 2013 - 09:16 AM

To anyone who could have this problem, the question was resolved here:

http://www.gamedev.net/topic/643414-drawing-multiple-lines-with-one-draw-call/






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS