...
The RixBxdf
interface characterizes the light-scattering behavior (sometimes referred to as material response) for a given point on the surface of an object.
RixBxdfFactory
Implementing the RixBxdfFactory Interface
RixBxdfFactory
is a subclass of RixShadingPlugin
, and therefore shares the same initialization, synchronization, and parameter table logic as other shading plugins. Therefore to start developing your own Bxdf, you can #include "RixBxdf.h"
and make sure your bxdf factory class implements the required methods inherited from the RixShadingPlugin
interface: Init()
, Finalize()
, Synchronize()
, GetParamTable()
, and CreateInstanceData()
. Generally, there is one shading plugin instance of a RixBxdfFactory per bound RiBxdf
(RIB) request. This instance may be active in multiple threads simultaneously.
...
Code Block | ||
---|---|---|
| ||
RIX_BXDFPLUGINCREATE { return new MyBxdfFactory(); } RIX_BXDFPLUGINDESTROY { delete ((MyBxdfFactory*)bxdf); } |
RixBxdfFactory::BeginScatter()
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 GenerateSample
, EvaluateSample
, 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.
...
BeginScatter()
is also passed two parameters that can be used as hints to optimize the calculation. RixBXLobeTraits const &lobesWanted
is a description of the Bxdf lobes that the renderer expects to generate or evaluate; this parameter can be used to avoid any computations not necessary for the requested lobes. RixSCShadingMode
will take either the value k_RixSCScatterQuery
, indicating that the factory should construct a Bxdf for scattering on the surface, or k_RixSCVolumeScatterQuery
, indicating that a Bxdf should be constructed for scattering on the inside of a volume.
RixBxdfFactory::BeginOpacity()
In certain cases, integrators may also call RixBxdfFactory::BeginOpacity()
to retrieve a RixOpacity
object. BeginOpacity
should be implemented in a similar fashion to BeginScatter()
, except that will be only be invoked by the renderer in narrower constraints: either for presence and opacity. As such, any inputs to the factory that do not affect presence nor opacity need not be evaluated. Furthermore, the RixSCShadingMode
can be examined to further narrow down the inputs; it will take either the value k_RixSCPresenceQuery
or k_RixSCOpacityQuery
.
RixBxdf
Once a RixBxdf
object is obtained, the integrator may invoke the following methods:
...
RixOpacity
...
The renderer will invoke the following methods on RixOpacity
:
...