Tuesday, 22 March 2011

HDRI lighting Tutorial

What are HDR images?


Most images contain a light value of 0 - 255 (0 being very dark or black and 255 being very light or white). HDR stands for high dynamic range which means it has a greater range than 0 - 255. This means then contain more light information and usually makes them more detailed because they contain more tones. This also gives them better details within shadows and highlights.

Terminology


For this tutorial, there is some technical vocabulary which you need to know. This will give you a better understanding of Maya lighting and also Mental Ray.


Mental Ray - A rendering software that can render at production quality.


Global Illumination - Allows light to reflect around a scene. It can make CG images look more natural.


Final Gathering - It is similar to global illumination but only allows light to bounce once. It allows                                              surfaces and planes to become lights as they can emit rays.

Surface Shader - This is a material that contains no other information other than its colour.

Penumbra Angle - The area outside of a lights cone angle, where it fades to nothing. The larger the penumbra angle, the softer the light edge.

Raytracing - Light information within a scene.

Refractions - A change of light direction due to environment such as surfaces or materials.

Raytraced Shadows - Shadows as a result of light in a scene with raytracing.

Ray Depth Limit - How shadows bounce around a scene. If the limit is set to one then the shadow will only bounce off one surface. If it set to three then it will bounce off three surfaces.

Eccentricity - The size of a highlight on a reflective surface.

Specular Roll Off - How bright the reflection of the highlight is. Some highlights can look unnatural so this tones them down.

Specular Colour - The colour of the highlight.

Tutorial

I will be creating the image below which is of three snooker balls on a snooker table.

On the balls are the reflections of the lights. The setting is very important because in most HDR images the surroundings are reflected in the object, especially if the surface has reflective properties. An example of this is a picture of a new shiny car. You can always see part of the surroundings in the paintwork.

Firstly we must make sure we have the mental ray plug-in enabled. Stat by going to window > Settings/Preferences > Plug-in Manager.


Then find a plug-in called Mayatomr.bundle and make sure loaded and auto-load are both ticked on then close this window.



This means we wont have to load it everytime we open the file and we can now render using mental ray. Next we need to start making the model to light. 

Create a plane and scale it up to make the table. Most of the table will be in darkness so it only needs to be a little bit bigger than the lit area. Then create three polygon spheres that are exactly the same size. Move them so they sit just on the plane rather than through it as these are going to be the snooker balls and they need to be on the table (which is our plane). The balls then need to be moved into position to form the composition of the image.

This uses Maya's default lighting
The next thing to do is to create the spotlights. You will probably have at least two lights in an image. This is because one will light the object and another will light the scene. It is unlikely you will ever get the desired effect using just one light.

So go to Create > Lights > Spot Light and this will create your first spotlight.


It then needs to be moved. It can be moved just by using the arrows but I found the easiest way to get the position perfect was to select the spot light then go to Panels > Look through selected camera. Even though its not a camera, you can still through it to where the light will hit.


After it is positioned, change back to the perspective camera (Panels > Perspective > Persp). 

We need to make the lighting a little bit softer as it has very hard edges. To do this we need to change the light attributes so select the light and then click the Attributes Editor icon in the top right hand corner (third one in).



From here you can change the cone angle to make it slightly wider (I have used 50) and change the penumbra angle to about 20 so the light has soft edges.


Under the mental ray settings, make sure the area light is ticked on.


If you do a quick render then you can see how the light currently looks.


This looks good and sets the right mood for our scene but the shadows on the snooker balls are too dark so we now need to add another spot light which will light just the snooker balls.

If you follow the same instructions to create another spot light but this time position the light closer to the ground and aimed at the dark side of the snooker balls. Also, adjust the cone angle to 100 and the penumbra angle to 40.


When we do another render, we can see the shadows are much smaller and not as dark as before.


The next thing is to make reflective planes. These will help bounce the light from the spot light onto our scene. To do this, create a polygon plane and move it so it sits just behind the area light. It has to be positioned a little way back because otherwise it may cut off some of our light. 



Then we apply a surface shader so right click on the plane and go to Assign Favourite Material > Surface Shader. Make sure the colour is set to completely white.


We want this reflective plane to move with the spot light so that if we need to adjust the position of the spotlight, the reflective plane will follow. To do this we need to parent it to the spotlight. First, select the plane then select the spot light whilst holding down shift and press P. Now the reflective plane will follow wherever we move the spot light. Now create another reflective plane for the other spot light and parent it.

The next step is to assign the materials to the different objects.The settings for the materials are extremely important as these are what effect the reflectivity and other attributes helping to make the image HDR.

