IShaderContext class

<oceansdk/contexts.h>

Description

This class allows nodes to access to shading parameters such as world position, normals, uv coordinates…

Namespace

This class is in the namespace Ocean::Sdk

Members

class IShaderContext
const Vec3<double> &worldPos() const

[virtual]

Returns

the position in world coordinates

const Vec3<float> &worldNormal() const

[virtual]

Returns

the surface normal in world coordinates

const Vec2<float> &uvs() const

[virtual]

Returns

the UV coordinates

const Vec2<float> &uvs(int index) const

[virtual]

Parameters

i – uv set index

Returns

the UV coordinates for set i

Returns the UV coordinates for UV set index. Currently, only one UV set is supported in Ocean, so index will always be 0. Added for future use.

uint32_t instanceId() const

[virtual]

Returns

the unique ID of the geometry instance

uint32_t numWavelengths() const

[virtual]

Returns

the number of wavelengths in the shading context

uint32_t getWavelengthIndex(uint32_t i) const

[virtual]

Parameters

i – Wavelength index between 0 and numWavelengths() - 1

Returns

the ith wavelength index

Returns the ith wavelength index of the shading context

The wavelength index varies from 0 to 232-1 between the low bound of the simulation range and the high bound of the simulation range.

Use getWavelengthMeters() for getting the actual wavelength.

float getWavelengthMeters(uint32_t i, float wlMin, float wlMax) const

[virtual]

Parameters
  • i – Wavelength index between 0 and numWavelengths() - 1

  • i – Lower bound of the simulation wavelength range

  • i – Upper bound of the simulation wavelength range

Returns

the ith wavelength

Returns the ith wavelength of the shading context in meters.

The bounds of the simulation wavelength range should be retrieved in plugins prepare() overloads with the functions IPrepareContext::wavelengthMin() and IPrepareContext::wavelengthMax().

Vec2<float> bumpNormalShiftTS(const Vec2<float> &dHdUV) const

[virtual]

Parameters

dHdUV – The texture space height differential

Returns

the tangent space height differential

Converts a bump map height differential in texture space (dH/dU and dH/dV) to a differential in tangent space (dH/dX and dH/dY)

~IShaderContext()

[virtual]

The destructor for IShaderContext