Sign in to follow this  
CadeF

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

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this