Hey, first post here. Thanks for all you do. Not sure how to report this, so here you go… If I should report bugs differently, please let me know.
While trying to use an array of Texture2D objects, I learned that array indicies must be literal expressions. Using Pipeline tool 3.7.1.189, the ‘Effect Processor’ throws an invalid operation expression on non-zero literal expressions. This fragment compiles:
texture2D textures[2];
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
float4 color0;
float4 color1;
color0 = textures[0].Sample(samplerState, input.TextureCoordinate);
color1 = textures[0].Sample(samplerState, input.TextureCoordinate);
return color0 * color1;
}
but if you change the ‘0’ to ‘1’ in the assignment for color1, the invalid operation exception occurs.
Here is the complete .fx file for reference. It looks silly because I tried to whittle it down to something small…
#if OPENGL
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_3
#define PS_SHADERMODEL ps_4_0_level_9_3
#endif
float4x4 World;
float4x4 View;
float4x4 Projection;
texture2D textures[2];
SamplerState samplerState { MinFilter = POINT; MagFilter = POINT; AddressU = Wrap; AddressV = Wrap; };
struct VertexShaderInput
{
float4 Position : POSITION0;
float2 TextureCoordinate : TEXCOORD0;
};
struct VertexShaderOutput
{
float4 Position : POSITION0;
float2 TextureCoordinate : TEXCOORD0;
};
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
float4 worldPosition = mul(input.Position, World);
float4 viewPosition = mul(worldPosition, View);
output.Position = mul(viewPosition, Projection);
output.TextureCoordinate = input.TextureCoordinate;
return output;
}
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
float4 color0;
float4 color1;
color0 = textures[0].Sample(samplerState, input.TextureCoordinate);
color1 = textures[1].Sample(samplerState, input.TextureCoordinate);
return color0 * color1;
}
technique RingArrayShader
{
pass Pass1
{
VertexShader = compile VS_SHADERMODEL VertexShaderFunction();
PixelShader = compile PS_SHADERMODEL PixelShaderFunction();
}
}