2 August 2010

Basic Materials & Lighting


Introduction:

This tutorial will be focused on teaching the basics of using and creating materials in 3ds Max. To begin, the main thing that I want to express is that in order to discern materials in a 3D scene, you have to have lighting. You can’t simply avoid this step. You should have at least a basic lighting rig setup that comes close to the scene that you will be using. How else will you be able to tweak the parameters of the materials if you do not know how light is affecting your object?

I am not going to go into detail here about how light works; here is a link for more information on this matter:http://en.wikipedia.org/wiki/Light

For argument’s sake, let’s just agree that we need light in our scene before we begin dealing with materials. Here we will create a version of the most basic light rig, the 3-point lighting setup.

We will look at how to create a basic lighting rig, using just the Scanline Renderer in Max. We then will begin to look at how to setup your materials. I will also show you how to use just about every map slot in the material editor and what they can be used for when it comes to your 3D scenes.


Basic Lighting Rig:

First, let’s create our light rig. Fire up Max and let’s create a Target Direct light in the Perspective View. Left-click once to create the actual light source out on the parameter of the home grid, then drag out to the centre of the grid and left click again to create the light’s target. Hopefully I won’t have to explain in detail the step of creating a light anymore. We are going to create an exterior scene so this first light will be our sun, hence the use of a Direct light (Fig.01). More on this in a minute.

(Fig.01)

We have created the first light of our 3-point lighting setup. Here is an example of what we are going for from Wikipedia (Fig.02).

(Fig.02)

So now that we have our main Key light, which in this case is going to represent our Sun, we can easily create the rest of lights. Notice we didn’t move the light at all; it is resting flat on the Z axis. Again, this will help us in our total creation process. Okay, while holding Shift and using the Move tool, go ahead and move our Direct light over to create Fill light 2 to reflect Fig.02, and rename this light Fill Light 1 (Fig.03).

(Fig.03)
While we’re at it, we might as well rename our first light to Key Light.

Let’s go back to our first Fill light and go ahead and copy it over to make our second fill light (
Fig.04).

(Fig.04)


Now we are going to add one more light and this is going to be our Backlight. This light is going to be used to give our scene or more importantly our main objects, i.e. characters, a little backlight to better separate them from the background.

This will be used on a per shot basis, more on this later as well.

Go ahead and copy our fill light once more and place it in our fourth position and rename it Backlight (
Fig.05).

(Fig.05)


Good, here is the basis for our lighting setup. Now it is time to go in and start tweaking.

For this we obviously are going to need some geometry. So here we go:

Create a sphere and a plane so that you have this now in your scene (
Fig.06).


(Fig.06)


Alright, now that we have base geometry, let’s go in and start tweaking our lights. Here is where you need to focus on principles and not so much on where I place this light or how much I change some value.

Each lighting setup you create will be adjusted based on each scene.

First let’s move our Key light up to around 50 units on the Z axis, our fill lights to around 25 or so and our backlight a little higher than them all. Remember, you determine the placement when it’s your project so don’t get concerned, just try to replicate this as quick as you can (
Fig.07).


(Fig.07)


What you should notice now is that our lighting is very blown out. Here is a quick render (Fig.08).


(Fig.08)

Not too realistic. The main problem right now is how the lights are behaving. They all look like spot lights in a theatre. Here is where we need to start adjusting the Intensity, Falloffs and Attenuation.

First we are going to deal with the Intensity of the lights. A quick and easy way to adjust all of the lights is by using the Light Lister. This is found under Tools > Light Lister. In here you will find a lot, but not all, of the main controls used to adjust lights. I want you to go in and make these changes (
Fig.09).


(Fig.09)


Okay so what did we do? Well first we lowered the Multiplier, thereby lowering the overall intensity being projected by each light. Then we changed the colours – should be self explanatory. We then set Shadows to Cast by checking the box, and then set each light to their particular shadow method. Notice that only our Key Light is using Raytrace shadows. Remember that this is our Sun and its shadows should be accurate and the most dominate. Then we lowered the Map Size to 256 on the rest of our lights (this saves rendering times) and set our Sm. Range, Sample range, to 30. This will make our shadows blurry. Now let’s render (Fig.10).

(Fig.10)


Notice how much difference this has made.

Keep in mind that we haven’t dealt with the spotlight effect yet, we’re still getting our intensity, so keep your pants on.

Now, just for illustrative purposes, here is the same render with this change – Sm. Range = 1.0 (Fig.11).

(Fig.11)

See how sharp the shadows are now? Told you it would make the shadows blurry! Okay, let’s deal with the spotlight effect.

Select our Key Light; go to the Modify Panel, find the Directional Parameters rollout and check Overshoot (
Fig.12).


(Fig.12)


