This article describes the V-Ray global illumination (GI) system.
General
V-Ray implementation requirements
Shader requirements
Light requirements
General
The global illumination system in V-Ray is split into several modules dealing
with different components of the GI solution:
- Direct light manager - responsible for handling direct
illumination from lights onto surfaces.
- Global light manger - responsible for computing the total
(direct+indirect) illumination reaching a surface. The direct illumination
is computed by calling the direct light manager. The indirect illumination
is split into serveral parts:
- Primary diffuse illumination. This is used to approximate indirect illumination
for surfaces directly visible by the camera.
- Secondary diffuse illumination. This is used to approximate indirect
illumination while computing the primary diffuse illumination.
- Caustics. These are caused by light reaching diffuse surfaces through
specular reflections/refractions.
V-Ray does not provide methods for sampling glossy illumination - this must
be handled by shaders, typically by brute-force integration over the hemisphere.
V-Ray can use different methods for computing indirect illumination:
- Primary diffuse illumination:
- direct integraton over the hemisphere;
- irradiance cache;
- light cache;
- photon map.
- Secondary diffuse illumination:
- direct integration over the hemisphere;
- light cache;
- photon map.
- Caustics:
- Caustics can be accounted for by the above methods, although typically
at high computational cost. As an option, they can be computed separately
through photon mapping.
Which methods will be used depends on the V-Ray parameters in the sequence data.
For more information, consult the V-Ray user manual.
V-Ray implementation requirements
Typically, the only thing that a V-Ray implementation must provide is an instance
of class VRayDirectLightManager. This must be provided
as a pointer in the sequence data structure. The default GI engine will call
different methods of this class to calculate the GI successfully.
The most important method is the VRayDirectLightManager::eval()
method. This computes the amount of direct light hitting a surface and reflected
towards the viewer.
Although not required in general, the additional EXT_PHOTON_LIGHT_MANAGER
and EXT_CAUSTICS_PHOTON_LIGHT_MANAGER must be supported
by the direct light manager, if you want to be able to compute caustics and
use the photon map as a GI engine.
An example direct light manager supporting the photon extensions is provided
with the sample renderer in the SDK. It simply passes the respective calls to
the scene lights and accumulates the result.
If you want to use an alternative global illumination engine, you can replace
the default one used by V-Ray by setting the appropritate member in the sequence
data structure.
Shader requirements
V-Ray has no specific requirements to shaders with respect to GI, in the sense
that the same shaders are used for normal rendering, direct light evaluation
and GI. However, there are some considerations to be made so that the behaviour
is what the user expects:
- When reflected or refracted rays are traced during gathering GI calculations
(VRayContext::rayparams.rayType & RT_INDIRECT
is non-zero), the shader must check if reflective/refractive GI caustics are
enabled. If not, the respective rays must not be traced. Those rays must not
be traced when photon-mapped caustics are used, either.
- When hilights are computed during gathering GI calculations, the shader
must check if reflective/refractive caustics are enabled. If not, hilights
must not be computed. These must not be computed when photon-mapped caustics
are used, either.
- V-Ray supports combined sampling of area lights. Those can be sampled either
through direct sampling of the lights, or through the gathering process performed
by the GI engine/shader reflection sampling, or by a combination of the two.
Shaders must choose which method to support. For more details, see the documentation
of class BRDFSampler.
- Shaders that are both transparent with respect to shadows and
refractive to the camera must take care not to add light contribution twice
(once during direct light sampling with transparent shadows, and once during
gathering GI calculations). It would be best to make the shader transparent
with respect to GI too.
Light requirements
There are also some considerations when writing lights:
- If the photon map or caustics are supported by a light, it must implement
the LightInterface::setPhotonRay(), LightInterface::getNumPhotons()
and LightInterface::getNumCausticsPhotons() methods.
- If caustics are on, the light must not compute highlights during gathering
GI calculations - those will be computed by the caustics photon map.
- If caustics are on, area lights must appear black for reflected/refracted
rays during gathering GI calculations - the contribution of these rays is
computed by the caustics photon map.