Can't blend Alpha and colour textures

Blitz3D Forums/Blitz3D Beginners Area/Can't blend Alpha and colour textures

Shifty Geezer(Posted 2004) [#1]
Iload two textures, one with ",2" flag for alpha, one left normal (or given ",1" flag.

I apply both textures to a model but they don't blend correctly. If I apply just the alpha (greyscale) image the object's transparency varies accordingly, but when i apply BOTH colour and alpha textures, the colour texture is MULTIPLIED by the alpha and the transparency doesn't change. What am I doing wrong?

Const SCREENX = 640
Const SCREENY = 480
; PositionTexture Example
; -----------------------

Graphics3D SCREENX,SCREENY
SetBuffer BackBuffer()

AmbientLight(255,255,255)

;rectangle=CreateMesh()
;surf=CreateSurface(rectangle)
;
;v0=AddVertex(surf,-1,-1,0) ; bottom corner 1
;v1=AddVertex(surf,-1,1,0) ; bottom corner 2
;v2=AddVertex(surf,1,1,0) ; bottom corner 3
;v3=AddVertex(surf,1,-1,0) ; bottom corner 4
;
;t0=AddTriangle(surf,v1,v2,v0) ; bottom triangle 1
;t1=AddTriangle(surf,v0,v2,v3) ; bottom triangle 2

rectangle=LoadMesh("rectangle.3ds")

;cube=testcreatecube()
ScaleEntity rectangle,3,1,3
PositionEntity rectangle,0,0,5
RotateEntity rectangle,180,0,0

sphere=CreateSphere(16)
ScaleEntity sphere,25,25,25
PositionEntity sphere,0,-26,5

rostrum=CreatePivot()
PositionEntity rostrum,0,0,5

camera=CreateCamera(rostrum)
PositionEntity camera,0,80,0
CameraZoom camera,2
PointEntity camera,rectangle

alpha=LoadTexture( "working/testalpha.png",2 )
colour=LoadTexture( "working/testcolour.png",1 )

EntityTexture rectangle,colour,0,0
EntityTexture rectangle,alpha,0,1

While Not KeyDown( 1 )

	; Position texture
	RenderWorld
	Flip

Wend

End



Ethan3850(Posted 2004) [#2]
Try using the TextureBlend command to change the Blend mode for your alpha texture from multiply to Alpha or None - e.g.

EntityTexture rectangle,alpha,0,1
TextureBlend alpha,1



Shifty Geezer(Posted 2004) [#3]
I tried that and it didn't work, plus many other variations. But ~I did find a fix just now. It seems you have to set the entity's alpha to something other than 1 for alpha maps to blend. This sets the maximum opacity for the alpha map.

Setting 'EntityAlpha entity,0.999' basically turns on alpha mapping with colour mapping correctly, where alpha = 1.0 is opaque.

Setting 'EntityAlpha entity,0.5' limits the alpha map to half opacity maximum.