Thanks, Tom!
Here’s the working shader now, works totally fine:
//refract.fx
#define DECLARE_TEXTURE(Name, index) \
Texture2D<float4> Name : register(t##index); \
sampler Name##Sampler : register(s##index)
#define SAMPLE_TEXTURE(Name, texCoord) Name.Sample(Name##Sampler, texCoord)
DECLARE_TEXTURE(TextureSampler, 0);
DECLARE_TEXTURE(RefractSampler, 1);
float amt = 0.0f;
struct PS_INPUT
{
float2 TexCoord : TEXCOORD0;
};
float4 Refract(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float2 tex = texCoord;
float offset = SAMPLE_TEXTURE(RefractSampler, texCoord).g;
tex.x += offset * 0.01f;
tex.y += offset * 0.01f;
return SAMPLE_TEXTURE(TextureSampler, tex);
}
technique RefractTechnique
{
pass P0
{
PixelShader = compile ps_4_0_level_9_3 Refract();
}
}