OSL Random color 3dsMax

Forums: OSL Random color 3dsMax
Post, discuss and share handy resources like textures, models and HDRI maps in this forum.
Forum rules
Please do not post any material that is copyrighted or restricted from public use in any way. OTOY NZ LTD and it's forum members are not liable for any copyright infringements on material in this forum. Please contact us if this is the case and we will remove the material in question.

OSL Random color 3dsMax

Postby paride4331 » Tue May 15, 2018 8:27 am

paride4331 Tue May 15, 2018 8:27 am
The Octane 'Random color texture' may depend on the number and order of objects using it.
(For example, using movable proxy on instance objects)
In this case, when hiding or deleting some of the objects, the other objects will change color.

To keep a constant random color per object, a simple OSL texture can be used to produce random color depending on the object User ID.

First, set some unique user ID to each object:
-Select all objects to use your random material
-Open the Octane object properties dialog
-Set 'start' to 0
-In the tool button '...', select 'Set selected IDs from selection order'

Then, use the RandomGreyInstance.osl as a texture, or copy the code below:

Code: Select all
#include <octane-oslintrin.h>
shader randomColorGreyFromInstance(
    int seedI = 0 [[string label = "Seed"]],
    output color c = 0)
{
    float noiseOut = noise("cell", (float)(_getinstanceid() + seedI));
    c = color(noiseOut, noiseOut, noiseOut);
}

That gives a random grey color for each object. see sample randomColorFromUserID.max

This can then be used as the input of a Gradient texture, to select your colors.
Attachments
randomcolorOSL.rar
(741.67 KiB) Downloaded 29 times
01.jpg
Win 7 / i7 5930 - 32gb / 1 x quadro K620 / 2 x Evga Titan X Hybrid
User avatar
paride4331
Octane Guru
Octane Guru
 
Posts: 1812
Joined: Fri Sep 18, 2015 7:19 am

Re: OSL Random color 3dsMax

Postby Rik » Tue May 15, 2018 10:14 am

Rik Tue May 15, 2018 10:14 am
Thanks Paride, that's great (appreciate the release 14 max file too)

Is it possible to apply the user id randomly to elements - such as leaves on a tree mesh?

Or would you need to keep thousands of instanced leaves plus trunk/branches as separate meshes but lumped together as a group?
Rik
Licensed Customer
Licensed Customer
 
Posts: 201
Joined: Wed Jul 28, 2010 8:57 pm

Return to Resources and Sharing


Who is online

Users browsing this forum: No registered users and 1 guest

Tue Sep 25, 2018 10:34 pm [ UTC ]