Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::VPLShaderManager Class Reference

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>

+ Inheritance diagram for mitsuba::VPLShaderManager:

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 ScenegetScene () 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 Classm_theClass
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Protected Member Functions

virtual ~VPLShaderManager ()
 Virtual destructor. More...
 
virtual const ClassgetClass () 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

mitsuba::VPLShaderManager::VPLShaderManager ( Renderer renderer)

Create a new shader manager.

virtual mitsuba::VPLShaderManager::~VPLShaderManager ( )
protectedvirtual

Virtual destructor.

Member Function Documentation

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.

Parameters
vplRecord describing the virtual point light source
bsdfMaterial of the object to be rendered
sensorSensor from which it is viewed
instanceTransformAn additional object-to-world transformation that is applied to the rendered geometry. Used for instancing.
faceNormalsWhen 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::drawAllGeometryForVPL ( const VPL vpl,
const Sensor sensor 
)

Convenience function for rendering all geometry for a given VPL.

This function issues the necessary calls to bind() unbind(), etc., and schedules draw calls for all of the scene geometry.

void mitsuba::VPLShaderManager::drawBackground ( const Sensor sensor,
const Transform projectionTransform,
Float  scaleFactor 
)

Draw the background if there is an environment emitter.

Float mitsuba::VPLShaderManager::getClamping ( ) const
inline

Return the clamping distance.

virtual const Class* mitsuba::VPLShaderManager::getClass ( ) const
protectedvirtual

Retrieve this object's class.

Reimplemented from Object.

bool mitsuba::VPLShaderManager::getDiffuseReceivers ( ) const
inline

Return whether or not surfaces are assumed to be diffuse.

bool mitsuba::VPLShaderManager::getDiffuseSources ( ) const
inline

Return whether or not non-diffuse VPLs are used.

const Scene* mitsuba::VPLShaderManager::getScene ( ) const
inline

Return the currently bound scene.

int mitsuba::VPLShaderManager::getShadowMapResolution ( ) const
inline

Return the current shadow map resolution.

void mitsuba::VPLShaderManager::init ( )

Upload requisite shaders to the GPU. To be called once.

void mitsuba::VPLShaderManager::resetCounter ( )
inline

Reset the VPL counter.

void mitsuba::VPLShaderManager::setClamping ( Float  clamping)
inline

Set the clamping distance.

void mitsuba::VPLShaderManager::setDiffuseReceivers ( bool  diffuseReceivers)
inline

Set whether or not surfaces are drawn assumed to be diffuse.

void mitsuba::VPLShaderManager::setDiffuseSources ( bool  diffuseSources)
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.

void mitsuba::VPLShaderManager::setShadowMapResolution ( int  resolution)
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.

Member Data Documentation

Class* mitsuba::VPLShaderManager::m_theClass
static

The documentation for this class was generated from the following file: