This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Helper function: sample the visible hemisphere from a spherical cap | |
vec3 SampleVndf_Hemisphere(vec2 u, vec3 wi) | |
{ | |
// sample a spherical cap in (-wi.z, 1] | |
float phi = 2.0f * M_PI * u.x; | |
float z = fma((1.0f - u.y), (1.0f + wi.z), -wi.z); | |
float sinTheta = sqrt(clamp(1.0f - z * z, 0.0f, 1.0f)); | |
float x = sinTheta * cos(phi); | |
float y = sinTheta * sin(phi); | |
vec3 c = vec3(x, y, z); |