Вы находитесь на странице: 1из 34

VRay Photon Mapping Tutorial

Search Keywords: photon, photon mapping

In this tutorial we'll examine photon mapping in VRay and efficient ways to use it.

What is photon mapping?


Photon mapping is a technique for computing global illumination. However, in difference from the
irradiance map, which starts tracing rays from the camera, photon mapping traces rays from the
lights in the scene. The two approaches are not mutually exclusive, and indeed for best results the
photon map and the irradiance map should be used together.

The photon map has many parameters that allow for a lot of interesting results; here we will not
discuss all possibilities but will just point out settings that are reliable and work well in most cases.

Initial settings
For all of our experiments, we will start with the following settings for the photon map (note that
these may be different from the defaults):

Convert to irradiance map - off

Auto search distance - off

Max photons - zero

Convex hull area estimate - off

Store direct light - on

Retrace threshold - zero

The only parameters that we will actually use are:

Max density - this defines the resolution (spatial detail) of the photon map. Lighting information
from the photon map is accumulated at a number of points on the surfaces of scene objects. This
parameter defines the distance (in world units) between those points. Smaller values mean that the
points will be closer to each other and there will be more of them. Larger values mean that the light
samples will be farther away from each other and there will be fewer of them. Obviously, this
parameter depends on the scale of your scene. Changing this parameter requires recomputing of the
photon map, since it is used only while the photon map is computed.

Search distance - this defines how lighting will be reconstructed from the surface points described
above. You may think of it as blurring of the photon map. It should be larger than Max density, but
the exact value depends on how blurry you want your photon map solution to be. Values of 2-5
times the value of Max density work well. Changing this parameter does not require recomputation
of the photon map since it is used only during rendering.

Additional parameters that we will keep at the default values, but which you may change as needed
are:

Bounces - this controls the number of light bounces; you can set it to whatever value you want;
more bounces mean slower computation of the photon map. We will keep this at 10, but you you
may adjust it as you want.

Multiplier - this is a multiplier for the photon map; we will keep it at 1.0, but you may adjust it if
you need.

We have thus limited the parameters of the photon map that we'll use to just two - Max density, and
Search distance. These are enough for controlling the photon map. Besides those settings, the
quality of the photon map depends on the number of photons emitted from scene lights. More
emitted photons mean a smoother and more accurate photon map. The number of light photons is
controllable for each light from the Light settings dialog, accessible from VRay's System rollout.

A simple example - the Cornel box


We'll demonstrate the effect of those two parameter on a simple Cornell box-like scene.

You can download the starting scene here (for 3dsmax 5). It includes a very simple setup of a closed
space with differently colored walls and a spot light. The walls have VRay materials applied to
them since currently photon mapping works only with VRay materials.

Note that the spot light has inverse square falloff and quite a high multiplier. This is because real-
world lights have inverse square falloff, and photon mapping produces inverse square falloff by
default.

This is what you get if you render the file straight away.

Now turn on GI and set the photon map method for both primary and secondary bounces. Turn off
Auto search dist, set Max photons to 0, Retrace threshold to 0.0, and Max density to 10.0:
VRay Displacement Mapping Tutorial
Search Keywords: displacement, displacement mapping, 2D, 3D

In this tutorial we'll examine displacement mapping in VRay. We will concentrate on the 3d
displacement mapping method.

What is displacement mapping?


Displacement mapping is a technique for adding geometric detail to surfaces at render time. In
contrast with bump mapping, which works by just changing the surface normal to create the illusion
of surface detail, displacement mapping modifies the surface itself. Here is an example of the same
object rendered with bump mapping and with displacement mapping:

Original object
Bump mapping

Displacement mapping

In the case of displacement mapping, the surface is actually modified, which leads to correct
outline, shadow and GI. In the case of bump mapping, although the surface appears modified, the
outline and the shadow stay the same.

Note that displacement is different from other kinds of shading, since it needs to modify the actual
object surface. Therefore an object must be displaced before it can be rendered. This is why in
VRay displacement is represented with a modifier (although the modifier can take the displacement
map from the object material).

A simple example - a displaced sphere


