X-Particles and Cycles 4D: Accessing X-Particle Data
In the page dealing with basic rendering, the particles had by default a plain white colour, or could have a colour from a node such as Diffuse BSDF. If you want to use the particles' own colours, you will need to use the Particle Info node.
Here is a simple node tree which will render particles in their own colour:
If the emitter is set to use random colours, this is the result:
However, you can do a lot more than just that.
Using the Age output from the Particle Info node
The Age output returns the particle age in seconds. If we link this to a Color Ramp node like so:
Then the particle colour will change with age:
However, you can see that something isn't right here. At least half the particles are coloured violet, but we would expect that only the very oldest ones would be that colour. This happens because the age is in seconds, and this scene was 3 seconds long, so many particles will have ages which are greater than 1 second.. The color ramp, however, expects a value between 0 and 1, so anything over 1 will return the colour at the right-hand end of the ramp.
What we need is to convert the age range, which we know will be from 0 to 3, into a range from 0 to 1. If we do that, we get this:
That is now correct.
The age conversion was done with a simple node group which gave a node tree like this:
The node group called 'MapValueTo0_1' takes any value and converts it to a value between 0 and 1 using the minimum and maximum values that are input to it. You can download this node group here from the Cycles 4D Node Group collection.
Other particle data
You can use other particle data in the same way. Here is the output of a scene lit only by the particles (there are no other lights). The particles emit light and the intensity and colour is controlled by the particle temperature, which is increased with age by an X-Particles Physical modifier:
The node tree is slightly more complex but the principle is the same.
How it works
As you can see from the enlarged image, the temperature is obtained from the Particle Info node and converted into a range from 0 to 1. It then drives a Color Ramp node for the diffuse colour. For the light emission, the value from the range node group is multiplied (by 5 in this case) and the result is used to drive an identical color ramp. The reason for this is to skew the colour towards the right of the ramp, otherwise the colours tend to be more red than white.
The range node output is also used to drive the Strength of the emission node; it is multiplied by 500 to increase the amount of light emitted.
You are really only limited by your imagination in how you use this data. Of course, sometimes you will need to emit geometry and render that. How you can control that in Cycles 4D is found on this page.