MART Term 2, Lecture 5
Beginning Texturing

Render View & Render Settings

Today we're going to be rendering scenes using the Maya software renderer, rather than just using OpenGL rendering in a viewport. Open up the following file:

rendering-ball.ma

This is the room scene that we lit last term. In order to try rendering it, click on Window → Rendering Editors → Render View. Make sure it's set to Maya Software, and click on Redo Previous Render (the leftmost button).

[screenshot: MART_T2L05_html_m7a1e6cb7]Now we have our rendered image. At the moment it doesn't look so different from our playblasted image, but that will change.

Notice how the line between the two walls is a bit jagged? It should be dead straight. This is caused by aliasing: when two different colours get drawn, a jagged edge is formed at pixel level. Maya can use a variety of methods to try and overcome this problem, collectively referred to as antialiasing. Cue an explanatory image stolen from the internet:

Antialiasing is a VERY big topic and the mathematics can get quite complicated: let's have a look at the basics as implemented in Maya.

Click on Open render settings window (fifth icon along). The first tab contains useful sections such as the file name that Maya will render to, file format, and the resolution of the images. Let's look at the second tab, titled Maya Software: we're going to look at the first set, labelled Anti-aliasing Quality. This contains a lot of options, and we're not going to investigate them in depth: we're just going to try changing the preset Quality values. By default it is on Preview Quality: let's move it up to Production Quality.

[screenshot: MART_T2L05_html_m78e5550c]Before you press render again, press the Store Image button (near the end, next to the 1:1 button). This will keep a copy of the current image in the render view so that we can compare our new version with our old one. Now press render again and try scrolling backwards and forwards between the two. The antialiasing has smoothed out the line, at the cost of making it slightly blurred.

[screenshot: MART_T2L05_html_m68fd0019][screenshot: MART_T2L05_html_m78f5d63e]Notice that we still get jagged edges on our shadows: the jaggedness on the shadows is due to using depth mapped shadows. Go into the attribute editor for the light, and try changing the Dmap Resolution (in the Depth Map Shadow Attributes section), and you'll see what I mean: the higher the resolution, the more accurate the shadows.

Texturing

[screenshot: MART_T2L05_html_61be50f2]Let's have a go at texturing. We'll do this on a new scene: firstly, get a sphere and a spotlight, and point the spotlight at the sphere. Now add a material to it by holding down the RMB on the sphere and going to Materials → Assign New Material → Phong. Get a render view of it up.

Depending on the shading model, a material has up to three distinct shading types:

Shading Models

We will look now at several different shading models that are implemented in Maya. I'm sure you'll go through the maths of them with someone at some point, so I won't go into it now (it's clearly not because I don't know it).

In the attribute editor of the sphere, go to the phong1 tab, and change the Type to each of the following in turn: I will discuss a select few of the parameters of each shading type. You can switch to high quality rendering in the viewport if you like, but be sure to have a render view up too: refresh it each time you modify something.

This is the simplest shading model. It does not react to light in any way: it is always exactly the same colour. You cannot cast shadows onto an object with this shading model. The Out Color attribute is the main colour, and the Out Glow Color can create some interesting effects (but be careful not to overuse it).

This is the next step up: it incorporates diffuse illumination, but does not have a specular highlight. We have several different attributes for it: Color is obvious, Transparency is also fairly evident (though it can be confusing that this is a colour too, not just a single value). Ambient Color is the colour with which the surface responds to ambient lights in your scene. We'll come back to some of the other attributes later.

Our first journey into the world of specular highlights is using the Phong shading model. This gives us that characteristic white spot on, for example, a snooker ball. It is a cheaper way to simulate direct reflection of light off the surface.

In order to speed things up a little, let's try using IPR rendering. IPR stands for Interactive Photorealistic Rendering, and it is a way to both cut down the amount of time spent rendering tests, and to automatically update the render view without having to click update. Click the Redo Previous IPR Render button. This will take longer to render the first time, but once it's done once it will be quicker. Now draw a box over the area that you want to adjust: for example, I'm going to draw a box over the area surrounding the ball.

As you can see, the top box of attributes are exactly the same as those in the Lambert shader, but we now have a new box underneath called Specular Shading. This allows us to change the size of the highlight (Cosine Power), the colour and therefore the brightness of it (Specular Colour), as well as raytraced reflections from the surface (Reflectivity and Reflected Colour). There are three very good reasons that we can't see any raytraced reflections at the moment:

  1. IPR rendering cannot do raytraced reflections

  2. Raytracing needs to be turned on in the Raytracing Quality subsection of the Maya Software tab of Render Settings

  3. We currently don't have any other objects in our scene to be reflected

[screenshot: MART_T2L05_html_4c7cd329]If we correct all of these problems (go back to normal render rather than IPR render), we get some beautiful reflections on our sphere.

The only difference between the Blinn shader and the phong shader is in the specular highlight: the Blinn's specular highlight tends to be softer. It behaves similarly to the Phong, but is calculated differently and has different attributes.

This gives an effect like brushed metal, with a highlight that is longer in one direction than the other.

Texture maps and Refraction

Let's go back to the Blinn shading model and try some things out with it. We'll try to put some refraction on it: refraction occurs when a transparent object (such as water or glass) bends light, creating a distorted image. Bear in mind that (raytraced) refraction and reflection are very expensive, and not always necessary: if, for example, you're making a window, the depth of glass will be so thin that the refraction will probably not be noticeable. In this case, it is probably prudent to remove the refraction altogether.

[screenshot: MART_T2L05_html_31e4adcd]In this case we're going to use refraction, so we need to have something to refract: let's create a sky-sphere. Create a sphere, make it very large, and assign a new surface shader material to it. Now, on the Out Color attribute, click on the little chequerboard next to the slider. This pops up a Create Render Node window, which allows us to apply either a procedural texture or an image map: we'll do the latter.

[screenshot: MART_T2L05_html_m135f2871]Click on File. Now things get a little complicated: we have to decide how the image is projected onto our object. Since we have a sphere, the spherical projection type would seem to make most sense. Now we need to find our image: click on the little triangle arrow thingie next to the Image slider. This brings up our file node, and we click on the little folder next to image name to find it. You can apply any image you like, but I'm going to use this one:

testsphericalmap.jpg

[screenshot: MART_T2L05_html_1f809d1f]Now go back to our sphere's Blinn shader. Let's add a little reflection (about 20%), and then put the transparency up to about 80%. This gives us a nice reflection, but no refraction. We have to set the refractive index: this is how much the light gets distorted when it passes through the sphere. Some example values:

In the Raytrace Options subsection of the Blinn, you'll find Refractive Index. Change it to whichever you like: I used 1.5.

For the sky-sphere, we had a map for the colour of the surface shader: it is possible to attach a map for virtually any attribute. For example, now let's try applying a transparency map, which controls how transparent the surface is at each point.

For this, we'll turn off the refraction. Do this at either of the points that we had to turn it on: in the shader or in the render settings.

[screenshot: MART_T2L05_html_6e045c8e]Click on the little checker board next to the transparency colour in the Blinn node. We could use another image, but this time let's try using a procedural texture. In the 2D Textures section, click on Checker (make sure the selection at the top is "as projection" and not Normal). Now change the Proj(ection) Type to Spherical (we do have a sphere, after all). This lets us see through bits of our object, but notice that reflection and specular still appears on the surface of the "invisible" bits. Let's get rid of that.

Open up Window → Rendering Editors → Hypershade. Have a look around: if you hover over the arrow going between projectionX and blinnX, you should see that it connects outColor from the projection to transparency of the blinn. If we also connect it to the specular color and the reflected color, it should remove the slight weirdness that we currently have. Middle-drag from one to the other, and select Other... from the pop-up menu. Now we have a connection editor, and we can select specularColor and reflectedColor. When we render this, we see that it's the wrong way round: it has removed the specular and reflectivity from the opposite bits than we wanted it to, because the checker is black where we want it to be white and vice versa. We can either make a new checker, or (better) invert the colours in our checker (using the General Utilities / Reverse node) so that it's the correct way round.

Once we've made a material, it is very easy to put it on more than one object: you can either select the object, RMB click and hold on the material in the hypershade and Assign Material To Selection, or you can RMB click and hold on the object in the viewport and go to Assign Existing Material.