Page 1 of 2

Random Color Texture, per Element

Posted: Wed Sep 21, 2022 1:06 pm
by mbetke
Is it possible to randomly tint an element and not the whole object? At the moment I have to detach all elements to tint it randomly.

Re: Random Color Texture, per Element

Posted: Thu Sep 22, 2022 8:40 am
by HHbomb
You can use "Material by element" modifier. But you need to make a multimaterial with lot of ID.
You can user a data channel modifier to assign a random vertex color for each element.

+1000 if otoy can make a random color by element !!!!! :-)

Re: Random Color Texture, per Element

Posted: Thu Sep 22, 2022 8:51 am
by mbetke
Yes, because that's why I ask. :)
I think Corona/Vray supports it. Sometimes the small things are the handy ones.

Re: Random Color Texture, per Element

Posted: Mon Mar 10, 2025 4:05 pm
by Pavlov
+ 100 on this.

In Corna and Vray we use this all of the time, it's priceless - you can differentiate leaves, buildings etc, without the need of assigning multiple materials.

Paoo

Re: Random Color Texture, per Element

Posted: Tue Mar 11, 2025 10:27 am
by paride4331

Re: Random Color Texture, per Element

Posted: Thu Mar 13, 2025 1:39 pm
by Pavlov
Hi Paride,

hard to tell since these are MAX examples but i'll try to explain.

Imagine a city made of many boxes, all part of the same mesh. I want to assign a different texture to each box (different facades) without having to assign, say, 20 random IDs. In Corona and Vray, the Randomizer can work not only on instances (like Octane Randomizer does) but also on individual elements of a single mesh. This means I can randomize 20 textures on each element of that single mesh without assigning different IDs or creating multiple materials—it's just one object with one material using a "Randomizer by Element" that randomly applies one of 20 textures to each box.

This approach is also very useful in many other situations, such as with trees. For example, you can assign 5 different leaf textures to each leaf (element) using a single material on a single mesh.

Hopefully it's clear, let me know if i've to explain better.

Thanks
Paolo

Re: Random Color Texture, per Element

Posted: Thu Mar 13, 2025 2:09 pm
by Pavlov
PS - some time ago i raised same topic - randomize by element - and someone posted a OSL that could do that.
I wanted to give it another run, but i cannot find it.

Can someone point me to the link ?

thanks
paolo

Re: Random Color Texture, per Element

Posted: Thu Mar 13, 2025 2:40 pm
by Pavlov
Just for clarity, this is same thing in Lightwave - single mesh, but different colors (or maps) for each leaf using an element-aware randmizer.

best
Paolo

Re: Random Color Texture, per Element

Posted: Wed Mar 19, 2025 3:17 pm
by HHbomb
+10000

Re: Random Color Texture, per Element

Posted: Wed Mar 26, 2025 1:55 am
by neonZorglub
Here is a new OSL texture that select random texture per element.
random_tex_per_element.png
random tex per element.zip
(348.92 KiB) Downloaded 27 times
The objects need to have an Octane geometry modifier, with a Vertex Attributes Generator set as follow:
Generator: PolyConnect
Attribute: Float1
Attribute name: ElementId

The OSL texture rand10Tex_ByElem_obj_uid.osl need to have a Grayscale vertex attribute in the 'Grayscale tex' input.
The Grayscale vertex attribute need to use the same attribute Name as in the geometry modifier : ElementId

Set the Texture count between 1 to 10.

When using multiple instances or copies of the same object, the vertex attribute values will be the same, so the random pattern will also be the same for each instance.
To have random variation on those instances, enable the 'Use Object seed' and / or 'Use InstanceID seed'

'Use Object seed' add randomness from an internal unique ID per object, but those IDs could change as you add/remove objects in the scene.
'Use InstanceID seed' add randomness from the 'User instance ID' that can be set per object in the Octane Object properties dialog.
Those Instance IDs will not change, so the random pattern will be more stable.
Note that you can use the tools in the Octane Object properties dialog to set those User instance IDs for all selected objects.
setting_user_instance_IDs.png
The second OSL (rand20Tex_ByElem_obj_uid.osl) is the same, but with up to 20 textures.

for 3dsMax 2018:
random tex per element_mx18.zip
(346.54 KiB) Downloaded 30 times