   Tangents problems, 3dsmax and xna
  I've been writing a shader in 3dsmax, and it all looks good there.However when I tested the shader in my xna application, the lighting seemed off.Check picture belowhttp://img32.picoodle.com/img/img32/3/12/29/f_lightingm_bb80004.jpgIf I lit the model just using the per vertex normals, it looked fine, so I assumed it was the tangents that were somehow wrong.And yes, when I modified the shader to display them, I got a difference in my xna application and 3dsmax.I tried exporting tangents using the kw xporter, but tangents end up looking quite broken.And when generating in xna gives me a different result than in 3dsmax.Here's a picture of that.http://img32.picoodle.com/img/img32/3/12/29/f_tangentsm_d06b99c.jpgAnyone have any suggestions? I guess I either have to flip vectors somehow, or get the proper tangents exported.below is the shader, but it's quite simple so I don't think the problem is there.//This is the base shader for the game. Most assets will have this shader.#ifdef _3DSMAX_string ParamID = "0x0001";#endiffloat4x4 World: World;float4x4 View: View;float4x4 Projection: Projection;float4x4 InverseTranspose : InverseTranspose;float3 AmbientColorSky : DIFFUSE <    string UIName =  "Ambient Sky";    string UIWidget = "Color";> = {0.5f, 0.5f, 0.5f};texture Texture : DiffuseMap< string UIName = "Diffuse Map ";int Texcoord = 0;int MapChannel = 1; >;   texture NormalMap : NormalMap< string UIName = "Normal Map";int Texcoord = 0;int MapChannel = 1; >; sampler2D DiffuseSampler = sampler_state {   Texture = <Texture>;   MipFilter = LINEAR;   MinFilter = ANISOTROPIC;   MagFilter = LINEAR;   MaxAnisotropy = 4;   AddressU = WRAP;   AddressV = WRAP; }; sampler2D NormalSampler = sampler_state {   Texture = <NormalMap>;   MipFilter = LINEAR;   MinFilter = ANISOTROPIC;   MagFilter = LINEAR;   MaxAnisotropy = 4;   AddressU = WRAP;   AddressV = WRAP; }; float4 light1Pos : POSITION < string UIName = "Light 1 Position"; string Object = "PointLight"; string Space = "World"; int refID = 1; > = {100.0f, 100.0f, 100.0f, 0.0f}; float4 light1Color : LIGHTCOLOR < int LightRef = 1; string UIWidget = "None"; > = { 1.0f, 1.0f, 1.0f, 1.0f}; struct VertexShaderInput{    float4 Position: POSITION0;    float3 Normal  : NORMAL;float3 Tangent: TANGENT0;    float2 UV: TEXCOORD0; };struct VertexShaderOutput{    float4 Position: POSITION0;    float2 UV: TEXCOORD0;float3 Normal : TEXCOORD1;  float3 Tangent: TEXCOORD2;float3 WorldPos: TEXCOORD3;};VertexShaderOutput VertexShaderFunction(VertexShaderInput input){    VertexShaderOutput output;    float4 worldPosition = mul(input.Position, World);    float4 viewPosition = mul(worldPosition, View);    output.Position = mul(viewPosition, Projection);    output.Normal = mul(input.Normal,World);    output.UV = input.UV;  output.Tangent = mul(input.Tangent.rgb,World);    output.WorldPos = worldPosition;    return output;}float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0{float3 Color;    float3 diffuse = tex2D(DiffuseSampler, input.UV).rgb;float3 normal = 2.0 * (tex2D(NormalSampler, input.UV).rgb-0.5); float3 Tn = normalize(input.Tangent);float3 Nn = normalize(input.Normal);float3 Bn = normalize(cross(Tn,Nn));float3 N = (Nn * normal.z) + (normal.x * -Bn + normal.y * Tn);N = normalize(N);float3 L = input.WorldPos - light1Pos.xyz;    diffuse = dot(normalize(-L),N);    diffuse = max(diffuse,0);Color = diffuse*AmbientColorSky;Color = input.Tangent;return float4(Color, 1);}technique Technique1{    pass Pass1    {VertexShader = compile vs_3_0 VertexShaderFunction();   PixelShader = compile ps_3_0 PixelShaderFunction();    }}   