diff options
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl index 898c7bfc578..3997de7a22d 100644 --- a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl @@ -37,6 +37,11 @@ float pdf_ggx_reflect(float NH, float a2) return NH * a2 / D_ggx_opti(NH, a2); } +float pdf_hemisphere() +{ + return 0.5 * M_1_PI; +} + vec3 sample_ggx(float nsample, float a2, vec3 N, vec3 T, vec3 B) { vec3 Xi = hammersley_3d(nsample); @@ -52,3 +57,17 @@ vec3 sample_ggx(float nsample, float a2, vec3 N, vec3 T, vec3 B) return tangent_to_world(Ht, N, T, B); } + +vec3 sample_hemisphere(float nsample, vec3 N, vec3 T, vec3 B) +{ + vec3 Xi = hammersley_3d(nsample); + + float z = Xi.x; /* cos theta */ + float r = sqrt( 1.0f - z*z ); /* sin theta */ + float x = r * Xi.y; + float y = r * Xi.z; + + vec3 Ht = vec3(x, y, z); + + return tangent_to_world(Ht, N, T, B); +}
\ No newline at end of file |