Archived

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

RhoneRanger

D3DTOP_BLENDTEXTUREALPHA help

Recommended Posts

I am using this flag to blend my textures on the 3rd pass, and it appears that some graphics cards (GeForce4 MX for one) dont like this call. All the other graphics cards I have tested on (GeForce4, etc) this call works fine! My question is, is there another way to blend textures besides calling D3DTOP_BLENDTEXTUREALHPA? Am I right in assuming that its the card that is not accepting the call? What has happened, is in the app the whole screen goes blank. They can still hear the music, but no textures or primitives are showing. I remove the line, and all works well (Except the texture blending of course). Thank you all!

Share this post


Link to post
Share on other sites
quote:
I am using this flag to blend my textures on the 3rd pass, and it appears that some graphics cards (GeForce4 MX for one) dont like this call.

What stage are you using? I don''t know a lot about GF4MX, but with the GF2MX you had specific operations with specific stages (Although it had 8 stages, they weren''t general purpose. Only the 1st 2 were general-purpose as far as I recall, the others had specific usages)

Make sure you call ValidateDevice() after you setup your stages, and check your debug spew. (Note that on the GF2MX, ValidateDevice() sometimes didn''t fail with invalid stage states set)
You should always test it on the REF device, if it runs, then it''s:
1) The card doesn''t support it: The most probable one
or
2) The driver''s buggy

quote:
is there another way to blend textures besides calling D3DTOP_BLENDTEXTUREALHPA?

Try:

AlphaOp = SelectArg1;
AlphaArg1 = Texture;
BlendOp = Add;
SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha;



Cheers,
Muhammad Haggag

Share this post


Link to post
Share on other sites
Thank you coder, and for the record I will post my TextureStageStates as of current


  

Device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
Device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
Device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
Device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
Device->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
Device->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );

Device->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
Device->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE );
Device->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
Device->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
Device->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
Device->SetTextureStageState( 1, D3DTSS_RESULTARG, D3DTA_TEMP );

Device->SetTextureStageState(2, D3DTSS_TEXCOORDINDEX, 1);
Device->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA );
Device->SetTextureStageState( 2, D3DTSS_COLORARG1, D3DTA_TEMP );
Device->SetTextureStageState( 2, D3DTSS_COLORARG2, D3DTA_CURRENT );
Device->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE );



I like it this way better than the way you posted earlier, cause the blending is done in the actual texture, in the Hardware, therefore much faster!

I guess I will have to have to test to see if the device is validated, and if not to blend the old way.

Thank you Coder!

Share this post


Link to post
Share on other sites
quote:
Device->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE ); Device->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); Device->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_DIFFUSE); Device->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); Device->SetTextureStageState( 1, D3DTSS_RESULTARG, D3DTA_TEMP );

You can''t enable colorOp and disable alphaOp. You either enable both, or disable both. The fact that it''s working doesn''t mean it''s right (a driver update/different_driver/card might break it).

Cheers,
Muhammad Haggag

Share this post


Link to post
Share on other sites
quote:
Coder, remember that stage 1 is returning TEMP.

My point was: The behavior *should* be undefined when you enable ColorOp while having AlphaOp disabled. So whether you''re returning TEMP or not, it''s not guaranteed to work on all cards/drivers.

Cheers,
Muhammad Haggag

Share this post


Link to post
Share on other sites
hmmm, so even if you dont use an alpha op, you still need to define one?


EDIT: Also since a GeForce2 does support blending by texture alpha channel and 8 texture passes, there shouldnt be a problem at all with this, unless my thinking is goofy.

[edited by - RhoneRanger on March 5, 2003 12:26:06 PM]

Share this post


Link to post
Share on other sites
Are you using ValidateDevice? I would suspect not. I''m not sure the GForce 4MX supports 3 this rendering setup.

Thanks
Chris

Share this post


Link to post
Share on other sites
quote:
hmmm, so even if you dont use an alpha op, you still need to define one?

As far as I know, yes. A Direct3D MVP said that you either enable both, or disable both. Just set it SELECTARG1, and make that your color/texture.

Cheers,
Muhammad Haggag

Share this post


Link to post
Share on other sites