Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Problem with D3DXComputeTangentFrame


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 george7378   Members   -  Reputation: 1245

Like
0Likes
Like

Posted 08 May 2013 - 02:36 PM

Hi everyone,

 

I have recently decided to mess with a mesh in Blender, and I didn't change much - I just removed about 50 vertices and replaced them with about 50 more (basically, just added a few cylinders in place of some old cylinder-like objects) and now I get the following problems when I try to compute the tangent frame for normal mapping:

 

D3DX: D3DXComputeTangentFrame: Warning: vertex 13296 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13297 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13298 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13317 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13318 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13319 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13345 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13346 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13347 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13366 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13367 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Warning: vertex 13368 has zero normal, results not guaranteed!
D3DX: D3DXComputeTangentFrame: Unable to create consistent tangent frames in this mesh without splitting vertices.

 

The vertex warnings actually appeared before, so that's nothing new (I have recalculated the normals in Blender many times, but it still gives me these 'no normal' warnings) but the last line is what is causing D3DXComputeTangentFrame to fail, and hence, my program doesn't run. Any ideas what could be causing the problem? I have no idea what it means!

 

Thanks!



Sponsor:

#2 MJP   Moderators   -  Reputation: 11569

Like
2Likes
Like

Posted 08 May 2013 - 03:59 PM

In certain cases vertices will need to be split in order to generate consistent tangent frames for all triangles. The most common and easy-to-understand case is when UV's are mirrored across a vertex. Here's a crude diagram showing what I mean:

 

(0, 0) ============ (1, 0) ============= (0, 0)

 |                    |                     |

 |                    |                     |

 |                    |                     |

 |                    |                     |

 |                    |                     |

 |                    |                     |

(0, 1) ============ (1, 1) ============= (0, 1)

 

So here we have two quads using 6 verts, with UV coordinates shown for each vertex. To generate tangents and bitangents for these vertices, we look at how the UV coordinates are changing going from one vertex to the next. The bitangent is simple in this case: it's always increasing in the downward direction, so the bitangent will be (0, -1, 0) for all 6 verts. However the tangent is not so simple. This is because the U coordinate increases going from the left verts to the middle verts, but then decreases again going from the middle vert to the right vert. So for the leftmost verts you want a tangent of (1, 0, 0), and for the rightmost vert you want a tangent of (-1, 0, 0). For the middle verts however there is no tangent value we can use that will work correctly with both the left quad and the right quad. To deal with this we have to split the middle verts, so that you have one with  a tangent of (1, 0, 0) for the left quad and one with a tangent of (-1, 0, 0) for the right quad.

D3DXComputeTangentFrame will not split vertices, since it tries to put the tangent/bitangent data in the same mesh that it's using as an input. If you need to split verts, then you need to use D3DXComputeTangentFrameEx which can output a different mesh than the input mesh with a different number of vertices.



#3 george7378   Members   -  Reputation: 1245

Like
0Likes
Like

Posted 08 May 2013 - 05:51 PM

Thanks for the info - I don't see how it could suddenly be problematic when all I did was edit a few vertices, but I don't know much about the inner workings of meshes. First, is it possible to identify the culprit UV vertices in Blender? (I'm right in thinking that it hasn't got anything to do with the vertices themselves, but rather the UV coordinates?) - if I could find them in Blender I could probably move them around a bit. If not ... I guess I'll try D3DXComputeTangentFrameEx, although there seem to be a lot of terms in that function which I don't understand!

 

Thanks.



#4 george7378   Members   -  Reputation: 1245

Like
0Likes
Like

Posted 09 May 2013 - 04:03 AM

OK, I changed my code so that it does this instead:

 

    if (FAILED(D3DXComputeTangentFrameEx(texturedMesh, D3DDECLUSAGE_TEXCOORD, 0, D3DDECLUSAGE_BINORMAL, 0, D3DDECLUSAGE_TANGENT, 0, D3DDECLUSAGE_NORMAL, 0, 0, 0, 0.01f, 0.25f, 0.01f, &texturedMesh, 0)))
    {return false;}

 

I think this is OK usage of the function? There's a lot of stuff in there which I'm not really sure of! The program seems to run OK though, so I guess it's no problem...






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS