Tangent-space generation failed


Hi There,

In my project I am exporting a mesh from Blender 2.63a which uses a UVSphere. The UVSphere has UV coordinates applied, and I need tangents and binormals generated on the export so I can apply a normal map in my shader.

I can successfully export this into PVRShaman as long as the UVSphere has 32 or less longitudinal segments. If I increase the number of segments of the UVSphere to 64 or even just to 33, then I get the following error on export:


"Tangent-space generation failed due to too many split vertices."


I can have as many "rings" (latitudinal lines) on the UV Sphere as I like, but I cannot increase the "segments" (longitudinal lines) above 32.


I performed a few experiments and it only happens if I select "smooth shading" in Blender. If I leave the model "flat shaded" then I can have 64 segments with no issues. But I need a smoothed shaded model.


I have been working with this limitation over the past few months, while I concentrated on developing the rest of my shader code, but I am getting to the point now where I need to increase the number of segments.


I just downloaded the new version of the PVRSDK & Tools - very nice btw :) and I ran my tests again this morning with the same results.


Any help you can give is much appreciated,


Thanks,


Andre.







bootstrapper2012-10-30 12:54:16

Can anyone offer any advice on this? It’s the most viewed of my questions, yet it remains unanswered. I am working around the problem, but sooner or later I would like to increase the density of my mesh. Please help :o3

Most likely your problem are the poles of your sphere …



If you look in the tools directory (SDK) there is a file called PVRTVertex.cpp which in turn has a method called PVRTVertexGenerateTangentSpace and within that method there is a “magic number” variable called const int cnMaxSharedVtx = 32;



This is essentially a hardcoded value which is causing your problems - either change it something higher and recompile Tools or rework your sphere so you don’t end up with poles ( something like this http://isoc-ny.org/wiki/File:Sphere.png)

OK, I see you are using the default exporter so you can’t just recompile the SDK with a higher value.



In this case, your only choice is to either change the sphere to a geodesic dome type ( with no poles) or , export your model without tangents/binormals and import the resulting POD in your own code (using the modified SDK with cnMaxSharedVtx =64 or something like that ) and call PVRTVertexGenerateTangentSpace within your code to generate tangents/binormals.


Hi Warmi,



Thanks very much for your help :slight_smile:

I don’t suppose there is a source code version of PVRGeoPOD which I could recompile with cnMaxSharedVtx = 128?



Andre.

Hi Andre,



Unfortunately we can’t provide source code for any of our utilities, but we’ll take your feedback into consideration to see if we can up the limit for the next release. The engineer responsible for this code is now on holiday until the new year, but I’ll discuss it with him when he returns.



In the meantime I’d suggest using Warmi’s workaround of a geodesic dome, or simplifying your model if possible. It should also be possible to work around it by splitting the model into multiple meshes (which can still be exported as a single POD).



Regards,

Tobias

Hi Tobias,



Thanks for getting back to me.



I took Warmi’s advice and I have now reworked my mesh to use a geodesic.



Thanks again and Merry Christmas to you all!