Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gpu_shader_2D_widget_base_frag.glsl « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bdc87baf924c49e8436c51b0c9c53358aac6f0d4 (plain)
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
uniform vec3 checkerColorAndSize;

noperspective in vec4 finalColor;
noperspective in float butCo;
flat in float discardFac;

out vec4 fragColor;

vec4 do_checkerboard()
{
  float size = checkerColorAndSize.z;
  vec2 phase = mod(gl_FragCoord.xy, size * 2.0);

  if ((phase.x > size && phase.y < size) || (phase.x < size && phase.y > size)) {
    return vec4(checkerColorAndSize.xxx, 1.0);
  }
  else {
    return vec4(checkerColorAndSize.yyy, 1.0);
  }
}

void main()
{
  if (min(1.0, -butCo) > discardFac) {
    discard;
  }

  fragColor = finalColor;

  if (butCo > 0.5) {
    vec4 checker = do_checkerboard();
    fragColor = mix(checker, fragColor, fragColor.a);
  }

  if (butCo > 0.0) {
    fragColor.a = 1.0;
  }

  fragColor = blender_srgb_to_framebuffer_space(fragColor);
}