# Cycles Emit Light from area on Texture

So I have a giant object that is completely uv unwrapped. I would like to make areas of the object with a specific area of texture emit light.

The problem is that this object (and it is only one object) only has one material. I would like the lava to emit light, but I cannot move it to a separate material without breaking something.

I'd like to find a method where I can select a part of the texture and tell blender that whatever has that part of the texture emits light.

Is this possible?

Thanks.

• What do you mean by 'I can't move it to a seperate material without breaking something'? If you have the lava selected in blender, you can add a new material to it that only applies to the selected lava, and another that only applies to the rest of the volcano? :) – Hexbob6 Jun 28 '15 at 1:01
• Yeah normally that's what I'd do, but I cannot select just the lava since the entire volcano is one object with one uv map that usually breaks if I move vertices. That and the fact that it would take me hours to hand select all the lava because I don't have any automatic way of doing so. – meed96 Jun 28 '15 at 1:08
• Yeah from looking at the way gandalf3 has got it set up, and looking at your original screenshot, it seems that your texture is largely reddish in colour, so having the mask affect only the R channel might be problematic :) I'll see what I can russle up! :D – Hexbob6 Jun 28 '15 at 1:27
• Ahh, I see what you mean. Would solid white and solid black work as long it was the same size? – meed96 Jun 28 '15 at 1:53
• Sweet! I'll try and tailor my answer to both Photoshop and GIMP then, for you and anyone else reading the answer in future :) – Hexbob6 Jun 29 '15 at 1:38

# Creating B/W Material Texture Masks in Photoshop (and GIMP)

Using Black and White (B/W) Texture Masks allow you to assign different types of materials to different parts of an object's surface via a 2D Image Texture, rather than selecting which faces and vertices of a Mesh you want a specific Material to apply to, and assigning it to them in that way. This gives you the benefit of a much higher degree of accuracy and customisability, which you wouldn't normally have when manually assigning materials.

There are several ways you can do this, such as using Procedural Noise Textures inside of Blender, however for more customisation and for trickier textures I've found that using External software like Photoshop or GIMP to produce the best results in a short amount of time! :)

This is essentially the process we'll be taking here. Starting with the Original Texture, we'll create a B/W Texture Mask, and then use it when adding a basic Diffuse/Emission Material to an object inside of Blender.

# Creating a Mask Using Photoshop

1. Begin by opening up the base texture in Photoshop.

2. Add in 2 New layers above the base texture, for sake of clarity I've called them 'Black Background' and 'White Foreground'. :)

3. Using the Magic Wand selection tool from the Toolshelf on the right, and with this Base Layer selected (and unlocked), click the area of colour that you want a new material to be assigned to in Blender. In this case we'll select the Orange Lava colour. If the results are not how you want, press Ctrl+D to deselect the selection, adjust the Tolerance, and check Anti-Alias, before reselecting. This will help Photoshop refine and find all of the orange colour up to the edges of the Lava, and the selection will be smooth and non-jittery. You can also Grow the selection slightly if need be by going Select > Modify > Expand.

4. With the marching ant selection still active, select the 'White Foreground' layer, and grab the Brush tool from the toolshelf. Change the Foreground Colour to White and paint across the area inside of the ant selection. You shouldn't be able to see any of the Orange colour inside of the selection after painting.

5. Change the Foreground Colour to Black and hit Ctrl+D to deselect the ant selection. Select the 'Black Background' layer and grab the Paint Bucket Tool from the toolshelf. Use the tool to make this entire layer black.

And there you have it, the B/W Texture Mask created in Photoshop. Save it out as a .PNG and you'll be ready to skip down to the Blender section below! :D

# Creating a Mask using GIMP

The steps in GIMP are essentially the same as in Photoshop, however there are slight differences in some of the tools have different names, and hotkeys are varied.

1. Begin by importing the Base Texture and adding in the 2 Layers above it as we did in Photoshop.

