debug_effects.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**************************************************************************/
  2. /* debug_effects.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef DEBUG_EFFECTS_RD_H
  31. #define DEBUG_EFFECTS_RD_H
  32. #include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
  33. #include "servers/rendering/renderer_rd/shaders/effects/motion_vectors.glsl.gen.h"
  34. #include "servers/rendering/renderer_rd/shaders/effects/shadow_frustum.glsl.gen.h"
  35. namespace RendererRD {
  36. class DebugEffects {
  37. private:
  38. struct {
  39. RD::VertexFormatID vertex_format;
  40. RID vertex_buffer;
  41. RID vertex_array;
  42. RID index_buffer;
  43. RID index_array;
  44. RID lines_buffer;
  45. RID lines_array;
  46. } frustum;
  47. struct ShadowFrustumPushConstant {
  48. float mvp[16];
  49. float color[4];
  50. };
  51. enum ShadowFrustumPipelines {
  52. SFP_TRANSPARENT,
  53. SFP_WIREFRAME,
  54. SFP_MAX
  55. };
  56. struct {
  57. ShadowFrustumShaderRD shader;
  58. RID shader_version;
  59. PipelineCacheRD pipelines[SFP_MAX];
  60. } shadow_frustum;
  61. struct MotionVectorsPushConstant {
  62. float reprojection_matrix[16];
  63. float resolution[2];
  64. uint32_t force_derive_from_depth;
  65. float pad;
  66. };
  67. struct {
  68. MotionVectorsShaderRD shader;
  69. RID shader_version;
  70. PipelineCacheRD pipeline;
  71. MotionVectorsPushConstant push_constant;
  72. } motion_vectors;
  73. void _create_frustum_arrays();
  74. protected:
  75. public:
  76. DebugEffects();
  77. ~DebugEffects();
  78. void draw_shadow_frustum(RID p_light, const Projection &p_cam_projection, const Transform3D &p_cam_transform, RID p_dest_fb, const Rect2 p_rect);
  79. void draw_motion_vectors(RID p_velocity, RID p_depth, RID p_dest_fb, const Projection &p_current_projection, const Transform3D &p_current_transform, const Projection &p_previous_projection, const Transform3D &p_previous_transform, Size2i p_resolution);
  80. };
  81. } // namespace RendererRD
  82. #endif // DEBUG_EFFECTS_RD_H