...
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
.
Instance Hints
Bxdfs that require special opacity handling or support interior shading need to indicate their support for these capabilities via an instance hint. Most Bxdfs do not require such, and should simply implement in their factory a trivial implementation of GetInstanceHints()
which simply returns k_TriviallyOpaque
. Bxdfs that do modulate opacity and/or require interior shading are required to override the GetInstanceHints()
method and return the appropriate bits in InstanceHints
to the renderer in order to trigger calls to BeginOpacity
and BeginInterior
.
As a further optimization, Bxdfs that deal with opacity or interiors may choose to change their behavior based upon their instance parameters. For example, they may opt out of opacity entirely if they can prove via inspection of the parameters that the intended result is equivalent to opaque. Bxdfs that choose to do so should "bake" this awareness into their instance data at the time of CreateInstanceData()
and inspect this instance data within the GetInstanceHints()
implementation.
Note that at the time of CreateInstanceData
, like other shading plugins, Bxdfs are unable to inspect the values of pattern network inputs; therefore, in cases these inputs are provided (i.e: RixParameterList::GetParamInfo
returns k_RixSCNetworkValue
) the Bxdf may have no choice but to defer inspection of the inputs until BeginOpacity()
or BeginInterior()
. At that time, those methods may then choose to return NULL instead.
RixBxdf
Once a RixBxdf
object is obtained, the integrator may invoke the following methods:
...