This tells Max to ignore the Hotspot and Falloff settings altogether and make this light emit as if it were so far away (like the sun) that these parameters would be useless.Now go ahead and do this for all of the lights. Here is what your render should like now (Fig.13).

(Fig.13)


And just like that, the spotlight effect is gone.

I need to caution you here on this one: having every light in your scene is a great way to achieve an effect like this, but you start getting a lot of geometry in your scene, start having geometry very spread out like in a wide open exterior scene, and have all of your lights set to overshoot and they are all casting shadows … don’t expect render times to stay low.

With that in mind, let me show you how to manage this. The goal here is to achieve the same effect as the rendering above but without setting all of the lights to overshoot.

First I’ll select one of the Fill lights; typically I always leave the Key light set to overshoot.

Then I’ll go in and adjust the Hotspot and Falloff settings (Fig.14).


(Fig.14)


I gauge this by watching the outer rim of the light. Once it has gone just past my scene geometry I stop increasing it; I also always give it just a little bit more of a bump just to be safe.

For example, 75 for hotspot worked and covered my scene, but I set it to 100 just to be safe (Fig.15).


(Fig.15)


Now I go in and make this change for the rest of my lights, remembering to leave my Key light alone.

Here is my new render (Fig.16).


(Fig.16)


Lighting is the same, but with one added benefit … notice the shadows from the fill lights and backlight? See how the shadows are more of a circle around the sphere in the picture on the left versus the one on the right? So not only did we save on computing times but we also generated shadows more attuned to what we need. By focusing the power and range of the light we also control how the shadows are created. Remember that with a light set to overshoot, we’re telling Max to treat the light as if it was coming from a very far off distance. With this being the case, shadows would be handled differently.

One last area to discuss and we can move on to materials.

What is the difference between Direct lights and Spot lights? Here is the best example I can muster (Fig.17 – 18).


(Fig.17)
(Fig.18)

Any questions, anyone?

Remember this is the basics of lighting: here is a good book to get if you want very in-depth coverage of the topic (Fig.19).


(Fig.19)


Okay, hopefully this gives you a good starting point for lighting. How you set it up and what you do with it is completely up to you when you work on your projects. As far as I’m concerned, it’s time for Materials!
The Basic Materials:

Now that we have lights, it is time to begin to look at how materials figure into this whole equation.

There are whole books dedicated to creating materials, and this book by Pete Draper is one of the best when it comes to really seeing how powerful the materials can get (Fig.20).


(Fig.20)


However, it can be a bit much to handle if you don’t have a firm understanding of the basics first. Basically that’s what I’m here for!

What we are going to work on here is the setup, concepts and implementation of how I believe you should go about creating your materials.

First off, a material is not a map and a map is not a material!

I’ll explain as we go:

Go ahead and open the Material Editor (M on the keyboard) (
Fig.21).


(Fig.21)


So to sum up: a Material is made up of maps. Maps by themselves are nothing. Please don’t forget this!

Now on to our first Material!

First thing we are going to do is setup our base colour, this will be our Diffuse map. I want you to use this image (
Fig.22).


(Fig.22)


(Right-click on the above image, Save Image As, and save it as “SlimyMetal_diffuse.jpg”)

Note: this image and the ones to follow were found from this website: http://www.filterforge.com

Now I want you to load this image into your Diffuse channel. For those that might be unfamiliar with how to do this I will explain it once and then it is up to you to remember (Fig.23). If you are good on this point skip down to the next step.
    1. In the Material Editor open the Maps rollout under the first free Material slot
    2. Click None in the Diffuse channel
    3. Double Click on Bitmap to chose this as the map type (more on the different types of maps later)
    4. Load the SlimyMetal_diffuse.jpg

(Fig.23)


You should now see this in your Material Editor (Fig.24).

(Fig.24)


All we have to do now is assign the material to our object and we can continue.
With the proper Map loaded into our Material let’s go ahead and assign it to our sphere. Select the sphere in the scene and press the Assign Material to Selection button – it only highlights if you have something selected (Fig.25).

(Fig.25)


Once we assign the Material we want to be able to see our map so we next tell Max to show the map in the viewport by pressing this button (Fig.26).

(Fig.26)

Good, you should be way caught up to speed now. From now on I am going to assume you get how to do this.

With the material assigned and viewing the map we can make further changes to how the map is “mapped” onto the surface. The simplest, and sometimes most efficient – yet not always the best – way to make a quick adjustment is by changing the tiling right here in the Material editor. What I want you to do is this: change the Tiling under the Coordinates rollout to 3 on both the U and V coordinates. As you can see, we are now telling Max to repeat the base image along the surface 3 times, also known as tiling (
Fig.27).


(Fig.27)


