PDA

View Full Version : Random Colors at render time



tcoursey
02-18-2012, 09:02 AM
Is there a way to setup random colors on a surface at render time. We use HD Instance and it has a shader that allows us to select/enter a bunch of colors on a gradient, then at render time it selects those colors randomly and puts them on the object.

I would like to know if there is something in 11 natively or a node other than HD Instance that can do this. Anyone know of anything? Thanks.

Hieron
02-18-2012, 09:20 AM
Sure, take instance # node and feed it into input of a gradient color node and feed that into your surface color input etc. Works better than it did for HDI actually afaik.. quite nice.

In nodal panel:
-Go to Spot nodes group
-Take the Instance info node
-Feed ID index into a gradient color input.

It won't be random like that btw, usually a nice sine wave node can be used for such but perhaps "fixed random" is actually included for this and can be used. Didn't test..

tcoursey
02-18-2012, 09:23 AM
sounds interesting. Unfortunately I have not played much with nodes, but can get around in there. I'll give it a shot! Thanks.

tcoursey
02-18-2012, 09:36 AM
ok, one more while we are at it. What about doing something similar but having a node select a random image? Looking to change out the License plate on a car.

Scenario: 10 different cars, instanced on polys spread out throug parking lot, random color (with node setup you gave) plus a random image for the license plate surface!

Come on...you can do it! :)

Hieron
02-18-2012, 10:52 AM
Stack all images blended and drive % of the layer between 0 and 100 by logic nodes taking input from instance #. Again randomized if need be.

Sorry, no time to produce examples..

tcoursey
02-18-2012, 10:54 AM
awesome! you've given me some great direction to begin playing with. I just may need to dive into this Nodal stuff after all. lol. Thanks!

tcoursey
02-18-2012, 02:54 PM
Works like a champ! Thanks so much. Thought I would share some images and a surface for others.

tcoursey
02-18-2012, 03:11 PM
Stack all images blended and drive % of the layer between 0 and 100 by logic nodes taking input from instance #. Again randomized if need be.

Sorry, no time to produce examples..

You've been much help...just a little more if you could.

I'm not quite following the Stack all images blended. Is this using a node of some sort? I added an 2D image node but there isn't (that I can see) the ability to add several in one like standard layer textures.

Again thanks for the help. This is opening my eyes wide! :bowdown:

Hieron
02-18-2012, 04:46 PM
ClothFX finally agrees with me, so I got a bit of time.
Attached a scene that leads to:

101895

It is real simple actually, like:
101898

In this case, the blue one is always active and on the background of the "stack". The "fixed random" output of the Instance Info is between 0 and 1 and random. So I feed it into 2 subtract nodes. One subtracts 0.33, the other 0.66. Then either goes into a logic node. The logic node merely checks if it stays above 0.

Suppose the Fixed Random info gives a 0.2 (between 0 and 1) for one of the instances. Both logic nodes would output "false", since the subtracts pushes both below 0, which is set to 0. So opacity of both image nodes red and yellow are invisible, so only blue is seen.

If the instance would have been between 0.33 and 1, the red one would get opacity set to 100%. But between 0.66 and 1, the yellow one gets 100% too and since it is in front it will be the one showing.

Thus, each gets a +- 33% share.

Scene and object:
101894

Not sure if there is another way to do it, this was superquick though. Surely a specific node could exist making it a tad simpler. This nodal flow will get huge when there are many images involved. Would be nice if we could nest nodes one day...

tcoursey
02-18-2012, 07:51 PM
excellent! This is perfect. I envy your mad skills in the node window. It's simple yes, but not straight forward to someone who is challenged in the node window. lol.

For others that may stumble upon this, you can add images to this nodal flow by following what is here. The only thing you will change is the VALUE in the first part (subtract). Take the number of images you plan to include and then divide 100 by that. ie. if you have 10 images you'll enter .1 in the first, .2 in the second .3 in the third etc..etc..

That seemed to work for me when I added two more to this setup anyway. Thanks again for the help and direction. This is wonderful stuff!

Iaian7
02-29-2012, 10:19 PM
...nice! And you shouldn't even need the subtract node, simply change the value the logic node is testing (if A is greater than 0.3333, etc.), right?

jameswillmott
02-29-2012, 10:59 PM
Not sure if there is another way to do it,

A Gradient; set the keys at integer positions ie. one at 0, one at 1.0, one at 2.0 etc. expose them so they have inputs on the node, feed the Instance# into the gradient, and feed the images as Image nodes into the keys, set the Gradient type to Repeat.

Scazzino
02-29-2012, 11:15 PM
Here's a simple way to change the colors with LW11's new instances. Instance Info: Fixed Random into a color gradient set to step interpolation.

http://forums.newtek.com/attachment.php?attachmentid=102177&d=1330397248

I used it to color all the superballs in the following render.
http://forums.newtek.com/showthread.php?t=126179

:thumbsup:

Hieron
03-01-2012, 05:23 AM
...nice! And you shouldn't even need the subtract node, simply change the value the logic node is testing (if A is greater than 0.3333, etc.), right?

Agh yes ofcourse, they stack. Doh. That's for working long hours.. :) Thanks.


A Gradient; set the keys at integer positions ie. one at 0, one at 1.0, one at 2.0 etc. expose them so they have inputs on the node, feed the Instance# into the gradient, and feed the images as Image nodes into the keys, set the Gradient type to Repeat.

Hehe I know it could be better, nice addition :)
Have to admit I didn't even use/know you could expose keys.


Here's a simple way to change the colors with LW11's new instances. Instance Info: Fixed Random into a color gradient set to step interpolation.


I used it to color all the superballs in the following render.
http://forums.newtek.com/showthread.php?t=126179

:thumbsup:

That's what I mentioned in the 2nd post up there right? Or? Nice image examples though, much clearer..

Scazzino
03-01-2012, 07:46 AM
That's what I mentioned in the 2nd post up there right? Or? Nice image examples though, much clearer..

Close. You said ID Index, and then suggested that "fixed random" might be for that reason. So I showed an example of doing just that to confirm your hunch, with an example of the nodes, and an example render. :thumbsup: