#version 120 varying mediump vec2 texture_coordinate; uniform sampler2D heightTexture; uniform sampler2D TerrainTexture1; uniform sampler2D TerrainTexture2; uniform sampler2D TerrainTexture3; uniform sampler2D TerrainTexture4; uniform sampler2D TerrainTexture5; uniform float time; void main (void) { mediump float height = ((texture2D(heightTexture, texture_coordinate).r-0.5)*255.0); mediump float snow=0, rock=0, grass=0, dirt=0; mediump float x = height; dirt = -0.0008*(x-16)*(x-16)+1.0; grass = -0.0011*(x-48)*(x-48)+1.0; rock = -0.0011*(x-100)*(x-100)+1.0; snow = -0.0021*(x-120)*(x-120)+1.0; if(dirt<0) dirt = 0; if(grass<0) grass = 0; if(rock<0) rock = 0; if(snow<0) snow = 0; if(x>130) snow=1.0; mediump vec2 texCoords = texture_coordinate + vec2(time, time) ; if(texCoords.s >1 ) texCoords.s = texCoords.s-int(texCoords.s); if(texCoords.t >1 ) texCoords.t = texCoords.t-int(texCoords.t); //texCoords=normalize(texCoords); gl_FragColor = dirt * texture2D(TerrainTexture1, texture_coordinate); gl_FragColor += grass* texture2D(TerrainTexture2, texture_coordinate); gl_FragColor += rock * texture2D(TerrainTexture3, texture_coordinate); gl_FragColor += snow * texture2D(TerrainTexture4, texture_coordinate); //gl_FragColor = normalize(gl_FragColor); gl_FragColor.a = 1.0; if( height < 0 ) { gl_FragColor = texture2D(TerrainTexture5, texCoords ); } }