Colorize using distance to an object?
#1
I i'd like my particles to have their color from their distance to an objet.

I mean :
I created a materiel using a multicolor gradient going formthe first color at the beginning (color 0) to the last color at the end (color 100).
When the particles are far from the object I want them to get color 0
and when they reach the objet's center (or, better, its surface) they get color 100.

I guess I need to use "Distance to target" custom float data and a mapping node but how?
(as I do when driving the opacity with a gradient using "Particle age" custom float value)
But what represents "target" in the  "Distance to target"? A value ? An objet ? A channel ?
The channel "target" allready exists, why? Should I use it?
How to evaluate the distance from each particle to the object?
...

Any help, tuto or example about it would very wellcome Smile
  Reply
#2
Target seems to be the target of a "find object" operator. I can sort of make it work for gravity, but had no luck with mapping.

Attached is a file (Max 2020) that uses an Object Test (Ignore if true, save all test values, and saved to a custom channel).

This is then retrieved via a value operator, mapped to 0-1 and used in a Mapping Operator. Could probably be retrieved directly in the Mapping Operator as well somehow.


Another, probably simpler approach would be to do this in the material. Use a distance map (e.g. V-Ray Distance or 3ds max Falloff) and use a mapped Gradient Ramp to apply your colors.


Attached Files
.max   Color_by_Distance_TyFlow_max2020.max (Size: 780 KB / Downloads: 12)
  Reply
#3
"Targets" are a tyFlow concept that refer to the particle ID of another particle, assigned to a float channel of the current particle.
  Reply
#4
(06-21-2025, 11:29 PM)Findus Wrote: Target seems to be the target of a "find object" operator. I can sort of make it work for gravity, but had no luck with mapping.

Attached is a file (Max 2020) that uses an Object Test (Ignore if true, save all test values, and saved to a custom channel).

This is then retrieved via a value operator, mapped to 0-1 and used in a Mapping Operator. Could probably be retrieved directly in the Mapping Operator as well somehow.


Another, probably simpler approach would be to do this in the material. Use a distance map (e.g. V-Ray Distance or 3ds max Falloff) and use a mapped Gradient Ramp to apply your colors.

Thanks for the scene Findus, it helps understanding a lot!

The distance is evaluated to the cube's pivot meaning changing the cube's size doesn't modify the particles colors.
And the cube could be any other object without changing anything either.

Is there any way it could be distance measured to the surface of the mesh itself ? (= the polygons)
  Reply
#5
Have you tried Surface Test?
  Reply


Forum Jump: