Test Distance and Add Colour ICE Node
My previous ‘Add Colour on Distance’ node for playing with particle colour had something of a limitation in that it could only be used once in an ICE Tree – trying to use multiple colour inputs just wouldn’t work. This is due to the fact that it uses a ‘Set Particle Colour’ node in the compound, so if you have more than one XSI will change the colour twice on the same frame.
To get around his we want to use a solution which only uses a single ‘Set Particle Colour’ node. The best way of doing this is to change the order in which we do things a little. The idea is to have a number of colours being added together which we then clamp and set. The colour we’re adding together can be calculated by testing the distance of the particle to the surface and, if it’s too far way, adding colour with all it’s values zeroed (resulting in no change). If it’s close enough then we can add a little bit of something more interesting.
To make things a bit neater, I created a compound called ‘Test Distance and Add Colour’, which you’re free to download. Stick it into your user compounds folder and it’ll show up under ‘Tasks/Particles/Colour’. It’s a very simple one, nothing complicated, which just tests the distance of a particle from a surface and has a colour value for both true and false outcomes. The user can define the true value from the node as well as the distance to start adding the colour.
Test distance and add colourxsicompound (.txt file, change to an .xsicompound to use)
Once you’ve set up the nodes you’ll want to pipe them into an ‘Add Colour’ node, along with a ‘Get Data from Previous Frame’ node looking at ‘Self.Color’ (very important that one!). I’d also recommend using a clamp to stop the values getting too large – this can cause problems if you want to blend colours and can cause havoc when it comes to lighting and rendering. Once we’ve got that all set up we can finally set the colour on the particles.
To demonstrate this in action I’ve made a little example which you can see below, along with the ICE Tree I used. You can see in it that I set up the colours to be created from a single scalar value piped into the appropriate value I wanted to add, then multiplied by -1 for those I wanted to take away. This made it much easier to test and balance out how much I wanted to add and take away. You don’t need to do this – in fact there are some situations where it wouldn’t be helpful (which I’ll post about later), but in this case it was pretty helpful.



January 27th, 2010 at 12:31 am
[...] Test Distance and Add Colour ICE Node [...]