Blender: Random Light Value
Have you ever made a scene that has a ton of lights with are meant to be different brightnesses and had to set them individual values manually? Takes a lot of time doesn't it (I know the pain, I've done it more than once). Did you know there is an easier way to do it in Blender with Cycles? Its true and its actually very easy to do.
In this tutorial, we will use a single material to control the light given off by multiple object. I will use my old TARDIS light but feel free to use any object you wish. It is the material, not the object which produces the effect.
In this tutorial, we will use a single material to control the light given off by multiple object. I will use my old TARDIS light but feel free to use any object you wish. It is the material, not the object which produces the effect.
Linking Materials
For this process to work, each object has to share the same material data or in the case of scene lights, lamp data. I will split this section in 2 to make it easier. The first section deals with people who already have lights and the second will deal with those who do not.
If you are using lamps, go to the Object Data tab instead of Material editor when it says (its where you choose the type of light you use. Sun, Spot, Area, etc.) If you Do Link If you Don't Link Note: this method won't work if the lights are all on the same mesh/object If you already have a bunch of lights that you want to use but don't the same material, this can be fixed but will take time depending on the amount of objects you have.
In the material editor with one of your lights selected, copy the name of the material responsible for emitting the light by pressing Ctrl+C while hovering the mouse over the light. If this was me, I would hover the mouse over the word "Light" (as that's what I called my material, that's a tip right there) and press Ctrl+C. There reason we are doing this is so you don't have to keep typing the material name in later. Now go to the other objects that you want to share the material with. Still in the material editor, click the button on the LEFT of the name. A drop down list should appear. Now press Ctrl+V to paste the name into the search box. This should either lead you straight to the material you are looking for or get you close enough to pick it out of the remaining list names. Now the material name should appear with a number on the right of it. This is how many material slots use this material data. The number should at least be as many objects you want to use as lamps. Repeat these steps till all lights use this material. Click here to go to the next step |
If you don't already have lights set up, it is best to set up a single object and then copy it around the scene
I will be using a TARDIS wall lamp so first, I set up the mesh so the part that will be the light has its own material. Then simply copy it around the scene using either SHIFT+D or ALT+D. SHIFT+D will create a duplicate that will share the materials but NOT the mesh data so you can change one objects mesh without effecting the others. ALT+D will create a duplicate that shares the materials AND mesh Data. This makes changing the meshes of all duplicates a lot easier as you only have to do it once. (tip: You can remove the link between mesh data by pressing U and selecting "Object+Data") You can use either method for copying your light as both methods automatically link the materials which is what we will be using. |
Setting up the Nodes
First, make sure the material you are using as a light is selected and then jump over to the node editor. As this is a light source, we need an emission node to emit light (Sift+A > Shader > Emission).
This is our material base to control the colour and strength of our light. The next node we need is the Object Info node (Shift+A > Input > Object Info) Plug the Random output of the Object Info node into the Strength input of the emission node. This will generate a random number for every object and use it as a strength value. Clever huh. You can control the strength to a degree using a Math node (Shift+A > Converter > Math) and plugging the random value into it. Then choose a mathematical equation to alter the output. I used the Multiply equation so some of the lights were much brighter than the other. |
This is just one of the many uses of the random value. It can be used to create random colours for materials, roughness values, mix values. I created the effect below just using a Colour Ramp.
Just plug a Colour Ramp node (Shift+A > Converter > ColorRamp) and set the the colours using the sliders and sit back and watch the magic (well actually its just maths...) |
If you liked this tutorial, why don't you share it, like it, reblog it. Can't hurt can it?