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
31#ifndef DEBUG_EFFECTS_RD_H
32#define DEBUG_EFFECTS_RD_H
33
34#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
35#include "servers/rendering/renderer_rd/shaders/effects/motion_vectors.glsl.gen.h"
36#include "servers/rendering/renderer_rd/shaders/effects/shadow_frustum.glsl.gen.h"
37#include "servers/rendering/renderer_scene_render.h"
38
39#include "servers/rendering_server.h"
40
41namespace RendererRD {
42
43class DebugEffects {
44private:
45 struct {
46 RD::VertexFormatID vertex_format;
47 RID vertex_buffer;
48 RID vertex_array;
49
50 RID index_buffer;
51 RID index_array;
52
53 RID lines_buffer;
54 RID lines_array;
55 } frustum;
56
57 struct ShadowFrustumPushConstant {
58 float mvp[16];
59 float color[4];
60 };
61
62 enum ShadowFrustumPipelines {
63 SFP_TRANSPARENT,
64 SFP_WIREFRAME,
65 SFP_MAX
66 };
67
68 struct {
69 ShadowFrustumShaderRD shader;
70 RID shader_version;
71 PipelineCacheRD pipelines[SFP_MAX];
72 } shadow_frustum;
73
74 struct MotionVectorsPushConstant {
75 float velocity_resolution[2];
76 float pad[2];
77 };
78
79 struct {
80 MotionVectorsShaderRD shader;
81 RID shader_version;
82 PipelineCacheRD pipeline;
83 MotionVectorsPushConstant push_constant;
84 } motion_vectors;
85
86 void _create_frustum_arrays();
87
88protected:
89public:
90 DebugEffects();
91 ~DebugEffects();
92
93 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);
94 void draw_motion_vectors(RID p_velocity, RID p_dest_fb, Size2i p_velocity_size);
95};
96
97} // namespace RendererRD
98
99#endif // DEBUG_EFFECTS_RD_H
100