Monday, September 16, 2013

HDRI Exterior lighting with Vray

An outline of the techniques used for rendering an exterior scene using Autodesk 3ds Max and Chaos Group Vray. A HDR image will be used to light and reflect the environment and VraySun as the direct light source for a typical sunny day scene.

HDRI stands for high-dynamic-range imaging, which is a 32bit float image format that allows a greater dynamic range of luminance between the lightest and darkest areas of an image.
A HDR image holds enough information to light a scene, where as images such as JPEGs do not hold enough information to light a scene successfully. HDR images can produce good results, but the intensity is still not enough to give realistic hard shadows that would come from the sun. By adding in VraySun as a direct light source, the two methods combined will allow for easy control over time of day and various types of weather conditions.
Before I start, I would like to point out that I will be using a linear workflow with a gamma 2.2 setup within 3ds Max and Vray. I strongly recommend setting this up as it will improve many areas within your workflow. You can find an easy to follow, step by step guide here. This tutorial will not go through the Vray render settings, but you can find a detailed explanation of how to set up the Vray renderer here.

Finding the right HDR image

The choice for time of day and weather conditions will determine what HDR image is required. Within this tutorial it will be a sunny midday HDR image with minimal cloud which you can purchase and download yourself from here. There are various shapes and sizes of HDR images out there on the web. You will need to make sure that the HDR image is a 360 degree spherical image and the higher the resolution the better. When a spherical HDR image has been applied as an environment, Autodesk 3ds Max wraps the HDR image around a sphere. None spherical HDR images will not wrap around the sphere correctly and produce incorrect results. Resolution matters only if you are planning to use the HDR image as a back plate. If the HDR image is only to be used to light a scene, you can get away with a much smaller resolution.

You would want a HDR image that has maximum sky and a hint of a horizon. Typically a HDR image is pure black under the horizon and therefore will not cast any light. In theory it will also be covered up by geometry.



You can also find HDR images that are pure sky with no horizon. This type of HDR image allows for maximum light, there is no pure black present.

Aligning the HDR image in the viewport

A 360 degree spherical image has a narrow aspect ratio. By default the 3ds Max viewport is 4:3 (1.33) which is a standard resolution of 640 x 480 pixels. As a result of this, you will not be able to see the full height of the HDR image no matter what aspect ratio you choose and this is due to the nature of a computer screen. The majority of exterior visualisations are viewed from a person’s eye line. If the sun is high up in the sky, it will not be visible within the viewport.

Start by setting your 3ds Max standard environment to a VrayHDRI.


Next drag and drop the material from the environment rollout to an empty slot in your material editor. Choose instance and then load in your HDR image. Here you can select spherical for the mapping type.


Go to views, viewport background and tick use environment background and display background. Under apply source and display to change the view type to all views.


HDR images are typically over exposed and may appear blown out in your viewport. To fix this, lower the overall multiplier so that you can clearly make out brightest spot within the HDR image, in this case it is the sun with no clouds. The render multiplier is there if you only wish to affect the map upon render time and not in the viewport.


Next add a Vray physical camera to your scene and point the target up in the sky. Move around the viewport and locate the brightest spot within the HDR image. Ideally the brightest spot needs to be in the centre of your viewport. You can leave the Vray physical camera settings at their default. Do not rotate your HDR image using the horizontal rotation in the material editor; this will need to remain at 0.0.


Once you have aligned the Vray Physical Camera to the bright spot within the HDR image, change the HDR image overall multiplier back to 1. Render your scene using the Vray physical camera with everything hidden so you only render the viewport environment. Once complete, within the Vray frame buffer click duplicate to Max frame buffer and leave it open. This is used as a reference so you can check that the VraySun lines up correctly.


Adding the VraySun

Add a Vray sun to the scene and choose yes to adding a VraySky map to the environment when prompted. This will replace the current HDR image in the viewport. Again, the VraySky map may be over exposed but there is no need to view the VraySky within the viewport, so turn off the viewport background.
Using the align tool, align the VraySun target to the Vray physical camera and then align the Vray physical camera target to the VraySun. The height of the VraySun will vary depending on where the bright spot is within the HDR image. The higher the VraySun the brighter the VraySky, this simulates the time of day. As an example the height of the VraySun for this scene after matching it to the HDR image is roughly 50 times the height of the building.


Render only the environment background using the Vray physical camera. If your sky is over exposed then adjust the f-number of the Vray physical camera to something like 12. Compare the rendered VraySky to the previously rendered HDR image. Both suns should be roughly in the same place within the image.
You may need to adjust the size of the sun within the VraySun parameters. Adjust the size multiplier but keep in mind that the larger the sun, the softer the shadows. A range of 2 – 10 is adequate. All other settings can remain at their defaults.

