Texturing splattering on terrain using blending.

Blitz3D Forums/Blitz3D Programming/Texturing splattering on terrain using blending.

I am searching for some basic basic code of how to blend textures into one surface. i belive its possible. i knwo there is examples but i fail to found them.



Here is code.
i use a jpg for grass texture
i use a jpg for mudd texture
i use a 33x33 BMP with black and white in.

Ressult of below is not good.. :D but it is as far as i come.

Please some one that is king of the hill of blending. help me.
;Blending texture school lession 1.   your fist blend.


;Goal is to create 3 textures. 1 grass, 2 Sand, 3 black and wite texture to do alpha of the textures.


;Setup gfx
Graphics3D 1280,800,32,2
SetBuffer BackBuffer()
Cls

camera=CreateCamera()
CameraViewport camera,0,0,1280,800




;Creates a plan mesh of 33x33 vertices
mesh=CreateMesh()
surf=CreateSurface(mesh)
For z=0 To 32
	For x=0 To 32
		vert=AddVertex (surf,x,0,z,x,z)
	Next
Next
For z=0 To 31
	For x=0 To 31

		V1=Z*33+X
		V2=(Z+1)*33+X
		V3=Z*33+X+1
		V4=(Z+1)*33+X+1

		AddTriangle surf,v1,v2,v3
		AddTriangle surf,v3,v2,v4

	Next
Next



;Position an rotate camera to point to the mesh
PositionEntity camera,0,50,0
PointEntity camera,mesh
PositionEntity camera,16,25,16


tex_grass=LoadTexture("Grass.jpg") ; loads the grass texture.
If Not tex_grass Then RuntimeError "Grass.jpg"
TextureBlend tex_grass,2

tex_blend1=LoadTexture("blend1.bmp",4) ;loads the blend1 texture.
If Not tex_blend1 Then RuntimeError "Blend1.bmp"
TextureBlend tex_blend1,2
ScaleTexture tex_blend1,33,33


tex_mudd=LoadTexture("mudd.jpg") ; loads the mudd texture.
If Not tex_mudd Then RuntimeError "mudd.jpg"
TextureBlend tex_mudd,2



tex_blend2=LoadTexture("blend2.bmp",4) ;loads the blend1 texture.
If Not tex_blend2 Then RuntimeError "Blend2.bmp"
TextureBlend tex_blend2,2
ScaleTexture tex_blend2,33,33



EntityTexture mesh,tex_grass,0,1
EntityTexture mesh,tex_blend1,0,2
EntityTexture mesh,tex_mudd,0,3
EntityTexture mesh,tex_blend2,0,4

EntityBlend mesh,1

While Not KeyHit(1)

	UpdateWorld()
	RenderWorld
	Flip

Wend