[RESOLVED] Render to Texture and Alphablend problem (VB6/DX8)
I’m trying to render to texture, by using the SetRenderTarget method. I create the texture using the D3DFMT_A8R8G8B8 format but when I render a sprite, for example, that has an 8bit alpha channel to the texture, the alpha blending doesn’t seem to be right. The “translucent pixels” in my image are more “clear” than it supposed to be. It’s better to look at an example, see http://www.auriterminal.com/view/Alpha.png (attached below)
There is a checkered image rendered first on to the backbuffer (which is presented). On top of that is an 8bit alpha channel image (black rectangle with three “holes” with varying opacity, that’s what it supposed to look like on the left. On the right is the render to texture surface. As you can see, the opacity for each hole is less with the right image. You can see the logic in the code snippet below.
Using VB6 and DX8.1
VB Code:
' Declarations
Dim pRendertexture As Direct3DTexture8
Dim pRendersurface As Direct3DSurface8
Dim pBackbuffer As Direct3DSurface8
Dim Zbuffer As Direct3DSurface8
' ... (Code) ....
' Create texture
Set pRendertexture = d3dx.CreateTexture(device, 256, 256, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT)
Set pRendersurface = pRendertexture.GetSurfaceLevel(0)