2009-05-07 20:53:56 -04:00
|
|
|
USING: multiline ;
|
|
|
|
IN: terrain.shaders
|
|
|
|
|
|
|
|
STRING: terrain-vertex-shader
|
|
|
|
|
|
|
|
uniform sampler2D heightmap;
|
2009-05-09 12:15:06 -04:00
|
|
|
uniform vec4 component_scale;
|
2009-05-07 20:53:56 -04:00
|
|
|
|
|
|
|
varying vec2 heightcoords;
|
|
|
|
|
|
|
|
float height(sampler2D map, vec2 coords)
|
|
|
|
{
|
|
|
|
vec4 v = texture2D(map, coords);
|
2009-05-09 12:15:06 -04:00
|
|
|
return dot(v, component_scale);
|
2009-05-07 20:53:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_Position = gl_ModelViewProjectionMatrix
|
|
|
|
* (gl_Vertex + vec4(0, height(heightmap, gl_Vertex.xz), 0, 0));
|
|
|
|
heightcoords = gl_Vertex.xz;
|
|
|
|
}
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
STRING: terrain-pixel-shader
|
|
|
|
|
|
|
|
uniform sampler2D heightmap;
|
2009-05-09 12:15:06 -04:00
|
|
|
uniform vec4 component_scale;
|
2009-05-07 20:53:56 -04:00
|
|
|
|
|
|
|
varying vec2 heightcoords;
|
|
|
|
|
|
|
|
float height(sampler2D map, vec2 coords)
|
|
|
|
{
|
|
|
|
vec4 v = texture2D(map, coords);
|
2009-05-09 12:15:06 -04:00
|
|
|
return dot(v, component_scale);
|
2009-05-07 20:53:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_FragColor = texture2D(heightmap, heightcoords);
|
|
|
|
}
|
|
|
|
|
|
|
|
;
|