1 #ifndef SHADER_model_gate_H
2 #define SHADER_model_gate_H
3 static void shader_model_gate_link(void);
4 static void shader_model_gate_register(void);
5 static struct vg_shader _shader_model_gate
= {
7 .link
= shader_model_gate_link
,
10 .orig_file
= "shaders/model_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"
17 "uniform mat4x3 uMdl;\n"
25 " vec3 world_pos = uMdl * vec4( a_co, 1.0 );\n"
26 " gl_Position = uPv * vec4(world_pos,1.0);\n"
35 .orig_file
= "shaders/model_gate_lq.fs",
37 "out vec4 FragColor;\n"
39 "uniform float uTime;\n"
40 "uniform vec3 uCam;\n"
41 "uniform vec2 uInvRes;\n"
42 "uniform vec4 uColour;\n"
50 " vec2 ssuv = gl_FragCoord.xy;\n"
51 " float opacity = 1.0-smoothstep(0.0,1.0,aUv.y+uColour.a);\n"
53 " vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n"
54 " float dither = fract( vDither.g / 71.0 ) - 0.5;\n"
56 " if( opacity+dither<0.5 )\n"
59 " FragColor = uColour;\n"
64 static GLuint _uniform_model_gate_uPv
;
65 static GLuint _uniform_model_gate_uMdl
;
66 static GLuint _uniform_model_gate_uTime
;
67 static GLuint _uniform_model_gate_uCam
;
68 static GLuint _uniform_model_gate_uInvRes
;
69 static GLuint _uniform_model_gate_uColour
;
70 static void shader_model_gate_uPv(m4x4f m
){
71 glUniformMatrix4fv(_uniform_model_gate_uPv
,1,GL_FALSE
,(float*)m
);
73 static void shader_model_gate_uMdl(m4x3f m
){
74 glUniformMatrix4x3fv(_uniform_model_gate_uMdl
,1,GL_FALSE
,(float*)m
);
76 static void shader_model_gate_uTime(float f
){
77 glUniform1f(_uniform_model_gate_uTime
,f
);
79 static void shader_model_gate_uCam(v3f v
){
80 glUniform3fv(_uniform_model_gate_uCam
,1,v
);
82 static void shader_model_gate_uInvRes(v2f v
){
83 glUniform2fv(_uniform_model_gate_uInvRes
,1,v
);
85 static void shader_model_gate_uColour(v4f v
){
86 glUniform4fv(_uniform_model_gate_uColour
,1,v
);
88 static void shader_model_gate_register(void){
89 vg_shader_register( &_shader_model_gate
);
91 static void shader_model_gate_use(void){ glUseProgram(_shader_model_gate
.id
); }
92 static void shader_model_gate_link(void){
93 _uniform_model_gate_uPv
= glGetUniformLocation( _shader_model_gate
.id
, "uPv" );
94 _uniform_model_gate_uMdl
= glGetUniformLocation( _shader_model_gate
.id
, "uMdl" );
95 _uniform_model_gate_uTime
= glGetUniformLocation( _shader_model_gate
.id
, "uTime" );
96 _uniform_model_gate_uCam
= glGetUniformLocation( _shader_model_gate
.id
, "uCam" );
97 _uniform_model_gate_uInvRes
= glGetUniformLocation( _shader_model_gate
.id
, "uInvRes" );
98 _uniform_model_gate_uColour
= glGetUniformLocation( _shader_model_gate
.id
, "uColour" );
100 #endif /* SHADER_model_gate_H */