Eevee: Fix black mesh when tangent is not present
In this case, the generic vertex attribute is {0,0,0,1}. So we look for this case. This fixes black text objects with a normal map applied. Also this could help porting sculpt mode drawing to Eevee without supporting normal mapping. Note that will just fix black meshes due to T61870 but objects will not show their normal map. So it's not a fix for this issue.
This commit is contained in:
parent
d0fb0d0a9d
commit
7fb7d20c19
Notes:
blender-bot
2023-02-14 03:21:25 +01:00
Referenced by issue #62621, object scale changes tangent node output in Eevee
|
@ -1001,7 +1001,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
|
|||
if (input->source == GPU_SOURCE_ATTR && input->attr_first) {
|
||||
if (input->attr_type == CD_TANGENT) { /* silly exception */
|
||||
BLI_dynstr_appendf(
|
||||
ds, "\tvar%d%s.xyz = normalize(NormalMatrix * att%d.xyz);\n",
|
||||
ds, "\tvar%d%s.xyz = NormalMatrix * att%d.xyz;\n",
|
||||
input->attr_id, use_geom ? "g" : "", input->attr_id);
|
||||
BLI_dynstr_appendf(
|
||||
ds, "\tvar%d%s.w = att%d.w;\n",
|
||||
|
|
|
@ -2967,6 +2967,12 @@ void node_object_info(mat4 obmat, vec3 info, out vec3 location, out float object
|
|||
|
||||
void node_normal_map(vec4 tangent, vec3 normal, vec3 texnormal, out vec3 outnormal)
|
||||
{
|
||||
if (all(equal(tangent, vec4(0.0, 0.0, 0.0, 1.0)))) {
|
||||
outnormal = normal;
|
||||
return;
|
||||
}
|
||||
|
||||
tangent.xyz = normalize(tangent.xyz);
|
||||
vec3 B = tangent.w * cross(normal, tangent.xyz);
|
||||
|
||||
outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * normal;
|
||||
|
|
Loading…
Reference in New Issue