CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2010
    Posts
    2

    HLSL4 - When setting struct values, order matters?

    I can't wrap my head around this. I'm trying to teach myself DirectX10 and am working on a lighting shader. I have a function that I call to move a vector from Local space to world space to camera space, and another that moves from local to WVP. My problem is the function to move to it WorldSpace is not working properly. It seems to be returning vertices that have NOT been transformed, ie they are still in their original locations.

    I have a switch/case statement in the function in there, that multiplies the vertex with a specified rotation matrix. I have verified that this is working correctly, ie the right matrix is used to multiply. I've verified that I'm setting the rotation matrix with the correct value.

    I cant think of anything else. Below is the shader function that I'm using, just wondering if anyone can see anything glaringly wrong. If anyone needs more code, I will be more than happy to post more. I just dont understand why the vertices are not transforming. Thanks for any help.

    <code>
    float3 MoveToWorldSpace(float3 vec, int index)
    {
    float4 temp = float4(vec, 1);
    float4 t = float4(0,0,0,1);
    [branch]
    switch(index){
    case 0:
    t = mul(temp, trans0w);
    break;
    case 1:
    t = mul(temp, trans1w);
    break;
    default:
    break;
    };
    float4 v;
    v.x = t.x;
    v.y = t.y;
    v.z = t.z;

    return v;
    };
    </code>

  2. #2
    Join Date
    Feb 2010
    Posts
    2

    Re: HLSL4

    And sorry about the innacurrate title name, I started asking a different question, but changed what I wanted to ask, and I can't figure out how to edit my post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured