Adding ray trace shadows and mental ray sun sky to the bottle.

This is a continuation of the previous blog posting.

Ray trace shadows.

First, we switch from Depth Map to Ray Trace shadows:




Here is what we get:


We see that the shadow is softer.

The Mental Ray sun and sky.
Now, we go into the Options settings of the Render View window and click on Physical Sun and Sky, which introduces a special shader, along with some added lighting:

Now, we get this:



Notice that the added light from the Mental Ray Sun and Sky material is completely washing out the table on which the bottle sits.  We would have to work with this to get it looking good.

Adjusting the Resolution attribute of a Directional light in Maya.

Shadows as roots.

In the video tutorials on 3DbyBuzz we took several looks at shadows and how they root objects in a scene so that they don’t seem to be floating in the air.

Shadow resolution.

Here, we look at adjusting the resolution of a shadow. First, we create a Directional light by going to Window on the top menu, choosing Rendering Editors, and selecting Hypershade.  Then, inside the Hypershade window, we choose Create, then Lights, then Directional Light. Directional lights are meant to model sunlight, i.e., light that is moving in parallel rays across the scene. With the light selected, we then hit control-a once or twice, until the Attribute Editor of the light appears. We set the shadow Resolution to 512 and choose Depth Map shadows:


  Then we render our scene, which consists of a glass bottle sitting on a countertop:


We see that the shadow of the bottle is quite jagged.
So, we change the resolution to 4096:


We render the scene again:


The shadow is much smoother now.

The renderings were made with the Mental Ray renderer within Maya.
Depth map shadows, as we have seen in the video tutorials on 3DbyBuzz, are sharper than the alternative, Ray Trace shadows.
Finally, it’s important to note that a Directional light, because it is spread across the entire scene, usually needs a higher shadow resolution than other lights in Maya.

Using the Penumbra and Dropoff settings on a Maya spotlight.

The spotlight and its attributes.

In the video tutorials on 3DbyBuzz, we make use of spotlights, but we are limited mostly to adjusting the Cone Angle attribute and the Intensity attribute.  Here, we will look at two other important attributes: Penumbra and Dropoff.

Three lights in the closet.

We will use the closet scene we have seen several times in the tutorials and on this blog. Here are the lights in the scene (shown in the Hypershade, by going to Window, and choosing Rendering Editors).  There are two soft point lights inside the closet and a spotlight positioned outside the closet and pointing directly at it.  The spotlight has a cone angle of 94.


Spotlight attributes.

Below is the Attribute Editor that pops up if we select the spotlight in the Main window and then hit a control-a once or twice.


So, just what is Penumbra?

The penumbra is the part of a shadow where some light makes it past whatever is casting the shadow.  It is a softer, gray shadow around the edges. So, we see below that a larger penumbra setting gives us a more gradual edge to the spotlight. And likewise, a penumbra of 0 creates a harsh edge to the light.  Without penumbra, there is no grayish zone.

Below, the Penumbra is set to 10 and the Dropoff at 0.


Below, the Penumbra is set to 0 and the Dropoff at 0.


Below, the Penumbra is set to 10 and the Dropoff at 94.
We add a drop off setting here in order to point out that the rate at which the light degrades as it moves through space also has a very powerful impact on the shadows cast by a light.  This is done by limiting the amount of light that touches an object.


Sculpting geometry with Maya with the Soft Modification tool.

Organic, hands-on model crafting.

In the video tutorials on 3DbyBuzz, we look at the Sculpt Geometry tool in Maya.  It is a key tool for folks who want to have that sense of crafting an object in a direct, hands-on fashion, almost like you are working with clay.

ZBrush and Mudbox.

This is an important issue, today, as more and more animators move toward Pixologic ZBrush and Autodesk Mudbox – both of which offer an organic sculpting capability for crafting models.  Many animators are creating their characters in one of these applications and then importing them into Maya for refinement, applying materials, and then animating. ZBrush is more popular and more powerful, and offers a Maya plugin.  Mudbox, as it is a companion product to Maya, has a built in workflow that allows the modeler to move smoothly between the two applications.

The Soft Modification Tool.

