3D BasicsMayaShaders & Texturing

Advanced Maya Viewport 2.0 Setup

By 12. September 2016 November 6th, 2018 No Comments

In this tutorial you can learn how to set up 3-point lighting, some shading basics, and how to tweak Viewport 2.0 – Maya’s built in realtime renderer. Along the way you will find some useful tips how to set up a project and organize objects in the Outliner.

Viewport 2.0 Tutorial Result

I used the free plant model “Dandelion” from xfrog.com (direct download here), the HDR panorama “05-16_Day_C” from noemotionhdrs.net and a photo-scanned low-poly ground model which you can download here. But any other assets can be used to follow this tutorial.

Set up a new project with > File > Project Window. Click “New”, type in a name in “Current Project” and change the Location if appropriate. As soon as you hit “Accept” Maya automatically creates a set of folders on your drive.

2017_projectwindow

Copy the downloaded files to the newly created sourceimages directory. Back in Maya go to > File > Save Scene As … type a name and save the file to the “scenes” directory. The idea behind the Project folder is, that files associated with the Maya scene like texture maps are stored in one place. If you or someone else want to work with this project on another computer then you just copy the complete project folder containing sourceimages, scenes, etc. to the new place. To switch the project in Maya choose > File > Set Project, navigate to the project folder you want to work with and hit “Set”.

2017_SaveAs

Now > File > Import the Maya file “GC17_3.mb”. The plant should approximately cover the base grid. It consists of 24 lines in x and z direction with a distance of 1 cm (Maya’s default units are centimeters). 24 x 24 cm is a good size for this plant. The scaling can be changed anytime, but for lighting, simulation or when you want to exchange models within a team it is recommended to work with the proper measures right from the start. If you prefer a clean workspace you can go to > Display and uncheck > Grid.

2017_ImportedDefault

The dandelion model already comes with textures and alpha masks. To make them visible select > Shading > Hardware Texturing or switch on the tiny checkerboard icon above the Viewport. You can also use the “6” and “5” key to switch texturing on and off.

2017_HardwareTexturing

When you zoom in to inspect the leaves you can see that the texture is only visible on one side.

2017_hardwaretexturingblack

To find out why you can open > Windows > Outliner and select the geometry, then > Display > Normals to make their direction visible. You can see that without lights in the scene only the outward facing Normals will be shaded (as long as the Ambient Color of the material is black).

2017_hardwaretexturingnormals

Select > Display > Normals again to hide them. Switch on the light bulb icon above the Viewport or select > Lighting > Use All Lights. Since there are no lights in the scene, everything becomes black. You can also use the “7” and “6” key to switch the light mode on and off.

2017_lightson

Let’s start with > Create > Lights > Ambient Light. It evenly illuminates all surfaces without any shadow. Not quite realistic but we will use it later to slightly brighten the shadows. Changing it’s position or rotation does not affect its direction or strength.

2017_AmbientLight

To bring in shadows we need a ground object. Go to > File > Import … and select the downloaded “BeachRocks.obj” from the sourceimages folder. A Material with the scanned texture will be automatically created, just change the Ambient Color to black in the Attribute Editor. Move around the plant on the ground to a nice spot. To center the view select the plant and hit the “F” key, then adjust your viewing angle further.

2017_GroundImport

Let’s start the Three-Point Lighting with a black scene. Select the ambient light in the Outliner and hit the “H” key to hide it for now. Begin with the the Key Light, it represents the dominant light source, such as the sun, a window, or ceiling light. Select > Create > Lights > Directional Light. The Key light should be rotated 15-45 degrees above (seen from side view) and 15-45 degrees beside (seen from top view) to the camera’s viewing axis. Changing the position of a Directional Light has no effect. Switch on the Shadows icon above the Viewport or make a tick at > Lighting > Shadows. The Key Light defines the most visible lighting and shadows in the scene. In the Attribute Editor increase the Intensity accordingly. Also switch on “Use Depth Map Shadows”, maximize the Resolution and change the Filter Size to 20 to improve the shadow quality. You will notice that the shadow does not match the blossom. By default Viewport 2.0 works with OpenGl which does not consider alpha masks in materials. On Windows computers it is possible to use DirectX for even better realtime shading effects, different shader set ups are then required.

2017_directionallight

