Fix T62621 object scale changes tangent node output in Eevee

Normal Matrices were not normalized, leading to non-normalized vector
rotations results.
This commit is contained in:
Clément Foucault 2019-03-15 22:28:18 +01:00
parent 1d6009d7aa
commit 86646dab7c
Notes: blender-bot 2023-02-14 08:58:01 +01:00
Referenced by commit cc1b193ddf, Revert "Fix T62621 object scale changes tangent node output in Eevee"
Referenced by issue #62783, Problems in 2.8 in viewport matcaps as well as render of certain files - Since last two week builds
Referenced by issue #62621, object scale changes tangent node output in Eevee
3 changed files with 6 additions and 4 deletions

View File

@ -66,8 +66,8 @@ void main()
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
worldNormal = normalize(WorldNormalMatrix * nor);
viewNormal = normalize(NormalMatrix * nor);
worldNormal = WorldNormalMatrix * nor;
viewNormal = NormalMatrix * nor;
#endif
/* Used for planar reflections */

View File

@ -24,8 +24,8 @@ void main() {
#ifdef MESH_SHADER
viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
viewNormal = normalize(NormalMatrix * nor);
worldNormal = normalize(WorldNormalMatrix * nor);
viewNormal = NormalMatrix * nor;
worldNormal = WorldNormalMatrix * nor;
#ifdef USE_ATTR
pass_attr(pos);
#endif

View File

@ -803,6 +803,7 @@ static void draw_matrices_model_prepare(DRWCallState *st)
copy_m3_m4(st->normalview, st->modelview);
invert_m3(st->normalview);
transpose_m3(st->normalview);
normalize_m3(st->normalview);
}
if (st->matflag & DRW_CALL_EYEVEC) {
/* Used by orthographic wires */
@ -821,6 +822,7 @@ static void draw_matrices_model_prepare(DRWCallState *st)
copy_m3_m4(st->normalworld, st->model);
invert_m3(st->normalworld);
transpose_m3(st->normalworld);
normalize_m3(st->normalworld);
st->matflag &= ~DRW_CALL_NORMALWORLD;
}
}