DX10 sprite and pixel shader
- by Alex Farber
I am using ID3DX10Sprite to draw 2D image on the screen. 3D scene contains only one textured sprite placed over the whole window area. Render method looks like this:
m_pDevice-ClearRenderTargetView(...);
m_pSprite-Begin(D3DX10_SPRITE_SORT_TEXTURE);
m_pSprite-DrawSpritesImmediate(&m_SpriteDefinition, 1, 0, 0);
m_pSprite-End();
Now I want to make some transformations with the sprite texture in a shader. Currently the program doesn't work with shader. How it is possible to add pixel shader to the program with this structure?
Inside the shader, I need to set all colors equal to red, and multiply pixel values by some coefficient. Something like this:
float4 TexturePixelShader(PixelInputType input) : SV_Target
{
float4 textureColor;
textureColor = shaderTexture.Sample(SampleType, input.tex);
textureColor.x = textureColor.x * coefficient;
textureColor.y = textureColor.x;
textureColor.z = textureColor.x;
return textureColor;
}