Jump to content
  • Advertisement
Sign in to follow this  
Hurp

Post Process Multitexture

This topic is 3767 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Well, rather then using the fixed functions SetTexture couldn't I just set the texture with effect->SetTexture ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!