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-11-19 20:24:08 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-20 15:09:27 +0300
commit566a4a96cb516d7e7981cf78d24fcb7546deaaf4 (patch)
treec8142165227c969e3f185df2bc8585ef9e86c8f8 /source/blender/draw/modes/shaders/common_hair_lib.glsl
parent86e0d13218d6e9f918ca857890ee1c0aa681091b (diff)
Fix T57891: Radius of strip hair doesn't scale with object scale
Note that this only works fine with uniformly scaled objects. Otherwise, the hair thickness will vary in a weird way depending on viewing angles.
Diffstat (limited to 'source/blender/draw/modes/shaders/common_hair_lib.glsl')
-rw-r--r--source/blender/draw/modes/shaders/common_hair_lib.glsl8
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/draw/modes/shaders/common_hair_lib.glsl b/source/blender/draw/modes/shaders/common_hair_lib.glsl
index e272db02318..c0c5f84d166 100644
--- a/source/blender/draw/modes/shaders/common_hair_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_hair_lib.glsl
@@ -135,7 +135,7 @@ float hair_shaperadius(float shape, float root, float tip, float time)
}
void hair_get_pos_tan_binor_time(
- bool is_persp, vec3 camera_pos, vec3 camera_z,
+ bool is_persp, mat4 invmodel_mat, vec3 camera_pos, vec3 camera_z,
out vec3 wpos, out vec3 wtan, out vec3 wbinor, out float time, out float thickness, out float thick_time)
{
int id = hair_get_base_id();
@@ -159,7 +159,11 @@ void hair_get_pos_tan_binor_time(
thick_time = float(gl_VertexID % hairThicknessRes) / float(hairThicknessRes - 1);
thick_time = thickness * (thick_time * 2.0 - 1.0);
- wpos += wbinor * thick_time;
+ /* Take object scale into account.
+ * NOTE: This only works fine with uniform scaling. */
+ float scale = 1.0 / length(mat3(invmodel_mat) * wbinor);
+
+ wpos += wbinor * thick_time * scale;
}
}