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

Abstract BSDF base-class. More...

#include <mitsuba/render/bsdf.h>

+ Inheritance diagram for mitsuba::BSDF:

Public Types

enum  EBSDFType {
  ENull = 0x00001, EDiffuseReflection = 0x00002, EDiffuseTransmission = 0x00004, EGlossyReflection = 0x00008,
  EGlossyTransmission = 0x00010, EDeltaReflection = 0x00020, EDeltaTransmission = 0x00040, EDelta1DReflection = 0x00080,
  EDelta1DTransmission = 0x00100, EAnisotropic = 0x01000, ESpatiallyVarying = 0x02000, ENonSymmetric = 0x04000,
  EFrontSide = 0x08000, EBackSide = 0x10000, EUsesSampler = 0x20000
}
 This list of flags is used to classify the different types of lobes that are implemented in a BSDF instance. More...
 
enum  ETypeCombinations {
  EReflection, ETransmission, EDiffuse = EDiffuseReflection | EDiffuseTransmission, EGlossy = EGlossyReflection | EGlossyTransmission,
  ESmooth = EDiffuse | EGlossy, EDelta = ENull | EDeltaReflection | EDeltaTransmission, EDelta1D = EDelta1DReflection | EDelta1DTransmission, EAll = EDiffuse | EGlossy | EDelta | EDelta1D
}
 Convenient combinations of flags from EBSDFType. More...
 

Public Member Functions

int getComponentCount () const
 Return the number of components of this BSDF. More...
 
unsigned int getType () const
 Return a listing of this BSDF's component types and properties, combined using binary OR. More...
 
unsigned int getType (int component) const
 
bool hasComponent (unsigned int type) const
 Test whether this BSDF contains a certain type of component. More...
 
bool usesRayDifferentials () const
 Return whether this BSDF makes use of ray differentials. More...
 
virtual Spectrum getDiffuseReflectance (const Intersection &its) const
 Return the diffuse reflectance value (if any) More...
 
virtual Spectrum getSpecularReflectance (const Intersection &its) const
 Return the specular reflectance value (if any) More...
 
virtual Spectrum sample (BSDFSamplingRecord &bRec, const Point2 &sample) const =0
 Sample the BSDF and return the importance weight (i.e. the value of the BSDF divided by the probability density of the sample). More...
 
virtual Spectrum sample (BSDFSamplingRecord &bRec, Float &pdf, const Point2 &sample) const =0
 Sample the BSDF and return the probability density and the importance weight of the sample (i.e. the value of the BSDF divided by the probability density) More...
 
virtual Spectrum eval (const BSDFSamplingRecord &bRec, EMeasure measure=ESolidAngle) const =0
 Evaluate the BSDF f(wi, wo) or its adjoint version f^{*}(wi, wo) More...
 
virtual Float pdf (const BSDFSamplingRecord &bRec, EMeasure measure=ESolidAngle) const =0
 Compute the probability of sampling bRec.wo (given bRec.wi). More...
 
virtual Float getEta () const
 For transmissive BSDFs: return the material's relative index of refraction. More...
 
virtual Float getRoughness (const Intersection &its, int index) const
 For rough BSDFs: return the root mean square surface roughness of the given BSDF component. More...
 
virtual Frame getFrame (const Intersection &its) const
 Sometimes, BSDF models make use of a perturbed frame for internal shading computations (e.g. bump maps). This function exposes this internal frame. More...
 
virtual void getFrameDerivative (const Intersection &its, Frame &du, Frame &dv) const
 Sometimes, BSDF models make use of a perturbed frame for internal shading computations (e.g. bump maps). This function computes the derivative of this frame with respect to the UV parameterization of the underlying shape. More...
 
virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
ConfigurableObject interface
virtual void configure ()
 Configure the material (called after construction by the XML parser) More...
 
virtual void addChild (const std::string &string, ConfigurableObject *obj)
 Add a child object. More...
 
void addChild (ConfigurableObject *child)
 Add an unnamed child. More...
 
virtual void serialize (Stream *stream, InstanceManager *manager) const
 Serialize this object to a stream. More...
 
virtual void setParent (ConfigurableObject *parent)
 Set the parent object. More...
 
- Public Member Functions inherited from mitsuba::ConfigurableObject
void addChild (ConfigurableObject *child)
 Add an unnamed child. More...
 
const std::string & getID () const
 Return the identifier associated with this instance (or "unnamed") More...
 
void setID (const std::string &name)
 Set the identifier associated with this instance. More...
 
const PropertiesgetProperties () const
 Return the properties object that was originally used to create this instance. More...
 
- Public Member Functions inherited from mitsuba::SerializableObject
 SerializableObject (Stream *stream, InstanceManager *manager)
 Unserialize a serializable object. 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...
 
- Public Member Functions inherited from mitsuba::HWResource
virtual ShadercreateShader (Renderer *renderer) const
 
virtual ~HWResource ()
 

Static Public Member Functions

static EMeasure getMeasure (unsigned int componentType)
 Return the measure corresponding to a particular component type. More...
 
- 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...
 

Static Public Attributes

static Classm_theClass
 
- Static Public Attributes inherited from mitsuba::ConfigurableObject
static Classm_theClass
 
- Static Public Attributes inherited from mitsuba::SerializableObject
static Classm_theClass
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Protected Member Functions

 BSDF (const Properties &props)
 Create a new BSDF instance. More...
 
 BSDF (Stream *stream, InstanceManager *manager)
 Unserialize a BSDF instance. More...
 
TextureensureEnergyConservation (Texture *tex, const std::string &paramName, Float max) const
 Convenience function to ensure energy conservation. More...
 
std::pair< Texture *, Texture * > ensureEnergyConservation (Texture *tex1, Texture *tex2, const std::string &paramName1, const std::string &paramName2, Float max) const
 Convenience function to ensure energy conservation. More...
 
virtual ~BSDF ()
 Virtual destructor. More...
 
- Protected Member Functions inherited from mitsuba::ConfigurableObject
virtual ~ConfigurableObject ()
 Virtual destructor. More...
 
 ConfigurableObject (const Properties &props)
 Construct a configurable object. More...
 
 ConfigurableObject (Stream *stream, InstanceManager *manager)
 Unserialize a configurable object. More...
 
- Protected Member Functions inherited from mitsuba::SerializableObject
 SerializableObject ()
 Construct a serializable object. More...
 
virtual ~SerializableObject ()
 Virtual deconstructor. More...
 
- Protected Member Functions inherited from Object
virtual ~Object ()
 Virtual private deconstructor. (Will only be called by ref) More...
 

Protected Attributes

std::vector< unsigned int > m_components
 
unsigned int m_combinedType
 
bool m_usesRayDifferentials
 
bool m_ensureEnergyConservation
 
- Protected Attributes inherited from mitsuba::ConfigurableObject
Properties m_properties
 

Detailed Description

Abstract BSDF base-class.

This class implements an abstract interface to all BSDF plugins in Mitsuba. It exposes functions for evaluating and sampling the model, and it allows querying the probability density of the sampling method. Smooth two-dimensional density functions, as well as degenerate one-dimensional and discrete densities are all handled within the same framework.

For improved flexibility with respect to the various rendering algorithms, this class can sample and evaluate a complete BSDF, but it also allows to pick and choose individual components of multi-lobed BSDFs based on their properties and component indices. This selection is specified using a special record that is provided along with every query.

BSDFSamplingRecord.

Member Enumeration Documentation

This list of flags is used to classify the different types of lobes that are implemented in a BSDF instance.

They are also useful for picking out individual components by setting combinations in BSDFSamplingRecord::typeMask.

Enumerator
ENull 

'null' scattering event, i.e. particles do not undergo deflection

EDiffuseReflection 

Ideally diffuse reflection.

EDiffuseTransmission 

Ideally diffuse transmission.

EGlossyReflection 

Glossy reflection.

EGlossyTransmission 

Glossy transmission.

EDeltaReflection 

Reflection into a discrete set of directions.

EDeltaTransmission 

Transmission into a discrete set of directions.

EDelta1DReflection 

Reflection into a 1D space of directions.

EDelta1DTransmission 

Transmission into a 1D space of directions.

EAnisotropic 

Other lobe attributes.

The lobe is not invariant to rotation around the normal

ESpatiallyVarying 

The BSDF depends on the UV coordinates.

ENonSymmetric 

Flags non-symmetry (e.g. transmission in dielectric materials)

EFrontSide 

Supports interactions on the front-facing side.

EBackSide 

Supports interactions on the back-facing side.

EUsesSampler 

