blob: e9974559f7c06ce7fe9984dc33059324c736b60c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
VARYING vec3 pos;
VARYING vec2 UV;
VARYING float overhigh;
void MAIN()
{
UV = UV0 * (vertCount / size);
float xStep = xDiff;
float yStep = yDiff;
if (flipU)
xStep *= -1;
if (flipV)
yStep *= -1;
vec2 uStep = vec2(xStep, 0.0);
vec2 vStep = vec2(0.0, yStep);
vec3 v = texture(height, UV).xyz;
vec3 vRight = texture(height, UV + uStep).xyz;
vec3 vLeft = texture(height, UV - uStep).xyz;
vec3 vUp = texture(height, UV + vStep).xyz;
vec3 vDown = texture(height, UV - vStep).xyz;
vec3 tangent = vLeft - vRight;
vec3 bitangent = vUp - vDown;
vec3 n = normalize(cross(bitangent, tangent));
overhigh = 0;
if (fill) {
if (v.y > graphHeight)
overhigh = 1;
if (any(greaterThan(UV0, vec2(1.05))) || any(lessThan(UV0, vec2(-0.05)))) // if sides bottom vertex
v.y = -graphHeight;
else if (v.y > graphHeight)
v.y = -10000;
// lower the unseen verts by a high amount to decrease the angle between the neighbouring seen verts
}
NORMAL = n;
VERTEX = v;
pos = VERTEX;
vec4 pos = MODELVIEWPROJECTION_MATRIX * vec4(VERTEX, 1.0);
pos.z += 0.000002 * (order + 1);
POSITION = pos;
}
|