The problem with this method is that we have changed the whole material. This means that every object in our scene that gets this material assigned will have the image tiled 3 times.

If you want one object to have it tiled 3 times and another 20 times then you will have to apply a UVMapping modifier to the one you want tiled more and adjust the tiling in the modifier. This is actually a preferred way to do this because you really should handle Mapping coordinates on a per-object basis, but for now this method will work for our needs. Or you could make a duplicate of this material and change the tiling just on the copy and assign that to the other object but hopefully you can see the redundancy and the waste of time in that method.

Now we need to go back to our main material level. Do this by hitting the Go to Parent button (
Fig.28).


(Fig.28)


Here, at the top level of the material, we will do what I tell my students is the absolute least you can do when making materials: copy the map in the diffuse channel to the Specular Level channel and the Bump channel. To do this just click and hold on the map in the diffuse channel and drag it to the Specular level channel, choose Copy when asked and then do the same to the Bump channel and again choose Copy (Fig.29).

(Fig.29)


As I said this is the least effort you can put into making you materials. Why? Because you have given Max enough information to simulate a basic material.

Let’s take a look at the render now to examine. I’m going to zoom up to sphere so we can see the details a little better.

Let’s compare (Fig.30 – 31).


(Fig.30)
(Fig.31)

See the difference? Diffuse with no specular or bump is just plain flat. This is what most of my students seem to do and they wonder why their renders are so flat.

By just copying channels we bring so much more realism to our objects, but like I said this is the least you should do.

Now, I didn’t add a comparison render showing with diffuse and just specular because adding the bump doesn’t change much at first. However, let’s play with that now.

In the Maps rollout, go down to the Bump channel and raise the Amount to 120 (
Fig.32).


(Fig.32)


Here is the render

(Fig.33)
(Fig.34)

Here the only thing we have done is increased the amount the Bump channel is effecting the whole material. But as you can see our sphere seems to have a little surface texture with 120 as compared to 30.

This is a lot better but the downside is that we are using the same image for all three channels. The Specular Level and Bump channel convert images into grayscale and thereby uses black and white to determine how much effect is seen.

This generally is not accurate. This is what we get (Fig.35 – Specular and Bump).


(Fig.35)

While at first this might not seem that bad, notice how there is basically no whites in the greyscale image. This means that nowhere on the surface will we find full effect.

What I want you to do now are save these images so we can experiment (Fig.36 – Save this as SlimyMetal_spec.jpg, and Fig.37 – Save this as SlimyMetal_bump.jpg).


(Fig.36)
(Fig.37)

Hopefully you can already see the major difference, so let’s go ahead and use them. Back in the Material Editor, go into the Specular Level channel and load in the SlimyMetal_spec image. Do this by clicking on the Bitmap slot under the Bitmap Parameters rollout and then go and choose the correct image (Fig.38).

(Fig.38)

Now the correct image is loaded (Fig.39).


(Fig.39)


Repeat this for the Bump Channel and load in the SlimyMetal_bump.jpg.

Once you’re done, go back to the top level of the material, this is what you should now have (Fig.40).


(Fig.40)


Now we have a specific image for each specific channel. Let’s render (Fig.41).

(Fig.41)


Might not seem better, but it is; we will need some further tweaking of amounts to really see the difference (Fig.42).


(Fig.42)


And here are the same amounts applied to the material with just one image for all three channels (Fig.43).


(Fig.43)

Conclusion:

I hope by this point that you can see and understand why it really does make a difference when you make specific images for specific channels.

Each channel has a different purpose so treating them as such is the trick to generating better and more realistic materials.

If you look at the render in Fig.42, I really want you to notice how where we see the green moss on the surface, we don’t really see any specularity. This is very true to real life: impossible to get without creating and using specific maps.


More Map Types :

Let’s continue experimenting with some of the other map channels so you get a feel for what they do.

Save this image as SlimyMetal_spec_color.jpg (Fig.44).


(Fig.44)


Now, using the same technique as before, copy one of the bitmaps from any of the three channels we are already using and replace that current bitmap image with this one. Here’s what you should get from the render (Fig.45).

(Fig.45)

Now we can control what colour shows up in the Specular channel.

On to the Self illumination channel. Go ahead and save this image as SlimyMetal_selfIllum.jpg
(Fig.46).

(Fig.46)

In the Material Editor, copy one of the bitmaps from any of the other channels into the Self illumination channel.

Note: by copying the maps into other channels we save ourselves the step of having to choose Bitmap, and then choosing the specific images.

Next, load up the SlimyMetal_selfIllum image in that channel.

Currently the effect is not going to be that dramatic.

What I want you to do is go back to the top level of the material, scroll up to the Blinn Basic Parameters rollout, and check the box next to Self illumination. Upon doing this you will notice that now the effect has really taken hold (Fig.47).

