Simplify GLSL in bump mapping, use gl_NormalMatrix where appropriate.
tangents are directions and should be transformed like directions.
This commit is contained in:
@@ -665,7 +665,7 @@ static char *code_generate_vertex(ListBase *nodes)
|
||||
for (input=node->inputs.first; input; input=input->next)
|
||||
if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
|
||||
if (input->attribtype == CD_TANGENT) { /* silly exception */
|
||||
BLI_dynstr_appendf(ds, "\tvar%d.xyz = normalize((gl_ModelViewMatrix * vec4(att%d.xyz, 0)).xyz);\n", input->attribid, input->attribid);
|
||||
BLI_dynstr_appendf(ds, "\tvar%d.xyz = normalize(gl_NormalMatrix * att%d.xyz);\n", input->attribid, input->attribid);
|
||||
BLI_dynstr_appendf(ds, "\tvar%d.w = att%d.w;\n", input->attribid, input->attribid);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1169,7 +1169,7 @@ static void do_material_tex(GPUShadeInput *shi)
|
||||
}
|
||||
else if (mtex->normapspace == MTEX_NSPACE_OBJECT) {
|
||||
/* transform normal by object then view matrix */
|
||||
GPU_link(mat, "mtex_nspace_object", GPU_builtin(GPU_VIEW_MATRIX), GPU_builtin(GPU_OBJECT_MATRIX), tnor, &newnor);
|
||||
GPU_link(mat, "mtex_nspace_object", tnor, &newnor);
|
||||
}
|
||||
else if (mtex->normapspace == MTEX_NSPACE_WORLD) {
|
||||
/* transform normal by view matrix */
|
||||
|
||||
@@ -1507,9 +1507,9 @@ void mtex_nspace_world(mat4 viewmat, vec3 texnormal, out vec3 outnormal)
|
||||
outnormal = normalize((viewmat*vec4(texnormal, 0.0)).xyz);
|
||||
}
|
||||
|
||||
void mtex_nspace_object(mat4 viewmat, mat4 obmat, vec3 texnormal, out vec3 outnormal)
|
||||
void mtex_nspace_object(vec3 texnormal, out vec3 outnormal)
|
||||
{
|
||||
outnormal = normalize((viewmat*(obmat*vec4(texnormal, 0.0))).xyz);
|
||||
outnormal = normalize(gl_NormalMatrix * texnormal);
|
||||
}
|
||||
|
||||
void mtex_blend_normal(float norfac, vec3 normal, vec3 newnormal, out vec3 outnormal)
|
||||
|
||||
Reference in New Issue
Block a user