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

Common pbr general shader. More...

Classes

struct  Light
 Analytic light data. Some members might only be valid for some types of lights. More...
 
struct  Probe
 Environment probe data. More...
 

Public Member Functions

vec3 F (vec3 F0, float VdotH)
 
vec3 iorToFresnel (vec3 internalIOR, vec3 externalIOR)
 
float iorToFresnel (float internalIOR, float externalIOR)
 
vec3 fresnelToIor (vec3 F0)
 
vec3 iridescenceSensitivity (float opd, float shift)
 
vec3 iridescenceF0 (vec3 F0, float LdotH, float ior, float thickness, float externalIOR)
 
float D (float NdotH, float alpha)
 
float DAnisotropic (float NdotH, float TdotH, float BdotH, float alphaT, float alphaB)
 
float DCharlie (float NdotH, float alpha)
 
float V (float NdotL, float NdotV, float alpha)
 
float Vfast (float NdotL, float NdotV, float alpha)
 
float VAnisotropic (float NdotL, float NdotV, float TdotV, float BdotV, float TdotL, float BdotL, float alphaT, float alphaB)
 
float VKelemen (float LdotH)
 
float VNeubelt (float NdotL, float NdotV)
 
vec3 ggx (vec3 n, vec3 v, vec3 l, vec3 h, vec3 F0, float roughness)
 
float ggxClearCoat (vec3 n, vec3 v, vec3 l, vec3 h, float roughness, out float clearCoatFresnel)
 
vec3 ggxAnisotropic (vec3 n, vec3 v, vec3 l, vec3 h, vec3 F0, Material material)
 
vec3 ggxSheen (vec3 n, vec3 v, vec3 l, vec3 h, Material material)
 
vec3 radiance (vec3 r, vec3 p, float roughness, textureCube cubeMap, Probe probe)
 
float probeWeight (vec3 p, Probe probe)
 
vec3 applySH (vec3 wn, vec4 coeffs[9])
 
float approximateSpecularAO (float diffuseAO, float NdotV, float roughness)
 
void ambientLighting (Material material, vec3 worldP, vec3 viewV, mat4 inverseV, Probe probe, textureCube envmap, vec4 envSH[9], texture2D brdfLUT, out vec3 diffuse, out vec3 specular)
 
void directBrdf (Material material, vec3 n, vec3 v, vec3 l, out vec3 diffuse, out vec3 specular)
 
bool applyPointLight (Light light, vec3 viewSpacePos, vec3 viewSpaceN, textureCubeArray shadowMap, out vec3 l, out float shadowing)
 
bool applyDirectionalLight (Light light, vec3 viewSpacePos, vec3 viewSpaceN, texture2DArray shadowMap, out vec3 l, out float shadowing)
 
bool applySpotLight (Light light, vec3 viewSpacePos, vec3 viewSpaceN, texture2DArray shadowMap, out vec3 l, out float shadowing)
 

Detailed Description

Common pbr general shader.

See also
GPUShaders::Common::Utils, GPUShaders::Common::Constants, GPUShaders::Common::Colors, GPUShaders::Common::Geometry, GPUShaders::Common::Samplers, GPUShaders::Common::Materials, GPUShaders::Common::Shadow_maps

Member Function Documentation

◆ ambientLighting()

void GPUShaders::Common::Common_pbr::ambientLighting ( Material  material,
vec3  worldP,
vec3  viewV,
mat4  inverseV,
Probe  probe,
textureCube  envmap,
vec4  envSH[9],
texture2D  brdfLUT,
out vec3  diffuse,
out vec3  specular 
)
inline

Evaluate the lighting contribution from an analytic light source.

Parameters
materialthe surface point material parameters
worldPthe surface position (in world space)
viewVthe outgoing view direction (in view space)
inverseVthe transformation matrix from view to world space
probethe environment probe parameters
envmapthe environment probe texture
envSHthe environment probe irradiance coefficients
brdfLUTthe preintegrated BRDF lookup table
diffusewill contain the diffuse ambient contribution
specularwill contain the specular ambient contribution

◆ applyDirectionalLight()

