Support Forum G3D Web Page |
G3D's default description of how a surface reflects light (photons).
More...
Inherits G3D::ReferenceCountedObject.
Public Member Functions | |
bool | conservativelyHasTransparency () const |
If the lambertian channel potentially has non-unit alpha or the transmission channel is non-trivially non-zero, returns true. More... | |
float | etaReflect () const |
for the material on the outside of this object (i.e. More... | |
float | etaTransmit () const |
for the material on the inside of this object (i.e. More... | |
const Color3 & | extinctionReflect () const |
Extinction coefficient for the material on the outside; complex part of the index of refraction. More... | |
const Color3 & | extinctionTransmit () const |
Extinction coefficient for the material on the inside; complex part of the index of refraction. More... | |
const Component4 & | glossy () const |
Packed factors affecting mirror and glossy reflection. More... | |
bool | hasGlossy () const |
Return true if there is any glossy (non-Lambertian, non-mirror) reflection from this BSDF. More... | |
bool | hasLambertian () const |
Return true if there is any Lambertian reflection from this BSDF. More... | |
bool | hasMirror () const |
Return true if there is any mirror reflection from this BSDF. More... | |
bool | hasReflection () const |
Return true if there is any Lambertian, mirror, or glossy reflection from this BSDF (not just mirror!) More... | |
bool | isZero () const |
True if this absorbs all light. More... | |
const Component4 & | lambertian () const |
Packed factors affecting the lambertian term. More... | |
virtual void | setStorage (ImageStorage s) const |
Move or copy data to CPU or GPU. More... | |
const Component3 & | transmissive () const |
: transmissivity More... | |
Static Public Member Functions | |
static shared_ptr< UniversalBSDF > | create (const Component4 &lambertian, const Component4 &glossy=Texture::zero(), const Component3 &transmissive=Texture::opaqueBlack(), float eta_transmit=1.0f, const Color3 &extinction_transmit=Color3::zero(), float eta_reflect=1.0f, const Color3 &extinction_reflect=Color3::zero()) |
static float | packedGlossyNone () |
The value that a non-glossy surface is packed as. More... | |
static float | packedSpecularMirror () |
The value that a mirror's glossy exponent (infinity) is packed as. More... | |
static float | packGlossyExponent (float blinnPhongExponent) |
Maps a Blinn-Phong exponent to G3D engine smoothness. More... | |
static Color3 | schlickFresnel (const Color3 &F0, float cos_i, float smoothness) |
Computes F_r, given the cosine of the angle of incidence and the reflectance at normal incidence. More... | |
static float | smoothnessToBlinnPhongExponent (float g3dSmoothness) |
Maps a G3D engine smoothness value to a Blinn-Phong exponent. More... | |
Static Public Attributes | |
static float | ignoreFloat |
Protected Member Functions | |
UniversalBSDF () | |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
Protected Attributes | |
float | m_eta_r |
For the material on the outside. More... | |
float | m_eta_t |
For the material on the inside. More... | |
Color3 | m_extinction_r |
Color3 | m_extinction_t |
Extinction coefficient for the material on the inside; complex part of the index of refraction. More... | |
Component4 | m_glossy |
Packed factors affecting mirror and glossy reflection. More... | |
Component4 | m_lambertian |
Packed factors affecting the lambertian term. More... | |
Component3 | m_transmissive |
: transmissivity More... | |
G3D's default description of how a surface reflects light (photons).
This is an analytic energy-conserving Bidirectional Scattering Distribution Function (BSDF) with phenomenonlogically meaningful parameters. It comprises Lambertian reflection, Schlick's Fresnel approximation for glossy and mirror reflection, Sloan, Hoffman, and Lafortune's normalization of the Blinn-Phong glossy lobe, and transmission (without exponential extinction) terms. It is a extension of the isotropic version of Ashikhmin and Shirley's empirical BRDF http://www.cs.utah.edu/~shirley/papers/jgtbrdf.pdf .
The methods of this class are primarily used for photon mapping, ray tracing, and software rasterization. The G3D::UniversalMaterial class manages BSDFs for GPU rasterization.
A surface is the 2D boundary between two 3D volumes. BSDF works with single-sided surfaces, so it is assumed that for transparent materials there are two oppositely-oriented surfaces, typically with different BSDFs, at every such boundary. Thus there are two indices of refraction at a surface: one for the inside (side opposite the normal) and one for the outside.
The major routines are:
scatter() | ||
getImpulses() | ||
evaluate() |
The material is parameterized by:
[UniversalBSDF::lambertian.rgb, UniversalMaterial::Specification::setLambertian]. Peak Lambertian (a.k.a. "diffuse surface color") reflectance, on [0, 1]. The actual reflectance applied at normal incidence is | ||
[UniversalBSDF::transmissive, UniversalMaterial::Specification::setTransmissive]. Transmission modulation factor ("transparent color") for the entire volume, on [0, 1]; 0 for opaque surfaces. The actual transmission at normal incidence will be . This is a fast approximation. Use the extinction coefficients for true participating medium transmission. | ||
[UniversalBSDF::glossy.rgb, UniversalMaterial::Specification::setShininess]. Fresnel reflection at normal incidence (a.k.a. "glossy/glossy/reflection color") on [0, 1] | ||
[UniversalBSDF::glossy.a, UniversalMaterial::Specification::setShininess] Surface shininess/smoothness (a.k.a. "shininess", "glossy exponent") 0 for purely Lambertian surfaces, packedGlossyMirror() / UniversalMaterial::Specification::setMirrorShininess() for perfect reflection, and values between packGlossyExponent(1) and packGlossyExponent(128) for glossy reflection. This is used to compute , the exponent on the normalized Blinn-Phong lobe. | ||
Index of refraction outside the material, i.e., on the same side as the normal (only used for surfaces with ; for computing refraction angle, not used for Fresnel factor). | ||
Index of refraction inside the material, i.e., opposite the normal (only used for surfaces with ; for computing refraction angle, not used for Fresnel factor). |
For energy conservation, choose and .
The following terminology for photon scattering is used in the G3D::UniversalMaterial::Settings and G3D::UniversalBSDF classes and their documentation:
(Departures from theory for artistic control: The direct shader always applies a glossy highlight with an exponent of 128 to mirror surfaces so that light sources produce highlights. Setting the Glossy/Mirror coefficient to zero for a transmissive surface guarantees no reflection, although real transmissive surfaces should always be reflective at glancing angles.)
The BSDF consists of four terms (at most three of which are non-zero): Lambertian, Glossy, Mirror, and Transmissive,
where
All vectors point outward from the surface. Let
is the Fresnel mirror reflection coefficient, which is approximated by Schlick's method as shown above.
The factor is the only significant source of error in the BSDF. An accurate scatting function would transmit with probabilty and then attenuate the scattered photon based on the distance traveled through the translucent medium. The concession to applying a constant attenuation is a typical one in rendering, however.
UniversalBSDF is scheduled to be merged into G3D::UniversalMaterial in December 2012.
|
inlineprotected |
bool G3D::UniversalBSDF::conservativelyHasTransparency | ( | ) | const |
If the lambertian channel potentially has non-unit alpha or the transmission channel is non-trivially non-zero, returns true.
Used by the ArticulatedModel OBJ loader to detect meshes that should be made two-sided.
This does not force lazy loaded textures to load.
|
static |
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
|
inline |
for the material on the outside of this object (i.e.
side of the normal).
|
inline |
for the material on the inside of this object (i.e.
side opposite the normal).
|
inline |
Extinction coefficient for the material on the outside; complex part of the index of refraction.
http://en.wikipedia.org/wiki/Complex_index_of_refraction#Dispersion_and_absorption
|
inline |
Extinction coefficient for the material on the inside; complex part of the index of refraction.
http://en.wikipedia.org/wiki/Complex_index_of_refraction#Dispersion_and_absorption
|
inline |
Packed factors affecting mirror and glossy reflection.
bool G3D::UniversalBSDF::hasGlossy | ( | ) | const |
Return true if there is any glossy (non-Lambertian, non-mirror) reflection from this BSDF.
bool G3D::UniversalBSDF::hasLambertian | ( | ) | const |
Return true if there is any Lambertian reflection from this BSDF.
bool G3D::UniversalBSDF::hasMirror | ( | ) | const |
Return true if there is any mirror reflection from this BSDF.
|
inline |
Return true if there is any Lambertian, mirror, or glossy reflection from this BSDF (not just mirror!)
|
inline |
True if this absorbs all light.
|
inline |
Packed factors affecting the lambertian term.
|
inlinestatic |
The value that a non-glossy surface is packed as.
|
inlinestatic |
The value that a mirror's glossy exponent (infinity) is packed as.
|
inlinestatic |
Maps a Blinn-Phong exponent to G3D engine smoothness.
|
inlinestatic |
Computes F_r, given the cosine of the angle of incidence and the reflectance at normal incidence.
Uses smoothness as a masking term to keep rough surfaces from having too much Fresnel
|
virtual |
Move or copy data to CPU or GPU.
Called from G3DMaterial::setStorage().
|
inlinestatic |
Maps a G3D engine smoothness value to a Blinn-Phong exponent.
Note that 0 = no glossy and 1 = mirror are handled specially by many shaders.
The maximum exponent is clamped to 20k to avoid numerical precision problems in downstream computations.
|
inline |
: transmissivity
|
static |
|
protected |
For the material on the outside.
Referenced by etaReflect().
|
protected |
For the material on the inside.
Referenced by etaTransmit().
|
protected |
Referenced by extinctionReflect().
|
protected |
Extinction coefficient for the material on the inside; complex part of the index of refraction.
http://en.wikipedia.org/wiki/Complex_index_of_refraction#Dispersion_and_absorption
Referenced by extinctionTransmit().
|
protected |
Packed factors affecting mirror and glossy reflection.
Referenced by glossy(), hasReflection(), and isZero().
|
protected |
Packed factors affecting the lambertian term.
Referenced by hasReflection(), isZero(), and lambertian().
|
protected |
: transmissivity
Referenced by isZero(), and transmissive().