diff options
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl | 20 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl | 4 |
2 files changed, 12 insertions, 12 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 004d884dc75..c190ca0e245 100644 --- a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl @@ -42,11 +42,6 @@ float pdf_ggx_reflect(float NH, float NV, float VH, float alpha) #endif } -float pdf_hemisphere() -{ - return 0.5 * M_1_PI; -} - vec3 sample_ggx(vec3 rand, float alpha, vec3 Vt) { #if USE_VISIBLE_NORMAL @@ -94,20 +89,24 @@ vec3 sample_ggx(vec3 rand, float alpha, vec3 V, vec3 N, vec3 T, vec3 B, out floa return tangent_to_world(Ht, N, T, B); } +float pdf_hemisphere() +{ + return 0.5 * M_1_PI; +} + vec3 sample_hemisphere(vec3 rand) { - /* Theta is the cone angle. */ float z = rand.x; /* cos theta */ float r = sqrt(max(0.0, 1.0 - z * z)); /* sin theta */ float x = r * rand.y; float y = r * rand.z; - return vec3(x, y, z); } -vec3 sample_hemisphere(vec3 rand, vec3 N, vec3 T, vec3 B) +vec3 sample_hemisphere(vec3 rand, vec3 N, vec3 T, vec3 B, out float pdf) { vec3 Ht = sample_hemisphere(rand); + pdf = pdf_hemisphere(); return tangent_to_world(Ht, N, T, B); } @@ -125,10 +124,11 @@ vec3 sample_ggx(float nsample, return sample_ggx(Xi, alpha, V, N, T, B, pdf); } -vec3 sample_hemisphere(float nsample, float inv_sample_count, vec3 N, vec3 T, vec3 B) +vec3 sample_hemisphere( + float nsample, float inv_sample_count, vec3 N, vec3 T, vec3 B, out float pdf) { vec3 Xi = hammersley_3d(nsample, inv_sample_count); - return sample_hemisphere(Xi, N, T, B); + return sample_hemisphere(Xi, N, T, B, pdf); } vec3 sample_cone(float nsample, float inv_sample_count, float angle, vec3 N, vec3 T, vec3 B) diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl index 0d0ae6ea4a5..18fcfd4fd41 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl @@ -147,14 +147,14 @@ void main() float weight = 0.0; vec3 out_radiance = vec3(0.0); for (float i = 0; i < sampleCount; i++) { - vec3 L = sample_hemisphere(i, invSampleCount, N, T, B); /* Microfacet normal */ + float pdf; + vec3 L = sample_hemisphere(i, invSampleCount, N, T, B, pdf); float NL = dot(N, L); if (NL > 0.0) { /* Coarse Approximation of the mapping distortion * Unit Sphere -> Cubemap Face */ const float dist = 4.0 * M_PI / 6.0; - float pdf = pdf_hemisphere(); /* http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html : Equation 13 */ float lod = clamp(lodFactor - 0.5 * log2(pdf * dist), 0.0, lodMax); |