8

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.

meed96
  • 1,979
  • 5
  • 30
  • 44
  • 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 01:01
  • 1
    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 01:08
  • Hmm okay, how do you currently know which vertices/faces are part of the lava? Are they a specific colour on the UV map or a seperate part of the UV map or what? – Hexbob6 Jun 28 '15 at 01:16
  • I didn't UV unwrap this, I got it from a piece of software. So the only way to check what verts the lava is is to go into textured view and look at them. – meed96 Jun 28 '15 at 01:17
  • Ah right I think I see what's up, you need to select the colour or the orange lava and use that as a mask to differentiate between the rock and lava materials, I'll put together something to help show you. – Hexbob6 Jun 28 '15 at 01:20
  • Gandalf already made an answer, but I would love to see a separate take on it, and more answers is always better. – meed96 Jun 28 '15 at 01:21
  • Ah, @gandalf3 's got in there first! ;) I'll still put something together if there's anything that you'd like clarifying? :) – Hexbob6 Jun 28 '15 at 01:21
  • Will do it tomorrow @meed96 , see if I can find any different ways of doing it! ;) – Hexbob6 Jun 28 '15 at 01:22
  • That would be useful, I'm having a couple problems with the mask affecting similar colored blocks, so perhaps a more advanced setup would be nice to look at if you can manage it. – meed96 Jun 28 '15 at 01:25
  • 1
    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 01:27
  • Here's a picture to show exactly whats happening, there are a few white pixels on the red block that exist when I pull the colorramp over the lava: http://i.imgur.com/DT6HPC1.png – meed96 Jun 28 '15 at 01:37
  • Hmm yes it does look like some of the colour from the lava is present elsewhere just enough for it to be included in the ramp. Is there any chance you're able to upload the original texture itself, it may be easy to just go into Photoshop or gimp and use the magic wand tool to make a mask? :) – Hexbob6 Jun 28 '15 at 01:44
  • How would Blender be able to interpret a mask from another piece of software? Where would it go in the node setup? I would be interested in doing this since the mask only has to be over a 16x16 area. – meed96 Jun 28 '15 at 01:46
  • If you created a Black and White Mask Texture in photoshop, where all white parts were representative of the lava, and all black the rock, then you could use this mask texture inside of blender as the fac input of a Mix Shader node to differentiate between 2 different materials :) – Hexbob6 Jun 28 '15 at 01:52
  • 1
    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 01:53
  • I think it should do, yes :) – Hexbob6 Jun 28 '15 at 01:58
  • Hey @meed96 , sorry i haven't managed to get round to the answer today, but if you're still having any issues I could have a go at one tomorrow? :) – Hexbob6 Jun 29 '15 at 01:28
  • Nope, got it figured out. But if you want to write an answer you'll probably get the selected answer. – meed96 Jun 29 '15 at 01:29
  • Well yknow I do like getting selected answers... ;) I'll see what I can do! Do you mind me asking whether you reached the solution through a photoshop B/W mask, or whether it was through Gandalf3's method in the end? :) – Hexbob6 Jun 29 '15 at 01:32
  • It was a gimp b/w :) – meed96 Jun 29 '15 at 01:33
  • 1
    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 01:38
  • That is the goal of SE :D – meed96 Jun 29 '15 at 01:38

2 Answers2

10

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.

Process1


Creating a Mask Using Photoshop

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

PSD1

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

PSD2

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.

PSD3

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.

PSD4

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.

PSD5

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.

GIMP1

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! :)

GIMP2

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.

GIMP3

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.

GIMP4

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.

Blender1

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.

Blender2

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! :)

Blender3


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

Final Result1

Hope it helps!! :)

Hexbob6
  • 2,038
  • 1
  • 19
  • 27
6

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:

enter image description here

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⇧ ShiftLMB LMB on any node.

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

gandalf3
  • 157,169
  • 58
  • 601
  • 1,133
  • 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 01: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 01: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 01:33
  • Haha, I just figured that out and edited your answer to include the details. – meed96 Jun 28 '15 at 01:34
  • 1
    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 01:48
  • You can try creating your mask using the Input->Geometry->Pointiness node tool. Set it up the same as shown above. It will allow you to make the recessed lava areas glow and should closely match the models contours. Adding or removing a subdivision modifier will influence the results. :) – MarcClintDion Jun 29 '15 at 00:43