Jump to content

Normalizing Across Multiple Attributes

Recommended Posts

Posted (edited)


I have a FLIP color mixing situation, but I'm using more than two colors. Let's say four, for now. My basic approach is this:

1) Create four attributes on all source particles, so a single particle would have for example all of these:

f@blue =0;

f@green = 0;

f@yellow = 0;

f@red = 1;

2) Find a way to mix the attributes during the sim

3) Transfer these attributes to the mesh, and then modulate the shader color with this input.

I'm looking for advice on how to get them mixing correctly in the sim. Attribute Transfer in a SOP solver might play a role here, but the issue is I need to find a way to normalize the influence of these attributes so they'd always add up to 1. That is, if one attribute increases, its influence is subtracted from another. Kind of like when painting weights in rigging.

I've watched a bunch of tutorials on color mixing, but they're always with just two colors, which simplifies things greatly. Been wrestling with this one for a while and I'd really appreciate any ideas on how to achieve this.

Thanks very much for any advice!

Edited by jamesearnest244

Share this post

Link to post
Share on other sites

To do the normalising step you can do something like this [in a wrangle in your SOP solver] - 

float total = f@blue + f@green + f@yellow + f@red;

f@blue /= total;
f@green /= total;
f@yellow /= total;
f@red /= total;

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now