aboutsummaryrefslogtreecommitdiff
path: root/shaders/forest.vert
blob: c52174c71a0b7d280606590a781f7048bf464a85 (plain) (blame)
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
#version 150
#extension GL_ARB_explicit_attrib_location : enable
#extension GL_ARB_explicit_uniform_location : enable

layout(location = 0) in vec3 in_position ;
layout(location = 2) in vec4 in_color ;
layout(location = 1) in vec3 in_normal ;
layout(location = 3) in vec2 in_texcoord ;

uniform mat4 pjMatrix ;
uniform mat4 mvMatrix ;
uniform float time ;
uniform mat3 normalMatrix ;

layout(location = 10) in vec3 in_translation ;
layout(location = 11) in vec3 in_scale ;
layout(location = 12) in vec2 in_sincos_rot ;
layout(location = 13) in float noise ;
layout(location = 14) in float in_shade ;

out vec2 texposition ;
out vec3 normal ;
out vec4 frag_position ;
out float shade ;

void main() {
    float s = in_sincos_rot.x ;
    float c = in_sincos_rot.y ;

    shade = in_shade ;
    mat3 rot = mat3( c,0,s,
                     0,1,0,
                    -s,0,c ) ;
    normal =-rot * normalMatrix * in_normal ;
    texposition = in_texcoord ;

    vec3 real_pos1 = (rot * in_position) * in_scale ;

    float val = sin(( (time+noise) * noise) / 100.0) / 30.0 * pow(real_pos1.y,2) ;
    s = sin( val ) ; c = cos( val ) ;
    rot = mat3( c, -s, 0,
                s,  c, 0,
                0,  0, 1 );

    vec3 real_pos = (rot * real_pos1) + in_translation ;
    gl_Position = pjMatrix * (frag_position = mvMatrix * vec4(real_pos,1.0) );
}