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

Utils general shader. More...

Public Member Functions

float linearizeDepth (float depth, vec2 projPlanes)
 
vec3 positionFromDepth (float depth, vec2 uv, vec4 projMat)
 
vec2 hammersleySample (uint i, int scount)
 
vec3 toCube (vec3 v)
 
vec4 toCube (vec3 v, uint layer)
 
vec4 floatToVec4 (float f)
 
float vec4ToFloat (vec4 v)
 
float convertToPrecision (float value, uint size)
 
vec3 convertToPrecision (vec3 value, uint size)
 
vec2 octahedralWrap (vec2 d)
 
vec2 encodeOctahedralDirection (vec3 d)
 
vec3 decodeOctahedralDirection (vec2 e)
 
vec2 encodeNormal (vec3 n)
 
vec3 decodeNormal (vec2 e)
 
void buildFrame (vec3 up, out vec3 right, out vec3 front)
 

Detailed Description

Utils general shader.

Member Function Documentation

◆ buildFrame()

void GPUShaders::Common::Utils::buildFrame ( vec3  up,
out vec3  right,
out vec3  front 
)
inline

Build a reference orthonormal frame from a given up vector.

Parameters
upthe normalized up vector to use
rightwill contain the normalized right vector
frontwill contain the normalized front vector

◆ convertToPrecision() [1/2]

float GPUShaders::Common::Utils::convertToPrecision ( float  value,
uint  size 
)
inline

Convert a normalized float value to a given bit precision.

Parameters
valuethe normalized value to quantize
sizethe number of bits to use
Returns
the quantized normalized value

◆ convertToPrecision() [2/2]

vec3 GPUShaders::Common::Utils::convertToPrecision ( vec3  value,
uint  size 
)
inline

Convert a vector of normalized float values to a given bit precision.

Parameters
valuethe normalized values to quantize
sizethe number of bits to use
Returns
the quantized normalized values

◆ decodeNormal()

vec3 GPUShaders::Common::Utils::decodeNormal ( vec2  e)
inline

Decode a normal from its storage-efficient representation.

Parameters
ethe normal representation
Returns
the decoded normal

◆ decodeOctahedralDirection()

vec3 GPUShaders::Common::Utils::decodeOctahedralDirection ( vec2  e)
inline

Decode a normalized direction from an octahedral representation.

Parameters
ethe representation parameters
Returns
the decoded direction

◆ encodeNormal()

vec2 GPUShaders::Common::Utils::encodeNormal ( vec3  n)
inline

Encode a normal into a compact representation for storage in a framebuffer.

Parameters
nthe normal to encode
Returns
the encoded representation

◆ encodeOctahedralDirection()

vec2 GPUShaders::Common::Utils::encodeOctahedralDirection ( vec3  d)
inline

Encode a normalized direction into an octahedral representation, as described in Octahedron normal vector encoding, Krzysztof Narkowicz, 2014 (https://knarkowicz.wordpress.com/2014/04/16/octahedron-normal-vector-encoding/)

Parameters
dthe normalized direction
Returns
the encoded representation

◆ floatToVec4()

vec4 GPUShaders::Common::Utils::floatToVec4 ( float  f)
inline

Store a 32bits float in a 4x8bits vector of normalized values.

Parameters
fthe float to store
Returns
the vec4 representation of the float

◆ hammersleySample()

vec2 GPUShaders::Common::Utils::hammersleySample ( uint  i,
int  scount 
)
inline

Compute an arbitrary sample of the 2D Hammersley sequence.

Parameters
ithe index in the hammersley sequence
scountthe total number of samples
Returns
the i-th 2D sample

◆ linearizeDepth()

float GPUShaders::Common::Utils::linearizeDepth ( float  depth,
vec2  projPlanes 
)
inline

Linearize a NDC space to view space using the camera projection parameters.

Parameters
depththe non-linear depth of the fragment
projPlanesthe depth-related coefficients of the projection matrix
Returns
the view space depth

◆ octahedralWrap()

vec2 GPUShaders::Common::Utils::octahedralWrap ( vec2  d)
inline

Wrap a projected direction in the octahedral parametrization of the unit sphere

Parameters
dthe projected direction in 2D
Returns
the corresponding coordinates in the parameterization

◆ positionFromDepth()

vec3 GPUShaders::Common::Utils::positionFromDepth ( float  depth,
vec2  uv,
vec4  projMat 
)
inline

Estimate the position of the current fragment in view space based on its depth and camera parameters.

Parameters
depththe depth of the fragment
uvthe input uv
projMatthe non trivial coefficients of the projection matrix
Returns
the view space position

◆ toCube() [1/2]

vec3 GPUShaders::Common::Utils::toCube ( vec3  v)
inline

Transform a world space direction to cubemap space. A vertical flip is needed.

Parameters
vthe direction to flip
Returns
the direction to use to sample in the cubemap

◆ toCube() [2/2]

vec4 GPUShaders::Common::Utils::toCube ( vec3  v,
uint  layer 
)
inline

Transform a world space direction to cubemap array space. A vertical flip is needed.

Parameters
vthe direction to flip
layerthe array layer index
Returns
the direction to use to sample in the cubemap

◆ vec4ToFloat()

float GPUShaders::Common::Utils::vec4ToFloat ( vec4  v)
inline

Load a 32bits float from a 4x8bits vector of normalized values.

Parameters
vthe vec4 representation of the float
Returns
the loaded float

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