SHARE
TWEET

debug.glsl

a guest Sep 29th, 2018 168 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [VS]
  2. out vec4 v_debugColor;
  3. out flat float v_debugFlag;
  4. #define debugColor v_debugColor
  5. #define debugFlag v_debugFlag
  6. #include ":_common"
  7.  
  8. [FSPass]
  9. in vec4 v_debugColor;
  10. in flat float v_debugFlag;
  11. vec4 debugColor = v_debugColor;
  12. float debugFlag = v_debugFlag;
  13. #include ":_common"
  14. #include ":_debugExit"
  15.  
  16. [FS]
  17. vec4 debugColor;
  18. float debugFlag;
  19. #include ":_common"
  20. #include ":_debugExit"
  21.  
  22. [VS.enable]
  23. #include ":VS"
  24.  
  25. [FSPass.enable]
  26. #include ":FSPass"
  27.  
  28. [FS.enable]
  29. #include ":FS"
  30.  
  31. [VS.disable]
  32. #include ":_disable"
  33. #include ":VS"
  34.  
  35. [FSPass.disable]
  36. #include ":_disable"
  37. #include ":FSPass"
  38.  
  39. [FS.disable]
  40. #include ":_disable"
  41. #include ":FS"
  42.  
  43. [_disable]
  44. #define DEBUG_DISABLE
  45.  
  46. [_common]
  47. #ifndef DEBUG_DISABLE
  48.  
  49. void setDebugColor(vec4 v) {
  50.     debugFlag = 10.0;
  51.     debugColor = v;
  52. }
  53.  
  54. void debug(bool v)  { setDebugColor(vec4(vec3(v ? 1.0 : 0.0), 1.0)); }
  55. void debug(int v)   { setDebugColor(vec4(vec3(v), 1.0)); }
  56. void debug(float v) { setDebugColor(vec4(vec3(v), 1.0)); }
  57. void debug(vec2 v)  { setDebugColor(vec4(v, 1.0, 1.0)); }
  58. void debug(vec3 v)  { setDebugColor(vec4(v, 1.0)); }
  59. void debug(vec4 v)  { setDebugColor(v); }
  60.  
  61. #define debug255(v) debug(v / 255.0)
  62.  
  63. #else
  64. #define debug(v)
  65. #endif
  66.  
  67. [_debugExit]
  68. #ifndef DEBUG_DISABLE
  69. #define debugExit()                  \
  70.     if (debugFlag >= 1.0) {          \
  71.         gl_FragData[0] = debugColor; \
  72.         return;                      \
  73.     }
  74. #else
  75. #define debugExit()
  76. #endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top