1 #ifndef SHADER_gatelq_H
2 #define SHADER_gatelq_H
3 static void shader_gatelq_link(void);
4 static void shader_gatelq_register(void);
5 static struct vg_shader _shader_gatelq
= {
7 .link
= shader_gatelq_link
,
10 .orig_file
= "../../shaders/gate.vs",
12 "layout (location=0) in vec3 a_co;\n"
13 "layout (location=1) in vec3 a_norm;\n"
14 "layout (location=2) in vec2 a_uv;\n"
15 "layout (location=3) in vec4 a_colour;\n"
16 "layout (location=4) in vec4 a_weights;\n"
17 "layout (location=5) in ivec4 a_groups;\n"
21 "uniform mat4x3 uMdl;\n"
29 " vec3 world_pos = uMdl * vec4( a_co, 1.0 );\n"
30 " gl_Position = uPv * vec4(world_pos,1.0);\n"
39 .orig_file
= "../../shaders/gate_lq.fs",
41 "out vec4 FragColor;\n"
43 "uniform float uTime;\n"
44 "uniform vec3 uCam;\n"
45 "uniform vec2 uInvRes;\n"
53 " vec2 ssuv = gl_FragCoord.xy;\n"
54 " float opacity = 1.0-smoothstep(0.4,1.0,aUv.y);\n"
56 " vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n"
57 " float dither = fract( vDither.g / 71.0 ) - 0.5;\n"
59 " if( opacity+dither<0.5 )\n"
62 " FragColor = vec4( 0.0, 1.0, 0.0, 1.0 );\n"
67 static GLuint _uniform_gatelq_uPv
;
68 static GLuint _uniform_gatelq_uMdl
;
69 static GLuint _uniform_gatelq_uTime
;
70 static GLuint _uniform_gatelq_uCam
;
71 static GLuint _uniform_gatelq_uInvRes
;
72 static void shader_gatelq_uPv(m4x4f m
){
73 glUniformMatrix4fv( _uniform_gatelq_uPv
, 1, GL_FALSE
, (float *)m
);
75 static void shader_gatelq_uMdl(m4x3f m
){
76 glUniformMatrix4x3fv( _uniform_gatelq_uMdl
, 1, GL_FALSE
, (float *)m
);
78 static void shader_gatelq_uTime(float f
){
79 glUniform1f( _uniform_gatelq_uTime
, f
);
81 static void shader_gatelq_uCam(v3f v
){
82 glUniform3fv( _uniform_gatelq_uCam
, 1, v
);
84 static void shader_gatelq_uInvRes(v2f v
){
85 glUniform2fv( _uniform_gatelq_uInvRes
, 1, v
);
87 static void shader_gatelq_register(void){
88 vg_shader_register( &_shader_gatelq
);
90 static void shader_gatelq_use(void){ glUseProgram(_shader_gatelq
.id
); }
91 static void shader_gatelq_link(void){
92 _uniform_gatelq_uPv
= glGetUniformLocation( _shader_gatelq
.id
, "uPv" );
93 _uniform_gatelq_uMdl
= glGetUniformLocation( _shader_gatelq
.id
, "uMdl" );
94 _uniform_gatelq_uTime
= glGetUniformLocation( _shader_gatelq
.id
, "uTime" );
95 _uniform_gatelq_uCam
= glGetUniformLocation( _shader_gatelq
.id
, "uCam" );
96 _uniform_gatelq_uInvRes
= glGetUniformLocation( _shader_gatelq
.id
, "uInvRes" );
98 #endif /* SHADER_gatelq_H */