RenderManAPI  24.0
RixBxdfLobe.h File Reference
#include <algorithm>
#include <cassert>
#include <cstring>
#include "RixInterfaces.h"
#include "RixShadingUtils.h"
#include "prmanapi.h"
#include "RiTypesHelper.h"

Go to the source code of this file.

Classes

struct  RixBXLobeSampled
 This struct represents the characteristics of just one lobe of a bxdf. More...
 
struct  RixBXLobeSampled::Bitfield
 
union  RixBXLobeSampled::Converter
 
struct  RixBXLobeTraits
 This struct represents the characteristics of potentially several lobes of a bxdf in aggregate. More...
 
struct  RixBXLobeTraits::Bitfield
 
union  RixBXLobeTraits::Converter
 
struct  RixBXActiveLobeWeights
 
struct  RixBXLobeWeights
 

Functions

PRMAN_INLINE RixBXLobeSampled RixBXLookupLobeByName (RixContext &ctx, bool discrete, bool specular, bool reflect, bool user, unsigned char lobeId, char const *name)
 Use this method to return a RixBXLobeSampled struct using the name of the bxdf lobe. More...
 
PRMAN_INLINE RixBXLobeTraits operator & (RixBXLobeTraits const &lhs, RixBXLobeTraits const &rhs)
 Bitwise AND all fields. More...
 
PRMAN_INLINE RixBXLobeTraits operator| (RixBXLobeTraits const &lhs, RixBXLobeTraits const &rhs)
 Bitwise OR all fields. More...
 
PRMAN_INLINE int RixBXChoose (float const xi, int const numThresholds, float const *thresholds)
 Useful utility functions that allow an integrator to select one lobe from a set of lobe described in the weights. More...
 
PRMAN_INLINE bool RixBXChooseLobe (float const xi, RixBXActiveLobeWeights &lw, RixBXLobeSampled &chosenLobe)
 Selects a lobe from a set of lobe responses stored in active weights, lw. More...
 
PRMAN_INLINE void RixBXChooseLobe (int const npoints, float const *xi, RixBXLobeWeights &lw, RixBXLobeSampled *lobeSampled)
 This overload takes an array of lobe weights, most likely produced in a call to GenerateSample, and selects one lobe for each point. More...
 
PRMAN_INLINE void RixBXChooseLobe (float const xi, RixBXActiveLobeWeights &lw, RixBXLobeTraits &traits)
 This overload takes multiple lobes for one point and importance samples the lobe responses to choose a lobe. More...
 
PRMAN_INLINE RixBXLobeTraits operator & (RixBXLobeTraits const &lhs, RixBXLobeTraits const &rhs)
 Bitwise AND all fields. More...
 

Function Documentation

◆ operator &() [1/2]

PRMAN_INLINE RixBXLobeTraits operator& ( RixBXLobeTraits const &  lhs,
RixBXLobeTraits const &  rhs 
)

Bitwise AND all fields.

References RixBXLobeTraits::Serialize().

◆ operator &() [2/2]

PRMAN_INLINE RixBXLobeTraits operator& ( RixBXLobeTraits const &  lhs,
RixBXLobeTraits const &  rhs 
)

Bitwise AND all fields.

References RixBXLobeTraits::Serialize().

◆ operator|()

PRMAN_INLINE RixBXLobeTraits operator| ( RixBXLobeTraits const &  lhs,
RixBXLobeTraits const &  rhs 
)

Bitwise OR all fields.

References RixBXLobeTraits::Serialize().

◆ RixBXChoose()

PRMAN_INLINE int RixBXChoose ( float const  xi,
int const  numThresholds,
float const *  thresholds 
)

Useful utility functions that allow an integrator to select one lobe from a set of lobe described in the weights.

Given a random number, xi, and cdf table, this function chooses an index into the table that satisfies the condition table[entry] <= xi < table[entry+1]. The table is expected to not start at 0.

◆ RixBXChooseLobe() [1/3]

PRMAN_INLINE bool RixBXChooseLobe ( float const  xi,
RixBXActiveLobeWeights lw,
RixBXLobeSampled chosenLobe 
)

