~vladh/peony

peony/src_shaders/gui_generic.frag -rw-r--r-- 457 bytes
7fc9922bVlad-Stefan Harbuz changes shaders namespace into class a month ago
                                                                                
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
/*
  Peony Game Engine
  Copyright (C) 2020 Vlad-Stefan Harbuz <vlad@vladh.net>
  All rights reserved.
*/

in BLOCK {
  vec2 tex_coords;
  vec4 color;
} fs_in;

out vec4 frag_color;

uniform sampler2D atlas_texture;

void main() {
  float opacity = 1.0;

  if (fs_in.tex_coords.x > 0.0 && fs_in.tex_coords.y > 0.0) {
    opacity = texture(
      atlas_texture, fs_in.tex_coords
    ).r;
  }

  frag_color = vec4(fs_in.color.rgb, opacity * fs_in.color.a);
}