Eevee: Hair: Disable SSR for hairs.
authorClément Foucault <foucault.clem@gmail.com>
Sun, 13 May 2018 22:18:00 +0000 (00:18 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Sun, 13 May 2018 22:18:00 +0000 (00:18 +0200)
SSR does not work with hair strands. Basically, the rays are too much
random to ever converge properly and just result in a soup of self
inter reflections.

So forcing it to not produce any SSR. Could potentially save some bandwidth
by not rendering hair to the SSR buffers.

source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl

index 80d305cb1e8b2225d4624555f5937ca315f0c5b9..704b039e0f60ef6bd7208b4a686ac60639937fbd 100644 (file)
@@ -671,6 +671,7 @@ struct Closure {
 /* This is hacking ssr_id to tag transparent bsdf */
 #define TRANSPARENT_CLOSURE_FLAG -2
 #define REFRACT_CLOSURE_FLAG -3
+#define NO_SSR -999
 
 #  ifdef USE_SSS
 #    ifdef USE_SSS_ALBEDO
index ca33aa99ed999e14d72f6e371f57600591bdab27..737a2977146952ca17c69cc3327a49b23d458ef2 100644 (file)
@@ -177,6 +177,13 @@ void CLOSURE_NAME(
        float cos_theta = rand.x * 2.0 - 1.0;
        float sin_theta = sqrt(max(0.0, 1.0f - cos_theta*cos_theta));;
        N = N * sin_theta + B * cos_theta;
+
+#  ifdef CLOSURE_GLOSSY
+       /* Hair random normal does not work with SSR :(.
+        * It just create self reflection feedback (which is beautifful btw)
+        * but not correct. */
+       ssr_id = NO_SSR; /* Force bypass */
+#  endif
 #endif
 
        /* ---------------------------------------------------------------- */
@@ -385,6 +392,12 @@ void CLOSURE_NAME(
        }
 
        out_spec += spec_accum.rgb * ssr_spec * spec_occlu * float(specToggle);
+
+#  ifdef HAIR_SHADER
+       /* Hack: Overide spec color so that ssr will not be computed
+        * even if ssr_id match the active ssr. */
+       ssr_spec = vec3(0.0);
+#  endif
 #endif
 
 #ifdef CLOSURE_REFRACTION