Sign in to follow this  
Moe

Particles + dot3 lighting + alpha blending...

Recommended Posts

Hey, A few days ago I had the crazy idea to make particle effects look even better - especially for smoke. I was thinking that you could use a normal/bump map on the particle texture to give each particle a bit more depth (using per pixel lighting). Does anyone have any idea what this would look like? Has this been done before? I think it could be quite interesting to see. I would throw together a demo if I wasn't so involved in school.

Share this post


Link to post
Share on other sites
I answer this from having used Direct3D's point-sprites for particle rendering, but isn't a typical particle rendered in screen-space as a billboard/imposter?

Provided that assertion is correct, your idea for per-pixel lighting falls apart a bit? I'm sure you could work around it - but the basic geometry is in screen space rather than work space, thus making converting the lighting vectors and so on a bit trickier?

[EDIT]
Actually, I suppose if you could pass your geometry through a shader you could work out the correct tangents/binormals and other funky stuff needed, and you obviously have the direction/distance from the light source..
[/EDIT]

Cheers,
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
I answer this from having used Direct3D's point-sprites for particle rendering, but isn't a typical particle rendered in screen-space as a billboard/imposter?

I am not 100% sure what you mean by this, but the particle system wouldn't necessarily have to be based on Pointsprites. Also, the particles would be treated just like any other 3D object - transformed from model space to world space, etc.

Quote:

Provided that assertion is correct, your idea for per-pixel lighting falls apart a bit? I'm sure you could work around it - but the basic geometry is in screen space rather than work space, thus making converting the lighting vectors and so on a bit trickier?

I would basically be supplying a normal map or bump map for each particle. That way any point/spot lights would effect the lighting of each particle differently. I think I know what you are getting at though.

Share this post


Link to post
Share on other sites
Quote:
I think I know what you are getting at though.

At least someone has some idea of what I'm on about [wink].

Quote:
the particle system wouldn't necessarily have to be based on Pointsprites.

That was both my assumption and my exception.

In D3D, with PSprites, you specify a point list and it transforms it to screen space and then generates a quad around it (again, in screen space) - to my knowledge none of these 4 verticies are anything more than 2D Quad's. Thus, if you applied a vertex/pixel shader that worked on the final geometry (and not the intermediary) you run into the problem I stated.

As I corrected myself, after thinking some more about it, I'm pretty sure it would be possible - just might be a bit more work on your part (no PSprite freebies).

Jack

Share this post


Link to post
Share on other sites
Yes, this is something we have proposed to several developers at various times. Also, if you make depth-correct sprites, it looks even better.

For instance, you can run a luminance filter on your smoke particle, and then use this as a height value to modify the depth of the particle on a per-fragment basis. It's slower than regular rendering, so if you are gpu bound, you can do non-depth correct rendering when you are far from a solid object, and turn it on when you get close to something.

Share this post


Link to post
Share on other sites
I think it would be interesting to experiment with this. Thanks for the feedback so far!

(I also think it would be interesting to do Cubic gloss mapping (on an object, but that is perhaps a whole nother discussion.)

Share this post


Link to post
Share on other sites
Quote:
Original post by SimmerD
Yes, this is something we have proposed to several developers at various times. Also, if you make depth-correct sprites, it looks even better.

Clever, I like the sound of that - don't suppose you have any screenshots/presentations demonstrating this sort of thing??

With regards to particle rendering - one thing I've always wanted to try in realtime (to my knowledge, no one else has tried) is shadowing (especically self shadowing).

I saw a few screenshots from an offline ray-tracer some years back where there were two scenes... the first was a nightclub with that fake smoke they pump out that picked out all the edges of the spotlights being used. The other was a simple statue in a graveyard and a bit of moonlight - and the way that the fog almost seems to disappear in the statue's shadow. Looked very nifty.

Jack

Share this post


Link to post
Share on other sites
I am considering adding these three effects to my engine as high-end features. I already have pretty nice smoke that hugs walls, responds to the wind, etc. but adding a bit of lighting, and possibly depth-correction would be good.

Since I am doing fake black on white background shadows, this makes translucent shadows easy.

Come to think of it, I bet you could do depth peeling from the light's POV to do translucent shadow maps...

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
With regards to particle rendering - one thing I've always wanted to try in realtime (to my knowledge, no one else has tried) is shadowing (especically self shadowing).


Link

A little ways down is an older demo by Humus that has shadows cast onto particles, which also cast shadows onto the ground. I don't believe it includes self-shadowing though (can't check right now, at work). It is pretty neat.

