diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-05-29 13:25:43 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-05-30 13:25:20 +0300 |
commit | 10f6450ef24ca1e99b3454c76117d877f35541fe (patch) | |
tree | e51aed473eb7bf398cab55abf47a889c087c17e4 /source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl | |
parent | 501c0b1df8c2db9806481d4e4c4c59008389b426 (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_vert.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl index 06b073afd8a..9dffe1ec33b 100644 --- a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl @@ -8,8 +8,10 @@ uniform mat3 NormalMatrix; uniform mat4 ModelMatrixInverse; #endif +#ifndef HAIR_SHADER in vec3 pos; in vec3 nor; +#endif out vec3 worldPosition; out vec3 viewPosition; @@ -28,12 +30,34 @@ out vec3 worldNormal; out vec3 viewNormal; #endif -void main() { +#ifdef HAIR_SHADER +out vec3 hairTangent; +out float hairThickTime; +out float hairThickness; +out float hairTime; +#endif + +void main() +{ +#ifdef HAIR_SHADER + vec3 pos, nor; + hair_get_pos_tan_nor_time( + (ProjectionMatrix[3][3] == 0.0), + ViewMatrixInverse[3].xyz, ViewMatrixInverse[2].xyz, + pos, nor, hairTangent, hairTime, hairThickness, hairThickTime); + + gl_Position = ViewProjectionMatrix * vec4(pos, 1.0); + viewPosition = (ModelMatrixInverse * vec4(pos, 1.0)).xyz; + worldPosition = pos; + worldNormal = nor; + viewNormal = normalize(mat3(ViewMatrixInverse) * nor); +#else gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz; worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz; - viewNormal = normalize(NormalMatrix * nor); worldNormal = normalize(WorldNormalMatrix * nor); + viewNormal = normalize(NormalMatrix * nor); +#endif /* Used for planar reflections */ gl_ClipDistance[0] = dot(vec4(worldPosition, 1.0), ClipPlanes[0]); |