View Full Version : adressing Variables in HLSL without D3DX
virtual
07-02-2011, 09:44 PM
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
depending on which version of d3d you are using you can do the following:
for d3d9
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:
float4 PackedVariables: register(c0);
or
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:
float timer: register(c0[0]);
float some_other_var: register(c0[1]);
then you can use SetPixelShaderConstantF function:
SetPixelShaderConstantF(0, @Data, 1);//for c0 register; in this case Data should be a float vector4 type.
virtual
08-02-2011, 07:20 AM
thats exactly what i am looking for , thanks alot Dan
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.