medfall

A super great game engine
Log | Files | Refs

text.glsl (643B)


      1 struct VSOut {
      2 	vec4 colour;
      3 	vec2 uv;
      4 };
      5 
      6 layout( std140 ) uniform window {
      7 	uvec2 window_size;
      8 };
      9 
     10 #ifdef VERTEX_SHADER
     11 
     12 in vec3 position;
     13 in vec4 colour;
     14 in vec2 tex_coord0;
     15 
     16 out VSOut v2f;
     17 
     18 void main() {
     19 	vec3 screen_position = vec3(
     20 		( position.x / window_size.x * 2.0 - 1.0 ),
     21 		-( position.y / window_size.y * 2.0 - 1.0 ),
     22 		position.z
     23 	);
     24 	gl_Position = vec4( screen_position, 1.0 );
     25 	v2f.colour = colour;
     26 	v2f.uv = tex_coord0;
     27 }
     28 
     29 #else
     30 
     31 in VSOut v2f;
     32 
     33 uniform sampler2D atlas;
     34 
     35 out vec4 screen_colour;
     36 
     37 void main() {
     38 	float alpha = texture( atlas, v2f.uv ).r;
     39 	screen_colour = vec4( v2f.colour.rgb, v2f.colour.a * alpha );
     40 }
     41 
     42 #endif