Post Process Multitexture

Started by
2 comments, last by MJP 16 years, 1 month ago
I started using a very basic Post Processing technique and I was wondering how I would do multi-texturing for post processing. My following (very slimmed down basic code) right now is

sampler2D gTexture;

float4 ps_main( float2 Tex : TEXCOORD0 ) : COLOR0
{

    return tex2D( gTexture, Tex.xy);
}
In the end I would like to have the second texture (with I suppose the first texture being my texture that is created from my back buffer, then is drawn with the D3D Device's sprite option) be set partially transparent.
Advertisement
sampler2D gTexture : register ( s0 );sampler2D gTexture2 : register ( s1 );float4 ps_main( float2 Tex : TEXCOORD0 ) : COLOR0{    float4 color = tex2D( gTexture, Tex.xy ) + tex2D( gTexture2, Tex.xy );    return color / 2.0f;}


The HLSL is very simple. You can of course do whatever blending technique you wish, you can even emulate standard fixed-function alpha-blending if you prefer. What I posted just weights the two textures equally.

As for outside your app, I don't think you're going to be able to make the D3DX sprite interface work for you. It's not really designed for these kinds of uses, so you're better off just making your own screen-sized code and working with that. See the PostProcess sample in the SDK if you need to see how to do that.

Also note that I added the register bit to the samplers, with this your samplers correspond directly to the texture stage you set a texture to.
Well, rather then using the fixed functions SetTexture couldn't I just set the texture with effect->SetTexture ?
Quote:Original post by Hurp
Well, rather then using the fixed functions SetTexture couldn't I just set the texture with effect->SetTexture ?


Absolutely, you'll just have to set your sampler to use that texture.

This topic is closed to new replies.

Advertisement