• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
george7378

Problem with D3DXComputeTangentFrame

3 posts in this topic

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!

0

Share this post


Link to post
Share on other sites

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.

2

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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...

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0