Selects a lobe from a set of lobe responses stored in active weights, lw.

The active lobe weights contains (possible multiple) lobe responses. This overload operates only on a single point and, consequently, the lobe is expected to be in index 0 of the lobe weights instance. Client code can call SetOffset on the lobe weights structure to choose a lobe on an arbitrary point before calling this function. The function uses the random number, xi, to choose the lobe and so this random number is expected to be correctly decorrelated with that used to generate the lobe weights. The function modifies the lobe weights directly by modifying the chosen lobe response by the probability of having chosen the lobe and returns, in chosenLobe, details on which lobe was selected. The members set in chosenLobe are its validity, whether it is specular, or no and the lpeId. If the lobe weights contain no non-zero lobes, or other errors occur, the returned choseLobe is set to invalid and false is returned. If a lobe is selected true is returned and chosenLobe is initialized as valid. xi - the decorrelated random number used to choose a lobe lw - contains multiple lobe responses. These are importance sampled to choose a lobe. The chosen lobe response is adjusted to reflect the probability of having chosen the lobe. All other lobe are set to zero. chosenLobe - an out parameter that indicates which lobe has been selected. The lobe sampled will be invalid if an error occured choosing a lobe.

References RixBXActiveLobeWeights::GetNumDiffuseLobes(), and RixBXActiveLobeWeights::GetNumSpecularLobes().

Referenced by RixBXChooseLobe().

◆ RixBXChooseLobe() [2/3]

PRMAN_INLINE void RixBXChooseLobe ( int const  npoints,
float const *  xi,
RixBXLobeWeights lw,
RixBXLobeSampled lobeSampled 
)

This overload takes an array of lobe weights, most likely produced in a call to GenerateSample, and selects one lobe for each point.

The behavior for each point is similar to RixBXChooseLobe(float const, RixBXActiveLobeWeights&, RixBXLobeSampled&) except that the lobeSampled parameter is also modified to reflect the lobe chosen at each point. npoints - number of multi-lobe responses in the lobe weights xi - correctly decorrelated random numbers to select a lobe, one for each point lw - contains multiple lobe responses, one for each point. This in/out parameter is modified such that only one lobe has a non-zero response (the chosen lobe). The chosen lobe is correctly adjusted to incorporate the probability of choosing the lobe. lobeSampled - an out parameter that contains the lpeId and whether the the lobe chosen is specular or not. If an error occurs when choosing a lobe for the given point the lobe sampled is invalidated.

References RixBXLobeWeights::GetActiveLobes(), RixBXLobeSampled::GetLpeId(), RixBXActiveLobeWeights::GetOffset(), RixBXLobeSampled::GetSpecular(), RixBXChooseLobe(), RixBXLobeSampled::SetLpeId(), RixBXActiveLobeWeights::SetOffset(), and RixBXLobeSampled::SetSpecular().

◆ RixBXChooseLobe() [3/3]

PRMAN_INLINE void RixBXChooseLobe ( float const  xi,
RixBXActiveLobeWeights lw,
RixBXLobeTraits traits 
)

This overload takes multiple lobes for one point and importance samples the lobe responses to choose a lobe.

This overload is precisely the same as: RixBXChooseLobe(float const, RixBXActiveLobeWeights&, RixBXLobeSampled&) except that the lobe traits are modified to represent the chosen lobe. See the RixBXLobeSampled overload for details.

References RixBXLobeSampled::GetLpeId(), RixBXLobeSampled::GetSpecular(), RixBXChooseLobe(), RixBXLobeTraits::SetDiffuse(), and RixBXLobeTraits::SetSpecular().

◆ RixBXLookupLobeByName()

PRMAN_INLINE RixBXLobeSampled RixBXLookupLobeByName ( RixContext ctx,
bool  discrete,
bool  specular,
bool  reflect,
bool  user,
unsigned char  lobeId,
char const *  name 
)

Use this method to return a RixBXLobeSampled struct using the name of the bxdf lobe.

References RixContext::GetRixInterface(), and k_RixLPEInfo.