I want to sample a texture stored in a register on the graphicsDevice at multiple UV locations within an effect. I can sample this texture at the current UV location fine, but if I try to create another sampler at a different UV location it doesn't work. Here's what the effect looks like:
//the width and height of the current screen
float Width;
float Height;
//the texture sampler
sampler ColSampler : register(s1);
struct VS_OUTPUT
{
float2 uv[2] : TEXCOORD0;
}
VS_OUTPUT vsMain( float2 uv : TEXCOORD )
{ float WidthOffset = 1.0/Width;
float HeightOffset = 1.0/Height;
VS_OUTPUT o;
o.uv[0] = uv;
o.uv[1] = uv + float2( WidthOffset, HeightOffset );
return o;
float WidthOffset = 1.0/Width;
float HeightOffset = 1.0/Height;
VS_OUTPUT o;
o.uv[0] = uv;
o.uv[1] = uv + float2( WidthOffset, HeightOffset );
return o;
float WidthOffset = 1.0/Width;
float HeightOffset = 1.0/Height;
VS_OUTPUT o;
o.uv[0] = uv;
o.uv[1] = uv + float2( WidthOffset, HeightOffset );
return o;
}
float4 psMain(VS_OUTPUT i) : COLOR0
{
float4 col = tex2D(ColSampler, i.uv[0]); //This works fine
float4 col = tex2D(ColSampler, i.uv[1]); //This always returns black
...
}
On a possibly related note, how can I set the sampler state on a texture that is stored in a register? It possible I may try to smaple UVs greater than 1 or less than 0, so I want to wrap the texture. Everything I've tried gives a syntax error when I compile.