2. With the Base Texture layer selected, grab the Magic Wand tool, check Antialiasing and adjust the Threshold as necessary to so that all of the Orange Lava colour is selected when clicked. Adjusting this process is actually slightly easier in GIMP than Photoshop, as you do not need to deselect the marching ants selection each time, after adjusting the tolerance, you can simply re-click for an instant update! :)

3. With the Foreground Colour set to white, and the 'White Foreground' layer selected, use the Paintbrush Tool to fill in the ants selection completely.

4. Finally press Ctrl+Shift+A to deselect the ant selection. Change the Foreground Colour to Black and with the 'Black Background Layer' selected, use the Paint Bucket Tool to fill it with a solid black.

And there you have the very (far too ;) ) similar way of creating the B/W Texture Mask using GIMP. GIMP's way of saving is a bit more of a hassle than Photoshop's- you have to export it as a .PNG, rather than saving and changing the file type. Go File > Export to do this! :)

# Using the Texture Mask to Affect Materials Inside of Blender

Whichever software you used to get here, you now have the original Base Texture, as well as the B/W Texture Mask. Read on to find out how to use these in Blender... ;)

1. Jumping into Blender, for the sake of demonstration, I've set up a simple Sun Lamp and Orthographic Camera scene, and imported the Base Texture by using Shift+A > Mesh > Images as Planes. This will add the Texture into a simple material applied to the plain, with an Image Texture node plugged into a Diffuse BSDF. You can preview how this looks in Textured or Rendered Viewport Mode.

2. To begin, we'll mix together the Diffuse BSDF shader, with an Emission shader, via a Mix Shader Node. We can set the Emission Strength to 3.000.

3. Finally, add in another Image Texture node and open up the B/W Texture Mask. Plug the Colour output of this node into the Fac input of the Mix Shader. This will make all of the Black Values of the Mask correspond to the Top Mix Shader Input, and the White Values of the Mask correspond to the Bottom Mix Shader Input. If anything funky happens just add an Invert node, or flip the top and bottom Mix Shader inputs! :)

And we've reached the conclusion! A VERY simple end node setup for an insanely useful, and widely applicable process! :D

Hope it helps!! :)

• Wow +1. Detailed answer. – meed96 Jun 29 '15 at 23:29

You a black and white mask of the lava parts, by which you can mix between the current shader and an emission shader.

Assuming you have no other way to generate such a mask, here's one option:

Find some aspect about the lava which separates it from the rest of the texture. It seems to be bright orange, where the rest of the texture is relatively dim. If you can set all the pixels with a value < dimmest pixel of lava to 0, you have a mask. A less than math node can work well for this, but I like using a color ramp node as it is easier to only allow a range of values.

For example, to emit light from the blue part of the blender logo, I first separated out the blue channel of the image with a Separate RGB node. Then I used a color ramp node to allow only blue pixels within a certain value range:

This particular example isn't very good, but I think you might have better results with your image.

To see the results of the color ramp threshold better, temporarily connect it to an emission shader. I highly recommend the Node Wrangler addon, which will let you do this quickly by pressing ⎈ Ctrl⇧ Shift LMB on any node.

Note that in your image almost everything is red, so separating the color channels probably won't do much.

• I'm having a slight issue figuring out what my mask is affecting since nearby blocks get shaded with the emission color, is there an easier way to tell what exactly the mask is affecting while I'm adjusting it? – meed96 Jun 28 '15 at 1:22
• Yeah, sadly the brighter colors on the red blocks overlap with the darker ones on the lava, the emission is being applied to both. I don't see any obvious fix for that though. – meed96 Jun 28 '15 at 1:27
• @meed96 Regarding your first comment, if you connect the color ramp straight to an emission shader for previewing it should help – gandalf3 Jun 28 '15 at 1:33
• Haha, I just figured that out and edited your answer to include the details. – meed96 Jun 28 '15 at 1:34
• Using the Node Efficiency Tools/NodeWrangler addon, you can Ctrl+Shift+LMB any node you want to preview and it'll automatically add a viewer node for easy viewing :) – Hexbob6 Jun 28 '15 at 1:48