# lighting - maya lighting ## LIGHTS IN MAYA For this lesson, you will learn how to control the four most common light types: Ambient, Directional, Point and Spot Lights. Bear in mind that lighting in 3D is not the same as lighting in the real world. One of the most important things you need to do is turn off the Default Light. Once you have added lights to a scene this can interfere with your lighting scheme. Even though there are no light nodes in the scene, the scene is being lit. Maya automatically detects this and creates a temporary default light in your scene just before you render. This feature can be turned off by unchecking Enable Default Light. Click on Windows > Rendering Editors > Render Settings, and in the Common tab, this checkbox is at the bottom, under Render Options. ![Turn off default light under options.](lighting_DefaultLight.jpg "Turn off default light under options.") 1. Set project to the Arts234_06_Lights_DemoFiles folder you downloaded from D2L. Open the scene file lights.ma. The scene file contains some city buildings on a plane. Click in the camera1 view to set focus and then click on the Render Current Frame button in the Status Line. The Render View window will appear and the camera1 view will be rendered. The scene looks like this: ![This is what the demo scene looks like with no lights on.](lighting_DemoSceneStart.jpg "This is what the demo scene looks like with no lights on.") 2. Ambient Lights simulate lighting being emitted evenly across the entire scene inwards from all directions and are often used to achieve the look of indirect lighting (i.e. general environmental bounce light). Select Create > Lights > Ambient Lights. ![Create an ambient light.](lighting_CreateAmbientLight.jpg "Create an ambient light.") In both the camera1 and the persp view select Shading > Smooth Shade All and then select Lighting > Use All Lights. These modes allow you to preview the lights in your scene directly in the viewport without rendering. Now move the light and decrease its contribution to the scene. Open the Channel Box for the Ambient Light. Move the light up 16 units on the Y-axis. ![Set the ambient intensity to 0.1](light_AmbientIntensity.jpg "Set the ambient intensity to 0.1") Going by Alan Chan’s suggestion, the Ambient Intensity should be in the range of 0 - 5%; e.g. intensity = 0.0 to 0.05. This instructor sees nothing wrong with bumping it up to 0.1-0.15 for outdoor daylight scenes, if you wish, but it should probably never be higher than 0.15. _If you render this view, you will quickly see that this ambient light we just made is contributing very little light to the scene overall. This is normal. This is what you want._ ![With only the ambient light, the renders are very dark.](lighting_AmbientRender.jpg "With only the ambient light, the renders are very dark.") 3. Directional Lights simulate light sources that are distant and have parallel light rays. Such a light is usually large and so strong that it lights your entire scene evenly from one direction, like the sun for example. Select Create > Lights > Directional Light. Rotate your light around and the viewport’s lighting will update instantly. IPR Render the persp view and marquee select an IPR region that encompasses most of the buildings. ![Directional lights simulate rays, such as rays from the sun](lighting_DirectionalLights.jpg "Directional lights simulate rays, such as rays from the sun") Bring up the light in the Attribute Editor for the Directional Light. Click on the color swatch to bring up the color chooser and change the light to yellow. Also remember Alan Chan’s suggestions. ![Set the color of the directional light to a yellow shade.](lighting_ColorSettings.jpg "Set the color of the directional light to a yellow shade.") Experiment with these settings for a bit, do a few renders on this, and then select the Directional Light and hide it by pressing CTRL+h. Click on the IPR Refresh button on the Render View tool bar to update the view. The world is mostly black again. 4. Point Lights are light sources that begin at a single point and radiate outwards in all directions to light other objects, like a bare light bulb. Select Create > Lights > Point Light. Move the light in between two sets of buildings to the following coordinates (-1, 4, 16). Notice how the light is emitting outwards in all directions. ![Set the point light settings.](lighting_PointLightSettings.jpg "Set the point light settings.") Select the Point Light and hide it by pressing CTRL+h. Press the IPR Refresh button on the Render View toolbar to update the view. 5. Spot Lights can be used to simulate lights such as theatre lights and desk lamps. They are much light Point Lights, in that they emit light from a single point. Their influence, however, is limited by a cone shape allowing for control over where the light falls. Select Create > Lights > Spot Light. A spotlight can be created with or without an Aim manipulator. With the light selected, select Display > Rendering > Camera/Light Manipulator > spotLight1, or press the t key. You can drag the two different manipulators in the viewport to position and aim from behind the buildings. ![The aim manipulator can be used to point something wherever you want to.](lighting_RenderingSpotlightManipulator.jpg "The aim manipulator can be used to point something wherever you want to.") ![Spotlight and aim manipulator](lighting_SpotlightWithManipulator.jpg "Spotlight and aim manipulator") Note that spotLight1 is currently pointed in the wrong direction. In one of the smaller viewport panels, select Panels > Look Through Selected. This will give you a view through spotLight1 (or whatever you have selected) so that you can look at what is being illuminated. As you reposition the light, the image will update in the IPR Region. ![Look through selected is very useful for positioning lights and cameras.](lighting_lookThroughSelected.jpg "Look through selected is very useful for positioning lights and cameras.") In the Attribute Editor, adjusting the Cone Angle attribute allows you to change the spread of the large end of the cone. Adjusting the Penumbra angle allows you to make the edge of the light softer. Adjusting the Dropoff allows you to control how quickly the light diminishes from the center of the spotlight to the edge. As you adjust all these settings they will update in Render View. ![Spotlight settings](lighting_spotlightSettings.jpg "Spotlight settings") By default, all light sources in Maya will light the objects in the scene regardless of how far away they are from the light. Not so in the real world. In the real world as objects get farther away from a light source, the amount that they are illuminated decreases. Maya lights can be set to have this kind of decay. In the Attribute Editor, set Decay Rate for the Spot Light to Linear. ![Adjusted spotlight settings](lighting_SpotlightSettings2.jpg "Adjusted spotlight settings") The scene will become dark. This is because the light is not bright enough to light the objects with that intensity and decay setting. Increase the intensity to somewhere between 9 and 10. The scene is now lit. (NOTICE: the buildings and ground are not as brightly lit as they get further away from the light. Quadratic and cubic light decays fall off much faster and require larger intensity settings.) ![You have to increase the intensity when using light decay.](lighting_IntensityDecay.jpg "You have to increase the intensity when using light decay.") Click on the STOP IPR button on the Render View tool bar. Select the Spot Light and hide it by pressing CTRL +h. --- ## SHADOWS Light can be set to cast shadows from and onto other objects. Maya supports two types of shadows: Depth Map and Raytrace. Depth Map shadows are recommended for most cases because they are generally faster to render. Some special effects can be achieved with Raytraced shadows, transparent shadows for glass objects for example. OUTLINER 6. Select the Directional Light in the Outliner. In the Attribute Editor, open the Shadows section and click the Use Depth Map Shadows check box. Render the persp view. ![Select lights in outliner and set the shadows up.](lighting_Outliner_Shadows.jpg "Select lights in outliner and set the shadows up.") The buildings now cast shadows onto the ground and each other. Notice how the shadows are parallel to each other. This is a characteristic specific to Directional Lights. Select the Directional Light and hide it by pressing CTRL +h. 7. Select the Point Light in the Outliner or Hypergraph and select Display > Show > Show Selection.. In the Attribute Editor, open the Shadows section and turn on the Use Depth Map Shadows. Render the persp view. ![Turn on depth map shadows and enable shadows in the viewport.](lighting_ViewportCastShadows.jpg "Turn on depth map shadows and enable shadows in the viewport.") The buildings cast shadows onto the ground and each other. However in contrast to the Directional Light, the shadows are cast outward and not parallel. This type of shadow is also the same for spot lights, excepting that spot lights are limited by the cone angle. ![Point lights cast shadows in all directions.](lighting_pointlightShadowsRender.jpg "Point lights cast shadows in all directions.") Another thing you should know about Maya and shadows is that you control whether an object casts or receives shadows. This is accessed in the Attribute Editor each object individually. The ability to control what light and shadow lands upon the objects of your choosing is to truly master lighting. Select the object and then go to Render Stats, this works for either NURBS or Polygon objects. ![These are the lighting settings in the individual object attributes.](lighting_objectControl.jpg "These are the lighting settings in the individual object attributes.") --- ## RAYTRACED SHADOWS Raytracing provides for accurate reflections, refractions and shadows (both transparent and soft). These effects are achieved by the renderer which shoots rays into a scene from the light source. These rays gather certain information which can be used to create photorealistic effects. However, raytracing is computationally intensive and it is suggested that it only be used when required for a particular effect. 8. Open the scene called raytracing.ma in the Arts234_06_Lights_DemoFiles folder (make sure you set this folder as the Project folder. This scene contains two flasks on a table in a room with a Point Light. Render the persp view. The flasks on the table are rendered, one is transparent and one is black. ![This is the rendered scene without raytracing.](lighting_RaytracingRendering.jpg "This is the rendered scene without raytracing.") When you enable raytracing both flasks will reflect the environment. In the Render Settings window, go to the Maya Software tab. Open the Raytracing Quality section and turn on Raytracing. Re-render the persp view. One looks more like glass and the other looks like shiny metal. ![Set the raytracing to on in your render settings.](lighting_RaytraceSettings.jpg "Set the raytracing to on in your render settings.") ![The rendering with raytracing turned on.](lighting_Flaskrenderingwithraytracing.jpg "The rendering with raytracing turned on.") Examine the materials assigned to the shiny metal flask. Select the black flask in the viewport. RMB click and select Materials > Material Attributes to bring that object’s assigned material up in the Attribute Editor. ![Set material attributes for the metal flask.](lighting_MaterialAttributes.jpg "Set material attributes for the metal flask.") The flask has a Blinn material assigned to it (which simulates shiny surfaces and allows for reflections). You can verify whether a material supports reflections by seeing if it has a Reflectivity attribute. This allows you to set how reflective an object is. In the case of the Blinn material, the Eccentricity, Specular Color, and Specular Rolloff attributes also play roles in the look of reflections. Increase the Reflectivity of the shiny metal flask’s material to 0.9. Render the image. ### REFRACTIVE GLASS Transparent surfaces are all around us, though we very rarely pay much attention to them. That is, until it is time to realistically model one in Maya; at which time, the subtle nuances that make these materials behave the way they do suddenly hit budding 3D artists like sledgehammer. The first thing we need to do is better understand how transparency works, within the real world and in Maya. In the real world, any transparent substance bends the light that travels through it. This is called refraction, and every transparent material refracts light to some extent. This is what makes a straw partly inserted in water appear broken, what makes a diamond sparkle, why lenses help us see, and why the sun appears larger on the horizon at sunset. Refraction again costs significant processor power, so use it wisely. When light passes from one transparent medium to another, we need to tell it the Refractive Index that it’s entering. This is where most people get confused, so we’ll start by building a simple glass to explain. Now let’s think about what happens in “real life”. A light ray starts out in air (index = 1) and hits the glass jug (index = 1.33). This bends the ray. Then it travels through the glass to the other side, back out into air (index = 1). ![Raytrace flask with metal reflections.](lighting_MetalRenerWRaytrace.jpg "Raytrace flask with metal reflections.") Load the glass flask’s material into the Attribute Editor and decrease the Reflectivity attribute to 0.25. Render the persp view. The glass isn’t looking very convincing, real glass refracts light. Load the glass flask’s material into the Attribute Editor and in the Raytracing Options section, enable Refractions and choose a Refraction Index f 1.333. Use Render Region to render only the glass flask. ![Set the glass material settings as shown.](lighting_GlassSettings.jpg "Set the glass material settings as shown.") ![The rendering of glass and refractive materials is much more realistic with raytraced refractions on.](lighting_RefractedGlassRender.jpg "The rendering of glass and refractive materials is much more realistic with raytraced refractions on.") 9. Now for the raytraced shadows! Before rendering this scene using the Raytracer, you should look at the effect of rendering this scene with Depth Map Shadows. In Outliner (or Hypergraph), select pointLight1 and load it into the Attribute Editor. ![Select the point light.](lighting_selectPointLight.jpg "Select the point light.") In the Shadows section, turn on Enable Depth Map Shadows and render the persp view. ![Turn on shadow map settings.](lighting_DepthMapShadows.jpg "Turn on shadow map settings.") (Note: both objects cast solid shadows. This is not good as the glass flask is transparent and should be casting transparent shadows.) Render. In the Attribute Editor, enable Raytrace Shadows in the Raytrace Shadows section and re-render the persp view. ![Turn off shadow maps, and turn on ray traced shadows in the light settings.](lighting_RaytraceShadows.jpg "Turn off shadow maps, and turn on ray traced shadows in the light settings.") Raytracing shadows allows you to create soft shadows as they appear in the real world, that is, they become softer gradually as they get further from the object. This effect comes with the price of substantially increased render times. You can create even softer shadows with less noise by specifying a larger size for the light (in Light Radius units) and increasing the number of Shadow Rays to reduce noise. Remember that increasing rays will substantially increase the render time. If your shadows look choppy, increase the shadow rays in the settings shown above. ![This is a render with raytraced shadows turned on.](lighting_RaytraceShadows_Render.jpg "This is a render with raytraced shadows turned on.") Shadow-mapped spot lights cannot cast transparent shadows through transparent surfaces or dissolved objects. The shadow will appear as if the object was solid. They can, however, be transparent if you use a ray traced shadow. For the best quality shadows of transparent objects use Ray Trace and turn on Caustics (more on this later). --- tags: #3d #maya #lighting #resources home: [[! 3d modeling- maya]]