Merge pull request #50133 from reduz/fix-render-debug-modes
Fix render debug modes.
This commit is contained in:
commit
d4e081bfe3
6 changed files with 66 additions and 31 deletions
|
@ -345,8 +345,20 @@ void RenderForwardClustered::_render_list_template(RenderingDevice::DrawListID p
|
||||||
mesh_surface = surf->surface_shadow;
|
mesh_surface = surf->surface_shadow;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
material_uniform_set = surf->material_uniform_set;
|
#ifdef DEBUG_ENABLED
|
||||||
shader = surf->shader;
|
if (unlikely(get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_LIGHTING)) {
|
||||||
|
material_uniform_set = scene_shader.default_material_uniform_set;
|
||||||
|
shader = scene_shader.default_material_shader_ptr;
|
||||||
|
} else if (unlikely(get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_OVERDRAW)) {
|
||||||
|
material_uniform_set = scene_shader.overdraw_material_uniform_set;
|
||||||
|
shader = scene_shader.overdraw_material_shader_ptr;
|
||||||
|
} else {
|
||||||
|
#endif
|
||||||
|
material_uniform_set = surf->material_uniform_set;
|
||||||
|
shader = surf->shader;
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
}
|
||||||
|
#endif
|
||||||
mesh_surface = surf->surface;
|
mesh_surface = surf->surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1048,10 +1060,15 @@ void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, con
|
||||||
|
|
||||||
// ADD Element
|
// ADD Element
|
||||||
if (p_pass_mode == PASS_MODE_COLOR) {
|
if (p_pass_mode == PASS_MODE_COLOR) {
|
||||||
if (surf->flags & (GeometryInstanceSurfaceDataCache::FLAG_PASS_DEPTH | GeometryInstanceSurfaceDataCache::FLAG_PASS_OPAQUE)) {
|
#ifdef DEBUG_ENABLED
|
||||||
|
bool force_alpha = unlikely(get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_OVERDRAW);
|
||||||
|
#else
|
||||||
|
bool force_alpha = false;
|
||||||
|
#endif
|
||||||
|
if (!force_alpha && (surf->flags & (GeometryInstanceSurfaceDataCache::FLAG_PASS_DEPTH | GeometryInstanceSurfaceDataCache::FLAG_PASS_OPAQUE))) {
|
||||||
rl->add_element(surf);
|
rl->add_element(surf);
|
||||||
}
|
}
|
||||||
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_PASS_ALPHA) {
|
if (force_alpha || (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_PASS_ALPHA)) {
|
||||||
render_list[RENDER_LIST_ALPHA].add_element(surf);
|
render_list[RENDER_LIST_ALPHA].add_element(surf);
|
||||||
if (uses_gi) {
|
if (uses_gi) {
|
||||||
surf->sort.uses_forward_gi = 1;
|
surf->sort.uses_forward_gi = 1;
|
||||||
|
|
|
@ -546,11 +546,9 @@ SceneShaderForwardClustered::~SceneShaderForwardClustered() {
|
||||||
RD::get_singleton()->free(default_vec4_xform_buffer);
|
RD::get_singleton()->free(default_vec4_xform_buffer);
|
||||||
RD::get_singleton()->free(shadow_sampler);
|
RD::get_singleton()->free(shadow_sampler);
|
||||||
|
|
||||||
storage->free(wireframe_material_shader);
|
|
||||||
storage->free(overdraw_material_shader);
|
storage->free(overdraw_material_shader);
|
||||||
storage->free(default_shader);
|
storage->free(default_shader);
|
||||||
|
|
||||||
storage->free(wireframe_material);
|
|
||||||
storage->free(overdraw_material);
|
storage->free(overdraw_material);
|
||||||
storage->free(default_material);
|
storage->free(default_material);
|
||||||
}
|
}
|
||||||
|
@ -775,6 +773,9 @@ void SceneShaderForwardClustered::init(RendererStorageRD *p_storage, const Strin
|
||||||
MaterialData *md = (MaterialData *)storage->material_get_data(default_material, RendererStorageRD::SHADER_TYPE_3D);
|
MaterialData *md = (MaterialData *)storage->material_get_data(default_material, RendererStorageRD::SHADER_TYPE_3D);
|
||||||
default_shader_rd = shader.version_get_shader(md->shader_data->version, SHADER_VERSION_COLOR_PASS);
|
default_shader_rd = shader.version_get_shader(md->shader_data->version, SHADER_VERSION_COLOR_PASS);
|
||||||
default_shader_sdfgi_rd = shader.version_get_shader(md->shader_data->version, SHADER_VERSION_DEPTH_PASS_WITH_SDF);
|
default_shader_sdfgi_rd = shader.version_get_shader(md->shader_data->version, SHADER_VERSION_DEPTH_PASS_WITH_SDF);
|
||||||
|
|
||||||
|
default_material_shader_ptr = md->shader_data;
|
||||||
|
default_material_uniform_set = md->uniform_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -785,12 +786,9 @@ void SceneShaderForwardClustered::init(RendererStorageRD *p_storage, const Strin
|
||||||
storage->material_initialize(overdraw_material);
|
storage->material_initialize(overdraw_material);
|
||||||
storage->material_set_shader(overdraw_material, overdraw_material_shader);
|
storage->material_set_shader(overdraw_material, overdraw_material_shader);
|
||||||
|
|
||||||
wireframe_material_shader = storage->shader_allocate();
|
MaterialData *md = (MaterialData *)storage->material_get_data(overdraw_material, RendererStorageRD::SHADER_TYPE_3D);
|
||||||
storage->shader_initialize(wireframe_material_shader);
|
overdraw_material_shader_ptr = md->shader_data;
|
||||||
storage->shader_set_code(wireframe_material_shader, "shader_type spatial;\nrender_mode wireframe,unshaded;\n void fragment() { ALBEDO=vec3(0.0,0.0,0.0); }");
|
overdraw_material_uniform_set = md->uniform_set;
|
||||||
wireframe_material = storage->material_allocate();
|
|
||||||
storage->material_initialize(wireframe_material);
|
|
||||||
storage->material_set_shader(wireframe_material, wireframe_material_shader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -192,8 +192,6 @@ public:
|
||||||
RID default_material;
|
RID default_material;
|
||||||
RID overdraw_material_shader;
|
RID overdraw_material_shader;
|
||||||
RID overdraw_material;
|
RID overdraw_material;
|
||||||
RID wireframe_material_shader;
|
|
||||||
RID wireframe_material;
|
|
||||||
RID default_shader_rd;
|
RID default_shader_rd;
|
||||||
RID default_shader_sdfgi_rd;
|
RID default_shader_sdfgi_rd;
|
||||||
|
|
||||||
|
@ -202,6 +200,12 @@ public:
|
||||||
|
|
||||||
RID shadow_sampler;
|
RID shadow_sampler;
|
||||||
|
|
||||||
|
RID default_material_uniform_set;
|
||||||
|
ShaderData *default_material_shader_ptr = nullptr;
|
||||||
|
|
||||||
|
RID overdraw_material_uniform_set;
|
||||||
|
ShaderData *overdraw_material_shader_ptr = nullptr;
|
||||||
|
|
||||||
SceneShaderForwardClustered();
|
SceneShaderForwardClustered();
|
||||||
~SceneShaderForwardClustered();
|
~SceneShaderForwardClustered();
|
||||||
|
|
||||||
|
|
|
@ -1078,14 +1078,16 @@ void RenderForwardMobile::_fill_render_list(RenderListType p_render_list, const
|
||||||
|
|
||||||
// ADD Element
|
// ADD Element
|
||||||
if (p_pass_mode == PASS_MODE_COLOR) {
|
if (p_pass_mode == PASS_MODE_COLOR) {
|
||||||
if (surf->flags & (GeometryInstanceSurfaceDataCache::FLAG_PASS_DEPTH | GeometryInstanceSurfaceDataCache::FLAG_PASS_OPAQUE)) {
|
#ifdef DEBUG_ENABLED
|
||||||
|
bool force_alpha = unlikely(get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_OVERDRAW);
|
||||||
|
#else
|
||||||
|
bool force_alpha = false;
|
||||||
|
#endif
|
||||||
|
if (!force_alpha && (surf->flags & (GeometryInstanceSurfaceDataCache::FLAG_PASS_DEPTH | GeometryInstanceSurfaceDataCache::FLAG_PASS_OPAQUE))) {
|
||||||
rl->add_element(surf);
|
rl->add_element(surf);
|
||||||
}
|
}
|
||||||
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_PASS_ALPHA) {
|
if (force_alpha || (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_PASS_ALPHA)) {
|
||||||
render_list[RENDER_LIST_ALPHA].add_element(surf);
|
render_list[RENDER_LIST_ALPHA].add_element(surf);
|
||||||
// if (uses_gi) {
|
|
||||||
// surf->sort.uses_forward_gi = 1;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uses_lightmap) {
|
if (uses_lightmap) {
|
||||||
|
@ -1451,8 +1453,20 @@ void RenderForwardMobile::_render_list_template(RenderingDevice::DrawListID p_dr
|
||||||
mesh_surface = surf->surface_shadow;
|
mesh_surface = surf->surface_shadow;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
material_uniform_set = surf->material_uniform_set;
|
#ifdef DEBUG_ENABLED
|
||||||
shader = surf->shader;
|
if (unlikely(get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_LIGHTING)) {
|
||||||
|
material_uniform_set = scene_shader.default_material_uniform_set;
|
||||||
|
shader = scene_shader.default_material_shader_ptr;
|
||||||
|
} else if (unlikely(get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_OVERDRAW)) {
|
||||||
|
material_uniform_set = scene_shader.overdraw_material_uniform_set;
|
||||||
|
shader = scene_shader.overdraw_material_shader_ptr;
|
||||||
|
} else {
|
||||||
|
#endif
|
||||||
|
material_uniform_set = surf->material_uniform_set;
|
||||||
|
shader = surf->shader;
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
}
|
||||||
|
#endif
|
||||||
mesh_surface = surf->surface;
|
mesh_surface = surf->surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -759,6 +759,9 @@ void SceneShaderForwardMobile::init(RendererStorageRD *p_storage, const String p
|
||||||
|
|
||||||
MaterialData *md = (MaterialData *)storage->material_get_data(default_material, RendererStorageRD::SHADER_TYPE_3D);
|
MaterialData *md = (MaterialData *)storage->material_get_data(default_material, RendererStorageRD::SHADER_TYPE_3D);
|
||||||
default_shader_rd = shader.version_get_shader(md->shader_data->version, SHADER_VERSION_COLOR_PASS);
|
default_shader_rd = shader.version_get_shader(md->shader_data->version, SHADER_VERSION_COLOR_PASS);
|
||||||
|
|
||||||
|
default_material_shader_ptr = md->shader_data;
|
||||||
|
default_material_uniform_set = md->uniform_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -769,12 +772,9 @@ void SceneShaderForwardMobile::init(RendererStorageRD *p_storage, const String p
|
||||||
storage->material_initialize(overdraw_material);
|
storage->material_initialize(overdraw_material);
|
||||||
storage->material_set_shader(overdraw_material, overdraw_material_shader);
|
storage->material_set_shader(overdraw_material, overdraw_material_shader);
|
||||||
|
|
||||||
wireframe_material_shader = storage->shader_allocate();
|
MaterialData *md = (MaterialData *)storage->material_get_data(overdraw_material, RendererStorageRD::SHADER_TYPE_3D);
|
||||||
storage->shader_initialize(wireframe_material_shader);
|
overdraw_material_shader_ptr = md->shader_data;
|
||||||
storage->shader_set_code(wireframe_material_shader, "shader_type spatial;\nrender_mode wireframe,unshaded;\n void fragment() { ALBEDO=vec3(0.0,0.0,0.0); }");
|
overdraw_material_uniform_set = md->uniform_set;
|
||||||
wireframe_material = storage->material_allocate();
|
|
||||||
storage->material_initialize(wireframe_material);
|
|
||||||
storage->material_set_shader(wireframe_material, wireframe_material_shader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -802,11 +802,9 @@ SceneShaderForwardMobile::~SceneShaderForwardMobile() {
|
||||||
RD::get_singleton()->free(default_vec4_xform_buffer);
|
RD::get_singleton()->free(default_vec4_xform_buffer);
|
||||||
RD::get_singleton()->free(shadow_sampler);
|
RD::get_singleton()->free(shadow_sampler);
|
||||||
|
|
||||||
storage->free(wireframe_material_shader);
|
|
||||||
storage->free(overdraw_material_shader);
|
storage->free(overdraw_material_shader);
|
||||||
storage->free(default_shader);
|
storage->free(default_shader);
|
||||||
|
|
||||||
storage->free(wireframe_material);
|
|
||||||
storage->free(overdraw_material);
|
storage->free(overdraw_material);
|
||||||
storage->free(default_material);
|
storage->free(default_material);
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,8 +189,6 @@ public:
|
||||||
RID default_material;
|
RID default_material;
|
||||||
RID overdraw_material_shader;
|
RID overdraw_material_shader;
|
||||||
RID overdraw_material;
|
RID overdraw_material;
|
||||||
RID wireframe_material_shader;
|
|
||||||
RID wireframe_material;
|
|
||||||
RID default_shader_rd;
|
RID default_shader_rd;
|
||||||
|
|
||||||
RID default_vec4_xform_buffer;
|
RID default_vec4_xform_buffer;
|
||||||
|
@ -198,6 +196,12 @@ public:
|
||||||
|
|
||||||
RID shadow_sampler;
|
RID shadow_sampler;
|
||||||
|
|
||||||
|
RID default_material_uniform_set;
|
||||||
|
ShaderData *default_material_shader_ptr = nullptr;
|
||||||
|
|
||||||
|
RID overdraw_material_uniform_set;
|
||||||
|
ShaderData *overdraw_material_shader_ptr = nullptr;
|
||||||
|
|
||||||
SceneShaderForwardMobile();
|
SceneShaderForwardMobile();
|
||||||
~SceneShaderForwardMobile();
|
~SceneShaderForwardMobile();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue