mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
Reorganize rendering server.
-Made RenderingServerScene abstract, allowing reimplementation -RenderingServerRaster -> RenderingServerDefault, but this class is going away soon.
This commit is contained in:
parent
ea7dd1be36
commit
e93b2242c2
100
core/templates/pass_func.h
Normal file
100
core/templates/pass_func.h
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* pass_func.h */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||||
|
/* */
|
||||||
|
/* 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. */
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef PASS_FUNC_H
|
||||||
|
#define PASS_FUNC_H
|
||||||
|
|
||||||
|
#define PASS0R(m_r, m_name) \
|
||||||
|
m_r m_name() { return PASSBASE->m_name(); }
|
||||||
|
#define PASS0RC(m_r, m_name) \
|
||||||
|
m_r m_name() const { return PASSBASE->m_name(); }
|
||||||
|
#define PASS1R(m_r, m_name, m_type1) \
|
||||||
|
m_r m_name(m_type1 arg1) { return PASSBASE->m_name(arg1); }
|
||||||
|
#define PASS1RC(m_r, m_name, m_type1) \
|
||||||
|
m_r m_name(m_type1 arg1) const { return PASSBASE->m_name(arg1); }
|
||||||
|
#define PASS2R(m_r, m_name, m_type1, m_type2) \
|
||||||
|
m_r m_name(m_type1 arg1, m_type2 arg2) { return PASSBASE->m_name(arg1, arg2); }
|
||||||
|
#define PASS2RC(m_r, m_name, m_type1, m_type2) \
|
||||||
|
m_r m_name(m_type1 arg1, m_type2 arg2) const { return PASSBASE->m_name(arg1, arg2); }
|
||||||
|
#define PASS3R(m_r, m_name, m_type1, m_type2, m_type3) \
|
||||||
|
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) { return PASSBASE->m_name(arg1, arg2, arg3); }
|
||||||
|
#define PASS3RC(m_r, m_name, m_type1, m_type2, m_type3) \
|
||||||
|
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) const { return PASSBASE->m_name(arg1, arg2, arg3); }
|
||||||
|
#define PASS4R(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \
|
||||||
|
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) { return PASSBASE->m_name(arg1, arg2, arg3, arg4); }
|
||||||
|
#define PASS4RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \
|
||||||
|
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) const { return PASSBASE->m_name(arg1, arg2, arg3, arg4); }
|
||||||
|
#define PASS5R(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \
|
||||||
|
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) { return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); }
|
||||||
|
#define PASS5RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \
|
||||||
|
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) const { return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); }
|
||||||
|
#define PASS6R(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \
|
||||||
|
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) { return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); }
|
||||||
|
#define PASS6RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \
|
||||||
|
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) const { return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); }
|
||||||
|
|
||||||
|
#define PASS0(m_name) \
|
||||||
|
void m_name() { PASSBASE->m_name(); }
|
||||||
|
#define PASS1(m_name, m_type1) \
|
||||||
|
void m_name(m_type1 arg1) { PASSBASE->m_name(arg1); }
|
||||||
|
#define PASS1C(m_name, m_type1) \
|
||||||
|
void m_name(m_type1 arg1) const { PASSBASE->m_name(arg1); }
|
||||||
|
#define PASS2(m_name, m_type1, m_type2) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2) { PASSBASE->m_name(arg1, arg2); }
|
||||||
|
#define PASS2C(m_name, m_type1, m_type2) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2) const { PASSBASE->m_name(arg1, arg2); }
|
||||||
|
#define PASS3(m_name, m_type1, m_type2, m_type3) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) { PASSBASE->m_name(arg1, arg2, arg3); }
|
||||||
|
#define PASS4(m_name, m_type1, m_type2, m_type3, m_type4) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) { PASSBASE->m_name(arg1, arg2, arg3, arg4); }
|
||||||
|
#define PASS5(m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); }
|
||||||
|
#define PASS6(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); }
|
||||||
|
#define PASS7(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7); }
|
||||||
|
#define PASS8(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); }
|
||||||
|
#define PASS9(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); }
|
||||||
|
#define PASS10(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); }
|
||||||
|
#define PASS11(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); }
|
||||||
|
#define PASS12(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); }
|
||||||
|
#define PASS13(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); }
|
||||||
|
#define PASS14(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13, m_type14) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); }
|
||||||
|
#define PASS15(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13, m_type14, m_type15) \
|
||||||
|
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14, m_type15 arg15) { PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); }
|
||||||
|
|
||||||
|
#endif // PASS_FUNC_H
|
@ -70,7 +70,7 @@
|
|||||||
#include "servers/physics_server_2d.h"
|
#include "servers/physics_server_2d.h"
|
||||||
#include "servers/physics_server_3d.h"
|
#include "servers/physics_server_3d.h"
|
||||||
#include "servers/register_server_types.h"
|
#include "servers/register_server_types.h"
|
||||||
#include "servers/rendering/rendering_server_raster.h"
|
#include "servers/rendering/rendering_server_default.h"
|
||||||
#include "servers/rendering/rendering_server_wrap_mt.h"
|
#include "servers/rendering/rendering_server_wrap_mt.h"
|
||||||
#include "servers/text_server.h"
|
#include "servers/text_server.h"
|
||||||
#include "servers/xr_server.h"
|
#include "servers/xr_server.h"
|
||||||
@ -1563,7 +1563,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
|
|||||||
|
|
||||||
/* Initialize Visual Server */
|
/* Initialize Visual Server */
|
||||||
|
|
||||||
rendering_server = memnew(RenderingServerRaster);
|
rendering_server = memnew(RenderingServerDefault);
|
||||||
if (OS::get_singleton()->get_render_thread_mode() != OS::RENDER_THREAD_UNSAFE) {
|
if (OS::get_singleton()->get_render_thread_mode() != OS::RENDER_THREAD_UNSAFE) {
|
||||||
rendering_server = memnew(RenderingServerWrapMT(rendering_server,
|
rendering_server = memnew(RenderingServerWrapMT(rendering_server,
|
||||||
OS::get_singleton()->get_render_thread_mode() ==
|
OS::get_singleton()->get_render_thread_mode() ==
|
||||||
|
@ -73,7 +73,7 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Displ
|
|||||||
// return ERR_UNAVAILABLE;
|
// return ERR_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rendering_server = memnew(RenderingServerRaster);
|
// rendering_server = memnew(RenderingServerDefault);
|
||||||
// // FIXME: Reimplement threaded rendering
|
// // FIXME: Reimplement threaded rendering
|
||||||
// if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
// if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
||||||
// rendering_server = memnew(RenderingServerWrapMT(rendering_server,
|
// rendering_server = memnew(RenderingServerWrapMT(rendering_server,
|
||||||
|
@ -4093,7 +4093,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
rendering_server = memnew(RenderingServerRaster);
|
rendering_server = memnew(RenderingServerDefault);
|
||||||
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
||||||
rendering_server = memnew(RenderingServerWrapMT(rendering_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
|
rendering_server = memnew(RenderingServerWrapMT(rendering_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "core/string/print_string.h"
|
#include "core/string/print_string.h"
|
||||||
#include "drivers/dummy/rasterizer_dummy.h"
|
#include "drivers/dummy/rasterizer_dummy.h"
|
||||||
#include "drivers/dummy/texture_loader_dummy.h"
|
#include "drivers/dummy/texture_loader_dummy.h"
|
||||||
#include "servers/rendering/rendering_server_raster.h"
|
#include "servers/rendering/rendering_server_default.h"
|
||||||
|
|
||||||
#include "main/main.h"
|
#include "main/main.h"
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int
|
|||||||
|
|
||||||
video_driver_index = p_video_driver; // unused in server platform, but should still be initialized
|
video_driver_index = p_video_driver; // unused in server platform, but should still be initialized
|
||||||
|
|
||||||
rendering_server = memnew(RenderingServerRaster);
|
rendering_server = memnew(RenderingServerDefault);
|
||||||
rendering_server->init();
|
rendering_server->init();
|
||||||
|
|
||||||
AudioDriverManager::initialize(p_audio_driver);
|
AudioDriverManager::initialize(p_audio_driver);
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
#include "main/main.h"
|
#include "main/main.h"
|
||||||
#include "platform/windows/windows_terminal_logger.h"
|
#include "platform/windows/windows_terminal_logger.h"
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/rendering/rendering_server_raster.h"
|
#include "servers/rendering/rendering_server_default.h"
|
||||||
#include "servers/rendering/rendering_server_wrap_mt.h"
|
#include "servers/rendering/rendering_server_wrap_mt.h"
|
||||||
#include "thread_uwp.h"
|
#include "thread_uwp.h"
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
|||||||
|
|
||||||
set_video_mode(vm);
|
set_video_mode(vm);
|
||||||
|
|
||||||
rendering_server = memnew(RenderingServerRaster);
|
rendering_server = memnew(RenderingServerDefault);
|
||||||
// FIXME: Reimplement threaded rendering
|
// FIXME: Reimplement threaded rendering
|
||||||
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
||||||
rendering_server = memnew(RenderingServerWrapMT(rendering_server, false));
|
rendering_server = memnew(RenderingServerWrapMT(rendering_server, false));
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#include "main/main.h"
|
#include "main/main.h"
|
||||||
#include "platform/windows/display_server_windows.h"
|
#include "platform/windows/display_server_windows.h"
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/rendering/rendering_server_raster.h"
|
#include "servers/rendering/rendering_server_default.h"
|
||||||
#include "servers/rendering/rendering_server_wrap_mt.h"
|
#include "servers/rendering/rendering_server_wrap_mt.h"
|
||||||
#include "windows_terminal_logger.h"
|
#include "windows_terminal_logger.h"
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ protected:
|
|||||||
static DisplayServerCreate server_create_functions[MAX_SERVERS];
|
static DisplayServerCreate server_create_functions[MAX_SERVERS];
|
||||||
static int server_create_count;
|
static int server_create_count;
|
||||||
|
|
||||||
friend class RenderingServerRaster;
|
friend class RenderingServerDefault;
|
||||||
virtual void _set_use_vsync(bool p_enable);
|
virtual void _set_use_vsync(bool p_enable);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -874,7 +874,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
|
|||||||
|
|
||||||
glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); //not used, so keep white
|
glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); //not used, so keep white
|
||||||
|
|
||||||
RenderingServerRaster::redraw_request();
|
RenderingServerDefault::redraw_request();
|
||||||
|
|
||||||
storage->particles_request_process(particles_cmd->particles);
|
storage->particles_request_process(particles_cmd->particles);
|
||||||
//enable instancing
|
//enable instancing
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "rasterizer_scene_high_end_rd.h"
|
#include "rasterizer_scene_high_end_rd.h"
|
||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
#include "servers/rendering/rendering_device.h"
|
#include "servers/rendering/rendering_device.h"
|
||||||
#include "servers/rendering/rendering_server_raster.h"
|
#include "servers/rendering/rendering_server_default.h"
|
||||||
|
|
||||||
/* SCENE SHADER */
|
/* SCENE SHADER */
|
||||||
void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
|
void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
|
||||||
@ -1512,7 +1512,7 @@ void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_insta
|
|||||||
e->priority = p_material->priority;
|
e->priority = p_material->priority;
|
||||||
|
|
||||||
if (p_material->shader_data->uses_time) {
|
if (p_material->shader_data->uses_time) {
|
||||||
RenderingServerRaster::redraw_request();
|
RenderingServerDefault::redraw_request();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "rasterizer_rd.h"
|
#include "rasterizer_rd.h"
|
||||||
#include "servers/rendering/rendering_server_raster.h"
|
#include "servers/rendering/rendering_server_default.h"
|
||||||
|
|
||||||
uint64_t RasterizerSceneRD::auto_exposure_counter = 2;
|
uint64_t RasterizerSceneRD::auto_exposure_counter = 2;
|
||||||
|
|
||||||
@ -2242,7 +2242,7 @@ void RasterizerSceneRD::_setup_sky(RID p_environment, RID p_render_buffers, cons
|
|||||||
if (shader_data->uses_time && time - sky->prev_time > 0.00001) {
|
if (shader_data->uses_time && time - sky->prev_time > 0.00001) {
|
||||||
sky->prev_time = time;
|
sky->prev_time = time;
|
||||||
sky->reflection.dirty = true;
|
sky->reflection.dirty = true;
|
||||||
RenderingServerRaster::redraw_request();
|
RenderingServerDefault::redraw_request();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (material != sky->prev_material) {
|
if (material != sky->prev_material) {
|
||||||
@ -5257,7 +5257,7 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu
|
|||||||
|
|
||||||
//swap final reduce with prev luminance
|
//swap final reduce with prev luminance
|
||||||
SWAP(rb->luminance.current, rb->luminance.reduce.write[rb->luminance.reduce.size() - 1]);
|
SWAP(rb->luminance.current, rb->luminance.reduce.write[rb->luminance.reduce.size() - 1]);
|
||||||
RenderingServerRaster::redraw_request(); //redraw all the time if auto exposure rendering is on
|
RenderingServerDefault::redraw_request(); //redraw all the time if auto exposure rendering is on
|
||||||
}
|
}
|
||||||
|
|
||||||
int max_glow_level = -1;
|
int max_glow_level = -1;
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
#include "rendering_server_canvas.h"
|
#include "rendering_server_canvas.h"
|
||||||
|
|
||||||
#include "core/math/geometry_2d.h"
|
#include "core/math/geometry_2d.h"
|
||||||
|
#include "rendering_server_default.h"
|
||||||
#include "rendering_server_globals.h"
|
#include "rendering_server_globals.h"
|
||||||
#include "rendering_server_raster.h"
|
|
||||||
#include "rendering_server_viewport.h"
|
#include "rendering_server_viewport.h"
|
||||||
|
|
||||||
static const int z_range = RS::CANVAS_ITEM_Z_MAX - RS::CANVAS_ITEM_Z_MIN + 1;
|
static const int z_range = RS::CANVAS_ITEM_Z_MAX - RS::CANVAS_ITEM_Z_MIN + 1;
|
||||||
@ -263,7 +263,7 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ci->update_when_visible) {
|
if (ci->update_when_visible) {
|
||||||
RenderingServerRaster::redraw_request();
|
RenderingServerDefault::redraw_request();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ci->commands != nullptr && p_clip_rect.intersects(global_rect, true)) || ci->vp_render || ci->copy_back_buffer) {
|
if ((ci->commands != nullptr && p_clip_rect.intersects(global_rect, true)) || ci->vp_render || ci->copy_back_buffer) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* rendering_server_raster.cpp */
|
/* rendering_server_default.cpp */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
@ -28,7 +28,7 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "rendering_server_raster.h"
|
#include "rendering_server_default.h"
|
||||||
|
|
||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
#include "core/io/marshalls.h"
|
#include "core/io/marshalls.h"
|
||||||
@ -36,35 +36,35 @@
|
|||||||
#include "core/templates/sort_array.h"
|
#include "core/templates/sort_array.h"
|
||||||
#include "rendering_server_canvas.h"
|
#include "rendering_server_canvas.h"
|
||||||
#include "rendering_server_globals.h"
|
#include "rendering_server_globals.h"
|
||||||
#include "rendering_server_scene.h"
|
#include "rendering_server_scene_raster.h"
|
||||||
|
|
||||||
// careful, these may run in different threads than the visual server
|
// careful, these may run in different threads than the visual server
|
||||||
|
|
||||||
int RenderingServerRaster::changes = 0;
|
int RenderingServerDefault::changes = 0;
|
||||||
|
|
||||||
/* BLACK BARS */
|
/* BLACK BARS */
|
||||||
|
|
||||||
void RenderingServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) {
|
void RenderingServerDefault::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) {
|
||||||
black_margin[MARGIN_LEFT] = p_left;
|
black_margin[MARGIN_LEFT] = p_left;
|
||||||
black_margin[MARGIN_TOP] = p_top;
|
black_margin[MARGIN_TOP] = p_top;
|
||||||
black_margin[MARGIN_RIGHT] = p_right;
|
black_margin[MARGIN_RIGHT] = p_right;
|
||||||
black_margin[MARGIN_BOTTOM] = p_bottom;
|
black_margin[MARGIN_BOTTOM] = p_bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) {
|
void RenderingServerDefault::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) {
|
||||||
black_image[MARGIN_LEFT] = p_left;
|
black_image[MARGIN_LEFT] = p_left;
|
||||||
black_image[MARGIN_TOP] = p_top;
|
black_image[MARGIN_TOP] = p_top;
|
||||||
black_image[MARGIN_RIGHT] = p_right;
|
black_image[MARGIN_RIGHT] = p_right;
|
||||||
black_image[MARGIN_BOTTOM] = p_bottom;
|
black_image[MARGIN_BOTTOM] = p_bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::_draw_margins() {
|
void RenderingServerDefault::_draw_margins() {
|
||||||
RSG::canvas_render->draw_window_margins(black_margin, black_image);
|
RSG::canvas_render->draw_window_margins(black_margin, black_image);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* FREE */
|
/* FREE */
|
||||||
|
|
||||||
void RenderingServerRaster::free(RID p_rid) {
|
void RenderingServerDefault::free(RID p_rid) {
|
||||||
if (RSG::storage->free(p_rid)) {
|
if (RSG::storage->free(p_rid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -77,14 +77,11 @@ void RenderingServerRaster::free(RID p_rid) {
|
|||||||
if (RSG::scene->free(p_rid)) {
|
if (RSG::scene->free(p_rid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (RSG::scene_render->free(p_rid)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EVENT QUEUING */
|
/* EVENT QUEUING */
|
||||||
|
|
||||||
void RenderingServerRaster::request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata) {
|
void RenderingServerDefault::request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata) {
|
||||||
ERR_FAIL_NULL(p_where);
|
ERR_FAIL_NULL(p_where);
|
||||||
FrameDrawnCallbacks fdc;
|
FrameDrawnCallbacks fdc;
|
||||||
fdc.object = p_where->get_instance_id();
|
fdc.object = p_where->get_instance_id();
|
||||||
@ -94,7 +91,7 @@ void RenderingServerRaster::request_frame_drawn_callback(Object *p_where, const
|
|||||||
frame_drawn_callbacks.push_back(fdc);
|
frame_drawn_callbacks.push_back(fdc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::draw(bool p_swap_buffers, double frame_step) {
|
void RenderingServerDefault::draw(bool p_swap_buffers, double frame_step) {
|
||||||
//needs to be done before changes is reset to 0, to not force the editor to redraw
|
//needs to be done before changes is reset to 0, to not force the editor to redraw
|
||||||
RS::get_singleton()->emit_signal("frame_pre_draw");
|
RS::get_singleton()->emit_signal("frame_pre_draw");
|
||||||
|
|
||||||
@ -104,11 +101,8 @@ void RenderingServerRaster::draw(bool p_swap_buffers, double frame_step) {
|
|||||||
|
|
||||||
TIMESTAMP_BEGIN()
|
TIMESTAMP_BEGIN()
|
||||||
|
|
||||||
RSG::scene_render->update(); //update scenes stuff before updating instances
|
RSG::scene->update(); //update scenes stuff before updating instances
|
||||||
|
|
||||||
RSG::scene->update_dirty_instances(); //update scene stuff
|
|
||||||
|
|
||||||
RSG::scene->render_particle_colliders();
|
|
||||||
RSG::storage->update_particles(); //need to be done after instances are updated (colliders and particle transforms), and colliders are rendered
|
RSG::storage->update_particles(); //need to be done after instances are updated (colliders and particle transforms), and colliders are rendered
|
||||||
|
|
||||||
RSG::scene->render_probes();
|
RSG::scene->render_probes();
|
||||||
@ -165,18 +159,18 @@ void RenderingServerRaster::draw(bool p_swap_buffers, double frame_step) {
|
|||||||
frame_profile_frame = RSG::storage->get_captured_timestamps_frame();
|
frame_profile_frame = RSG::storage->get_captured_timestamps_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::sync() {
|
void RenderingServerDefault::sync() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderingServerRaster::has_changed() const {
|
bool RenderingServerDefault::has_changed() const {
|
||||||
return changes > 0;
|
return changes > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::init() {
|
void RenderingServerDefault::init() {
|
||||||
RSG::rasterizer->initialize();
|
RSG::rasterizer->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::finish() {
|
void RenderingServerDefault::finish() {
|
||||||
if (test_cube.is_valid()) {
|
if (test_cube.is_valid()) {
|
||||||
free(test_cube);
|
free(test_cube);
|
||||||
}
|
}
|
||||||
@ -186,69 +180,69 @@ void RenderingServerRaster::finish() {
|
|||||||
|
|
||||||
/* STATUS INFORMATION */
|
/* STATUS INFORMATION */
|
||||||
|
|
||||||
int RenderingServerRaster::get_render_info(RenderInfo p_info) {
|
int RenderingServerDefault::get_render_info(RenderInfo p_info) {
|
||||||
return RSG::storage->get_render_info(p_info);
|
return RSG::storage->get_render_info(p_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
String RenderingServerRaster::get_video_adapter_name() const {
|
String RenderingServerDefault::get_video_adapter_name() const {
|
||||||
return RSG::storage->get_video_adapter_name();
|
return RSG::storage->get_video_adapter_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
String RenderingServerRaster::get_video_adapter_vendor() const {
|
String RenderingServerDefault::get_video_adapter_vendor() const {
|
||||||
return RSG::storage->get_video_adapter_vendor();
|
return RSG::storage->get_video_adapter_vendor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::set_frame_profiling_enabled(bool p_enable) {
|
void RenderingServerDefault::set_frame_profiling_enabled(bool p_enable) {
|
||||||
RSG::storage->capturing_timestamps = p_enable;
|
RSG::storage->capturing_timestamps = p_enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t RenderingServerRaster::get_frame_profile_frame() {
|
uint64_t RenderingServerDefault::get_frame_profile_frame() {
|
||||||
return frame_profile_frame;
|
return frame_profile_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<RenderingServer::FrameProfileArea> RenderingServerRaster::get_frame_profile() {
|
Vector<RenderingServer::FrameProfileArea> RenderingServerDefault::get_frame_profile() {
|
||||||
return frame_profile;
|
return frame_profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TESTING */
|
/* TESTING */
|
||||||
|
|
||||||
void RenderingServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
|
void RenderingServerDefault::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
|
||||||
redraw_request();
|
redraw_request();
|
||||||
RSG::rasterizer->set_boot_image(p_image, p_color, p_scale, p_use_filter);
|
RSG::rasterizer->set_boot_image(p_image, p_color, p_scale, p_use_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::set_default_clear_color(const Color &p_color) {
|
void RenderingServerDefault::set_default_clear_color(const Color &p_color) {
|
||||||
RSG::viewport->set_default_clear_color(p_color);
|
RSG::viewport->set_default_clear_color(p_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderingServerRaster::has_feature(Features p_feature) const {
|
bool RenderingServerDefault::has_feature(Features p_feature) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) {
|
void RenderingServerDefault::sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) {
|
||||||
RSG::scene_render->sdfgi_set_debug_probe_select(p_position, p_dir);
|
RSG::scene->sdfgi_set_debug_probe_select(p_position, p_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
RID RenderingServerRaster::get_test_cube() {
|
RID RenderingServerDefault::get_test_cube() {
|
||||||
if (!test_cube.is_valid()) {
|
if (!test_cube.is_valid()) {
|
||||||
test_cube = _make_test_cube();
|
test_cube = _make_test_cube();
|
||||||
}
|
}
|
||||||
return test_cube;
|
return test_cube;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderingServerRaster::has_os_feature(const String &p_feature) const {
|
bool RenderingServerDefault::has_os_feature(const String &p_feature) const {
|
||||||
return RSG::storage->has_os_feature(p_feature);
|
return RSG::storage->has_os_feature(p_feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::set_debug_generate_wireframes(bool p_generate) {
|
void RenderingServerDefault::set_debug_generate_wireframes(bool p_generate) {
|
||||||
RSG::storage->set_debug_generate_wireframes(p_generate);
|
RSG::storage->set_debug_generate_wireframes(p_generate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerRaster::call_set_use_vsync(bool p_enable) {
|
void RenderingServerDefault::call_set_use_vsync(bool p_enable) {
|
||||||
DisplayServer::get_singleton()->_set_use_vsync(p_enable);
|
DisplayServer::get_singleton()->_set_use_vsync(p_enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderingServerRaster::is_low_end() const {
|
bool RenderingServerDefault::is_low_end() const {
|
||||||
// FIXME: Commented out when rebasing vulkan branch on master,
|
// FIXME: Commented out when rebasing vulkan branch on master,
|
||||||
// causes a crash, it seems rasterizer is not initialized yet the
|
// causes a crash, it seems rasterizer is not initialized yet the
|
||||||
// first time it's called.
|
// first time it's called.
|
||||||
@ -256,14 +250,15 @@ bool RenderingServerRaster::is_low_end() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderingServerRaster::RenderingServerRaster() {
|
RenderingServerDefault::RenderingServerDefault() {
|
||||||
RSG::canvas = memnew(RenderingServerCanvas);
|
RSG::canvas = memnew(RenderingServerCanvas);
|
||||||
RSG::viewport = memnew(RenderingServerViewport);
|
RSG::viewport = memnew(RenderingServerViewport);
|
||||||
RSG::scene = memnew(RenderingServerScene);
|
RenderingServerSceneRaster *sr = memnew(RenderingServerSceneRaster);
|
||||||
|
RSG::scene = sr;
|
||||||
RSG::rasterizer = Rasterizer::create();
|
RSG::rasterizer = Rasterizer::create();
|
||||||
RSG::storage = RSG::rasterizer->get_storage();
|
RSG::storage = RSG::rasterizer->get_storage();
|
||||||
RSG::canvas_render = RSG::rasterizer->get_canvas();
|
RSG::canvas_render = RSG::rasterizer->get_canvas();
|
||||||
RSG::scene_render = RSG::rasterizer->get_scene();
|
sr->scene_render = RSG::rasterizer->get_scene();
|
||||||
|
|
||||||
frame_profile_frame = 0;
|
frame_profile_frame = 0;
|
||||||
|
|
||||||
@ -273,7 +268,7 @@ RenderingServerRaster::RenderingServerRaster() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderingServerRaster::~RenderingServerRaster() {
|
RenderingServerDefault::~RenderingServerDefault() {
|
||||||
memdelete(RSG::canvas);
|
memdelete(RSG::canvas);
|
||||||
memdelete(RSG::viewport);
|
memdelete(RSG::viewport);
|
||||||
memdelete(RSG::rasterizer);
|
memdelete(RSG::rasterizer);
|
@ -1,5 +1,5 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* rendering_server_raster.h */
|
/* rendering_server_default.h */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
@ -28,18 +28,18 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#ifndef RENDERING_SERVER_RASTER_H
|
#ifndef RENDERING_SERVER_DEFAULT_H
|
||||||
#define RENDERING_SERVER_RASTER_H
|
#define RENDERING_SERVER_DEFAULT_H
|
||||||
|
|
||||||
#include "core/math/octree.h"
|
#include "core/math/octree.h"
|
||||||
#include "rendering_server_canvas.h"
|
#include "rendering_server_canvas.h"
|
||||||
#include "rendering_server_globals.h"
|
#include "rendering_server_globals.h"
|
||||||
#include "rendering_server_scene.h"
|
#include "rendering_server_scene_raster.h"
|
||||||
#include "rendering_server_viewport.h"
|
#include "rendering_server_viewport.h"
|
||||||
#include "servers/rendering/rasterizer.h"
|
#include "servers/rendering/rasterizer.h"
|
||||||
#include "servers/rendering_server.h"
|
#include "servers/rendering_server.h"
|
||||||
|
|
||||||
class RenderingServerRaster : public RenderingServer {
|
class RenderingServerDefault : public RenderingServer {
|
||||||
enum {
|
enum {
|
||||||
MAX_INSTANCE_CULL = 8192,
|
MAX_INSTANCE_CULL = 8192,
|
||||||
MAX_INSTANCE_LIGHTS = 4,
|
MAX_INSTANCE_LIGHTS = 4,
|
||||||
@ -554,7 +554,7 @@ public:
|
|||||||
|
|
||||||
#undef BINDBASE
|
#undef BINDBASE
|
||||||
//from now on, calls forwarded to this singleton
|
//from now on, calls forwarded to this singleton
|
||||||
#define BINDBASE RSG::scene_render
|
#define BINDBASE RSG::scene
|
||||||
|
|
||||||
BIND1(directional_shadow_atlas_set_size, int)
|
BIND1(directional_shadow_atlas_set_size, int)
|
||||||
BIND1(gi_probe_set_quality, GIProbeQuality)
|
BIND1(gi_probe_set_quality, GIProbeQuality)
|
||||||
@ -853,8 +853,8 @@ public:
|
|||||||
|
|
||||||
virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir);
|
virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir);
|
||||||
|
|
||||||
RenderingServerRaster();
|
RenderingServerDefault();
|
||||||
~RenderingServerRaster();
|
~RenderingServerDefault();
|
||||||
|
|
||||||
#undef DISPLAY_CHANGED
|
#undef DISPLAY_CHANGED
|
||||||
|
|
@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
RasterizerStorage *RenderingServerGlobals::storage = nullptr;
|
RasterizerStorage *RenderingServerGlobals::storage = nullptr;
|
||||||
RasterizerCanvas *RenderingServerGlobals::canvas_render = nullptr;
|
RasterizerCanvas *RenderingServerGlobals::canvas_render = nullptr;
|
||||||
RasterizerScene *RenderingServerGlobals::scene_render = nullptr;
|
|
||||||
Rasterizer *RenderingServerGlobals::rasterizer = nullptr;
|
Rasterizer *RenderingServerGlobals::rasterizer = nullptr;
|
||||||
|
|
||||||
RenderingServerCanvas *RenderingServerGlobals::canvas = nullptr;
|
RenderingServerCanvas *RenderingServerGlobals::canvas = nullptr;
|
||||||
|
@ -41,7 +41,6 @@ class RenderingServerGlobals {
|
|||||||
public:
|
public:
|
||||||
static RasterizerStorage *storage;
|
static RasterizerStorage *storage;
|
||||||
static RasterizerCanvas *canvas_render;
|
static RasterizerCanvas *canvas_render;
|
||||||
static RasterizerScene *scene_render;
|
|
||||||
static Rasterizer *rasterizer;
|
static Rasterizer *rasterizer;
|
||||||
|
|
||||||
static RenderingServerCanvas *canvas;
|
static RenderingServerCanvas *canvas;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -28,450 +28,175 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#ifndef VISUALSERVERSCENE_H
|
#ifndef RENDERINGSERVERSCENE_H
|
||||||
#define VISUALSERVERSCENE_H
|
#define RENDERINGSERVERSCENE_H
|
||||||
|
|
||||||
#include "servers/rendering/rasterizer.h"
|
#include "servers/rendering/rasterizer.h"
|
||||||
|
|
||||||
#include "core/math/geometry_3d.h"
|
|
||||||
#include "core/math/octree.h"
|
|
||||||
#include "core/os/semaphore.h"
|
|
||||||
#include "core/os/thread.h"
|
|
||||||
#include "core/templates/local_vector.h"
|
|
||||||
#include "core/templates/rid_owner.h"
|
|
||||||
#include "core/templates/self_list.h"
|
|
||||||
#include "servers/xr/xr_interface.h"
|
#include "servers/xr/xr_interface.h"
|
||||||
|
|
||||||
class RenderingServerScene {
|
class RenderingServerScene {
|
||||||
public:
|
public:
|
||||||
enum {
|
virtual RID camera_create() = 0;
|
||||||
MAX_INSTANCE_CULL = 65536,
|
|
||||||
MAX_LIGHTS_CULLED = 4096,
|
virtual void camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) = 0;
|
||||||
MAX_REFLECTION_PROBES_CULLED = 4096,
|
virtual void camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) = 0;
|
||||||
MAX_DECALS_CULLED = 4096,
|
virtual void camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) = 0;
|
||||||
MAX_GI_PROBES_CULLED = 4096,
|
virtual void camera_set_transform(RID p_camera, const Transform &p_transform) = 0;
|
||||||
MAX_ROOM_CULL = 32,
|
virtual void camera_set_cull_mask(RID p_camera, uint32_t p_layers) = 0;
|
||||||
MAX_LIGHTMAPS_CULLED = 4096,
|
virtual void camera_set_environment(RID p_camera, RID p_env) = 0;
|
||||||
MAX_EXTERIOR_PORTALS = 128,
|
virtual void camera_set_camera_effects(RID p_camera, RID p_fx) = 0;
|
||||||
};
|
virtual void camera_set_use_vertical_aspect(RID p_camera, bool p_enable) = 0;
|
||||||
|
virtual bool is_camera(RID p_camera) const = 0;
|
||||||
uint64_t render_pass;
|
|
||||||
|
virtual RID scenario_create() = 0;
|
||||||
static RenderingServerScene *singleton;
|
|
||||||
|
virtual void scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode) = 0;
|
||||||
/* CAMERA API */
|
virtual void scenario_set_environment(RID p_scenario, RID p_environment) = 0;
|
||||||
|
virtual void scenario_set_camera_effects(RID p_scenario, RID p_fx) = 0;
|
||||||
struct Camera {
|
virtual void scenario_set_fallback_environment(RID p_scenario, RID p_environment) = 0;
|
||||||
enum Type {
|
virtual void scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count) = 0;
|
||||||
PERSPECTIVE,
|
virtual bool is_scenario(RID p_scenario) const = 0;
|
||||||
ORTHOGONAL,
|
virtual RID scenario_get_environment(RID p_scenario) = 0;
|
||||||
FRUSTUM
|
|
||||||
};
|
virtual RID instance_create() = 0;
|
||||||
Type type;
|
|
||||||
float fov;
|
virtual void instance_set_base(RID p_instance, RID p_base) = 0;
|
||||||
float znear, zfar;
|
virtual void instance_set_scenario(RID p_instance, RID p_scenario) = 0;
|
||||||
float size;
|
virtual void instance_set_layer_mask(RID p_instance, uint32_t p_mask) = 0;
|
||||||
Vector2 offset;
|
virtual void instance_set_transform(RID p_instance, const Transform &p_transform) = 0;
|
||||||
uint32_t visible_layers;
|
virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id) = 0;
|
||||||
bool vaspect;
|
virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) = 0;
|
||||||
RID env;
|
virtual void instance_set_surface_material(RID p_instance, int p_surface, RID p_material) = 0;
|
||||||
RID effects;
|
virtual void instance_set_visible(RID p_instance, bool p_visible) = 0;
|
||||||
|
|
||||||
Transform transform;
|
virtual void instance_set_custom_aabb(RID p_instance, AABB p_aabb) = 0;
|
||||||
|
|
||||||
Camera() {
|
virtual void instance_attach_skeleton(RID p_instance, RID p_skeleton) = 0;
|
||||||
visible_layers = 0xFFFFFFFF;
|
virtual void instance_set_exterior(RID p_instance, bool p_enabled) = 0;
|
||||||
fov = 75;
|
|
||||||
type = PERSPECTIVE;
|
virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) = 0;
|
||||||
znear = 0.05;
|
|
||||||
zfar = 100;
|
|
||||||
size = 1.0;
|
|
||||||
offset = Vector2();
|
|
||||||
vaspect = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mutable RID_PtrOwner<Camera> camera_owner;
|
|
||||||
|
|
||||||
virtual RID camera_create();
|
|
||||||
virtual void camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far);
|
|
||||||
virtual void camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far);
|
|
||||||
virtual void camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far);
|
|
||||||
virtual void camera_set_transform(RID p_camera, const Transform &p_transform);
|
|
||||||
virtual void camera_set_cull_mask(RID p_camera, uint32_t p_layers);
|
|
||||||
virtual void camera_set_environment(RID p_camera, RID p_env);
|
|
||||||
virtual void camera_set_camera_effects(RID p_camera, RID p_fx);
|
|
||||||
virtual void camera_set_use_vertical_aspect(RID p_camera, bool p_enable);
|
|
||||||
|
|
||||||
/* SCENARIO API */
|
|
||||||
|
|
||||||
struct Instance;
|
|
||||||
|
|
||||||
struct Scenario {
|
|
||||||
RS::ScenarioDebugMode debug;
|
|
||||||
RID self;
|
|
||||||
|
|
||||||
Octree<Instance, true> octree;
|
|
||||||
|
|
||||||
List<Instance *> directional_lights;
|
|
||||||
RID environment;
|
|
||||||
RID fallback_environment;
|
|
||||||
RID camera_effects;
|
|
||||||
RID reflection_probe_shadow_atlas;
|
|
||||||
RID reflection_atlas;
|
|
||||||
|
|
||||||
SelfList<Instance>::List instances;
|
|
||||||
|
|
||||||
LocalVector<RID> dynamic_lights;
|
|
||||||
|
|
||||||
Scenario() { debug = RS::SCENARIO_DEBUG_DISABLED; }
|
|
||||||
};
|
|
||||||
|
|
||||||
mutable RID_PtrOwner<Scenario> scenario_owner;
|
|
||||||
|
|
||||||
static void *_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int);
|
|
||||||
static void _instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *);
|
|
||||||
|
|
||||||
virtual RID scenario_create();
|
|
||||||
|
|
||||||
virtual void scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode);
|
|
||||||
virtual void scenario_set_environment(RID p_scenario, RID p_environment);
|
|
||||||
virtual void scenario_set_camera_effects(RID p_scenario, RID p_fx);
|
|
||||||
virtual void scenario_set_fallback_environment(RID p_scenario, RID p_environment);
|
|
||||||
virtual void scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count);
|
|
||||||
|
|
||||||
/* INSTANCING API */
|
|
||||||
|
|
||||||
struct InstanceBaseData {
|
|
||||||
virtual ~InstanceBaseData() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Instance : RasterizerScene::InstanceBase {
|
|
||||||
RID self;
|
|
||||||
//scenario stuff
|
|
||||||
OctreeElementID octree_id;
|
|
||||||
Scenario *scenario;
|
|
||||||
SelfList<Instance> scenario_item;
|
|
||||||
|
|
||||||
//aabb stuff
|
|
||||||
bool update_aabb;
|
|
||||||
bool update_dependencies;
|
|
||||||
|
|
||||||
SelfList<Instance> update_item;
|
|
||||||
|
|
||||||
AABB *custom_aabb; // <Zylann> would using aabb directly with a bool be better?
|
|
||||||
float extra_margin;
|
|
||||||
ObjectID object_id;
|
|
||||||
|
|
||||||
float lod_begin;
|
|
||||||
float lod_end;
|
|
||||||
float lod_begin_hysteresis;
|
|
||||||
float lod_end_hysteresis;
|
|
||||||
RID lod_instance;
|
|
||||||
|
|
||||||
Vector<Color> lightmap_target_sh; //target is used for incrementally changing the SH over time, this avoids pops in some corner cases and when going interior <-> exterior
|
|
||||||
|
|
||||||
uint64_t last_render_pass;
|
|
||||||
uint64_t last_frame_pass;
|
|
||||||
|
|
||||||
uint64_t version; // changes to this, and changes to base increase version
|
|
||||||
|
|
||||||
InstanceBaseData *base_data;
|
|
||||||
|
|
||||||
virtual void dependency_deleted(RID p_dependency) {
|
|
||||||
if (p_dependency == base) {
|
|
||||||
singleton->instance_set_base(self, RID());
|
|
||||||
} else if (p_dependency == skeleton) {
|
|
||||||
singleton->instance_attach_skeleton(self, RID());
|
|
||||||
} else {
|
|
||||||
singleton->_instance_queue_update(this, false, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void dependency_changed(bool p_aabb, bool p_dependencies) {
|
|
||||||
singleton->_instance_queue_update(this, p_aabb, p_dependencies);
|
|
||||||
}
|
|
||||||
|
|
||||||
Instance() :
|
|
||||||
scenario_item(this),
|
|
||||||
update_item(this) {
|
|
||||||
octree_id = 0;
|
|
||||||
scenario = nullptr;
|
|
||||||
|
|
||||||
update_aabb = false;
|
|
||||||
update_dependencies = false;
|
|
||||||
|
|
||||||
extra_margin = 0;
|
|
||||||
|
|
||||||
visible = true;
|
|
||||||
|
|
||||||
lod_begin = 0;
|
|
||||||
lod_end = 0;
|
|
||||||
lod_begin_hysteresis = 0;
|
|
||||||
lod_end_hysteresis = 0;
|
|
||||||
|
|
||||||
last_render_pass = 0;
|
|
||||||
last_frame_pass = 0;
|
|
||||||
version = 1;
|
|
||||||
base_data = nullptr;
|
|
||||||
|
|
||||||
custom_aabb = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
~Instance() {
|
|
||||||
if (base_data) {
|
|
||||||
memdelete(base_data);
|
|
||||||
}
|
|
||||||
if (custom_aabb) {
|
|
||||||
memdelete(custom_aabb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SelfList<Instance>::List _instance_update_list;
|
|
||||||
void _instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_dependencies = false);
|
|
||||||
|
|
||||||
struct InstanceGeometryData : public InstanceBaseData {
|
|
||||||
List<Instance *> lighting;
|
|
||||||
bool lighting_dirty;
|
|
||||||
bool can_cast_shadows;
|
|
||||||
bool material_is_animated;
|
|
||||||
|
|
||||||
List<Instance *> decals;
|
|
||||||
bool decal_dirty;
|
|
||||||
|
|
||||||
List<Instance *> reflection_probes;
|
|
||||||
bool reflection_dirty;
|
|
||||||
|
|
||||||
List<Instance *> gi_probes;
|
|
||||||
bool gi_probes_dirty;
|
|
||||||
|
|
||||||
List<Instance *> lightmap_captures;
|
|
||||||
|
|
||||||
InstanceGeometryData() {
|
|
||||||
lighting_dirty = false;
|
|
||||||
reflection_dirty = true;
|
|
||||||
can_cast_shadows = true;
|
|
||||||
material_is_animated = true;
|
|
||||||
gi_probes_dirty = true;
|
|
||||||
decal_dirty = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct InstanceReflectionProbeData : public InstanceBaseData {
|
|
||||||
Instance *owner;
|
|
||||||
|
|
||||||
struct PairInfo {
|
|
||||||
List<Instance *>::Element *L; //reflection iterator in geometry
|
|
||||||
Instance *geometry;
|
|
||||||
};
|
|
||||||
List<PairInfo> geometries;
|
|
||||||
|
|
||||||
RID instance;
|
|
||||||
bool reflection_dirty;
|
|
||||||
SelfList<InstanceReflectionProbeData> update_list;
|
|
||||||
|
|
||||||
int render_step;
|
|
||||||
|
|
||||||
InstanceReflectionProbeData() :
|
|
||||||
update_list(this) {
|
|
||||||
reflection_dirty = true;
|
|
||||||
render_step = -1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct InstanceDecalData : public InstanceBaseData {
|
|
||||||
Instance *owner;
|
|
||||||
RID instance;
|
|
||||||
|
|
||||||
struct PairInfo {
|
|
||||||
List<Instance *>::Element *L; //reflection iterator in geometry
|
|
||||||
Instance *geometry;
|
|
||||||
};
|
|
||||||
List<PairInfo> geometries;
|
|
||||||
|
|
||||||
InstanceDecalData() {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SelfList<InstanceReflectionProbeData>::List reflection_probe_render_list;
|
|
||||||
|
|
||||||
struct InstanceLightData : public InstanceBaseData {
|
|
||||||
struct PairInfo {
|
|
||||||
List<Instance *>::Element *L; //light iterator in geometry
|
|
||||||
Instance *geometry;
|
|
||||||
};
|
|
||||||
|
|
||||||
RID instance;
|
|
||||||
uint64_t last_version;
|
|
||||||
List<Instance *>::Element *D; // directional light in scenario
|
|
||||||
|
|
||||||
bool shadow_dirty;
|
|
||||||
|
|
||||||
List<PairInfo> geometries;
|
|
||||||
|
|
||||||
Instance *baked_light;
|
|
||||||
|
|
||||||
RS::LightBakeMode bake_mode;
|
|
||||||
uint32_t max_sdfgi_cascade = 2;
|
|
||||||
|
|
||||||
uint64_t sdfgi_cascade_light_pass = 0;
|
|
||||||
|
|
||||||
InstanceLightData() {
|
|
||||||
bake_mode = RS::LIGHT_BAKE_DISABLED;
|
|
||||||
shadow_dirty = true;
|
|
||||||
D = nullptr;
|
|
||||||
last_version = 0;
|
|
||||||
baked_light = nullptr;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct InstanceGIProbeData : public InstanceBaseData {
|
|
||||||
Instance *owner;
|
|
||||||
|
|
||||||
struct PairInfo {
|
|
||||||
List<Instance *>::Element *L; //gi probe iterator in geometry
|
|
||||||
Instance *geometry;
|
|
||||||
};
|
|
||||||
|
|
||||||
List<PairInfo> geometries;
|
|
||||||
List<PairInfo> dynamic_geometries;
|
|
||||||
|
|
||||||
Set<Instance *> lights;
|
|
||||||
|
|
||||||
struct LightCache {
|
|
||||||
RS::LightType type;
|
|
||||||
Transform transform;
|
|
||||||
Color color;
|
|
||||||
float energy;
|
|
||||||
float bake_energy;
|
|
||||||
float radius;
|
|
||||||
float attenuation;
|
|
||||||
float spot_angle;
|
|
||||||
float spot_attenuation;
|
|
||||||
bool has_shadow;
|
|
||||||
bool sky_only;
|
|
||||||
};
|
|
||||||
|
|
||||||
Vector<LightCache> light_cache;
|
|
||||||
Vector<RID> light_instances;
|
|
||||||
|
|
||||||
RID probe_instance;
|
|
||||||
|
|
||||||
bool invalid;
|
|
||||||
uint32_t base_version;
|
|
||||||
|
|
||||||
SelfList<InstanceGIProbeData> update_element;
|
|
||||||
|
|
||||||
InstanceGIProbeData() :
|
|
||||||
update_element(this) {
|
|
||||||
invalid = true;
|
|
||||||
base_version = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SelfList<InstanceGIProbeData>::List gi_probe_update_list;
|
|
||||||
|
|
||||||
struct InstanceLightmapData : public InstanceBaseData {
|
|
||||||
struct PairInfo {
|
|
||||||
List<Instance *>::Element *L; //iterator in geometry
|
|
||||||
Instance *geometry;
|
|
||||||
};
|
|
||||||
List<PairInfo> geometries;
|
|
||||||
|
|
||||||
Set<Instance *> users;
|
|
||||||
|
|
||||||
InstanceLightmapData() {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Set<Instance *> heightfield_particle_colliders_update_list;
|
|
||||||
|
|
||||||
int instance_cull_count;
|
|
||||||
Instance *instance_cull_result[MAX_INSTANCE_CULL];
|
|
||||||
Instance *instance_shadow_cull_result[MAX_INSTANCE_CULL]; //used for generating shadowmaps
|
|
||||||
Instance *light_cull_result[MAX_LIGHTS_CULLED];
|
|
||||||
RID sdfgi_light_cull_result[MAX_LIGHTS_CULLED];
|
|
||||||
RID light_instance_cull_result[MAX_LIGHTS_CULLED];
|
|
||||||
uint64_t sdfgi_light_cull_pass = 0;
|
|
||||||
int light_cull_count;
|
|
||||||
int directional_light_count;
|
|
||||||
RID reflection_probe_instance_cull_result[MAX_REFLECTION_PROBES_CULLED];
|
|
||||||
RID decal_instance_cull_result[MAX_DECALS_CULLED];
|
|
||||||
int reflection_probe_cull_count;
|
|
||||||
int decal_cull_count;
|
|
||||||
RID gi_probe_instance_cull_result[MAX_GI_PROBES_CULLED];
|
|
||||||
int gi_probe_cull_count;
|
|
||||||
Instance *lightmap_cull_result[MAX_LIGHTS_CULLED];
|
|
||||||
int lightmap_cull_count;
|
|
||||||
|
|
||||||
RID_PtrOwner<Instance> instance_owner;
|
|
||||||
|
|
||||||
virtual RID instance_create();
|
|
||||||
|
|
||||||
virtual void instance_set_base(RID p_instance, RID p_base);
|
|
||||||
virtual void instance_set_scenario(RID p_instance, RID p_scenario);
|
|
||||||
virtual void instance_set_layer_mask(RID p_instance, uint32_t p_mask);
|
|
||||||
virtual void instance_set_transform(RID p_instance, const Transform &p_transform);
|
|
||||||
virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id);
|
|
||||||
virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight);
|
|
||||||
virtual void instance_set_surface_material(RID p_instance, int p_surface, RID p_material);
|
|
||||||
virtual void instance_set_visible(RID p_instance, bool p_visible);
|
|
||||||
|
|
||||||
virtual void instance_set_custom_aabb(RID p_instance, AABB p_aabb);
|
|
||||||
|
|
||||||
virtual void instance_attach_skeleton(RID p_instance, RID p_skeleton);
|
|
||||||
virtual void instance_set_exterior(RID p_instance, bool p_enabled);
|
|
||||||
|
|
||||||
virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin);
|
|
||||||
|
|
||||||
// don't use these in a game!
|
// don't use these in a game!
|
||||||
virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const;
|
virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const = 0;
|
||||||
virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const;
|
virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const = 0;
|
||||||
virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const;
|
virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0;
|
||||||
|
|
||||||
virtual void instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled);
|
virtual void instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled) = 0;
|
||||||
virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting);
|
virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting) = 0;
|
||||||
virtual void instance_geometry_set_material_override(RID p_instance, RID p_material);
|
virtual void instance_geometry_set_material_override(RID p_instance, RID p_material) = 0;
|
||||||
|
|
||||||
virtual void instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin);
|
virtual void instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin) = 0;
|
||||||
virtual void instance_geometry_set_as_instance_lod(RID p_instance, RID p_as_lod_of_instance);
|
virtual void instance_geometry_set_as_instance_lod(RID p_instance, RID p_as_lod_of_instance) = 0;
|
||||||
virtual void instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index);
|
virtual void instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index) = 0;
|
||||||
|
|
||||||
void _update_instance_shader_parameters_from_material(Map<StringName, RasterizerScene::InstanceBase::InstanceShaderParameter> &isparams, const Map<StringName, RasterizerScene::InstanceBase::InstanceShaderParameter> &existing_isparams, RID p_material);
|
virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value) = 0;
|
||||||
|
virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const = 0;
|
||||||
|
virtual Variant instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const = 0;
|
||||||
|
virtual Variant instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const = 0;
|
||||||
|
|
||||||
virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value);
|
virtual void directional_shadow_atlas_set_size(int p_size) = 0;
|
||||||
virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const;
|
|
||||||
virtual Variant instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const;
|
|
||||||
virtual Variant instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const;
|
|
||||||
|
|
||||||
_FORCE_INLINE_ void _update_instance(Instance *p_instance);
|
/* SKY API */
|
||||||
_FORCE_INLINE_ void _update_instance_aabb(Instance *p_instance);
|
|
||||||
_FORCE_INLINE_ void _update_dirty_instance(Instance *p_instance);
|
|
||||||
_FORCE_INLINE_ void _update_instance_lightmap_captures(Instance *p_instance);
|
|
||||||
|
|
||||||
_FORCE_INLINE_ bool _light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, bool p_cam_vaspect, RID p_shadow_atlas, Scenario *p_scenario);
|
virtual RID sky_create() = 0;
|
||||||
|
virtual void sky_set_radiance_size(RID p_sky, int p_radiance_size) = 0;
|
||||||
|
virtual void sky_set_mode(RID p_sky, RS::SkyMode p_samples) = 0;
|
||||||
|
virtual void sky_set_material(RID p_sky, RID p_material) = 0;
|
||||||
|
virtual Ref<Image> sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) = 0;
|
||||||
|
|
||||||
RID _render_get_environment(RID p_camera, RID p_scenario);
|
/* ENVIRONMENT API */
|
||||||
|
|
||||||
bool _render_reflection_probe_step(Instance *p_instance, int p_step);
|
virtual RID environment_create() = 0;
|
||||||
void _prepare_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, bool p_cam_vaspect, RID p_render_buffers, RID p_environment, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, bool p_using_shadows = true);
|
|
||||||
void _render_scene(RID p_render_buffers, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_environment, RID p_force_camera_effects, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass);
|
|
||||||
void render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas);
|
|
||||||
|
|
||||||
void render_camera(RID p_render_buffers, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
|
virtual void environment_set_background(RID p_env, RS::EnvironmentBG p_bg) = 0;
|
||||||
void render_camera(RID p_render_buffers, Ref<XRInterface> &p_interface, XRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
|
virtual void environment_set_sky(RID p_env, RID p_sky) = 0;
|
||||||
void update_dirty_instances();
|
virtual void environment_set_sky_custom_fov(RID p_env, float p_scale) = 0;
|
||||||
|
virtual void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) = 0;
|
||||||
|
virtual void environment_set_bg_color(RID p_env, const Color &p_color) = 0;
|
||||||
|
virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0;
|
||||||
|
virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0;
|
||||||
|
virtual void environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient = RS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, RS::EnvironmentReflectionSource p_reflection_source = RS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) = 0;
|
||||||
|
|
||||||
void render_particle_colliders();
|
virtual void environment_set_glow(RID p_env, bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) = 0;
|
||||||
void render_probes();
|
virtual void environment_glow_set_use_bicubic_upscale(bool p_enable) = 0;
|
||||||
|
virtual void environment_glow_set_use_high_quality(bool p_enable) = 0;
|
||||||
|
|
||||||
TypedArray<Image> bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size);
|
virtual void environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, RS::EnvVolumetricFogShadowFilter p_shadow_filter) = 0;
|
||||||
|
|
||||||
bool free(RID p_rid);
|
virtual void environment_set_volumetric_fog_volume_size(int p_size, int p_depth) = 0;
|
||||||
|
virtual void environment_set_volumetric_fog_filter_active(bool p_enable) = 0;
|
||||||
|
virtual void environment_set_volumetric_fog_directional_shadow_shrink_size(int p_shrink_size) = 0;
|
||||||
|
virtual void environment_set_volumetric_fog_positional_shadow_shrink_size(int p_shrink_size) = 0;
|
||||||
|
|
||||||
|
virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) = 0;
|
||||||
|
virtual void environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) = 0;
|
||||||
|
|
||||||
|
virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) = 0;
|
||||||
|
|
||||||
|
virtual void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size) = 0;
|
||||||
|
|
||||||
|
virtual void environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, bool p_use_multibounce, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) = 0;
|
||||||
|
|
||||||
|
virtual void environment_set_sdfgi_ray_count(RS::EnvironmentSDFGIRayCount p_ray_count) = 0;
|
||||||
|
virtual void environment_set_sdfgi_frames_to_converge(RS::EnvironmentSDFGIFramesToConverge p_frames) = 0;
|
||||||
|
|
||||||
|
virtual void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) = 0;
|
||||||
|
|
||||||
|
virtual void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) = 0;
|
||||||
|
|
||||||
|
virtual void environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_aerial_perspective) = 0;
|
||||||
|
|
||||||
|
virtual Ref<Image> environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) = 0;
|
||||||
|
|
||||||
|
virtual RS::EnvironmentBG environment_get_background(RID p_Env) const = 0;
|
||||||
|
virtual int environment_get_canvas_max_layer(RID p_env) const = 0;
|
||||||
|
|
||||||
|
virtual bool is_environment(RID p_environment) const = 0;
|
||||||
|
|
||||||
|
virtual void screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_limit) = 0;
|
||||||
|
virtual void sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) = 0;
|
||||||
|
virtual void sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) = 0;
|
||||||
|
|
||||||
|
/* Camera Effects */
|
||||||
|
|
||||||
|
virtual RID camera_effects_create() = 0;
|
||||||
|
|
||||||
|
virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) = 0;
|
||||||
|
virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) = 0;
|
||||||
|
|
||||||
|
virtual void camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) = 0;
|
||||||
|
virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) = 0;
|
||||||
|
|
||||||
|
virtual void shadows_quality_set(RS::ShadowQuality p_quality) = 0;
|
||||||
|
virtual void directional_shadow_quality_set(RS::ShadowQuality p_quality) = 0;
|
||||||
|
|
||||||
|
virtual RID shadow_atlas_create() = 0;
|
||||||
|
virtual void shadow_atlas_set_size(RID p_atlas, int p_size) = 0;
|
||||||
|
virtual void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) = 0;
|
||||||
|
|
||||||
|
/* Render Buffers */
|
||||||
|
|
||||||
|
virtual RID render_buffers_create() = 0;
|
||||||
|
virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding) = 0;
|
||||||
|
|
||||||
|
virtual void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) = 0;
|
||||||
|
|
||||||
|
virtual TypedArray<Image> bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) = 0;
|
||||||
|
virtual void gi_probe_set_quality(RS::GIProbeQuality) = 0;
|
||||||
|
|
||||||
|
virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) = 0;
|
||||||
|
|
||||||
|
virtual void render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas) = 0;
|
||||||
|
virtual void render_camera(RID p_render_buffers, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) = 0;
|
||||||
|
virtual void render_camera(RID p_render_buffers, Ref<XRInterface> &p_interface, XRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) = 0;
|
||||||
|
|
||||||
|
virtual void update() = 0;
|
||||||
|
virtual void render_probes() = 0;
|
||||||
|
|
||||||
|
virtual bool free(RID p_rid) = 0;
|
||||||
|
|
||||||
RenderingServerScene();
|
RenderingServerScene();
|
||||||
virtual ~RenderingServerScene();
|
virtual ~RenderingServerScene();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISUALSERVERSCENE_H
|
#endif // RENDERINGSERVERSCENE_H
|
||||||
|
3072
servers/rendering/rendering_server_scene_raster.cpp
Normal file
3072
servers/rendering/rendering_server_scene_raster.cpp
Normal file
File diff suppressed because it is too large
Load Diff
582
servers/rendering/rendering_server_scene_raster.h
Normal file
582
servers/rendering/rendering_server_scene_raster.h
Normal file
@ -0,0 +1,582 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* rendering_server_scene_raster.h */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||||
|
/* */
|
||||||
|
/* 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. */
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef RENDERING_SERVER_SCENE_RASTER_H
|
||||||
|
#define RENDERING_SERVER_SCENE_RASTER_H
|
||||||
|
|
||||||
|
#include "core/templates/pass_func.h"
|
||||||
|
#include "servers/rendering/rasterizer.h"
|
||||||
|
|
||||||
|
#include "core/math/geometry_3d.h"
|
||||||
|
#include "core/math/octree.h"
|
||||||
|
#include "core/os/semaphore.h"
|
||||||
|
#include "core/os/thread.h"
|
||||||
|
#include "core/templates/local_vector.h"
|
||||||
|
#include "core/templates/rid_owner.h"
|
||||||
|
#include "core/templates/self_list.h"
|
||||||
|
#include "servers/rendering/rendering_server_scene.h"
|
||||||
|
#include "servers/xr/xr_interface.h"
|
||||||
|
|
||||||
|
class RenderingServerSceneRaster : public RenderingServerScene {
|
||||||
|
public:
|
||||||
|
RasterizerScene *scene_render;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MAX_INSTANCE_CULL = 65536,
|
||||||
|
MAX_LIGHTS_CULLED = 4096,
|
||||||
|
MAX_REFLECTION_PROBES_CULLED = 4096,
|
||||||
|
MAX_DECALS_CULLED = 4096,
|
||||||
|
MAX_GI_PROBES_CULLED = 4096,
|
||||||
|
MAX_ROOM_CULL = 32,
|
||||||
|
MAX_LIGHTMAPS_CULLED = 4096,
|
||||||
|
MAX_EXTERIOR_PORTALS = 128,
|
||||||
|
};
|
||||||
|
|
||||||
|
uint64_t render_pass;
|
||||||
|
|
||||||
|
static RenderingServerSceneRaster *singleton;
|
||||||
|
|
||||||
|
/* CAMERA API */
|
||||||
|
|
||||||
|
struct Camera {
|
||||||
|
enum Type {
|
||||||
|
PERSPECTIVE,
|
||||||
|
ORTHOGONAL,
|
||||||
|
FRUSTUM
|
||||||
|
};
|
||||||
|
Type type;
|
||||||
|
float fov;
|
||||||
|
float znear, zfar;
|
||||||
|
float size;
|
||||||
|
Vector2 offset;
|
||||||
|
uint32_t visible_layers;
|
||||||
|
bool vaspect;
|
||||||
|
RID env;
|
||||||
|
RID effects;
|
||||||
|
|
||||||
|
Transform transform;
|
||||||
|
|
||||||
|
Camera() {
|
||||||
|
visible_layers = 0xFFFFFFFF;
|
||||||
|
fov = 75;
|
||||||
|
type = PERSPECTIVE;
|
||||||
|
znear = 0.05;
|
||||||
|
zfar = 100;
|
||||||
|
size = 1.0;
|
||||||
|
offset = Vector2();
|
||||||
|
vaspect = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mutable RID_PtrOwner<Camera> camera_owner;
|
||||||
|
|
||||||
|
virtual RID camera_create();
|
||||||
|
virtual void camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far);
|
||||||
|
virtual void camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far);
|
||||||
|
virtual void camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far);
|
||||||
|
virtual void camera_set_transform(RID p_camera, const Transform &p_transform);
|
||||||
|
virtual void camera_set_cull_mask(RID p_camera, uint32_t p_layers);
|
||||||
|
virtual void camera_set_environment(RID p_camera, RID p_env);
|
||||||
|
virtual void camera_set_camera_effects(RID p_camera, RID p_fx);
|
||||||
|
virtual void camera_set_use_vertical_aspect(RID p_camera, bool p_enable);
|
||||||
|
virtual bool is_camera(RID p_camera) const;
|
||||||
|
|
||||||
|
/* SCENARIO API */
|
||||||
|
|
||||||
|
struct Instance;
|
||||||
|
|
||||||
|
struct Scenario {
|
||||||
|
RS::ScenarioDebugMode debug;
|
||||||
|
RID self;
|
||||||
|
|
||||||
|
Octree<Instance, true> octree;
|
||||||
|
|
||||||
|
List<Instance *> directional_lights;
|
||||||
|
RID environment;
|
||||||
|
RID fallback_environment;
|
||||||
|
RID camera_effects;
|
||||||
|
RID reflection_probe_shadow_atlas;
|
||||||
|
RID reflection_atlas;
|
||||||
|
|
||||||
|
SelfList<Instance>::List instances;
|
||||||
|
|
||||||
|
LocalVector<RID> dynamic_lights;
|
||||||
|
|
||||||
|
Scenario() { debug = RS::SCENARIO_DEBUG_DISABLED; }
|
||||||
|
};
|
||||||
|
|
||||||
|
mutable RID_PtrOwner<Scenario> scenario_owner;
|
||||||
|
|
||||||
|
static void *_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int);
|
||||||
|
static void _instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *);
|
||||||
|
|
||||||
|
virtual RID scenario_create();
|
||||||
|
|
||||||
|
virtual void scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode);
|
||||||
|
virtual void scenario_set_environment(RID p_scenario, RID p_environment);
|
||||||
|
virtual void scenario_set_camera_effects(RID p_scenario, RID p_fx);
|
||||||
|
virtual void scenario_set_fallback_environment(RID p_scenario, RID p_environment);
|
||||||
|
virtual void scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count);
|
||||||
|
virtual bool is_scenario(RID p_scenario) const;
|
||||||
|
virtual RID scenario_get_environment(RID p_scenario);
|
||||||
|
|
||||||
|
/* INSTANCING API */
|
||||||
|
|
||||||
|
struct InstanceBaseData {
|
||||||
|
virtual ~InstanceBaseData() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Instance : RasterizerScene::InstanceBase {
|
||||||
|
RID self;
|
||||||
|
//scenario stuff
|
||||||
|
OctreeElementID octree_id;
|
||||||
|
Scenario *scenario;
|
||||||
|
SelfList<Instance> scenario_item;
|
||||||
|
|
||||||
|
//aabb stuff
|
||||||
|
bool update_aabb;
|
||||||
|
bool update_dependencies;
|
||||||
|
|
||||||
|
SelfList<Instance> update_item;
|
||||||
|
|
||||||
|
AABB *custom_aabb; // <Zylann> would using aabb directly with a bool be better?
|
||||||
|
float extra_margin;
|
||||||
|
ObjectID object_id;
|
||||||
|
|
||||||
|
float lod_begin;
|
||||||
|
float lod_end;
|
||||||
|
float lod_begin_hysteresis;
|
||||||
|
float lod_end_hysteresis;
|
||||||
|
RID lod_instance;
|
||||||
|
|
||||||
|
Vector<Color> lightmap_target_sh; //target is used for incrementally changing the SH over time, this avoids pops in some corner cases and when going interior <-> exterior
|
||||||
|
|
||||||
|
uint64_t last_render_pass;
|
||||||
|
uint64_t last_frame_pass;
|
||||||
|
|
||||||
|
uint64_t version; // changes to this, and changes to base increase version
|
||||||
|
|
||||||
|
InstanceBaseData *base_data;
|
||||||
|
|
||||||
|
virtual void dependency_deleted(RID p_dependency) {
|
||||||
|
if (p_dependency == base) {
|
||||||
|
singleton->instance_set_base(self, RID());
|
||||||
|
} else if (p_dependency == skeleton) {
|
||||||
|
singleton->instance_attach_skeleton(self, RID());
|
||||||
|
} else {
|
||||||
|
singleton->_instance_queue_update(this, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void dependency_changed(bool p_aabb, bool p_dependencies) {
|
||||||
|
singleton->_instance_queue_update(this, p_aabb, p_dependencies);
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance() :
|
||||||
|
scenario_item(this),
|
||||||
|
update_item(this) {
|
||||||
|
octree_id = 0;
|
||||||
|
scenario = nullptr;
|
||||||
|
|
||||||
|
update_aabb = false;
|
||||||
|
update_dependencies = false;
|
||||||
|
|
||||||
|
extra_margin = 0;
|
||||||
|
|
||||||
|
visible = true;
|
||||||
|
|
||||||
|
lod_begin = 0;
|
||||||
|
lod_end = 0;
|
||||||
|
lod_begin_hysteresis = 0;
|
||||||
|
lod_end_hysteresis = 0;
|
||||||
|
|
||||||
|
last_render_pass = 0;
|
||||||
|
last_frame_pass = 0;
|
||||||
|
version = 1;
|
||||||
|
base_data = nullptr;
|
||||||
|
|
||||||
|
custom_aabb = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
~Instance() {
|
||||||
|
if (base_data) {
|
||||||
|
memdelete(base_data);
|
||||||
|
}
|
||||||
|
if (custom_aabb) {
|
||||||
|
memdelete(custom_aabb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SelfList<Instance>::List _instance_update_list;
|
||||||
|
void _instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_dependencies = false);
|
||||||
|
|
||||||
|
struct InstanceGeometryData : public InstanceBaseData {
|
||||||
|
List<Instance *> lighting;
|
||||||
|
bool lighting_dirty;
|
||||||
|
bool can_cast_shadows;
|
||||||
|
bool material_is_animated;
|
||||||
|
|
||||||
|
List<Instance *> decals;
|
||||||
|
bool decal_dirty;
|
||||||
|
|
||||||
|
List<Instance *> reflection_probes;
|
||||||
|
bool reflection_dirty;
|
||||||
|
|
||||||
|
List<Instance *> gi_probes;
|
||||||
|
bool gi_probes_dirty;
|
||||||
|
|
||||||
|
List<Instance *> lightmap_captures;
|
||||||
|
|
||||||
|
InstanceGeometryData() {
|
||||||
|
lighting_dirty = false;
|
||||||
|
reflection_dirty = true;
|
||||||
|
can_cast_shadows = true;
|
||||||
|
material_is_animated = true;
|
||||||
|
gi_probes_dirty = true;
|
||||||
|
decal_dirty = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct InstanceReflectionProbeData : public InstanceBaseData {
|
||||||
|
Instance *owner;
|
||||||
|
|
||||||
|
struct PairInfo {
|
||||||
|
List<Instance *>::Element *L; //reflection iterator in geometry
|
||||||
|
Instance *geometry;
|
||||||
|
};
|
||||||
|
List<PairInfo> geometries;
|
||||||
|
|
||||||
|
RID instance;
|
||||||
|
bool reflection_dirty;
|
||||||
|
SelfList<InstanceReflectionProbeData> update_list;
|
||||||
|
|
||||||
|
int render_step;
|
||||||
|
|
||||||
|
InstanceReflectionProbeData() :
|
||||||
|
update_list(this) {
|
||||||
|
reflection_dirty = true;
|
||||||
|
render_step = -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct InstanceDecalData : public InstanceBaseData {
|
||||||
|
Instance *owner;
|
||||||
|
RID instance;
|
||||||
|
|
||||||
|
struct PairInfo {
|
||||||
|
List<Instance *>::Element *L; //reflection iterator in geometry
|
||||||
|
Instance *geometry;
|
||||||
|
};
|
||||||
|
List<PairInfo> geometries;
|
||||||
|
|
||||||
|
InstanceDecalData() {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SelfList<InstanceReflectionProbeData>::List reflection_probe_render_list;
|
||||||
|
|
||||||
|
struct InstanceLightData : public InstanceBaseData {
|
||||||
|
struct PairInfo {
|
||||||
|
List<Instance *>::Element *L; //light iterator in geometry
|
||||||
|
Instance *geometry;
|
||||||
|
};
|
||||||
|
|
||||||
|
RID instance;
|
||||||
|
uint64_t last_version;
|
||||||
|
List<Instance *>::Element *D; // directional light in scenario
|
||||||
|
|
||||||
|
bool shadow_dirty;
|
||||||
|
|
||||||
|
List<PairInfo> geometries;
|
||||||
|
|
||||||
|
Instance *baked_light;
|
||||||
|
|
||||||
|
RS::LightBakeMode bake_mode;
|
||||||
|
uint32_t max_sdfgi_cascade = 2;
|
||||||
|
|
||||||
|
uint64_t sdfgi_cascade_light_pass = 0;
|
||||||
|
|
||||||
|
InstanceLightData() {
|
||||||
|
bake_mode = RS::LIGHT_BAKE_DISABLED;
|
||||||
|
shadow_dirty = true;
|
||||||
|
D = nullptr;
|
||||||
|
last_version = 0;
|
||||||
|
baked_light = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct InstanceGIProbeData : public InstanceBaseData {
|
||||||
|
Instance *owner;
|
||||||
|
|
||||||
|
struct PairInfo {
|
||||||
|
List<Instance *>::Element *L; //gi probe iterator in geometry
|
||||||
|
Instance *geometry;
|
||||||
|
};
|
||||||
|
|
||||||
|
List<PairInfo> geometries;
|
||||||
|
List<PairInfo> dynamic_geometries;
|
||||||
|
|
||||||
|
Set<Instance *> lights;
|
||||||
|
|
||||||
|
struct LightCache {
|
||||||
|
RS::LightType type;
|
||||||
|
Transform transform;
|
||||||
|
Color color;
|
||||||
|
float energy;
|
||||||
|
float bake_energy;
|
||||||
|
float radius;
|
||||||
|
float attenuation;
|
||||||
|
float spot_angle;
|
||||||
|
float spot_attenuation;
|
||||||
|
bool has_shadow;
|
||||||
|
bool sky_only;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector<LightCache> light_cache;
|
||||||
|
Vector<RID> light_instances;
|
||||||
|
|
||||||
|
RID probe_instance;
|
||||||
|
|
||||||
|
bool invalid;
|
||||||
|
uint32_t base_version;
|
||||||
|
|
||||||
|
SelfList<InstanceGIProbeData> update_element;
|
||||||
|
|
||||||
|
InstanceGIProbeData() :
|
||||||
|
update_element(this) {
|
||||||
|
invalid = true;
|
||||||
|
base_version = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SelfList<InstanceGIProbeData>::List gi_probe_update_list;
|
||||||
|
|
||||||
|
struct InstanceLightmapData : public InstanceBaseData {
|
||||||
|
struct PairInfo {
|
||||||
|
List<Instance *>::Element *L; //iterator in geometry
|
||||||
|
Instance *geometry;
|
||||||
|
};
|
||||||
|
List<PairInfo> geometries;
|
||||||
|
|
||||||
|
Set<Instance *> users;
|
||||||
|
|
||||||
|
InstanceLightmapData() {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Set<Instance *> heightfield_particle_colliders_update_list;
|
||||||
|
|
||||||
|
int instance_cull_count;
|
||||||
|
Instance *instance_cull_result[MAX_INSTANCE_CULL];
|
||||||
|
Instance *instance_shadow_cull_result[MAX_INSTANCE_CULL]; //used for generating shadowmaps
|
||||||
|
Instance *light_cull_result[MAX_LIGHTS_CULLED];
|
||||||
|
RID sdfgi_light_cull_result[MAX_LIGHTS_CULLED];
|
||||||
|
RID light_instance_cull_result[MAX_LIGHTS_CULLED];
|
||||||
|
uint64_t sdfgi_light_cull_pass = 0;
|
||||||
|
int light_cull_count;
|
||||||
|
int directional_light_count;
|
||||||
|
RID reflection_probe_instance_cull_result[MAX_REFLECTION_PROBES_CULLED];
|
||||||
|
RID decal_instance_cull_result[MAX_DECALS_CULLED];
|
||||||
|
int reflection_probe_cull_count;
|
||||||
|
int decal_cull_count;
|
||||||
|
RID gi_probe_instance_cull_result[MAX_GI_PROBES_CULLED];
|
||||||
|
int gi_probe_cull_count;
|
||||||
|
Instance *lightmap_cull_result[MAX_LIGHTS_CULLED];
|
||||||
|
int lightmap_cull_count;
|
||||||
|
|
||||||
|
RID_PtrOwner<Instance> instance_owner;
|
||||||
|
|
||||||
|
virtual RID instance_create();
|
||||||
|
|
||||||
|
virtual void instance_set_base(RID p_instance, RID p_base);
|
||||||
|
virtual void instance_set_scenario(RID p_instance, RID p_scenario);
|
||||||
|
virtual void instance_set_layer_mask(RID p_instance, uint32_t p_mask);
|
||||||
|
virtual void instance_set_transform(RID p_instance, const Transform &p_transform);
|
||||||
|
virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id);
|
||||||
|
virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight);
|
||||||
|
virtual void instance_set_surface_material(RID p_instance, int p_surface, RID p_material);
|
||||||
|
virtual void instance_set_visible(RID p_instance, bool p_visible);
|
||||||
|
|
||||||
|
virtual void instance_set_custom_aabb(RID p_instance, AABB p_aabb);
|
||||||
|
|
||||||
|
virtual void instance_attach_skeleton(RID p_instance, RID p_skeleton);
|
||||||
|
virtual void instance_set_exterior(RID p_instance, bool p_enabled);
|
||||||
|
|
||||||
|
virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin);
|
||||||
|
|
||||||
|
// don't use these in a game!
|
||||||
|
virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const;
|
||||||
|
virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const;
|
||||||
|
virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const;
|
||||||
|
|
||||||
|
virtual void instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled);
|
||||||
|
virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting);
|
||||||
|
virtual void instance_geometry_set_material_override(RID p_instance, RID p_material);
|
||||||
|
|
||||||
|
virtual void instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin);
|
||||||
|
virtual void instance_geometry_set_as_instance_lod(RID p_instance, RID p_as_lod_of_instance);
|
||||||
|
virtual void instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index);
|
||||||
|
|
||||||
|
void _update_instance_shader_parameters_from_material(Map<StringName, RasterizerScene::InstanceBase::InstanceShaderParameter> &isparams, const Map<StringName, RasterizerScene::InstanceBase::InstanceShaderParameter> &existing_isparams, RID p_material);
|
||||||
|
|
||||||
|
virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value);
|
||||||
|
virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const;
|
||||||
|
virtual Variant instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const;
|
||||||
|
virtual Variant instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const;
|
||||||
|
|
||||||
|
_FORCE_INLINE_ void _update_instance(Instance *p_instance);
|
||||||
|
_FORCE_INLINE_ void _update_instance_aabb(Instance *p_instance);
|
||||||
|
_FORCE_INLINE_ void _update_dirty_instance(Instance *p_instance);
|
||||||
|
_FORCE_INLINE_ void _update_instance_lightmap_captures(Instance *p_instance);
|
||||||
|
|
||||||
|
_FORCE_INLINE_ bool _light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, bool p_cam_vaspect, RID p_shadow_atlas, Scenario *p_scenario);
|
||||||
|
|
||||||
|
RID _render_get_environment(RID p_camera, RID p_scenario);
|
||||||
|
|
||||||
|
bool _render_reflection_probe_step(Instance *p_instance, int p_step);
|
||||||
|
void _prepare_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, bool p_cam_vaspect, RID p_render_buffers, RID p_environment, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, bool p_using_shadows = true);
|
||||||
|
void _render_scene(RID p_render_buffers, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_environment, RID p_force_camera_effects, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass);
|
||||||
|
void render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas);
|
||||||
|
|
||||||
|
void render_camera(RID p_render_buffers, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
|
||||||
|
void render_camera(RID p_render_buffers, Ref<XRInterface> &p_interface, XRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
|
||||||
|
void update_dirty_instances();
|
||||||
|
|
||||||
|
void render_particle_colliders();
|
||||||
|
virtual void render_probes();
|
||||||
|
|
||||||
|
TypedArray<Image> bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size);
|
||||||
|
|
||||||
|
//pass to scene render
|
||||||
|
|
||||||
|
/* ENVIRONMENT API */
|
||||||
|
|
||||||
|
#ifdef PASSBASE
|
||||||
|
#undef PASSBASE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PASSBASE scene_render
|
||||||
|
|
||||||
|
PASS1(directional_shadow_atlas_set_size, int)
|
||||||
|
PASS1(gi_probe_set_quality, RS::GIProbeQuality)
|
||||||
|
|
||||||
|
/* SKY API */
|
||||||
|
|
||||||
|
PASS0R(RID, sky_create)
|
||||||
|
PASS2(sky_set_radiance_size, RID, int)
|
||||||
|
PASS2(sky_set_mode, RID, RS::SkyMode)
|
||||||
|
PASS2(sky_set_material, RID, RID)
|
||||||
|
PASS4R(Ref<Image>, sky_bake_panorama, RID, float, bool, const Size2i &)
|
||||||
|
|
||||||
|
PASS0R(RID, environment_create)
|
||||||
|
|
||||||
|
PASS1RC(bool, is_environment, RID)
|
||||||
|
|
||||||
|
PASS2(environment_set_background, RID, RS::EnvironmentBG)
|
||||||
|
PASS2(environment_set_sky, RID, RID)
|
||||||
|
PASS2(environment_set_sky_custom_fov, RID, float)
|
||||||
|
PASS2(environment_set_sky_orientation, RID, const Basis &)
|
||||||
|
PASS2(environment_set_bg_color, RID, const Color &)
|
||||||
|
PASS2(environment_set_bg_energy, RID, float)
|
||||||
|
PASS2(environment_set_canvas_max_layer, RID, int)
|
||||||
|
PASS7(environment_set_ambient_light, RID, const Color &, RS::EnvironmentAmbientSource, float, float, RS::EnvironmentReflectionSource, const Color &)
|
||||||
|
|
||||||
|
PASS6(environment_set_ssr, RID, bool, int, float, float, float)
|
||||||
|
PASS1(environment_set_ssr_roughness_quality, RS::EnvironmentSSRRoughnessQuality)
|
||||||
|
|
||||||
|
PASS9(environment_set_ssao, RID, bool, float, float, float, float, float, RS::EnvironmentSSAOBlur, float)
|
||||||
|
PASS2(environment_set_ssao_quality, RS::EnvironmentSSAOQuality, bool)
|
||||||
|
|
||||||
|
PASS11(environment_set_glow, RID, bool, Vector<float>, float, float, float, float, RS::EnvironmentGlowBlendMode, float, float, float)
|
||||||
|
PASS1(environment_glow_set_use_bicubic_upscale, bool)
|
||||||
|
PASS1(environment_glow_set_use_high_quality, bool)
|
||||||
|
|
||||||
|
PASS9(environment_set_tonemap, RID, RS::EnvironmentToneMapper, float, float, bool, float, float, float, float)
|
||||||
|
|
||||||
|
PASS7(environment_set_adjustment, RID, bool, float, float, float, bool, RID)
|
||||||
|
|
||||||
|
PASS9(environment_set_fog, RID, bool, const Color &, float, float, float, float, float, float)
|
||||||
|
PASS9(environment_set_volumetric_fog, RID, bool, float, const Color &, float, float, float, float, RS::EnvVolumetricFogShadowFilter)
|
||||||
|
|
||||||
|
PASS2(environment_set_volumetric_fog_volume_size, int, int)
|
||||||
|
PASS1(environment_set_volumetric_fog_filter_active, bool)
|
||||||
|
PASS1(environment_set_volumetric_fog_directional_shadow_shrink_size, int)
|
||||||
|
PASS1(environment_set_volumetric_fog_positional_shadow_shrink_size, int)
|
||||||
|
|
||||||
|
PASS11(environment_set_sdfgi, RID, bool, RS::EnvironmentSDFGICascades, float, RS::EnvironmentSDFGIYScale, bool, bool, bool, float, float, float)
|
||||||
|
PASS1(environment_set_sdfgi_ray_count, RS::EnvironmentSDFGIRayCount)
|
||||||
|
PASS1(environment_set_sdfgi_frames_to_converge, RS::EnvironmentSDFGIFramesToConverge)
|
||||||
|
|
||||||
|
PASS1RC(RS::EnvironmentBG, environment_get_background, RID)
|
||||||
|
PASS1RC(int, environment_get_canvas_max_layer, RID)
|
||||||
|
|
||||||
|
PASS3R(Ref<Image>, environment_bake_panorama, RID, bool, const Size2i &)
|
||||||
|
|
||||||
|
PASS3(screen_space_roughness_limiter_set_active, bool, float, float)
|
||||||
|
PASS1(sub_surface_scattering_set_quality, RS::SubSurfaceScatteringQuality)
|
||||||
|
PASS2(sub_surface_scattering_set_scale, float, float)
|
||||||
|
|
||||||
|
/* CAMERA EFFECTS */
|
||||||
|
|
||||||
|
PASS0R(RID, camera_effects_create)
|
||||||
|
|
||||||
|
PASS2(camera_effects_set_dof_blur_quality, RS::DOFBlurQuality, bool)
|
||||||
|
PASS1(camera_effects_set_dof_blur_bokeh_shape, RS::DOFBokehShape)
|
||||||
|
|
||||||
|
PASS8(camera_effects_set_dof_blur, RID, bool, float, float, bool, float, float, float)
|
||||||
|
PASS3(camera_effects_set_custom_exposure, RID, bool, float)
|
||||||
|
|
||||||
|
PASS1(shadows_quality_set, RS::ShadowQuality)
|
||||||
|
PASS1(directional_shadow_quality_set, RS::ShadowQuality)
|
||||||
|
|
||||||
|
PASS2(sdfgi_set_debug_probe_select, const Vector3 &, const Vector3 &)
|
||||||
|
|
||||||
|
/* Render Buffers */
|
||||||
|
|
||||||
|
PASS0R(RID, render_buffers_create)
|
||||||
|
PASS7(render_buffers_configure, RID, RID, int, int, RS::ViewportMSAA, RS::ViewportScreenSpaceAA, bool)
|
||||||
|
|
||||||
|
/* Shadow Atlas */
|
||||||
|
PASS0R(RID, shadow_atlas_create)
|
||||||
|
PASS2(shadow_atlas_set_size, RID, int)
|
||||||
|
PASS3(shadow_atlas_set_quadrant_subdivision, RID, int, int)
|
||||||
|
|
||||||
|
PASS1(set_debug_draw_mode, RS::ViewportDebugDraw)
|
||||||
|
|
||||||
|
virtual void update();
|
||||||
|
|
||||||
|
bool free(RID p_rid);
|
||||||
|
|
||||||
|
RenderingServerSceneRaster();
|
||||||
|
virtual ~RenderingServerSceneRaster();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VISUALSERVERSCENE_H
|
@ -33,7 +33,7 @@
|
|||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
#include "rendering_server_canvas.h"
|
#include "rendering_server_canvas.h"
|
||||||
#include "rendering_server_globals.h"
|
#include "rendering_server_globals.h"
|
||||||
#include "rendering_server_scene.h"
|
#include "rendering_server_scene_raster.h"
|
||||||
|
|
||||||
static Transform2D _canvas_get_transform(RenderingServerViewport::Viewport *p_viewport, RenderingServerCanvas::Canvas *p_canvas, RenderingServerViewport::Viewport::CanvasData *p_canvas_data, const Vector2 &p_vp_size) {
|
static Transform2D _canvas_get_transform(RenderingServerViewport::Viewport *p_viewport, RenderingServerCanvas::Canvas *p_canvas, RenderingServerViewport::Viewport::CanvasData *p_canvas_data, const Vector2 &p_vp_size) {
|
||||||
Transform2D xf = p_viewport->global_transform;
|
Transform2D xf = p_viewport->global_transform;
|
||||||
@ -101,17 +101,15 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
|
|||||||
|
|
||||||
Color bgcolor = RSG::storage->get_default_clear_color();
|
Color bgcolor = RSG::storage->get_default_clear_color();
|
||||||
|
|
||||||
if (!p_viewport->hide_canvas && !p_viewport->disable_environment && RSG::scene->scenario_owner.owns(p_viewport->scenario)) {
|
if (!p_viewport->hide_canvas && !p_viewport->disable_environment && RSG::scene->is_scenario(p_viewport->scenario)) {
|
||||||
RenderingServerScene::Scenario *scenario = RSG::scene->scenario_owner.getornull(p_viewport->scenario);
|
RID environment = RSG::scene->scenario_get_environment(p_viewport->scenario);
|
||||||
ERR_FAIL_COND(!scenario);
|
if (RSG::scene->is_environment(environment)) {
|
||||||
if (RSG::scene_render->is_environment(scenario->environment)) {
|
scenario_draw_canvas_bg = RSG::scene->environment_get_background(environment) == RS::ENV_BG_CANVAS;
|
||||||
scenario_draw_canvas_bg = RSG::scene_render->environment_get_background(scenario->environment) == RS::ENV_BG_CANVAS;
|
scenario_canvas_max_layer = RSG::scene->environment_get_canvas_max_layer(environment);
|
||||||
|
|
||||||
scenario_canvas_max_layer = RSG::scene_render->environment_get_canvas_max_layer(scenario->environment);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool can_draw_3d = RSG::scene->camera_owner.owns(p_viewport->camera);
|
bool can_draw_3d = RSG::scene->is_camera(p_viewport->camera);
|
||||||
|
|
||||||
if (p_viewport->clear_mode != RS::VIEWPORT_CLEAR_NEVER) {
|
if (p_viewport->clear_mode != RS::VIEWPORT_CLEAR_NEVER) {
|
||||||
if (p_viewport->transparent_bg) {
|
if (p_viewport->transparent_bg) {
|
||||||
@ -124,8 +122,8 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
|
|||||||
|
|
||||||
if ((scenario_draw_canvas_bg || can_draw_3d) && !p_viewport->render_buffers.is_valid()) {
|
if ((scenario_draw_canvas_bg || can_draw_3d) && !p_viewport->render_buffers.is_valid()) {
|
||||||
//wants to draw 3D but there is no render buffer, create
|
//wants to draw 3D but there is no render buffer, create
|
||||||
p_viewport->render_buffers = RSG::scene_render->render_buffers_create();
|
p_viewport->render_buffers = RSG::scene->render_buffers_create();
|
||||||
RSG::scene_render->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, p_viewport->size.width, p_viewport->size.height, p_viewport->msaa, p_viewport->screen_space_aa, p_viewport->use_debanding);
|
RSG::scene->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, p_viewport->size.width, p_viewport->size.height, p_viewport->msaa, p_viewport->screen_space_aa, p_viewport->use_debanding);
|
||||||
}
|
}
|
||||||
|
|
||||||
RSG::storage->render_target_request_clear(p_viewport->render_target, bgcolor);
|
RSG::storage->render_target_request_clear(p_viewport->render_target, bgcolor);
|
||||||
@ -559,7 +557,7 @@ void RenderingServerViewport::draw_viewports() {
|
|||||||
{
|
{
|
||||||
RSG::storage->render_target_set_external_texture(vp->render_target, 0);
|
RSG::storage->render_target_set_external_texture(vp->render_target, 0);
|
||||||
|
|
||||||
RSG::scene_render->set_debug_draw_mode(vp->debug_draw);
|
RSG::scene->set_debug_draw_mode(vp->debug_draw);
|
||||||
RSG::storage->render_info_begin_capture();
|
RSG::storage->render_info_begin_capture();
|
||||||
|
|
||||||
// render standard mono camera
|
// render standard mono camera
|
||||||
@ -598,7 +596,7 @@ void RenderingServerViewport::draw_viewports() {
|
|||||||
|
|
||||||
RENDER_TIMESTAMP("<Rendering Viewport " + itos(i));
|
RENDER_TIMESTAMP("<Rendering Viewport " + itos(i));
|
||||||
}
|
}
|
||||||
RSG::scene_render->set_debug_draw_mode(RS::VIEWPORT_DEBUG_DRAW_DISABLED);
|
RSG::scene->set_debug_draw_mode(RS::VIEWPORT_DEBUG_DRAW_DISABLED);
|
||||||
|
|
||||||
RENDER_TIMESTAMP("<Render Viewports");
|
RENDER_TIMESTAMP("<Render Viewports");
|
||||||
//this needs to be called to make screen swapping more efficient
|
//this needs to be called to make screen swapping more efficient
|
||||||
@ -618,7 +616,7 @@ RID RenderingServerViewport::viewport_create() {
|
|||||||
viewport->hide_scenario = false;
|
viewport->hide_scenario = false;
|
||||||
viewport->hide_canvas = false;
|
viewport->hide_canvas = false;
|
||||||
viewport->render_target = RSG::storage->render_target_create();
|
viewport->render_target = RSG::storage->render_target_create();
|
||||||
viewport->shadow_atlas = RSG::scene_render->shadow_atlas_create();
|
viewport->shadow_atlas = RSG::scene->shadow_atlas_create();
|
||||||
viewport->viewport_render_direct_to_screen = false;
|
viewport->viewport_render_direct_to_screen = false;
|
||||||
|
|
||||||
return rid;
|
return rid;
|
||||||
@ -641,10 +639,10 @@ void RenderingServerViewport::viewport_set_size(RID p_viewport, int p_width, int
|
|||||||
RSG::storage->render_target_set_size(viewport->render_target, p_width, p_height);
|
RSG::storage->render_target_set_size(viewport->render_target, p_width, p_height);
|
||||||
if (viewport->render_buffers.is_valid()) {
|
if (viewport->render_buffers.is_valid()) {
|
||||||
if (p_width == 0 || p_height == 0) {
|
if (p_width == 0 || p_height == 0) {
|
||||||
RSG::scene_render->free(viewport->render_buffers);
|
RSG::scene->free(viewport->render_buffers);
|
||||||
viewport->render_buffers = RID();
|
viewport->render_buffers = RID();
|
||||||
} else {
|
} else {
|
||||||
RSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, viewport->msaa, viewport->screen_space_aa, viewport->use_debanding);
|
RSG::scene->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, viewport->msaa, viewport->screen_space_aa, viewport->use_debanding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -838,14 +836,14 @@ void RenderingServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int
|
|||||||
|
|
||||||
viewport->shadow_atlas_size = p_size;
|
viewport->shadow_atlas_size = p_size;
|
||||||
|
|
||||||
RSG::scene_render->shadow_atlas_set_size(viewport->shadow_atlas, viewport->shadow_atlas_size);
|
RSG::scene->shadow_atlas_set_size(viewport->shadow_atlas, viewport->shadow_atlas_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) {
|
void RenderingServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) {
|
||||||
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
||||||
ERR_FAIL_COND(!viewport);
|
ERR_FAIL_COND(!viewport);
|
||||||
|
|
||||||
RSG::scene_render->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv);
|
RSG::scene->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingServerViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa) {
|
void RenderingServerViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa) {
|
||||||
@ -857,7 +855,7 @@ void RenderingServerViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA
|
|||||||
}
|
}
|
||||||
viewport->msaa = p_msaa;
|
viewport->msaa = p_msaa;
|
||||||
if (viewport->render_buffers.is_valid()) {
|
if (viewport->render_buffers.is_valid()) {
|
||||||
RSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, p_msaa, viewport->screen_space_aa, viewport->use_debanding);
|
RSG::scene->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, p_msaa, viewport->screen_space_aa, viewport->use_debanding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,7 +868,7 @@ void RenderingServerViewport::viewport_set_screen_space_aa(RID p_viewport, RS::V
|
|||||||
}
|
}
|
||||||
viewport->screen_space_aa = p_mode;
|
viewport->screen_space_aa = p_mode;
|
||||||
if (viewport->render_buffers.is_valid()) {
|
if (viewport->render_buffers.is_valid()) {
|
||||||
RSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, viewport->msaa, p_mode, viewport->use_debanding);
|
RSG::scene->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, viewport->msaa, p_mode, viewport->use_debanding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,7 +881,7 @@ void RenderingServerViewport::viewport_set_use_debanding(RID p_viewport, bool p_
|
|||||||
}
|
}
|
||||||
viewport->use_debanding = p_use_debanding;
|
viewport->use_debanding = p_use_debanding;
|
||||||
if (viewport->render_buffers.is_valid()) {
|
if (viewport->render_buffers.is_valid()) {
|
||||||
RSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, viewport->msaa, viewport->screen_space_aa, p_use_debanding);
|
RSG::scene->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, viewport->msaa, viewport->screen_space_aa, p_use_debanding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,9 +963,9 @@ bool RenderingServerViewport::free(RID p_rid) {
|
|||||||
Viewport *viewport = viewport_owner.getornull(p_rid);
|
Viewport *viewport = viewport_owner.getornull(p_rid);
|
||||||
|
|
||||||
RSG::storage->free(viewport->render_target);
|
RSG::storage->free(viewport->render_target);
|
||||||
RSG::scene_render->free(viewport->shadow_atlas);
|
RSG::scene->free(viewport->shadow_atlas);
|
||||||
if (viewport->render_buffers.is_valid()) {
|
if (viewport->render_buffers.is_valid()) {
|
||||||
RSG::scene_render->free(viewport->render_buffers);
|
RSG::scene->free(viewport->render_buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (viewport->canvas_map.front()) {
|
while (viewport->canvas_map.front()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user