Color variation on multi sub material
#1
Hello,

How can i apply a random color, from a fixed set of colors, to a multi sub material?

In detail, i'm using TyFlow to Birth a reference shape.
That shape has a Multi/Sub-Object material applied to it, and the diffuse color of one of those sub-materials is randomly chosen from a pool of 10 fixed colors.

With Arnold, i can use the "Object ID" and "1 of N color" maps to achieve that on a group of shapes, but i can't do it with a single TyFlow object, because i don't have an "Object ID" for each particle.

I also can't seem to do it using the "Material ID" operator, because then, each particle gets assigned only one of the Sub-Materials.

Is there any way i can pass an unique particle id or attribute to use in Arnold as User Data?

Any help would be greatly appreciated.

Thank you
  Reply
#2
You could try the Instance ID operator...that assigns a gbuffer value to particles which Arnold may be able to interpret (not sure if the Arnold devs implemented that, but it should work in VRay, for example).

An alternative way would be to create a Gradient Ramp texmap, set interpolation mode to solid and then evenly space your 10 colors apart in the gradient. Then in tyFlow, use a Mapping operator to assign a mapping override to particles. Set the override value to 1 and variation to 100%. Since that will assign a random X-coordinate (between 0-1) to your particle's UVW channel, they will effectively choose one of your 10 colors in the gradient ramp you apply to them at random.
  Reply
#3
(02-19-2022, 04:04 AM)tyFlow Wrote: You could try the Instance ID operator...that assigns a gbuffer value to particles which Arnold may be able to interpret (not sure if the Arnold devs implemented that, but it should work in VRay, for example).

An alternative way would be to create a Gradient Ramp texmap, set interpolation mode to solid and then evenly space your 10 colors apart in the gradient. Then in tyFlow, use a Mapping operator to assign a mapping override to particles. Set the override value to 1 and variation to 100%. Since that will assign a random X-coordinate (between 0-1) to your particle's UVW channel, they will effectively choose one of your 10 colors in the gradient ramp you apply to them at random.

Thank you for your prompt reply.

I've tried the gradient ramp method, but i don't seem to be able to get it working.
The preview on the viewport seems fine, but when rendering, all the objects are of the same color. To be more precise, it's only showing the first color on the gradient ramp.

In Arnold, i was able to create an OSL shader that returns the particle ID, and get the color variation working. Still doing some tests to check if it's working ok.
  Reply


Forum Jump: