debug_effects.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. #include "servers/rendering/renderer_scene_render.h"
  36. #include "servers/rendering_server.h"
  37. namespace RendererRD {
  38. class DebugEffects {
  39. private:
  40. struct {
  41. RD::VertexFormatID vertex_format;
  42. RID vertex_buffer;
  43. RID vertex_array;
  44. RID index_buffer;
  45. RID index_array;
  46. RID lines_buffer;
  47. RID lines_array;
  48. } frustum;
  49. struct ShadowFrustumPushConstant {
  50. float mvp[16];
  51. float color[4];
  52. };
  53. enum ShadowFrustumPipelines {
  54. SFP_TRANSPARENT,
  55. SFP_WIREFRAME,
  56. SFP_MAX
  57. };
  58. struct {
  59. ShadowFrustumShaderRD shader;
  60. RID shader_version;
  61. PipelineCacheRD pipelines[SFP_MAX];
  62. } shadow_frustum;
  63. struct MotionVectorsPushConstant {
  64. float reprojection_matrix[16];
  65. float resolution[2];
  66. uint32_t force_derive_from_depth;
  67. float pad;
  68. };
  69. struct {
  70. MotionVectorsShaderRD shader;
  71. RID shader_version;
  72. PipelineCacheRD pipeline;
  73. MotionVectorsPushConstant push_constant;
  74. } motion_vectors;
  75. void _create_frustum_arrays();
  76. protected:
  77. public:
  78. DebugEffects();
  79. ~DebugEffects();
  80. 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);
  81. 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);
  82. };
  83. } // namespace RendererRD
  84. #endif // DEBUG_EFFECTS_RD_H