I'm going to start with the easiest material, which is the table. Select the plane and right click >Assign New Material > Lambert. Rename the lambert straight away so we do not get confused with our materials. I have renamed it simply table. We want to change the colour to a dark green to make it look like a snooker table. It is important that the material is a lambert because we want the material to have a matt effect. All the other material attribute settings stay the same.

On the snooker balls we are going to assign blinn materials. Right click on the ball nearest to the camera and Assign new material > Blinn. Rename the material. My ball is going to be red so I have renamed my material redball then open the attribute settings. Now we're not using the translucence attribute so turn both the translucence depth and focus down to 0 so there is no effect on our ball at all. 




Under the specular shading attribute, decrease the eccentricity to 0.250, increase the specular roll off to 1.000 and reflectivity to 0.800. These all effect how the light bounces off the ball. You need the material to be quite reflective so the settings are higher. 

To make the reflection and highlight of the ball more natural, we need to adjust the specular colour. At the moment it is white but we need to change it to a very light red to give a more realistic reflection.


Under the raytrace options make sure refractions is ticked on and the reflection limit is up to 3.


That is the red ball done. Now we need to do the same for the white ball and the blue ball. All the settings will be the same except for the colour and specular colour which will be lighter versions of the colour of the ball. A quick tip that I used was to not make the white ball a bright white, use a light grey so that you can still see the specular colour and looks more realistic.

Now our whole scene should look like this:


And when rendered, should look like this:


Now it does quite look how we want it too yet. The surfaces are not reflecting properly and there are no shadows so the balls look as though they are floating.

To add the shadows, you first need to decide which light you want them to come from. In the scene I've created, the higher light will create the desired shadows as they will be visible to the right of the snooker balls.

Select the light which you wish the shadows to come from then go to the Attribute Editor. Under the Shadows drop down tab there is a Use Raytrace Shadows option. Make sure this is ticked then adjust the  Ray Depth Limit to 3. This allows the shadows to bounce up to three times.


If you render the scene again, the snooker balls now look as though they are on the table rather than floating.


We now need to adjust the render settings. If you go to the button at the top of the screen that looks like a clapper board with two dots next to it :


Change the Render Using setting to mental ray from the drop down menu. More tabs should then appear. 


Under the Features tab, under Rendering Features, make sure Raytracing and Final Gathering are ticked on.


Under the Quality tab, change the Quality Presets to Production. This will change the Raytracing options to Reflections at 10, Refractions at 10 and Max Trace Depth to 20. 



Finally, under the Indirect Lighting tab, make sure Final Gathering is ticked on. This will change the quality presets  to custom but will leave the values and settings the same.


The render settings can then be closed.

If you render the scene you can see it looks much more realistic but the problem we have now is that the two reflective planes behind the spot lights are extremely visible because they are reflected in the surface of the snooker balls.



The reflectivity can be an advantage but can also be a disadvantage. The disadvantage is whatever we add to our scene, including lights and reflective planes, will now be reflected in the snooker balls. The advantage is that we can add objects and images to our background for them to be reflected in the surface giving us a realistic HDR image without having to do any horrendously complicated textures. 

The next stage for our scene is to put it into a context. So we know they are snooker balls on a snooker table but where is the snooker table?

We don't want to add a whole environment because that could ruin the mood of our image. Instead we are going to suggest it is in a snooker hall. We do this by adding the lights of a snooker hall into the reflection from our snooker balls. No light is actually going to come from our snooker hall light but from the spot lights we created earlier. To do this we need to make the reflective planes invisible from the camera and make our snooker hall light into our new reflective planes.

To begin, we need to hide the two planes that are being reflected. Select the first plane and go to the Attribute Editor. Under Object Display drop down tab, make sure visibility is ticked off


Repeat this process with the other plane.

To make the snooker hall lights, I have created a basic strip light out of a polygon cylinder and polygon plane



There are two planes (one slightly larger than the other) and one thin long cylinder (this forms the bulb part) which are all easier to see when they are selected.


This light does not have to be modelled in great detail as is it only being seen in a reflection. The most important part is the colour of the materials. We are going to use different shades of grey and they are going to be surface shaders. The whiter the surface shader, the more it will reflect so we need the bulb part to be completely white. Select the cylinder then right click > Assign Favourite Material > Surface Shader then make the out colour completely white.


We want the plane above the cylinder to be less reflective so assign another surface shader but make it a light grey. We want the plane above that to be even less reflective so assign another surface shader but make this one even darker. All together they will look like this:


The only thing left to do now is move the snooker hall light into the correct position for the reflection.

This is my final scene set up.


So we move the camera back into place for our composition and then we do the final render

This is our final image.




No comments:

Post a Comment