(Fig.47)


And here’s the render (Fig.48). Imagine this for a spaceship’s onboard lights.

(Fig.48)


    Next let’s look at the Opacity channel, here’s your image (Fig.49 – SlimyMetal_opacity.jpg).

(Fig.49)


Now repeat the copy of the bitmap into the Opacity channel and load this new image.

Here’s the render (Fig.50).

(Fig.50)


What’s important to note here are the shadows; the only reason our shadows show up is because our key light is set to Raytrace shadows. You could also check the 2-sided box under the Shader Basic Parameters rollout and get something like this (Fig.51).


(Fig.51)


Now we can see through to the inside of the sphere.

The last channel we will look at is going to be the Reflection channel. With this we are going to introduce a new Map Type: the Mask map.

Find your Reflection channel in the Material Editor and again copy into it one of the bitmaps from another channel. Now go into that channel by pressing the channel button (
Fig.52).


(Fig.52)


Now in here, press the Bitmap button at the top right corner (Fig.53).

(Fig.53)

This opens the Material/Map browser.

In here double click on Mask and when prompted choose Keep old map as sub map.

This loads the Mask Map into the current slot and loads the previous Bitmap map into the first channel of the Mask Map (Fig.54).


(Fig.54)


Okay, what we want to do here is create a reflection channel that reflects the environment but also includes the exclusion of the holes in our sphere as well as the self illuminated mortar of the bricks.

So to do this I want you to drag the Bitmap from the Map slot to the Mask slot and this time choose Swap when prompted. Now go into the Mask Bitmap and load in this image (
Fig.55 – SlimyMetal_reflectionMask.jpg).


(Fig.55)


You should now have this at the top level of the Mask map (Fig.56).

(Fig.56)


So now we have setup the image that is going to mask whatever we want to reflect. In order to create the reflection we need another new type of map.

In the Map slot here in our Mask map, press None and then choose Raytrace for the Map type. Inside the Raytrace map you can leave all of the settings alone, they’re fine the way they are. Go all the way back up to the top level of the material. We are going to need to make a few tweaks in order to really see what we have just done with this last map. Make the following changes (
Fig.57).

(Fig.57)


Notice I unchecked 2-Sided, and the Specular Color. I also lowered the Specular Level and Bump amounts.

Here’s the render – yes, I added a teapot and a material to the ground plane. You really shouldn’t have any trouble with that (Fig.58).


(Fig.58)


As you can see, we are reflecting the environment around the sphere but also not reflecting where the self illuminated mortar is or where we have holes.

One last thing I want to show you before I leave is the Blend Material.


The Blend Material:



The Blend material does just what its name suggests; it blends different materials.Let’s take a quick look.

At the top level of our material, where it says Standard (telling us that we currently are using a Standard Material), press the button and choose Blend from the browser. Again, select keep old map as sub map. Now you should have this (
Fig.59).


(Fig.59)

So we now have as the first material, the material we just made (01-Default Standard). We can obviously load in a new material and also if we like choose a Mask map to blend the two of them. Since we are going to keep this simple we will not make another complicated material not will we use a complicated Mask map.

Go inside of the Material 2 slot. This will open the Standard material there. In the diffuse channel I want you to load in the SlimyMetal_bump image. You should have this (
Fig.60).

(Fig.60)

Notice that the thumbnail didn’t change, don’t worry though, this is because at the Blend level we don’t have this material set to really do anything. Remember this is the second material that is going to be blended. As it stands right now, we aren’t blending anything.

Let’s go back up to the Blend level now.

Now for the Mask, load into this channel a Gradient Ramp map. This is what it will look like (
Fig.61).


(Fig.61)


Now make these changes (Fig.62).


(Fig.62)


Now, see where the middle slider is in the actual gradient image (Fig.63)?


(Fig.63)


Double-click on this slider and change the colour to white.

Before you render away, change the Noise Size to 3. Here’s your render (Fig.64).


(Fig.64)


As you can see, we have blended 2 different materials together. It really is up to you on what you do with this. Here I have gone back into the 2nd material and set it’s opacity to 0, making it invisible and here’s what I get (Fig.65).


(Fig.65)

Conclusion:

I hope that this has helped you gain a little more insight into how the Material Editor works and how to set up basic lighting.

I will continue to write more tutorials on materials and lighting setups, but for now I’m done. Practice what you have learned; it really is the only way to know it.

Keep in mind, too, that these procedures are just for guidance; if you find a way or a method that gets better results then go with it. I never try to say that this is how things must be done, I just want to point you in the right direction and get you rolling.

See you next time!



No comments:

Post a Comment

Follow on Buzz