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>2018-05-29 13:25:43 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-30 13:25:20 +0300
commit10f6450ef24ca1e99b3454c76117d877f35541fe (patch)
treee51aed473eb7bf398cab55abf47a889c087c17e4 /source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
parent501c0b1df8c2db9806481d4e4c4c59008389b426 (diff)
Eevee: Add support for new Hair geometry system.
This now can shade actual poly strips that mimics cylinders. This makes hair coverage exact compared to the line method and result in smoother fading hair. This does make the sampling a bit more exact but needs more samples to converge properly.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl42
1 files changed, 30 insertions, 12 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index 737a2977146..accecaacbde 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -21,6 +21,15 @@ in vec3 worldNormal;
in vec3 viewNormal;
#endif
+#ifdef HAIR_SHADER
+in vec3 hairTangent; /* world space */
+in float hairThickTime;
+in float hairThickness;
+in float hairTime;
+
+uniform int hairThicknessRes = 1;
+#endif
+
#endif /* LIT_SURFACE_UNIFORM */
/** AUTO CONFIG
@@ -169,21 +178,30 @@ void CLOSURE_NAME(
vec4 rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2.0), 0);
#ifdef HAIR_SHADER
- /* Random normal distribution on the hair surface. */
- vec3 T = normalize(worldNormal); /* meh, TODO fix worldNormal misnaming. */
- vec3 B = normalize(cross(V, T));
- N = cross(T, B); /* Normal facing view */
- /* We want a cosine distribution. */
- 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;
+ if (hairThicknessRes == 1) {
+ /* Random normal distribution on the hair surface. */
+ vec3 T = normalize(worldNormal); /* meh, TODO fix worldNormal misnaming. */
+ vec3 B = normalize(cross(V, T));
+ N = cross(T, B); /* Normal facing view */
+ /* We want a cosine distribution. */
+ 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 */
+ /* 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
+ }
+ else {
+ vec3 T = normalize(cross(hairTangent, worldNormal));
+ /* We want a cosine distribution. */
+ float cos_theta = hairThickTime / hairThickness;
+ float sin_theta = sqrt(max(0.0, 1.0f - cos_theta*cos_theta));;
+ N = normalize(hairTangent * cos_theta + T * sin_theta);
+ }
#endif
/* ---------------------------------------------------------------- */