diff options
author | jfons <joan.fonssanchez@gmail.com> | 2021-04-20 18:40:24 +0200 |
---|---|---|
committer | jfons <joan.fonssanchez@gmail.com> | 2021-04-23 21:45:23 +0200 |
commit | 4d9d99bb827967e2bb931eeb8c3f0e079b39ae1a (patch) | |
tree | dcd5ff54562db253500aa835a27f3b2548e42eb9 /doc/classes | |
parent | 34b3e8f9e2ae076990ecf3b2827eff759ba2abf9 (diff) |
Implement occlusion culling
Added an occlusion culling system with support for static occluder meshes.
It can be enabled via `Project Settings > Rendering > Occlusion Culling > Use Occlusion Culling`.
Occluders are defined via the new `Occluder3D` resource and instanced using the new
`OccluderInstance3D` node. The occluders can also be automatically baked from a
scene using the built-in editor plugin.
Diffstat (limited to 'doc/classes')
-rw-r--r-- | doc/classes/GeometryInstance3D.xml | 2 | ||||
-rw-r--r-- | doc/classes/Occluder3D.xml | 19 | ||||
-rw-r--r-- | doc/classes/OccluderInstance3D.xml | 37 | ||||
-rw-r--r-- | doc/classes/ProjectSettings.xml | 6 | ||||
-rw-r--r-- | doc/classes/RenderingServer.xml | 70 | ||||
-rw-r--r-- | doc/classes/Viewport.xml | 4 |
6 files changed, 136 insertions, 2 deletions
diff --git a/doc/classes/GeometryInstance3D.xml b/doc/classes/GeometryInstance3D.xml index 631a30abab..b2c3bfc3ed 100644 --- a/doc/classes/GeometryInstance3D.xml +++ b/doc/classes/GeometryInstance3D.xml @@ -48,6 +48,8 @@ </member> <member name="gi_mode" type="int" setter="set_gi_mode" getter="get_gi_mode" enum="GeometryInstance3D.GIMode" default="0"> </member> + <member name="ignore_occlusion_culling" type="bool" setter="set_ignore_occlusion_culling" getter="is_ignoring_occlusion_culling" default="false"> + </member> <member name="lod_bias" type="float" setter="set_lod_bias" getter="get_lod_bias" default="1.0"> </member> <member name="lod_max_distance" type="float" setter="set_lod_max_distance" getter="get_lod_max_distance" default="0.0"> diff --git a/doc/classes/Occluder3D.xml b/doc/classes/Occluder3D.xml new file mode 100644 index 0000000000..fc676c2b49 --- /dev/null +++ b/doc/classes/Occluder3D.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="Occluder3D" inherits="Resource" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <members> + <member name="indices" type="PackedInt32Array" setter="set_indices" getter="get_indices" default="PackedInt32Array( )"> + </member> + <member name="vertices" type="PackedVector3Array" setter="set_vertices" getter="get_vertices" default="PackedVector3Array( )"> + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/OccluderInstance3D.xml b/doc/classes/OccluderInstance3D.xml new file mode 100644 index 0000000000..76b784d21d --- /dev/null +++ b/doc/classes/OccluderInstance3D.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="OccluderInstance3D" inherits="Node3D" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_bake_mask_bit" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="layer" type="int"> + </argument> + <description> + </description> + </method> + <method name="set_bake_mask_bit"> + <return type="void"> + </return> + <argument index="0" name="layer" type="int"> + </argument> + <argument index="1" name="enabled" type="bool"> + </argument> + <description> + </description> + </method> + </methods> + <members> + <member name="bake_mask" type="int" setter="set_bake_mask" getter="get_bake_mask" default="4294967295"> + </member> + <member name="occluder" type="Occluder3D" setter="set_occluder" getter="get_occluder"> + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 59279f4e3f..5bc7588ce3 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1468,6 +1468,12 @@ </member> <member name="rendering/mesh_lod/lod_change/threshold_pixels" type="float" setter="" getter="" default="1.0"> </member> + <member name="rendering/occlusion_culling/bvh_build_quality" type="int" setter="" getter="" default="2"> + </member> + <member name="rendering/occlusion_culling/occlusion_rays_per_thread" type="int" setter="" getter="" default="512"> + </member> + <member name="rendering/occlusion_culling/use_occlusion_culling" type="bool" setter="" getter="" default="false"> + </member> <member name="rendering/reflections/reflection_atlas/reflection_count" type="int" setter="" getter="" default="64"> Number of cubemaps to store in the reflection atlas. The number of [ReflectionProbe]s in a scene will be limited by this amount. A higher number requires more VRAM. </member> diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index d6eaa1b88b..638b0bb297 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -1999,6 +1999,24 @@ Sets the number of instances visible at a given time. If -1, all instances that have been allocated are drawn. Equivalent to [member MultiMesh.visible_instance_count]. </description> </method> + <method name="occluder_create"> + <return type="RID"> + </return> + <description> + </description> + </method> + <method name="occluder_set_mesh"> + <return type="void"> + </return> + <argument index="0" name="arg0" type="RID"> + </argument> + <argument index="1" name="arg1" type="PackedVector3Array"> + </argument> + <argument index="2" name="arg2" type="PackedInt32Array"> + </argument> + <description> + </description> + </method> <method name="omni_light_create"> <return type="RID"> </return> @@ -2412,6 +2430,16 @@ The scenario is the 3D world that all the visual instances exist in. </description> </method> + <method name="scenario_set_camera_effects"> + <return type="void"> + </return> + <argument index="0" name="scenario" type="RID"> + </argument> + <argument index="1" name="effects" type="RID"> + </argument> + <description> + </description> + </method> <method name="scenario_set_debug"> <return type="void"> </return> @@ -2897,6 +2925,22 @@ Sets the anti-aliasing mode. See [enum ViewportMSAA] for options. </description> </method> + <method name="viewport_set_occlusion_culling_build_quality"> + <return type="void"> + </return> + <argument index="0" name="quality" type="int" enum="RenderingServer.ViewportOcclusionCullingBuildQuality"> + </argument> + <description> + </description> + </method> + <method name="viewport_set_occlusion_rays_per_thread"> + <return type="void"> + </return> + <argument index="0" name="rays_per_thread" type="int"> + </argument> + <description> + </description> + </method> <method name="viewport_set_parent_viewport"> <return type="void"> </return> @@ -3002,6 +3046,16 @@ <description> </description> </method> + <method name="viewport_set_use_occlusion_culling"> + <return type="void"> + </return> + <argument index="0" name="viewport" type="RID"> + </argument> + <argument index="1" name="enable" type="bool"> + </argument> + <description> + </description> + </method> <method name="viewport_set_use_xr"> <return type="void"> </return> @@ -3454,6 +3508,8 @@ </constant> <constant name="VIEWPORT_DEBUG_DRAW_GI_BUFFER" value="17" enum="ViewportDebugDraw"> </constant> + <constant name="VIEWPORT_DEBUG_DRAW_OCCLUDERS" value="23" enum="ViewportDebugDraw"> + </constant> <constant name="SKY_MODE_QUALITY" value="1" enum="SkyMode"> Uses high quality importance sampling to process the radiance map. In general, this results in much higher quality than [constant Sky.PROCESS_MODE_REALTIME] but takes much longer to generate. This should not be used if you plan on changing the sky at runtime. If you are finding that the reflection is not blurry enough and is showing sparkles or fireflies, try increasing [member ProjectSettings.rendering/reflections/sky_reflections/ggx_samples]. </constant> @@ -3606,6 +3662,12 @@ <constant name="SCENARIO_DEBUG_SHADELESS" value="3" enum="ScenarioDebugMode"> Draw all objects without shading. Equivalent to setting all objects shaders to [code]unshaded[/code]. </constant> + <constant name="VIEWPORT_OCCLUSION_BUILD_QUALITY_LOW" value="0" enum="ViewportOcclusionCullingBuildQuality"> + </constant> + <constant name="VIEWPORT_OCCLUSION_BUILD_QUALITY_MEDIUM" value="1" enum="ViewportOcclusionCullingBuildQuality"> + </constant> + <constant name="VIEWPORT_OCCLUSION_BUILD_QUALITY_HIGH" value="2" enum="ViewportOcclusionCullingBuildQuality"> + </constant> <constant name="INSTANCE_NONE" value="0" enum="InstanceType"> The instance does not have a type. </constant> @@ -3638,7 +3700,9 @@ <constant name="INSTANCE_LIGHTMAP" value="10" enum="InstanceType"> The instance is a lightmap. </constant> - <constant name="INSTANCE_MAX" value="11" enum="InstanceType"> + <constant name="INSTANCE_OCCLUDER" value="11" enum="InstanceType"> + </constant> + <constant name="INSTANCE_MAX" value="12" enum="InstanceType"> Represents the size of the [enum InstanceType] enum. </constant> <constant name="INSTANCE_GEOMETRY_MASK" value="30" enum="InstanceType"> @@ -3653,7 +3717,9 @@ <constant name="INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE" value="2" enum="InstanceFlags"> When set, manually requests to draw geometry on next frame. </constant> - <constant name="INSTANCE_FLAG_MAX" value="3" enum="InstanceFlags"> + <constant name="INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING" value="3" enum="InstanceFlags"> + </constant> + <constant name="INSTANCE_FLAG_MAX" value="4" enum="InstanceFlags"> Represents the size of the [enum InstanceFlags] enum. </constant> <constant name="SHADOW_CASTING_SETTING_OFF" value="0" enum="ShadowCastingSetting"> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 471d21374d..cce5705379 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -267,6 +267,8 @@ </member> <member name="use_debanding" type="bool" setter="set_use_debanding" getter="is_using_debanding" default="false"> </member> + <member name="use_occlusion_culling" type="bool" setter="set_use_occlusion_culling" getter="is_using_occlusion_culling" default="false"> + </member> <member name="world_2d" type="World2D" setter="set_world_2d" getter="get_world_2d"> The custom [World2D] which can be used as 2D environment source. </member> @@ -419,6 +421,8 @@ </constant> <constant name="DEBUG_DRAW_CLUSTER_REFLECTION_PROBES" value="22" enum="DebugDraw"> </constant> + <constant name="DEBUG_DRAW_OCCLUDERS" value="23" enum="DebugDraw"> + </constant> <constant name="DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST" value="0" enum="DefaultCanvasItemTextureFilter"> The texture filter reads from the nearest pixel only. The simplest and fastest method of filtering, but the texture will look pixelized. </constant> |