Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
GPUShaders::Common::Materials Class Reference

Materials general shader. More...

Classes

struct  Material
 

Public Member Functions

float encodeMaterial (uint material)
 
uint decodeMaterial (float raw)
 
float encodeMetalnessAndParameter (float metalness, float parameter)
 
void decodeMetalnessAndParameter (float raw, out float metalness, out float parameter)
 
vec2 decodeIridescence (float ior, float thickness)
 
vec2 encodeRgbOn10Plus2Bits (vec3 rgb)
 
vec3 decodeRgbFrom10Plus2Bits (vec2 packed)
 
Material initMaterial ()
 
Material decodeMaterialFromGbuffer (vec2 uv, texture2D gbuffer0, texture2D gbuffer1, texture2D gbuffer2)
 

Detailed Description

Materials general shader.

See also
GPUShaders::Common::Samplers, GPUShaders::Common::Utils

Member Function Documentation

◆ decodeIridescence()

vec2 GPUShaders::Common::Materials::decodeIridescence ( float  ior,
float  thickness 
)
inline

Convert the iridescence normalized values to the physical quantities.

Parameters
iorthe normalized index of refraction
thicknessthe normalized thickness
Returns
a vector containing a refraction index in [1.2, 2.4] and a thickness in [300nm, 800nm]

◆ decodeMaterial()

uint GPUShaders::Common::Materials::decodeMaterial ( float  raw)
inline

Decode a material ID from its G-buffer representation.

Parameters
rawthe raw value stored in the Gbuffer
Returns
the decoded material identifier

◆ decodeMaterialFromGbuffer()

Material GPUShaders::Common::Materials::decodeMaterialFromGbuffer ( vec2  uv,
texture2D  gbuffer0,
texture2D  gbuffer1,
texture2D  gbuffer2 
)
inline

Populate material parameters from the G-buffer content.

Parameters
uvthe location in the G-buffer
gbuffer0first texture of the G-buffer
gbuffer1second texture of the G-buffer
gbuffer2third texture of the G-buffer
Returns
the decoded material parameters
Bug:
There is a precision issue when decoding from the Gbuffer instead of an inline value.

◆ decodeMetalnessAndParameter()

void GPUShaders::Common::Materials::decodeMetalnessAndParameter ( float  raw,
out float  metalness,
out float  parameter 
)
inline

Decode metalness and another float parameter from a unique 8-bit normalized value, using 5 bits for metalness and 3 bits ofr the other parameter.

Parameters
rawthe packed input value
metalnesswill contain the normalized unpacked metalness
parameterwill contain the normalized unpacked other parameter

◆ decodeRgbFrom10Plus2Bits()

vec3 GPUShaders::Common::Materials::decodeRgbFrom10Plus2Bits ( vec2  packed)
inline

Decode a RGB color from a 10 and a 2 bits normalized values

Parameters
packedthe packed values
Returns
the decoded color

◆ encodeMaterial()

float GPUShaders::Common::Materials::encodeMaterial ( uint  material)
inline

Encode a material ID for storage in the G-buffer.

Parameters
materialthe identifier to encode
Returns
the encoded value as a normalized float

◆ encodeMetalnessAndParameter()

float GPUShaders::Common::Materials::encodeMetalnessAndParameter ( float  metalness,
float  parameter 
)
inline

Encode metalness and another float parameter into a unique 8-bit normalized value, assigning 5 bits to metalness and 3 bits to the other parameter.

Parameters
metalnessthe metalness
parameterthe other parameter to pack
Returns
a normalized float value storing both packed inputs

◆ encodeRgbOn10Plus2Bits()

vec2 GPUShaders::Common::Materials::encodeRgbOn10Plus2Bits ( vec3  rgb)
inline

Store a RGB color on 12 bits, split into 10 and 2 bits for storage in the Gbuffer.

Parameters
rgbthe color to pack
Returns
the 10 and 2 bits normalized values encoding the color

◆ initMaterial()

Material GPUShaders::Common::Materials::initMaterial ( )
inline

Fill a material with default parameters.

Returns
the initialized material

The documentation for this class was generated from the following file: