This tutorial shows how to generate caustics by shining a V-Ray Sun light through a faceted glass cup.
Overview
In this tutorial, you will learn how to generate caustics using a Photon Map. Photon Mapping can only calculated when doing a production render. Interactive rendering always generates Progressive caustics. A Photon Map is a map of the locations where the photons in the scene go once they are shot from the light source. This map tells V-Ray where to render caustics to create a realistic image.
Download the scene and follow along:
When the Caustics Mode is set to New map, a new photon map is generated for the scene. You can generate a new map each time you start a new production render, or - if you are generating caustics for the same scene, you can enable the AutoSave option to save the generated Photon Map file. You can then upload it when the production render is complete, by setting the Mode to From file and re-use the same Photon Map. This speeds up the render, allowing you to edit more efficiently. If you make changes to the caustics settings/setup, you need to render a new map again.
Material Setup
In the sample scene, the V-Ray Material is already set up to imitate glass. Inspect it, or copy its settings to create realistic glass material yourself. For the purpose of generating caustics, only one option concerns us, and that is the Affect Shadows option, located under the Refraction rollout of the material's properties.
Select the glass geometry in the Outliner. Go to the Editor at the bottom of the viewport and set it to the V-Ray Node Editor. Set the Node Tree to Shader. You should see the Cup_Glass_Water_Mtl setup. In the Node menu on the right-side panel of the V-Ray Node Editor, expand the Refraction dropdown and enable Affect Shadows. You can also find any V-Ray material's options under the Material Properties
tab.Click on the image to view it in full size
Caustics Setup
Caustics are disabled in V-Ray by default, as Caustics are quite slow to calculate in general. To enable caustics, you need to go to the Render Properties
tab and set the following properties:Enable Caustics.
- Mode = New map. This generates a photon map when you start your production render.
- Search Distance (pixels) = 3.000. This parameter determines how far from a given point on the surface V-Ray searches for photons. Higher values create sharper caustics.
- Max Photons = 600. This parameter determines the maximum number of photons within the search distance that are considered when rendering caustics. Higher values create smoother but blurrier caustics.
Click on the image to view it in full size
Sun Light Setup
Besides enabling caustics, you also need to set the Sun Light's (if any in the scene) Photon Radius large enough to encompass the relevant areas of the scene. In this case, we have a closeup shot of a glass cup, which means that we don't need to set a large number for the Photon Radius. In fact, it can even be smaller than the default value of 50.
Select the V-Ray Sun from the Outliner and go to the Data Properties tab. Expand the Photon emission dropdown and set the Photon Radius to 5. This value will be enough to render caustics and will optimize our render time.
Click on the image to view it in full size
Final Render
We can now render our scene. We need to set appropriate render settings. Calculating caustics by generating a new photon map allows us to use the Bucket sampler, so we will opt for it.
Go to the Render Properties
tab and open the Sampler tab. Set the following properties:- Sampler Type = Bucket
- Noise Limit = 0.008. This means that the render ceases once this noise limit is reached.
- Firefly Removal = 0.05. This option helps remove any unnecessary highlights that might occur from the caustic calculations.
We can now start our final production
render.Click on the image to view it in full size
Add Layers
When the render is complete, you can apply some post-effects to the render. You can do so right in the V-Ray Frame Buffer. Double-click on the right panel expander. Here you can find the Layers panel. Visit the Layers page and learn how to use Layers. They work similarly to other post-production software - corrections are applied from the bottom to the top, except for nested layers, which are executed after their parent. We have prepared a subtle correction preset, packed with the downloadable scene for this tutorial. To load a preset, click on the Load layer tree preset button. Then, locate the directory where you've extracted the sample file for this scene. Look for a .vfbl file that came with the sample scene. Load it into the VFB to apply the layer preset.
Click on the image to view it in full size
This is the final render result. Remember the main dependencies to render caustics:
- Refractive material with disabled Affect Shadows
- Geometry with applied displacement or that has curves of any kind
- Enabled Caustics in the V-Ray Render Settings
- Appropriate Sunlight Photon Radius.
If you would like to use the Caustics Render Channel alone, there is another step you need to consider when adjusting the V-Ray material - setting the Refraction Advanced > Affect Alpha parameter to All channels. Sometimes, photons can fall behind in refractive surfaces, and they are then calculated towards the Refraction render channel, instead of the Caustics render channel. This does not affect the final render, but it does create inaccuracies when working solely with the render channels. Because of this, the Affect Alpha channel needs to be set to All channels to ensure the Caustics render element also contains the photons fallen behind refraction.
Click on the image to view it in full size