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-13 23:20:44 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-13 23:44:57 +0300
commit0c1c69d8df45ce59ca59cdb1c8aebcb93926f0d1 (patch)
treedb91fffc8b01ddc1faccb01648b9b2125caf3b03 /source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
parent402442997a39067d6f84538770665f1baf206f79 (diff)
Eevee: Hair: Remove old hack and replace by new hack.
This is a hack to properly shade wire hairs. Use stochastic sampling and let TAA solve the noise. At least it's way more correct than the previous hack.
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.glsl44
1 files changed, 9 insertions, 35 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 88fde8929cb..d777f9f5397 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -168,15 +168,19 @@ 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 */
+
+ N = N * abs(rand.z) + B * rand.y;
+#endif
+
/* ---------------------------------------------------------------- */
/* -------------------- SCENE LAMPS LIGHTING ---------------------- */
/* ---------------------------------------------------------------- */
-#ifdef HAIR_SHADER
- vec3 norm_view = cross(V, N);
- norm_view = normalize(cross(norm_view, N)); /* Normal facing view */
-#endif
-
for (int i = 0; i < MAX_LIGHT && i < laNumLight; ++i) {
LightData ld = lights_data[i];
@@ -186,29 +190,6 @@ void CLOSURE_NAME(
vec3 l_color_vis = ld.l_color * light_visibility(ld, worldPosition, viewPosition, viewNormal, l_vector);
-#ifdef HAIR_SHADER
- vec3 norm_lamp, view_vec;
- float occlu_trans, occlu;
- light_hair_common(ld, N, V, l_vector, norm_view, occlu_trans, occlu, norm_lamp, view_vec);
-
- #ifdef CLOSURE_DIFFUSE
- out_diff += l_color_vis * light_diffuse(ld, -norm_lamp, V, l_vector) * occlu_trans;
- #endif
-
- #ifdef CLOSURE_SUBSURFACE
- out_trans += ld.l_color * light_translucent(ld, worldPosition, -norm_lamp, l_vector, sss_scale) * occlu_trans;
- #endif
-
- #ifdef CLOSURE_GLOSSY
- out_spec += l_color_vis * light_specular(ld, N, view_vec, l_vector, roughnessSquared, f0) * occlu * ld.l_spec;
- #endif
-
- #ifdef CLOSURE_CLEARCOAT
- out_spec += l_color_vis * light_specular(ld, C_N, view_vec, l_vector, C_roughnessSquared, f0) * C_intensity * occlu * ld.l_spec;
- #endif
-
-#else /* HAIR_SHADER */
-
#ifdef CLOSURE_DIFFUSE
out_diff += l_color_vis * light_diffuse(ld, N, V, l_vector);
#endif
@@ -224,15 +205,8 @@ void CLOSURE_NAME(
#ifdef CLOSURE_CLEARCOAT
out_spec += l_color_vis * light_specular(ld, C_N, V, l_vector, C_roughnessSquared, f0) * C_intensity * ld.l_spec;
#endif
-
-#endif /* HAIR_SHADER */
}
-#ifdef HAIR_SHADER
- N = -norm_view;
-#endif
-
-
/* ---------------------------------------------------------------- */
/* ---------------- SPECULAR ENVIRONMENT LIGHTING ----------------- */