#include <shader_bsdf.h>
Public Types | |
typedef bool | Transport |
sampling/evaluation direction | |
enum | Type { Invalid = 0x00, Reflect_diffuse = 0x01, Reflect_glossy = 0x02, Reflect_specular = 0x04, Transmit_diffuse = 0x10, Transmit_glossy = 0x20, Transmit_specular = 0x40, Reflect_regular, Transmit_regular, All_diffuse, All_glossy, All_specular, All_regular, All_reflect, All_transmit, All } |
Public Member Functions | |
virtual miColor | eval (const miVector &ray, const miVector &out, Type flags=All, Transport dir=From_eye) const =0 |
virtual Type | sample (const miVector &ray, miVector *out, miColor *weight, double xi[3], Type flags=All, Transport dir=From_eye) const =0 |
virtual bool | all_components (Type type) const =0 |
virtual bool | any_component (Type type) const =0 |
Static Public Attributes | |
const Transport | From_eye = false |
rendering from the camera | |
const Transport | From_light = true |
from the light, e.g. photons |
The Bsdf
interface represents the concept of a Bidirectional Scattering Distribution Function. The BSDF describes the scattering characteristics of a point, i.e. reflection (the BRDF), and transmission (the BTDF).
This interface allows shaders to interact with BSDFs. It is intended to serve the same purpose as the RC Direction Functions and Shading Models functions (see the manual), but in a generalized way.
For example, a shader might use a Bsdf
in the following way:
Access_bsdf bsdf(state); // do light loop for (...) { direct += light * bsdf->eval(view_dir,light_dir); }
If diffuse and specular contributions are needed separately, the BSDF evaluation can be restricted by passing e.g. Bsdf::Reflect_diffuse
or Bsdf::All_glossy
as the third parameter of the eval
function. Note, however, that multiple separate evaluations of components are more expensive than a single evaluation of all components.
Note that specular components cannot be evaluated, they have to be sampled. Thus, reflections of light sources in perfect mirrors can be achieved by code similar to
double xi[3]; mi_sample(xi,0,state,3,0); if (bsdf->sample(view_dir,&refl_dir,&mirror,xi,Bsdf::Reflect_specular) && mi_trace_reflection(&hit,state,&refl_dir) && !state->child->pri) { // light source hit light_hit = mirror * hit; }
|
|
Checks if the BSDF supports all of the given components.
If
|
|
Checks if the BSDF supports the given component.
If
|
|
Evaluates the BSDF at the current point.
When tracing rays from the eye towards the scene (the usual case),
Because specular components cannot be evaluated (they can only be sampled), this function only evaluates the diffuse and glossy parts. The contribution from specular components is black. Shaders must use
|
|
Importance samples an outgoing direction using the quasirandom numbers supplied in
All directions are in world space. The
The importance sampling weight (i.e. the BSDF value for the sampled direction divided by the probability of sampling the direction) will be written to
This function returns the type of the component that was sampled. Note that, while this function may return
Suitable values for
|
Copyright © 1986-2008 by
mental images GmbH