Editing textures in a shader

Started by
6 comments, last by JB3DG 10 years, 9 months ago

Hi guys

Is it possible to write to a texture in a shader? For example i have a texture array of 4 textures, the first 3 have been loaded with images, the 4th is left blank. Now i sample the first 3, perform an alpha blend on them. Is it possible to send the resulting color to the 4th texture?

Thanks

JB

Advertisement

Yes. Just create texture with shader resource and render target flags.

Im guessing then that the texture must be a render target and it will be filled with the returned values of the shader?

That's right. Considering original post you'll need to set depth stencil to NULL while rendering into this texture.

Got it. Thanks a bunch.

Just to make sure I am not missing anything, how does one "execute" the shader function?

Shaders get executed by rendering (drawing) something. For your current problem a so-called full-screen quad is recommended - a quad which covers the whole target area. With D3D10/11 one can even avoid vertices/indices and a input layout altogether by applying the following trick (it's actually a full-screen triangle, but the result is the same).

Thanks. Will try.

This topic is closed to new replies.

Advertisement