Depending on the scene, there are multiple options available for the type of sky used with the VraySun.
Preetham et al
This is typical blue sky that has a visible atmospheric haze.
CIE Clear
Again a typical blue sky, but it has less atmospheric haze which tends to give a deeper more saturated blue
CIE Overcast
A very diffuse and desaturated sky that you would typically get in overcast weather conditions. You would normally use very soft shadows, which are controlled by the sun size.


Adding environment light

Place a VrayLight in to the scene and change the type to dome, set the intensity multiplier to 1 and under texture, drag and drop the HDR image from the material editor and chose instance. Make sure the Vray light dome is perpendicular to the ground plane.
If you want the HDR image to be visible when rendered, keep invisible un-ticked and if you plan to add your own sky in, post production then tick invisible. The VraySky will then be the background for the render; this can be removed via an alpha mask whereas the HDR image cannot.


The resolution and the adaptiveness of the texture affect the way shadow rays are generated towards bright area of the HDR image. Increasing the resolution requires more RAM and slows down the render times slightly, but it will make the adaptation follow more closely with the intensity of the HDR image. Within the majority of scenes this goes unnoticed, so the default resolution and adaptive amount is adequate.

Setting up the multipliers

In the material editor, make sure the HDR image overall multiplier is set to 1. Also set the VraySun multiplier to 1. You can control the level of intensity via the Vray physical camera settings. Keeping all multipliers at 1 and the default settings for the Vray Physical Camera is a good starting point. Then adjust the exposure to suit your scene. You can turn off the Vray dome light and complete a test render to see the effects of the VraySun and vice versa. By doing this you can see how one is affecting the other and then find a healthy balance between the two.

Making final adjustments

Remove the VraySky from the 3ds Max standard environment as this is no longer required because the scene will be lit via the Vray dome light. It was only used to make sure that the VraySun was aligned to the HDR image correctly and was the right size.

Next within the Vray physical camera settings, change the white balance to daylight as this will add a colour filter to the 
render. This is not a requirement, you can choose to have a neutral colour balance of white if you prefer.


You may need to increase the sampling subdivisions of the Vray dome light. If your shadows are very noisy, increase the subdivisions by multiples of 8 until you are satisfied with the results.


The resulting render has a visible reflection within the windows. The Vray dome light does two things, illuminates the scene and adds a reflective environment. There is no need to add a reflection map in the Vray GI environment (skylight) override.

Rotating the VraySun and HDR image

At the moment the sun is to the right of the building. Obviously if you were to move the VraySun to front or the left side you would want the HDR image to rotate also, so that the two suns stay together. This can be achieved by wiring the horizontal rotation of the HDR image to the Z rotation of the Vray dome light.
When rotating HDR images, they are rotated by degrees. Because the 3ds Max rotation is also in degrees, wiring HDR image and the Vray dome light together is very straight forward. There would only be any complication when trying to wire an image that uses U and V as rotation, which is essentially X and Y coordinates. If for example you use EXR images instead of HDR images, you would need some method of converting the different forms of rotation.
Hide everything within your scene except the VraySun and the Vray dome light. In the top view, position the Vray dome light half way between the VraySun and its target, it doesn’t have to be exactly to centre.
Using the select and link tool, select both the VraySun and its s target and link them to the Vray dome light. Test that the link was successful by rotating the Vray dome light on its Z axis, the VraySun and its target should rotate around the Vray dome light. If you have rotated the Vray dome light, undo this step as it needs to be in its original position.


Still in the top view, select and right click the Vray dome light and choose wire parameterstransformrotation, and then Z rotation.


A wire will appear prompting for you to select an object so select the Vray dome light itself. Then choose object (VrayLight), texture, and then horizontal rotation.


In the new pop up window, choose one-way connection: left parameter controls right parameter. In the expression window put a – (Minus) in front of Z_Rotation. This is to make both the Vray dome light and HDR image rotate in the same direction. Otherwise the Vray dome light will rotate in a clockwise direction and the HDR image will rotate in an anticlockwise direction. Press connect and close the window.


This allows you to control the rotation of the HDR image shown within the material editor by rotating the Vray dome light on the Z axis within the viewport. Now the position of the brightest spot within the HDR image will follow the VraySun. You will notice that you can no longer rotate the HDR image by horizontal rotation within the material editor, this is now greyed out. You can see the results by rotating the Vray dome light and watching the HDR image within the material editor rotate in real time.



MintViz is the owner and author of this content. Please click the following link to be redirected. http://www.workshop.mintviz.com/tutorials/hdri-exterior-lighting-with-vray/#ixzz2f3CYkhCY
Under Creative Commons License: Attribution Non-Commercial

No comments:

Post a Comment