Given:
G=Grass
D=Dirt
R=Rock
S=Stone
I created 512x512 texture called tex0.
It's made up of 4 256x256 grass textures.
G G
G G
Also created 512x512 texture called tex1.
it's made up of 4 256x256 textures.
G R
D S
finally, create 512x512 texture called tex2.
it's made up of 4 256x256 textures each being a gradient fill.
GF GF
GF GF
The goal is to blend my two textures together using the gradient fill to provide a seamless transition. A more advanced version would allow a base texture, tiled texture, and the 2nd UV would control the alpha tile to be used.
I can't seem to get the alpha to cause the blend to work very well.
Here is the basic sample code I'm using. All help appreciated.
G=Grass
D=Dirt
R=Rock
S=Stone
I created 512x512 texture called tex0.
It's made up of 4 256x256 grass textures.
G G
G G
Also created 512x512 texture called tex1.
it's made up of 4 256x256 textures.
G R
D S
finally, create 512x512 texture called tex2.
it's made up of 4 256x256 textures each being a gradient fill.
GF GF
GF GF
The goal is to blend my two textures together using the gradient fill to provide a seamless transition. A more advanced version would allow a base texture, tiled texture, and the 2nd UV would control the alpha tile to be used.
I can't seem to get the alpha to cause the blend to work very well.
Here is the basic sample code I'm using. All help appreciated.
Dim u1#(4), V1#(4) Dim M(2) Global mesh, surf ;Graphics3D 800,600,32,2 Graphics3D 800,600,32 cam=CreateCamera() MoveEntity cam ,10,100,10 AmbientLight 128,128,128 ;AmbientLight 256,256,256 M(1)=CREATEGRID(32,100) ;Smoothing off ClearTextureFilters ;Filter Flags ;1: Color ;2: Alpha ;4: Masked ;8: Mipmapped ;16: Clamp U ;32: Clamp V ;64: Spherical reflection map TextureFilter "",1+2 ;TextureFilter "",1+8 ; Mip Mapped ; Load texture ;tex0=LoadTexture("alphaL.png") tex1=LoadTexture(".\textures\nutarg.tga") ClearTextureFilters TextureFilter "",8 ;tex1=LoadTexture("raw3.jpg") tex0=LoadTexture(".\textures\G0.jpg") TextureFilter "",8 tex2=LoadTexture(".\textures\T0.jpg") ; Create brush brush=CreateBrush() ; Apply texture to brush BrushTexture brush,tex0,0,0 BrushTexture brush,tex1,0,1 BrushTexture brush,tex2,0,2 ;Blend - Blend mode of texture. ;0: Do Not blend ;1: No blend Or Alpha (alpha when texture loaded with alpha flag - Not recommended For multitexturing - see below) ;2: Multiply (Default) ;3: Add TextureBlend tex0,2 TextureBlend tex1,1 TextureBlend tex2,2 ; And some shininess ;BrushShininess brush,1 ; Paint mesh with brush PaintSurface surf,brush PointEntity cam,m(1) While Not KeyHit(1) ; Toggle wireframe enable value between true and false when spacebar is pressed If KeyHit( 57 )=True Then enable=1-enable ; Enable/disable wireframe rendering WireFrame enable If T=0 Then T=MilliSecs() ;Prime time T2=MilliSecs() DeltaT# = (T2-T) / 1000.0 T=MilliSecs() ; Execute every 25ms ( 40/sec ) If T > Time2 + 0 Then Time2=T mxs#=mxs#+(MouseXSpeed()-mxs#)/3 mys#=mys#+(MouseYSpeed()-mys#)/3 If MouseDown(2) Then MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 p1#=p1#-mys# y1#=y1#-mxs# RotateEntity cam,-p1#,y1#,0 EndIf End If RenderWorld Flip Wend Function CreateGrid( Segs, Siz ) mesh=CreateMesh() surf=CreateSurface(mesh) For y=0 To Segs For x=0 To Segs tex=Rnd(1,2) Select tex Case 1 u1(1)=0:v1(1)=0 u1(2)=0:v1(2)=.4 u1(3)=.4:v1(3)=.4 u1(4)=.4:v1(4)=0 Case 2 u1(1)=0:v1(1)=.6 u1(2)=0:v1(2)=1 u1(3)=.4:v1(3)=1 u1(4)=.4:v1(4)=.6 Case 3 u1(1)=.6:v1(1)=.6 u1(2)=.6:v1(2)=1 u1(3)=1:v1(3)=1 u1(4)=1:v1(4)=.6 Case 4 u1(1)=.6:v1(1)=0 u1(2)=.6:v1(2)=.4 u1(3)=1:v1(3)=.4 u1(4)=1:v1(4)=0 End Select ;u1(1)=1:v1(1)=1 ;u1(2)=1:v1(2)=0 ;u1(3)=0:v1(3)=0 ;u1(4)=0:v1(4)=1 ;u1(1)=0:v1(1)=0 ;u1(2)=0:v1(2)=1 ;u1(3)=1:v1(3)=1 ;u1(4)=1:v1(4)=0 vert0=AddVertex(surf, x*siz+siz,0, y*siz-siz,u1(1),v1(1)) vert1=AddVertex(surf, x*siz+siz,0, y*siz,u1(2),v1(2)) vert2=AddVertex(surf, x*siz,0, y*siz,u1(3),v1(3)) vert3=AddVertex(surf, x*siz,0, y*siz-siz,u1(4),v1(4)) AddTriangle(surf,vert0,vert2,vert1) AddTriangle(surf,vert2,vert0,vert3) Next Next UpdateNormals mesh Return mesh End Function