Start with an empty scene. Create a GeoSphere with a radius about 40 units in the viewport and
choose VRay as the renderer. Apply some Standard material to the sphere.

Irradiance map modes: Rendering a static


scene from multiple views
Search Keywords: IR, Irradiance map, GI

In this tutorial we will examine ways to efficiently render a static scene from multiple views.

This is the scene we will use for the tutorial:


We want to efficiently render several views of this scene, using the irradiance map.

The different irradiance map modes will help us in this task.

First open the starting scene.

By default the irradiance map mode is set to Single frame. This allows us to render the scene from
any view, but every time the irradiance map will be computed from scratch. There are two cameras
in the scene. Render each of them:

We could render a single view, save the irradiance map, and tell VRay to use that map, instead of
computing a new one the next time. Since the irradiance map from the last rendering is still in
memory (we have the Don't delete option in the On render end group set), all we have to do is open
the Advanced irradiance map parameters rollout and click the Save to file button. Choose a file
name, for example "test", and save the irradiance map.

Now that we have map saved to disk, we have to tell VRay to use that map. Change the irradiance
map mode to From file, click the Browse button and select the file we just saved. Re-render the
image. Notice that now VRay does not calculate an irradiance map, but skips directly ahead to the
rendering.

Since no irradiance map is computed, the rendering is very fast. What if we want to render the first
view at this moment? This is what happens:
Clearly this is not what we want, but why does it happen? The irradiance map is only partially
view-independent - meaning that a single sample in the irradiance map is valid for any view, but the
samples for a given view are optimally generated for that view only. VRay will not calculate the
irradiance map for parts of the scene that are out of view. If you check the Show samples option in
the Indirect illumination rollout and render the scene, you can see where the actual samples are:

Is it possible to render this new view using the old samples and add new ones only where it is
necessary? The answer is "yes". Just set the irradiance map mode to Incremental add to current
map. Remember that the current irradiance map is still in memory. Render the view:
VRay - Rendering an interior scene tutorial
Search Keywords: interior, lighting an interior

Note: The scene for this tutorial is provided by Wouter Wynen from Aversis
(http://www.aversis.be/). For further discussion of this topic, see this topic on the VRay forum.

Part I: Adjusting the GI settings


Step 1. First render

1.1. Open the scene (which can be found here).

1.2. Assign VRay as the current renderer.

Since the default VRay settings are not very well suited for a fast initial preview, we'll make a few
quick adjustments before the first render.

1.3. Check the Override mtl option in the Global switches rollout, click the button next to it and
select a default VRayMtl material.

1.4. Set the Image sampler type to Fixed.

1.5. Set the resolution to 400 x 325.

1.6. Set the Region size in the System rollout to 32 x 32 pixels.

1.7. Optionally, you can turn on the Frame stamp to print the render time on the image.

1.8. Render the scene:

Step 2. GI preview

2.1. Turn GI on from the Indirect illumination rollout.

2.2. Select Light map as both the primary and secondary GI engine.

2.3. In the Light cache rollout, set the Subdivs to 500, since we want only a fast preview. We'll
return this to 1000 for the final rendering.
2.4. Set the Interp. samples of the light map to 5 for a faster rendering.

2.4. Turn on the Show calc phase option for the light map.

2.5. Render:

The result is quite noisy, but it does give a good idea of what the scene lighting is like.

Step 3: Tweaks

3.1. Since the scene looks too dark, we would like to brighten it a bit. There are several ways to do
this. One is to increase the power of the lights. However, this will make the directly lit areas of the
image, like the patch of sunlight, too bright while indirectly lit regions will remain relatively dark.
Here is an example of this (all lights are x 2):

You can see that the increased light power has made the image brighter, and also has increased the
contrast of the lighting. The scene still looks dark though. We can increase the light power even
further, but this will blow out the directly lit areas too much, and will slow down the GI calculations
later on. So, instead of increasing light power, we will simply make the material brighter.

3.2. Go to the Material Edtior and put the default VRayMtl in one of the slots (it shows up as being
used in the "Environment" in the Material/Maps browser).

3.3. Make the diffuse color of the material RGB (200,200,200).

3.4. Render
The result is much better. We still have the same amount of light entering the scene, but it is
bounced around more and thus increases the overall brightness of the scene.

At this point, you can adjust the ratio, color etc of the lights, while getting a relatively fast feedback
on the lighting.

Step 4. Better GI.

The GI settings that we used are good mostly for fast previews, while you are still adjusting the
scene. Once you have settled on the parameters of the lights, it's time to refine the GI solution.

4.1. Set the primary GI engine to Irradiance map.

4.2. Select a Medium preset for the irradiance map.

4.3. Turn the Show calc phase option for the irradiance map on.

4.4. Render the scene.

Rendering takes more time now as VRay needs to calculate a more precise GI solution.

Step 5: Better antialiasing and less noise

The GI looks ok now, but we still have no antialiasing and there is noise from the area light at the
window. We'll deal with those now.

5.1. Set the Image sampler type to Adaptive QMC.

5.2. Turn GI off.

5.3. Render

We do have antialiasing now, but the noise is even worse. We'll adjust the QMC sampler to improve
that.

5.4. Set the Min. samples of the QMC sampler to 16 and the Noise threshold to 0.002.

5.5. Render.
The noise is less, but there is still some of it. Reducing the Noise threshold and increasing the Min.
samples any more will not help. We simply need more samples for the area light. One way to do
that is to go to the parameters of the VRayLight and increase the subdivs. However, if you have
many lights in the scene, this is quite a lot of clicking. Instead, we will use the Global subdivs
multiplier to do that.

5.6. Set the Global subdivs multiplier to 4.0 and render:

There is still some noise, but we can continue to increase the Global subdivs multiplier until the
result is good enough; 16.0 seems to be a good value.

5.7. Set the Global subdivs multiplier to 16.0 and render:


Step 6. Final rendering with GI

The increased Global subdivs multiplier affects the irradiance map too, so if we render now with
GI, it will be too slow. We'll need to do some adjustments.

6.1. Turn GI on.

6.2. Set the Hemispheric subdivs for the irradiance map to 8.0 to compensate for the increased
Global subdivs multiplier.

6.3. Render

This completes the first part of the tutorial. In the next part, we'll add the scene materials.

Part II: Rendering with materials


Step 1. Rendering with materials

1.1. Turn the Override mtl option in the Global switches rollout off.

1.2. Turn on the reflection/refraction Max depth limit in the same rollout.

1.3. Turn GI off.

1.4. Set the Noise treshold of the QMC sampler to 0.005 for faster previews.

1.5. Render.
Step 2. Preview materials with GI on

2.1. Turn GI on.

2.2. For faster previews set the primary engine to Light cache .

2.3. Render

At this point you can adjust your scene materials while getting fast previews of how the will look in
the scene.

Step 3. Better GI with the materials

3.1. Set the primary engine to Irradiance map.

3.2. Set the QMC Noise threshold to 0.002.

3.3. Set the light cache Subdivs to 1000.

3.4. Set the light cache Sample size to 0.03 (this will make the light cache a little smoother and
slightly faster).

3.4. Render.
This is the final image that we will render at full res in the next part.

Part III: Rendering the final image


We now have to render the final image.

Step 1. Adjusting VRay for larger resolution

1.1. Set the resolution to 1600 x 1300.

1.2. Set the render region size to 64 x 64.

We will need to adjust the irradiance map parameters: since we increased the resolution twice, we
can decrease the irradiance map Min and Max rate by 2.

1.3. Set the irradiance map preset to Custom.

1.4. Set irradiance map min rate to -5.

1.5. Set irradiance map max rate to -3.

Step 2. Rendering the final image.

2.1. Set the 3dsmax to save the rendered image. For increased precision, you can choose a 16-bit
image format (for example, a 16-bit .png). Optionally, you can save to a .hdr image; in that case you
need to select the Unclamped color channel in the VRay GBuffer rollout.

2.2. Press the Render button.

2.3. Go out for lunch.


The final scene for this rendering can be found here.

Part IV: Post-processing the image


The image looks ok, but in most cases you will want it to be a little darker or a little brighter etc.
Instead of changing the lights and re-rendering, you can do those adjustments in an image
processing program.

For example, here is the same image with the gamma value adjusted. I used a .png file and
IrfanView for this purpose, but you can use any other software that you feel comfortable with - for
example, HDRShop for .hdr files.

To add a more photographic feel to your image, you can apply some radial darkening of the corners,
for example like this:
VRay Rendering Surface Interfaces

Search Keywords: glass, liquid, surface interface

General
In this tutorial we will discuss the rendering of refractive surface interfaces with VRay. A typical
example of this is the rendering of a liquid in a glass container. The problem is that we have two
separate objects, which share the exact same surface boundary.

From a modeling point of view, it is very difficult to ensure that the two objects have the exact same
boundary geometry. While this can be achieved (although with difficulty) for static scenes, things
become very problematic in animation.

From a rendering point of view, if the two surfaces match exactly, the renderer cannot distinguish
between them accurately, which may lead to errors in the rendering.

Considering these two issues, it is obvious that we will need to separate the surfaces, or to model
the surface interface separately. We have the following three options:

The liquid and the container do not touch and have a gap between them. This approach is
simple to implement and does not require any special support from the renderer. However, it
does not produce a reallistic result. This is because the gap between the two surfaces
changes the rendering drastically and makes the liquid look like a solid block.

The liquid overlaps the container. This approach potentially produces much more realistic
results, but it requires special support from the renderer. This is because the renderer must
keep track of which surfaces have been intersected along a ray path, so that it can compute
the correct index of refraction. Without this built-in support, this method cannot be used.
Luckily, VRay supports the necessary framework for this, which makes this approach the
preferred one.

The third approach is to model the interface separately. In general, this is difficult to
implement - especially in animations. Further on, with this approach introduces a third
object in the scene with a separate material, which makes things more complicated. Also, it
will not work very well with things like fog in the glass - since in that case, VRay cannot
make the connection between the glass/liquid material, and the surface interface material,
and cannot apply the correct fogging value.

Below, we will discuss the first two methods only; the third method is more difficult and we do not
recommend it with VRay.

Initial rendering
1.1. Open the starting scene, which can be found here.

1.2. Assign VRay as the current renderer.


1.3. To make the previews of the scene faster, go to the Image sampler rollout and set the Image
sampler type to Fixed.

Next, we want to get some fast GI:

1.4. In the Indirect illumination rollout, turn GI on and set both the Primary and Secondary GI
engines to Light cache.

1.5. Turn off the Refractive GI caustics. We will add photon-mapped caustics later on for the final
image.

1.6. In the Light cache rollout, set the light cache Sample size to 0.04 for less noisy light cache
samples.

1.7. Set the light cache Filter mode to Fixed and set the Filter size to 0.08 since we will display the
light cache directly.

1.8. Turn off the Store direct light option for the light cache, since we want to compute direct
lighting separately.

1.9. Set the light cache Subdivs to 500.

1.9. Set the light cache Subdivs to 500.

1.10. Optionally, turn on the frame stamp from the System rollout.
1.11. Render:

This shows the container that we will fill with liquid in the next section.

Rendering the liquid


Now that we have the container, we have to add the liquid.

2.1. Unhide the "liquid inside" object. If you look at the from the Front viewport, you will notice
that the object is slightly inside the glass container, without touching it:

This shows the container that we will fill with liquid in the next section.

Rendering the liquid


Now that we have the container, we have to add the liquid.

2.1. Unhide the "liquid inside" object. If you look at the from the Front viewport, you will notice
that the object is slightly inside the glass container, without touching it:

2.2. Render:
Although the distance between the container and the liquid is really small, the rendering does not
look realistic - it looks like we have a glass with a solid block inside it. To avoid this, we will make
the liquid to overlap the container a little bit.

2.3. Hide the "liquid inside" object and unhide the "liquid overlapped" object. In the Front viewport
you can notice that this object overlaps the container a little bit:

2.4. Render:

Now it looks a lot better; the liquid really seems to be touching the glass.

Final rendering
For the final rendering we would like to improve the antialiasing, and to add some caustics.

3.1. Turn Caustics on from the Caustics rollout.

3.2. Set the Max. density to 0.2 - we want to limit the caustics photon density, since this allows us
to shoot more caustics photons for a smoother caustics effect.

3.3. Set the Search distance to 2.0. Typically values of 5 to 10 times the Max. density parameter
work well.

3.4. Set the Max. photons parameter to 0 - this will cause VRay to consider all photons within the
search distance from the shaded point.
3.5. Render:

Rendering now takes a little more time, since VRay needs to compute the caustics as well.

We have caustics now, but they appear quite noisy. We can reduce the noise by increasing the
Caustics subdivs for the light.

3.6. Select the VRayLight object.

3.7. Right-click in the viewport and select "VRay properties..." to bring up the VRay Light settings
dialog.

3.8. Set the Caustics subdivs to 4000.

3.9. Render:
Caustics look better now and these are the settings that we will use for the final rendering. If you
want even smoother caustics, further increase the Caustics subdivs of the light and/or increase the
Search distance parameter.

3.10. In order to avoid recomputing the caustics every time for the next renderings, save the
caustics photon map to file, set the Caustics mode to From file, and select the saved caustics map
with the Browse button.

Now we need to improve the antialiasing and to reduce the noise from the area light.

3.11. In the Image sampler rollout, set the Image sampler type to Adaptive QMC.

3.12. In the QMC Sampler rollout, set the Noise threshold to 0.002.

3.13. Set the Global subdivs multiplier to 8.0 - this will reduce the noise from the area light.

3.14. Render:

This is our final image.

Basic Texture Baking with VRay, part I


Search Keywords: bake, baking, render to texture

General
In this tutorial we will discuss the process of texture baking with VRay.

Rendering to texture, or "texture baking, allows you to create texture maps based on an object's
appearance in the rendered scene. The textures are then baked into the object that is, they become
part of the object via mapping, and can be used to display the textured object rapidly on Direct3D
devices such as graphics display cards or game engines.

In our case, we will show you how a simple scene can be baked and how this method can also be
used for making a Fly-Through Animation.

The scene contains 2 objects (the Space ship and the Ground) and 1 Light source (omni). You can
download the initial scene here.

The objects actually don't have any specific maps (diffuse) but a simple diffuse color. The materials
assigned to them are both VRay materials. A gray one is assigned to the Ground object, and a Green
one to the Space ship. The materials are Default, with Diffuse colors:

The Space Ship Material : (103, 174, 108)


The Ground Material : (128, 128, 128)

The Light source (omni) is situated a bit above and aside from the Ship. It has a Multiplier of 2.0
and Color RGB (226, 201, 146); the shadow type is VRayShadow.

Setting the Render


1.1. Open the starting scene, which can be found here.

1.2. Assign VRay as the current renderer.

1.3. You can open the Material Editor (M) to assure the materials are properly set and assigned.

1.4. Before we do our first rendering, we will turn on the Frame Stamp (System Rollout) so that we
can have the render times shown.
1.5. Render:

That is what we get with all default VRay Settings. To make the lighting a little more interesting,
we will add global illumination and area shadows to the rendering.

1.6. Go to Image sampler rollout and set the Image sampler type to Adaptive QMC.

1.7. In the Indirect illumination rollout, turn GI on and set both the Primary and Secondary GI
engines to Quasi-Monte Carlo.

1.8. In the Environment rollout, turn Override MAX's (Skylight) on and set Color (255, 255, 255)
and Multiplier to 0.8.

This will give us some environment color to act as a skylight.


1.9. Render:

Notice how the render time has increased, due to all the changes we made on the render setup.

1.10. Turn on the Area Shadow of the omni light.

1.11. Render:
Now we have the area shadow.

The image looks good, but grainy. To reduce the noise, we will adjust the QMC sampler
parameters.

1.12. In the rQMC Sampler rollout, set the Noise threshold to 0.001.

1.13. Set the Global subdivs multiplier to 10.0.

1.14. Render:

Notice how the render time has increased, but the quality is much better. Now our scene is ready
for baking.

Preparing Objects for Baking the Textures


2.1. Before all, we will turn Off the Frame Stamp (System Rollout), otherwise we will get it on our
baked textures as well, which we do not want.
2.2. Now open the Render to Texture (0) Window from the Rendering Menu.

2.3. Choose your Output folder, where the new baked textures will be saved.

2.4. Select both objects from the scene (the Space ship and the Ground).

2.5. In the Mapping Coordinates Section - select Use Automatic Unwrap.

See how both objects were automatically added in the table of Objects to Bake.

2.6. In the Output rollout - choose 512 for the Size, turn on Enable (if not), and give the map a
name in the name-field.

This actually will be the suffix-name of your newly baked texture files, prefixed by the name of its
object in the scene.

For example: in our case the baked map of our Ground object will have the name:
GroundCompleteMap.tga
2.7. In the Baked Material rollout - choose Save Source (Create Shell).

2.8. Select the Create New Baked option and choose (Standard: Blinn) from the pop-up menu.

2.9. Select Keep Source Materials.

2.10. Now go back to the Output rollout - choose Self-Illumination in the Target Map Slot.

See how this is automatically added in the table as well.


Leave all the other settings by Default.

Now our objects are ready for baking (rendering).

Baking the Textures (Rendering)


3.1. Hit Render Button on bottom of the Render to Texture Window.

3.2. You can see that the baking process proceeds in a row object by object, as they were set in the
table.

First is being rendered (baked) the Ground object followed by the Space ship.
Loading the new Baked materials and Viewport preview
4.1. Open the Material Editor (M) and choose an empty one.

4.2. Click on the Get Material icon to open the Material/Map Browser.

4.3. Select Browse From: Scene

4.4. You will notice that there are 2 new materials. They are Shell Materials and contain both the
original VRay material and the new Baked Material in them.

That is because we wanted so: see steps 2.7, 2.8, 2.9

4.5. Drag the new materials in the Material Editor as shown.

4.6. In the new Shell Material Paramaters, choose the Baked Material for Viewport, and
Original Material for Render.

This simply means that:

- if we do a new fresh render (F9) - the object will use their Original material (VRayMtl).

- in all the viewports - the objects will use their Baked Material (Standard).
4.7. Select the new Ground Shell Material - ground_material[Ground].

4.8. Turn on Self-Illumination and select a pure white Color (255, 255, 255). See that there we
already have the Baked Map attached.

That is because we choosed exactly this Target Slot (see step 2.10)

4.9. Go to the Self-Illumination Map, and turn on the Show Map in Viewport icon.
4.10. In the Viewport, you should be able to see the ground plane with its already baked map.

Note: if you forget to turn on the Show Map in Viewport icon, the viewport would look just like
this:

At this point, the Space ship is still being shown as totally black because we still haven't adjusted its
material.

4.11. Repeat steps from 4.7 to 4.9. for the new Space ship material - ship_material [Space_Ship].
Now the viewport should look like something like this (notice how the Edged Faces (F4) can be
also shown along with the baked maps).

Shade + Edged Faces On Shade + Edged Faces Off

4.12. Here are some additional views of the scene from different positions:

4.12. Here are some additional views of the scene from different positions:

Rendering the scene with the baked materials


5.1. Open the Material Editor (M).

5.2. Choose the Baked Material in the Render option for both our Shell Materials.
5.3. Select the omni light and switch it off. Actually we can even delete that light from the scene
and it will still render fine - we have all the lighting baked into the textures already.

5.4. In the VRay settings, turn GI off, Environment (Skylight) off, Default Lights off.

5.5. Render:
Notice the render time. In step 1.14. we had 4m:35s compared to 8.6 seconds that we get now. That
is simply because with the baked textures VRay is not doing any lighting calculations. You can even
switch to the default scanline render and still get the same result.

Having all this in mind, you can animate a camera and render a whole fly-through animation with
very short render times per frame.

Notes:

We will show You another method, which can produce absolutely the same result as the above. This
one concerns steps from 2.7 to 2.10.

Because the VRayMtl does not support a Self-illumination map, we will use the VRayLightMtl.
The new baked maps will be automatically placed in the Texmap slot. Then for previewing the
baked results, You repeat steps from 4.7 to 4.11 (of course considering in mind the new
VRayLightMtls).
In the next part of the texture baking tutorial you will learn how to bake only specific elements of
the rendering (e.g. only the lighting or GI).

Вам также может понравиться