# IBsdf class¶

<oceansdk/bsdfplugin.h>

## Description¶

This interface class allows calling a BSDF

In the SDK, you will either:

## Namespace¶

This class is in the namespace Ocean::Sdk

## Inherited by¶

IBsdfPlugin

## Members¶

class IBsdf : public INode
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, IStokesContext *stokes, const Vec3<float> &kLt, const Vec3<float> &kEt) const

[virtual]

Parameters
• stokes – Pointer to stokes to which values must be added

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()