# IBsdfPlugin class¶

<oceansdk/bsdfplugin.h>

## Description¶

This interface class allows creating a BSDF plugin by subclassing it and implementing all pure virtual member functions below.

## Namespace¶

This class is in the namespace Ocean::Sdk

## Members¶

class IBsdfPlugin : public IBsdf
Vec3<float> samplePdf(const IShaderContext *context, const Vec3<float> &k1t, ISampler *sampler) const

[virtual]

Parameters
• sc – Pointer to the shading context

• k1t – The inbound vector in tangent space coordinates

• sampler – Pointer to the sampler

Returns

The sampled direction in tangent space coordinates

Samples an outbound vector for a given inbound vector and shading context, using the provided numerical sampler

k1t is the inbound vector in respect to the tracing algorithm. It may either be the light or eye vector, depending if the algorithm is forward or reverse path tracing.

The probability distribution function (pdf) of sampling the returned vector must be equal to the value returned by pdf()

All numerical sampling performed in this function must be done through the sampler parameter. No other (pseudo)random generator may be used. See ISampler for more details on how to use it.

For good efficiency, the pdf of this function should be as close to proportional to the BSDF values computed by getValues(). More precisely, the optimal pdf is the normalized bsdf. The ratio bsdf/pdf should never be much higher than the bsdf energy conservation factor, or high noise will persist longer.

float pdf(const IShaderContext *context, const Vec3<float> &k1t, const Vec3<float> &k2t) const

[virtual]

Parameters
• sc – Pointer to the shading context

• k1t – The inbound vector in tangent space coordinates

• k2t – The sampled outbound vector in tangent space coordinates

Returns

The pdf value

Returns the probably distribution function (pdf) of sampling the direction k2t given the inbound direction k1t when calling samplePdf()

float decay(const IShaderContext *sc, const Vec3<float> &k1t) const

[virtual]

Parameters
• sc – The shading context

• k1t – The inbound vector

Returns

the decay value.

Computes the bsdf decay value for the given shader context sc and inbound vector k1t.

The decay is the probability to not recurse the path tracing when bouncing over a surface (russian roulette algorithm). The ideal decay value is the energy conservation factor of the BSDF. It must be comprised between 0 and 1

k1t is the inbound vector in respect to the tracing algorithm. It may either be the light or eye vector, depending if the algorithm is forward or reverse path tracing.

void getValues(const IShaderContext *context, float *dest, const Vec3<float> &kLt, const Vec3<float> &kEt) const

[virtual]

Parameters
• dest – Pointer to a float array where the function should store its result

• sc – The shading context

• kLt – The light vector in tangent space coordinates

• kEt – The eye vector in tangent space coordinates

Asks the bsdf to compute its values and store them in dest.

The size of dest should be retrieved using IShaderContext::numWavelengths().

Wavelengths may be retrieved using IShaderContext::getWavelength()

const char *typeName() const

[virtual]

Returns the type name for this bsdf, as used internally and in Ocean files.

The type name must contain only lowercase ASCII letters (a-z), underscores (_) and digits (0-9).

Returns

the type name as a null terminated string

const char *prettyTypeName() const

[virtual]

Returns the pretty type name for this bsdf as a zero terminated string. Used in the graphical user interface.

The pretty type name may contain UTF-8 characters.

Returns

the pretty type name as a null terminated string

IBsdfPlugin *clone() const

[virtual]

Clones the current class, usually implemented by:

{ return new MyClass(*this); }

Returns

pointer to a fresh copy of the object

void getParameters(IParamList *iParamList)

[virtual]

This function asks the bsdf plugin to declare its parameters via the IParamList interface

Parameters

iParamList – The interface for adding parameters

bool setParameter(const char *parameterName, const IParamValue &value)

[virtual]

This function sets the parameter parameterName to the value value

Parameters
• parameterName – The parameter name

• value – The new parameter value

Returns

true if the parameter was successfully updated

void addChildren(IAddChildContext *iChildAdd)

[virtual]

This function asks the bsdf plugin to declare its children.

Parameters

bool prepare(const IPrepareContext *iPrepare)

[virtual]

This function asks the bsdf plugin to prepare itself for rendering.

All kind of precomputations should be performed here.

Pointer to children nodes should be retrieved in this function using the IPrepareContext interface

Parameters

iPrepare – The interface for getting child node pointers and other initialization data