• Runtimes
  • How to access mesh vertex data for TBN-matrix?

A question for @Mitch or @badlogic, or anyone who knows the answer...

I'm trying to find a way to gain access to the vertex tangents array of the mesh in order to calculate the TBN-matrix for proper normal lighting using skinned meshes, but I'm not sure how to do it in a shader with glsl es (using gamemaker studio).

From this post viewtopic.php?f=7&t=4103
Mitch said,"... a Skinned mesh that is deformed via weights takes into account the rotation/scale of the most significant bone per vertex to calculate its corresponding tangent."

I know the above was stated for Unity, but is it possible to gain access to this vertex array information? Especially in an engine that doesn't have pre-built scripts that support 3D like game maker? (I especially need this if I want to increase performance, because currently, the TBN matrix is being calculated in the fragment shader using derivative functions - which is too heavy on the GPU.)

Related Discussions
...
  • تم التحرير

We don't calculate the tangents in runtimes other than Unity I'm afraid. I'll ask @Pharan to point you at the place in the Unity runtime where we calculate the tangents.

If you are interested in the "normal" vertex data, that's accessible either on the mesh attachment (before transforms) or on the slat the mesh attachment is attached to (after slot).

What runtime are you using?

badlogic wrote

We don't calculate the tangents in runtimes other than Unity I'm afraid. I'll ask @Pharan to point you at the place in the Unity runtime where we calculate the tangents.

Oh, okay, that's useful to know.

I believe I"m using the ecriss/GameMaker - C runtime http://www.yoyogames.com/blog/43... or whatever the official GM runtime for Spine is at the moment, thought I wasn't aware if people are still using the older ones that are just extensions.


@Pharan Pardon me, but I still haven't found where the tangents are calculated in the Spine Unity runtime.

Where is that Pharan?! :wonder: Look here, most of the actual work is done here. Note only 3 of the ArraysMeshGenerator functions are used for tangents, you can ignore the rest.

@Nate Thank you very much!