Alpha Channel only in Direct3D ?
Hi guys,
I'm using Direct3D for my 2D game. I have lots of things I want to blit that are really just an alpha channel and a color, with no actual texture, for example, tiny particles that are a solid color. So I was thinking, all I really need is the alpha channel and the diffuse color of the four vetices, but it seems I still have to store the texture colors; that's a waste. Right now I'm just making the texture itself a solid color and not using the diffuse color for the vertices. Also, if I want to change the color on the fly I can do that by changing the vertex colors and using a solid white texture. But like I said, it seems like a waste.
Any ideas ? Thanks.
PS - Is this the right forum for Direct3D questions ?
You'll want to check out the SetTextureStageState() function, and all of it's related constants. You can use it to set both the Color and Alpha operations to D3DTOP_SELECTARG1, and then set argument 1 for both color and alpha equal to D3DTA_DIFFUSE. With this setup, you don't need any texture at all. The primitive will be colored and blended according to the diffuse vertex colors/alpha only, nothing else.
[edit]And the DirectX Forum would probably be where you wanted this, for future reference.[/edit]
[edit]And the DirectX Forum would probably be where you wanted this, for future reference.[/edit]
That won't give him per-pixel alpha (for particles, I'm guessing that's what he needs - single-colour quads with an alpha channel to shape them into circles or something). If he wants his particles to fade out at the edges and tries to do it by setting the alpha of each vertex to zero... he won't see very much... [smile]
I believe you want the D3DFMT_A8 texture format. If that's not supported, then try stepping up to a 16-bit format (like D3DFMT_R5G6B5, or even D3DFMT_R16), and then to 24 bits, and then to 32.
You don't necessarily need to store alpha information in the alpha channel of a texture; using a pixel shader you could move, say, the red component of the texture into the alpha channel of the result.
This isn't the correct forum for DirectX questions, but I'll move it for you.
I believe you want the D3DFMT_A8 texture format. If that's not supported, then try stepping up to a 16-bit format (like D3DFMT_R5G6B5, or even D3DFMT_R16), and then to 24 bits, and then to 32.
You don't necessarily need to store alpha information in the alpha channel of a texture; using a pixel shader you could move, say, the red component of the texture into the alpha channel of the result.
This isn't the correct forum for DirectX questions, but I'll move it for you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement