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

overlay_wireframe_frag.glsl « shaders « overlay « engines « draw « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bc28d7a8a3617f2abfd4bf029ef7a6e7e1e6b6d1 (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
41
42
43
44

#pragma BLENDER_REQUIRE(common_view_lib.glsl)

void main()
{
  /* Needed only because of wireframe slider.
   * If we could get rid of it would be nice because of performance drain of discard. */
  if (edgeStart.r == -1.0) {
    discard;
  }

#ifndef SELECT_EDGES
  lineOutput = pack_line_data(gl_FragCoord.xy, edgeStart, edgePos);
  fragColor = finalColor;

#  ifdef CUSTOM_DEPTH_BIAS
  vec2 dir = lineOutput.xy * 2.0 - 1.0;
  bool dir_horiz = abs(dir.x) > abs(dir.y);

  vec2 uv = gl_FragCoord.xy * drw_view.viewport_size_inverse;
  float depth_occluder = texture(depthTex, uv).r;
  float depth_min = depth_occluder;
  vec2 texel_uv_size = drw_view.viewport_size_inverse;

  if (dir_horiz) {
    depth_min = min(depth_min, texture(depthTex, uv + vec2(-texel_uv_size.x, 0.0)).r);
    depth_min = min(depth_min, texture(depthTex, uv + vec2(texel_uv_size.x, 0.0)).r);
  }
  else {
    depth_min = min(depth_min, texture(depthTex, uv + vec2(0, -texel_uv_size.y)).r);
    depth_min = min(depth_min, texture(depthTex, uv + vec2(0, texel_uv_size.y)).r);
  }

  float delta = abs(depth_occluder - depth_min);

  if (gl_FragCoord.z < (depth_occluder + delta) && gl_FragCoord.z > depth_occluder) {
    gl_FragDepth = depth_occluder;
  }
  else {
    gl_FragDepth = gl_FragCoord.z;
  }
#  endif
#endif
}