GLchar *TerrainVertexShaderStr[] = {
(GLchar*) "#version 120\n",
(GLchar*) "uniform sampler2D vertTexture; \n",
(GLchar*) "uniform sampler2D normTexture; \n",
(GLchar*) "uniform vec3 sunpos; \n",
(GLchar*) "uniform vec4 transMatrix; \n",
(GLchar*) "attribute vec2 vPosition; \n",
(GLchar*) "varying vec2 texCrd; \n",
(GLchar*) "varying float color; \n",
(GLchar*) "varying float diff; \n",
(GLchar*) "void main () { \n",
(GLchar*) " vec2 tpos = vec2(gl_Vertex.xy); \n",
(GLchar*) " tpos.x = (tpos.x * transMatrix.b) + transMatrix.r; \n",
(GLchar*) " tpos.y = (tpos.y * transMatrix.a) + transMatrix.g; \n",
(GLchar*) " vec4 vert = texture2D(vertTexture, tpos).xyzw; \n",
(GLchar*) " vec3 norm = texture2D(normTexture, tpos).xyz; \n",
(GLchar*) " color = clamp(((vert.y / 1.5f) + 400.0f) / 5120.0f, 0.02f, 1.0f); \n",
(GLchar*) " diff = clamp(dot(norm.xyz, normalize(sunpos - vert.xyz)), 0.6f, 1.0f); \n",
(GLchar*) " texCrd = vec2(vPosition.xy); \n",
(GLchar*) " gl_Position = gl_ModelViewProjectionMatrix * vert; \n",
(GLchar*) "}"
};
GLchar *TerrainFragmentShaderStr[] = {
(GLchar*) "#version 120\n",
(GLchar*) "uniform sampler1D colorTexture; \n",
(GLchar*) "uniform sampler2D grndTexture; \n",
(GLchar*) "varying vec2 texCrd; \n",
(GLchar*) "varying float color; \n",
(GLchar*) "varying float diff; \n",
(GLchar*) "void main () { \n",
(GLchar*) " vec4 vcolor = texture1D(colorTexture, color); \n",
(GLchar*) " vec4 tcolor = texture2D(grndTexture, texCrd); \n",
(GLchar*) " gl_FragColor = vcolor * diff; \n",
(GLchar*) "}"
};