This class is responsible for the on-demand creation of GPU shaders to render shapes that are illuminated by virtual point light sources. More...
#include <mitsuba/hw/vpl.h>
Classes | |
struct | AnimatedGeometryRecord |
Helper data structure to keep track of shapes that are undergoing keyframe animations. More... | |
struct | DependencyNode |
This helper class stores a reference to a Shader and all sub-shaders that are part of its evaluation. More... | |
struct | MaterialOrder |
Order materials so that they can be drawn with the least number of GPU pipeline flushes. Draw transparent objects last. More... | |
struct | VPLConfiguration |
Describes the configuration of a (vpl, bsdf, emitter) shader chain triplet. More... | |
Public Member Functions | |
VPLShaderManager (Renderer *renderer) | |
Create a new shader manager. More... | |
void | init () |
Upload requisite shaders to the GPU. To be called once. More... | |
void | cleanup () |
Issue a final cleanup (before destroying the shader manager) More... | |
void | setScene (const Scene *scene) |
Associate the shader manager with a new scene. More... | |
const Scene * | getScene () const |
Return the currently bound scene. More... | |
void | setVPL (const VPL &vpl) |
Prepare the shader manager for rendering with a new VPL. More... | |
void | bind (const VPL &vpl, const BSDF *bsdf, const Sensor *sensor, const Emitter *emitter, const Matrix4x4 &instanceTransform, bool faceNormals) |
Bind a shader for rendering a certain VPL/BSDF/Emitter triplet. More... | |
void | unbind () |
Release the currently bound shader and any resources (textures,..) that it references. More... | |
void | drawAllGeometryForVPL (const VPL &vpl, const Sensor *sensor) |
Convenience function for rendering all geometry for a given VPL. More... | |
void | drawBackground (const Sensor *sensor, const Transform &projectionTransform, Float scaleFactor) |
Draw the background if there is an environment emitter. More... | |
void | setClamping (Float clamping) |
Set the clamping distance. More... | |
Float | getClamping () const |
Return the clamping distance. More... | |
void | setShadowMapResolution (int resolution) |
Set the current shadow map resolution. More... | |
int | getShadowMapResolution () const |
Return the current shadow map resolution. More... | |
void | setDiffuseSources (bool diffuseSources) |
Set whether or not non-diffuse VPLs are used. More... | |
bool | getDiffuseSources () const |
Return whether or not non-diffuse VPLs are used. More... | |
void | setDiffuseReceivers (bool diffuseReceivers) |
Set whether or not surfaces are drawn assumed to be diffuse. More... | |
bool | getDiffuseReceivers () const |
Return whether or not surfaces are assumed to be diffuse. More... | |
void | resetCounter () |
Reset the VPL counter. More... | |
Public Member Functions inherited from Object | |
Object () | |
Construct a new object. More... | |
int | getRefCount () const |
Return the current reference count. More... | |
void | incRef () const |
Increase the reference count of the object by one. More... | |
void | decRef (bool autoDeallocate=true) const |
Decrease the reference count of the object and possibly deallocate it. More... | |
virtual std::string | toString () const |
Return a human-readable string representation of the object's contents. More... | |
Static Public Attributes | |
static Class * | m_theClass |
Static Public Attributes inherited from Object | |
static Class * | m_theClass |
Pointer to the object's class descriptor. More... | |
Protected Member Functions | |
virtual | ~VPLShaderManager () |
Virtual destructor. More... | |
virtual const Class * | getClass () const |
Retrieve this object's class. More... | |
Protected Member Functions inherited from Object | |
virtual | ~Object () |
Virtual private deconstructor. (Will only be called by ref) More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Object | |
static void | staticInitialization () |
Initializes the built-in reference count debugger (if enabled) More... | |
static void | staticShutdown () |
Free the memory taken by staticInitialization() More... | |
This class is responsible for the on-demand creation of GPU shaders to render shapes that are illuminated by virtual point light sources.
This is used to drive the vpl
integrator as well as the interactive preview in the Mitsuba GUI.
For each encountered BSDF-VPL pair, a custom piece of code describing the characteristic light transport between them is created and cached. The implementation carefully looks at the tree of shader dependencies and creates code that can be shared with other materials that have a similar configuration. This is necessary to avoid generating a potentially huge O(N^2) number of very similar programs and brings it down to O(n^2) where n << N.
mitsuba::VPLShaderManager::VPLShaderManager | ( | Renderer * | renderer | ) |
Create a new shader manager.
|
protectedvirtual |
Virtual destructor.
void mitsuba::VPLShaderManager::bind | ( | const VPL & | vpl, |
const BSDF * | bsdf, | ||
const Sensor * | sensor, | ||
const Emitter * | emitter, | ||
const Matrix4x4 & | instanceTransform, | ||
bool | faceNormals | ||
) |
Bind a shader for rendering a certain VPL/BSDF/Emitter triplet.
vpl | Record describing the virtual point light source |
bsdf | Material of the object to be rendered |
sensor | Sensor from which it is viewed |
instanceTransform | An additional object-to-world transformation that is applied to the rendered geometry. Used for instancing. |
faceNormals | When set to true , a special shader is used to create face normals for the geometry |
void mitsuba::VPLShaderManager::cleanup | ( | ) |
Issue a final cleanup (before destroying the shader manager)
void mitsuba::VPLShaderManager::drawBackground | ( | const Sensor * | sensor, |
const Transform & | projectionTransform, | ||
Float | scaleFactor | ||
) |
Draw the background if there is an environment emitter.
|
inline |
Return the clamping distance.
|
protectedvirtual |
Retrieve this object's class.
Reimplemented from Object.
|
inline |
Return whether or not surfaces are assumed to be diffuse.
|
inline |
Return whether or not non-diffuse VPLs are used.
|
inline |
Return the currently bound scene.
|
inline |
Return the current shadow map resolution.
void mitsuba::VPLShaderManager::init | ( | ) |
Upload requisite shaders to the GPU. To be called once.
|
inline |
Reset the VPL counter.
|
inline |
Set the clamping distance.
|
inline |
Set whether or not surfaces are drawn assumed to be diffuse.
|
inline |
Set whether or not non-diffuse VPLs are used.
void mitsuba::VPLShaderManager::setScene | ( | const Scene * | scene | ) |
Associate the shader manager with a new scene.
This function uploads all relevant triangle geometry to the GPU, and releases any resources held for the previous scene. It is valid to call the function with a NULL
argument.
|
inline |
Set the current shadow map resolution.
void mitsuba::VPLShaderManager::setVPL | ( | const VPL & | vpl | ) |
Prepare the shader manager for rendering with a new VPL.
Must be called after setScene() and before bind(). This function creates a suitable shadow map for the VPL.
void mitsuba::VPLShaderManager::unbind | ( | ) |
Release the currently bound shader and any resources (textures,..) that it references.
|
static |