mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Disable unsupported SSR, SSS, DoF on transparent viewports
For technical reasons, transparent viewports cannot support screen-space reflections, subsurface scattering and depth of field. Previously, enabling any of these would turn transparent viewports invisible.
This commit is contained in:
parent
efb40c1524
commit
1c62ba40b7
6 changed files with 25 additions and 4 deletions
|
@ -398,6 +398,7 @@
|
|||
</member>
|
||||
<member name="subsurf_scatter_enabled" type="bool" setter="set_feature" getter="get_feature" default="false">
|
||||
If [code]true[/code], subsurface scattering is enabled. Emulates light that penetrates an object's surface, is scattered, and then emerges. Subsurface scattering quality is controlled by [member ProjectSettings.rendering/environment/subsurface_scattering/subsurface_scattering_quality].
|
||||
[b]Note:[/b] Subsurface scattering is not supported on viewports that have a transparent background (where [member Viewport.transparent_bg] is [code]true[/code]).
|
||||
</member>
|
||||
<member name="subsurf_scatter_skin_mode" type="bool" setter="set_flag" getter="get_flag" default="false">
|
||||
If [code]true[/code], subsurface scattering will use a special mode optimized for the color and density of human skin, such as boosting the intensity of the red channel in subsurface scattering.
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<member name="dof_blur_far_enabled" type="bool" setter="set_dof_blur_far_enabled" getter="is_dof_blur_far_enabled" default="false">
|
||||
Enables depth of field blur for objects further than [member dof_blur_far_distance]. Strength of blur is controlled by [member dof_blur_amount] and modulated by [member dof_blur_far_transition].
|
||||
[b]Note:[/b] Depth of field blur is only supported in the Forward+ and Mobile rendering methods, not Compatibility.
|
||||
[b]Note:[/b] Depth of field blur is not supported on viewports that have a transparent background (where [member Viewport.transparent_bg] is [code]true[/code]).
|
||||
</member>
|
||||
<member name="dof_blur_far_transition" type="float" setter="set_dof_blur_far_transition" getter="get_dof_blur_far_transition" default="5.0">
|
||||
When positive, distance over which (starting from [member dof_blur_far_distance]) blur effect will scale from 0 to [member dof_blur_amount]. When negative, uses physically-based scaling so depth of field effect will scale from 0 at [member dof_blur_far_distance] and will increase in a physically accurate way as objects get further from the [Camera3D].
|
||||
|
@ -35,6 +36,7 @@
|
|||
<member name="dof_blur_near_enabled" type="bool" setter="set_dof_blur_near_enabled" getter="is_dof_blur_near_enabled" default="false">
|
||||
Enables depth of field blur for objects closer than [member dof_blur_near_distance]. Strength of blur is controlled by [member dof_blur_amount] and modulated by [member dof_blur_near_transition].
|
||||
[b]Note:[/b] Depth of field blur is only supported in the Forward+ and Mobile rendering methods, not Compatibility.
|
||||
[b]Note:[/b] Depth of field blur is not supported on viewports that have a transparent background (where [member Viewport.transparent_bg] is [code]true[/code]).
|
||||
</member>
|
||||
<member name="dof_blur_near_transition" type="float" setter="set_dof_blur_near_transition" getter="get_dof_blur_near_transition" default="1.0">
|
||||
When positive, distance over which blur effect will scale from 0 to [member dof_blur_amount], ending at [member dof_blur_near_distance]. When negative, uses physically-based scaling so depth of field effect will scale from 0 at [member dof_blur_near_distance] and will increase in a physically accurate way as objects get closer to the [Camera3D].
|
||||
|
|
|
@ -303,6 +303,7 @@
|
|||
<member name="ssr_enabled" type="bool" setter="set_ssr_enabled" getter="is_ssr_enabled" default="false">
|
||||
If [code]true[/code], screen-space reflections are enabled. Screen-space reflections are more accurate than reflections from [VoxelGI]s or [ReflectionProbe]s, but are slower and can't reflect surfaces occluded by others.
|
||||
[b]Note:[/b] SSR is only supported in the Forward+ rendering method, not Mobile or Compatibility.
|
||||
[b]Note:[/b] SSR is not supported on viewports that have a transparent background (where [member Viewport.transparent_bg] is [code]true[/code]).
|
||||
</member>
|
||||
<member name="ssr_fade_in" type="float" setter="set_ssr_fade_in" getter="get_ssr_fade_in" default="0.15">
|
||||
The fade-in distance for screen-space reflections. Affects the area from the reflected material to the screen-space reflection. Only positive values are valid (negative values will be clamped to [code]0.0[/code]).
|
||||
|
|
|
@ -442,6 +442,7 @@
|
|||
</member>
|
||||
<member name="transparent_bg" type="bool" setter="set_transparent_background" getter="has_transparent_background" default="false">
|
||||
If [code]true[/code], the viewport should render its background as transparent.
|
||||
[b]Note:[/b] Due to technical limitations, certain rendering features are disabled when a viewport has a transparent background. This currently applies to screen-space reflections, subsurface scattering, and depth of field.
|
||||
</member>
|
||||
<member name="use_debanding" type="bool" setter="set_use_debanding" getter="is_using_debanding" default="false">
|
||||
If [code]true[/code], uses a fast post-processing filter to make banding significantly less visible in 3D. 2D rendering is [i]not[/i] affected by debanding unless the [member Environment.background_mode] is [constant Environment.BG_CANVAS].
|
||||
|
|
|
@ -1820,9 +1820,13 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
|
|||
using_sdfgi = true;
|
||||
}
|
||||
if (environment_get_ssr_enabled(p_render_data->environment)) {
|
||||
using_separate_specular = true;
|
||||
using_ssr = true;
|
||||
color_pass_flags |= COLOR_PASS_FLAG_SEPARATE_SPECULAR;
|
||||
if (!p_render_data->transparent_bg) {
|
||||
using_separate_specular = true;
|
||||
using_ssr = true;
|
||||
color_pass_flags |= COLOR_PASS_FLAG_SEPARATE_SPECULAR;
|
||||
} else {
|
||||
WARN_PRINT_ONCE("Screen-space reflections are not supported in viewports with a transparent background. Disabling SSR in transparent viewport.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1900,6 +1904,11 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
|
|||
|
||||
bool using_sss = rb_data.is_valid() && !is_reflection_probe && scene_state.used_sss && ss_effects->sss_get_quality() != RS::SUB_SURFACE_SCATTERING_QUALITY_DISABLED;
|
||||
|
||||
if (using_sss && p_render_data->transparent_bg) {
|
||||
WARN_PRINT_ONCE("Sub-surface scattering is not supported in viewports with a transparent background. Disabling SSS in transparent viewport.");
|
||||
using_sss = false;
|
||||
}
|
||||
|
||||
if ((using_sss || ce_needs_separate_specular) && !using_separate_specular) {
|
||||
using_separate_specular = true;
|
||||
color_pass_flags |= COLOR_PASS_FLAG_SEPARATE_SPECULAR;
|
||||
|
|
|
@ -478,7 +478,14 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende
|
|||
|
||||
bool dest_is_msaa_2d = rb->get_view_count() == 1 && texture_storage->render_target_get_msaa(render_target) != RS::VIEWPORT_MSAA_DISABLED;
|
||||
|
||||
if (can_use_effects && RSG::camera_attributes->camera_attributes_uses_dof(p_render_data->camera_attributes)) {
|
||||
bool using_dof = RSG::camera_attributes->camera_attributes_uses_dof(p_render_data->camera_attributes);
|
||||
|
||||
if (using_dof && p_render_data->transparent_bg) {
|
||||
WARN_PRINT_ONCE("Depth of field is not supported in viewports with a transparent background. Disabling DoF in transparent viewport.");
|
||||
using_dof = false;
|
||||
}
|
||||
|
||||
if (can_use_effects && using_dof) {
|
||||
RENDER_TIMESTAMP("Depth of Field");
|
||||
RD::get_singleton()->draw_command_begin_label("DOF");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue