So I have a pixelshader that blends different textures using a blend map, but I am attempting to make the blending an option. So my solution was that I calculate 3 different float3 which are in an array (0 is no blend, 1 is blend between two textures, and 2 is blend between three textures), and then I thought I could use a value from a constant buffer to determine which one should be used like this roughly.
cbuffer VSConstants : register(b13)
{
float4 i;
}
int index = i[0];
return float4(finalized[index], 1.0f);
but the result from this is that D3DCompileFromFile returns E_FAIL and then CreatePixelShader crashes with an access violation.
I'm guessing that the compiler doesn't like that I use index as an "index" casuse if I set it to a manual value like 1 it works perfectly fine. The only other way I could think of getting around it is by using if cases to check what i[0] is but from what we learnt if cases are not a good thing to have in shaders from an optimisation view (and seeing how I would need multiple if cases it gets even worse). So does anyone know how I can solve the problem, or alternativly have another solution?