bool GPUShaders::Common::Common_pbr::applyDirectionalLight ( Light  light,
vec3  viewSpacePos,
vec3  viewSpaceN,
texture2DArray  shadowMap,
out vec3  l,
out float  shadowing 
)
inline

Compute a directional light contribution for a given scene point.

Parameters
lightthe light information
viewSpacePosthe point position in view space
viewSpaceNthe normal in view space
shadowMapthe 2D shadow maps
lwill contain the light direction for the point
shadowingwill contain the shadowing factor
Returns
true if the light contributes to the point shading

◆ applyPointLight()

bool GPUShaders::Common::Common_pbr::applyPointLight ( Light  light,
vec3  viewSpacePos,
vec3  viewSpaceN,
textureCubeArray  shadowMap,
out vec3  l,
out float  shadowing 
)
inline

Compute a point light contribution for a given scene point.

Parameters
lightthe light information
viewSpacePosthe point position in view space
viewSpaceNthe normal in view space
shadowMapthe cube shadow maps
lwill contain the light direction for the point
shadowingwill contain the shadowing factor
Returns
true if the light contributes to the point shading

◆ applySH()

vec3 GPUShaders::Common::Common_pbr::applySH ( vec3  wn,
vec4  coeffs[9] 
)
inline

Evaluate the ambient irradiance (as SH coefficients) in a given direction.

Parameters
wnthe direction (normalized) in world space
coeffsthe SH coefficients
Returns
the ambient irradiance

◆ applySpotLight()

bool GPUShaders::Common::Common_pbr::applySpotLight ( Light  light,
vec3  viewSpacePos,
vec3  viewSpaceN,
texture2DArray  shadowMap,
out vec3  l,
out float  shadowing 
)
inline

Compute a spot light contribution for a given scene point.

Parameters
lightthe light information
viewSpacePosthe point position in view space
viewSpaceNthe normal in view space
shadowMapthe 2D shadow maps
lwill contain the light direction for the point
shadowingwill contain the shadowing factor
Returns
true if the light contributes to the point shading

◆ approximateSpecularAO()

float GPUShaders::Common::Common_pbr::approximateSpecularAO ( float  diffuseAO,
float  NdotV,
float  roughness 
)
inline

Estimate specular ambient occlusion. Based on "Moving Frostbite to Physically Based Rendering".

Parameters
diffuseAOdiffuse visbility factor
NdotVvisibility/normal angle
roughnesslinear material roughness
Returns
the estimated specular visibility

◆ D()

float GPUShaders::Common::Common_pbr::D ( float  NdotH,
float  alpha 
)
inline

GGX Distribution term.

Parameters
NdotHangle between the half and normal directions
alphathe roughness squared
Returns
the distribution term

◆ DAnisotropic()

float GPUShaders::Common::Common_pbr::DAnisotropic ( float  NdotH,
float  TdotH,
float  BdotH,
float  alphaT,
float  alphaB 
)
inline

