Advertisement

You're blocking ads, which pay for BlenderNation. Read about other ways to support us.

Random Values in Cycles Materials

6

onelvxe writes:

The age old question of how to get truly RANDOM values into the Cycles Shader Node Tree has been solved. Using some trickery and workarounds courtesy of Jacques Lucke's wonderful Animation Nodes, we can finally send truly random values into a Cycles Material.

In this quick tutorial you'll learn how to create random float/grayscale values, vectors, and colors, animate them, and loop them to introduce all sorts of discord and natural chaos into your scenes.

Download the Blend File here (Note: you must install animation nodes for the blend file to work. Get Animation Nodes here).

About the Author

Jared Webber

ONELVXE Studios creates custom visuals, campaigns, music and artwork for brands, corporate clients, artists & musicians, as well as designers around the world.

6 Comments

  1. I'm on my phone so I can't check myself. I have a still image and want to add random colors to my grass. Do this generate a random different output for different objects using the same material on the same frame?

    • It depends on how exactly your scene is setup. This works differently than the Object Info node, which does what you're talking about. If your grass is a bunch of modeled grass clumps that are instantiated and using the hair system, you can use the "Object Info" node to give them random colors. Just make sure they are all set to use the same material and Object Info can be used to give each clump of grass a different color.

      You can extend Object Info and combine it with the method shown here using a math node. This is useful if you want the grass to say change colors every frame (you can also step through frames and skip them using AN nodes). Essentially, you would multiply Object Info with your routed Cycles Material Output data from AN. This would still give you a randomly generated, constantly changing value in Cycles Shader Nodes, but would make it so that every object gets a different multiplier and thus, it's own random number.

  2. You don't need animation nodes to get a random value varying over time. Just insert a keyframe and add a noise modifier in the graph editor.

    • You don't "need" Animation Nodes, you're right. But the purpose of this tutorial was to show how to get a random value into Cycles without the use of a textures. Just a purely random value, that you can loop and do whatever you want with.

  3. This doesn't appear to generate random colours. It merely picks a colour in a specific range already defined by a ColorRamp node. For example, there's no bright yellow in the ColorRamp node shown here, so my object is never going to turn randomly bright yellow.

    • You can actually use color Nodes in Animation Nodes and output them to Cycles. I was just simply showing how you get a random NUMBER into a Cycles Material. If you want a random color, you have to setup the randomization and pipe it into a HSV color node or do some other things in Animation Nodes, then take that color and plug it directly into the color socket of a shader or color mix node in the Shader Node Tree.

Leave A Reply

To add a profile picture to your message, register your email address with Gravatar.com. To protect your email address, create an account on BlenderNation and log in when posting a message.

Advertisement

×