PDA

View Full Version : Need a good Dust Shader for Particle Cloud


Mumf
05-21-2002, 09:14 PM
I'm trying to create a good shader for dust that I can apply to Particle Cloud emissions.

I'm having trouble making anything look good, and was wondering if anyone has made, or knows where I can find a good shader for some dirty dust getting kicked up by cars and people or dirt roads, etc...

Thanks,

Mumf :D

svenip
05-22-2002, 10:36 AM
i think off you should use sprite particles. paint yourself a few images with a cloud and then assign them randomly to the particles via the creation expression or something like that.

i really think that's the easiest way to do this. if you have more questions i could write an in depth explain.

rsalonen
05-22-2002, 12:30 PM
I'm note sure if Mumf needs more eplanation about this, but I would really love to know how to do this, because I'm working on something similar, but it's sand for me (I guess same prinicples anyway)

So if you got time to write please do so! ;)

svenip
05-22-2002, 12:47 PM
so ok here's what i would do (don't flogg me :) )

if you have your motion for the particles (i don't want to explain that because this can be really big) then we can add some attributes for our particles (first make them sprites)

ok, go to the add dynamic attributes and hit the generall butt. in the particle tab select all the sprite attributes ending with PP and the attributes (opacityPP, lifespanPP (means that you have this attribute for each single particle).

next we write the creation and runtime expressions. you need to think about what the dust is doing. is he changing over time or only at birth. thats why we have these 2 expressions. so lets look. i would say that we should have a little variance in the lifespanPP for the dust. so in the creation expression we add
lifespannPP = rand(min,max). the min,max value is in seconds not in frames. so give them a little variance. then we should have the effect of fading out the opacity to the end of the lifespan. so right-click on the opacityPP and create a ramp with the age as inputV. the ramp reads like this. at the bottom the particle is born and at the top he dies. so you should have a black-white ramp from bottom to top.
now we wanna handle the scale of the sprites. i guess the particle gets bigger to let's say 70% of his age and then back smaller.

svenip
05-22-2002, 12:55 PM
we should end something like this for the runtime expression.

float $partLifeSpan = lifespanPP/0.7;
float $value = .....;
if($partLifeSpan <= lifespanPP)
spriteScaleXPP += $value
else
spriteScaleXPP -= $value;

spriteScaleYPP = spriteScaleXPP;

in the creation expression we write the birth scale.

spriteScaleXPP = rand(min,max);
spriteScaleYPP = spriteScaleXPP;

also we should let them twist a bit. so this again should be in the runtime

spriteTwistPP = smoothstep(0,lifespanPP,age) * rand(360,720);

means that the sprites will twist in the whole life 360-720 degrees.

svenip
05-22-2002, 01:06 PM
now lets look that we assign each particle a different image.
obviously this is something for the creation expression.

spriteNumPP = trunc(1,(the number of images you have));

now assign a shader to the particles and assign a file texture for the color. now it's a good idea that you name your image files correctly. (filename.number). browse for the first one (filename.1). switch on (useFrameExtension). under that is a folder hardware texture cycling. put in the number of your last image in to the end cylce. and very important remove the frame number from your file name above. so that it reads "filename." because the frame extension is added from maya now. what we have to do now is to key the frame extension at frame 1 with value one and at the frame with your highest image number (if you have 10 go to frame 10 and key the frame extension with 10).

so, this is the simplest way. for a better and much more complicated one i need more time to test :D .

i didn't even tested this one, so if there's error in the expression i will see that later that day then i have the time to test. sorry. but should work.:bounce:

Mumf
05-22-2002, 05:00 PM
Thanks for the help Svenip. I'm a bit stuck though.

Where do you put these expressions? Which array attribute box do these get assigned to?

Thanks, Mumf



Originally posted by svenip
we should end something like this for the runtime expression.

float $partLifeSpan = lifespanPP/0.7;
float $value = .....;
if($partLifeSpan <= lifespanPP)
spriteScaleXPP += $value
else
spriteScaleXPP -= $value;

spriteScaleYPP = spriteScaleXPP;

in the creation expression we write the birth scale.

spriteScaleXPP = rand(min,max);
spriteScaleYPP = spriteScaleXPP;

also we should let them twist a bit. so this again should be in the runtime

spriteTwistPP = smoothstep(0,lifespanPP,age) * rand(360,720);

means that the sprites will twist in the whole life 360-720 degrees.

svenip
05-22-2002, 05:20 PM
in the attribute editor of your particles in the folder "per particle array attributes" right click on one of the attributes. you will find a menu point for creation and runtime expression. but don't understand it wrong. there is no creation/runtime expression for each attribute. only one global creation/runtime expr. for each particleshape.

Mumf
05-22-2002, 05:39 PM
Cool! Almost everything is working.

I'm not getting any rotation yet, though.

Should this line work?

particleShape1.spriteTwistPP = smoothstep(0,particleShape1.lifespanPP,particleShape1.age) * rand(360,720);

Thanks,

Mumf

svenip
05-22-2002, 05:50 PM
oh yeah just a little thing. it's because of the rand. put this line into the creation expression.

float $partRandTwist = rand(360,720);

and then change the line in the runtime to

particleShape1.spriteTwistPP = smoothstep(0,particleShape1.lifespanPP,particleShape1.age) * $partRandTwist;

now the multiply for the smoothstep will be calculated only once (at the birth). before it was always new calculated every frame and it has given a strange twist.

now it should work. (you should see the spriteTwistPP in the attributelist, if not create it within the general button)

svenip
05-22-2002, 05:56 PM
uups , forgot.

first you must create this attribute. hit the generall button and in the new create a float-per particle array attribute named randTwist.

then delete the last thing i told you off the creation (float $partRandTwist = rand(360,720);) and change the runtime to this.

particleShape1.spriteTwistPP = smoothstep(0,particleShape1.lifespanPP,particleShape1.age) * particleShape1.randTwist;

the creation expressions gets this

particleShape1.randTwist = rand(360,720);

Mumf
05-22-2002, 06:07 PM
WOW!

That's super cool! Thanks!

I'm going to have a lot of fun playing with this. :applause:

Do you have any suggestions on exporting and importing this particle system into new scenes. I've had some trouble in the past, doing this, and I'm going to need export this system eventually. Is there a technique for getting particle systems to export properly?

Thanks again,

Mumf

svenip
05-22-2002, 06:15 PM
hmm, didn't thought about that right now. but lets do it.

at first there will be for sure a problem with the random function. because it's random it won't be the same result in the new one. so add a seed in the creation expression. seed(whatever). this will take the random out of the random. means if you have the same seed in a scene it will create the same random numbers in the scene.
ok, then exporting should be simple actually. make the particle system in a seperate file and then save the file just like a normal scene. then it should be no problem with importing. :hmm:

if you get any, write a line what happens.

Mumf
05-22-2002, 09:46 PM
Thanks again for all your help, Svenip. I appreciate it.

:wavey:

rsalonen
05-23-2002, 01:53 PM
Thanks ALLOT for the great eplanation!

Man, you're da master even Yoda can't compare ;)

I haven't got the time to try this out, but I will soon, and I'm sure it will work...

Man, how do you know allot these expresions? Where di you learn it, because it's like a different world to me, easier to go and learn Chinese on a day :p

Well, once again, thanks a bunches svenip!

svenip
05-23-2002, 02:55 PM
thanx Veqtue, i really appreciate it. but don't build me a statue right now. i really just thought about the problem and the expressions aren't very complicated (believe me :) ) the smoothstep actually is one of the most used i guess, because it's so fantastic :hmm:
i'm only a student, but working with maya since maya1.0. so it's just a matter of working time etc. and i really like to help out here. because i'm writing on my exam i have a lot of sparetime right now. but i guess yoda has more "medichlorians" in his blood then me.

CGTalk Moderation
01-13-2006, 06:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.