Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As mentioned above, integrators invoke RixBxdfFactory::BeginScatter() to obtain a RixBxdf. The renderer's operating model is that the Bxdf that is obtained this way is a closure, with the closure functions being GenerateSampleEvaluateSample, EvaluateSamplesAtIndex(), and EmitLocal. The RixBxdfFactory should stash state in the RixBxdf object and consider that the RixBxdf lifetime is under control of the integrator. Generally integrators will attempt to minimize the number of live  RixBxdf  objects but may nonetheless require a large number. For this reason, the RixBxdf  instances should attempt to minimize  memory consumption and construction / deconstruction costs.

Any computations that the Bxdf need in order to efficient evaluate its closure functions should be computed once inside RixBxdfFactory::BeginScatter(), and then saved in the overridden RixBxdf class. Critically, these computations include upstream evaluation of any pattern networks. Therefore, it is typical for BeginScatter() to invoke  RixShadingContext::EvalParam() in order to evaluate the relevant bxdf input parameters, and then pass the pointers returned from EvalParam to the Bxdf constructor. Since Bxdfs also generally require geometric data, or built-in variables, such as the shading normal , geometric normal, (Nn) and viewing direction (Vn), either BeginScatter() or the Bxdf constructor itself will need to call RixShadingContext::GetBuiltinVar() function for each such built-in variable.

...

The GenerateSample() function has the following input parameters: transportTrait, lobesWanted, and random number generator rng.

  • The transportTrait

...

  •  tells the Bxdf the subset of light transport to consider: direct illumination, indirect illumination, or both. 
  • lobesWanted

...

  •  specifies what lobes are requested, for example specular reflection, diffuse transmission, etc.

...

  •  
  • rng should be called to generate well-stratified samples; such samples typically reduce noise and improve convergence compared to using uniform random samples. 

The GenerateSample() function has the following output parameters (results): lobeSampled, direction directions, weight weights, forward pdf forwardPdfs, reverse pdf reversePdfs, and compTrans.  lobeSampled is All results are arrays with one value per sample point.

  • lobeSampled is similar to the input lobesWanted, and specifies which lobe was actually sampled.

...

  •  Bxdfs must respect the transportTrait and lobesWanted request and indicate which class of lobe is associated with each sample by setting lobesSampled for each generated sample. If and only if the bxdf is unable to generate a requested sample, then lobesSampled should be set to k_RixBXNullTrait; for example, if the lobesWanted argument requests a specific lobe (e.g., diffuse reflection) that the Bxdf does not support because the Bxdf only supports glossy reflections, then lobesSampled should be set to k_RixBXNullTrait. However, if it is possible to generate the requested samples, then lobesSampled should not be set to k_RixBXNullTrait and should instead be set to the sampled lobe for each point in the shading context
  • directions is the generated ray direction vectors; these directions must

...

  • be unit length.

...

  •  
  • weights is a color per sample indicating that sample's weight. 

...

  • forwardPdfs should account for light moving from the L to V direction

...

  • , whereas reversePdfs account for the opposite (from V to L). Bxdfs should always provide both pdf values for

...

  • integrators to use

...

  • compTrans

...

  •  is an optional result which can be used to indicate transmission color; this will be used as alpha in compositing. A bxdf should check that compTrans

...

  •  is not NULL before assigning to it.

...

  •   

As an example, a purely Lambertian diffuse bxdf should loop over the sample points and for each sample point set the result values as follows: set lobeSampled to  to diffuse reflection, set the reflection direction to a randomly generated direction chosen with a cosine distribution on the hemisphere defined by the surface normal (using a well-stratified 2D "random" sample value generated by calling the provided random number generator), set the weight to the diffuse surface albedo color times dot(Nn, LLn) divided by pi, set the forward pdf to dot(Nn, Ln) divided by pi, and set the reverse pdf to dot(Nn, Vn). More details can be found in the source code for the PxrDiffuse bxdf.

The parameters to the EvaluateSample() function are very similar: transportTrait, lobesWanted, random number generator, lobesEvaluated, direction directions, weight, forward pdf and reverse pdf weights, forwardPdfs and reversePdfs.  The main difference is that direction (Ln) is an array of inputs that the function should compute weights and pdfs for.

The EvaluateSamplesAtIndex() function is very similar to EvaluateSample(), but is used to evaluate multiple samples at the same surface position and normal, but with different illumination directions (Ln). The inputs are the same as for EvaluateSample(), except that it has two additional inputs: index and  and number of samples numSamples. index is  is used to index into built-in variables such as the normal Nn and viewing direction Vn, and number of samples is numSamples is the number of directions (Ln) to evaluate the bxdf for. The functionality of EvaluateSamplesAtIndex()–  the former only exists otherwise is similar to EvaluateSample()and exists in order to make sample evaluation more efficient in certain light transport settings.

...

In order to maintain physical correctness, bxdfs are expected to conserve energy and obey the Helmholtz reciprocity principle. Care should be taken so that RixBxdf::GenerateSample(),  RixBxdf::EvaluateSample() and RixBxdf::EvaluateSamplesAtIndex() return consistent results. This allows bxdf plugins to be compatible with different rendering techniques such as:

...