# SDK: Tangent and Bitangent

**URL:** <https://forums.chaos.com/t/sdk-tangent-and-bitangent/20775>\
**Category:** Public\
**Created:** [May 26, 2009, 12:24pm UTC](https://forums.chaos.com/t/sdk-tangent-and-bitangent/20775 "2009-05-26T12:24:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aya](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@Aya](https://forums.chaos.com/u/Aya)\
**Post date:** [May 26, 2009, 12:24pm UTC](https://forums.chaos.com/t/sdk-tangent-and-bitangent/20775/1 "2009-05-26T12:24:08Z")

</div>

Hi,

is there any pre-computed Tangent and Bitangent available somewhere, or do I have to compute it myself?

And if I have to compute it myself.. how would I do this? Because I can’t find any information about the triangle-UVs that I’d need in the VRayContext ☹

Aya~

---

<div class="post-metadata">

**Author:** ![vladimir.nedev](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/vladimir.nedev/32/59224_2.png) [@vladimir.nedev](https://forums.chaos.com/u/vladimir.nedev)\
**Post date:** [June 1, 2009, 3:58pm UTC](https://forums.chaos.com/t/sdk-tangent-and-bitangent/20775/2 "2009-06-01T15:58:36Z")

</div>

You can get this information by querying the sd (ShadeData) of VRayContext::rayresult for the MappedSurface interface. Then use it to retrieve the transformation from world to texture space. Then invert this transformation and use its x and y columns to get the world space coordinates of the tangent and bi-tangent vectors.

Something like this:

MappedSurface \*mappedSurf=(MappedSurface\*) GET\_INTERFACE(rc.rayresult.sd, EXT\_MAPPED\_SURFACE);  
if (mappedSurf) {  
&nbsp;&nbsp;&nbsp;&nbsp;Matrix worldToTex=mappedSurf-\>getLocalUVWTransform(rc, channel).m;  
&nbsp;&nbsp;&nbsp;&nbsp;Matrix texToWorld=inverse(worldToTex);  
&nbsp;&nbsp;&nbsp;&nbsp;texToWorld.f[0]; // this is the tangent  
&nbsp;&nbsp;&nbsp;&nbsp;texToWolrd.f[1]; // this is the bi-tangent  
}

Hope this helps.

Greetings,  
Vladimir Nedev

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [June 1, 2009, 4:00pm UTC](https://forums.chaos.com/t/sdk-tangent-and-bitangent/20775/3 "2009-06-01T16:00:32Z")

</div>

This is correct for Maya, but for 3ds Max you can simply use the ShadeContext:: DPDUVW() method. Note however that the result from this is not continuous across triangles. If you need the continious vectors, let me know.

Best regards,  
Vlado
