Drawing Alphas

Started by
6 comments, last by Dark_Light 19 years, 3 months ago
Hi people. I am looking for a way of drawing a texture that contains only Alpha to the screen. In doing this I wish to preserve the RGB that is currently on the screen and simply overwrite the Alpha. This will then aid the next draw that will do alpha blending depending on the destination Alpha. This method is intended to be used when a device cannot support more then 1 texturestate. I am open to alternatives. But I do want to make this a GPU task. I already have a 100% CPU method for doing this and it seem dumb to do it on the CPU when the GPU can do it much better. Thanks.
Advertisement
SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA);
Draw
SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA);
Draw again

requires

D3DPMISCCAPS_COLORWRITEENABLE capabilities bit is set in the PrimitiveMiscCaps member of the D3DCAPS9
Sounds good.
just in the middle of trying something else at the moment.
Thanks very much tho..

il let you know it i can get it working or not.


I have used the idea you posted but my alpha blending is not acting up.

If I do a the following
Draw RGB
Draw A
Draw RGB

Instead of getting the first land last draws blended with A, I get a 50% blend between the two.

This is odd. It even happens if I tern alpha blending off. Right now what ever I draw to the screen is blended by 50% depending on what ever was there in the first place.

Is this to do with me rendering a texture in the same place as the last one?

I really need to solve this problem.. its been on the back burner for ages
What SRCBLEND, DESTBLEND, and BLENDOP are you using?

When you created your device, did you ask for A8R8G8B8, or X8R8G8B8?

Are you sure your alpha is being written correctly? To verify this, in your last stage use a colorop of SELECTARG1, CURRENT|ALPHAREPLICATE, and turn on RGB writes again. Your alpha value will be drawn as grey.
Unfortunately something is not working.

I have used the idea you posted but my alpha blending is not acting up.

If I do a the following
Draw RGB
Draw A
Draw RGB

Instead of getting the first land last draws blended with A, I get a 50% blend between the two.

This is odd. It even happens if I tern alpha blending off. Right now what ever I draw to the screen is blended by 50% depending on what ever was there in the first place.

Is this to do with me rendering a texture in the same place as the last one?

I really need to solve this problem.. its been on the back burner for ages


Yep my alfa blend is definity off.

More Detail:
I have a dievice as normal with a format of (Format.A8R8G8B8)
If I draw a mesh to the device it looks fine

I have 3 textures
T1 is a plain RGB texture
T2 is a plain RGB texture
A1 is alpha map containing just alpha

I have working code that uses multiple texture stages to combine them all correctly (so I know colour and alpha are fine)

However I now need to write some code to support cards that can only do one render stage.

The plan was to write RGB then A then RGB blending with dA (d = destination)

However! And this is the bit that bugging me.

I am using ColorWriteEnable to enable and disable channel output.

If I do ColorWriteEnable.RedGreenBlueAlpha or
ColorWriteEnable.RedGreenBlue

Then the texture will show fine.
But as soon as I use

ColorWriteEnable.Red or ColorWriteEnable.Alpha etc then
The texture is belnded 50% with d.
No matter what the output.
Ahhhhh its so frustrating

Just to summarise if I write the first texture to the device using something like ColorWriteEnable.Red then it is blended with the background colour.

The only way I can get it to write without blending is to do
ColorWriteEnable.RedGreenBlueAlpha

Any help would be very mush appreciated. I have been going around is circle with this for ages and ages.!
Oh almost forgot
I am using every combination of alpha blend and blend. Although the output changes it makes no odds to the bug of the blending problem I am having.

Also this card only has one texture stage and so I cannot do any of that fancy stuff.. (I do know what you mean tho) But I know my R,G,B and A are fine as I have a working function for mutly stage cards. And it uses the same textures.
Wohoo got it working.

This topic is closed to new replies.

Advertisement