Uses extra random numbers from the supplied sampler instance.

Convenient combinations of flags from EBSDFType.

Enumerator
EReflection 

Any reflection component (scattering into discrete, 1D, or 2D set of directions)

ETransmission 

Any transmission component (scattering into discrete, 1D, or 2D set of directions)

EDiffuse 

Diffuse scattering into a 2D set of directions.

EGlossy 

Non-diffuse scattering into a 2D set of directions.

ESmooth 

Scattering into a 2D set of directions.

EDelta 

Scattering into a discrete set of directions.

EDelta1D 

Scattering into a 1D space of directions.

EAll 

Any kind of scattering.

Constructor & Destructor Documentation

mitsuba::BSDF::BSDF ( const Properties props)
protected

Create a new BSDF instance.

mitsuba::BSDF::BSDF ( Stream stream,
InstanceManager manager 
)
protected

Unserialize a BSDF instance.

virtual mitsuba::BSDF::~BSDF ( )
protectedvirtual

Virtual destructor.

Member Function Documentation

virtual void mitsuba::BSDF::addChild ( const std::string &  string,
ConfigurableObject obj 
)
virtual

Add a child object.

Reimplemented from mitsuba::ConfigurableObject.

void mitsuba::BSDF::addChild ( ConfigurableObject child)
inline

Add an unnamed child.

virtual void mitsuba::BSDF::configure ( )
virtual

Configure the material (called after construction by the XML parser)

Reimplemented from mitsuba::ConfigurableObject.

Texture* mitsuba::BSDF::ensureEnergyConservation ( Texture tex,
const std::string &  paramName,
Float  max 
) const
protected

Convenience function to ensure energy conservation.

This function determines the component-wise maximum of the texture tex and checks if it is below max. If yes, it returns the texture unmodified. Otherwise, it wraps the texture into a ScaleTexture instance (with a scaling factor chosen so that the desired maximum max is abided) and prints a warning.

std::pair<Texture *, Texture *> mitsuba::BSDF::ensureEnergyConservation ( Texture tex1,
Texture tex2,
const std::string &  paramName1,
const std::string &  paramName2,
Float  max 
) const
protected

Convenience function to ensure energy conservation.

This function determines the component-wise maximum of the sum tex1 + tex2 and checks if it is below max. If yes, it returns the texture unmodified. Otherwise, it wraps each the texture into a ScaleTexture instance (with a scaling factor chosen so that the desired maximum max is abided) and prints a warning.

virtual Spectrum mitsuba::BSDF::eval ( const BSDFSamplingRecord bRec,
EMeasure  measure = ESolidAngle 
) const
pure virtual

Evaluate the BSDF f(wi, wo) or its adjoint version f^{*}(wi, wo)

This method allows to query the BSDF as a whole or pick out individual components. When querying a smooth (i.e. non-degenerate) component, it already multiplies the result by the cosine foreshortening factor with respect to the outgoing direction.

Parameters
bRecA record with detailed information on the BSDF query
measureSpecifies the measure of the component. This is necessary to handle BSDFs, whose components live on spaces with different measures. (E.g. a diffuse material with an ideally smooth dielectric coating).
virtual const Class* mitsuba::BSDF::getClass ( ) const
virtual

Retrieve this object's class.

Reimplemented from mitsuba::ConfigurableObject.

int mitsuba::BSDF::getComponentCount ( ) const
inline

Return the number of components of this BSDF.

virtual Spectrum mitsuba::BSDF::getDiffuseReflectance ( const Intersection its) const
virtual

Return the diffuse reflectance value (if any)

virtual Float mitsuba::BSDF::getEta ( ) const
virtual

For transmissive BSDFs: return the material's relative index of refraction.

The default implementation returns 1.0.

Returns
interior IOR / exteriorIOR
virtual Frame mitsuba::BSDF::getFrame ( const Intersection its) const
virtual

Sometimes, BSDF models make use of a perturbed frame for internal shading computations (e.g. bump maps). This function exposes this internal frame.

By default, it returns its.shFrame

virtual void mitsuba::BSDF::getFrameDerivative ( const Intersection its,
Frame du,
Frame dv 
) const
virtual

Sometimes, BSDF models make use of a perturbed frame for internal shading computations (e.g. bump maps). This function computes the derivative of this frame with respect to the UV parameterization of the underlying shape.

