Texture Blend

BlitzMax Forums/MiniB3D Module/Texture Blend

BLaBZ(Posted 2010) [#1]
Trying to make the top textures alpha areas show the bottom texture, seems to work in blitz3d but not with miniB3D..

Blitz3D

; TextureBlend Example
; --------------------

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()

; Choose a background colour which isn't the same colour as anything else, to  avoid confusion
CameraClsColor camera,255,0,0

light=CreateLight()
RotateEntity light,90,0,0

cube=CreateCube()
PositionEntity cube,0,0,5

; Load textures
tex0=LoadTexture( "pcolor.png",2 )
tex1=LoadTexture( "power1text.png",2 )


; Texture cube with textures
EntityTexture cube,tex0,0,0
EntityTexture cube,tex1,0,1


tex0_blend_info$="no texture"
tex1_blend_info$="no texture"

While Not KeyDown( 1 )

; Change texture 0 blending mode
If KeyHit( 11 )=True
tex0_blend=tex0_blend+1
If tex0_blend=4 Then tex0_blend=0
If tex0_blend=0 Then tex0_blend_info$="no texture"
If tex0_blend=1 Then tex0_blend_info$="no blend"
If tex0_blend=2 Then tex0_blend_info$="multiply"
If tex0_blend=3 Then tex0_blend_info$="add"
EndIf

; Change texture 1 blending mode
If KeyHit( 2 )=True
tex1_blend=tex1_blend+1
If tex1_blend=4 Then tex1_blend=0
If tex1_blend=0 Then tex1_blend_info$="no texture"
If tex1_blend=1 Then tex1_blend_info$="no blend"
If tex1_blend=2 Then tex1_blend_info$="multiply"
If tex1_blend=3 Then tex1_blend_info$="add"
EndIf

; Set texture blend modes
TextureBlend tex0,tex0_blend 
TextureBlend tex1,tex1_blend 

TurnEntity cube,0.1,0.1,0.1

RenderWorld

Text 0,0,"Press 0 to change texture 0's blending mode"
Text 0,20,"Press 1 to change texture 1's blending mode"
Text 0,40,"TextureBlend tex0,"+tex0_blend+" ("+tex0_blend_info$+")"
Text 0,60,"TextureBlend tex1,"+tex1_blend+" ("+tex1_blend_info$+")"

Flip

Wend

End 



miniB3D

SuperStrict


Import MaxGUI.Drivers
Import "minib3d.bmx"




Graphics3D 800,600,32,2


Local camera:TCamera=CreateCamera()
CameraClsColor camera,255,0,0
Local light:TLight=CreateLight()
RotateEntity(light,90,0,0)
Local cube:TEntity=CreateCube()
PositionEntity cube,0,0,5

Local tex0:TTexture=LoadTexture("pcolor.png",2)
Local tex1:TTexture=LoadTexture("power1text.png",2)

EntityTexture cube,tex0,0,0
EntityTexture cube,tex1,0,1

TextureBlend tex0,1
TextureBlend tex1,1

Local tex_blend1:Int=1
Local tex_blend_info1:String

Local tex_blend2:Int=1
Local tex_blend_info2:String

While Not KeyDown(KEY_ESCAPE)

	If KeyHit(KEY_1)
		tex_blend1=tex_blend1 + 1
		If tex_blend1=4 Then tex_blend1=0
		If tex_blend1=0 Then tex_blend_info1="No texture"
		If tex_blend1=1 Then tex_blend_info1="No blend"
		If tex_blend1=2 Then tex_blend_info1="multiply"
		If tex_blend1=3 Then tex_blend_info1="add"
	EndIf
	
	If KeyHit(KEY_2)
		tex_blend2=tex_blend2 + 1
		If tex_blend2=4 Then tex_blend2=0
		If tex_blend2=0 Then tex_blend_info2="No texture"
		If tex_blend2=1 Then tex_blend_info2="No blend"
		If tex_blend2=2 Then tex_blend_info2="multiply"
		If tex_blend2=3 Then tex_blend_info2="add"
	EndIf
	
	TextureBlend tex0,tex_blend1
	TextureBlend tex1,tex_blend2
	
	TurnEntity cube,0.1,0.1,0.1
		
	UpdateWorld
	RenderWorld
	
	
	BeginMax2D()
		DrawText tex_blend_info1,0,0
		DrawText tex_blend_info2,0,12
	EndMax2D()
	
	
	
	Flip
	Cls

Wend 


In Blitz3D when textureblend is set to no blend for both textures I get the result I'm looking for...minib3d not so much

any help is really appreciated!