Jump to content

Normalizing Across Multiple Attributes


Recommended Posts

Hi,

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
Link to comment
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;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...