static EMeasure mitsuba::BSDF::getMeasure ( unsigned int  componentType)
inlinestatic

Return the measure corresponding to a particular component type.

virtual Float mitsuba::BSDF::getRoughness ( const Intersection its,
int  index 
) const
virtual

For rough BSDFs: return the root mean square surface roughness of the given BSDF component.

An infinite value indicates a component that is ideally diffuse

virtual Spectrum mitsuba::BSDF::getSpecularReflectance ( const Intersection its) const
inlinevirtual

Return the specular reflectance value (if any)

unsigned int mitsuba::BSDF::getType ( ) const
inline

Return a listing of this BSDF's component types and properties, combined using binary OR.

See Also
EBSDFType
unsigned int mitsuba::BSDF::getType ( int  component) const
inline

Returns the classification flags of a specific component

See Also
EBSDFType
bool mitsuba::BSDF::hasComponent ( unsigned int  type) const
inline

Test whether this BSDF contains a certain type of component.

virtual Float mitsuba::BSDF::pdf ( const BSDFSamplingRecord bRec,
EMeasure  measure = ESolidAngle 
) const
pure virtual

Compute the probability of sampling bRec.wo (given bRec.wi).

This method provides access to the probability density that would result when supplying the same BSDF query record to the sample() method. It correctly handles changes in probability when only a subset of the components is chosen for sampling (this can be done using the BSDFSamplingRecord::component and BSDFSamplingRecord::typeMask fields).

Parameters
bRecA record with detailed information on the BSDF query
measureSpecifies the measure of the component. This is necessary to handle BSDFs, whose components live on spaces with different measures. (E.g. a diffuse material with an ideally smooth dielectric coating).
virtual Spectrum mitsuba::BSDF::sample ( BSDFSamplingRecord bRec,
const Point2 sample 
) const
pure virtual

Sample the BSDF and return the importance weight (i.e. the value of the BSDF divided by the probability density of the sample).

When the probability density is not explicitly required, this function should be preferred, since it is potentially faster by making use of cancellations during the division.

If a component mask or a specific component index is specified, the sample is drawn from the matching component, if it exists. Depending on the provided transport type, either the BSDF or its adjoint version is used.

Parameters
bRecA BSDF query record
sampleA uniformly distributed sample on \([0,1]^2\)
Returns
The BSDF value divided by the probability density of the sample sample (multiplied by the cosine foreshortening factor when a non-delta component is sampled) A zero spectrum means that sampling failed.
Remarks
This function is not exposed by the Python API. See the other sample function instead.
virtual Spectrum mitsuba::BSDF::sample ( BSDFSamplingRecord bRec,
Float pdf,
const Point2 sample 
) const
pure virtual

Sample the BSDF and return the probability density and the importance weight of the sample (i.e. the value of the BSDF divided by the probability density)

If a component mask or a specific component index is specified, the sample is drawn from the matching component, if it exists. Depending on the provided transport type, either the BSDF or its adjoint version is used.

When sampling a continuous/non-delta component, this method also multiplies by the cosine foreshorening factor with respect to the sampled direction.

Parameters
bRecA BSDF query record
sampleA uniformly distributed sample on \([0,1]^2\)
pdfWill record the probability with respect to solid angles (or the discrete probability when a delta component is sampled)
Returns
The BSDF value (multiplied by the cosine foreshortening factor when a non-delta component is sampled). A zero spectrum means that sampling failed.
Remarks
From Python, this function is is called using the syntax value, pdf = bsdf.sample(bRec, sample)
virtual void mitsuba::BSDF::serialize ( Stream stream,
InstanceManager manager 
) const
virtual

Serialize this object to a stream.

Reimplemented from mitsuba::ConfigurableObject.

virtual void mitsuba::BSDF::setParent ( ConfigurableObject parent)
virtual

Set the parent object.

Reimplemented from mitsuba::ConfigurableObject.

bool mitsuba::BSDF::usesRayDifferentials ( ) const
inline

Return whether this BSDF makes use of ray differentials.

Member Data Documentation

unsigned int mitsuba::BSDF::m_combinedType
protected
std::vector<unsigned int> mitsuba::BSDF::m_components
protected
bool mitsuba::BSDF::m_ensureEnergyConservation
protected
Class* mitsuba::BSDF::m_theClass
static
bool mitsuba::BSDF::m_usesRayDifferentials
protected

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