Per-Pixel Texture Alpha?

Blitz3D Forums/Blitz3D Programming/Per-Pixel Texture Alpha?

Yes, very true jfk :-)


I've hit a snag though. The following code (slightly different from what I posted above) works fine on one PC (with Geforce 4 gfx), but on another (with Intel gfx) the ReadPixelFast returns $0000FFFF for pixels that are quite clearly black (should be $00000000). In fact, for all pixels the Green and Blue are always $FF.

Anyone got any ideas why this might happen?

	Local TexBuff = TextureBuffer(Texture)
	LockBuffer(TexBuff)

	For X = 0 To TextureWidth(Texture) -1
		For Y = 0 To TextureHeight(Texture) -1
	
			Local RGB = ReadPixelFast(X, Y, TexBuff) And $00ffffff
			
			Local Red = (RGB Shr 16) And $ff
			Local Green = (RGB Shr 8) And $ff
			Local Blue = RGB And $ff
			Local Alpha = (Red + Green + Blue) / 3
			
			DebugLog (Hex(RGB) + " > " + Red + ", " + Green + ", " + Blue + " = " + Alpha)
			
			WritePixelFast(X, Y, (Alpha Shl 24) Or RGB, TexBuff)	
			
		Next
	Next
	
	UnlockBuffer(TexBuff)