To soften and extend the illumination provided by the key light and to make more of the subject visible, we add a Fill Light. It can simulate light scattered from the sky (other than the sun), secondary light sources such as table lamps, or reflected and bounced light. If necessary, you may add several of them to a scene. Hide all lights in the Outliner with “H” and > Create > Lights > Spot Light. For better handling use the Scale Tool to make the light cone visible. Scaling does not change the light intensity of Spot- or Directional Lights (only Area Lights are affected). Seen from the top view, the Fill Light should come from a generally opposite angle than the Key Light – to fill it’s shadows. It can be raised to the subject’s height, but should be lower than the Key Light. The intensity of the Fill Light should be less than 50% of the Key Light. Since the Intensity of the Key Light is already 2.5 we can leave it at 1. Tick here also “Use Depth Map Shadows”, maximize the Resolution and change the Filter Size to 20 to improve the shadow quality. Changing the color of the Fill Light makes the scene look a little bit more interesting.

2017_FillLight

To highlight the edge of the objects and to help visually separate them from the background let’s add the Rim Light or Back Light. Place a Spot Light behind your subject, opposite from the camera. Tick here also “Use Depth Map Shadows”, maximize the Resolution and change the Filter Size to 20 to improve the shadow quality. To add some variation I changed the color to a colder tone.

2017_BackLight

Now the Three-Point Lighting set is complete. Switch on Key, Fill and Back Light in the Outliner. Let’s clean up the Outliner in the meantime. Rename the lights according to their function and > Create > Empty Group. MMB drag the Lights into the Null Object, create others for the cameras and the geometry. To hide the Groups in the Outliner you can select > Show > Objects > Sets and > Invert Shown.

2017_outlinerhidesets

Now you can collapse the groups with unused scene elements or hide them from the Viewport with the “H” key.

2017_outlinergroups

To make the material of the plant appear a little bit more lightweight, just increase the Translucence value in all plant shaders slightly.

2017_translucence

The shadows in some parts are quite dark – unlike in reality where almost always diffuse light is around. By using the Ambient Light with a very low intensity we can fake that effect here.

2017_ambientadjust

The ground texture looks a bit overexposed compared to the plant, so let’s adjust that. Select the object and in the Attribute Editor click on the Input icon next to the Color slider.

2017_croundcolorlink

You will be directed to the Texture attributes where you can decrease the Exposure.

2017_groundexposure

For the sky background create a sphere with a radius of 250 cm. It should enclose the ground but be not bigger, otherwise the quality of the shadows might become too poor (the anti aliasing of the lights is calculated relative to the dimension of the whole scene). With the sphere selected RMB > Assign New Material >Maya > Surface > Lambert.

2017_assignlambert

Click on the checkerboard icon next to the Color slider.

2017_assignbgtexture

The “Create Render Node” Windows pops up. Select > 2D Textures > File.

2017_assignbgtexturefile

In the Attribute Editor click on the folder icon and select the downloaded HDR image in the sourceimages folder (the low-res version is fine). Since the sky panorama is in HDR format (High Dynamic Range) the Color Space needs to be changed to RAW (without color correction). Reduce the Exposure to -1 for now, you can fine tune it later.

2017_bgexposureraw

The Normals of the Sphere are pointing outwards by default, but we need them inwards here. To flip the direction  select > Mesh Display > Reverse. In the Shape tab of the Attribute Editor switch off “Casts Shadows” and “Receive Shadows”.

2017_bgshadowoff

To prevent the lights affecting the intensity of the background go to the material settings in the Attribute Manager and maximize the Ambient Color and disable Diffuse. Then the material becomes a kind of self-illuminating. You can quickly test the effect by selecting the Light group in the Outliner. When you hit the “H” key to hide all lights in the scene, everything becomes black – except the Background Sphere.

2017_bgdiffuseambient

Now let’s tweak the Hardware Render Settings. In the Viewport go to > Renderer > Viewport 2.0  > Options, enable Screen-space Ambient Occlusion and maximize Samples, Radius and Filter. Ambient Occlusion adds a shadow effect at overlapping or angular surface areas. It does not work well with the alpha mask of the dandelion here, so we need to reduce the Amount to 0.3. In other scenes higher values should work fine. To add some more finesse adjust the Hardware Fog settings and activate the atmospheric effect in the Viewport at > Shading > Hardware Fog.

2017_hwrenderersettings

In the last step let’s add Depth of Field blur to the scene. Make sure that your custom camera is the active camera. In the Viewport select > Panels > Perspective > (Camera Name). In the Shape tab of your custom camera make a tick at Depth of Field and change the Focus Distance according to the distance from the camera to the focus object. Activate >Shading > Depth of Field or the small icon above the Viewport.

2017_dofsettings

lighteffectslayers