Developer Examples

Developer Examples

This page provides examples of Bxdfs (Materials) that may be useful for developers.


Bxdfs

The following Bxdfs are included with the RPS distribution primarily as reference examples for those who wish to write their own Bxdfs.

PxrDiffuse

images/bxdfball_diffuse.png

An ideal (Lambertian) diffuse material.

Parameters
"color diffuseColor"
The color of the surface. Default is white (1,1,1).
"color transmissionColor"
When non-zero, light arriving from the back side of the surface is transmitted to the front after being attenuated by the value of this parameter. This feature is useful to approximate the look of thin translucent objects, such as leaves or canvas. Since light is integrated on both sides of the surface this effect can double the light integration costs. Also, if your surface is not thin, then you may incur the extra light costs only to find that back-side light is occluded. Default is black (0, 0, 0), i.e. thin translucency is not enabled.

PxrConstant

images/bxdfball_constant.png

A material with constant color: an emitter with no reflection. Independent of illumination and viewing direction.

Parameters
"color emitColor"
The emitted color. Default is white (1,1,1).

PxrASSurface

PxrASSurface is an implementation of the Ashikhmin-Shirley BRDF from "An Anisotropic Phong BDRF Model" by Michael Ashikhmin and Peter Shirley.

Parameters
"color diffuseColor"
The diffuse color of the surface. Default is white (1,1,1).
"color specularColor"
The specular color of the surface. Default is white (1,1,1).
"float ks"
Multiplier on specular color. Default is 0.04.
"float roughness"
Surface roughness. 0 means completely smooth. Default is 0.001.
"float anisoRatio"
Ratio of anisotropy. Default value is 1.

PxrSubsurface

A simple subsurface scattering-only material. The scattering model is a simple approximation of beam diffusion and single-scattering.

Parameters
"color albedo"
The diffuse albedo. Default value is (0.830, 0.791, 0.753), corresponding to white marble.
"color diffuseMeanFreePath"
Default value is (8.51, 5.57, 3.95), corresponding to white marble. Measured in mm.
"float unitLength"
A multiplier on diffuseMeanFreePath. Can be used to convert modeling units, for example from cm to mm. Default value is 0.1.
"float indirectAtSss"
Determines whether or not indirect lighting samples are generated at SSS ray hit points (0, or "off" by default).

PxrBeerGlass

A smooth glass material with Fresnel reflection and refraction and Beer's law (exponential fall-off) in the interior, the PxrBeerGlass Bxdf is a good example of a simple Bxdf with an interior integrator. In addition to the usual functions such as GenerateSample(), EvaluateSample(), and EvaluateSamplesAtIndex(), PxrBeerGlass also has a GetInterior() function, which returns a pointer to its interior (which has been constructed in the PxrBeerGlass constructor).

PxrBeerGlassInterior is the interior integrator for PxrBeerGlass. Its GetNearestHits() function does two things: first, it calls the regular GetNearestHits() function to trace the pending rays, then it loops over the rays and, for those rays that entered the object interior, it computes Beer's Law extinction based on the length of the ray and the absorption coefficients. The result is stored in the transmission result parameter. Note that some of these rays may be traced in a direction away from the object - no further action is taken for those rays (i.e. their transmission is set to (1,1,1)).

Parameters
"float eta"
Index of refraction. Default value is 1.5 (glass).
"color absorption"
Absorption coefficients for the exponential fall-off in the interior. Default value is (0,0,0) for no absorption and values can extend beyond the zero-to-one range.

PxrSmoothDielectric

A smooth dielectric material such as plastic with diffuse and specular reflection determined by a Fresnel term.

Parameters
"color diffuseColor"
The diffuse color of the surface. Default is pale blue (0.15, 0.15, 0.45).
"color specularColor"
The specular color of the surface. Default is (0.04, 0.04, 0.04).

PxrConductor

A smooth or rough conductor material such as metal.

Isotropic reflection only (no anisotropic reflection and no refraction). No Fresnel term. Mainly a testbed/showcase for the firefly noise reduction that comes from using Heitz and d'Eons visible normals importance sampling. (The firefly reduction is most visible for large roughness and when other types of fireflies aren't present.)

Uses the GGX model and Smith shadowing from Walter et al, "Microfacet Models for Refraction through Rough Surfaces" (EGSR 2007). Importance-sampling of microfacet orientations (only visible microfacet normals) from Heitz and d'Eon, "Importance Sampling Microfacet-Based BSDFs using the Distribution of Visible Normals" (EGSR 2014).

Parameters
"color specularColor"
The specular color of the surface. Default is (1, 1, 1).
"float roughness"
Surface roughness. 0 means completely smooth. Default is 0.1. Note that roughness gets squared: alpha = roughness^2 for perceptual reasons as in PxrDisney and some other Bxdfs.