D3DTOP_BLENDTEXTUREALPHA help

Started by
8 comments, last by RhoneRanger 21 years, 1 month ago
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!
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Advertisement
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

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!
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
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

Coder, remember that stage 1 is returning TEMP.
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
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

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]
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Are you using ValidateDevice? I would suspect not. I''m not sure the GForce 4MX supports 3 this rendering setup.

Thanks
Chris
CheersChris
Yes I am using Validate Device
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
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

This topic is closed to new replies.

Advertisement