fs_bokeh_dof_debug.sc 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. $input v_texcoord0
  2. /*
  3. * Copyright 2021 elven cache. All rights reserved.
  4. * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
  5. */
  6. #include "../common/common.sh"
  7. #include "parameters.sh"
  8. #include "bokeh_dof.sh"
  9. SAMPLER2D(s_color, 0);
  10. SAMPLER2D(s_depth, 1);
  11. void main()
  12. {
  13. vec2 texCoord = v_texcoord0.xy;
  14. // desaturate color to make tinted color stand out
  15. vec3 color = texture2D(s_color, texCoord).xyz;
  16. color = toGamma(color);
  17. color = vec3_splat(dot(color, vec3(0.33, 0.34, 0.33)));
  18. // get circle of confusion from depth
  19. float depth = texture2D(s_depth, texCoord).x;
  20. float circleOfConfusion = GetCircleOfConfusion(depth, u_focusPoint, u_focusScale);
  21. // apply tint color to debug where blur applied
  22. vec3 tintColor;
  23. if (circleOfConfusion < 0.0)
  24. {
  25. // tint foreground orange
  26. tintColor = vec3(187.0, 61.0, 7.0) / 255.0;
  27. }
  28. else
  29. {
  30. // tint background blue
  31. tintColor = vec3(11.0, 89.0, 138.0) / 255.0;
  32. }
  33. tintColor *= color;
  34. color = mix(color, tintColor, abs(circleOfConfusion));
  35. gl_FragColor = vec4(color, 1.0);
  36. }