While the Sculpt Geometry tool, which uses a painting metaphor and can be used with polygon, subdivision, and NURBS models, is very popular, there is another tool in Maya that is also quite powerful. It shares something with the Sculpt Geometry tool, and with another tool that we have looked at in the video tutorials, the Soft Selection Tool: the Soft Modification tool can be carefully tuned to have a drop off effect on geometry surrounding the point of application of the tool.  (The Soft Selection tool is also covered in 3DbyBuzz.

The settings.

This is how the Soft Modification Tool can be activated:


Here are its settings:


Note that the top slider controls the falloff radius.

Using the tool.
Below, we see what happens when we right click, go into Object mode, and select the Moai model we have used in the tutorials and in this blog.  It does the same thing that the Soft Select tool does, using a rainbox of colors to tell us how far outward the tool will have an effect.



It is important to note that the tool needs to have a very low setting on the slider in order to make your modifications localized.

Using Maya expressions and variables to animate models.

In the video tutorials on 3DbyBuzz, we look at using a simple Maya expression to rotate a door knob.  In this posting, we reexamine this and then take a look at two other expressions. Then, at the very end, we’ll look at a few useful MEL system variables, and at defining user variables.

Example 1: Expressions in Maya and the doorknob.

There are many cases in which keyframing the motion of an object is very difficult, in particular, in situations that require precise, cyclic changes in the attribute of an object, or in the relationship between two or more attributes. In the image below, the knob on the door is selected, and then we have right-clicked on the Rotate attribute.  This brings up the Edit Expression option.



The expression editor.
Selecting this in turn brings up the Expression Editor:



We have entered an expression in the Expression Editor – it tells Maya to change the value of the rotation attribute along the x axis over the course of the frames that appear on the timeline.
Specifically, Maya is told to rotate the knob through an entire 360 degrees.
We then hit Create on the Expression Editor.

Example 2: Applying an expression to the visibility attribute of an object that has a material with a glow intensity.
Let’s do another example.

The foggy street.
In the video tutorials on 3DbyBuzz, we made use of a street scene, with a sidewalk, pavement, grass, and fog.  We inserted the of lights of a car.
What we’ll do here is color those lights, one red, and one blue, and then have them flash on and off randomly.

Lights that are not lights.
Here’s the important point, though: these “lights” are actually spheres with blinn materials that have a glow intensity.  They are not Maya lights.  Here is the attribute editor after we have selected the blinn material for one of them:



What we will apply our expression to is the visibility of the two spheres – not to the material on the spheres.

Assigning an expression to the visibility of an object.
Below, one of the spheres has been selected in the main window, and we have opened up the Expression Editor by going to Window at the top of the Main Menu, selecting Animation Editors, and then choosing Expression Editor.  Then we clicked on the visibility attribute in the second column from the left.
Here is the expression after we have typed it in and hit Create:



The expression makes use of a random function with reevaluates the visibility of the sphere for every frame.  This is a great function to have – because one of the most difficult things to do is to generate what appears to be random values.

We then must do the same thing to the other sphere.

The result.
Finally, here is a sequence of three frames, taken across a series of 30 frames:




Now, we have flashing emergency lights, perhaps from an approaching police car.


Example 3: our squashing ball.
In a previous posting of this blog, we looked at using a Squash deformer to flatten a ball when it hits the ground.
You might remember that we also wanted the ball to stretch out as it rose up.  We did this by using the scale tool and keyframing the ball stretching out as it went up.
We’ll do this again, but in reverse, and not by using the scale tool.  We will use a squash deformer when the ball hits the floor, as we did before.  But we will use an expression to stretch the ball out as it comes down.

The stretch expression.


The result.



Notice the squash deformer, which we introduce just before the ball hits the ground:


Useful MEL variables and user defined variables.
System variables.
Here are some useful facts about MEL variables:
currentTime is a system variable which contains the current timestamp.
frame is a system variable which holds the current frame number – this is very useful, since expressions get evaluated on every frame.

User defined variables.
Variables created by the programmer, always have a $ in the front, e.g.: int $buzzint;.
Keep in mind that after the $ there has to be a character, and not a number.
Another example of a use variable: float $buzzarray[] = {1.1, 32.2, 23.3, 14.4, 45.6}; 
One more example: matrix $buzzmatrix[9] [2] ; 
There are also local and global variables.

Local variables.

Here are two local variables:
{ int $kingint = 1; int $buzzint = 0; if ($kingint = 1) print ($buzzint); }; The squiggly parens mark the scoping of the two variables.

Global variables.
This program will print the same result as the one above, but it contains a global and a local variable:
global int $kingint = 1; proc buzzproc() { int $buzzint = 0; if ($kingint = 1) print $buzzint; } buzzproc();

Control structures.
Lastly, we note that MEL has a handful of control structures.  Here is an example:
global int $kingint = 1; proc buzzproc() { int $buzzint = 0; while ($buzzint < 3) {print $buzzint; $buzzint = $buzzint – 1; }; } buzzproc();
Note that this program will run forever…

Using anisotropy with mental ray to control the transparency of frosted glass.

In the video tutorials on 3DbyBuzz, we used the mental ray mia_material and its frosted glass preset to create frosted glass doors for a closet.

In this posting, we focus on one particular setting for the frosted glass, Anisotropy.
Anisotropy is an attribute that can be set in the mia_material attribute box.  This controls highlights that run across the scene in multiple directions.

Anisotropy settings.
In the image below, we see the Anisotropy settings for the mia_material that makes up the frosted glass of our doors.


Set to 1.
Below is a render resulting from an Anisotropy setting of 1, meaning that the left-right and up-down values of the highlights are equal, or more precisely, that the highlights are even in all directions.
Thus, the glass doors blur the white shelves behind them.


Set to 10.

Below, the setting is 10, creating a highlight that is not equal in all directions.  In particular, the top-down highlights are softer than the left-right highlights. The effect is to undo some of the frosted effect of the glass, as the highlights don’t blur the shelves as much. You can think of it this way: in order for the horizontal shelves to be distorted to the point of not being easily visible, the white coloring of the shelves needs to be moved upward and downward.



Set to 100.

If we crank it up even more, we see that the highlights are very weak in the top-down direction (compared to the left-right direction).  So there is now virtually no frosted glass effect.


A number less than 1.

Below, we see what happens if you set the number to .1.  Now, the highlights are greater up-down than they are right-left, and the doors are distorted again.


Using ambient occlusion with a mental ray material.

In the previous posting of this blog, we looked at a few ways of manipulating light in a Maya scene, focusing on the mental ray renderer.  We looked at global illumination and final gathering, caustics, and irradiance. Now, we look at another way of fine tuning light effects with the mental ray renderer on Maya.

A sample model.

In this lesson, we will use a scene built by Dreamlight.  It is called La Piazza Realistic Mediterranean Town, and was originally built for Daz3d.  I exported it out of Daz3d as an FBX file and then imported it into Maya.  I then replaced the materials on the central tower in the scene with a mia_material that is colored a light tan.  We will only look at a piece of the scene.

Ambient occlusion.

The mia_material has a special setting called Ambient Occlusion:


Without ambient occlusion.

Here is the rendered scene, using mental ray, and with Ambient Occlusion on the mia_material settings not checked off:


Note that the left face of the tower is hidden in shadow.

With ambient occlusion.

Here is the same scene with ambient occlusion turned on:


Note that now, we can seem much of the detail on the left face of the tower.

What happened?

Importantly, remember that ambient occlusion is a property of the material that is on the tower.  The rest of the scene does not have a mia_material on it. By turning on ambient occlusion, we are telling the mental ray renderer to not let the strong spotlight that falls on the right side of the building wash out the right side and cast the left side into shadow. Importantly, there is a second light in the scene, an ambient light.  When we turn on ambient occlusion, we are telling Maya to pay less attention to the spotlight and to let the effects of ambient light effect the material.

With only ambient light and without ambient occlusion.

Now, here is a rendering where the spotlight has been turned off and ambient occlusion on the mia_material is turned off.  Left click to enlarge it:


Wow!  it turns out that the mia_material, without ambient occlusion, will not accept the effects of ambient light.

With only ambient light and with ambient occlusion.
Now, with only the ambient light turned on, but with ambient occlusion turn on in the attribute editor for the mia_material, we get the following.  Please note that the ambient light had to be made much stronger in order to light up the tower by itself:


The lesson.
With ambient occlusion turned on, and with the spotlight turned on, mental ray accepts the effects of ambient light and so the ambient light created by the spotlight and the ambient light illuminates the tower, making the detailed light and shadow of the tower more visible.
With ambient occlusion turned on, and with only the ambient light turned on, the ambient light by itself lights up the tower.

A proper rendering.
Because my manipulation of this scene does not do the artist’s work justice, here is a rendering of the center of the original scene, created by the Daz3D renderer.  Left click on the image to enlarge it:


Global illumination, final gathering, caustics, and light emitting materials in Maya, using mental ray.

In the video tutorials on 3DbyBuzz, we look at the basics of creating lights in Maya, using ray tracing, and manipulating shadows.  We also look at the rudiments of global illumination and final gathering.  And we look at depth map versus ray traced shadows. In this posting, we review final gathering and then look at a couple of new things: caustics and irradiance.  Our goal is to look at a few different ways of adding light effects to a scene. We will be using the mental ray renderer for this posting.

Global illumination and final gathering.

We use these two options to add more light to darkened areas of a scene. As a reminder, final gathering, which is an option you can set in the mental ray renderer, adds some extra computations to the ray tracer, and in doing so, fills in dark areas.  These often occur when one part of a model is casting a shadow on itself.  By using final gathering, we put some extra rays in those little spots. If we go to Window, choose Render Editors, and then Render View, we can select mental ray, and then go to the Indirect Lighting tab and choose Global Illumination. We will also turn on Final Gathering, which does a similar job, but is less effective.



 Below, is the before and after. Without global illumination and final gathering.  Notice the area around the brass bolt.




  With global illumination and final gathering.  Look at the same area:




We use caustics to create the harsh light reflections and refractions we often get when light hits a glass object. We will manipulate both the lights in a scene and the mental ray settings to get caustics. We will use a scene that we have seen in the tutorials on 3DbyBuzz.  We have a NURBS curve that has been revolved to make a dish.  On it we have placed the mental ray mia_material, with a ThickGlass preset:



We apply this material to the dish by selecting the dish in the Main window, then right clicking on the material, and then assigning it:



 First, here is a scene without caustics:



  Now, we turn on Caustics in the mental ray render settings:



Now, we turn on photon emitting in the attributes of the dominant light in the scene, which happens to be a spot light with a wide cone.  The other light in the scene is also a spotlight with a wide cone, but its intensity is much lower.



  Now, we render the scene again:



 Light emitting materials: Irradiance.

First, we choose a highly reflective material from the mental ray list of materials.



We apply this material to the dish by selecting the dish in the Main window, then right clicking on the material, and then assigning it:



Now, we turn our two spotlights in the scene down low and render. There is very little light in the scene:



Now, we turn up the irradiance of the material.

Below is the result.  We have a sci-fi goblet.



Placing fill lights in a Maya scene.

Lights in Maya.

In the video tutorials on 3DbyBuzz, we have looked at creating the various kinds of light that are available in Maya.  One thing we have not looked at is using lights as precise, local fill lights.

Fill lights.

We create lights by going to Create on the Main Menu and going to Lights. Here is a rendering of the Moai statue we have used in the videos.  The only light is a directional light.


Softening the nose shadow.

Now, we create a point light and locate it near the left bridge of the nose.



We have softened the shadow.

But, what about Volume lights?

You might think that the best kind of light to use for very refined control would be a Volume light that is set to shine inward:


But the problem is that Maya 2013 seems to have a lot of trouble rendering volume lights with either the Maya software renderer or Mental Ray.  It simple seems that the light does not exist. But if we want to use the Hardware renderer, it will work:


Using the Append to Polygon tool for connecting two stairs.

Connecting two carpeted stairs.

In one of the videos on 3DbyBuzz, we looked at connecting two carped stairs and noted that we have to model the offset of the front face of the top step from the bottom step, so that the carpet would pull backward over the lip of the top step.  We used NURBS tools to do this.

Polygon stairs.

Here we take a quick look at doing a similar thing with polygon modeling. First, we create the two planes need for two steps. Importantly, we must use the Combine tool and create one object out of the two.  This tool is found by changing the Main Menu Selector in the upper left corner of the main Maya window to Polygons.  Then we choose Mesh and then select Combine.



The planes are not connected yet, but they are one object.

The Append to Polygon tool.

Now, we go to Edit Mesh and select Append to Polygon Tool.



  Then we select the two edges of the two polygons that are closest together.


Then we hit Enter – and the two planes are connected by an angled polygon, creating the the offset of the carpet from the front of one step to the top of the other.