| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "servers/rendering/renderer_scene_render.h" |
| 34 |
#include "servers/rendering/storage/render_scene_data.h" |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
class RenderSceneDataRD : public RenderSceneData { |
| 40 |
GDCLASS(RenderSceneDataRD, RenderSceneData); |
| 41 |
|
| 42 |
public: |
| 43 |
bool calculate_motion_vectors = false; |
| 44 |
|
| 45 |
Transform3D cam_transform; |
| 46 |
Projection cam_projection; |
| 47 |
Vector2 taa_jitter; |
| 48 |
float taa_frame_count = 0.0f; |
| 49 |
uint32_t camera_visible_layers; |
| 50 |
bool cam_orthogonal = false; |
| 51 |
bool cam_frustum = false; |
| 52 |
bool flip_y = false; |
| 53 |
|
| 54 |
|
| 55 |
Transform3D main_cam_transform; |
| 56 |
|
| 57 |
|
| 58 |
uint32_t view_count = 1; |
| 59 |
Vector3 view_eye_offset[RendererSceneRender::MAX_RENDER_VIEWS]; |
| 60 |
Projection view_projection[RendererSceneRender::MAX_RENDER_VIEWS]; |
| 61 |
|
| 62 |
Transform3D prev_cam_transform; |
| 63 |
Projection prev_cam_projection; |
| 64 |
Vector2 prev_taa_jitter; |
| 65 |
Projection prev_view_projection[RendererSceneRender::MAX_RENDER_VIEWS]; |
| 66 |
|
| 67 |
float z_near = 0.0; |
| 68 |
float z_far = 0.0; |
| 69 |
|
| 70 |
float lod_distance_multiplier = 0.0; |
| 71 |
float screen_mesh_lod_threshold = 0.0; |
| 72 |
|
| 73 |
uint32_t directional_light_count = 0; |
| 74 |
float dual_paraboloid_side = 0.0; |
| 75 |
float opaque_prepass_threshold = 0.0; |
| 76 |
bool material_uv2_mode = false; |
| 77 |
float emissive_exposure_normalization = 0.0; |
| 78 |
bool shadow_pass = false; |
| 79 |
|
| 80 |
Size2 shadow_atlas_pixel_size; |
| 81 |
Size2 directional_shadow_pixel_size; |
| 82 |
|
| 83 |
float radiance_pixel_size; |
| 84 |
float radiance_border_size; |
| 85 |
Size2 reflection_atlas_border_size; |
| 86 |
|
| 87 |
float time; |
| 88 |
float time_step; |
| 89 |
|
| 90 |
virtual Transform3D get_cam_transform() const override; |
| 91 |
virtual Projection get_cam_projection() const override; |
| 92 |
|
| 93 |
virtual uint32_t get_view_count() const override; |
| 94 |
virtual Vector3 get_view_eye_offset(uint32_t p_view) const override; |
| 95 |
virtual Projection get_view_projection(uint32_t p_view) const override; |
| 96 |
|
| 97 |
RID create_uniform_buffer(); |
| 98 |
void update_ubo(RID p_uniform_buffer, RS::ViewportDebugDraw p_debug_mode, RID p_env, RID p_reflection_probe_instance, RID p_camera_attributes, bool p_pancake_shadows, const Size2i &p_screen_size, const Size2 &p_viewport_size, const Color &p_default_bg_color, float p_luminance_multiplier, bool p_opaque_render_buffers, bool p_apply_alpha_multiplier); |
| 99 |
virtual RID get_uniform_buffer() const override; |
| 100 |
|
| 101 |
static uint32_t get_uniform_buffer_size_bytes() { return sizeof(UBODATA); } |
| 102 |
|
| 103 |
private: |
| 104 |
RID uniform_buffer; |
| 105 |
|
| 106 |
enum SceneDataFlags { |
| 107 |
SCENE_DATA_FLAGS_USE_AMBIENT_LIGHT = 1 << 0, |
| 108 |
SCENE_DATA_FLAGS_USE_AMBIENT_CUBEMAP = 1 << 1, |
| 109 |
SCENE_DATA_FLAGS_USE_REFLECTION_CUBEMAP = 1 << 2, |
| 110 |
SCENE_DATA_FLAGS_USE_ROUGHNESS_LIMITER = 1 << 3, |
| 111 |
SCENE_DATA_FLAGS_USE_FOG = 1 << 4, |
| 112 |
SCENE_DATA_FLAGS_USE_UV2_MATERIAL = 1 << 5, |
| 113 |
SCENE_DATA_FLAGS_USE_PANCAKE_SHADOWS = 1 << 6, |
| 114 |
SCENE_DATA_FLAGS_IN_SHADOW_PASS = 1 << 7, |
| 115 |
SCENE_DATA_FLAGS_MAX |
| 116 |
}; |
| 117 |
|
| 118 |
|
| 119 |
struct UBO { |
| 120 |
float projection_matrix[16]; |
| 121 |
float inv_projection_matrix[16]; |
| 122 |
float inv_view_matrix[12]; |
| 123 |
float view_matrix[12]; |
| 124 |
|
| 125 |
#ifdef REAL_T_IS_DOUBLE |
| 126 |
float inv_view_precision[4]; |
| 127 |
#endif |
| 128 |
|
| 129 |
float projection_matrix_view[RendererSceneRender::MAX_RENDER_VIEWS][16]; |
| 130 |
float inv_projection_matrix_view[RendererSceneRender::MAX_RENDER_VIEWS][16]; |
| 131 |
float eye_offset[RendererSceneRender::MAX_RENDER_VIEWS][4]; |
| 132 |
|
| 133 |
float main_cam_inv_view_matrix[16]; |
| 134 |
|
| 135 |
float viewport_size[2]; |
| 136 |
float screen_pixel_size[2]; |
| 137 |
|
| 138 |
float directional_penumbra_shadow_kernel[128]; |
| 139 |
float directional_soft_shadow_kernel[128]; |
| 140 |
float penumbra_shadow_kernel[128]; |
| 141 |
float soft_shadow_kernel[128]; |
| 142 |
|
| 143 |
float shadow_atlas_pixel_size[2]; |
| 144 |
float directional_shadow_pixel_size[2]; |
| 145 |
|
| 146 |
float radiance_pixel_size; |
| 147 |
float radiance_border_size; |
| 148 |
float reflection_atlas_border_size[2]; |
| 149 |
|
| 150 |
uint32_t directional_light_count; |
| 151 |
float dual_paraboloid_side; |
| 152 |
float z_far; |
| 153 |
float z_near; |
| 154 |
|
| 155 |
float roughness_limiter_amount; |
| 156 |
float roughness_limiter_limit; |
| 157 |
float opaque_prepass_threshold; |
| 158 |
uint32_t flags; |
| 159 |
|
| 160 |
float radiance_inverse_xform[12]; |
| 161 |
|
| 162 |
float ambient_light_color_energy[4]; |
| 163 |
|
| 164 |
float ambient_color_sky_mix; |
| 165 |
float fog_density; |
| 166 |
float fog_height; |
| 167 |
float fog_height_density; |
| 168 |
|
| 169 |
float fog_depth_curve; |
| 170 |
float fog_depth_begin; |
| 171 |
float fog_depth_end; |
| 172 |
float fog_sun_scatter; |
| 173 |
|
| 174 |
float fog_light_color[3]; |
| 175 |
float fog_aerial_perspective; |
| 176 |
|
| 177 |
float time; |
| 178 |
float taa_frame_count; |
| 179 |
float taa_jitter[2]; |
| 180 |
|
| 181 |
float emissive_exposure_normalization; |
| 182 |
float IBL_exposure_normalization; |
| 183 |
uint32_t camera_visible_layers; |
| 184 |
float pass_alpha_multiplier; |
| 185 |
}; |
| 186 |
|
| 187 |
struct UBODATA { |
| 188 |
UBO ubo; |
| 189 |
UBO prev_ubo; |
| 190 |
}; |
| 191 |
}; |