2019-11-05 11:01:00 +00:00
/*************************************************************************/
2020-12-04 18:26:24 +00:00
/* renderer_scene_render_rd.h */
2019-11-05 11:01:00 +00:00
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
2022-01-03 20:27:34 +00:00
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
2019-11-05 11:01:00 +00:00
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
2022-07-23 21:41:51 +00:00
# ifndef RENDERER_SCENE_RENDER_RD_H
# define RENDERER_SCENE_RENDER_RD_H
2019-08-18 22:40:52 +00:00
2020-11-07 22:33:38 +00:00
# include "core/templates/local_vector.h"
# include "core/templates/rid_owner.h"
2020-12-04 18:26:24 +00:00
# include "servers/rendering/renderer_compositor.h"
2021-01-17 16:25:38 +00:00
# include "servers/rendering/renderer_rd/cluster_builder_rd.h"
2022-04-29 07:10:54 +00:00
# include "servers/rendering/renderer_rd/effects/bokeh_dof.h"
# include "servers/rendering/renderer_rd/effects/copy_effects.h"
2022-08-04 08:40:39 +00:00
# include "servers/rendering/renderer_rd/effects/fsr.h"
2022-06-28 09:10:36 +00:00
# include "servers/rendering/renderer_rd/effects/ss_effects.h"
2022-04-27 03:42:50 +00:00
# include "servers/rendering/renderer_rd/effects/tone_mapper.h"
2022-02-11 11:33:54 +00:00
# include "servers/rendering/renderer_rd/effects/vrs.h"
2022-07-19 04:17:58 +00:00
# include "servers/rendering/renderer_rd/environment/fog.h"
2022-05-20 02:52:19 +00:00
# include "servers/rendering/renderer_rd/environment/gi.h"
2022-07-19 04:17:58 +00:00
# include "servers/rendering/renderer_rd/environment/sky.h"
2022-08-04 08:40:39 +00:00
# include "servers/rendering/renderer_rd/framebuffer_cache_rd.h"
# include "servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h"
2021-07-02 23:14:19 +00:00
# include "servers/rendering/renderer_scene.h"
2020-12-04 18:26:24 +00:00
# include "servers/rendering/renderer_scene_render.h"
2020-03-27 18:21:27 +00:00
# include "servers/rendering/rendering_device.h"
2019-08-26 20:43:58 +00:00
2021-05-05 05:41:12 +00:00
struct RenderDataRD {
2022-08-04 08:40:39 +00:00
Ref < RenderSceneBuffersRD > render_buffers ;
2021-05-05 05:41:12 +00:00
2022-05-02 14:28:25 +00:00
Transform3D cam_transform ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
Projection cam_projection ;
2022-04-04 14:10:22 +00:00
Vector2 taa_jitter ;
2022-04-26 19:49:44 +00:00
bool cam_orthogonal = false ;
2021-05-05 05:41:12 +00:00
2021-05-07 13:19:04 +00:00
// For stereo rendering
uint32_t view_count = 1 ;
2022-06-16 12:02:18 +00:00
Vector3 view_eye_offset [ RendererSceneRender : : MAX_RENDER_VIEWS ] ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
Projection view_projection [ RendererSceneRender : : MAX_RENDER_VIEWS ] ;
2021-05-07 13:19:04 +00:00
2022-04-04 14:10:22 +00:00
Transform3D prev_cam_transform ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
Projection prev_cam_projection ;
2022-04-04 14:10:22 +00:00
Vector2 prev_taa_jitter ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
Projection prev_view_projection [ RendererSceneRender : : MAX_RENDER_VIEWS ] ;
2022-04-04 14:10:22 +00:00
2021-05-05 05:41:12 +00:00
float z_near = 0.0 ;
float z_far = 0.0 ;
2022-07-23 14:01:53 +00:00
const PagedArray < RenderGeometryInstance * > * instances = nullptr ;
2021-05-05 05:41:12 +00:00
const PagedArray < RID > * lights = nullptr ;
const PagedArray < RID > * reflection_probes = nullptr ;
2021-06-04 22:47:26 +00:00
const PagedArray < RID > * voxel_gi_instances = nullptr ;
2021-05-05 05:41:12 +00:00
const PagedArray < RID > * decals = nullptr ;
const PagedArray < RID > * lightmaps = nullptr ;
2021-10-03 11:28:55 +00:00
const PagedArray < RID > * fog_volumes = nullptr ;
2022-05-02 14:28:25 +00:00
RID environment ;
2022-07-31 23:20:24 +00:00
RID camera_attributes ;
2022-05-02 14:28:25 +00:00
RID shadow_atlas ;
RID reflection_atlas ;
RID reflection_probe ;
2021-05-05 05:41:12 +00:00
int reflection_probe_pass = 0 ;
float lod_distance_multiplier = 0.0 ;
2022-05-02 14:28:25 +00:00
Plane lod_camera_plane ;
2021-12-28 23:10:41 +00:00
float screen_mesh_lod_threshold = 0.0 ;
2021-05-05 05:41:12 +00:00
2022-05-02 14:28:25 +00:00
RID cluster_buffer ;
2021-05-05 05:41:12 +00:00
uint32_t cluster_size = 0 ;
uint32_t cluster_max_elements = 0 ;
uint32_t directional_light_count = 0 ;
2021-07-12 23:32:05 +00:00
bool directional_light_soft_shadows = false ;
2021-07-02 23:14:19 +00:00
RendererScene : : RenderInfo * render_info = nullptr ;
2021-05-05 05:41:12 +00:00
} ;
2020-12-04 18:26:24 +00:00
class RendererSceneRenderRD : public RendererSceneRender {
2022-07-19 04:17:58 +00:00
friend RendererRD : : SkyRD ;
2022-05-20 02:52:19 +00:00
friend RendererRD : : GI ;
2021-02-13 12:08:08 +00:00
2019-08-18 22:40:52 +00:00
protected :
2022-04-29 07:10:54 +00:00
RendererRD : : BokehDOF * bokeh_dof = nullptr ;
RendererRD : : CopyEffects * copy_effects = nullptr ;
2022-04-27 03:42:50 +00:00
RendererRD : : ToneMapper * tone_mapper = nullptr ;
2022-08-04 08:40:39 +00:00
RendererRD : : FSR * fsr = nullptr ;
2022-02-11 11:33:54 +00:00
RendererRD : : VRS * vrs = nullptr ;
2022-05-02 14:28:25 +00:00
double time = 0.0 ;
double time_step = 0.0 ;
2020-03-20 00:32:19 +00:00
2022-08-04 08:40:39 +00:00
virtual void setup_render_buffer_data ( Ref < RenderSceneBuffersRD > p_render_buffers ) = 0 ;
2019-08-18 22:40:52 +00:00
2022-07-31 23:20:24 +00:00
void _setup_lights ( RenderDataRD * p_render_data , const PagedArray < RID > & p_lights , const Transform3D & p_camera_transform , RID p_shadow_atlas , bool p_using_shadows , uint32_t & r_directional_light_count , uint32_t & r_positional_light_count , bool & r_directional_light_soft_shadows ) ;
2020-10-17 05:08:21 +00:00
void _setup_decals ( const PagedArray < RID > & p_decals , const Transform3D & p_camera_inverse_xform ) ;
2022-07-31 23:20:24 +00:00
void _setup_reflections ( RenderDataRD * p_render_data , const PagedArray < RID > & p_reflections , const Transform3D & p_camera_inverse_transform , RID p_environment ) ;
2020-12-23 16:52:58 +00:00
2021-05-05 05:41:12 +00:00
virtual void _render_scene ( RenderDataRD * p_render_data , const Color & p_default_color ) = 0 ;
2021-02-02 19:51:36 +00:00
virtual void _render_shadow_begin ( ) = 0 ;
2022-07-23 14:01:53 +00:00
virtual void _render_shadow_append ( RID p_framebuffer , const PagedArray < RenderGeometryInstance * > & p_instances , const Projection & p_projection , const Transform3D & p_transform , float p_zfar , float p_bias , float p_normal_bias , bool p_use_dp , bool p_use_dp_flip , bool p_use_pancake , const Plane & p_camera_plane = Plane ( ) , float p_lod_distance_multiplier = 0.0 , float p_screen_mesh_lod_threshold = 0.0 , const Rect2i & p_rect = Rect2i ( ) , bool p_flip_y = false , bool p_clear_region = true , bool p_begin = true , bool p_end = true , RendererScene : : RenderInfo * p_render_info = nullptr ) = 0 ;
2021-02-02 19:51:36 +00:00
virtual void _render_shadow_process ( ) = 0 ;
virtual void _render_shadow_end ( uint32_t p_barrier = RD : : BARRIER_MASK_ALL ) = 0 ;
2022-07-31 23:20:24 +00:00
virtual void _render_material ( const Transform3D & p_cam_transform , const Projection & p_cam_projection , bool p_cam_orthogonal , const PagedArray < RenderGeometryInstance * > & p_instances , RID p_framebuffer , const Rect2i & p_region , float p_exposure_normalization ) = 0 ;
2022-07-23 14:01:53 +00:00
virtual void _render_uv2 ( const PagedArray < RenderGeometryInstance * > & p_instances , RID p_framebuffer , const Rect2i & p_region ) = 0 ;
2022-08-04 08:40:39 +00:00
virtual void _render_sdfgi ( Ref < RenderSceneBuffersRD > p_render_buffers , const Vector3i & p_from , const Vector3i & p_size , const AABB & p_bounds , const PagedArray < RenderGeometryInstance * > & p_instances , const RID & p_albedo_texture , const RID & p_emission_texture , const RID & p_emission_aniso_texture , const RID & p_geom_facing_texture , float p_exposure_normalization ) = 0 ;
2022-07-23 14:01:53 +00:00
virtual void _render_particle_collider_heightfield ( RID p_fb , const Transform3D & p_cam_transform , const Projection & p_cam_projection , const PagedArray < RenderGeometryInstance * > & p_instances ) = 0 ;
2019-08-18 22:40:52 +00:00
2022-08-04 08:40:39 +00:00
void _debug_sdfgi_probes ( Ref < RenderSceneBuffersRD > p_render_buffers , RID p_framebuffer , uint32_t p_view_count , const Projection * p_camera_with_transforms , bool p_will_continue_color , bool p_will_continue_depth ) ;
void _debug_draw_cluster ( Ref < RenderSceneBuffersRD > p_render_buffers ) ;
2020-01-10 00:40:26 +00:00
2020-01-25 10:18:55 +00:00
virtual void _base_uniforms_changed ( ) = 0 ;
2022-08-04 08:40:39 +00:00
virtual RID _render_buffers_get_normal_texture ( Ref < RenderSceneBuffersRD > p_render_buffers ) = 0 ;
virtual RID _render_buffers_get_velocity_texture ( Ref < RenderSceneBuffersRD > p_render_buffers ) = 0 ;
2020-01-25 10:18:55 +00:00
2022-08-04 08:40:39 +00:00
void _process_ssao ( Ref < RenderSceneBuffersRD > p_render_buffers , RID p_environment , RID p_normal_buffer , const Projection & p_projection ) ;
void _process_ssr ( Ref < RenderSceneBuffersRD > p_render_buffers , RID p_dest_framebuffer , const RID * p_normal_buffer_slices , RID p_specular_buffer , const RID * p_metallic_slices , const Color & p_metallic_mask , RID p_environment , const Projection * p_projections , const Vector3 * p_eye_offsets , bool p_use_additive ) ;
void _process_sss ( Ref < RenderSceneBuffersRD > p_render_buffers , const Projection & p_camera ) ;
void _process_ssil ( Ref < RenderSceneBuffersRD > p_render_buffers , RID p_environment , RID p_normal_buffer , const Projection & p_projection , const Transform3D & p_transform ) ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
2022-08-04 08:40:39 +00:00
void _copy_framebuffer_to_ssil ( Ref < RenderSceneBuffersRD > p_render_buffers ) ;
2020-01-25 10:18:55 +00:00
2021-05-05 05:41:12 +00:00
bool _needs_post_prepass_render ( RenderDataRD * p_render_data , bool p_use_gi ) ;
void _post_prepass_render ( RenderDataRD * p_render_data , bool p_use_gi ) ;
void _pre_resolve_render ( RenderDataRD * p_render_data , bool p_use_gi ) ;
2021-02-02 19:51:36 +00:00
2022-08-04 08:40:39 +00:00
void _pre_opaque_render ( RenderDataRD * p_render_data , bool p_use_ssao , bool p_use_ssil , bool p_use_gi , const RID * p_normal_roughness_slices , RID p_voxel_gi_buffer ) ;
2021-02-02 19:51:36 +00:00
2021-08-11 11:00:12 +00:00
void _render_buffers_copy_screen_texture ( const RenderDataRD * p_render_data ) ;
void _render_buffers_copy_depth_texture ( const RenderDataRD * p_render_data ) ;
2021-06-26 10:49:25 +00:00
void _render_buffers_post_process_and_tonemap ( const RenderDataRD * p_render_data ) ;
void _post_process_subpass ( RID p_source_texture , RID p_framebuffer , const RenderDataRD * p_render_data ) ;
void _disable_clear_request ( const RenderDataRD * p_render_data ) ;
2020-12-23 16:52:58 +00:00
// needed for a single argument calls (material and uv2)
2022-07-23 14:01:53 +00:00
PagedArrayPool < RenderGeometryInstance * > cull_argument_pool ;
PagedArray < RenderGeometryInstance * > cull_argument ; //need this to exist
2021-02-13 12:08:08 +00:00
2022-06-28 09:10:36 +00:00
RendererRD : : SSEffects * ss_effects = nullptr ;
2022-05-20 02:52:19 +00:00
RendererRD : : GI gi ;
2022-07-19 04:17:58 +00:00
RendererRD : : SkyRD sky ;
2021-02-13 12:08:08 +00:00
2021-07-15 20:06:33 +00:00
//used for mobile renderer mostly
typedef int32_t ForwardID ;
enum ForwardIDType {
FORWARD_ID_TYPE_OMNI_LIGHT ,
FORWARD_ID_TYPE_SPOT_LIGHT ,
FORWARD_ID_TYPE_REFLECTION_PROBE ,
FORWARD_ID_TYPE_DECAL ,
FORWARD_ID_MAX ,
} ;
virtual ForwardID _allocate_forward_id ( ForwardIDType p_type ) { return - 1 ; }
virtual void _free_forward_id ( ForwardIDType p_type , ForwardID p_id ) { }
virtual void _map_forward_id ( ForwardIDType p_type , ForwardID p_id , uint32_t p_index ) { }
virtual bool _uses_forward_ids ( ) const { return false ; }
2021-07-19 19:41:55 +00:00
virtual void _update_shader_quality_settings ( ) { }
2019-08-18 22:40:52 +00:00
private :
2020-03-27 18:21:27 +00:00
RS : : ViewportDebugDraw debug_draw = RS : : VIEWPORT_DEBUG_DRAW_DISABLED ;
2020-12-04 18:26:24 +00:00
static RendererSceneRenderRD * singleton ;
2020-01-10 00:40:26 +00:00
2019-09-09 20:50:51 +00:00
/* REFLECTION ATLAS */
2019-09-07 01:51:27 +00:00
2019-09-09 20:50:51 +00:00
struct ReflectionAtlas {
int count = 0 ;
int size = 0 ;
2019-09-07 01:51:27 +00:00
2019-09-09 20:50:51 +00:00
RID reflection ;
2019-09-07 01:51:27 +00:00
RID depth_buffer ;
2019-10-03 20:39:08 +00:00
RID depth_fb ;
2019-09-07 01:51:27 +00:00
2019-09-09 20:50:51 +00:00
struct Reflection {
RID owner ;
2022-07-19 04:17:58 +00:00
RendererRD : : SkyRD : : ReflectionData data ;
2019-09-09 20:50:51 +00:00
RID fbs [ 6 ] ;
} ;
Vector < Reflection > reflections ;
2021-01-17 16:25:38 +00:00
ClusterBuilderRD * cluster_builder = nullptr ;
2019-09-09 20:50:51 +00:00
} ;
2020-12-17 18:56:59 +00:00
mutable RID_Owner < ReflectionAtlas > reflection_atlas_owner ;
2019-09-09 20:50:51 +00:00
/* REFLECTION PROBE INSTANCE */
struct ReflectionProbeInstance {
RID probe ;
int atlas_index = - 1 ;
RID atlas ;
2019-09-07 01:51:27 +00:00
bool dirty = true ;
bool rendering = false ;
2020-03-01 01:16:50 +00:00
int processing_layer = 1 ;
2019-09-07 01:51:27 +00:00
int processing_side = 0 ;
2019-09-09 20:50:51 +00:00
uint32_t render_step = 0 ;
uint64_t last_pass = 0 ;
2021-03-10 11:23:55 +00:00
uint32_t cull_mask = 0 ;
2019-09-07 01:51:27 +00:00
2021-07-15 20:06:33 +00:00
ForwardID forward_id = - 1 ;
2020-10-17 05:08:21 +00:00
Transform3D transform ;
2019-09-07 01:51:27 +00:00
} ;
mutable RID_Owner < ReflectionProbeInstance > reflection_probe_instance_owner ;
2020-08-19 13:38:24 +00:00
/* DECAL INSTANCE */
2020-04-14 03:05:21 +00:00
struct DecalInstance {
RID decal ;
2020-10-17 05:08:21 +00:00
Transform3D transform ;
2022-05-02 14:28:25 +00:00
uint32_t cull_mask = 0 ;
2021-07-15 20:06:33 +00:00
ForwardID forward_id = - 1 ;
2020-04-14 03:05:21 +00:00
} ;
mutable RID_Owner < DecalInstance > decal_instance_owner ;
2020-12-31 12:42:56 +00:00
/* LIGHTMAP INSTANCE */
struct LightmapInstance {
RID lightmap ;
2020-10-17 05:08:21 +00:00
Transform3D transform ;
2020-12-31 12:42:56 +00:00
} ;
mutable RID_Owner < LightmapInstance > lightmap_instance_owner ;
2019-09-07 01:51:27 +00:00
/* SHADOW ATLAS */
2020-08-13 01:21:01 +00:00
struct ShadowShrinkStage {
RID texture ;
RID filter_texture ;
2022-05-02 14:28:25 +00:00
uint32_t size = 0 ;
2020-08-13 01:21:01 +00:00
} ;
2019-09-07 01:51:27 +00:00
struct ShadowAtlas {
enum {
QUADRANT_SHIFT = 27 ,
2021-08-04 15:18:06 +00:00
OMNI_LIGHT_FLAG = 1 < < 26 ,
SHADOW_INDEX_MASK = OMNI_LIGHT_FLAG - 1 ,
2019-09-07 01:51:27 +00:00
SHADOW_INVALID = 0xFFFFFFFF
} ;
struct Quadrant {
2022-05-02 14:28:25 +00:00
uint32_t subdivision = 0 ;
2019-09-07 01:51:27 +00:00
struct Shadow {
RID owner ;
2022-05-02 14:28:25 +00:00
uint64_t version = 0 ;
uint64_t fog_version = 0 ; // used for fog
uint64_t alloc_tick = 0 ;
Shadow ( ) { }
2019-09-07 01:51:27 +00:00
} ;
Vector < Shadow > shadows ;
2022-05-02 14:28:25 +00:00
Quadrant ( ) { }
2019-09-07 01:51:27 +00:00
} quadrants [ 4 ] ;
int size_order [ 4 ] = { 0 , 1 , 2 , 3 } ;
uint32_t smallest_subdiv = 0 ;
int size = 0 ;
2022-02-04 15:41:08 +00:00
bool use_16_bits = true ;
2019-09-07 01:51:27 +00:00
RID depth ;
RID fb ; //for copying
2022-05-13 13:04:37 +00:00
HashMap < RID , uint32_t > shadow_owners ;
2019-09-07 01:51:27 +00:00
} ;
RID_Owner < ShadowAtlas > shadow_atlas_owner ;
2021-01-24 19:00:20 +00:00
void _update_shadow_atlas ( ShadowAtlas * shadow_atlas ) ;
2021-08-04 15:18:06 +00:00
void _shadow_atlas_invalidate_shadow ( RendererSceneRenderRD : : ShadowAtlas : : Quadrant : : Shadow * p_shadow , RID p_atlas , RendererSceneRenderRD : : ShadowAtlas * p_shadow_atlas , uint32_t p_quadrant , uint32_t p_shadow_idx ) ;
2019-09-07 01:51:27 +00:00
bool _shadow_atlas_find_shadow ( ShadowAtlas * shadow_atlas , int * p_in_quadrants , int p_quadrant_count , int p_current_subdiv , uint64_t p_tick , int & r_quadrant , int & r_shadow ) ;
2021-08-04 15:18:06 +00:00
bool _shadow_atlas_find_omni_shadows ( ShadowAtlas * shadow_atlas , int * p_in_quadrants , int p_quadrant_count , int p_current_subdiv , uint64_t p_tick , int & r_quadrant , int & r_shadow ) ;
2019-09-07 01:51:27 +00:00
2020-04-10 09:30:36 +00:00
RS : : ShadowQuality shadows_quality = RS : : SHADOW_QUALITY_MAX ; //So it always updates when first set
RS : : ShadowQuality directional_shadow_quality = RS : : SHADOW_QUALITY_MAX ;
float shadows_quality_radius = 1.0 ;
float directional_shadow_quality_radius = 1.0 ;
2022-04-04 13:06:57 +00:00
float * directional_penumbra_shadow_kernel = nullptr ;
float * directional_soft_shadow_kernel = nullptr ;
float * penumbra_shadow_kernel = nullptr ;
float * soft_shadow_kernel = nullptr ;
2020-04-10 09:30:36 +00:00
int directional_penumbra_shadow_samples = 0 ;
int directional_soft_shadow_samples = 0 ;
int penumbra_shadow_samples = 0 ;
int soft_shadow_samples = 0 ;
2021-07-19 19:41:55 +00:00
RS : : DecalFilter decals_filter = RS : : DECAL_FILTER_LINEAR_MIPMAPS ;
RS : : LightProjectorFilter light_projectors_filter = RS : : LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS ;
2020-04-08 01:51:52 +00:00
2019-09-07 01:51:27 +00:00
/* DIRECTIONAL SHADOW */
struct DirectionalShadow {
RID depth ;
2021-01-24 19:00:20 +00:00
RID fb ; //when renderign direct
2019-09-07 01:51:27 +00:00
int light_count = 0 ;
int size = 0 ;
2022-02-04 15:41:08 +00:00
bool use_16_bits = true ;
2019-09-07 01:51:27 +00:00
int current_light = 0 ;
} directional_shadow ;
2021-01-24 19:00:20 +00:00
void _update_directional_shadow_atlas ( ) ;
2019-09-07 01:51:27 +00:00
/* SHADOW CUBEMAPS */
struct ShadowCubemap {
RID cubemap ;
RID side_fb [ 6 ] ;
} ;
2022-05-13 13:04:37 +00:00
HashMap < int , ShadowCubemap > shadow_cubemaps ;
2019-09-07 01:51:27 +00:00
ShadowCubemap * _get_shadow_cubemap ( int p_size ) ;
void _create_shadow_cubemaps ( ) ;
/* LIGHT INSTANCE */
struct LightInstance {
struct ShadowTransform {
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
Projection camera ;
2020-10-17 05:08:21 +00:00
Transform3D transform ;
2019-09-07 01:51:27 +00:00
float farplane ;
float split ;
float bias_scale ;
2020-04-08 01:51:52 +00:00
float shadow_texel_size ;
2020-04-09 18:11:15 +00:00
float range_begin ;
2019-09-07 17:38:17 +00:00
Rect2 atlas_rect ;
2020-04-09 18:11:15 +00:00
Vector2 uv_scale ;
2019-09-07 01:51:27 +00:00
} ;
2020-04-01 17:29:35 +00:00
RS : : LightType light_type = RS : : LIGHT_DIRECTIONAL ;
2019-09-07 01:51:27 +00:00
2021-02-02 19:51:36 +00:00
ShadowTransform shadow_transform [ 6 ] ;
2019-09-07 01:51:27 +00:00
2020-06-25 13:33:28 +00:00
AABB aabb ;
2019-09-07 01:51:27 +00:00
RID self ;
RID light ;
2020-10-17 05:08:21 +00:00
Transform3D transform ;
2019-09-07 01:51:27 +00:00
Vector3 light_vector ;
Vector3 spot_vector ;
2020-04-01 17:29:35 +00:00
float linear_att = 0.0 ;
2019-09-07 01:51:27 +00:00
uint64_t shadow_pass = 0 ;
uint64_t last_scene_pass = 0 ;
uint64_t last_scene_shadow_pass = 0 ;
uint64_t last_pass = 0 ;
2021-03-10 11:23:55 +00:00
uint32_t cull_mask = 0 ;
2019-09-07 01:51:27 +00:00
uint32_t light_directional_index = 0 ;
Rect2 directional_rect ;
2022-05-19 15:00:06 +00:00
HashSet < RID > shadow_atlases ; //shadow atlases where this light is registered
2019-09-07 01:51:27 +00:00
2021-07-15 20:06:33 +00:00
ForwardID forward_id = - 1 ;
2019-09-07 01:51:27 +00:00
LightInstance ( ) { }
} ;
mutable RID_Owner < LightInstance > light_instance_owner ;
/* ENVIRONMENT */
2020-03-27 18:21:27 +00:00
RS : : EnvironmentSSAOQuality ssao_quality = RS : : ENV_SSAO_QUALITY_MEDIUM ;
2020-10-18 22:27:51 +00:00
bool ssao_half_size = false ;
2020-12-08 05:37:09 +00:00
float ssao_adaptive_target = 0.5 ;
int ssao_blur_passes = 2 ;
float ssao_fadeout_from = 50.0 ;
float ssao_fadeout_to = 300.0 ;
2021-08-03 07:07:32 +00:00
RS : : EnvironmentSSILQuality ssil_quality = RS : : ENV_SSIL_QUALITY_MEDIUM ;
bool ssil_half_size = false ;
bool ssil_using_half_size = false ;
float ssil_adaptive_target = 0.5 ;
int ssil_blur_passes = 4 ;
float ssil_fadeout_from = 50.0 ;
float ssil_fadeout_to = 300.0 ;
2020-03-30 13:46:03 +00:00
bool glow_bicubic_upscale = false ;
2020-09-01 06:04:45 +00:00
bool glow_high_quality = false ;
2022-02-28 00:06:26 +00:00
RS : : EnvironmentSSRRoughnessQuality ssr_roughness_quality = RS : : ENV_SSR_ROUGHNESS_QUALITY_LOW ;
2020-01-25 10:18:55 +00:00
2020-04-04 02:42:26 +00:00
RS : : SubSurfaceScatteringQuality sss_quality = RS : : SUB_SURFACE_SCATTERING_QUALITY_MEDIUM ;
float sss_scale = 0.05 ;
float sss_depth_scale = 0.01 ;
2020-01-16 00:23:21 +00:00
2022-07-31 23:20:24 +00:00
bool use_physical_light_units = false ;
2020-01-13 18:37:24 +00:00
2022-08-04 08:40:39 +00:00
/* Cluster builder */
2019-09-07 01:51:27 +00:00
2021-01-17 16:25:38 +00:00
ClusterBuilderSharedDataRD cluster_builder_shared ;
ClusterBuilderRD * current_cluster_builder = nullptr ;
2022-08-04 08:40:39 +00:00
/* RENDER BUFFERS */
2020-04-02 02:24:52 +00:00
2022-08-04 08:40:39 +00:00
void _allocate_luminance_textures ( Ref < RenderSceneBuffersRD > rb ) ;
2020-06-25 13:33:28 +00:00
2022-08-04 08:40:39 +00:00
void _render_buffers_debug_draw ( Ref < RenderSceneBuffersRD > p_render_buffers , RID p_shadow_atlas , RID p_occlusion_buffer ) ;
2019-08-18 22:40:52 +00:00
2020-06-25 13:33:28 +00:00
/* GI */
2020-01-26 23:09:40 +00:00
bool screen_space_roughness_limiter = false ;
2020-06-25 13:33:28 +00:00
float screen_space_roughness_limiter_amount = 0.25 ;
float screen_space_roughness_limiter_limit = 0.18 ;
2020-01-26 23:09:40 +00:00
2020-07-22 23:39:09 +00:00
/* Cluster */
struct Cluster {
/* Scene State UBO */
2021-03-10 11:23:55 +00:00
// !BAS! Most data here is not just used by our clustering logic but also by other lighting implementations. Maybe rename this struct to something more appropriate
2021-01-08 16:03:09 +00:00
enum {
REFLECTION_AMBIENT_DISABLED = 0 ,
REFLECTION_AMBIENT_ENVIRONMENT = 1 ,
REFLECTION_AMBIENT_COLOR = 2 ,
} ;
struct ReflectionData {
2020-07-22 23:39:09 +00:00
float box_extents [ 3 ] ;
float index ;
float box_offset [ 3 ] ;
uint32_t mask ;
float ambient [ 3 ] ; // ambient color,
2021-01-08 16:03:09 +00:00
float intensity ;
2021-04-20 13:59:46 +00:00
uint32_t exterior ;
uint32_t box_project ;
2020-07-22 23:39:09 +00:00
uint32_t ambient_mode ;
2022-07-31 23:20:24 +00:00
float exposure_normalization ;
2020-07-22 23:39:09 +00:00
float local_matrix [ 16 ] ; // up to here for spot and omni, rest is for directional
} ;
struct LightData {
float position [ 3 ] ;
float inv_radius ;
2021-08-04 15:18:06 +00:00
float direction [ 3 ] ; // in omni, x and y are used for dual paraboloid offset
2020-07-22 23:39:09 +00:00
float size ;
2021-01-08 16:03:09 +00:00
float color [ 3 ] ;
float attenuation ;
2021-02-06 20:39:08 +00:00
float inv_spot_attenuation ;
float cos_spot_angle ;
2021-01-08 16:03:09 +00:00
float specular_amount ;
2022-06-10 10:47:06 +00:00
float shadow_opacity ;
2021-01-08 16:03:09 +00:00
2020-07-22 23:39:09 +00:00
float atlas_rect [ 4 ] ; // in omni, used for atlas uv, in spot, used for projector uv
float shadow_matrix [ 16 ] ;
float shadow_bias ;
float shadow_normal_bias ;
float transmittance_bias ;
float soft_shadow_size ;
float soft_shadow_scale ;
uint32_t mask ;
2021-07-09 08:28:33 +00:00
float volumetric_fog_energy ;
2021-04-25 21:36:39 +00:00
uint32_t bake_mode ;
2020-07-22 23:39:09 +00:00
float projector_rect [ 4 ] ;
} ;
struct DirectionalLightData {
float direction [ 3 ] ;
float energy ;
float color [ 3 ] ;
float size ;
float specular ;
uint32_t mask ;
float softshadow_angle ;
float soft_shadow_scale ;
uint32_t blend_splits ;
2022-06-10 10:47:06 +00:00
float shadow_opacity ;
2020-07-22 23:39:09 +00:00
float fade_from ;
float fade_to ;
2021-04-25 21:36:39 +00:00
uint32_t pad [ 2 ] ;
uint32_t bake_mode ;
2021-07-09 08:28:33 +00:00
float volumetric_fog_energy ;
2020-07-22 23:39:09 +00:00
float shadow_bias [ 4 ] ;
float shadow_normal_bias [ 4 ] ;
float shadow_transmittance_bias [ 4 ] ;
2020-08-13 01:21:01 +00:00
float shadow_z_range [ 4 ] ;
2020-07-22 23:39:09 +00:00
float shadow_range_begin [ 4 ] ;
float shadow_split_offsets [ 4 ] ;
float shadow_matrices [ 4 ] [ 16 ] ;
float uv_scale1 [ 2 ] ;
float uv_scale2 [ 2 ] ;
float uv_scale3 [ 2 ] ;
float uv_scale4 [ 2 ] ;
} ;
struct DecalData {
float xform [ 16 ] ;
float inv_extents [ 3 ] ;
float albedo_mix ;
float albedo_rect [ 4 ] ;
float normal_rect [ 4 ] ;
float orm_rect [ 4 ] ;
float emission_rect [ 4 ] ;
float modulate [ 4 ] ;
float emission_energy ;
uint32_t mask ;
float upper_fade ;
float lower_fade ;
float normal_xform [ 12 ] ;
float normal [ 3 ] ;
float normal_fade ;
} ;
2021-01-17 16:25:38 +00:00
template < class T >
struct InstanceSort {
float depth ;
2022-04-04 13:06:57 +00:00
T * instance = nullptr ;
2021-01-17 16:25:38 +00:00
bool operator < ( const InstanceSort & p_sort ) const {
return depth < p_sort . depth ;
}
} ;
2022-04-04 13:06:57 +00:00
ReflectionData * reflections = nullptr ;
2021-01-17 16:25:38 +00:00
InstanceSort < ReflectionProbeInstance > * reflection_sort ;
2020-07-22 23:39:09 +00:00
uint32_t max_reflections ;
RID reflection_buffer ;
uint32_t max_reflection_probes_per_instance ;
2021-01-17 16:25:38 +00:00
uint32_t reflection_count = 0 ;
2020-07-22 23:39:09 +00:00
2022-04-04 13:06:57 +00:00
DecalData * decals = nullptr ;
2021-01-17 16:25:38 +00:00
InstanceSort < DecalInstance > * decal_sort ;
2020-07-22 23:39:09 +00:00
uint32_t max_decals ;
RID decal_buffer ;
2021-01-17 16:25:38 +00:00
uint32_t decal_count ;
2020-07-22 23:39:09 +00:00
2022-04-04 13:06:57 +00:00
LightData * omni_lights = nullptr ;
LightData * spot_lights = nullptr ;
2021-01-17 16:25:38 +00:00
InstanceSort < LightInstance > * omni_light_sort ;
InstanceSort < LightInstance > * spot_light_sort ;
2020-07-22 23:39:09 +00:00
uint32_t max_lights ;
2021-01-17 16:25:38 +00:00
RID omni_light_buffer ;
RID spot_light_buffer ;
uint32_t omni_light_count = 0 ;
uint32_t spot_light_count = 0 ;
2022-04-04 13:06:57 +00:00
DirectionalLightData * directional_lights = nullptr ;
2020-07-22 23:39:09 +00:00
uint32_t max_directional_lights ;
RID directional_light_buffer ;
} cluster ;
2021-02-02 19:51:36 +00:00
struct RenderState {
2021-05-05 05:41:12 +00:00
const RendererSceneRender : : RenderShadowData * render_shadows = nullptr ;
2021-02-02 19:51:36 +00:00
int render_shadow_count = 0 ;
2021-05-05 05:41:12 +00:00
const RendererSceneRender : : RenderSDFGIData * render_sdfgi_regions = nullptr ;
2021-02-02 19:51:36 +00:00
int render_sdfgi_region_count = 0 ;
2021-05-05 05:41:12 +00:00
const RendererSceneRender : : RenderSDFGIUpdateData * sdfgi_update_data = nullptr ;
2021-02-02 19:51:36 +00:00
2021-06-04 22:47:26 +00:00
uint32_t voxel_gi_count = 0 ;
2021-02-02 19:51:36 +00:00
LocalVector < int > cube_shadows ;
LocalVector < int > shadows ;
LocalVector < int > directional_shadows ;
2021-05-05 05:41:12 +00:00
bool depth_prepass_used ; // this does not seem used anywhere...
2021-02-02 19:51:36 +00:00
} render_state ;
2020-08-13 01:21:01 +00:00
RID shadow_sampler ;
2019-09-07 01:51:27 +00:00
uint64_t scene_pass = 0 ;
uint64_t shadow_atlas_realloc_tolerance_msec = 500 ;
2021-02-13 12:08:08 +00:00
/* !BAS! is this used anywhere?
2020-06-25 13:33:28 +00:00
struct SDFGICosineNeighbour {
uint32_t neighbour ;
float weight ;
} ;
2021-02-13 12:08:08 +00:00
*/
2020-06-25 13:33:28 +00:00
2021-01-17 16:25:38 +00:00
uint32_t max_cluster_elements = 512 ;
2020-12-07 21:27:38 +00:00
2022-07-23 14:01:53 +00:00
void _render_shadow_pass ( RID p_light , RID p_shadow_atlas , int p_pass , const PagedArray < RenderGeometryInstance * > & p_instances , const Plane & p_camera_plane = Plane ( ) , float p_lod_distance_multiplier = 0 , float p_screen_mesh_lod_threshold = 0.0 , bool p_open_pass = true , bool p_close_pass = true , bool p_clear_region = true , RendererScene : : RenderInfo * p_render_info = nullptr ) ;
2021-02-02 19:51:36 +00:00
2022-07-19 04:17:58 +00:00
/* Volumetric Fog */
uint32_t volumetric_fog_size = 128 ;
uint32_t volumetric_fog_depth = 128 ;
bool volumetric_fog_filter_active = true ;
2022-08-04 08:40:39 +00:00
void _update_volumetric_fog ( Ref < RenderSceneBuffersRD > p_render_buffers , RID p_environment , const Projection & p_cam_projection , const Transform3D & p_cam_transform , const Transform3D & p_prev_cam_inv_transform , RID p_shadow_atlas , int p_directional_light_count , bool p_use_directional_shadows , int p_positional_light_count , int p_voxel_gi_count , const PagedArray < RID > & p_fog_volumes ) ;
2022-07-19 04:17:58 +00:00
2019-08-18 22:40:52 +00:00
public :
2022-07-27 06:14:23 +00:00
static RendererSceneRenderRD * get_singleton ( ) { return singleton ; }
2022-08-04 08:40:39 +00:00
/* Cluster builder */
ClusterBuilderSharedDataRD * get_cluster_builder_shared ( ) { return & cluster_builder_shared ; }
2022-05-20 02:52:19 +00:00
/* GI */
RendererRD : : GI * get_gi ( ) { return & gi ; }
2019-08-18 22:40:52 +00:00
/* SHADOW ATLAS API */
2021-07-03 09:49:25 +00:00
virtual RID shadow_atlas_create ( ) override ;
2022-02-04 15:41:08 +00:00
virtual void shadow_atlas_set_size ( RID p_atlas , int p_size , bool p_16_bits = true ) override ;
2021-07-03 09:49:25 +00:00
virtual void shadow_atlas_set_quadrant_subdivision ( RID p_atlas , int p_quadrant , int p_subdivision ) override ;
2022-01-24 14:55:32 +00:00
virtual bool shadow_atlas_update_light ( RID p_atlas , RID p_light_instance , float p_coverage , uint64_t p_light_version ) override ;
2019-09-07 01:51:27 +00:00
_FORCE_INLINE_ bool shadow_atlas_owns_light_instance ( RID p_atlas , RID p_light_intance ) {
2021-09-29 17:08:41 +00:00
ShadowAtlas * atlas = shadow_atlas_owner . get_or_null ( p_atlas ) ;
2019-09-07 01:51:27 +00:00
ERR_FAIL_COND_V ( ! atlas , false ) ;
return atlas - > shadow_owners . has ( p_light_intance ) ;
}
_FORCE_INLINE_ RID shadow_atlas_get_texture ( RID p_atlas ) {
2021-09-29 17:08:41 +00:00
ShadowAtlas * atlas = shadow_atlas_owner . get_or_null ( p_atlas ) ;
2019-09-07 01:51:27 +00:00
ERR_FAIL_COND_V ( ! atlas , RID ( ) ) ;
return atlas - > depth ;
}
_FORCE_INLINE_ Size2i shadow_atlas_get_size ( RID p_atlas ) {
2021-09-29 17:08:41 +00:00
ShadowAtlas * atlas = shadow_atlas_owner . get_or_null ( p_atlas ) ;
2019-09-07 01:51:27 +00:00
ERR_FAIL_COND_V ( ! atlas , Size2i ( ) ) ;
return Size2 ( atlas - > size , atlas - > size ) ;
}
2022-02-04 15:41:08 +00:00
virtual void directional_shadow_atlas_set_size ( int p_size , bool p_16_bits = true ) override ;
2021-07-03 09:49:25 +00:00
virtual int get_directional_light_shadow_size ( RID p_light_intance ) override ;
virtual void set_directional_shadow_count ( int p_count ) override ;
2019-09-07 01:51:27 +00:00
_FORCE_INLINE_ RID directional_shadow_get_texture ( ) {
return directional_shadow . depth ;
}
_FORCE_INLINE_ Size2i directional_shadow_get_size ( ) {
return Size2i ( directional_shadow . size , directional_shadow . size ) ;
}
2019-08-18 22:40:52 +00:00
2020-06-25 13:33:28 +00:00
/* SDFGI UPDATE */
2022-08-04 08:40:39 +00:00
virtual void sdfgi_update ( const Ref < RenderSceneBuffers > & p_render_buffers , RID p_environment , const Vector3 & p_world_position ) override ;
virtual int sdfgi_get_pending_region_count ( const Ref < RenderSceneBuffers > & p_render_buffers ) const override ;
virtual AABB sdfgi_get_pending_region_bounds ( const Ref < RenderSceneBuffers > & p_render_buffers , int p_region ) const override ;
virtual uint32_t sdfgi_get_pending_region_cascade ( const Ref < RenderSceneBuffers > & p_render_buffers , int p_region ) const override ;
2020-06-25 13:33:28 +00:00
RID sdfgi_get_ubo ( ) const { return gi . sdfgi_ubo ; }
2021-02-13 12:08:08 +00:00
2019-08-26 20:43:58 +00:00
/* SKY API */
2019-08-18 22:40:52 +00:00
2021-07-03 09:49:25 +00:00
virtual RID sky_allocate ( ) override ;
virtual void sky_initialize ( RID p_rid ) override ;
2021-02-09 16:19:03 +00:00
2021-07-03 09:49:25 +00:00
virtual void sky_set_radiance_size ( RID p_sky , int p_radiance_size ) override ;
virtual void sky_set_mode ( RID p_sky , RS : : SkyMode p_mode ) override ;
virtual void sky_set_material ( RID p_sky , RID p_material ) override ;
virtual Ref < Image > sky_bake_panorama ( RID p_sky , float p_energy , bool p_bake_irradiance , const Size2i & p_size ) override ;
2019-08-18 22:40:52 +00:00
2019-08-26 20:43:58 +00:00
/* ENVIRONMENT API */
2021-07-03 09:49:25 +00:00
virtual void environment_glow_set_use_bicubic_upscale ( bool p_enable ) override ;
virtual void environment_glow_set_use_high_quality ( bool p_enable ) override ;
2019-08-18 22:40:52 +00:00
2021-07-03 09:49:25 +00:00
virtual void environment_set_volumetric_fog_volume_size ( int p_size , int p_depth ) override ;
virtual void environment_set_volumetric_fog_filter_active ( bool p_enable ) override ;
2019-08-18 22:40:52 +00:00
2021-07-03 09:49:25 +00:00
virtual void environment_set_ssao_quality ( RS : : EnvironmentSSAOQuality p_quality , bool p_half_size , float p_adaptive_target , int p_blur_passes , float p_fadeout_from , float p_fadeout_to ) override ;
2022-07-27 06:14:23 +00:00
2021-08-03 07:07:32 +00:00
virtual void environment_set_ssil_quality ( RS : : EnvironmentSSILQuality p_quality , bool p_half_size , float p_adaptive_target , int p_blur_passes , float p_fadeout_from , float p_fadeout_to ) override ;
2022-07-27 06:14:23 +00:00
2021-07-03 09:49:25 +00:00
virtual void environment_set_sdfgi_ray_count ( RS : : EnvironmentSDFGIRayCount p_ray_count ) override ;
virtual void environment_set_sdfgi_frames_to_converge ( RS : : EnvironmentSDFGIFramesToConverge p_frames ) override ;
virtual void environment_set_sdfgi_frames_to_update_light ( RS : : EnvironmentSDFGIFramesToUpdateLight p_update ) override ;
2019-08-18 22:40:52 +00:00
2021-07-03 09:49:25 +00:00
virtual void environment_set_ssr_roughness_quality ( RS : : EnvironmentSSRRoughnessQuality p_quality ) override ;
2020-04-02 02:24:52 +00:00
RS : : EnvironmentSSRRoughnessQuality environment_get_ssr_roughness_quality ( ) const ;
2021-07-03 09:49:25 +00:00
virtual Ref < Image > environment_bake_panorama ( RID p_env , bool p_bake_irradiance , const Size2i & p_size ) override ;
2020-05-01 12:34:23 +00:00
2022-07-31 23:20:24 +00:00
_FORCE_INLINE_ bool is_using_physical_light_units ( ) {
return use_physical_light_units ;
2021-06-26 10:49:25 +00:00
}
2021-10-03 11:28:55 +00:00
/* LIGHT INSTANCE API */
2021-07-03 09:49:25 +00:00
virtual RID light_instance_create ( RID p_light ) override ;
virtual void light_instance_set_transform ( RID p_light_instance , const Transform3D & p_transform ) override ;
virtual void light_instance_set_aabb ( RID p_light_instance , const AABB & p_aabb ) override ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
virtual void light_instance_set_shadow_transform ( RID p_light_instance , const Projection & p_projection , const Transform3D & p_transform , float p_far , float p_split , int p_pass , float p_shadow_texel_size , float p_bias_scale = 1.0 , float p_range_begin = 0 , const Vector2 & p_uv_scale = Vector2 ( ) ) override ;
2021-07-03 09:49:25 +00:00
virtual void light_instance_mark_visible ( RID p_light_instance ) override ;
2019-09-07 01:51:27 +00:00
_FORCE_INLINE_ RID light_instance_get_base_light ( RID p_light_instance ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2019-09-07 01:51:27 +00:00
return li - > light ;
}
2020-10-17 05:08:21 +00:00
_FORCE_INLINE_ Transform3D light_instance_get_base_transform ( RID p_light_instance ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2019-09-07 01:51:27 +00:00
return li - > transform ;
}
2019-08-18 22:40:52 +00:00
2021-08-04 15:18:06 +00:00
_FORCE_INLINE_ Rect2 light_instance_get_shadow_atlas_rect ( RID p_light_instance , RID p_shadow_atlas , Vector2i & r_omni_offset ) {
2021-09-29 17:08:41 +00:00
ShadowAtlas * shadow_atlas = shadow_atlas_owner . get_or_null ( p_shadow_atlas ) ;
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2019-09-07 01:51:27 +00:00
uint32_t key = shadow_atlas - > shadow_owners [ li - > self ] ;
uint32_t quadrant = ( key > > ShadowAtlas : : QUADRANT_SHIFT ) & 0x3 ;
uint32_t shadow = key & ShadowAtlas : : SHADOW_INDEX_MASK ;
ERR_FAIL_COND_V ( shadow > = ( uint32_t ) shadow_atlas - > quadrants [ quadrant ] . shadows . size ( ) , Rect2 ( ) ) ;
uint32_t atlas_size = shadow_atlas - > size ;
uint32_t quadrant_size = atlas_size > > 1 ;
uint32_t x = ( quadrant & 1 ) * quadrant_size ;
uint32_t y = ( quadrant > > 1 ) * quadrant_size ;
uint32_t shadow_size = ( quadrant_size / shadow_atlas - > quadrants [ quadrant ] . subdivision ) ;
x + = ( shadow % shadow_atlas - > quadrants [ quadrant ] . subdivision ) * shadow_size ;
y + = ( shadow / shadow_atlas - > quadrants [ quadrant ] . subdivision ) * shadow_size ;
2021-08-04 15:18:06 +00:00
if ( key & ShadowAtlas : : OMNI_LIGHT_FLAG ) {
if ( ( ( shadow + 1 ) % shadow_atlas - > quadrants [ quadrant ] . subdivision ) = = 0 ) {
r_omni_offset . x = 1 - int ( shadow_atlas - > quadrants [ quadrant ] . subdivision ) ;
r_omni_offset . y = 1 ;
} else {
r_omni_offset . x = 1 ;
r_omni_offset . y = 0 ;
}
}
2019-09-07 01:51:27 +00:00
uint32_t width = shadow_size ;
uint32_t height = shadow_size ;
return Rect2 ( x / float ( shadow_atlas - > size ) , y / float ( shadow_atlas - > size ) , width / float ( shadow_atlas - > size ) , height / float ( shadow_atlas - > size ) ) ;
}
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
_FORCE_INLINE_ Projection light_instance_get_shadow_camera ( RID p_light_instance , int p_index ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2019-09-07 01:51:27 +00:00
return li - > shadow_transform [ p_index ] . camera ;
}
2020-04-08 01:51:52 +00:00
_FORCE_INLINE_ float light_instance_get_shadow_texel_size ( RID p_light_instance , RID p_shadow_atlas ) {
# ifdef DEBUG_ENABLED
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2020-04-08 01:51:52 +00:00
ERR_FAIL_COND_V ( ! li - > shadow_atlases . has ( p_shadow_atlas ) , 0 ) ;
# endif
2021-09-29 17:08:41 +00:00
ShadowAtlas * shadow_atlas = shadow_atlas_owner . get_or_null ( p_shadow_atlas ) ;
2020-04-08 01:51:52 +00:00
ERR_FAIL_COND_V ( ! shadow_atlas , 0 ) ;
# ifdef DEBUG_ENABLED
ERR_FAIL_COND_V ( ! shadow_atlas - > shadow_owners . has ( p_light_instance ) , 0 ) ;
# endif
uint32_t key = shadow_atlas - > shadow_owners [ p_light_instance ] ;
uint32_t quadrant = ( key > > ShadowAtlas : : QUADRANT_SHIFT ) & 0x3 ;
uint32_t quadrant_size = shadow_atlas - > size > > 1 ;
uint32_t shadow_size = ( quadrant_size / shadow_atlas - > quadrants [ quadrant ] . subdivision ) ;
return float ( 1.0 ) / shadow_size ;
}
2020-10-17 05:08:21 +00:00
_FORCE_INLINE_ Transform3D
2020-04-08 01:51:52 +00:00
light_instance_get_shadow_transform ( RID p_light_instance , int p_index ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2019-09-07 17:38:17 +00:00
return li - > shadow_transform [ p_index ] . transform ;
}
2020-04-08 01:51:52 +00:00
_FORCE_INLINE_ float light_instance_get_shadow_bias_scale ( RID p_light_instance , int p_index ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2020-04-08 01:51:52 +00:00
return li - > shadow_transform [ p_index ] . bias_scale ;
}
_FORCE_INLINE_ float light_instance_get_shadow_range ( RID p_light_instance , int p_index ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2020-04-08 01:51:52 +00:00
return li - > shadow_transform [ p_index ] . farplane ;
}
2020-04-09 18:11:15 +00:00
_FORCE_INLINE_ float light_instance_get_shadow_range_begin ( RID p_light_instance , int p_index ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2020-04-09 18:11:15 +00:00
return li - > shadow_transform [ p_index ] . range_begin ;
}
_FORCE_INLINE_ Vector2 light_instance_get_shadow_uv_scale ( RID p_light_instance , int p_index ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2020-04-09 18:11:15 +00:00
return li - > shadow_transform [ p_index ] . uv_scale ;
}
2019-09-07 17:38:17 +00:00
_FORCE_INLINE_ Rect2 light_instance_get_directional_shadow_atlas_rect ( RID p_light_instance , int p_index ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2019-09-07 17:38:17 +00:00
return li - > shadow_transform [ p_index ] . atlas_rect ;
}
_FORCE_INLINE_ float light_instance_get_directional_shadow_split ( RID p_light_instance , int p_index ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2019-09-07 17:38:17 +00:00
return li - > shadow_transform [ p_index ] . split ;
}
2020-04-08 01:51:52 +00:00
_FORCE_INLINE_ float light_instance_get_directional_shadow_texel_size ( RID p_light_instance , int p_index ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2020-04-08 01:51:52 +00:00
return li - > shadow_transform [ p_index ] . shadow_texel_size ;
}
2019-09-07 01:51:27 +00:00
_FORCE_INLINE_ void light_instance_set_render_pass ( RID p_light_instance , uint64_t p_pass ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2019-09-07 01:51:27 +00:00
li - > last_pass = p_pass ;
}
_FORCE_INLINE_ uint64_t light_instance_get_render_pass ( RID p_light_instance ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2019-09-07 01:51:27 +00:00
return li - > last_pass ;
}
2021-07-15 20:06:33 +00:00
_FORCE_INLINE_ ForwardID light_instance_get_forward_id ( RID p_light_instance ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2021-07-15 20:06:33 +00:00
return li - > forward_id ;
2019-09-07 01:51:27 +00:00
}
2020-03-27 18:21:27 +00:00
_FORCE_INLINE_ RS : : LightType light_instance_get_type ( RID p_light_instance ) {
2021-09-29 17:08:41 +00:00
LightInstance * li = light_instance_owner . get_or_null ( p_light_instance ) ;
2019-09-07 01:51:27 +00:00
return li - > light_type ;
}
2021-10-03 11:28:55 +00:00
/* FOG VOLUMES */
virtual RID fog_volume_instance_create ( RID p_fog_volume ) override ;
virtual void fog_volume_instance_set_transform ( RID p_fog_volume_instance , const Transform3D & p_transform ) override ;
virtual void fog_volume_instance_set_active ( RID p_fog_volume_instance , bool p_active ) override ;
virtual RID fog_volume_instance_get_volume ( RID p_fog_volume_instance ) const override ;
virtual Vector3 fog_volume_instance_get_position ( RID p_fog_volume_instance ) const override ;
2021-07-03 09:49:25 +00:00
virtual RID reflection_atlas_create ( ) override ;
virtual void reflection_atlas_set_size ( RID p_ref_atlas , int p_reflection_size , int p_reflection_count ) override ;
virtual int reflection_atlas_get_size ( RID p_ref_atlas ) const override ;
2020-12-17 18:56:59 +00:00
2019-09-09 20:50:51 +00:00
_FORCE_INLINE_ RID reflection_atlas_get_texture ( RID p_ref_atlas ) {
2021-09-29 17:08:41 +00:00
ReflectionAtlas * atlas = reflection_atlas_owner . get_or_null ( p_ref_atlas ) ;
2019-09-09 20:50:51 +00:00
ERR_FAIL_COND_V ( ! atlas , RID ( ) ) ;
return atlas - > reflection ;
}
2021-07-03 09:49:25 +00:00
virtual RID reflection_probe_instance_create ( RID p_probe ) override ;
virtual void reflection_probe_instance_set_transform ( RID p_instance , const Transform3D & p_transform ) override ;
virtual void reflection_probe_release_atlas_index ( RID p_instance ) override ;
virtual bool reflection_probe_instance_needs_redraw ( RID p_instance ) override ;
virtual bool reflection_probe_instance_has_reflection ( RID p_instance ) override ;
virtual bool reflection_probe_instance_begin_render ( RID p_instance , RID p_reflection_atlas ) override ;
2021-06-26 10:49:25 +00:00
virtual RID reflection_probe_create_framebuffer ( RID p_color , RID p_depth ) ;
2021-07-03 09:49:25 +00:00
virtual bool reflection_probe_instance_postprocess_step ( RID p_instance ) override ;
2019-09-07 01:51:27 +00:00
uint32_t reflection_probe_instance_get_resolution ( RID p_instance ) ;
RID reflection_probe_instance_get_framebuffer ( RID p_instance , int p_index ) ;
2019-10-03 20:39:08 +00:00
RID reflection_probe_instance_get_depth_framebuffer ( RID p_instance , int p_index ) ;
2019-09-07 01:51:27 +00:00
_FORCE_INLINE_ RID reflection_probe_instance_get_probe ( RID p_instance ) {
2021-09-29 17:08:41 +00:00
ReflectionProbeInstance * rpi = reflection_probe_instance_owner . get_or_null ( p_instance ) ;
2019-09-07 01:51:27 +00:00
ERR_FAIL_COND_V ( ! rpi , RID ( ) ) ;
return rpi - > probe ;
}
2021-07-15 20:06:33 +00:00
_FORCE_INLINE_ ForwardID reflection_probe_instance_get_forward_id ( RID p_instance ) {
2021-09-29 17:08:41 +00:00
ReflectionProbeInstance * rpi = reflection_probe_instance_owner . get_or_null ( p_instance ) ;
2019-09-07 01:51:27 +00:00
ERR_FAIL_COND_V ( ! rpi , 0 ) ;
2021-07-15 20:06:33 +00:00
return rpi - > forward_id ;
2019-09-07 01:51:27 +00:00
}
2019-09-09 20:50:51 +00:00
_FORCE_INLINE_ void reflection_probe_instance_set_render_pass ( RID p_instance , uint32_t p_render_pass ) {
2021-09-29 17:08:41 +00:00
ReflectionProbeInstance * rpi = reflection_probe_instance_owner . get_or_null ( p_instance ) ;
2019-09-09 20:50:51 +00:00
ERR_FAIL_COND ( ! rpi ) ;
rpi - > last_pass = p_render_pass ;
}
_FORCE_INLINE_ uint32_t reflection_probe_instance_get_render_pass ( RID p_instance ) {
2021-09-29 17:08:41 +00:00
ReflectionProbeInstance * rpi = reflection_probe_instance_owner . get_or_null ( p_instance ) ;
2019-09-09 20:50:51 +00:00
ERR_FAIL_COND_V ( ! rpi , 0 ) ;
return rpi - > last_pass ;
}
2020-10-17 05:08:21 +00:00
_FORCE_INLINE_ Transform3D reflection_probe_instance_get_transform ( RID p_instance ) {
2021-09-29 17:08:41 +00:00
ReflectionProbeInstance * rpi = reflection_probe_instance_owner . get_or_null ( p_instance ) ;
2020-10-17 05:08:21 +00:00
ERR_FAIL_COND_V ( ! rpi , Transform3D ( ) ) ;
2019-09-07 01:51:27 +00:00
return rpi - > transform ;
}
2019-09-09 20:50:51 +00:00
_FORCE_INLINE_ int reflection_probe_instance_get_atlas_index ( RID p_instance ) {
2021-09-29 17:08:41 +00:00
ReflectionProbeInstance * rpi = reflection_probe_instance_owner . get_or_null ( p_instance ) ;
2019-09-09 20:50:51 +00:00
ERR_FAIL_COND_V ( ! rpi , - 1 ) ;
2019-09-07 01:51:27 +00:00
2019-09-09 20:50:51 +00:00
return rpi - > atlas_index ;
2019-09-07 01:51:27 +00:00
}
2019-08-18 22:40:52 +00:00
2021-07-03 09:49:25 +00:00
virtual RID decal_instance_create ( RID p_decal ) override ;
virtual void decal_instance_set_transform ( RID p_decal , const Transform3D & p_transform ) override ;
2020-04-14 03:05:21 +00:00
_FORCE_INLINE_ RID decal_instance_get_base ( RID p_decal ) const {
2021-09-29 17:08:41 +00:00
DecalInstance * decal = decal_instance_owner . get_or_null ( p_decal ) ;
2020-04-14 03:05:21 +00:00
return decal - > decal ;
}
2021-07-15 20:06:33 +00:00
_FORCE_INLINE_ ForwardID decal_instance_get_forward_id ( RID p_decal ) const {
2021-09-29 17:08:41 +00:00
DecalInstance * decal = decal_instance_owner . get_or_null ( p_decal ) ;
2021-07-15 20:06:33 +00:00
return decal - > forward_id ;
}
2020-10-17 05:08:21 +00:00
_FORCE_INLINE_ Transform3D decal_instance_get_transform ( RID p_decal ) const {
2021-09-29 17:08:41 +00:00
DecalInstance * decal = decal_instance_owner . get_or_null ( p_decal ) ;
2020-04-14 03:05:21 +00:00
return decal - > transform ;
}
2021-07-03 09:49:25 +00:00
virtual RID lightmap_instance_create ( RID p_lightmap ) override ;
virtual void lightmap_instance_set_transform ( RID p_lightmap , const Transform3D & p_transform ) override ;
2021-01-04 12:33:25 +00:00
_FORCE_INLINE_ bool lightmap_instance_is_valid ( RID p_lightmap_instance ) {
2021-09-29 17:08:41 +00:00
return lightmap_instance_owner . get_or_null ( p_lightmap_instance ) ! = nullptr ;
2021-01-04 12:33:25 +00:00
}
2020-12-31 12:42:56 +00:00
_FORCE_INLINE_ RID lightmap_instance_get_lightmap ( RID p_lightmap_instance ) {
2021-09-29 17:08:41 +00:00
LightmapInstance * li = lightmap_instance_owner . get_or_null ( p_lightmap_instance ) ;
2020-12-31 12:42:56 +00:00
return li - > lightmap ;
}
2020-10-17 05:08:21 +00:00
_FORCE_INLINE_ Transform3D lightmap_instance_get_transform ( RID p_lightmap_instance ) {
2021-09-29 17:08:41 +00:00
LightmapInstance * li = lightmap_instance_owner . get_or_null ( p_lightmap_instance ) ;
2020-12-31 12:42:56 +00:00
return li - > transform ;
}
2021-03-04 00:53:09 +00:00
/* gi light probes */
2021-02-13 12:08:08 +00:00
2021-07-03 09:49:25 +00:00
virtual RID voxel_gi_instance_create ( RID p_base ) override ;
virtual void voxel_gi_instance_set_transform_to_data ( RID p_probe , const Transform3D & p_xform ) override ;
virtual bool voxel_gi_needs_update ( RID p_probe ) const override ;
2022-07-23 14:01:53 +00:00
virtual void voxel_gi_update ( RID p_probe , bool p_update_light_instances , const Vector < RID > & p_light_instances , const PagedArray < RenderGeometryInstance * > & p_dynamic_objects ) override ;
2021-07-03 09:49:25 +00:00
virtual void voxel_gi_set_quality ( RS : : VoxelGIQuality p_quality ) override { gi . voxel_gi_quality = p_quality ; }
2020-06-25 13:33:28 +00:00
2021-03-04 00:53:09 +00:00
/* render buffers */
2019-10-03 20:39:08 +00:00
2021-07-26 11:31:15 +00:00
virtual float _render_buffers_get_luminance_multiplier ( ) ;
2021-06-17 10:37:08 +00:00
virtual RD : : DataFormat _render_buffers_get_color_format ( ) ;
2021-07-15 20:06:33 +00:00
virtual bool _render_buffers_can_be_storage ( ) ;
2022-08-04 08:40:39 +00:00
virtual Ref < RenderSceneBuffers > render_buffers_create ( ) override ;
2021-07-03 09:49:25 +00:00
virtual void gi_set_use_half_resolution ( bool p_enable ) override ;
2019-08-18 22:40:52 +00:00
2021-06-04 22:47:26 +00:00
RID render_buffers_get_default_voxel_gi_buffer ( ) ;
2020-08-13 01:21:01 +00:00
2021-11-23 21:16:03 +00:00
virtual void update_uniform_sets ( ) { } ;
2022-08-04 08:40:39 +00:00
virtual void render_scene ( const Ref < RenderSceneBuffers > & p_render_buffers , const CameraData * p_camera_data , const CameraData * p_prev_camera_data , const PagedArray < RenderGeometryInstance * > & p_instances , const PagedArray < RID > & p_lights , const PagedArray < RID > & p_reflection_probes , const PagedArray < RID > & p_voxel_gi_instances , const PagedArray < RID > & p_decals , const PagedArray < RID > & p_lightmaps , const PagedArray < RID > & p_fog_volumes , RID p_environment , RID p_camera_attributes , RID p_shadow_atlas , RID p_occluder_debug_tex , RID p_reflection_atlas , RID p_reflection_probe , int p_reflection_probe_pass , float p_screen_mesh_lod_threshold , const RenderShadowData * p_render_shadows , int p_render_shadow_count , const RenderSDFGIData * p_render_sdfgi_regions , int p_render_sdfgi_region_count , const RenderSDFGIUpdateData * p_sdfgi_update_data = nullptr , RendererScene : : RenderInfo * r_render_info = nullptr ) override ;
2019-09-07 01:51:27 +00:00
2022-07-23 14:01:53 +00:00
virtual void render_material ( const Transform3D & p_cam_transform , const Projection & p_cam_projection , bool p_cam_orthogonal , const PagedArray < RenderGeometryInstance * > & p_instances , RID p_framebuffer , const Rect2i & p_region ) override ;
2019-10-11 02:14:56 +00:00
2022-07-23 14:01:53 +00:00
virtual void render_particle_collider_heightfield ( RID p_collider , const Transform3D & p_transform , const PagedArray < RenderGeometryInstance * > & p_instances ) override ;
2020-10-08 00:29:49 +00:00
2021-07-03 09:49:25 +00:00
virtual void set_scene_pass ( uint64_t p_pass ) override {
2020-04-08 01:51:52 +00:00
scene_pass = p_pass ;
}
_FORCE_INLINE_ uint64_t get_scene_pass ( ) {
return scene_pass ;
}
2019-08-18 22:40:52 +00:00
2021-07-03 09:49:25 +00:00
virtual void screen_space_roughness_limiter_set_active ( bool p_enable , float p_amount , float p_limit ) override ;
virtual bool screen_space_roughness_limiter_is_active ( ) const override ;
2020-06-25 13:33:28 +00:00
virtual float screen_space_roughness_limiter_get_amount ( ) const ;
virtual float screen_space_roughness_limiter_get_limit ( ) const ;
2020-01-26 23:09:40 +00:00
2021-07-03 09:49:25 +00:00
virtual void sub_surface_scattering_set_quality ( RS : : SubSurfaceScatteringQuality p_quality ) override ;
2020-04-04 02:42:26 +00:00
RS : : SubSurfaceScatteringQuality sub_surface_scattering_get_quality ( ) const ;
2021-07-03 09:49:25 +00:00
virtual void sub_surface_scattering_set_scale ( float p_scale , float p_depth_scale ) override ;
2020-04-04 02:42:26 +00:00
2022-04-30 23:40:30 +00:00
virtual void positional_soft_shadow_filter_set_quality ( RS : : ShadowQuality p_quality ) override ;
virtual void directional_soft_shadow_filter_set_quality ( RS : : ShadowQuality p_quality ) override ;
2021-07-19 19:41:55 +00:00
virtual void decals_set_filter ( RS : : DecalFilter p_filter ) override ;
virtual void light_projectors_set_filter ( RS : : LightProjectorFilter p_filter ) override ;
2022-08-12 23:02:32 +00:00
_FORCE_INLINE_ RS : : ShadowQuality shadows_quality_get ( ) const {
return shadows_quality ;
}
_FORCE_INLINE_ RS : : ShadowQuality directional_shadow_quality_get ( ) const {
return directional_shadow_quality ;
}
_FORCE_INLINE_ float shadows_quality_radius_get ( ) const {
return shadows_quality_radius ;
}
_FORCE_INLINE_ float directional_shadow_quality_radius_get ( ) const {
return directional_shadow_quality_radius ;
}
2020-04-10 09:30:36 +00:00
2022-08-12 23:02:32 +00:00
_FORCE_INLINE_ float * directional_penumbra_shadow_kernel_get ( ) {
return directional_penumbra_shadow_kernel ;
}
_FORCE_INLINE_ float * directional_soft_shadow_kernel_get ( ) {
return directional_soft_shadow_kernel ;
}
_FORCE_INLINE_ float * penumbra_shadow_kernel_get ( ) {
return penumbra_shadow_kernel ;
}
_FORCE_INLINE_ float * soft_shadow_kernel_get ( ) {
return soft_shadow_kernel ;
}
2020-04-10 09:30:36 +00:00
2022-08-12 23:02:32 +00:00
_FORCE_INLINE_ int directional_penumbra_shadow_samples_get ( ) const {
return directional_penumbra_shadow_samples ;
}
_FORCE_INLINE_ int directional_soft_shadow_samples_get ( ) const {
return directional_soft_shadow_samples ;
}
_FORCE_INLINE_ int penumbra_shadow_samples_get ( ) const {
return penumbra_shadow_samples ;
}
_FORCE_INLINE_ int soft_shadow_samples_get ( ) const {
return soft_shadow_samples ;
}
2020-04-08 01:51:52 +00:00
2022-08-12 23:02:32 +00:00
_FORCE_INLINE_ RS : : LightProjectorFilter light_projectors_get_filter ( ) const {
return light_projectors_filter ;
}
_FORCE_INLINE_ RS : : DecalFilter decals_get_filter ( ) const {
return decals_filter ;
}
2021-07-19 19:41:55 +00:00
2019-08-26 20:43:58 +00:00
int get_roughness_layers ( ) const ;
bool is_using_radiance_cubemap_array ( ) const ;
2022-08-31 17:24:04 +00:00
virtual TypedArray < Image > bake_render_uv2 ( RID p_base , const TypedArray < RID > & p_material_overrides , const Size2i & p_image_size ) override ;
2020-05-01 12:34:23 +00:00
2021-07-03 09:49:25 +00:00
virtual bool free ( RID p_rid ) override ;
2019-08-18 22:40:52 +00:00
2021-07-03 09:49:25 +00:00
virtual void update ( ) override ;
2019-08-26 20:43:58 +00:00
2021-07-03 09:49:25 +00:00
virtual void set_debug_draw_mode ( RS : : ViewportDebugDraw p_debug_draw ) override ;
2020-04-08 01:51:52 +00:00
_FORCE_INLINE_ RS : : ViewportDebugDraw get_debug_draw_mode ( ) const {
return debug_draw ;
}
2020-01-10 00:40:26 +00:00
2021-07-03 09:49:25 +00:00
virtual void set_time ( double p_time , double p_step ) override ;
2020-01-12 01:26:52 +00:00
2020-07-22 23:39:09 +00:00
RID get_reflection_probe_buffer ( ) ;
2021-01-17 16:25:38 +00:00
RID get_omni_light_buffer ( ) ;
RID get_spot_light_buffer ( ) ;
2020-07-22 23:39:09 +00:00
RID get_directional_light_buffer ( ) ;
RID get_decal_buffer ( ) ;
int get_max_directional_lights ( ) const ;
2021-07-03 09:49:25 +00:00
virtual void sdfgi_set_debug_probe_select ( const Vector3 & p_position , const Vector3 & p_dir ) override ;
2020-06-25 13:33:28 +00:00
2022-02-11 11:33:54 +00:00
virtual bool is_vrs_supported ( ) const ;
2021-03-23 10:46:31 +00:00
virtual bool is_dynamic_gi_supported ( ) const ;
virtual bool is_clustered_enabled ( ) const ;
virtual bool is_volumetric_supported ( ) const ;
2021-03-10 11:23:55 +00:00
virtual uint32_t get_max_elements ( ) const ;
2020-12-07 21:27:38 +00:00
2021-08-16 17:51:29 +00:00
void init ( ) ;
2022-06-21 00:08:33 +00:00
RendererSceneRenderRD ( ) ;
2020-12-04 18:26:24 +00:00
~ RendererSceneRenderRD ( ) ;
2019-08-18 22:40:52 +00:00
} ;
2022-07-23 21:41:51 +00:00
# endif // RENDERER_SCENE_RENDER_RD_H