Texturing splattering on terrain using blending.

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

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I made a second surface, with vertexalpha. So now, there is 2 surface layers on top of each other. Actually you would only need to use 2 layers on the parts where a transition between the two textures is made:
;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 800,600,0,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
surf1=surf
surf=CreateSurface(mesh)
For z=0 To 32
	For x=0 To 32
		vert=AddVertex (surf,x,0,z,x,z)
		VertexColor surf,vert,255,255,255,Rnd(0,1)
	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
surf2=surf

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

tex_grass=LoadBrush("Grass.jpg") ; loads the grass texture.
If Not tex_grass Then RuntimeError "Grass.jpg"

tex_mudd=LoadBrush("mudd.jpg") ; loads the mudd texture.
If Not tex_mudd Then RuntimeError "mudd.jpg"

BrushFX tex_mudd,32+1+2
PaintSurface surf1,tex_grass
PaintSurface surf2,tex_mudd

While Not KeyHit(1)

	UpdateWorld()
	RenderWorld
	Flip

Wend

End