2023-01-05 13:25:55 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* rasterizer_scene_gles3.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/**************************************************************************/
|
2021-09-27 01:07:10 +02:00
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#ifndef RASTERIZER_SCENE_GLES3_H
|
|
|
|
#define RASTERIZER_SCENE_GLES3_H
|
2021-09-27 01:07:10 +02:00
|
|
|
|
2021-11-16 16:25:42 +01:00
|
|
|
#ifdef GLES3_ENABLED
|
2021-09-27 01:07:10 +02:00
|
|
|
|
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-20 01:11:13 +02:00
|
|
|
#include "core/math/projection.h"
|
2022-05-10 19:02:44 +02:00
|
|
|
#include "core/templates/paged_allocator.h"
|
2021-09-27 01:07:10 +02:00
|
|
|
#include "core/templates/rid_owner.h"
|
|
|
|
#include "core/templates/self_list.h"
|
2023-03-20 05:01:58 +01:00
|
|
|
#include "drivers/gles3/shaders/cubemap_filter.glsl.gen.h"
|
|
|
|
#include "drivers/gles3/shaders/sky.glsl.gen.h"
|
2021-09-27 01:07:10 +02:00
|
|
|
#include "scene/resources/mesh.h"
|
|
|
|
#include "servers/rendering/renderer_compositor.h"
|
|
|
|
#include "servers/rendering/renderer_scene_render.h"
|
|
|
|
#include "servers/rendering_server.h"
|
2022-02-20 01:08:53 +01:00
|
|
|
#include "shader_gles3.h"
|
2022-09-12 11:44:48 +02:00
|
|
|
#include "storage/light_storage.h"
|
2022-06-21 02:08:33 +02:00
|
|
|
#include "storage/material_storage.h"
|
2022-08-04 10:40:39 +02:00
|
|
|
#include "storage/render_scene_buffers_gles3.h"
|
2022-06-21 02:08:33 +02:00
|
|
|
#include "storage/utilities.h"
|
2022-02-20 01:08:53 +01:00
|
|
|
|
2022-05-10 19:02:44 +02:00
|
|
|
enum RenderListType {
|
|
|
|
RENDER_LIST_OPAQUE, //used for opaque objects
|
|
|
|
RENDER_LIST_ALPHA, //used for transparent objects
|
|
|
|
RENDER_LIST_SECONDARY, //used for shadows and other objects
|
|
|
|
RENDER_LIST_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
enum PassMode {
|
|
|
|
PASS_MODE_COLOR,
|
|
|
|
PASS_MODE_COLOR_TRANSPARENT,
|
|
|
|
PASS_MODE_SHADOW,
|
|
|
|
PASS_MODE_DEPTH,
|
|
|
|
};
|
|
|
|
|
|
|
|
// These should share as much as possible with SkyUniform Location
|
|
|
|
enum SceneUniformLocation {
|
|
|
|
SCENE_TONEMAP_UNIFORM_LOCATION,
|
|
|
|
SCENE_GLOBALS_UNIFORM_LOCATION,
|
|
|
|
SCENE_DATA_UNIFORM_LOCATION,
|
|
|
|
SCENE_MATERIAL_UNIFORM_LOCATION,
|
2022-05-16 20:56:03 +02:00
|
|
|
SCENE_EMPTY, // Unused, put here to avoid conflicts with SKY_DIRECTIONAL_LIGHT_UNIFORM_LOCATION.
|
2022-05-10 19:02:44 +02:00
|
|
|
SCENE_OMNILIGHT_UNIFORM_LOCATION,
|
|
|
|
SCENE_SPOTLIGHT_UNIFORM_LOCATION,
|
2022-05-16 20:56:03 +02:00
|
|
|
SCENE_DIRECTIONAL_LIGHT_UNIFORM_LOCATION,
|
2022-09-04 16:56:24 +02:00
|
|
|
SCENE_MULTIVIEW_UNIFORM_LOCATION,
|
2023-05-26 05:04:00 +02:00
|
|
|
SCENE_POSITIONAL_SHADOW_UNIFORM_LOCATION,
|
|
|
|
SCENE_DIRECTIONAL_SHADOW_UNIFORM_LOCATION,
|
2022-05-10 19:02:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SkyUniformLocation {
|
|
|
|
SKY_TONEMAP_UNIFORM_LOCATION,
|
|
|
|
SKY_GLOBALS_UNIFORM_LOCATION,
|
2022-05-16 20:56:03 +02:00
|
|
|
SKY_EMPTY, // Unused, put here to avoid conflicts with SCENE_DATA_UNIFORM_LOCATION.
|
2022-05-10 19:02:44 +02:00
|
|
|
SKY_MATERIAL_UNIFORM_LOCATION,
|
2022-05-16 20:56:03 +02:00
|
|
|
SKY_DIRECTIONAL_LIGHT_UNIFORM_LOCATION,
|
2023-01-28 05:03:00 +01:00
|
|
|
SKY_MULTIVIEW_UNIFORM_LOCATION,
|
2022-05-16 20:56:03 +02:00
|
|
|
};
|
|
|
|
|
2022-02-20 01:08:53 +01:00
|
|
|
struct RenderDataGLES3 {
|
2022-08-04 10:40:39 +02:00
|
|
|
Ref<RenderSceneBuffersGLES3> render_buffers;
|
2022-05-10 19:02:44 +02:00
|
|
|
bool transparent_bg = false;
|
2022-02-20 01:08:53 +01:00
|
|
|
|
2022-11-14 18:21:06 +01:00
|
|
|
Transform3D cam_transform;
|
|
|
|
Transform3D inv_cam_transform;
|
|
|
|
Projection cam_projection;
|
2022-05-10 19:02:44 +02:00
|
|
|
bool cam_orthogonal = false;
|
2022-10-13 04:33:06 +02:00
|
|
|
uint32_t camera_visible_layers = 0xFFFFFFFF;
|
2022-02-20 01:08:53 +01:00
|
|
|
|
|
|
|
// For stereo rendering
|
|
|
|
uint32_t view_count = 1;
|
2022-06-16 14:02:18 +02: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-20 01:11:13 +02:00
|
|
|
Projection view_projection[RendererSceneRender::MAX_RENDER_VIEWS];
|
2022-02-20 01:08:53 +01:00
|
|
|
|
|
|
|
float z_near = 0.0;
|
|
|
|
float z_far = 0.0;
|
|
|
|
|
2022-07-23 16:01:53 +02:00
|
|
|
const PagedArray<RenderGeometryInstance *> *instances = nullptr;
|
2022-02-20 01:08:53 +01:00
|
|
|
const PagedArray<RID> *lights = nullptr;
|
|
|
|
const PagedArray<RID> *reflection_probes = nullptr;
|
2022-11-14 18:21:06 +01:00
|
|
|
RID environment;
|
|
|
|
RID camera_attributes;
|
2023-05-26 05:04:00 +02:00
|
|
|
RID shadow_atlas;
|
2022-11-14 18:21:06 +01:00
|
|
|
RID reflection_probe;
|
2022-02-20 01:08:53 +01:00
|
|
|
int reflection_probe_pass = 0;
|
|
|
|
|
|
|
|
float lod_distance_multiplier = 0.0;
|
|
|
|
float screen_mesh_lod_threshold = 0.0;
|
|
|
|
|
|
|
|
uint32_t directional_light_count = 0;
|
2023-05-26 05:04:00 +02:00
|
|
|
uint32_t directional_shadow_count = 0;
|
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
uint32_t spot_light_count = 0;
|
|
|
|
uint32_t omni_light_count = 0;
|
2022-02-20 01:08:53 +01:00
|
|
|
|
2022-09-08 02:44:36 +02:00
|
|
|
RenderingMethod::RenderInfo *render_info = nullptr;
|
2023-05-26 05:04:00 +02:00
|
|
|
|
|
|
|
/* Shadow data */
|
|
|
|
const RendererSceneRender::RenderShadowData *render_shadows = nullptr;
|
|
|
|
int render_shadow_count = 0;
|
2022-02-20 01:08:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class RasterizerCanvasGLES3;
|
2021-09-27 01:07:10 +02:00
|
|
|
|
2021-10-26 17:18:39 +02:00
|
|
|
class RasterizerSceneGLES3 : public RendererSceneRender {
|
2022-02-20 01:08:53 +01:00
|
|
|
private:
|
|
|
|
static RasterizerSceneGLES3 *singleton;
|
|
|
|
RS::ViewportDebugDraw debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED;
|
|
|
|
uint64_t scene_pass = 0;
|
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
template <class T>
|
|
|
|
struct InstanceSort {
|
|
|
|
float depth;
|
|
|
|
T *instance = nullptr;
|
|
|
|
bool operator<(const InstanceSort &p_sort) const {
|
|
|
|
return depth < p_sort.depth;
|
|
|
|
}
|
|
|
|
};
|
2022-02-20 01:08:53 +01:00
|
|
|
|
2022-05-03 22:28:15 +02:00
|
|
|
struct SceneGlobals {
|
|
|
|
RID shader_default_version;
|
|
|
|
RID default_material;
|
|
|
|
RID default_shader;
|
2022-05-16 20:56:03 +02:00
|
|
|
RID cubemap_filter_shader_version;
|
2022-05-03 22:28:15 +02:00
|
|
|
} scene_globals;
|
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
/* LIGHT INSTANCE */
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
struct LightData {
|
|
|
|
float position[3];
|
|
|
|
float inv_radius;
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
float direction[3]; // Only used by SpotLight
|
|
|
|
float size;
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
float color[3];
|
|
|
|
float attenuation;
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
float inv_spot_attenuation;
|
|
|
|
float cos_spot_angle;
|
|
|
|
float specular_amount;
|
2022-06-10 12:47:06 +02:00
|
|
|
float shadow_opacity;
|
2023-11-20 04:39:20 +01:00
|
|
|
|
|
|
|
float pad[3];
|
|
|
|
uint32_t bake_mode;
|
2022-05-16 20:56:03 +02:00
|
|
|
};
|
|
|
|
static_assert(sizeof(LightData) % 16 == 0, "LightData size must be a multiple of 16 bytes");
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
struct DirectionalLightData {
|
|
|
|
float direction[3];
|
|
|
|
float energy;
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
float color[3];
|
|
|
|
float size;
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
uint32_t enabled; // For use by SkyShaders
|
2023-11-20 04:39:20 +01:00
|
|
|
uint32_t bake_mode;
|
2023-05-26 05:04:00 +02:00
|
|
|
float shadow_opacity;
|
2022-05-16 20:56:03 +02:00
|
|
|
float specular;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(DirectionalLightData) % 16 == 0, "DirectionalLightData size must be a multiple of 16 bytes");
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2023-05-26 05:04:00 +02:00
|
|
|
struct ShadowData {
|
|
|
|
float shadow_matrix[16];
|
|
|
|
|
|
|
|
float light_position[3];
|
|
|
|
float shadow_normal_bias;
|
|
|
|
|
|
|
|
float pad[3];
|
|
|
|
float shadow_atlas_pixel_size;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(ShadowData) % 16 == 0, "ShadowData size must be a multiple of 16 bytes");
|
|
|
|
|
|
|
|
struct DirectionalShadowData {
|
|
|
|
float direction[3];
|
|
|
|
float shadow_atlas_pixel_size;
|
|
|
|
float shadow_normal_bias[4];
|
|
|
|
float shadow_split_offsets[4];
|
|
|
|
float shadow_matrices[4][16];
|
|
|
|
float fade_from;
|
|
|
|
float fade_to;
|
|
|
|
uint32_t blend_splits; // Not exposed to the shader.
|
|
|
|
uint32_t pad;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(DirectionalShadowData) % 16 == 0, "DirectionalShadowData size must be a multiple of 16 bytes");
|
|
|
|
|
2022-07-23 16:01:53 +02:00
|
|
|
class GeometryInstanceGLES3;
|
2022-05-10 19:02:44 +02:00
|
|
|
|
|
|
|
// Cached data for drawing surfaces
|
|
|
|
struct GeometryInstanceSurface {
|
|
|
|
enum {
|
|
|
|
FLAG_PASS_DEPTH = 1,
|
|
|
|
FLAG_PASS_OPAQUE = 2,
|
|
|
|
FLAG_PASS_ALPHA = 4,
|
|
|
|
FLAG_PASS_SHADOW = 8,
|
|
|
|
FLAG_USES_SHARED_SHADOW_MATERIAL = 128,
|
|
|
|
FLAG_USES_SCREEN_TEXTURE = 2048,
|
|
|
|
FLAG_USES_DEPTH_TEXTURE = 4096,
|
|
|
|
FLAG_USES_NORMAL_TEXTURE = 8192,
|
|
|
|
FLAG_USES_DOUBLE_SIDED_SHADOWS = 16384,
|
|
|
|
};
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint64_t lod_index : 8;
|
|
|
|
uint64_t surface_index : 8;
|
|
|
|
uint64_t geometry_id : 32;
|
|
|
|
uint64_t material_id_low : 16;
|
|
|
|
|
|
|
|
uint64_t material_id_hi : 16;
|
|
|
|
uint64_t shader_id : 32;
|
|
|
|
uint64_t uses_softshadow : 1;
|
|
|
|
uint64_t uses_projector : 1;
|
|
|
|
uint64_t uses_forward_gi : 1;
|
|
|
|
uint64_t uses_lightmap : 1;
|
|
|
|
uint64_t depth_layer : 4;
|
|
|
|
uint64_t priority : 8;
|
|
|
|
};
|
|
|
|
struct {
|
|
|
|
uint64_t sort_key1;
|
|
|
|
uint64_t sort_key2;
|
|
|
|
};
|
|
|
|
} sort;
|
|
|
|
|
|
|
|
RS::PrimitiveType primitive = RS::PRIMITIVE_MAX;
|
|
|
|
uint32_t flags = 0;
|
|
|
|
uint32_t surface_index = 0;
|
|
|
|
uint32_t lod_index = 0;
|
2023-05-27 03:09:39 +02:00
|
|
|
uint32_t index_count = 0;
|
2023-05-26 05:04:00 +02:00
|
|
|
int32_t light_pass_index = -1;
|
|
|
|
bool finished_base_pass = false;
|
2022-05-10 19:02:44 +02:00
|
|
|
|
|
|
|
void *surface = nullptr;
|
|
|
|
GLES3::SceneShaderData *shader = nullptr;
|
|
|
|
GLES3::SceneMaterialData *material = nullptr;
|
|
|
|
|
|
|
|
void *surface_shadow = nullptr;
|
|
|
|
GLES3::SceneShaderData *shader_shadow = nullptr;
|
|
|
|
GLES3::SceneMaterialData *material_shadow = nullptr;
|
|
|
|
|
|
|
|
GeometryInstanceSurface *next = nullptr;
|
|
|
|
GeometryInstanceGLES3 *owner = nullptr;
|
|
|
|
};
|
|
|
|
|
2023-11-20 04:39:20 +01:00
|
|
|
struct GeometryInstanceLightmapSH {
|
|
|
|
Color sh[9];
|
|
|
|
};
|
|
|
|
|
2022-07-23 16:01:53 +02:00
|
|
|
class GeometryInstanceGLES3 : public RenderGeometryInstanceBase {
|
|
|
|
public:
|
2022-05-10 19:02:44 +02:00
|
|
|
//used during rendering
|
|
|
|
bool store_transform_cache = true;
|
|
|
|
|
2022-06-15 05:55:07 +02:00
|
|
|
int32_t instance_count = 0;
|
2022-05-10 19:02:44 +02:00
|
|
|
|
|
|
|
bool can_sdfgi = false;
|
|
|
|
bool using_projectors = false;
|
|
|
|
bool using_softshadows = false;
|
|
|
|
|
2023-05-26 05:04:00 +02:00
|
|
|
struct LightPass {
|
|
|
|
int32_t light_id = -1; // Position in the light uniform buffer.
|
|
|
|
int32_t shadow_id = -1; // Position in the shadow uniform buffer.
|
|
|
|
RID light_instance_rid;
|
|
|
|
bool is_omni = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
LocalVector<LightPass> light_passes;
|
|
|
|
|
|
|
|
uint32_t paired_omni_light_count = 0;
|
|
|
|
uint32_t paired_spot_light_count = 0;
|
|
|
|
LocalVector<RID> paired_omni_lights;
|
|
|
|
LocalVector<RID> paired_spot_lights;
|
2022-05-16 20:56:03 +02:00
|
|
|
LocalVector<uint32_t> omni_light_gl_cache;
|
|
|
|
LocalVector<uint32_t> spot_light_gl_cache;
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2023-11-20 04:39:20 +01:00
|
|
|
RID lightmap_instance;
|
|
|
|
Rect2 lightmap_uv_scale;
|
|
|
|
uint32_t lightmap_slice_index;
|
|
|
|
GeometryInstanceLightmapSH *lightmap_sh = nullptr;
|
|
|
|
|
2023-05-26 05:04:00 +02:00
|
|
|
// Used during setup.
|
2022-05-10 19:02:44 +02:00
|
|
|
GeometryInstanceSurface *surface_caches = nullptr;
|
|
|
|
SelfList<GeometryInstanceGLES3> dirty_list_element;
|
|
|
|
|
2022-07-23 16:01:53 +02:00
|
|
|
GeometryInstanceGLES3() :
|
|
|
|
dirty_list_element(this) {}
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2022-07-23 16:01:53 +02:00
|
|
|
virtual void _mark_dirty() override;
|
|
|
|
virtual void set_use_lightmap(RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) override;
|
|
|
|
virtual void set_lightmap_capture(const Color *p_sh9) override;
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2022-07-23 16:01:53 +02:00
|
|
|
virtual void pair_light_instances(const RID *p_light_instances, uint32_t p_light_instance_count) override;
|
|
|
|
virtual void pair_reflection_probe_instances(const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) override {}
|
|
|
|
virtual void pair_decal_instances(const RID *p_decal_instances, uint32_t p_decal_instance_count) override {}
|
|
|
|
virtual void pair_voxel_gi_instances(const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) override {}
|
2022-05-10 19:02:44 +02:00
|
|
|
|
2022-07-23 16:01:53 +02:00
|
|
|
virtual void set_softshadow_projector_pairing(bool p_softshadow, bool p_projector) override {}
|
2022-05-10 19:02:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2023-12-18 23:35:26 +01:00
|
|
|
INSTANCE_DATA_FLAGS_DYNAMIC = 1 << 3,
|
2022-09-15 17:50:12 +02:00
|
|
|
INSTANCE_DATA_FLAGS_NON_UNIFORM_SCALE = 1 << 4,
|
|
|
|
INSTANCE_DATA_FLAG_USE_GI_BUFFERS = 1 << 5,
|
|
|
|
INSTANCE_DATA_FLAG_USE_LIGHTMAP_CAPTURE = 1 << 7,
|
|
|
|
INSTANCE_DATA_FLAG_USE_LIGHTMAP = 1 << 8,
|
|
|
|
INSTANCE_DATA_FLAG_USE_SH_LIGHTMAP = 1 << 9,
|
|
|
|
INSTANCE_DATA_FLAG_USE_VOXEL_GI = 1 << 10,
|
|
|
|
INSTANCE_DATA_FLAG_PARTICLES = 1 << 11,
|
2022-05-10 19:02:44 +02:00
|
|
|
INSTANCE_DATA_FLAG_MULTIMESH = 1 << 12,
|
|
|
|
INSTANCE_DATA_FLAG_MULTIMESH_FORMAT_2D = 1 << 13,
|
|
|
|
INSTANCE_DATA_FLAG_MULTIMESH_HAS_COLOR = 1 << 14,
|
|
|
|
INSTANCE_DATA_FLAG_MULTIMESH_HAS_CUSTOM_DATA = 1 << 15,
|
|
|
|
};
|
|
|
|
|
2022-06-21 02:08:33 +02:00
|
|
|
static void _geometry_instance_dependency_changed(Dependency::DependencyChangedNotification p_notification, DependencyTracker *p_tracker);
|
|
|
|
static void _geometry_instance_dependency_deleted(const RID &p_dependency, DependencyTracker *p_tracker);
|
2022-05-10 19:02:44 +02:00
|
|
|
|
|
|
|
SelfList<GeometryInstanceGLES3>::List geometry_instance_dirty_list;
|
|
|
|
|
|
|
|
// Use PagedAllocator instead of RID to maximize performance
|
|
|
|
PagedAllocator<GeometryInstanceGLES3> geometry_instance_alloc;
|
|
|
|
PagedAllocator<GeometryInstanceSurface> geometry_instance_surface_alloc;
|
|
|
|
|
|
|
|
void _geometry_instance_add_surface_with_material(GeometryInstanceGLES3 *ginstance, uint32_t p_surface, GLES3::SceneMaterialData *p_material, uint32_t p_material_id, uint32_t p_shader_id, RID p_mesh);
|
|
|
|
void _geometry_instance_add_surface_with_material_chain(GeometryInstanceGLES3 *ginstance, uint32_t p_surface, GLES3::SceneMaterialData *p_material, RID p_mat_src, RID p_mesh);
|
|
|
|
void _geometry_instance_add_surface(GeometryInstanceGLES3 *ginstance, uint32_t p_surface, RID p_material, RID p_mesh);
|
2022-07-23 16:01:53 +02:00
|
|
|
void _geometry_instance_update(RenderGeometryInstance *p_geometry_instance);
|
2022-05-10 19:02:44 +02:00
|
|
|
void _update_dirty_geometry_instances();
|
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
struct SceneState {
|
|
|
|
struct UBO {
|
|
|
|
float projection_matrix[16];
|
|
|
|
float inv_projection_matrix[16];
|
|
|
|
float inv_view_matrix[16];
|
|
|
|
float view_matrix[16];
|
|
|
|
|
|
|
|
float viewport_size[2];
|
|
|
|
float screen_pixel_size[2];
|
|
|
|
|
|
|
|
float ambient_light_color_energy[4];
|
|
|
|
|
|
|
|
float ambient_color_sky_mix;
|
|
|
|
uint32_t material_uv2_mode;
|
2022-08-01 01:20:24 +02:00
|
|
|
float emissive_exposure_normalization;
|
2022-05-16 20:56:03 +02:00
|
|
|
uint32_t use_ambient_light = 0;
|
|
|
|
|
|
|
|
uint32_t use_ambient_cubemap = 0;
|
|
|
|
uint32_t use_reflection_cubemap = 0;
|
|
|
|
float fog_aerial_perspective;
|
|
|
|
float time;
|
|
|
|
|
|
|
|
float radiance_inverse_xform[12];
|
|
|
|
|
|
|
|
uint32_t directional_light_count;
|
|
|
|
float z_far;
|
|
|
|
float z_near;
|
2022-08-01 01:20:24 +02:00
|
|
|
float IBL_exposure_normalization;
|
2022-05-16 20:56:03 +02:00
|
|
|
|
|
|
|
uint32_t fog_enabled;
|
|
|
|
float fog_density;
|
|
|
|
float fog_height;
|
|
|
|
float fog_height_density;
|
|
|
|
|
|
|
|
float fog_light_color[3];
|
|
|
|
float fog_sun_scatter;
|
2023-05-26 05:04:00 +02:00
|
|
|
|
|
|
|
float shadow_bias;
|
|
|
|
float pad;
|
2022-10-13 04:33:06 +02:00
|
|
|
uint32_t camera_visible_layers;
|
2023-05-26 05:04:00 +02:00
|
|
|
bool pancake_shadows;
|
2022-05-16 20:56:03 +02:00
|
|
|
};
|
|
|
|
static_assert(sizeof(UBO) % 16 == 0, "Scene UBO size must be a multiple of 16 bytes");
|
|
|
|
|
2022-09-04 16:56:24 +02:00
|
|
|
struct MultiviewUBO {
|
|
|
|
float projection_matrix_view[RendererSceneRender::MAX_RENDER_VIEWS][16];
|
|
|
|
float inv_projection_matrix_view[RendererSceneRender::MAX_RENDER_VIEWS][16];
|
|
|
|
float eye_offset[RendererSceneRender::MAX_RENDER_VIEWS][4];
|
|
|
|
};
|
|
|
|
static_assert(sizeof(MultiviewUBO) % 16 == 0, "Multiview UBO size must be a multiple of 16 bytes");
|
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
struct TonemapUBO {
|
|
|
|
float exposure = 1.0;
|
|
|
|
float white = 1.0;
|
|
|
|
int32_t tonemapper = 0;
|
|
|
|
int32_t pad = 0;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(TonemapUBO) % 16 == 0, "Tonemap UBO size must be a multiple of 16 bytes");
|
|
|
|
|
|
|
|
UBO ubo;
|
|
|
|
GLuint ubo_buffer = 0;
|
2022-09-04 16:56:24 +02:00
|
|
|
MultiviewUBO multiview_ubo;
|
|
|
|
GLuint multiview_buffer = 0;
|
2022-05-16 20:56:03 +02:00
|
|
|
GLuint tonemap_buffer = 0;
|
|
|
|
|
|
|
|
bool used_depth_prepass = false;
|
|
|
|
|
|
|
|
GLES3::SceneShaderData::BlendMode current_blend_mode = GLES3::SceneShaderData::BLEND_MODE_MIX;
|
|
|
|
GLES3::SceneShaderData::DepthDraw current_depth_draw = GLES3::SceneShaderData::DEPTH_DRAW_OPAQUE;
|
|
|
|
GLES3::SceneShaderData::DepthTest current_depth_test = GLES3::SceneShaderData::DEPTH_TEST_DISABLED;
|
|
|
|
GLES3::SceneShaderData::Cull cull_mode = GLES3::SceneShaderData::CULL_BACK;
|
|
|
|
|
|
|
|
bool texscreen_copied = false;
|
|
|
|
bool used_screen_texture = false;
|
|
|
|
bool used_normal_texture = false;
|
|
|
|
bool used_depth_texture = false;
|
|
|
|
|
|
|
|
LightData *omni_lights = nullptr;
|
|
|
|
LightData *spot_lights = nullptr;
|
2023-05-26 05:04:00 +02:00
|
|
|
ShadowData *positional_shadows = nullptr;
|
2022-05-16 20:56:03 +02:00
|
|
|
|
2022-09-12 11:44:48 +02:00
|
|
|
InstanceSort<GLES3::LightInstance> *omni_light_sort;
|
|
|
|
InstanceSort<GLES3::LightInstance> *spot_light_sort;
|
2022-05-16 20:56:03 +02:00
|
|
|
GLuint omni_light_buffer = 0;
|
|
|
|
GLuint spot_light_buffer = 0;
|
2023-05-26 05:04:00 +02:00
|
|
|
GLuint positional_shadow_buffer = 0;
|
2022-05-16 20:56:03 +02:00
|
|
|
uint32_t omni_light_count = 0;
|
|
|
|
uint32_t spot_light_count = 0;
|
2023-05-26 05:04:00 +02:00
|
|
|
RS::ShadowQuality positional_shadow_quality = RS::ShadowQuality::SHADOW_QUALITY_SOFT_LOW;
|
2022-05-16 20:56:03 +02:00
|
|
|
|
|
|
|
DirectionalLightData *directional_lights = nullptr;
|
|
|
|
GLuint directional_light_buffer = 0;
|
2023-05-26 05:04:00 +02:00
|
|
|
DirectionalShadowData *directional_shadows = nullptr;
|
|
|
|
GLuint directional_shadow_buffer = 0;
|
|
|
|
RS::ShadowQuality directional_shadow_quality = RS::ShadowQuality::SHADOW_QUALITY_SOFT_LOW;
|
2022-05-16 20:56:03 +02:00
|
|
|
} scene_state;
|
|
|
|
|
2022-05-10 19:02:44 +02:00
|
|
|
struct RenderListParameters {
|
|
|
|
GeometryInstanceSurface **elements = nullptr;
|
|
|
|
int element_count = 0;
|
|
|
|
bool reverse_cull = false;
|
2022-12-06 03:10:13 +01:00
|
|
|
uint64_t spec_constant_base_flags = 0;
|
2022-05-10 19:02:44 +02:00
|
|
|
bool force_wireframe = false;
|
|
|
|
|
2022-12-06 03:10:13 +01:00
|
|
|
RenderListParameters(GeometryInstanceSurface **p_elements, int p_element_count, bool p_reverse_cull, uint64_t p_spec_constant_base_flags, bool p_force_wireframe = false) {
|
2022-05-10 19:02:44 +02:00
|
|
|
elements = p_elements;
|
|
|
|
element_count = p_element_count;
|
|
|
|
reverse_cull = p_reverse_cull;
|
|
|
|
spec_constant_base_flags = p_spec_constant_base_flags;
|
|
|
|
force_wireframe = p_force_wireframe;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RenderList {
|
|
|
|
LocalVector<GeometryInstanceSurface *> elements;
|
|
|
|
|
|
|
|
void clear() {
|
|
|
|
elements.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
//should eventually be replaced by radix
|
|
|
|
|
|
|
|
struct SortByKey {
|
|
|
|
_FORCE_INLINE_ bool operator()(const GeometryInstanceSurface *A, const GeometryInstanceSurface *B) const {
|
|
|
|
return (A->sort.sort_key2 == B->sort.sort_key2) ? (A->sort.sort_key1 < B->sort.sort_key1) : (A->sort.sort_key2 < B->sort.sort_key2);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void sort_by_key() {
|
|
|
|
SortArray<GeometryInstanceSurface *, SortByKey> sorter;
|
|
|
|
sorter.sort(elements.ptr(), elements.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void sort_by_key_range(uint32_t p_from, uint32_t p_size) {
|
|
|
|
SortArray<GeometryInstanceSurface *, SortByKey> sorter;
|
|
|
|
sorter.sort(elements.ptr() + p_from, p_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SortByDepth {
|
|
|
|
_FORCE_INLINE_ bool operator()(const GeometryInstanceSurface *A, const GeometryInstanceSurface *B) const {
|
|
|
|
return (A->owner->depth < B->owner->depth);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void sort_by_depth() { //used for shadows
|
|
|
|
|
|
|
|
SortArray<GeometryInstanceSurface *, SortByDepth> sorter;
|
|
|
|
sorter.sort(elements.ptr(), elements.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SortByReverseDepthAndPriority {
|
|
|
|
_FORCE_INLINE_ bool operator()(const GeometryInstanceSurface *A, const GeometryInstanceSurface *B) const {
|
|
|
|
return (A->sort.priority == B->sort.priority) ? (A->owner->depth > B->owner->depth) : (A->sort.priority < B->sort.priority);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void sort_by_reverse_depth_and_priority() { //used for alpha
|
|
|
|
|
|
|
|
SortArray<GeometryInstanceSurface *, SortByReverseDepthAndPriority> sorter;
|
|
|
|
sorter.sort(elements.ptr(), elements.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
_FORCE_INLINE_ void add_element(GeometryInstanceSurface *p_element) {
|
|
|
|
elements.push_back(p_element);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
RenderList render_list[RENDER_LIST_MAX];
|
|
|
|
|
2023-05-26 05:04:00 +02:00
|
|
|
void _setup_lights(const RenderDataGLES3 *p_render_data, bool p_using_shadows, uint32_t &r_directional_light_count, uint32_t &r_omni_light_count, uint32_t &r_spot_light_count, uint32_t &r_directional_shadow_count);
|
|
|
|
void _setup_environment(const RenderDataGLES3 *p_render_data, bool p_no_fog, const Size2i &p_screen_size, bool p_flip_y, const Color &p_default_bg_color, bool p_pancake_shadows, float p_shadow_bias = 0.0);
|
2022-05-10 19:02:44 +02:00
|
|
|
void _fill_render_list(RenderListType p_render_list, const RenderDataGLES3 *p_render_data, PassMode p_pass_mode, bool p_append = false);
|
2023-10-26 09:25:09 +02:00
|
|
|
void _render_shadows(const RenderDataGLES3 *p_render_data, const Size2i &p_viewport_size = Size2i(1, 1));
|
|
|
|
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, RenderingMethod::RenderInfo *p_render_info = nullptr, const Size2i &p_viewport_size = Size2i(1, 1));
|
2023-10-26 03:10:38 +02:00
|
|
|
void _render_post_processing(const RenderDataGLES3 *p_render_data);
|
2022-05-10 19:02:44 +02:00
|
|
|
|
|
|
|
template <PassMode p_pass_mode>
|
|
|
|
_FORCE_INLINE_ void _render_list_template(RenderListParameters *p_params, const RenderDataGLES3 *p_render_data, uint32_t p_from_element, uint32_t p_to_element, bool p_alpha_pass = false);
|
|
|
|
|
2022-02-20 01:08:53 +01:00
|
|
|
protected:
|
|
|
|
double time;
|
|
|
|
double time_step = 0;
|
|
|
|
|
|
|
|
bool screen_space_roughness_limiter = false;
|
|
|
|
float screen_space_roughness_limiter_amount = 0.25;
|
|
|
|
float screen_space_roughness_limiter_limit = 0.18;
|
|
|
|
|
2023-10-26 03:10:38 +02:00
|
|
|
void _render_buffers_debug_draw(Ref<RenderSceneBuffersGLES3> p_render_buffers, RID p_shadow_atlas, GLuint p_fbo);
|
2022-02-20 01:08:53 +01:00
|
|
|
|
2022-08-01 01:20:24 +02:00
|
|
|
/* Camera Attributes */
|
|
|
|
|
|
|
|
struct CameraAttributes {
|
|
|
|
float exposure_multiplier = 1.0;
|
|
|
|
float exposure_normalization = 1.0;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool use_physical_light_units = false;
|
|
|
|
mutable RID_Owner<CameraAttributes, true> camera_attributes_owner;
|
|
|
|
|
2022-02-20 01:08:53 +01:00
|
|
|
/* Environment */
|
|
|
|
|
|
|
|
RS::EnvironmentSSAOQuality ssao_quality = RS::ENV_SSAO_QUALITY_MEDIUM;
|
|
|
|
bool ssao_half_size = false;
|
|
|
|
float ssao_adaptive_target = 0.5;
|
|
|
|
int ssao_blur_passes = 2;
|
|
|
|
float ssao_fadeout_from = 50.0;
|
|
|
|
float ssao_fadeout_to = 300.0;
|
|
|
|
|
|
|
|
bool glow_bicubic_upscale = false;
|
|
|
|
RS::EnvironmentSSRRoughnessQuality ssr_roughness_quality = RS::ENV_SSR_ROUGHNESS_QUALITY_LOW;
|
|
|
|
|
|
|
|
/* Sky */
|
|
|
|
|
2022-05-16 20:56:03 +02:00
|
|
|
struct SkyGlobals {
|
|
|
|
float fog_aerial_perspective = 0.0;
|
|
|
|
Color fog_light_color;
|
|
|
|
float fog_sun_scatter = 0.0;
|
|
|
|
bool fog_enabled = false;
|
|
|
|
float fog_density = 0.0;
|
|
|
|
float z_far = 0.0;
|
|
|
|
uint32_t directional_light_count = 0;
|
|
|
|
|
|
|
|
DirectionalLightData *directional_lights = nullptr;
|
|
|
|
DirectionalLightData *last_frame_directional_lights = nullptr;
|
|
|
|
uint32_t last_frame_directional_light_count = 0;
|
|
|
|
GLuint directional_light_buffer = 0;
|
|
|
|
|
|
|
|
RID shader_default_version;
|
|
|
|
RID default_material;
|
|
|
|
RID default_shader;
|
|
|
|
RID fog_material;
|
|
|
|
RID fog_shader;
|
|
|
|
GLuint screen_triangle = 0;
|
|
|
|
GLuint screen_triangle_array = 0;
|
|
|
|
GLuint radical_inverse_vdc_cache_tex = 0;
|
|
|
|
uint32_t max_directional_lights = 4;
|
|
|
|
uint32_t roughness_layers = 8;
|
|
|
|
uint32_t ggx_samples = 128;
|
|
|
|
} sky_globals;
|
|
|
|
|
2022-02-20 01:08:53 +01:00
|
|
|
struct Sky {
|
|
|
|
// Screen Buffers
|
|
|
|
GLuint half_res_pass = 0;
|
|
|
|
GLuint half_res_framebuffer = 0;
|
|
|
|
GLuint quarter_res_pass = 0;
|
|
|
|
GLuint quarter_res_framebuffer = 0;
|
|
|
|
Size2i screen_size = Size2i(0, 0);
|
|
|
|
|
|
|
|
// Radiance Cubemap
|
|
|
|
GLuint radiance = 0;
|
|
|
|
GLuint radiance_framebuffer = 0;
|
2022-05-16 20:56:03 +02:00
|
|
|
GLuint raw_radiance = 0;
|
2022-02-20 01:08:53 +01:00
|
|
|
|
|
|
|
RID material;
|
2022-05-16 20:56:03 +02:00
|
|
|
GLuint uniform_buffer;
|
2022-02-20 01:08:53 +01:00
|
|
|
|
|
|
|
int radiance_size = 256;
|
2022-05-16 20:56:03 +02:00
|
|
|
int mipmap_count = 1;
|
2022-02-20 01:08:53 +01:00
|
|
|
|
|
|
|
RS::SkyMode mode = RS::SKY_MODE_AUTOMATIC;
|
|
|
|
|
|
|
|
//ReflectionData reflection;
|
|
|
|
bool reflection_dirty = false;
|
|
|
|
bool dirty = false;
|
|
|
|
int processing_layer = 0;
|
|
|
|
Sky *dirty_list = nullptr;
|
2022-08-01 01:20:24 +02:00
|
|
|
float baked_exposure = 1.0;
|
2022-02-20 01:08:53 +01:00
|
|
|
|
|
|
|
//State to track when radiance cubemap needs updating
|
2022-04-30 00:34:01 +02:00
|
|
|
GLES3::SkyMaterialData *prev_material;
|
2022-02-20 01:08:53 +01:00
|
|
|
Vector3 prev_position = Vector3(0.0, 0.0, 0.0);
|
|
|
|
float prev_time = 0.0f;
|
|
|
|
};
|
|
|
|
|
|
|
|
Sky *dirty_sky_list = nullptr;
|
|
|
|
mutable RID_Owner<Sky, true> sky_owner;
|
|
|
|
|
2022-08-04 10:40:39 +02:00
|
|
|
void _setup_sky(const RenderDataGLES3 *p_render_data, const PagedArray<RID> &p_lights, const Projection &p_projection, const Transform3D &p_transform, const Size2i p_screen_size);
|
2022-02-20 01:08:53 +01:00
|
|
|
void _invalidate_sky(Sky *p_sky);
|
|
|
|
void _update_dirty_skys();
|
2022-08-01 01:20:24 +02:00
|
|
|
void _update_sky_radiance(RID p_env, const Projection &p_projection, const Transform3D &p_transform, float p_luminance_multiplier);
|
2022-05-16 20:56:03 +02:00
|
|
|
void _filter_sky_radiance(Sky *p_sky, int p_base_layer);
|
2023-01-28 05:03:00 +01:00
|
|
|
void _draw_sky(RID p_env, const Projection &p_projection, const Transform3D &p_transform, float p_luminance_multiplier, bool p_use_multiview, bool p_flip_y);
|
2022-05-16 20:56:03 +02:00
|
|
|
void _free_sky_data(Sky *p_sky);
|
2022-02-20 01:08:53 +01:00
|
|
|
|
2021-09-27 01:07:10 +02:00
|
|
|
public:
|
2022-07-23 16:01:53 +02:00
|
|
|
static RasterizerSceneGLES3 *get_singleton() { return singleton; }
|
|
|
|
|
2022-09-06 11:15:00 +02:00
|
|
|
RasterizerCanvasGLES3 *canvas = nullptr;
|
2022-02-20 01:08:53 +01:00
|
|
|
|
2022-07-23 16:01:53 +02:00
|
|
|
RenderGeometryInstance *geometry_instance_create(RID p_base) override;
|
|
|
|
void geometry_instance_free(RenderGeometryInstance *p_geometry_instance) override;
|
2021-09-27 01:07:10 +02:00
|
|
|
|
|
|
|
uint32_t geometry_instance_get_pair_mask() override;
|
|
|
|
|
|
|
|
/* SDFGI UPDATE */
|
|
|
|
|
2022-08-04 10:40:39 +02:00
|
|
|
void sdfgi_update(const Ref<RenderSceneBuffers> &p_render_buffers, RID p_environment, const Vector3 &p_world_position) override {}
|
|
|
|
int sdfgi_get_pending_region_count(const Ref<RenderSceneBuffers> &p_render_buffers) const override {
|
2022-05-10 19:02:44 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2022-08-04 10:40:39 +02:00
|
|
|
AABB sdfgi_get_pending_region_bounds(const Ref<RenderSceneBuffers> &p_render_buffers, int p_region) const override {
|
2022-05-10 19:02:44 +02:00
|
|
|
return AABB();
|
|
|
|
}
|
2022-08-04 10:40:39 +02:00
|
|
|
uint32_t sdfgi_get_pending_region_cascade(const Ref<RenderSceneBuffers> &p_render_buffers, int p_region) const override {
|
2022-05-10 19:02:44 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2021-09-27 01:07:10 +02:00
|
|
|
|
|
|
|
/* SKY API */
|
|
|
|
|
|
|
|
RID sky_allocate() override;
|
|
|
|
void sky_initialize(RID p_rid) override;
|
|
|
|
void sky_set_radiance_size(RID p_sky, int p_radiance_size) override;
|
2022-02-20 01:08:53 +01:00
|
|
|
void sky_set_mode(RID p_sky, RS::SkyMode p_mode) override;
|
2021-09-27 01:07:10 +02:00
|
|
|
void sky_set_material(RID p_sky, RID p_material) override;
|
|
|
|
Ref<Image> sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) override;
|
2022-08-01 01:20:24 +02:00
|
|
|
float sky_get_baked_exposure(RID p_sky) const;
|
2021-09-27 01:07:10 +02:00
|
|
|
|
|
|
|
/* ENVIRONMENT API */
|
|
|
|
|
|
|
|
void environment_glow_set_use_bicubic_upscale(bool p_enable) override;
|
|
|
|
|
|
|
|
void environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) override;
|
2022-07-27 08:14:23 +02:00
|
|
|
|
2021-09-27 01:07:10 +02:00
|
|
|
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 08:14:23 +02:00
|
|
|
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;
|
2021-09-27 01:07:10 +02:00
|
|
|
|
|
|
|
void environment_set_sdfgi_ray_count(RS::EnvironmentSDFGIRayCount p_ray_count) override;
|
|
|
|
void environment_set_sdfgi_frames_to_converge(RS::EnvironmentSDFGIFramesToConverge p_frames) override;
|
|
|
|
void environment_set_sdfgi_frames_to_update_light(RS::EnvironmentSDFGIFramesToUpdateLight p_update) override;
|
|
|
|
|
|
|
|
void environment_set_volumetric_fog_volume_size(int p_size, int p_depth) override;
|
|
|
|
void environment_set_volumetric_fog_filter_active(bool p_enable) override;
|
|
|
|
|
|
|
|
Ref<Image> environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) override;
|
|
|
|
|
2022-08-01 01:20:24 +02:00
|
|
|
_FORCE_INLINE_ bool is_using_physical_light_units() {
|
|
|
|
return use_physical_light_units;
|
|
|
|
}
|
2021-09-27 01:07:10 +02:00
|
|
|
|
2022-05-01 01:40:30 +02:00
|
|
|
void positional_soft_shadow_filter_set_quality(RS::ShadowQuality p_quality) override;
|
|
|
|
void directional_soft_shadow_filter_set_quality(RS::ShadowQuality p_quality) override;
|
2021-09-27 01:07:10 +02:00
|
|
|
|
2021-10-26 17:18:39 +02:00
|
|
|
RID fog_volume_instance_create(RID p_fog_volume) override;
|
|
|
|
void fog_volume_instance_set_transform(RID p_fog_volume_instance, const Transform3D &p_transform) override;
|
|
|
|
void fog_volume_instance_set_active(RID p_fog_volume_instance, bool p_active) override;
|
|
|
|
RID fog_volume_instance_get_volume(RID p_fog_volume_instance) const override;
|
|
|
|
Vector3 fog_volume_instance_get_position(RID p_fog_volume_instance) const override;
|
|
|
|
|
2021-09-27 01:07:10 +02:00
|
|
|
RID voxel_gi_instance_create(RID p_voxel_gi) override;
|
|
|
|
void voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) override;
|
|
|
|
bool voxel_gi_needs_update(RID p_probe) const override;
|
2022-07-23 16:01:53 +02:00
|
|
|
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-09-27 01:07:10 +02:00
|
|
|
|
|
|
|
void voxel_gi_set_quality(RS::VoxelGIQuality) override;
|
|
|
|
|
2022-09-08 02:44:36 +02:00
|
|
|
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, RenderingMethod::RenderInfo *r_render_info = nullptr) override;
|
2022-07-23 16:01:53 +02:00
|
|
|
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;
|
|
|
|
void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<RenderGeometryInstance *> &p_instances) override;
|
2021-09-27 01:07:10 +02:00
|
|
|
|
2022-02-20 01:08:53 +01:00
|
|
|
void set_scene_pass(uint64_t p_pass) override {
|
|
|
|
scene_pass = p_pass;
|
|
|
|
}
|
|
|
|
|
|
|
|
_FORCE_INLINE_ uint64_t get_scene_pass() {
|
|
|
|
return scene_pass;
|
|
|
|
}
|
|
|
|
|
2021-09-27 01:07:10 +02:00
|
|
|
void set_time(double p_time, double p_step) override;
|
|
|
|
void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) override;
|
2022-02-20 01:08:53 +01:00
|
|
|
_FORCE_INLINE_ RS::ViewportDebugDraw get_debug_draw_mode() const {
|
|
|
|
return debug_draw;
|
|
|
|
}
|
2021-09-27 01:07:10 +02:00
|
|
|
|
2022-08-04 10:40:39 +02:00
|
|
|
Ref<RenderSceneBuffers> render_buffers_create() override;
|
2021-09-27 01:07:10 +02:00
|
|
|
void gi_set_use_half_resolution(bool p_enable) override;
|
|
|
|
|
|
|
|
void screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_curve) override;
|
|
|
|
bool screen_space_roughness_limiter_is_active() const override;
|
|
|
|
|
|
|
|
void sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) override;
|
|
|
|
void sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) override;
|
|
|
|
|
2022-08-31 19:24:04 +02:00
|
|
|
TypedArray<Image> bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) override;
|
2021-09-27 01:07:10 +02:00
|
|
|
|
|
|
|
bool free(RID p_rid) override;
|
|
|
|
void update() override;
|
|
|
|
void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) override;
|
|
|
|
|
|
|
|
void decals_set_filter(RS::DecalFilter p_filter) override;
|
|
|
|
void light_projectors_set_filter(RS::LightProjectorFilter p_filter) override;
|
|
|
|
|
2022-06-21 02:08:33 +02:00
|
|
|
RasterizerSceneGLES3();
|
2022-02-20 01:08:53 +01:00
|
|
|
~RasterizerSceneGLES3();
|
2021-09-27 01:07:10 +02:00
|
|
|
};
|
|
|
|
|
2021-11-16 16:25:42 +01:00
|
|
|
#endif // GLES3_ENABLED
|
2021-09-27 01:07:10 +02:00
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#endif // RASTERIZER_SCENE_GLES3_H
|