Eevee: Fix tangent vector not normalized before interpolation.

This commit is contained in:
Clément Foucault 2019-03-21 23:53:24 +01:00
parent 27109fd209
commit 8b00712b55
Notes: blender-bot 2023-02-14 11:29:52 +01:00
Referenced by issue #62839, object scale changes normal map output in eevee
1 changed files with 7 additions and 0 deletions

View File

@ -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(