Multitexturing and EntityAlpha problem

Blitz3D Forums/Blitz3D Beginners Area/Multitexturing and EntityAlpha problem

octothorpe(Posted 2005) [#1]
I have a multitextured quad which is to act as a window for a GUI. The first texture is a simple tiled background for my window. The second texture needs to be either masked or transparent so I can show through parts of the window background where there are no gadgets or text; since I couldn't seem to get masking working, I'm using alpha.

Details:
texture 0: loadtexture_COLOUR, textureblend_ALPHA
texture 1: loadtexture_COLOUR+loadtexture_ALPHA+loadtexture_VRAM, textureblend_ALPHA

My problem is that when I set the enitity to an Alpha setting less than 1, the first texture disappears entirely.

1. How do I fix this?

2. Is there some page I can read that will explain all the nuances of what issues there are when combining alpha, multitextuing, and any other directx features i should be concerned about?

3. It seems rediculous that createtexture() defaults each pixel to be opaque, and I have to loop through and set them to 0. Am I doing something wrong?
; create the overlay texture which will be drawn to
this_window\overlay_texture = createtexture(next_power_of_two(width), next_power_of_two(height), loadtexture_COLOUR+loadtexture_ALPHA+loadtexture_VRAM)
scaletexture(this_window\overlay_texture, texturewidth(this_window\overlay_texture), textureheight(this_window\overlay_texture))
textureblend(this_window\overlay_texture, textureblend_ALPHA)
; make it transparent
for x=0 to texturewidth(this_window\overlay_texture)-1:for y=0 to textureheight(this_window\overlay_texture)
	writepixel(x,y,0,texturebuffer(this_window\overlay_texture))
next:next



octothorpe(Posted 2005) [#2]
help?


DH(Posted 2005) [#3]
From my experience (back when we were given the ability to store textures in VRam and what not), you don't have much leeway with writing directly to textures with alpha or mask information and have it acutally work.

There was something from mark that said the 256 flag wasn't intended as official and if too many problems arose he was going to take it out... That was months ago though.


jfk EO-11110(Posted 2005) [#4]
I think it wasn0t the 256 flag, but the mix of multiply blending and alpha blending. Some cards can't take it.

But if a mesh disappears if you reduce the alpha, sounds more like a driver bug to me. I had something similar, then I updated the driver (catalyst) and the problem was solved.

Also, you may swap the texture index for your mutlitexturing, so use an other layer for the alpha texture.

Unfortunatly this isn't really exact science since even the cards interprets these things individually.

BTW yes, you normally need to set the Alpha Bytes "manually", but there's a trick that may speed things up:

Keep a texture in memory that is black and fully transparent. Now use copyrect to copy from this texture to the texture you want to work with. Now draw to the edited texure (eg. Line, Plot or Text). You'll see, the texture is masked.


jfk EO-11110(Posted 2005) [#5]
BTW don't use Writepixel, but writepixelfast instead! (With Lockbuffer)