https://bugs.winehq.org/show_bug.cgi?id=41383
Bug ID: 41383 Summary: normal computation with vertex blending looks wrong Product: Wine Version: unspecified Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: directx-d3d Assignee: wine-bugs@winehq.org Reporter: davyaxel@free.fr Distribution: ---
Hi,
In wined3d/glsl_shader.c, in shader_glsl_generate_ffp_vertex_shader, one can find:
if (settings->normal) { if (!settings->vertexblends) { shader_addline(buffer, "normal = ffp_normal_matrix * ffp_attrib_normal;\n"); } else { for (i = 0; i < settings->vertexblends + 1; ++i) shader_addline(buffer, "normal += ffp_attrib_blendweight[%u] * (mat3(ffp_modelview_matrix[%u]) * ffp_attrib_normal);\n", i, i); }
if (settings->normalize) shader_addline(buffer, "normal = normalize(normal);\n"); }
There seems to be a mistake: in the non vertexblends case, ffp_normal_matrix is set to the transpose of the inverse of the modelview matrix. That is in accordance to the spec. However in the vertexblends case, the modelview matrices are used non-inversed.
I guess they should be inversed and transposed (which explains why msdn says half the number of blend matrices are available when normals are used: because you need to store the inverses).
This non-msdn documentation https://user.xmission.com/~legalize/book/download/06-Vertex%20Transformation... (see page 14) also says the matrices should be inversed.