Jump to content
  • Advertisement
Sign in to follow this  
CadeF

[Solved]Problem with HLSL shader - Refuses to accept anything as a tangent

This topic is 4666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a problem. In my hlsl shader, whatever I put in the vertex shader's input as the tangent becomes 1.0f,1.0f,1.0f. If I swap the normal and the tangent coordinates, the normal is still accepted (containing what the tangent contained) and the tangent is still 1.0f,1.0f,1.0f. Vertex structure
    Public Structure udt_FaceVert
        Dim X As Single
        Dim Y As Single
        Dim Z As Single
        Dim Normal As Vector3
        Dim Tu As Single
        Dim Tv As Single
        Dim Tangent As Vector3
    End Structure

Vertex format = VertexFormats.Position Or VertexFormats.Normal Or VertexFormats.Texture0 Or VertexFormats.Texture1



struct a2v
{ 
    float4 position : POSITION0;
    float3 normal : NORMAL;
    float2 tex0 : TEXCOORD0;
    float3 tangent : TANGENT;
};

But if I use this,
struct a2v
{ 
    float4 position : POSITION0;
    float3 normal : TANGENT;
    float2 tex0 : TEXCOORD0;
    float3 tangent : NORMAL;
};
The tangent contains valid data and the normal contains 1.0f,1.0f,1.0f.



If I swap the normal and the tangent before draw*primitive and before using the shader, the normal will contain the correct tangent data and the tangent will contain 1.0f,1.0f,1.0f instead of the normal data. By pausing the program right at the DrawPrimitve/DrawUserPrimitive, I can see that the tangent data passed is correct. There is no specific shader which is causing the problem. I have written 3 different shaders to output what the vertex's tangent is and it is always 1.0f,1.0f,1.0f Any ideas? I'm fairly sure I've overlooked something somewhere. Thanks :) [Edited by - CadeF on November 6, 2005 5:02:34 PM]

Share this post


Link to post
Share on other sites
Advertisement
Also, your HLSL structure should look like:


struct a2v
{
float4 position : POSITION0;
float3 normal : NORMAL;
float2 tex0 : TEXCOORD0;
float3 tangent : TEXCOORD1;
};


xyzzy

Share this post


Link to post
Share on other sites
Thanks, xyzzy

In future, if anyone stumbles on this thread, the final fvf is

D3DDevice.VertexFormat = VertexFormats.Position Or VertexFormats.Normal Or VertexFormats.Texture1 Or VertexFormats.Texture2 Or VertexTextureCoordinate.Size3(1)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!