# How to use the velocity from the particle info node (cycles material)?

I am trying to do a kind of wind simulation in cycles: i set up a particle simulation, assign an object to them and bake.

Then i tried to setup a material (used for the object) to convert the particle speed into different colors: slow red, faster green, at example.

The problem is: how can i use the velocity output from the particle info node to modify the color of the shader? Or are there better systems in cycles?

I’m curious about this as I have a similar problem: I’m using the particle velocity to control the brightness of an emission shader. Problem is, that it’s a vector, not a scalar. If the velocity is plugged into a node expecting a scalar, the vector gets converted to a scalar value by adding the vector’s x,y, and z. This doesn’t work too well, as you can probably imagine.

I can’t seem to find a way to get the magnitude of a vector in the node editor. Is there a way to do this? That would fix my problem and it would also fix the OP’s problem, as he/she could plug the velocity magnitude into a ColorRamp node and that would do exactly what they want.

I managed to work this out. In order to get the magnitude of a vector, you can take the dot product of the vector with itself. This give the square of the magnitude, so then you just take the square root of that. Here’s my material setup, it blends between glass and emission, so that the faster it moves, the more brightly it emits light:

Here’s a really quick render of the result:

By the way, here’s an animation render from BEFORE I worked out how to get the magnitude of the velocity. The effect is “wrong” but I really quite like it.

Thank you very much for sharing the setup, i tried that and with little tweaking is working fine for my needs.

You’re welcome I’ve been messing with it some more, and this is pretty cool in motion:

nice example using cycles

thanks