Sampling Module
Low-discrepancy sequences, disk/sphere/hemisphere sampling, and GGX sampling PDFs.
Turn the guide into code
Take the key idea from this page into the playground and validate it in a real shader instead of leaving it as theory.
Open PlaygroundLow-discrepancy sequences, disk/sphere/hemisphere sampling, and GGX sampling PDFs.
Import
import Sampling
This module imports: Math, Random, Spaces.
Constants
const float INV_UINT_MAX = 2.3283064365386963e-10Structs
No structs found.
Enums
No enums found.
Functions
radical_inverse_vdc
Reference: https://en.wikipedia.org/wiki/Van_der_Corput_sequence
radical_inverse_vdc :: (uint bits) -> float
hammersley
Reference: https://en.wikipedia.org/wiki/Low-discrepancy_sequence
hammersley :: (uint index, uint count) -> float2
r2
Reference: http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
r2 :: (uint index) -> float2
seeded_2d
Returns a deterministic random 2D sample from a seed and sequence index.
seeded_2d :: (uint seed, uint index) -> float2
uniform_disk
Reference: https://en.wikipedia.org/wiki/Polar_coordinate_system
uniform_disk :: (float2 xi) -> float2
uniform_circle
Maps a scalar sample to a point on the unit circle.
uniform_circle :: (float xi) -> float2
uniform_sphere
Reference: https://en.wikipedia.org/wiki/Sphere#Spherical_coordinates
uniform_sphere :: (float2 xi) -> float3
uniform_hemisphere_z
Maps a uniform square sample to a local +Z hemisphere direction.
uniform_hemisphere_z :: (float2 xi) -> float3
cosine_hemisphere_z
Reference: https://www.pbr-book.org/4ed/Sampling_Algorithms/Sampling_Multidimensional_Functions
cosine_hemisphere_z :: (float2 xi) -> float3
uniform_hemisphere
Maps a uniform square sample to a world-space hemisphere direction around normal.
uniform_hemisphere :: (float2 xi, float3 normal) -> float3
cosine_hemisphere
Maps a uniform square sample to a cosine-weighted world-space hemisphere direction around normal.
cosine_hemisphere :: (float2 xi, float3 normal) -> float3
ggx_half_vector_z
Background: https://pharr.org/matt/blog/2022/05/06/trowbridge-reitz.html
ggx_half_vector_z :: (float2 xi, float roughness) -> float3
ggx_half_vector
Reference: https://en.wikipedia.org/wiki/Specular_highlight#Microfacet_models
ggx_half_vector :: (float2 xi, float roughness, float3 normal) -> float3
cosine_hemisphere_pdf
Returns the PDF for cosine-weighted hemisphere sampling.
cosine_hemisphere_pdf :: (float cosTheta) -> float
uniform_sphere_pdf
Returns the constant PDF for uniform sphere sampling.
uniform_sphere_pdf :: () -> float
uniform_hemisphere_pdf
Returns the constant PDF for uniform hemisphere sampling.
uniform_hemisphere_pdf :: () -> float
ggx_ndf
Reference: https://en.wikipedia.org/wiki/Specular_highlight#Microfacet_models
ggx_ndf :: (float NdotH, float roughness) -> float
ggx_reflection_pdf
Returns the reflected-direction PDF for GGX half-vector sampling.
ggx_reflection_pdf :: (float NdotH, float VdotH, float roughness) -> float
Source
Generated from compiler-reference/modules/Sampling.bwsl.