Share this post


Link to post
Share on other sites
Quote:
Original post by SimmerD
I am considering adding these three effects to my engine as high-end features. I already have pretty nice smoke that hugs walls, responds to the wind, etc. but adding a bit of lighting, and possibly depth-correction would be good.

Since I am doing fake black on white background shadows, this makes translucent shadows easy.

Come to think of it, I bet you could do depth peeling from the light's POV to do translucent shadow maps...

Wow, it sounds like you have quite the particle system! I am interested on how you do it...

I have always had some sort of strange fetish for particle systems. I thought it would look especially cool to use bump mapped particles with point/spot lights. It would give the smoke that added depth without having to use a hoard of smaller particles. I think this is something I am going to have to play with.

Hey Kalidor, thanks for the link. I had run accross it before, but didn't trying running it. I will have to try running it when I get home.

Share this post


Link to post
Share on other sites
Quote:
I am considering adding these three effects to my engine as high-end features. I already have pretty nice smoke that hugs walls, responds to the wind, etc. but adding a bit of lighting, and possibly depth-correction would be good.

Since I am doing fake black on white background shadows, this makes translucent shadows easy.

Come to think of it, I bet you could do depth peeling from the light's POV to do translucent shadow maps...

All sounds very impressive - look forward to seeing the end results (if possible!).

However, something I thought of when reading this thread just now... At least in my experience, there is often quite heavy overdraw in a particle system. Maybe I did it slightly wrong in the past, but sorting particles by depth each frame was a big no-no, and the only good solution was to have them ZTEST but not ZWRITE. In doing this, they appear to correctly blend together - even if the blending isn't strictly in a depth correct order (but, the correct number will be blended at a given point).

Granted, when you have semi-translucent pixels the previously written value is necessary to produce the correct result. But that pixel will need to be calculated.

Do you see that as being a possible problem? a few 1000 (or few 10,000's) of point sprites of a modest size with all of this depth correction, texture look-ups and blending... Adds up to one helluva a bandwidth and processing unfriendly effect [smile]

Quote:
Original post by Kalidor
Link

A little ways down is an older demo by Humus that has shadows cast onto particles, which also cast shadows onto the ground. I don't believe it includes self-shadowing though (can't check right now, at work). It is pretty neat.

Thanks for the link - looks impressive from the screenshot, but thats not quite what I was thinking of.

The effect I saw (as I said, it was offline - I'll be very amazed if it can be done in realtime) is where the particles presumably self-shadowed themselves. So you'd (in the case of light) be able to see a cone from a torch through the smoke (with the particles drifting in/out and distorting/reflecting it slightly); and in the case of shadows you'd end up with a similarish effect to stencil-volumes when you write the volumes to the colour buffer (for debug).

Cheers,
Jack

Share this post


Link to post
Share on other sites
Maybe I'm just missing something here, but if you can already do per pixel lighting and bump mapping, then applying those shaders to a particle system shouldn't be any different than applying it to a regular model.

You just can't use D3D's built in point sprites, you have to actually create the quads yourself and do it like you would in openGL.

One thing I can think of though is the self shadowing might not look right.
Since you'd be lightning 2d billboards in tangent space, they all might end up looking nearly the same, unless you tweaked the UV's for each particle to add some diversity, or used a noise function to generate the bump maps.

I guess the only way to find out is to try it!

Share this post


Link to post
Share on other sites
For the most part I was thinking of maybe several thousand particles at the maximum. There would probably be 2 to 5 different base texture/normal map combinations per particle set. That way it would give a bit of diversity to the particles, yet still be able to batch them in groups of at least a few hundred.

EDIT - Okay, I was doing a little more thinking about it. It might not work as expected because the polygons are being oriented to the camera, so if the player moves while looking at the particles it might look a bit odd. I think it would be interesting to try at least.

[Edited by - Moe on February 16, 2005 9:51:05 AM]

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