Deborah R. Fowler


back to Particles and Procedural Effects

Updated: Sept 3  2013  .

PBR, VEX and bsdf

A very popular technique right now is physically based rendering. Houdini uses a physically based renderer inside of mantra called PBR. This involved using an algorithm that is more physically based to take advantage of global illumination models. These kinds of algorithms have existed for several decades but have become very production friendly now that hardware needs have caught up.

Pixar, using renderman, has now started the process of using physically based lighting in their pipeline (
Siggraph 2013 - included Katana - Pixar's Fast Lighting Preview with NVIDIA Technology).

Lighting, shading and rendering are all heavily inter-related so this is simply a brief overview of how to get up to speed with bsdf in your vex/vops shaders for use with pbr in Houdini.


What is BSDF?

Bidirectional scattering distribution function - was probably introduced in 1991 by Paul Heckbert. It is often used to name the mathematical function which describes how light is scattered by a surface. In practice it is split into the reflected (BRDF) and transmitted (BTDF) components.

The general concept is of an incoming/incident ray and an outgoing/reflected or transmitted ray and a result of some kind to describe what happens. Subsurface scattering  is a specialized case of BTDF.

There is an excellent explanatory article at scratchapixel on this subject here. Also below are excerpts from H12.5 document on understanding mantra rendering.

PBR (physically based rendering) is a shading process that supports accurate physical simulations of lighting, shadows, and shading. It can work with either sampling methods (raytracing or micropolygon).

Whereas in traditional shading the shader programs control the number and distribution of secondary rays, in PBR secondary rays are controlled by the surface’s BSDF (Bidirectional Scattering Distribution Function).

In PBR, the surface shader is responsible for computing the BSDF of the surface. Whereas traditional surface shaders set Cf (surface color) and Of (surface opacity) color values, surface shaders for PBR set F to a bsdf value (bsdf is a VEX datatype introduced in Houdini 9).


VEX

Below is a simple shader from sidefx documentation that works for traditional and PBR algorithms.

001 surface simple() 002 { 003 vector nn = nomalize(frontface(N, I)); 004 Cf = diffuse(nn); 005 F = diffuse(); 006 }

Lines 3 and 4 are needed for the traditional pipeline, however in PBR, only line 5 is needed. Thus if you encounter an older shader without F set, it will render black in PBR.

If you wanted to modify this to include a parameter for color it might look like this:

surface simple( vector basecolor = {1,0,0} )
{
   vector nn = normalize(frontface(N, I));
   Cf = diffuse(nn) * basecolor;
   F = diffuse() * basecolor;
}

Traditional surface shaders can cause light and shadow shaders to run using an illuminance loop. Inside this loop are Cl (light color), shadow(Cl) - uses the shadow shader, and L(direction from the surface to the light).