Skip to main content
GameDev.net gamedev.net
🔒 Locked

backbuffer=backbuffer * texture - blend modes

Started by Hello Kitty Nov 9, 2010 at 11:42 AM 3 replies 1.3k views
Original Post
Hello Kitty
Hello Kitty
I am making a dx9 ao shader.



I have the ao greyscale image in a texture, and the rendered scene in the backbuffer.



What blendmodes (dx9 fixed function pipeline) would I need to multiply the ao texture against the backbuffer.



something like this : backbuffer=backbuffer*aotexture



I currently have the following, but it is not blending with the backbuffer.



gRender->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
gRender->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
gRender->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);
gRender->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
gRender->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
gRender->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
gRender->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2 );
gRender->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );


Is it even possible to blend a texture with the existing backbuffer?





Thanks

-goodbye-
Adam_42
Adam_42
The only blend operations supported are listed here. If you need anything else you'll need to render your scene to a render target, and then take that render target along with the AO texture as inputs to a shader that blends them in the way you want.
Hodgman
Hodgman
The first 3 lines of code you posted do set up the correct blend mode, i.e.
result = src*0 + dest * source
or
result = dest * source

The next 5 lines of code seem to be telling the FFP to multiply your AO texture with the vertex diffuse colour -- do you need to do this as well?

What do you mean by "it is not blending with the backbuffer"? Do you end up with the backbuffer, the ao-buffer, just a black screen, etc?
Hello Kitty
Hello Kitty
No, I dont need to multiply my AO texture with the vertex diffuse colour.

So what should the SetTextureStageStates be?

I only see the ao texture. There is no blending.

thanks


-goodbye-
sanxcoo
sanxcoo
Maybe you can try this

gRender->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT );

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.