Hello everybody!
After experimenting with Krakatoa for a while and finally buying some work/render licenses, I still miss the particle age for creating custom color passes. For example I would like to create a color gradient for the particles over time till their death. I had a look at the two script operators examples with the density and speed but couldn’t figure out a solution. That’s what we’ve come up till now:
on ChannelsUsed pCont do
(
pCont.useVector = true
pCont.useAge = true
pCont.useLifespan = true
)
on Init pCont do ( )
on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(
pCont.particleIndex = i
faktor = (pCont.particleAge as float / pCont.particleLifespan as float)
ColorResult = (faktor255) as integer
pCont.particleVector = [255.0,0.0,0.0] - [(ColorResult),(ColorResult-1),0.0]
)
)
on Release pCont do ( )
Did I mention that I’m a horrible scripter?
In the upper solution I just wanted a gradient between two colors (RED->GREEN), but a better solution would be a three-color-particle-age-gradient…
Who can help me?
Thanks!
Greets
Emil
Hi,
Your code is close - but you missed the fact that vertex colors are not stored as 8-bit RGBs but as 0.0-1.0 components, so you have to get rid of all the 255s in the code.
on ChannelsUsed pCont do
(
pCont.useVector = true
pCont.useAge = true
pCont.useLifespan = true
)
on Init pCont do ( )
on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(
pCont.particleIndex = i
ColorResult = pCont.particleAge as float / pCont.particleLifespan as float
pCont.particleVector = [1.0-ColorResult,ColorResult,0.0]
)
)
on Release pCont do ( )
Then don’t forget to add a Delete operator to define the age, and a Krakatoa Options operator to check the MXSVector->Vertex Color option.
I got a particle system that changes from red to green over yellowish/orange in the middle.
You should get the same once you fix the code.
Thank you, Bobo!
I’ll test the script as soon as I can! Yes, Delete Operator and Krakatoa Options Operator are a must (also according to the tutorial on franticfilms.com)
Best regards
Emil
Just a note that if all your particles have the SAME life expectancy, you can get the color gradient much easier by animating a Texture operator between 1,0,0 and 0,1,0 and set it to write to Vertex Color and sync to Particle Age.
This will NOT normalize the duration of the animation, but it will start it when the particle is born. If your particles live for, say, 50 frames, you could set the second keyframe on frame 50 and the particles will show the color gradient during their lifetime.
In that case, you don’t need the Krakatoa Options operator or a Script and it runs MUCH faster.
Wow, Bobo, that’s an interesting solution! I am just testing it
Thanks!
Greets
Emil