Anisotropic GGX distribution term. Described by B. Burley in "Physically-Based Shading at Disney", 2012, (https://www.disneyanimation.com/publications/physically-based-shading-at-disney/)

Parameters
NdotHangle between the half and normal directions
TdotHangle between the half and tangent directions
BdotHangle between the half and bitangent directions
alphaTthe roughness squared in the tangent direction
alphaBthe roughness squared in the bitangent direction
Returns
the distribution term

◆ DCharlie()

float GPUShaders::Common::Common_pbr::DCharlie ( float  NdotH,
float  alpha 
)
inline

Sheen-specific "Charlie" distribution. Described by A.-C. Estevez and C. Kulla in "Production Friendly Microfacet Sheen BRDF", 2017, (http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf)

Parameters
NdotHangle between the half and normal directions
alphathe roughness squared
Returns
the distribution term

◆ directBrdf()

void GPUShaders::Common::Common_pbr::directBrdf ( Material  material,
vec3  n,
vec3  v,
vec3  l,
out vec3  diffuse,
out vec3  specular 
)
inline

Evaluate the lighting contribution from an analytic light source.

Parameters
materialthe surface point material parameters
nthe surface normal (in view space)
vthe outgoing view direction (in view space)
lthe incoming light direction (in view space)
diffusewill contain the diffuse direct contribution
specularwill contain the specular direct contribution

◆ F()

vec3 GPUShaders::Common::Common_pbr::F ( vec3  F0,
float  VdotH 
)
inline

Fresnel approximation.

Parameters
F0fresnel based coefficient
VdotHangle between the half and view directions
Returns
the Fresnel term

◆ fresnelToIor()

vec3 GPUShaders::Common::Common_pbr::fresnelToIor ( vec3  F0)
inline

Convert a Fresnel coefficient to an internal IOR, assuming the external medium is air (IOR 1.0)

Parameters
F0the Fresnel coefficient
Returns
the IOR

◆ ggx()

vec3 GPUShaders::Common::Common_pbr::ggx ( vec3  n,
vec3  v,
vec3  l,
vec3  h,
vec3  F0,
float  roughness 
)
inline

Evaluate the GGX BRDF for a given normal, view direction and material parameters.

Parameters
nthe surface normal
vthe view direction
lthe light direction
hthe half vector between the view and light
F0the Fresnel coefficient
roughnessthe surface roughness
Returns
the BRDF value

◆ ggxAnisotropic()

vec3 GPUShaders::Common::Common_pbr::ggxAnisotropic ( vec3  n,
vec3  v,
vec3  l,
vec3  h,
vec3  F0,
Material  material 
)
inline

Evaluate the anisotropic GGX BRDF for a given normal, view direction, frame and material parameters.

Parameters
nthe surface normal
vthe view direction
lthe light direction
hthe half vector between the view and light
F0the Fresnel coefficient
materialthe surface parameters
Returns
the BRDF value

◆ ggxClearCoat()

float GPUShaders::Common::Common_pbr::ggxClearCoat ( vec3  n,
vec3  v,
vec3  l,
vec3  h,
float  roughness,
out float  clearCoatFresnel 
)
inline

Evaluate a simplified GGX BRDF for a given normal, view direction and material parameters.

Parameters
nthe surface normal
vthe view direction
lthe light direction
hthe half vector between the view and light
roughnessthe surface roughness
clearCoatFresnelwill contain the value of the Fresnel coefficient
Returns
the BRDF value

◆ ggxSheen()

vec3 GPUShaders::Common::Common_pbr::ggxSheen ( vec3  n,
vec3  v,
vec3  l,
vec3  h,
Material  material 
)
inline

Sheen specific BRDF, with a constant Fresnel coefficient.

Parameters
nthe surface normal
vthe view direction
lthe light direction
hthe half vector between the view and light
materialthe surface parameters
Returns
the BRDF value

◆ iorToFresnel() [1/2]

float GPUShaders::Common::Common_pbr::iorToFresnel ( float  internalIOR,
float  externalIOR 
)
inline

Estimate the Fresnel coefficient at an interface based on the internal and external media IORs.

Parameters
internalIORthe internal IOR
externalIORthe external IOR
Returns
the corresponding Fresnel coefficient

◆ iorToFresnel() [2/2]

vec3 GPUShaders::Common::Common_pbr::iorToFresnel ( vec3  internalIOR,
vec3  externalIOR 
)
inline

Estimate the Fresnel coefficient at an interface based on the internal and external media IORs.

Parameters
internalIORthe internal IOR
externalIORthe external IOR
Returns
the corresponding Fresnel coefficient

◆ iridescenceF0()

vec3 GPUShaders::Common::Common_pbr::iridescenceF0 ( vec3  F0,
float  LdotH,
float  ior,
float  thickness,
float  externalIOR 
)
inline

Evaluate the new Fresnel coefficient generated by the interferences caused by a thin film on top of a dieletric or conductor. This approximation that accounts for multiple reflections inside the thin film while accounting for spectral variations has been described by L. Belcour and P. Barla in "A Practical Extension to Microfacet Theory for the Modeling of Varying Iridescence", 2017, (https://belcour.github.io/blog/research/publication/2017/05/01/brdf-thin-film.html). Additional simplifications have been described by S. Lagarde and E. Golubev in "The Road toward Unified Rendering with Unity’s High Definition Render Pipeline", 2015, (http://advances.realtimerendering.com/s2018/index.htm#_9hypxp9ajqi).

Parameters
F0the base surface Fresnel coefficient
LdotHthe dot product between the light and the half vector
iorthe thin film index of refraction
thicknessthe thin film thickness (in nm)
externalIOR
Returns
the updated Fresnel coefficient

◆ iridescenceSensitivity()

vec3 GPUShaders::Common::Common_pbr::iridescenceSensitivity ( float  opd,
float  shift 
)
inline

Approximation of the Fourier transform of the sensitivity for iridescent materials, using four gaussian lobes. This encompasses the sensitivity resulting from all light paths with the input path difference and phase.

Parameters
opdoptical path difference
shiftphase of the signal
Returns
the sensitivty in XYZ color space

◆ probeWeight()

float GPUShaders::Common::Common_pbr::probeWeight ( vec3  p,
Probe  probe 
)
inline

Compute the contribution of a probe to a given point in the scene, based on the probe effect box size, position and fading settings.

Parameters
pthe position in the scene (world space)
probethe probe parameters
Returns
the contribution weight in [0,1]

◆ radiance()

vec3 GPUShaders::Common::Common_pbr::radiance ( vec3  r,
vec3  p,
float  roughness,
textureCube  cubeMap,
Probe  probe 
)
inline

Return the (pre-convolved) radiance for a given direction (in world space) and material parameters.

Parameters
rthe direction to query (world space)
pthe surface point (world space)
roughnessthe surface roughness
cubeMapthe environment map texture
probethe probe parameters
Returns
the radiance value

◆ V()

float GPUShaders::Common::Common_pbr::V ( float  NdotL,
float  NdotV,
float  alpha 
)
inline

Visibility term of GGX BRDF, V=G/(n.v)(n.l)

Parameters
NdotLdot product of the light direction with the surface normal
NdotVdot product of the view direction with the surface normal
alphasquared roughness
Returns
the value of V

◆ VAnisotropic()

float GPUShaders::Common::Common_pbr::VAnisotropic ( float  NdotL,
float  NdotV,
float  TdotV,
float  BdotV,
float  TdotL,
float  BdotL,
float  alphaT,
float  alphaB 
)
inline

Visibility term of the anisotropic GGX BRDF. Described by B. Burley in "Physically-Based Shading at Disney", 2012, (https://www.disneyanimation.com/publications/physically-based-shading-at-disney/)

Parameters
NdotLdot product of the light direction with the surface normal
NdotVdot product of the view direction with the surface normal
TdotVdot product of the tangent direction with the view direction
BdotVdot product of the bitangent direction with the view direction
TdotLdot product of the tangent direction with the light direction
BdotLdot product of the bitangent direction with the light direction
alphaTsquared roughness in the tangent direction
alphaBsquared roughness in the bitangent direction
Returns
the value of V

◆ Vfast()

float GPUShaders::Common::Common_pbr::Vfast ( float  NdotL,
float  NdotV,
float  alpha 
)
inline

Linearized visibility term of GGX BRDF, V=G/(n.v)(n.l)

Parameters
NdotLdot product of the light direction with the surface normal
NdotVdot product of the view direction with the surface normal
alphasquared roughness
Returns
the value of V

◆ VKelemen()

float GPUShaders::Common::Common_pbr::VKelemen ( float  LdotH)
inline

Simplified visibility term described by Kelemen in "A Microfacet Based Coupled Specular-Matte BRDF Model with Importance Sampling", 2001

Parameters
LdotHdot product of the light direction and the half vector
Returns
the value of V

◆ VNeubelt()

float GPUShaders::Common::Common_pbr::VNeubelt ( float  NdotL,
float  NdotV 
)
inline

Sheen-specific visibility term. Described by D. Neubelt and M. Pettineo in "Crafting a Next-Gen Material Pipeline for The Order: 1886", 2014, (https://www.gdcvault.com/play/1020162/Crafting-a-Next-Gen-Material)

Parameters
NdotLdot product of the light direction with the surface normal
NdotVdot product of the view direction with the surface normal
Returns
the value of V

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