DX10 sprite and pixel shader
Posted
by
Alex Farber
on Game Development
See other posts from Game Development
or by Alex Farber
Published on 2012-03-27T10:55:52Z
Indexed on
2012/03/27
11:41 UTC
Read the original article
Hit count: 282
directx10
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; }
© Game Development or respective owner