Stack Exchange
Passing Texture through Shader DirectX 9
I am trying to render a texture that gets passed through a pixel shader.
Currently my shader is as follows:
float4 EffectProcess( float2 Tex : TEXCOORD0 ) : COLOR0
{
   return float4(1,0,0,1);
}

technique MyTechnique
{
    pass p0
    {
        VertexShader = null;
        PixelShader = compile ps_2_0 EffectProcess();
    }
}

As you can see, it is a very basic shader that makes that forces the pixels to be red.
UINT uiPasses = 0;
        res= g_lpEffect->Begin(&uiPasses, 0);
        for (UINT uiPass = 0; uiPass < uiPasses; uiPass++)
        {
            res = g_lpEffect->BeginPass(uiPass);
            res = sprite->Begin(D3DXSPRITE_SORT_TEXTURE);
            res = sprite->Draw(tex, NULL, 0x0, 0x0, 0xFFFFFFFF);
            res = sprite->End();
            res = g_lpEffect->EndPass();
        }
        res = g_lpEffect->End();

And I am drawing the texture using the shader like so. I am not sure this is the correct way to do it though and have found very little resources on the subject.
The shader is being created correctly and the texture aswell, all calls return a hresult of S_OK, yet when I run the code, the texture shows perfectly, without being overwritten by red.

Both sprite and effects by default store initial pipeline state and set up their own when Begin is called and then restore it when End is called. So I suspect that sprite->Begin(D3DXSPRITE_SORT_TEXTURE); will disable effect processing and your pixel shader is never called. You may try to pass something like D3DXSPRITE_DONOTMODIFY_RENDERSTATE into Begin to prevent it from modifying pipeline state, though this may break sprite rendering. It would be better to get rid of sprite altogether and write your own sprite shader (both vertex and pixel) because fixed pipeline rendering is mostly deprecated these days.

I ended up creating my own sprite shader to do what I wanted to do.
