Results 1 to 3 of 3

Thread: adressing Variables in HLSL without D3DX

  1. #1

    adressing Variables in HLSL without D3DX

    hi guys

    suppose that in my HLSL pixel shader i have a variable lets say : float timer .
    how could we addressing this variable from the application without ID3DXConstantTable
    i am looking for SetPixelShaderConstant() way


    thanks in advance
    Last edited by virtual; 07-02-2011 at 09:48 PM.

  2. #2
    depending on which version of d3d you are using you can do the following:
    for d3d9
    Code:
    float timer: register(c0);
    notice that in this case the timer variable will occupy the entire c0 register.
    you can pack your variable into a vector or a structure to be more efficient, like this:
    Code:
    float4 PackedVariables: register(c0);
    or
    Code:
    struct MyStruct {
      float t;
      float t2;
      float2 t3;
    };
    MyStruct v: register(c1);
    for d3d10 and higher you can specify the register offset
    so you can use overlapping registers like this:
    Code:
    float timer: register(c0[0]);
    float some_other_var: register(c0[1]);
    then you can use SetPixelShaderConstantF function:
    Code:
    SetPixelShaderConstantF(0, @Data, 1);//for c0 register; in this case Data should be a float vector4 type.
    Last edited by Dan; 08-02-2011 at 12:42 AM.

  3. #3
    thats exactly what i am looking for , thanks alot Dan

Bookmarks

Posting Permissions

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