color based on particle age

More questions Bobo!

I have particles that are being emitted/dispersed from several objects then getting sucked in by a vortex. Ideally, I would like the particles to inherit the color/material from their source object and blend to a new mat/color based on distance to the vortex.

Mathias muller does something similar with his “particles in the zoo” clip. He writes in this description “To change the color or do all kinds of other stuff you can use particle flow channels like the Scale channel which is easily animatable and then for example use a blend operator in the KMCs to blend based on the changing scale” to acheive this effect.
Unfortunately I have no idea how to do that :stuck_out_tongue:

Anywho, I’m using a simple particle age material for the various objects instead. However, using scanline it renders the color of the particles fine based on their age. When I switch over to krakatoa it seems it is only using the first color in the particle age material.

So, If you know how I can use the scale channel to blend mat/color using the scale channel then I’m all ears. If not, You can just tell me how to get particle age material to work with krakatoa :wink:

The Particle Age map in Max is a hack and we don’t support it. Also it has a limitation of 64K particles, then it stops working.
Since the particles in PFlow do not need the Scale info when rendered in Krakatoa (as Krakatoa does not respect that channel), Matthias was obviously animating the Scale from 0.0 to 1.0 and synchronizing it to the Particle Age (or whatever) which is a feature of PFlow itself. Then he would take the Scale channel and use it in a KCM to control the Blend Operator. Alternatively, you could save the Age and LifeSpan channels and perform the calculation in the KCM as shown in the tutorials here:
software.primefocusworld.com/sof … by_age.php

Since MagmaFlow is an awesome system for post-processing particles, you could also measure the distance to the vortex directly in the KCM and not in PFlow.
Just create an Input Vector node, Connect to scene track and pick the Position of the Vortex object, then subtract the Position Channel converted ToWorld from the Vector node, get the Magnitude of the result and you will have the distance from the particle to the vortex. Divide this by the max. distance a particle can even have to the vortex and you will get 1.0 when at that distance and 0.0 when at the vortex. Now feed this into the 3rd slot of a Blend operator and provide two Vector or TextureMap inputs for the color at far and near to the Vortex and your are set up, in real time.

tried the tutorial on the website for using the lifespan/ age channels and seems to work fine. However
when I add in multiple events it seems to break it somehow.

if I use just a basic birth/delete flow in 1 event I get a nice gradient at birth to death. When add in a "find target "in the birth event and send out to a second a event to delete the particles I only get a gradient starting where the particles hit the “find target node”. Is there some reason why the find target operator would be resetting the particle age?

There are a bunch of threads regarding this already, but here it comes again:

This is simply how PFlow assigns LifeSpan. When a particle is born, it has a LifeSpan of “forever”. Any number divided by infinity is 0, so you cannot do Age/LifeSpan unless you put a direct Delete operator in the Event in question.
Sending out with a test to an event that contains a Delete operator does not count, because PFlow cannot predict when and if the particle will ever go to that event. So unless you have a Delete operator in the Event itself, the LifeSpan won’t be set to a finite value and the whole calculation won’t work. For example, neither the FindTarget nor the Collision test can predict at the time of birth of the particles whether it will ever be sent out unless - it would require running the whole flow on all frames to find out, and that would be too slow. So your only way of specifying a time of death to actually affect the LifeSpan is by adding a Delete operator to the initial event where the particle is born. I am afraid there is no way around this (at least I don’t know if one).

A possible solution would be to change the color of the particle based on the distance to the target instead of the age. See my other post for details.

Okay I got color based on Age / velocity / position to work !

Thanks for all the help!

You haven’t seen the last of me though :wink:

I Spoke too soon! more questions :wink:

Okay so I successfully blended between a my saved color channel and a vector( color ) based on age/velocity/position. I used a mappingobject operator in my pflow event and saved out the color channel ( teapot with a flower texture ). What if I wanted to change the texture used to color the particles at birth after I have saved out the .prt? I assumed that saving out the TextureCoord channel and applying a texture to the .prt loader or using a textmap input to texturecoord channel in the KCM would let me do this, But it is not acting how I thought it would. I looked up the in the help but there isn’t much there about the texturecoord channel ( TextureCoord float32[3] - Texture Coordinates. This is converted to/from 3ds Max map channel 1 (UVW) where appropriate ) Could you elaborate on this for me?

Thanks.

Ok, first some history:

3ds Max 1.0 had one Texture Channel. Obviously it wasn’t enough, so Max 2.0 added a VertexColor channel and the Indices 0 and 1 were given to the VertexColor channel and the TextureCoord channels, respectively. In Max 3.0, the number of Mapping Channels was increased to 100 (0,1+98 more). Thus, for legacy reasons, we call Mapping Channel 1 “TextureCoord”, Mapping Channels 2 to 99 “Mapping2” - “Mapping99”, and the VertexColor channel (a.k.a. Mapping Channel 0) is automatically converted back and forth to the Krakatoa Color channel.

The Mapping Channels are, obviously, used by 2D and some procedural textures to map to the geometry of the object. For meshes, the Mapping coordinates consist of both Mapping Vertices and Mapping Faces which build a topology in UVW space where each face corresponds to the SAME face in the geometry mesh.
But in Krakatoa, each particle is a point and space and its texture coordinate is just a UVW value without the need for any topology. The value stored in the TextureCoord or MappingNN channel defines exactly the location in image space where the texel to map would reside.

Thus, if you have TextureCoord channel baked out to PRTs from the PFlow, you can apply a KCM to the PRT Loader, grab a TextureMap input, select any texture that can use the Mapping Channel 1 and set the output to Color. As result, the color coming from the PFlow will be replaced with the color calculated dynamically from the texture map you selected.
On top of this KCM, you can now add your other KCM that reads the Color and blends to another color by Age.
Alternatively, you can use a single KCM where the Color Channel Input is replaced by the TextureMap input described above, and your flow will produce a color blend between the texture map colors and the color specified for blending by age / distance / whatever.

If this does not explain enough, please let me know.

That makes perfect sense :wink: You’re quite the wealth of knowledge !