Path Tracing
Loading...
Searching...
No Matches
sampling.glsl File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

vec3 pcg3d (uvec3 v)
vec3 rand3 (int bounce, int path_id, uvec2 px)
mat3 onb (vec3 n)
vec3 sampleTriangle (vec3 v0, vec3 v1, vec3 v2, vec2 rnd)
 Samples a random point in the triangle surface uniformly distributed, based on R. Osada, Shape Distributions.
float triangleArea (vec3 v0, vec3 v1, vec3 v2)
vec3 sampleCone (vec3 axis, float theta_max, vec2 rnd)
float conePDF (float theta_max)
float powerHeuristic (float pdf_a, float pdf_b)
float bsdfPDF_diffuse (vec3 normal, vec3 dir)
float trianglelightPDF (float dist, float cos_light, float area)

Function Documentation

◆ bsdfPDF_diffuse()

float bsdfPDF_diffuse ( vec3 normal,
vec3 dir )

PDF (solid-angle) of a cosine-weighted hemisphere for the diffuse BSDF

Note
Isolated on purpose: GGX only needs to replace this implementation, not the MIS logic

◆ conePDF()

float conePDF ( float theta_max)

◆ onb()

mat3 onb ( vec3 n)

◆ pcg3d()

vec3 pcg3d ( uvec3 v)

◆ powerHeuristic()

float powerHeuristic ( float pdf_a,
float pdf_b )

Power Heuristic for combining two sampling strategies Returns the MIS weight for pdf_a

◆ rand3()

vec3 rand3 ( int bounce,
int path_id,
uvec2 px )
Note
using frame_id as seed gives same output
px coords passed from frag or comp shader

◆ sampleCone()

vec3 sampleCone ( vec3 axis,
float theta_max,
vec2 rnd )

Uniformly samples a direction inside a cone of half-angle theta_max around the axis Used for the sun's angular disk

Parameters
axisCone central direction (unit vector)
theta_maxCone half-angle in radians
rndTwo uniform random numbers [0,1[

◆ sampleTriangle()

vec3 sampleTriangle ( vec3 v0,
vec3 v1,
vec3 v2,
vec2 rnd )

Samples a random point in the triangle surface uniformly distributed, based on R. Osada, Shape Distributions.

◆ triangleArea()

float triangleArea ( vec3 v0,
vec3 v1,
vec3 v2 )

◆ trianglelightPDF()

float trianglelightPDF ( float dist,
float cos_light,
float area )

Converts triangle-light sampling into a solid-angle measure PDF at the shading point. Same formula sampleEmissiveTriangle() uses when it picks the light