diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-03-22 01:53:24 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-03-22 02:13:18 +0300 |
commit | 8b00712b55e79a550fc02e7237b8d8fdb5fc35ef (patch) | |
tree | 90ce6cfe660672b78086e759f4ace00e0226d543 /source/blender/gpu/intern | |
parent | 27109fd209ca572445d9ec27b7f220b01001bf5b (diff) |
Eevee: Fix tangent vector not normalized before interpolation.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 195dc8950aa..99b79d3758c 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -1006,6 +1006,13 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u BLI_dynstr_appendf( ds, "\tvar%d%s.w = att%d.w;\n", input->attr_id, use_geom ? "g" : "", input->attr_id); + /* Normalize only if vector is not null. */ + BLI_dynstr_appendf( + ds, "\tfloat lvar%d = dot(att%d.xyz, att%d.xyz);\n", + input->attr_id, input->attr_id, input->attr_id); + BLI_dynstr_appendf( + ds, "\tvar%d%s.xyz *= (lvar%d > 0.0) ? inversesqrt(lvar%d) : 1.0;\n", + input->attr_id, use_geom ? "g" : "", input->attr_id, input->attr_id); } else if (input->attr_type == CD_ORCO) { BLI_dynstr_appendf( |