Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2017-12-06 12:45:12 +0300
committerClément Foucault <foucault.clem@gmail.com>2017-12-06 12:47:44 +0300
commit16b9e91bf1db35b54a292049ec8d1c2d5669c163 (patch)
tree4012b203e194bc71b8b917ec7c04100b5a4e4797 /source/blender/draw
parent7ca8af4cc82010c85fa6d7f663977117eb23b6f9 (diff)
Eevee: Fix sampling direction calculation.
It was causing problems with the visibility filtering on Intel GPU.
Diffstat (limited to 'source/blender/draw')
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl6
1 files changed, 3 insertions, 3 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 8cb5a66290d..13586619fe9 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
@@ -54,7 +54,7 @@ vec3 sample_ggx(vec3 rand, float a2)
{
/* Theta is the aperture angle of the cone */
float z = sqrt( (1.0 - rand.x) / ( 1.0 + a2 * rand.x - rand.x ) ); /* cos theta */
- float r = sqrt( 1.0 - z * z ); /* sin theta */
+ float r = sqrt(max(0.0, 1.0f - z*z)); /* sin theta */
float x = r * rand.y;
float y = r * rand.z;
@@ -82,7 +82,7 @@ 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 r = sqrt(max(0.0, 1.0f - z*z)); /* sin theta */
float x = r * Xi.y;
float y = r * Xi.z;
@@ -96,7 +96,7 @@ vec3 sample_cone(float nsample, float angle, vec3 N, vec3 T, vec3 B)
vec3 Xi = hammersley_3d(nsample);
float z = cos(angle * Xi.x); /* cos theta */
- float r = sqrt( 1.0f - z*z ); /* sin theta */
+ float r = sqrt(max(0.0, 1.0f - z*z)); /* sin theta */
float x = r * Xi.y;
float y = r * Xi.z;