Archived

This topic is now archived and is closed to further replies.

Texture blending - animate from a2b

This topic is 5648 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 want a surface to slowly fade between two textures - I.E. draw one [solid] texture then another on top with varying transparency. Can I do this with a single-pass, using two texture stages or should I draw twice? I have looked through the complicated blending options available but can''t work out how to do it in a single pass! A

Share this post


Link to post
Share on other sites
You should be able to use the D3DTOP_BLENDCURRENTALPHA texture stage state...

// select texture A
Stage 0 colourarg1 = textureA
Stage 0 colourop = select texture or modulate texture with diffuse

// blend stage0 output with textureB controlled by alpha channel
Stage 1 colourarg1 = textureB
Stage 1 colourarg2 = current
Stage 1 colourop = D3DTOP_BLENDCURRENTALPHA


Then you set the alpha texture stage states so that whatever alpha source you choose ends up in the stage1''s alpha.

This alpha value (from whereever you decide to put it) controls the blend percentage.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Did you have alpha blending enabled ? - if so, you shouldn''t because that will use the alpha value at the end of the texture blending pipe to control the opacity of the complete polygon when its rendered to the frame buffer.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Ok, I''ve got it now thanks.
But I have to say the SetTextureStageState() part of DirectX does seem a real mess, especially as there appear to be no tutorials or samples covering single-pass blending/multi-texturing etc.
Perhaps thats the price for flexibility.

Share this post


Link to post
Share on other sites
Aye, it can be a bit daunting until you get used to it.

1. I''d suggest having a play around with one/all of "MFC Texture" in the SDK, "BlendView" from nVidia or "MulTex" from ATI. Those programs let you play around with the texture blend cascade in realtime, and see the results in realtime. Very handy to confirm how it works.

2. IMO both APIs haven''t had an ideal solution to "fragment processing" until very recently. Register combiner style APIs have been slightly more intuitive, but not much.
Thankfully pixel shaders are much more intuitive and map much better to hardware.* Just have to wait another few years before the majority of users have shader capable hardware. (Many games developers are now concentrating on shaders as a primary path with fixed function being the downlevel port).


* the mapping of the texture stage state stuff to hardware usually isn''t exact, so some combinations simply aren''t supported either. This can be confusing when you set up a combination of operations which are all supported, which fit within the supported number of stages and it still fails ValidateDevice() or comes out wrong.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites