Rename GI Classes

* GIProbe is now VoxelGI
* BakedLightmap is now LightmapGI

As godot adds more ways to provide GI (as an example, SDFGI in 4.0), the different techniques (which have different pros/cons) need to be properly named to avoid confusion.
This commit is contained in:
reduz 2021-06-04 19:47:26 -03:00
parent 7085c0d801
commit 32625145c8
67 changed files with 1467 additions and 1465 deletions

View file

@ -199,7 +199,7 @@
The emitted light's color. See [member emission_enabled]. The emitted light's color. See [member emission_enabled].
</member> </member>
<member name="emission_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> <member name="emission_enabled" type="bool" setter="set_feature" getter="get_feature" default="false">
If [code]true[/code], the body emits light. Emitting light makes the object appear brighter. The object can also cast light on other objects if a [GIProbe] is used and this object is used in baked lighting. If [code]true[/code], the body emits light. Emitting light makes the object appear brighter. The object can also cast light on other objects if a [VoxelGI] is used and this object is used in baked lighting.
</member> </member>
<member name="emission_energy" type="float" setter="set_emission_energy" getter="get_emission_energy" default="1.0"> <member name="emission_energy" type="float" setter="set_emission_energy" getter="get_emission_energy" default="1.0">
The emitted light's strength. See [member emission_enabled]. The emitted light's strength. See [member emission_enabled].

View file

@ -206,7 +206,7 @@
The depth tolerance for screen-space reflections. The depth tolerance for screen-space reflections.
</member> </member>
<member name="ss_reflections_enabled" type="bool" setter="set_ssr_enabled" getter="is_ssr_enabled" default="false"> <member name="ss_reflections_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 [GIProbe]s or [ReflectionProbe]s, but are slower and can't reflect surfaces occluded by others. 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.
</member> </member>
<member name="ss_reflections_fade_in" type="float" setter="set_ssr_fade_in" getter="get_ssr_fade_in" default="0.15"> <member name="ss_reflections_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). The fade-in distance for screen-space reflections. Affects the area from the reflected material to the screen-space reflection).

View file

@ -52,7 +52,7 @@
The light's strength multiplier (this is not a physical unit). For [OmniLight3D] and [SpotLight3D], changing this value will only change the light color's intensity, not the light's radius. The light's strength multiplier (this is not a physical unit). For [OmniLight3D] and [SpotLight3D], changing this value will only change the light color's intensity, not the light's radius.
</member> </member>
<member name="light_indirect_energy" type="float" setter="set_param" getter="get_param" default="1.0"> <member name="light_indirect_energy" type="float" setter="set_param" getter="get_param" default="1.0">
Secondary multiplier used with indirect light (light bounces). Used with [GIProbe]. Secondary multiplier used with indirect light (light bounces). Used with [VoxelGI].
</member> </member>
<member name="light_negative" type="bool" setter="set_negative" getter="is_negative" default="false"> <member name="light_negative" type="bool" setter="set_negative" getter="is_negative" default="false">
If [code]true[/code], the light's effect is reversed, darkening areas and casting bright shadows. If [code]true[/code], the light's effect is reversed, darkening areas and casting bright shadows.

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="BakedLightmap" inherits="VisualInstance3D" version="4.0"> <class name="LightmapGI" inherits="VisualInstance3D" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>
@ -21,17 +21,17 @@
</member> </member>
<member name="environment_custom_sky" type="Sky" setter="set_environment_custom_sky" getter="get_environment_custom_sky"> <member name="environment_custom_sky" type="Sky" setter="set_environment_custom_sky" getter="get_environment_custom_sky">
</member> </member>
<member name="environment_mode" type="int" setter="set_environment_mode" getter="get_environment_mode" enum="BakedLightmap.EnvironmentMode" default="0"> <member name="environment_mode" type="int" setter="set_environment_mode" getter="get_environment_mode" enum="LightmapGI.EnvironmentMode" default="0">
</member> </member>
<member name="generate_probes_subdiv" type="int" setter="set_generate_probes" getter="get_generate_probes" enum="BakedLightmap.GenerateProbes" default="0"> <member name="generate_probes_subdiv" type="int" setter="set_generate_probes" getter="get_generate_probes" enum="LightmapGI.GenerateProbes" default="0">
</member> </member>
<member name="interior" type="bool" setter="set_interior" getter="is_interior" default="false"> <member name="interior" type="bool" setter="set_interior" getter="is_interior" default="false">
</member> </member>
<member name="light_data" type="BakedLightmapData" setter="set_light_data" getter="get_light_data"> <member name="light_data" type="LightmapGIData" setter="set_light_data" getter="get_light_data">
</member> </member>
<member name="max_texture_size" type="int" setter="set_max_texture_size" getter="get_max_texture_size" default="16384"> <member name="max_texture_size" type="int" setter="set_max_texture_size" getter="get_max_texture_size" default="16384">
</member> </member>
<member name="quality" type="int" setter="set_bake_quality" getter="get_bake_quality" enum="BakedLightmap.BakeQuality" default="1"> <member name="quality" type="int" setter="set_bake_quality" getter="get_bake_quality" enum="LightmapGI.BakeQuality" default="1">
</member> </member>
<member name="use_denoiser" type="bool" setter="set_use_denoiser" getter="is_using_denoiser" default="true"> <member name="use_denoiser" type="bool" setter="set_use_denoiser" getter="is_using_denoiser" default="true">
</member> </member>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="BakedLightmapData" inherits="Resource" version="4.0"> <class name="LightmapGIData" inherits="Resource" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1421,18 +1421,16 @@
</member> </member>
<member name="rendering/global_illumination/gi/use_half_resolution" type="bool" setter="" getter="" default="false"> <member name="rendering/global_illumination/gi/use_half_resolution" type="bool" setter="" getter="" default="false">
</member> </member>
<member name="rendering/global_illumination/gi_probes/anisotropic" type="bool" setter="" getter="" default="false">
If [code]true[/code], take additional samples when rendering objects affected by a [GIProbe] to reduce artifacts from only sampling in one direction.
</member>
<member name="rendering/global_illumination/gi_probes/quality" type="int" setter="" getter="" default="1">
Sets the number of cone samples taken when rendering objects affected by [GIProbe]s.
</member>
<member name="rendering/global_illumination/sdfgi/frames_to_converge" type="int" setter="" getter="" default="4"> <member name="rendering/global_illumination/sdfgi/frames_to_converge" type="int" setter="" getter="" default="4">
</member> </member>
<member name="rendering/global_illumination/sdfgi/frames_to_update_lights" type="int" setter="" getter="" default="2"> <member name="rendering/global_illumination/sdfgi/frames_to_update_lights" type="int" setter="" getter="" default="2">
</member> </member>
<member name="rendering/global_illumination/sdfgi/probe_ray_count" type="int" setter="" getter="" default="1"> <member name="rendering/global_illumination/sdfgi/probe_ray_count" type="int" setter="" getter="" default="1">
</member> </member>
<member name="rendering/global_illumination/voxel_gi/anisotropic" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/global_illumination/voxel_gi/quality" type="int" setter="" getter="" default="1">
</member>
<member name="rendering/lightmapping/bake_performance/max_rays_per_pass" type="int" setter="" getter="" default="32"> <member name="rendering/lightmapping/bake_performance/max_rays_per_pass" type="int" setter="" getter="" default="32">
</member> </member>
<member name="rendering/lightmapping/bake_performance/max_rays_per_probe_pass" type="int" setter="" getter="" default="64"> <member name="rendering/lightmapping/bake_performance/max_rays_per_probe_pass" type="int" setter="" getter="" default="64">

View file

@ -5,7 +5,7 @@
</brief_description> </brief_description>
<description> <description>
Captures its surroundings as a cubemap, and stores versions of it with increasing levels of blur to simulate different material roughnesses. Captures its surroundings as a cubemap, and stores versions of it with increasing levels of blur to simulate different material roughnesses.
The [ReflectionProbe] is used to create high-quality reflections at the cost of performance. It can be combined with [GIProbe]s and Screen Space Reflections to achieve high quality reflections. [ReflectionProbe]s render all objects within their [member cull_mask], so updating them can be quite expensive. It is best to update them once with the important static objects and then leave them. The [ReflectionProbe] is used to create high-quality reflections at the cost of performance. It can be combined with [VoxelGI]s and Screen Space Reflections to achieve high quality reflections. [ReflectionProbe]s render all objects within their [member cull_mask], so updating them can be quite expensive. It is best to update them once with the important static objects and then leave them.
</description> </description>
<tutorials> <tutorials>
<link title="Reflection probes">https://docs.godotengine.org/en/latest/tutorials/3d/reflection_probes.html</link> <link title="Reflection probes">https://docs.godotengine.org/en/latest/tutorials/3d/reflection_probes.html</link>

View file

@ -3477,14 +3477,14 @@
<constant name="VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER" value="5" enum="ViewportDebugDraw"> <constant name="VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER" value="5" enum="ViewportDebugDraw">
Normal buffer is drawn instead of regular scene so you can see the per-pixel normals that will be used by post-processing effects. Normal buffer is drawn instead of regular scene so you can see the per-pixel normals that will be used by post-processing effects.
</constant> </constant>
<constant name="VIEWPORT_DEBUG_DRAW_GI_PROBE_ALBEDO" value="6" enum="ViewportDebugDraw"> <constant name="VIEWPORT_DEBUG_DRAW_VOXEL_GI_ALBEDO" value="6" enum="ViewportDebugDraw">
Objects are displayed with only the albedo value from [GIProbe]s. Objects are displayed with only the albedo value from [VoxelGI]s.
</constant> </constant>
<constant name="VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING" value="7" enum="ViewportDebugDraw"> <constant name="VIEWPORT_DEBUG_DRAW_VOXEL_GI_LIGHTING" value="7" enum="ViewportDebugDraw">
Objects are displayed with only the lighting value from [GIProbe]s. Objects are displayed with only the lighting value from [VoxelGI]s.
</constant> </constant>
<constant name="VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION" value="8" enum="ViewportDebugDraw"> <constant name="VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION" value="8" enum="ViewportDebugDraw">
Objects are displayed with only the emission color from [GIProbe]s. Objects are displayed with only the emission color from [VoxelGI]s.
</constant> </constant>
<constant name="VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS" value="9" enum="ViewportDebugDraw"> <constant name="VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS" value="9" enum="ViewportDebugDraw">
Draws the shadow atlas that stores shadows from [OmniLight3D]s and [SpotLight3D]s in the upper left quadrant of the [Viewport]. Draws the shadow atlas that stores shadows from [OmniLight3D]s and [SpotLight3D]s in the upper left quadrant of the [Viewport].
@ -3694,8 +3694,8 @@
<constant name="INSTANCE_DECAL" value="8" enum="InstanceType"> <constant name="INSTANCE_DECAL" value="8" enum="InstanceType">
The instance is a decal. The instance is a decal.
</constant> </constant>
<constant name="INSTANCE_GI_PROBE" value="9" enum="InstanceType"> <constant name="INSTANCE_VOXEL_GI" value="9" enum="InstanceType">
The instance is a GI probe. The instance is a VoxelGI.
</constant> </constant>
<constant name="INSTANCE_LIGHTMAP" value="10" enum="InstanceType"> <constant name="INSTANCE_LIGHTMAP" value="10" enum="InstanceType">
The instance is a lightmap. The instance is a lightmap.

View file

@ -382,14 +382,14 @@
</constant> </constant>
<constant name="DEBUG_DRAW_NORMAL_BUFFER" value="5" enum="DebugDraw"> <constant name="DEBUG_DRAW_NORMAL_BUFFER" value="5" enum="DebugDraw">
</constant> </constant>
<constant name="DEBUG_DRAW_GI_PROBE_ALBEDO" value="6" enum="DebugDraw"> <constant name="DEBUG_DRAW_VOXEL_GI_ALBEDO" value="6" enum="DebugDraw">
Objects are displayed with only the albedo value from [GIProbe]s. Objects are displayed with only the albedo value from [VoxelGI]s.
</constant> </constant>
<constant name="DEBUG_DRAW_GI_PROBE_LIGHTING" value="7" enum="DebugDraw"> <constant name="DEBUG_DRAW_VOXEL_GI_LIGHTING" value="7" enum="DebugDraw">
Objects are displayed with only the lighting value from [GIProbe]s. Objects are displayed with only the lighting value from [VoxelGI]s.
</constant> </constant>
<constant name="DEBUG_DRAW_GI_PROBE_EMISSION" value="8" enum="DebugDraw"> <constant name="DEBUG_DRAW_VOXEL_GI_EMISSION" value="8" enum="DebugDraw">
Objects are displayed with only the emission color from [GIProbe]s. Objects are displayed with only the emission color from [VoxelGI]s.
</constant> </constant>
<constant name="DEBUG_DRAW_SHADOW_ATLAS" value="9" enum="DebugDraw"> <constant name="DEBUG_DRAW_SHADOW_ATLAS" value="9" enum="DebugDraw">
Draws the shadow atlas that stores shadows from [OmniLight3D]s and [SpotLight3D]s in the upper left quadrant of the [Viewport]. Draws the shadow atlas that stores shadows from [OmniLight3D]s and [SpotLight3D]s in the upper left quadrant of the [Viewport].

View file

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GIProbe" inherits="VisualInstance3D" version="4.0"> <class name="VoxelGI" inherits="VisualInstance3D" version="4.0">
<brief_description> <brief_description>
Real-time global illumination (GI) probe. Real-time global illumination (GI) probe.
</brief_description> </brief_description>
<description> <description>
[GIProbe]s are used to provide high-quality real-time indirect light to scenes. They precompute the effect of objects that emit light and the effect of static geometry to simulate the behavior of complex light in real-time. [GIProbe]s need to be baked before using, however, once baked, dynamic objects will receive light from them. Further, lights can be fully dynamic or baked. [VoxelGI]s are used to provide high-quality real-time indirect light to scenes. They precompute the effect of objects that emit light and the effect of static geometry to simulate the behavior of complex light in real-time. [VoxelGI]s need to be baked before using, however, once baked, dynamic objects will receive light from them. Further, lights can be fully dynamic or baked.
Having [GIProbe]s in a scene can be expensive, the quality of the probe can be turned down in exchange for better performance in the [ProjectSettings] using [member ProjectSettings.rendering/global_illumination/gi_probes/quality]. Having [VoxelGI]s in a scene can be expensive, the quality of the probe can be turned down in exchange for better performance in the [ProjectSettings] using [member ProjectSettings.rendering/global_illumination/voxel_gi/quality].
[b]Note:[/b] Meshes should have sufficiently thick walls to avoid light leaks (avoid one-sided walls). For interior levels, enclose your level geometry in a sufficiently large box and bridge the loops to close the mesh. [b]Note:[/b] Meshes should have sufficiently thick walls to avoid light leaks (avoid one-sided walls). For interior levels, enclose your level geometry in a sufficiently large box and bridge the loops to close the mesh.
</description> </description>
<tutorials> <tutorials>
<link title="GI probes">https://docs.godotengine.org/en/latest/tutorials/3d/gi_probes.html</link> <link title="GI probes">https://docs.godotengine.org/en/latest/tutorials/3d/voxel_gi.html</link>
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link> <link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials> </tutorials>
<methods> <methods>
@ -21,7 +21,7 @@
<argument index="1" name="create_visual_debug" type="bool" default="false"> <argument index="1" name="create_visual_debug" type="bool" default="false">
</argument> </argument>
<description> <description>
Bakes the effect from all [GeometryInstance3D]s marked with [constant GeometryInstance3D.GI_MODE_BAKED] and [Light3D]s marked with either [constant Light3D.BAKE_DYNAMIC] or [constant Light3D.BAKE_STATIC]. If [code]create_visual_debug[/code] is [code]true[/code], after baking the light, this will generate a [MultiMesh] that has a cube representing each solid cell with each cube colored to the cell's albedo color. This can be used to visualize the [GIProbe]'s data and debug any issues that may be occurring. Bakes the effect from all [GeometryInstance3D]s marked with [constant GeometryInstance3D.GI_MODE_BAKED] and [Light3D]s marked with either [constant Light3D.BAKE_DYNAMIC] or [constant Light3D.BAKE_STATIC]. If [code]create_visual_debug[/code] is [code]true[/code], after baking the light, this will generate a [MultiMesh] that has a cube representing each solid cell with each cube colored to the cell's albedo color. This can be used to visualize the [VoxelGI]'s data and debug any issues that may be occurring.
</description> </description>
</method> </method>
<method name="debug_bake"> <method name="debug_bake">
@ -33,14 +33,14 @@
</method> </method>
</methods> </methods>
<members> <members>
<member name="data" type="GIProbeData" setter="set_probe_data" getter="get_probe_data"> <member name="data" type="VoxelGIData" setter="set_probe_data" getter="get_probe_data">
The [GIProbeData] resource that holds the data for this [GIProbe]. The [VoxelGIData] resource that holds the data for this [VoxelGI].
</member> </member>
<member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 10, 10, 10 )"> <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 10, 10, 10 )">
The size of the area covered by the [GIProbe]. If you make the extents larger without increasing the subdivisions with [member subdiv], the size of each cell will increase and result in lower detailed lighting. The size of the area covered by the [VoxelGI]. If you make the extents larger without increasing the subdivisions with [member subdiv], the size of each cell will increase and result in lower detailed lighting.
</member> </member>
<member name="subdiv" type="int" setter="set_subdiv" getter="get_subdiv" enum="GIProbe.Subdiv" default="1"> <member name="subdiv" type="int" setter="set_subdiv" getter="get_subdiv" enum="VoxelGI.Subdiv" default="1">
Number of times to subdivide the grid that the [GIProbe] operates on. A higher number results in finer detail and thus higher visual quality, while lower numbers result in better performance. Number of times to subdivide the grid that the [VoxelGI] operates on. A higher number results in finer detail and thus higher visual quality, while lower numbers result in better performance.
</member> </member>
</members> </members>
<constants> <constants>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GIProbeData" inherits="Resource" version="4.0"> <class name="VoxelGIData" inherits="Resource" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -119,7 +119,6 @@
#include "editor/plugins/animation_tree_editor_plugin.h" #include "editor/plugins/animation_tree_editor_plugin.h"
#include "editor/plugins/asset_library_editor_plugin.h" #include "editor/plugins/asset_library_editor_plugin.h"
#include "editor/plugins/audio_stream_editor_plugin.h" #include "editor/plugins/audio_stream_editor_plugin.h"
#include "editor/plugins/baked_lightmap_editor_plugin.h"
#include "editor/plugins/camera_3d_editor_plugin.h" #include "editor/plugins/camera_3d_editor_plugin.h"
#include "editor/plugins/canvas_item_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor/plugins/collision_polygon_2d_editor_plugin.h" #include "editor/plugins/collision_polygon_2d_editor_plugin.h"
@ -132,13 +131,13 @@
#include "editor/plugins/editor_debugger_plugin.h" #include "editor/plugins/editor_debugger_plugin.h"
#include "editor/plugins/editor_preview_plugins.h" #include "editor/plugins/editor_preview_plugins.h"
#include "editor/plugins/font_editor_plugin.h" #include "editor/plugins/font_editor_plugin.h"
#include "editor/plugins/gi_probe_editor_plugin.h"
#include "editor/plugins/gpu_particles_2d_editor_plugin.h" #include "editor/plugins/gpu_particles_2d_editor_plugin.h"
#include "editor/plugins/gpu_particles_3d_editor_plugin.h" #include "editor/plugins/gpu_particles_3d_editor_plugin.h"
#include "editor/plugins/gpu_particles_collision_sdf_editor_plugin.h" #include "editor/plugins/gpu_particles_collision_sdf_editor_plugin.h"
#include "editor/plugins/gradient_editor_plugin.h" #include "editor/plugins/gradient_editor_plugin.h"
#include "editor/plugins/item_list_editor_plugin.h" #include "editor/plugins/item_list_editor_plugin.h"
#include "editor/plugins/light_occluder_2d_editor_plugin.h" #include "editor/plugins/light_occluder_2d_editor_plugin.h"
#include "editor/plugins/lightmap_gi_editor_plugin.h"
#include "editor/plugins/line_2d_editor_plugin.h" #include "editor/plugins/line_2d_editor_plugin.h"
#include "editor/plugins/material_editor_plugin.h" #include "editor/plugins/material_editor_plugin.h"
#include "editor/plugins/mesh_editor_plugin.h" #include "editor/plugins/mesh_editor_plugin.h"
@ -175,6 +174,7 @@
#include "editor/plugins/tiles/tiles_editor_plugin.h" #include "editor/plugins/tiles/tiles_editor_plugin.h"
#include "editor/plugins/version_control_editor_plugin.h" #include "editor/plugins/version_control_editor_plugin.h"
#include "editor/plugins/visual_shader_editor_plugin.h" #include "editor/plugins/visual_shader_editor_plugin.h"
#include "editor/plugins/voxel_gi_editor_plugin.h"
#include "editor/progress_dialog.h" #include "editor/progress_dialog.h"
#include "editor/project_export.h" #include "editor/project_export.h"
#include "editor/project_settings_editor.h" #include "editor/project_settings_editor.h"
@ -484,8 +484,8 @@ void EditorNode::_update_from_settings() {
RS::get_singleton()->environment_set_sdfgi_frames_to_converge(frames_to_converge); RS::get_singleton()->environment_set_sdfgi_frames_to_converge(frames_to_converge);
RS::EnvironmentSDFGIRayCount ray_count = RS::EnvironmentSDFGIRayCount(int(GLOBAL_GET("rendering/global_illumination/sdfgi/probe_ray_count"))); RS::EnvironmentSDFGIRayCount ray_count = RS::EnvironmentSDFGIRayCount(int(GLOBAL_GET("rendering/global_illumination/sdfgi/probe_ray_count")));
RS::get_singleton()->environment_set_sdfgi_ray_count(ray_count); RS::get_singleton()->environment_set_sdfgi_ray_count(ray_count);
RS::GIProbeQuality gi_probe_quality = RS::GIProbeQuality(int(GLOBAL_GET("rendering/global_illumination/gi_probes/quality"))); RS::VoxelGIQuality voxel_gi_quality = RS::VoxelGIQuality(int(GLOBAL_GET("rendering/global_illumination/voxel_gi/quality")));
RS::get_singleton()->gi_probe_set_quality(gi_probe_quality); RS::get_singleton()->voxel_gi_set_quality(voxel_gi_quality);
RS::get_singleton()->environment_set_volumetric_fog_volume_size(GLOBAL_GET("rendering/environment/volumetric_fog/volume_size"), GLOBAL_GET("rendering/environment/volumetric_fog/volume_depth")); RS::get_singleton()->environment_set_volumetric_fog_volume_size(GLOBAL_GET("rendering/environment/volumetric_fog/volume_size"), GLOBAL_GET("rendering/environment/volumetric_fog/volume_depth"));
RS::get_singleton()->environment_set_volumetric_fog_filter_active(bool(GLOBAL_GET("rendering/environment/volumetric_fog/use_filter"))); RS::get_singleton()->environment_set_volumetric_fog_filter_active(bool(GLOBAL_GET("rendering/environment/volumetric_fog/use_filter")));
RS::get_singleton()->canvas_set_shadow_texture_size(GLOBAL_GET("rendering/2d/shadow_atlas/size")); RS::get_singleton()->canvas_set_shadow_texture_size(GLOBAL_GET("rendering/2d/shadow_atlas/size"));
@ -6818,8 +6818,8 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(TilesEditorPlugin(this))); add_editor_plugin(memnew(TilesEditorPlugin(this)));
add_editor_plugin(memnew(SpriteFramesEditorPlugin(this))); add_editor_plugin(memnew(SpriteFramesEditorPlugin(this)));
add_editor_plugin(memnew(TextureRegionEditorPlugin(this))); add_editor_plugin(memnew(TextureRegionEditorPlugin(this)));
add_editor_plugin(memnew(GIProbeEditorPlugin(this))); add_editor_plugin(memnew(VoxelGIEditorPlugin(this)));
add_editor_plugin(memnew(BakedLightmapEditorPlugin(this))); add_editor_plugin(memnew(LightmapGIEditorPlugin(this)));
add_editor_plugin(memnew(OccluderInstance3DEditorPlugin(this))); add_editor_plugin(memnew(OccluderInstance3DEditorPlugin(this)));
add_editor_plugin(memnew(Path2DEditorPlugin(this))); add_editor_plugin(memnew(Path2DEditorPlugin(this)));
add_editor_plugin(memnew(Path3DEditorPlugin(this))); add_editor_plugin(memnew(Path3DEditorPlugin(this)));

View file

Before

Width:  |  Height:  |  Size: 247 B

After

Width:  |  Height:  |  Size: 247 B

View file

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 325 B

View file

Before

Width:  |  Height:  |  Size: 420 B

After

Width:  |  Height:  |  Size: 420 B

View file

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 434 B

View file

@ -34,15 +34,14 @@
#include "core/math/geometry_2d.h" #include "core/math/geometry_2d.h"
#include "core/math/geometry_3d.h" #include "core/math/geometry_3d.h"
#include "scene/3d/audio_stream_player_3d.h" #include "scene/3d/audio_stream_player_3d.h"
#include "scene/3d/baked_lightmap.h"
#include "scene/3d/collision_polygon_3d.h" #include "scene/3d/collision_polygon_3d.h"
#include "scene/3d/collision_shape_3d.h" #include "scene/3d/collision_shape_3d.h"
#include "scene/3d/cpu_particles_3d.h" #include "scene/3d/cpu_particles_3d.h"
#include "scene/3d/decal.h" #include "scene/3d/decal.h"
#include "scene/3d/gi_probe.h"
#include "scene/3d/gpu_particles_3d.h" #include "scene/3d/gpu_particles_3d.h"
#include "scene/3d/gpu_particles_collision_3d.h" #include "scene/3d/gpu_particles_collision_3d.h"
#include "scene/3d/light_3d.h" #include "scene/3d/light_3d.h"
#include "scene/3d/lightmap_gi.h"
#include "scene/3d/lightmap_probe.h" #include "scene/3d/lightmap_probe.h"
#include "scene/3d/listener_3d.h" #include "scene/3d/listener_3d.h"
#include "scene/3d/mesh_instance_3d.h" #include "scene/3d/mesh_instance_3d.h"
@ -57,6 +56,7 @@
#include "scene/3d/sprite_3d.h" #include "scene/3d/sprite_3d.h"
#include "scene/3d/vehicle_body_3d.h" #include "scene/3d/vehicle_body_3d.h"
#include "scene/3d/visibility_notifier_3d.h" #include "scene/3d/visibility_notifier_3d.h"
#include "scene/3d/voxel_gi.h"
#include "scene/resources/box_shape_3d.h" #include "scene/resources/box_shape_3d.h"
#include "scene/resources/capsule_shape_3d.h" #include "scene/resources/capsule_shape_3d.h"
#include "scene/resources/concave_polygon_shape_3d.h" #include "scene/resources/concave_polygon_shape_3d.h"
@ -3086,35 +3086,35 @@ void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
} }
/////////////////////////////// ///////////////////////////////
GIProbeGizmoPlugin::GIProbeGizmoPlugin() { VoxelGIGizmoPlugin::VoxelGIGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/gi_probe", Color(0.5, 1, 0.6)); Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/voxel_gi", Color(0.5, 1, 0.6));
create_material("gi_probe_material", gizmo_color); create_material("voxel_gi_material", gizmo_color);
// This gizmo draws a lot of lines. Use a low opacity to make it not too intrusive. // This gizmo draws a lot of lines. Use a low opacity to make it not too intrusive.
gizmo_color.a = 0.1; gizmo_color.a = 0.1;
create_material("gi_probe_internal_material", gizmo_color); create_material("voxel_gi_internal_material", gizmo_color);
gizmo_color.a = 0.05; gizmo_color.a = 0.05;
create_material("gi_probe_solid_material", gizmo_color); create_material("voxel_gi_solid_material", gizmo_color);
create_icon_material("gi_probe_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoGIProbe", "EditorIcons")); create_icon_material("voxel_gi_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoVoxelGI", "EditorIcons"));
create_handle_material("handles"); create_handle_material("handles");
} }
bool GIProbeGizmoPlugin::has_gizmo(Node3D *p_spatial) { bool VoxelGIGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<GIProbe>(p_spatial) != nullptr; return Object::cast_to<VoxelGI>(p_spatial) != nullptr;
} }
String GIProbeGizmoPlugin::get_gizmo_name() const { String VoxelGIGizmoPlugin::get_gizmo_name() const {
return "GIProbe"; return "VoxelGI";
} }
int GIProbeGizmoPlugin::get_priority() const { int VoxelGIGizmoPlugin::get_priority() const {
return -1; return -1;
} }
String GIProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { String VoxelGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
switch (p_idx) { switch (p_idx) {
case 0: case 0:
return "Extents X"; return "Extents X";
@ -3127,13 +3127,13 @@ String GIProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int
return ""; return "";
} }
Variant GIProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { Variant VoxelGIGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node());
return probe->get_extents(); return probe->get_extents();
} }
void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void VoxelGIGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node());
Transform3D gt = probe->get_global_transform(); Transform3D gt = probe->get_global_transform();
Transform3D gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
@ -3163,8 +3163,8 @@ void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer
probe->set_extents(extents); probe->set_extents(extents);
} }
void GIProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { void VoxelGIGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node());
Vector3 restore = p_restore; Vector3 restore = p_restore;
@ -3180,19 +3180,19 @@ void GIProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, co
ur->commit_action(); ur->commit_action();
} }
void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { void VoxelGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node());
Ref<Material> material = get_material("gi_probe_material", p_gizmo); Ref<Material> material = get_material("voxel_gi_material", p_gizmo);
Ref<Material> icon = get_material("gi_probe_icon", p_gizmo); Ref<Material> icon = get_material("voxel_gi_icon", p_gizmo);
Ref<Material> material_internal = get_material("gi_probe_internal_material", p_gizmo); Ref<Material> material_internal = get_material("voxel_gi_internal_material", p_gizmo);
p_gizmo->clear(); p_gizmo->clear();
Vector<Vector3> lines; Vector<Vector3> lines;
Vector3 extents = probe->get_extents(); Vector3 extents = probe->get_extents();
static const int subdivs[GIProbe::SUBDIV_MAX] = { 64, 128, 256, 512 }; static const int subdivs[VoxelGI::SUBDIV_MAX] = { 64, 128, 256, 512 };
AABB aabb = AABB(-extents, extents * 2); AABB aabb = AABB(-extents, extents * 2);
int subdiv = subdivs[probe->get_subdiv()]; int subdiv = subdivs[probe->get_subdiv()];
@ -3256,7 +3256,7 @@ void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
} }
if (p_gizmo->is_selected()) { if (p_gizmo->is_selected()) {
Ref<Material> solid_material = get_material("gi_probe_solid_material", p_gizmo); Ref<Material> solid_material = get_material("voxel_gi_solid_material", p_gizmo);
p_gizmo->add_solid_box(solid_material, aabb.get_size()); p_gizmo->add_solid_box(solid_material, aabb.get_size());
} }
@ -3266,7 +3266,7 @@ void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
//// ////
BakedLightmapGizmoPlugin::BakedLightmapGizmoPlugin() { LightmapGIGizmoPlugin::LightmapGIGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/lightmap_lines", Color(0.5, 0.6, 1)); Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/lightmap_lines", Color(0.5, 0.6, 1));
gizmo_color.a = 0.1; gizmo_color.a = 0.1;
@ -3280,39 +3280,39 @@ BakedLightmapGizmoPlugin::BakedLightmapGizmoPlugin() {
add_material("lightmap_probe_material", mat); add_material("lightmap_probe_material", mat);
create_icon_material("baked_indirect_light_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoBakedLightmap", "EditorIcons")); create_icon_material("baked_indirect_light_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoLightmapGI", "EditorIcons"));
} }
String BakedLightmapGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { String LightmapGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
return ""; return "";
} }
Variant BakedLightmapGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { Variant LightmapGIGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
return Variant(); return Variant();
} }
void BakedLightmapGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void LightmapGIGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
} }
void BakedLightmapGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { void LightmapGIGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
} }
bool BakedLightmapGizmoPlugin::has_gizmo(Node3D *p_spatial) { bool LightmapGIGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<BakedLightmap>(p_spatial) != nullptr; return Object::cast_to<LightmapGI>(p_spatial) != nullptr;
} }
String BakedLightmapGizmoPlugin::get_gizmo_name() const { String LightmapGIGizmoPlugin::get_gizmo_name() const {
return "BakedLightmap"; return "LightmapGI";
} }
int BakedLightmapGizmoPlugin::get_priority() const { int LightmapGIGizmoPlugin::get_priority() const {
return -1; return -1;
} }
void BakedLightmapGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Ref<Material> icon = get_material("baked_indirect_light_icon", p_gizmo); Ref<Material> icon = get_material("baked_indirect_light_icon", p_gizmo);
BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node()); LightmapGI *baker = Object::cast_to<LightmapGI>(p_gizmo->get_spatial_node());
Ref<BakedLightmapData> data = baker->get_light_data(); Ref<LightmapGIData> data = baker->get_light_data();
p_gizmo->add_unscaled_billboard(icon, 0.05); p_gizmo->add_unscaled_billboard(icon, 0.05);

View file

@ -316,8 +316,8 @@ public:
DecalGizmoPlugin(); DecalGizmoPlugin();
}; };
class GIProbeGizmoPlugin : public EditorNode3DGizmoPlugin { class VoxelGIGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(GIProbeGizmoPlugin, EditorNode3DGizmoPlugin); GDCLASS(VoxelGIGizmoPlugin, EditorNode3DGizmoPlugin);
public: public:
bool has_gizmo(Node3D *p_spatial) override; bool has_gizmo(Node3D *p_spatial) override;
@ -330,11 +330,11 @@ public:
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override;
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override;
GIProbeGizmoPlugin(); VoxelGIGizmoPlugin();
}; };
class BakedLightmapGizmoPlugin : public EditorNode3DGizmoPlugin { class LightmapGIGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(BakedLightmapGizmoPlugin, EditorNode3DGizmoPlugin); GDCLASS(LightmapGIGizmoPlugin, EditorNode3DGizmoPlugin);
public: public:
bool has_gizmo(Node3D *p_spatial) override; bool has_gizmo(Node3D *p_spatial) override;
@ -347,7 +347,7 @@ public:
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override;
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override;
BakedLightmapGizmoPlugin(); LightmapGIGizmoPlugin();
}; };
class LightmapProbeGizmoPlugin : public EditorNode3DGizmoPlugin { class LightmapProbeGizmoPlugin : public EditorNode3DGizmoPlugin {

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* baked_lightmap_editor_plugin.cpp */ /* lightmap_gi_editor_plugin.cpp */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include "baked_lightmap_editor_plugin.h" #include "lightmap_gi_editor_plugin.h"
void BakedLightmapEditorPlugin::_bake_select_file(const String &p_file) { void LightmapGIEditorPlugin::_bake_select_file(const String &p_file) {
if (lightmap) { if (lightmap) {
BakedLightmap::BakeError err; LightmapGI::BakeError err;
if (get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root() == lightmap) { if (get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root() == lightmap) {
err = lightmap->bake(lightmap, p_file, bake_func_step); err = lightmap->bake(lightmap, p_file, bake_func_step);
} else { } else {
@ -42,7 +42,7 @@ void BakedLightmapEditorPlugin::_bake_select_file(const String &p_file) {
bake_func_end(); bake_func_end();
switch (err) { switch (err) {
case BakedLightmap::BAKE_ERROR_NO_SAVE_PATH: { case LightmapGI::BAKE_ERROR_NO_SAVE_PATH: {
String scene_path = lightmap->get_filename(); String scene_path = lightmap->get_filename();
if (scene_path == String()) { if (scene_path == String()) {
scene_path = lightmap->get_owner()->get_filename(); scene_path = lightmap->get_owner()->get_filename();
@ -57,10 +57,10 @@ void BakedLightmapEditorPlugin::_bake_select_file(const String &p_file) {
file_dialog->popup_file_dialog(); file_dialog->popup_file_dialog();
} break; } break;
case BakedLightmap::BAKE_ERROR_NO_MESHES: case LightmapGI::BAKE_ERROR_NO_MESHES:
EditorNode::get_singleton()->show_warning(TTR("No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake Light' flag is on.")); EditorNode::get_singleton()->show_warning(TTR("No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake Light' flag is on."));
break; break;
case BakedLightmap::BAKE_ERROR_CANT_CREATE_IMAGE: case LightmapGI::BAKE_ERROR_CANT_CREATE_IMAGE:
EditorNode::get_singleton()->show_warning(TTR("Failed creating lightmap images, make sure path is writable.")); EditorNode::get_singleton()->show_warning(TTR("Failed creating lightmap images, make sure path is writable."));
break; break;
default: { default: {
@ -69,12 +69,12 @@ void BakedLightmapEditorPlugin::_bake_select_file(const String &p_file) {
} }
} }
void BakedLightmapEditorPlugin::_bake() { void LightmapGIEditorPlugin::_bake() {
_bake_select_file(""); _bake_select_file("");
} }
void BakedLightmapEditorPlugin::edit(Object *p_object) { void LightmapGIEditorPlugin::edit(Object *p_object) {
BakedLightmap *s = Object::cast_to<BakedLightmap>(p_object); LightmapGI *s = Object::cast_to<LightmapGI>(p_object);
if (!s) { if (!s) {
return; return;
} }
@ -82,11 +82,11 @@ void BakedLightmapEditorPlugin::edit(Object *p_object) {
lightmap = s; lightmap = s;
} }
bool BakedLightmapEditorPlugin::handles(Object *p_object) const { bool LightmapGIEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("BakedLightmap"); return p_object->is_class("LightmapGI");
} }
void BakedLightmapEditorPlugin::make_visible(bool p_visible) { void LightmapGIEditorPlugin::make_visible(bool p_visible) {
if (p_visible) { if (p_visible) {
bake->show(); bake->show();
} else { } else {
@ -94,9 +94,9 @@ void BakedLightmapEditorPlugin::make_visible(bool p_visible) {
} }
} }
EditorProgress *BakedLightmapEditorPlugin::tmp_progress = nullptr; EditorProgress *LightmapGIEditorPlugin::tmp_progress = nullptr;
bool BakedLightmapEditorPlugin::bake_func_step(float p_progress, const String &p_description, void *, bool p_refresh) { bool LightmapGIEditorPlugin::bake_func_step(float p_progress, const String &p_description, void *, bool p_refresh) {
if (!tmp_progress) { if (!tmp_progress) {
tmp_progress = memnew(EditorProgress("bake_lightmaps", TTR("Bake Lightmaps"), 1000, false)); tmp_progress = memnew(EditorProgress("bake_lightmaps", TTR("Bake Lightmaps"), 1000, false));
ERR_FAIL_COND_V(tmp_progress == nullptr, false); ERR_FAIL_COND_V(tmp_progress == nullptr, false);
@ -104,18 +104,18 @@ bool BakedLightmapEditorPlugin::bake_func_step(float p_progress, const String &p
return tmp_progress->step(p_description, p_progress * 1000, p_refresh); return tmp_progress->step(p_description, p_progress * 1000, p_refresh);
} }
void BakedLightmapEditorPlugin::bake_func_end() { void LightmapGIEditorPlugin::bake_func_end() {
if (tmp_progress != nullptr) { if (tmp_progress != nullptr) {
memdelete(tmp_progress); memdelete(tmp_progress);
tmp_progress = nullptr; tmp_progress = nullptr;
} }
} }
void BakedLightmapEditorPlugin::_bind_methods() { void LightmapGIEditorPlugin::_bind_methods() {
ClassDB::bind_method("_bake", &BakedLightmapEditorPlugin::_bake); ClassDB::bind_method("_bake", &LightmapGIEditorPlugin::_bake);
} }
BakedLightmapEditorPlugin::BakedLightmapEditorPlugin(EditorNode *p_node) { LightmapGIEditorPlugin::LightmapGIEditorPlugin(EditorNode *p_node) {
editor = p_node; editor = p_node;
bake = memnew(Button); bake = memnew(Button);
bake->set_flat(true); bake->set_flat(true);
@ -130,9 +130,9 @@ BakedLightmapEditorPlugin::BakedLightmapEditorPlugin(EditorNode *p_node) {
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->add_filter("*.lmbake ; LightMap Bake"); file_dialog->add_filter("*.lmbake ; LightMap Bake");
file_dialog->set_title(TTR("Select lightmap bake file:")); file_dialog->set_title(TTR("Select lightmap bake file:"));
file_dialog->connect("file_selected", callable_mp(this, &BakedLightmapEditorPlugin::_bake_select_file)); file_dialog->connect("file_selected", callable_mp(this, &LightmapGIEditorPlugin::_bake_select_file));
bake->add_child(file_dialog); bake->add_child(file_dialog);
} }
BakedLightmapEditorPlugin::~BakedLightmapEditorPlugin() { LightmapGIEditorPlugin::~LightmapGIEditorPlugin() {
} }

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* baked_lightmap_editor_plugin.h */ /* lightmap_gi_editor_plugin.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -33,13 +33,13 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_plugin.h" #include "editor/editor_plugin.h"
#include "scene/3d/baked_lightmap.h" #include "scene/3d/lightmap_gi.h"
#include "scene/resources/material.h" #include "scene/resources/material.h"
class BakedLightmapEditorPlugin : public EditorPlugin { class LightmapGIEditorPlugin : public EditorPlugin {
GDCLASS(BakedLightmapEditorPlugin, EditorPlugin); GDCLASS(LightmapGIEditorPlugin, EditorPlugin);
BakedLightmap *lightmap; LightmapGI *lightmap;
Button *bake; Button *bake;
EditorNode *editor; EditorNode *editor;
@ -56,14 +56,14 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
virtual String get_name() const override { return "BakedLightmap"; } virtual String get_name() const override { return "LightmapGI"; }
bool has_main_screen() const override { return false; } bool has_main_screen() const override { return false; }
virtual void edit(Object *p_object) override; virtual void edit(Object *p_object) override;
virtual bool handles(Object *p_object) const override; virtual bool handles(Object *p_object) const override;
virtual void make_visible(bool p_visible) override; virtual void make_visible(bool p_visible) override;
BakedLightmapEditorPlugin(EditorNode *p_node); LightmapGIEditorPlugin(EditorNode *p_node);
~BakedLightmapEditorPlugin(); ~LightmapGIEditorPlugin();
}; };
#endif #endif

View file

@ -3060,9 +3060,9 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_DISPLAY_NORMAL_BUFFER: case VIEW_DISPLAY_NORMAL_BUFFER:
case VIEW_DISPLAY_DEBUG_SHADOW_ATLAS: case VIEW_DISPLAY_DEBUG_SHADOW_ATLAS:
case VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS: case VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS:
case VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO: case VIEW_DISPLAY_DEBUG_VOXEL_GI_ALBEDO:
case VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING: case VIEW_DISPLAY_DEBUG_VOXEL_GI_LIGHTING:
case VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION: case VIEW_DISPLAY_DEBUG_VOXEL_GI_EMISSION:
case VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE: case VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE:
case VIEW_DISPLAY_DEBUG_SSAO: case VIEW_DISPLAY_DEBUG_SSAO:
case VIEW_DISPLAY_DEBUG_PSSM_SPLITS: case VIEW_DISPLAY_DEBUG_PSSM_SPLITS:
@ -3086,9 +3086,9 @@ void Node3DEditorViewport::_menu_option(int p_option) {
VIEW_DISPLAY_WIREFRAME, VIEW_DISPLAY_WIREFRAME,
VIEW_DISPLAY_DEBUG_SHADOW_ATLAS, VIEW_DISPLAY_DEBUG_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS, VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO, VIEW_DISPLAY_DEBUG_VOXEL_GI_ALBEDO,
VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING, VIEW_DISPLAY_DEBUG_VOXEL_GI_LIGHTING,
VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION, VIEW_DISPLAY_DEBUG_VOXEL_GI_EMISSION,
VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE, VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE,
VIEW_DISPLAY_DEBUG_SSAO, VIEW_DISPLAY_DEBUG_SSAO,
VIEW_DISPLAY_DEBUG_GI_BUFFER, VIEW_DISPLAY_DEBUG_GI_BUFFER,
@ -3114,9 +3114,9 @@ void Node3DEditorViewport::_menu_option(int p_option) {
Viewport::DEBUG_DRAW_WIREFRAME, Viewport::DEBUG_DRAW_WIREFRAME,
Viewport::DEBUG_DRAW_SHADOW_ATLAS, Viewport::DEBUG_DRAW_SHADOW_ATLAS,
Viewport::DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS, Viewport::DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
Viewport::DEBUG_DRAW_GI_PROBE_ALBEDO, Viewport::DEBUG_DRAW_VOXEL_GI_ALBEDO,
Viewport::DEBUG_DRAW_GI_PROBE_LIGHTING, Viewport::DEBUG_DRAW_VOXEL_GI_LIGHTING,
Viewport::DEBUG_DRAW_GI_PROBE_EMISSION, Viewport::DEBUG_DRAW_VOXEL_GI_EMISSION,
Viewport::DEBUG_DRAW_SCENE_LUMINANCE, Viewport::DEBUG_DRAW_SCENE_LUMINANCE,
Viewport::DEBUG_DRAW_SSAO, Viewport::DEBUG_DRAW_SSAO,
Viewport::DEBUG_DRAW_GI_BUFFER, Viewport::DEBUG_DRAW_GI_BUFFER,
@ -4036,9 +4036,9 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
display_submenu->add_separator(); display_submenu->add_separator();
display_submenu->add_radio_check_item(TTR("Decal Atlas"), VIEW_DISPLAY_DEBUG_DECAL_ATLAS); display_submenu->add_radio_check_item(TTR("Decal Atlas"), VIEW_DISPLAY_DEBUG_DECAL_ATLAS);
display_submenu->add_separator(); display_submenu->add_separator();
display_submenu->add_radio_check_item(TTR("GIProbe Lighting"), VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING); display_submenu->add_radio_check_item(TTR("VoxelGI Lighting"), VIEW_DISPLAY_DEBUG_VOXEL_GI_LIGHTING);
display_submenu->add_radio_check_item(TTR("GIProbe Albedo"), VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO); display_submenu->add_radio_check_item(TTR("VoxelGI Albedo"), VIEW_DISPLAY_DEBUG_VOXEL_GI_ALBEDO);
display_submenu->add_radio_check_item(TTR("GIProbe Emission"), VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION); display_submenu->add_radio_check_item(TTR("VoxelGI Emission"), VIEW_DISPLAY_DEBUG_VOXEL_GI_EMISSION);
display_submenu->add_separator(); display_submenu->add_separator();
display_submenu->add_radio_check_item(TTR("SDFGI Cascades"), VIEW_DISPLAY_DEBUG_SDFGI); display_submenu->add_radio_check_item(TTR("SDFGI Cascades"), VIEW_DISPLAY_DEBUG_SDFGI);
display_submenu->add_radio_check_item(TTR("SDFGI Probes"), VIEW_DISPLAY_DEBUG_SDFGI_PROBES); display_submenu->add_radio_check_item(TTR("SDFGI Probes"), VIEW_DISPLAY_DEBUG_SDFGI_PROBES);
@ -6496,8 +6496,8 @@ void Node3DEditor::_register_all_gizmos() {
add_gizmo_plugin(Ref<CPUParticles3DGizmoPlugin>(memnew(CPUParticles3DGizmoPlugin))); add_gizmo_plugin(Ref<CPUParticles3DGizmoPlugin>(memnew(CPUParticles3DGizmoPlugin)));
add_gizmo_plugin(Ref<ReflectionProbeGizmoPlugin>(memnew(ReflectionProbeGizmoPlugin))); add_gizmo_plugin(Ref<ReflectionProbeGizmoPlugin>(memnew(ReflectionProbeGizmoPlugin)));
add_gizmo_plugin(Ref<DecalGizmoPlugin>(memnew(DecalGizmoPlugin))); add_gizmo_plugin(Ref<DecalGizmoPlugin>(memnew(DecalGizmoPlugin)));
add_gizmo_plugin(Ref<GIProbeGizmoPlugin>(memnew(GIProbeGizmoPlugin))); add_gizmo_plugin(Ref<VoxelGIGizmoPlugin>(memnew(VoxelGIGizmoPlugin)));
add_gizmo_plugin(Ref<BakedLightmapGizmoPlugin>(memnew(BakedLightmapGizmoPlugin))); add_gizmo_plugin(Ref<LightmapGIGizmoPlugin>(memnew(LightmapGIGizmoPlugin)));
add_gizmo_plugin(Ref<LightmapProbeGizmoPlugin>(memnew(LightmapProbeGizmoPlugin))); add_gizmo_plugin(Ref<LightmapProbeGizmoPlugin>(memnew(LightmapProbeGizmoPlugin)));
add_gizmo_plugin(Ref<CollisionObject3DGizmoPlugin>(memnew(CollisionObject3DGizmoPlugin))); add_gizmo_plugin(Ref<CollisionObject3DGizmoPlugin>(memnew(CollisionObject3DGizmoPlugin)));
add_gizmo_plugin(Ref<CollisionShape3DGizmoPlugin>(memnew(CollisionShape3DGizmoPlugin))); add_gizmo_plugin(Ref<CollisionShape3DGizmoPlugin>(memnew(CollisionShape3DGizmoPlugin)));

View file

@ -206,9 +206,9 @@ class Node3DEditorViewport : public Control {
VIEW_DISPLAY_NORMAL_BUFFER, VIEW_DISPLAY_NORMAL_BUFFER,
VIEW_DISPLAY_DEBUG_SHADOW_ATLAS, VIEW_DISPLAY_DEBUG_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS, VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO, VIEW_DISPLAY_DEBUG_VOXEL_GI_ALBEDO,
VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING, VIEW_DISPLAY_DEBUG_VOXEL_GI_LIGHTING,
VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION, VIEW_DISPLAY_DEBUG_VOXEL_GI_EMISSION,
VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE, VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE,
VIEW_DISPLAY_DEBUG_SSAO, VIEW_DISPLAY_DEBUG_SSAO,
VIEW_DISPLAY_DEBUG_PSSM_SPLITS, VIEW_DISPLAY_DEBUG_PSSM_SPLITS,

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* gi_probe_editor_plugin.cpp */ /* voxel_gi_editor_plugin.cpp */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,49 +28,49 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include "gi_probe_editor_plugin.h" #include "voxel_gi_editor_plugin.h"
void GIProbeEditorPlugin::_bake() { void VoxelGIEditorPlugin::_bake() {
if (gi_probe) { if (voxel_gi) {
if (gi_probe->get_probe_data().is_null()) { if (voxel_gi->get_probe_data().is_null()) {
String path = get_tree()->get_edited_scene_root()->get_filename(); String path = get_tree()->get_edited_scene_root()->get_filename();
if (path == String()) { if (path == String()) {
path = "res://" + gi_probe->get_name() + "_data.res"; path = "res://" + voxel_gi->get_name() + "_data.res";
} else { } else {
String ext = path.get_extension(); String ext = path.get_extension();
path = path.get_basename() + "." + gi_probe->get_name() + "_data.res"; path = path.get_basename() + "." + voxel_gi->get_name() + "_data.res";
} }
probe_file->set_current_path(path); probe_file->set_current_path(path);
probe_file->popup_file_dialog(); probe_file->popup_file_dialog();
return; return;
} }
gi_probe->bake(); voxel_gi->bake();
} }
} }
void GIProbeEditorPlugin::edit(Object *p_object) { void VoxelGIEditorPlugin::edit(Object *p_object) {
GIProbe *s = Object::cast_to<GIProbe>(p_object); VoxelGI *s = Object::cast_to<VoxelGI>(p_object);
if (!s) { if (!s) {
return; return;
} }
gi_probe = s; voxel_gi = s;
} }
bool GIProbeEditorPlugin::handles(Object *p_object) const { bool VoxelGIEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("GIProbe"); return p_object->is_class("VoxelGI");
} }
void GIProbeEditorPlugin::_notification(int p_what) { void VoxelGIEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_PROCESS) { if (p_what == NOTIFICATION_PROCESS) {
if (!gi_probe) { if (!voxel_gi) {
return; return;
} }
const Vector3i size = gi_probe->get_estimated_cell_size(); const Vector3i size = voxel_gi->get_estimated_cell_size();
String text = vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z); String text = vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z);
int data_size = 4; int data_size = 4;
if (GLOBAL_GET("rendering/quality/gi_probes/anisotropic")) { if (GLOBAL_GET("rendering/quality/voxel_gi/anisotropic")) {
data_size += 4; data_size += 4;
} }
const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0);
@ -98,7 +98,7 @@ void GIProbeEditorPlugin::_notification(int p_what) {
} }
} }
void GIProbeEditorPlugin::make_visible(bool p_visible) { void VoxelGIEditorPlugin::make_visible(bool p_visible) {
if (p_visible) { if (p_visible) {
bake_hb->show(); bake_hb->show();
set_process(true); set_process(true);
@ -108,38 +108,38 @@ void GIProbeEditorPlugin::make_visible(bool p_visible) {
} }
} }
EditorProgress *GIProbeEditorPlugin::tmp_progress = nullptr; EditorProgress *VoxelGIEditorPlugin::tmp_progress = nullptr;
void GIProbeEditorPlugin::bake_func_begin(int p_steps) { void VoxelGIEditorPlugin::bake_func_begin(int p_steps) {
ERR_FAIL_COND(tmp_progress != nullptr); ERR_FAIL_COND(tmp_progress != nullptr);
tmp_progress = memnew(EditorProgress("bake_gi", TTR("Bake GI Probe"), p_steps)); tmp_progress = memnew(EditorProgress("bake_gi", TTR("Bake GI Probe"), p_steps));
} }
void GIProbeEditorPlugin::bake_func_step(int p_step, const String &p_description) { void VoxelGIEditorPlugin::bake_func_step(int p_step, const String &p_description) {
ERR_FAIL_COND(tmp_progress == nullptr); ERR_FAIL_COND(tmp_progress == nullptr);
tmp_progress->step(p_description, p_step, false); tmp_progress->step(p_description, p_step, false);
} }
void GIProbeEditorPlugin::bake_func_end() { void VoxelGIEditorPlugin::bake_func_end() {
ERR_FAIL_COND(tmp_progress == nullptr); ERR_FAIL_COND(tmp_progress == nullptr);
memdelete(tmp_progress); memdelete(tmp_progress);
tmp_progress = nullptr; tmp_progress = nullptr;
} }
void GIProbeEditorPlugin::_giprobe_save_path_and_bake(const String &p_path) { void VoxelGIEditorPlugin::_voxel_gi_save_path_and_bake(const String &p_path) {
probe_file->hide(); probe_file->hide();
if (gi_probe) { if (voxel_gi) {
gi_probe->bake(); voxel_gi->bake();
ERR_FAIL_COND(gi_probe->get_probe_data().is_null()); ERR_FAIL_COND(voxel_gi->get_probe_data().is_null());
ResourceSaver::save(p_path, gi_probe->get_probe_data(), ResourceSaver::FLAG_CHANGE_PATH); ResourceSaver::save(p_path, voxel_gi->get_probe_data(), ResourceSaver::FLAG_CHANGE_PATH);
} }
} }
void GIProbeEditorPlugin::_bind_methods() { void VoxelGIEditorPlugin::_bind_methods() {
} }
GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) { VoxelGIEditorPlugin::VoxelGIEditorPlugin(EditorNode *p_node) {
editor = p_node; editor = p_node;
bake_hb = memnew(HBoxContainer); bake_hb = memnew(HBoxContainer);
bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@ -148,7 +148,7 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
bake->set_flat(true); bake->set_flat(true);
bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons"));
bake->set_text(TTR("Bake GI Probe")); bake->set_text(TTR("Bake GI Probe"));
bake->connect("pressed", callable_mp(this, &GIProbeEditorPlugin::_bake)); bake->connect("pressed", callable_mp(this, &VoxelGIEditorPlugin::_bake));
bake_hb->add_child(bake); bake_hb->add_child(bake);
bake_info = memnew(Label); bake_info = memnew(Label);
bake_info->set_h_size_flags(Control::SIZE_EXPAND_FILL); bake_info->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@ -156,18 +156,18 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
bake_hb->add_child(bake_info); bake_hb->add_child(bake_info);
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb);
gi_probe = nullptr; voxel_gi = nullptr;
probe_file = memnew(EditorFileDialog); probe_file = memnew(EditorFileDialog);
probe_file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); probe_file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
probe_file->add_filter("*.res"); probe_file->add_filter("*.res");
probe_file->connect("file_selected", callable_mp(this, &GIProbeEditorPlugin::_giprobe_save_path_and_bake)); probe_file->connect("file_selected", callable_mp(this, &VoxelGIEditorPlugin::_voxel_gi_save_path_and_bake));
get_editor_interface()->get_base_control()->add_child(probe_file); get_editor_interface()->get_base_control()->add_child(probe_file);
probe_file->set_title(TTR("Select path for GIProbe Data File")); probe_file->set_title(TTR("Select path for VoxelGI Data File"));
GIProbe::bake_begin_function = bake_func_begin; VoxelGI::bake_begin_function = bake_func_begin;
GIProbe::bake_step_function = bake_func_step; VoxelGI::bake_step_function = bake_func_step;
GIProbe::bake_end_function = bake_func_end; VoxelGI::bake_end_function = bake_func_end;
} }
GIProbeEditorPlugin::~GIProbeEditorPlugin() { VoxelGIEditorPlugin::~VoxelGIEditorPlugin() {
} }

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* gi_probe_editor_plugin.h */ /* voxel_gi_editor_plugin.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 GIPROBEEDITORPLUGIN_H #ifndef VOXEL_GIEDITORPLUGIN_H
#define GIPROBEEDITORPLUGIN_H #define VOXEL_GIEDITORPLUGIN_H
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_plugin.h" #include "editor/editor_plugin.h"
#include "scene/3d/gi_probe.h" #include "scene/3d/voxel_gi.h"
#include "scene/resources/material.h" #include "scene/resources/material.h"
class GIProbeEditorPlugin : public EditorPlugin { class VoxelGIEditorPlugin : public EditorPlugin {
GDCLASS(GIProbeEditorPlugin, EditorPlugin); GDCLASS(VoxelGIEditorPlugin, EditorPlugin);
GIProbe *gi_probe; VoxelGI *voxel_gi;
HBoxContainer *bake_hb; HBoxContainer *bake_hb;
Label *bake_info; Label *bake_info;
@ -54,21 +54,21 @@ class GIProbeEditorPlugin : public EditorPlugin {
static void bake_func_end(); static void bake_func_end();
void _bake(); void _bake();
void _giprobe_save_path_and_bake(const String &p_path); void _voxel_gi_save_path_and_bake(const String &p_path);
protected: protected:
static void _bind_methods(); static void _bind_methods();
void _notification(int p_what); void _notification(int p_what);
public: public:
virtual String get_name() const override { return "GIProbe"; } virtual String get_name() const override { return "VoxelGI"; }
bool has_main_screen() const override { return false; } bool has_main_screen() const override { return false; }
virtual void edit(Object *p_object) override; virtual void edit(Object *p_object) override;
virtual bool handles(Object *p_object) const override; virtual bool handles(Object *p_object) const override;
virtual void make_visible(bool p_visible) override; virtual void make_visible(bool p_visible) override;
GIProbeEditorPlugin(EditorNode *p_node); VoxelGIEditorPlugin(EditorNode *p_node);
~GIProbeEditorPlugin(); ~VoxelGIEditorPlugin();
}; };
#endif // GIPROBEEDITORPLUGIN_H #endif // VOXEL_GIEDITORPLUGIN_H

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* baked_lightmap.cpp */ /* lightmap_gi.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 "baked_lightmap.h" #include "lightmap_gi.h"
#include "core/io/config_file.h" #include "core/io/config_file.h"
#include "core/io/resource_saver.h" #include "core/io/resource_saver.h"
@ -40,7 +40,7 @@
#include "core/templates/sort_array.h" #include "core/templates/sort_array.h"
#include "lightmap_probe.h" #include "lightmap_probe.h"
void BakedLightmapData::add_user(const NodePath &p_path, const Rect2 &p_uv_scale, int p_slice_index, int32_t p_sub_instance) { void LightmapGIData::add_user(const NodePath &p_path, const Rect2 &p_uv_scale, int p_slice_index, int32_t p_sub_instance) {
User user; User user;
user.path = p_path; user.path = p_path;
user.uv_scale = p_uv_scale; user.uv_scale = p_uv_scale;
@ -49,35 +49,35 @@ void BakedLightmapData::add_user(const NodePath &p_path, const Rect2 &p_uv_scale
users.push_back(user); users.push_back(user);
} }
int BakedLightmapData::get_user_count() const { int LightmapGIData::get_user_count() const {
return users.size(); return users.size();
} }
NodePath BakedLightmapData::get_user_path(int p_user) const { NodePath LightmapGIData::get_user_path(int p_user) const {
ERR_FAIL_INDEX_V(p_user, users.size(), NodePath()); ERR_FAIL_INDEX_V(p_user, users.size(), NodePath());
return users[p_user].path; return users[p_user].path;
} }
int32_t BakedLightmapData::get_user_sub_instance(int p_user) const { int32_t LightmapGIData::get_user_sub_instance(int p_user) const {
ERR_FAIL_INDEX_V(p_user, users.size(), -1); ERR_FAIL_INDEX_V(p_user, users.size(), -1);
return users[p_user].sub_instance; return users[p_user].sub_instance;
} }
Rect2 BakedLightmapData::get_user_lightmap_uv_scale(int p_user) const { Rect2 LightmapGIData::get_user_lightmap_uv_scale(int p_user) const {
ERR_FAIL_INDEX_V(p_user, users.size(), Rect2()); ERR_FAIL_INDEX_V(p_user, users.size(), Rect2());
return users[p_user].uv_scale; return users[p_user].uv_scale;
} }
int BakedLightmapData::get_user_lightmap_slice_index(int p_user) const { int LightmapGIData::get_user_lightmap_slice_index(int p_user) const {
ERR_FAIL_INDEX_V(p_user, users.size(), -1); ERR_FAIL_INDEX_V(p_user, users.size(), -1);
return users[p_user].slice_index; return users[p_user].slice_index;
} }
void BakedLightmapData::clear_users() { void LightmapGIData::clear_users() {
users.clear(); users.clear();
} }
void BakedLightmapData::_set_user_data(const Array &p_data) { void LightmapGIData::_set_user_data(const Array &p_data) {
ERR_FAIL_COND(p_data.size() <= 0); ERR_FAIL_COND(p_data.size() <= 0);
ERR_FAIL_COND((p_data.size() % 4) != 0); ERR_FAIL_COND((p_data.size() % 4) != 0);
@ -86,7 +86,7 @@ void BakedLightmapData::_set_user_data(const Array &p_data) {
} }
} }
Array BakedLightmapData::_get_user_data() const { Array LightmapGIData::_get_user_data() const {
Array ret; Array ret;
for (int i = 0; i < users.size(); i++) { for (int i = 0; i < users.size(); i++) {
ret.push_back(users[i].path); ret.push_back(users[i].path);
@ -97,33 +97,33 @@ Array BakedLightmapData::_get_user_data() const {
return ret; return ret;
} }
RID BakedLightmapData::get_rid() const { RID LightmapGIData::get_rid() const {
return lightmap; return lightmap;
} }
void BakedLightmapData::clear() { void LightmapGIData::clear() {
users.clear(); users.clear();
} }
void BakedLightmapData::set_light_texture(const Ref<TextureLayered> &p_light_texture) { void LightmapGIData::set_light_texture(const Ref<TextureLayered> &p_light_texture) {
light_texture = p_light_texture; light_texture = p_light_texture;
RS::get_singleton()->lightmap_set_textures(lightmap, light_texture.is_valid() ? light_texture->get_rid() : RID(), uses_spherical_harmonics); RS::get_singleton()->lightmap_set_textures(lightmap, light_texture.is_valid() ? light_texture->get_rid() : RID(), uses_spherical_harmonics);
} }
Ref<TextureLayered> BakedLightmapData::get_light_texture() const { Ref<TextureLayered> LightmapGIData::get_light_texture() const {
return light_texture; return light_texture;
} }
void BakedLightmapData::set_uses_spherical_harmonics(bool p_enable) { void LightmapGIData::set_uses_spherical_harmonics(bool p_enable) {
uses_spherical_harmonics = p_enable; uses_spherical_harmonics = p_enable;
RS::get_singleton()->lightmap_set_textures(lightmap, light_texture.is_valid() ? light_texture->get_rid() : RID(), uses_spherical_harmonics); RS::get_singleton()->lightmap_set_textures(lightmap, light_texture.is_valid() ? light_texture->get_rid() : RID(), uses_spherical_harmonics);
} }
bool BakedLightmapData::is_using_spherical_harmonics() const { bool LightmapGIData::is_using_spherical_harmonics() const {
return uses_spherical_harmonics; return uses_spherical_harmonics;
} }
void BakedLightmapData::set_capture_data(const AABB &p_bounds, bool p_interior, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) { void LightmapGIData::set_capture_data(const AABB &p_bounds, bool p_interior, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) {
if (p_points.size()) { if (p_points.size()) {
int pc = p_points.size(); int pc = p_points.size();
ERR_FAIL_COND(pc * 9 != p_point_sh.size()); ERR_FAIL_COND(pc * 9 != p_point_sh.size());
@ -141,31 +141,31 @@ void BakedLightmapData::set_capture_data(const AABB &p_bounds, bool p_interior,
bounds = p_bounds; bounds = p_bounds;
} }
PackedVector3Array BakedLightmapData::get_capture_points() const { PackedVector3Array LightmapGIData::get_capture_points() const {
return RS::get_singleton()->lightmap_get_probe_capture_points(lightmap); return RS::get_singleton()->lightmap_get_probe_capture_points(lightmap);
} }
PackedColorArray BakedLightmapData::get_capture_sh() const { PackedColorArray LightmapGIData::get_capture_sh() const {
return RS::get_singleton()->lightmap_get_probe_capture_sh(lightmap); return RS::get_singleton()->lightmap_get_probe_capture_sh(lightmap);
} }
PackedInt32Array BakedLightmapData::get_capture_tetrahedra() const { PackedInt32Array LightmapGIData::get_capture_tetrahedra() const {
return RS::get_singleton()->lightmap_get_probe_capture_tetrahedra(lightmap); return RS::get_singleton()->lightmap_get_probe_capture_tetrahedra(lightmap);
} }
PackedInt32Array BakedLightmapData::get_capture_bsp_tree() const { PackedInt32Array LightmapGIData::get_capture_bsp_tree() const {
return RS::get_singleton()->lightmap_get_probe_capture_bsp_tree(lightmap); return RS::get_singleton()->lightmap_get_probe_capture_bsp_tree(lightmap);
} }
AABB BakedLightmapData::get_capture_bounds() const { AABB LightmapGIData::get_capture_bounds() const {
return bounds; return bounds;
} }
bool BakedLightmapData::is_interior() const { bool LightmapGIData::is_interior() const {
return interior; return interior;
} }
void BakedLightmapData::_set_probe_data(const Dictionary &p_data) { void LightmapGIData::_set_probe_data(const Dictionary &p_data) {
ERR_FAIL_COND(!p_data.has("bounds")); ERR_FAIL_COND(!p_data.has("bounds"));
ERR_FAIL_COND(!p_data.has("points")); ERR_FAIL_COND(!p_data.has("points"));
ERR_FAIL_COND(!p_data.has("tetrahedra")); ERR_FAIL_COND(!p_data.has("tetrahedra"));
@ -175,7 +175,7 @@ void BakedLightmapData::_set_probe_data(const Dictionary &p_data) {
set_capture_data(p_data["bounds"], p_data["interior"], p_data["points"], p_data["sh"], p_data["tetrahedra"], p_data["bsp"]); set_capture_data(p_data["bounds"], p_data["interior"], p_data["points"], p_data["sh"], p_data["tetrahedra"], p_data["bsp"]);
} }
Dictionary BakedLightmapData::_get_probe_data() const { Dictionary LightmapGIData::_get_probe_data() const {
Dictionary d; Dictionary d;
d["bounds"] = get_capture_bounds(); d["bounds"] = get_capture_bounds();
d["points"] = get_capture_points(); d["points"] = get_capture_points();
@ -186,23 +186,23 @@ Dictionary BakedLightmapData::_get_probe_data() const {
return d; return d;
} }
void BakedLightmapData::_bind_methods() { void LightmapGIData::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_user_data", "data"), &BakedLightmapData::_set_user_data); ClassDB::bind_method(D_METHOD("_set_user_data", "data"), &LightmapGIData::_set_user_data);
ClassDB::bind_method(D_METHOD("_get_user_data"), &BakedLightmapData::_get_user_data); ClassDB::bind_method(D_METHOD("_get_user_data"), &LightmapGIData::_get_user_data);
ClassDB::bind_method(D_METHOD("set_light_texture", "light_texture"), &BakedLightmapData::set_light_texture); ClassDB::bind_method(D_METHOD("set_light_texture", "light_texture"), &LightmapGIData::set_light_texture);
ClassDB::bind_method(D_METHOD("get_light_texture"), &BakedLightmapData::get_light_texture); ClassDB::bind_method(D_METHOD("get_light_texture"), &LightmapGIData::get_light_texture);
ClassDB::bind_method(D_METHOD("set_uses_spherical_harmonics", "uses_spherical_harmonics"), &BakedLightmapData::set_uses_spherical_harmonics); ClassDB::bind_method(D_METHOD("set_uses_spherical_harmonics", "uses_spherical_harmonics"), &LightmapGIData::set_uses_spherical_harmonics);
ClassDB::bind_method(D_METHOD("is_using_spherical_harmonics"), &BakedLightmapData::is_using_spherical_harmonics); ClassDB::bind_method(D_METHOD("is_using_spherical_harmonics"), &LightmapGIData::is_using_spherical_harmonics);
ClassDB::bind_method(D_METHOD("add_user", "path", "uv_scale", "slice_index", "sub_instance"), &BakedLightmapData::add_user); ClassDB::bind_method(D_METHOD("add_user", "path", "uv_scale", "slice_index", "sub_instance"), &LightmapGIData::add_user);
ClassDB::bind_method(D_METHOD("get_user_count"), &BakedLightmapData::get_user_count); ClassDB::bind_method(D_METHOD("get_user_count"), &LightmapGIData::get_user_count);
ClassDB::bind_method(D_METHOD("get_user_path", "user_idx"), &BakedLightmapData::get_user_path); ClassDB::bind_method(D_METHOD("get_user_path", "user_idx"), &LightmapGIData::get_user_path);
ClassDB::bind_method(D_METHOD("clear_users"), &BakedLightmapData::clear_users); ClassDB::bind_method(D_METHOD("clear_users"), &LightmapGIData::clear_users);
ClassDB::bind_method(D_METHOD("_set_probe_data", "data"), &BakedLightmapData::_set_probe_data); ClassDB::bind_method(D_METHOD("_set_probe_data", "data"), &LightmapGIData::_set_probe_data);
ClassDB::bind_method(D_METHOD("_get_probe_data"), &BakedLightmapData::_get_probe_data); ClassDB::bind_method(D_METHOD("_get_probe_data"), &LightmapGIData::_get_probe_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light_texture", PROPERTY_HINT_RESOURCE_TYPE, "TextureLayered"), "set_light_texture", "get_light_texture"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light_texture", PROPERTY_HINT_RESOURCE_TYPE, "TextureLayered"), "set_light_texture", "get_light_texture");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "uses_spherical_harmonics", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_uses_spherical_harmonics", "is_using_spherical_harmonics"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "uses_spherical_harmonics", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_uses_spherical_harmonics", "is_using_spherical_harmonics");
@ -210,17 +210,17 @@ void BakedLightmapData::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "probe_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_probe_data", "_get_probe_data"); ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "probe_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_probe_data", "_get_probe_data");
} }
BakedLightmapData::BakedLightmapData() { LightmapGIData::LightmapGIData() {
lightmap = RS::get_singleton()->lightmap_create(); lightmap = RS::get_singleton()->lightmap_create();
} }
BakedLightmapData::~BakedLightmapData() { LightmapGIData::~LightmapGIData() {
RS::get_singleton()->free(lightmap); RS::get_singleton()->free(lightmap);
} }
/////////////////////////// ///////////////////////////
void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound> &meshes, Vector<LightsFound> &lights, Vector<Vector3> &probes) { void LightmapGI::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound> &meshes, Vector<LightsFound> &lights, Vector<Vector3> &probes) {
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_at_node); MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_at_node);
if (mi && mi->get_gi_mode() == GeometryInstance3D::GI_MODE_BAKED && mi->is_visible_in_tree()) { if (mi && mi->get_gi_mode() == GeometryInstance3D::GI_MODE_BAKED && mi->is_visible_in_tree()) {
Ref<Mesh> mesh = mi->get_mesh(); Ref<Mesh> mesh = mi->get_mesh();
@ -320,7 +320,7 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound>
} }
} }
int BakedLightmap::_bsp_get_simplex_side(const Vector<Vector3> &p_points, const LocalVector<BSPSimplex> &p_simplices, const Plane &p_plane, uint32_t p_simplex) const { int LightmapGI::_bsp_get_simplex_side(const Vector<Vector3> &p_points, const LocalVector<BSPSimplex> &p_simplices, const Plane &p_plane, uint32_t p_simplex) const {
int over = 0; int over = 0;
int under = 0; int under = 0;
int coplanar = 0; int coplanar = 0;
@ -348,7 +348,7 @@ int BakedLightmap::_bsp_get_simplex_side(const Vector<Vector3> &p_points, const
//#define DEBUG_BSP //#define DEBUG_BSP
int32_t BakedLightmap::_compute_bsp_tree(const Vector<Vector3> &p_points, const LocalVector<Plane> &p_planes, LocalVector<int32_t> &planes_tested, const LocalVector<BSPSimplex> &p_simplices, const LocalVector<int32_t> &p_simplex_indices, LocalVector<BSPNode> &bsp_nodes) { int32_t LightmapGI::_compute_bsp_tree(const Vector<Vector3> &p_points, const LocalVector<Plane> &p_planes, LocalVector<int32_t> &planes_tested, const LocalVector<BSPSimplex> &p_simplices, const LocalVector<int32_t> &p_simplex_indices, LocalVector<BSPNode> &bsp_nodes) {
//if we reach here, it means there is more than one simplex //if we reach here, it means there is more than one simplex
int32_t node_index = (int32_t)bsp_nodes.size(); int32_t node_index = (int32_t)bsp_nodes.size();
bsp_nodes.push_back(BSPNode()); bsp_nodes.push_back(BSPNode());
@ -533,7 +533,7 @@ int32_t BakedLightmap::_compute_bsp_tree(const Vector<Vector3> &p_points, const
return node_index; return node_index;
} }
bool BakedLightmap::_lightmap_bake_step_function(float p_completion, const String &p_text, void *ud, bool p_refresh) { bool LightmapGI::_lightmap_bake_step_function(float p_completion, const String &p_text, void *ud, bool p_refresh) {
BakeStepUD *bsud = (BakeStepUD *)ud; BakeStepUD *bsud = (BakeStepUD *)ud;
bool ret = false; bool ret = false;
if (bsud->func) { if (bsud->func) {
@ -542,7 +542,7 @@ bool BakedLightmap::_lightmap_bake_step_function(float p_completion, const Strin
return ret; return ret;
} }
void BakedLightmap::_plot_triangle_into_octree(GenProbesOctree *p_cell, float p_cell_size, const Vector3 *p_triangle) { void LightmapGI::_plot_triangle_into_octree(GenProbesOctree *p_cell, float p_cell_size, const Vector3 *p_triangle) {
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
Vector3i pos = p_cell->offset; Vector3i pos = p_cell->offset;
uint32_t half_size = p_cell->size / 2; uint32_t half_size = p_cell->size / 2;
@ -578,7 +578,7 @@ void BakedLightmap::_plot_triangle_into_octree(GenProbesOctree *p_cell, float p_
} }
} }
void BakedLightmap::_gen_new_positions_from_octree(const GenProbesOctree *p_cell, float p_cell_size, const Vector<Vector3> &probe_positions, LocalVector<Vector3> &new_probe_positions, HashMap<Vector3i, bool, Vector3iHash> &positions_used, const AABB &p_bounds) { void LightmapGI::_gen_new_positions_from_octree(const GenProbesOctree *p_cell, float p_cell_size, const Vector<Vector3> &probe_positions, LocalVector<Vector3> &new_probe_positions, HashMap<Vector3i, bool, Vector3iHash> &positions_used, const AABB &p_bounds) {
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
Vector3i pos = p_cell->offset; Vector3i pos = p_cell->offset;
if (i & 1) { if (i & 1) {
@ -618,7 +618,7 @@ void BakedLightmap::_gen_new_positions_from_octree(const GenProbesOctree *p_cell
} }
} }
BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_data_path, Lightmapper::BakeStepFunc p_bake_step, void *p_bake_userdata) { LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_path, Lightmapper::BakeStepFunc p_bake_step, void *p_bake_userdata) {
if (p_image_data_path == "") { if (p_image_data_path == "") {
if (get_light_data().is_null()) { if (get_light_data().is_null()) {
return BAKE_ERROR_NO_SAVE_PATH; return BAKE_ERROR_NO_SAVE_PATH;
@ -1011,10 +1011,10 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
/* POSTBAKE: Save Light Data */ /* POSTBAKE: Save Light Data */
Ref<BakedLightmapData> data; Ref<LightmapGIData> data;
if (get_light_data().is_valid()) { if (get_light_data().is_valid()) {
data = get_light_data(); data = get_light_data();
set_light_data(Ref<BakedLightmapData>()); //clear set_light_data(Ref<LightmapGIData>()); //clear
data->clear(); data->clear();
} else { } else {
data.instance(); data.instance();
@ -1183,7 +1183,7 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
return BAKE_ERROR_OK; return BAKE_ERROR_OK;
} }
void BakedLightmap::_notification(int p_what) { void LightmapGI::_notification(int p_what) {
if (p_what == NOTIFICATION_POST_ENTER_TREE) { if (p_what == NOTIFICATION_POST_ENTER_TREE) {
if (light_data.is_valid()) { if (light_data.is_valid()) {
_assign_lightmaps(); _assign_lightmaps();
@ -1197,7 +1197,7 @@ void BakedLightmap::_notification(int p_what) {
} }
} }
void BakedLightmap::_assign_lightmaps() { void LightmapGI::_assign_lightmaps() {
ERR_FAIL_COND(!light_data.is_valid()); ERR_FAIL_COND(!light_data.is_valid());
for (int i = 0; i < light_data->get_user_count(); i++) { for (int i = 0; i < light_data->get_user_count(); i++) {
@ -1216,7 +1216,7 @@ void BakedLightmap::_assign_lightmaps() {
} }
} }
void BakedLightmap::_clear_lightmaps() { void LightmapGI::_clear_lightmaps() {
ERR_FAIL_COND(!light_data.is_valid()); ERR_FAIL_COND(!light_data.is_valid());
for (int i = 0; i < light_data->get_user_count(); i++) { for (int i = 0; i < light_data->get_user_count(); i++) {
Node *node = get_node(light_data->get_user_path(i)); Node *node = get_node(light_data->get_user_path(i));
@ -1234,7 +1234,7 @@ void BakedLightmap::_clear_lightmaps() {
} }
} }
void BakedLightmap::set_light_data(const Ref<BakedLightmapData> &p_data) { void LightmapGI::set_light_data(const Ref<LightmapGIData> &p_data) {
if (light_data.is_valid()) { if (light_data.is_valid()) {
if (is_inside_tree()) { if (is_inside_tree()) {
_clear_lightmaps(); _clear_lightmaps();
@ -1253,119 +1253,119 @@ void BakedLightmap::set_light_data(const Ref<BakedLightmapData> &p_data) {
update_gizmo(); update_gizmo();
} }
Ref<BakedLightmapData> BakedLightmap::get_light_data() const { Ref<LightmapGIData> LightmapGI::get_light_data() const {
return light_data; return light_data;
} }
void BakedLightmap::set_bake_quality(BakeQuality p_quality) { void LightmapGI::set_bake_quality(BakeQuality p_quality) {
bake_quality = p_quality; bake_quality = p_quality;
} }
BakedLightmap::BakeQuality BakedLightmap::get_bake_quality() const { LightmapGI::BakeQuality LightmapGI::get_bake_quality() const {
return bake_quality; return bake_quality;
} }
AABB BakedLightmap::get_aabb() const { AABB LightmapGI::get_aabb() const {
return AABB(); return AABB();
} }
Vector<Face3> BakedLightmap::get_faces(uint32_t p_usage_flags) const { Vector<Face3> LightmapGI::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>(); return Vector<Face3>();
} }
void BakedLightmap::set_use_denoiser(bool p_enable) { void LightmapGI::set_use_denoiser(bool p_enable) {
use_denoiser = p_enable; use_denoiser = p_enable;
} }
bool BakedLightmap::is_using_denoiser() const { bool LightmapGI::is_using_denoiser() const {
return use_denoiser; return use_denoiser;
} }
void BakedLightmap::set_directional(bool p_enable) { void LightmapGI::set_directional(bool p_enable) {
directional = p_enable; directional = p_enable;
} }
bool BakedLightmap::is_directional() const { bool LightmapGI::is_directional() const {
return directional; return directional;
} }
void BakedLightmap::set_interior(bool p_enable) { void LightmapGI::set_interior(bool p_enable) {
interior = p_enable; interior = p_enable;
} }
bool BakedLightmap::is_interior() const { bool LightmapGI::is_interior() const {
return interior; return interior;
} }
void BakedLightmap::set_environment_mode(EnvironmentMode p_mode) { void LightmapGI::set_environment_mode(EnvironmentMode p_mode) {
environment_mode = p_mode; environment_mode = p_mode;
notify_property_list_changed(); notify_property_list_changed();
} }
BakedLightmap::EnvironmentMode BakedLightmap::get_environment_mode() const { LightmapGI::EnvironmentMode LightmapGI::get_environment_mode() const {
return environment_mode; return environment_mode;
} }
void BakedLightmap::set_environment_custom_sky(const Ref<Sky> &p_sky) { void LightmapGI::set_environment_custom_sky(const Ref<Sky> &p_sky) {
environment_custom_sky = p_sky; environment_custom_sky = p_sky;
} }
Ref<Sky> BakedLightmap::get_environment_custom_sky() const { Ref<Sky> LightmapGI::get_environment_custom_sky() const {
return environment_custom_sky; return environment_custom_sky;
} }
void BakedLightmap::set_environment_custom_color(const Color &p_color) { void LightmapGI::set_environment_custom_color(const Color &p_color) {
environment_custom_color = p_color; environment_custom_color = p_color;
} }
Color BakedLightmap::get_environment_custom_color() const { Color LightmapGI::get_environment_custom_color() const {
return environment_custom_color; return environment_custom_color;
} }
void BakedLightmap::set_environment_custom_energy(float p_energy) { void LightmapGI::set_environment_custom_energy(float p_energy) {
environment_custom_energy = p_energy; environment_custom_energy = p_energy;
} }
float BakedLightmap::get_environment_custom_energy() const { float LightmapGI::get_environment_custom_energy() const {
return environment_custom_energy; return environment_custom_energy;
} }
void BakedLightmap::set_bounces(int p_bounces) { void LightmapGI::set_bounces(int p_bounces) {
ERR_FAIL_COND(p_bounces < 0 || p_bounces > 16); ERR_FAIL_COND(p_bounces < 0 || p_bounces > 16);
bounces = p_bounces; bounces = p_bounces;
} }
int BakedLightmap::get_bounces() const { int LightmapGI::get_bounces() const {
return bounces; return bounces;
} }
void BakedLightmap::set_bias(float p_bias) { void LightmapGI::set_bias(float p_bias) {
ERR_FAIL_COND(p_bias < 0.00001); ERR_FAIL_COND(p_bias < 0.00001);
bias = p_bias; bias = p_bias;
} }
float BakedLightmap::get_bias() const { float LightmapGI::get_bias() const {
return bias; return bias;
} }
void BakedLightmap::set_max_texture_size(int p_size) { void LightmapGI::set_max_texture_size(int p_size) {
ERR_FAIL_COND(p_size < 2048); ERR_FAIL_COND(p_size < 2048);
max_texture_size = p_size; max_texture_size = p_size;
} }
int BakedLightmap::get_max_texture_size() const { int LightmapGI::get_max_texture_size() const {
return max_texture_size; return max_texture_size;
} }
void BakedLightmap::set_generate_probes(GenerateProbes p_generate_probes) { void LightmapGI::set_generate_probes(GenerateProbes p_generate_probes) {
gen_probes = p_generate_probes; gen_probes = p_generate_probes;
} }
BakedLightmap::GenerateProbes BakedLightmap::get_generate_probes() const { LightmapGI::GenerateProbes LightmapGI::get_generate_probes() const {
return gen_probes; return gen_probes;
} }
void BakedLightmap::_validate_property(PropertyInfo &property) const { void LightmapGI::_validate_property(PropertyInfo &property) const {
if (property.name == "environment_custom_sky" && environment_mode != ENVIRONMENT_MODE_CUSTOM_SKY) { if (property.name == "environment_custom_sky" && environment_mode != ENVIRONMENT_MODE_CUSTOM_SKY) {
property.usage = 0; property.usage = 0;
} }
@ -1377,47 +1377,47 @@ void BakedLightmap::_validate_property(PropertyInfo &property) const {
} }
} }
void BakedLightmap::_bind_methods() { void LightmapGI::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_light_data", "data"), &BakedLightmap::set_light_data); ClassDB::bind_method(D_METHOD("set_light_data", "data"), &LightmapGI::set_light_data);
ClassDB::bind_method(D_METHOD("get_light_data"), &BakedLightmap::get_light_data); ClassDB::bind_method(D_METHOD("get_light_data"), &LightmapGI::get_light_data);
ClassDB::bind_method(D_METHOD("set_bake_quality", "bake_quality"), &BakedLightmap::set_bake_quality); ClassDB::bind_method(D_METHOD("set_bake_quality", "bake_quality"), &LightmapGI::set_bake_quality);
ClassDB::bind_method(D_METHOD("get_bake_quality"), &BakedLightmap::get_bake_quality); ClassDB::bind_method(D_METHOD("get_bake_quality"), &LightmapGI::get_bake_quality);
ClassDB::bind_method(D_METHOD("set_bounces", "bounces"), &BakedLightmap::set_bounces); ClassDB::bind_method(D_METHOD("set_bounces", "bounces"), &LightmapGI::set_bounces);
ClassDB::bind_method(D_METHOD("get_bounces"), &BakedLightmap::get_bounces); ClassDB::bind_method(D_METHOD("get_bounces"), &LightmapGI::get_bounces);
ClassDB::bind_method(D_METHOD("set_generate_probes", "subdivision"), &BakedLightmap::set_generate_probes); ClassDB::bind_method(D_METHOD("set_generate_probes", "subdivision"), &LightmapGI::set_generate_probes);
ClassDB::bind_method(D_METHOD("get_generate_probes"), &BakedLightmap::get_generate_probes); ClassDB::bind_method(D_METHOD("get_generate_probes"), &LightmapGI::get_generate_probes);
ClassDB::bind_method(D_METHOD("set_bias", "bias"), &BakedLightmap::set_bias); ClassDB::bind_method(D_METHOD("set_bias", "bias"), &LightmapGI::set_bias);
ClassDB::bind_method(D_METHOD("get_bias"), &BakedLightmap::get_bias); ClassDB::bind_method(D_METHOD("get_bias"), &LightmapGI::get_bias);
ClassDB::bind_method(D_METHOD("set_environment_mode", "mode"), &BakedLightmap::set_environment_mode); ClassDB::bind_method(D_METHOD("set_environment_mode", "mode"), &LightmapGI::set_environment_mode);
ClassDB::bind_method(D_METHOD("get_environment_mode"), &BakedLightmap::get_environment_mode); ClassDB::bind_method(D_METHOD("get_environment_mode"), &LightmapGI::get_environment_mode);
ClassDB::bind_method(D_METHOD("set_environment_custom_sky", "sky"), &BakedLightmap::set_environment_custom_sky); ClassDB::bind_method(D_METHOD("set_environment_custom_sky", "sky"), &LightmapGI::set_environment_custom_sky);
ClassDB::bind_method(D_METHOD("get_environment_custom_sky"), &BakedLightmap::get_environment_custom_sky); ClassDB::bind_method(D_METHOD("get_environment_custom_sky"), &LightmapGI::get_environment_custom_sky);
ClassDB::bind_method(D_METHOD("set_environment_custom_color", "color"), &BakedLightmap::set_environment_custom_color); ClassDB::bind_method(D_METHOD("set_environment_custom_color", "color"), &LightmapGI::set_environment_custom_color);
ClassDB::bind_method(D_METHOD("get_environment_custom_color"), &BakedLightmap::get_environment_custom_color); ClassDB::bind_method(D_METHOD("get_environment_custom_color"), &LightmapGI::get_environment_custom_color);
ClassDB::bind_method(D_METHOD("set_environment_custom_energy", "energy"), &BakedLightmap::set_environment_custom_energy); ClassDB::bind_method(D_METHOD("set_environment_custom_energy", "energy"), &LightmapGI::set_environment_custom_energy);
ClassDB::bind_method(D_METHOD("get_environment_custom_energy"), &BakedLightmap::get_environment_custom_energy); ClassDB::bind_method(D_METHOD("get_environment_custom_energy"), &LightmapGI::get_environment_custom_energy);
ClassDB::bind_method(D_METHOD("set_max_texture_size", "max_texture_size"), &BakedLightmap::set_max_texture_size); ClassDB::bind_method(D_METHOD("set_max_texture_size", "max_texture_size"), &LightmapGI::set_max_texture_size);
ClassDB::bind_method(D_METHOD("get_max_texture_size"), &BakedLightmap::get_max_texture_size); ClassDB::bind_method(D_METHOD("get_max_texture_size"), &LightmapGI::get_max_texture_size);
ClassDB::bind_method(D_METHOD("set_use_denoiser", "use_denoiser"), &BakedLightmap::set_use_denoiser); ClassDB::bind_method(D_METHOD("set_use_denoiser", "use_denoiser"), &LightmapGI::set_use_denoiser);
ClassDB::bind_method(D_METHOD("is_using_denoiser"), &BakedLightmap::is_using_denoiser); ClassDB::bind_method(D_METHOD("is_using_denoiser"), &LightmapGI::is_using_denoiser);
ClassDB::bind_method(D_METHOD("set_interior", "enable"), &BakedLightmap::set_interior); ClassDB::bind_method(D_METHOD("set_interior", "enable"), &LightmapGI::set_interior);
ClassDB::bind_method(D_METHOD("is_interior"), &BakedLightmap::is_interior); ClassDB::bind_method(D_METHOD("is_interior"), &LightmapGI::is_interior);
ClassDB::bind_method(D_METHOD("set_directional", "directional"), &BakedLightmap::set_directional); ClassDB::bind_method(D_METHOD("set_directional", "directional"), &LightmapGI::set_directional);
ClassDB::bind_method(D_METHOD("is_directional"), &BakedLightmap::is_directional); ClassDB::bind_method(D_METHOD("is_directional"), &LightmapGI::is_directional);
// ClassDB::bind_method(D_METHOD("bake", "from_node"), &BakedLightmap::bake, DEFVAL(Variant())); // ClassDB::bind_method(D_METHOD("bake", "from_node"), &LightmapGI::bake, DEFVAL(Variant()));
ADD_GROUP("Tweaks", ""); ADD_GROUP("Tweaks", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "quality", PROPERTY_HINT_ENUM, "Low,Medium,High,Ultra"), "set_bake_quality", "get_bake_quality"); ADD_PROPERTY(PropertyInfo(Variant::INT, "quality", PROPERTY_HINT_ENUM, "Low,Medium,High,Ultra"), "set_bake_quality", "get_bake_quality");
@ -1435,7 +1435,7 @@ void BakedLightmap::_bind_methods() {
ADD_GROUP("Gen Probes", "generate_probes_"); ADD_GROUP("Gen Probes", "generate_probes_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "generate_probes_subdiv", PROPERTY_HINT_ENUM, "Disabled,4,8,16,32"), "set_generate_probes", "get_generate_probes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "generate_probes_subdiv", PROPERTY_HINT_ENUM, "Disabled,4,8,16,32"), "set_generate_probes", "get_generate_probes");
ADD_GROUP("Data", ""); ADD_GROUP("Data", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light_data", PROPERTY_HINT_RESOURCE_TYPE, "BakedLightmapData"), "set_light_data", "get_light_data"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light_data", PROPERTY_HINT_RESOURCE_TYPE, "LightmapGIData"), "set_light_data", "get_light_data");
BIND_ENUM_CONSTANT(BAKE_QUALITY_LOW); BIND_ENUM_CONSTANT(BAKE_QUALITY_LOW);
BIND_ENUM_CONSTANT(BAKE_QUALITY_MEDIUM); BIND_ENUM_CONSTANT(BAKE_QUALITY_MEDIUM);
@ -1462,5 +1462,5 @@ void BakedLightmap::_bind_methods() {
BIND_ENUM_CONSTANT(ENVIRONMENT_MODE_CUSTOM_COLOR); BIND_ENUM_CONSTANT(ENVIRONMENT_MODE_CUSTOM_COLOR);
} }
BakedLightmap::BakedLightmap() { LightmapGI::LightmapGI() {
} }

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* baked_lightmap.h */ /* lightmap_gi.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef BAKED_LIGHTMAP_H #ifndef LIGHTMAP_GI_H
#define BAKED_LIGHTMAP_H #define LIGHTMAP_GI_H
#include "core/templates/local_vector.h" #include "core/templates/local_vector.h"
#include "scene/3d/light_3d.h" #include "scene/3d/light_3d.h"
@ -39,8 +39,8 @@
#include "scene/3d/visual_instance_3d.h" #include "scene/3d/visual_instance_3d.h"
#include "scene/resources/sky.h" #include "scene/resources/sky.h"
class BakedLightmapData : public Resource { class LightmapGIData : public Resource {
GDCLASS(BakedLightmapData, Resource); GDCLASS(LightmapGIData, Resource);
RES_BASE_EXTENSION("lmbake") RES_BASE_EXTENSION("lmbake")
Ref<TextureLayered> light_texture; Ref<TextureLayered> light_texture;
@ -95,12 +95,12 @@ public:
void clear(); void clear();
virtual RID get_rid() const override; virtual RID get_rid() const override;
BakedLightmapData(); LightmapGIData();
~BakedLightmapData(); ~LightmapGIData();
}; };
class BakedLightmap : public VisualInstance3D { class LightmapGI : public VisualInstance3D {
GDCLASS(BakedLightmap, VisualInstance3D); GDCLASS(LightmapGI, VisualInstance3D);
public: public:
enum BakeQuality { enum BakeQuality {
@ -149,7 +149,7 @@ private:
bool directional = false; bool directional = false;
GenerateProbes gen_probes = GENERATE_PROBES_DISABLED; GenerateProbes gen_probes = GENERATE_PROBES_DISABLED;
Ref<BakedLightmapData> light_data; Ref<LightmapGIData> light_data;
struct LightsFound { struct LightsFound {
Transform3D xform; Transform3D xform;
@ -230,8 +230,8 @@ protected:
void _notification(int p_what); void _notification(int p_what);
public: public:
void set_light_data(const Ref<BakedLightmapData> &p_data); void set_light_data(const Ref<LightmapGIData> &p_data);
Ref<BakedLightmapData> get_light_data() const; Ref<LightmapGIData> get_light_data() const;
void set_bake_quality(BakeQuality p_quality); void set_bake_quality(BakeQuality p_quality);
BakeQuality get_bake_quality() const; BakeQuality get_bake_quality() const;
@ -273,12 +273,12 @@ public:
Vector<Face3> get_faces(uint32_t p_usage_flags) const override; Vector<Face3> get_faces(uint32_t p_usage_flags) const override;
BakeError bake(Node *p_from_node, String p_image_data_path = "", Lightmapper::BakeStepFunc p_bake_step = nullptr, void *p_bake_userdata = nullptr); BakeError bake(Node *p_from_node, String p_image_data_path = "", Lightmapper::BakeStepFunc p_bake_step = nullptr, void *p_bake_userdata = nullptr);
BakedLightmap(); LightmapGI();
}; };
VARIANT_ENUM_CAST(BakedLightmap::BakeQuality); VARIANT_ENUM_CAST(LightmapGI::BakeQuality);
VARIANT_ENUM_CAST(BakedLightmap::GenerateProbes); VARIANT_ENUM_CAST(LightmapGI::GenerateProbes);
VARIANT_ENUM_CAST(BakedLightmap::BakeError); VARIANT_ENUM_CAST(LightmapGI::BakeError);
VARIANT_ENUM_CAST(BakedLightmap::EnvironmentMode); VARIANT_ENUM_CAST(LightmapGI::EnvironmentMode);
#endif // BAKED_LIGHTMAP_H #endif // BAKED_LIGHTMAP_H

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* gi_probe.cpp */ /* voxel_gi.cpp */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include "gi_probe.h" #include "voxel_gi.h"
#include "core/os/os.h" #include "core/os/os.h"
#include "mesh_instance_3d.h" #include "mesh_instance_3d.h"
#include "voxelizer.h" #include "voxelizer.h"
void GIProbeData::_set_data(const Dictionary &p_data) { void VoxelGIData::_set_data(const Dictionary &p_data) {
ERR_FAIL_COND(!p_data.has("bounds")); ERR_FAIL_COND(!p_data.has("bounds"));
ERR_FAIL_COND(!p_data.has("octree_size")); ERR_FAIL_COND(!p_data.has("octree_size"));
ERR_FAIL_COND(!p_data.has("octree_cells")); ERR_FAIL_COND(!p_data.has("octree_cells"));
@ -67,7 +67,7 @@ void GIProbeData::_set_data(const Dictionary &p_data) {
allocate(to_cell_xform, bounds, octree_size, octree_cells, octree_data, octree_df, octree_levels); allocate(to_cell_xform, bounds, octree_size, octree_cells, octree_data, octree_df, octree_levels);
} }
Dictionary GIProbeData::_get_data() const { Dictionary VoxelGIData::_get_data() const {
Dictionary d; Dictionary d;
d["bounds"] = get_bounds(); d["bounds"] = get_bounds();
Vector3i otsize = get_octree_size(); Vector3i otsize = get_octree_size();
@ -90,186 +90,186 @@ Dictionary GIProbeData::_get_data() const {
return d; return d;
} }
void GIProbeData::allocate(const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3 &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) { void VoxelGIData::allocate(const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3 &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) {
RS::get_singleton()->gi_probe_allocate_data(probe, p_to_cell_xform, p_aabb, p_octree_size, p_octree_cells, p_data_cells, p_distance_field, p_level_counts); RS::get_singleton()->voxel_gi_allocate_data(probe, p_to_cell_xform, p_aabb, p_octree_size, p_octree_cells, p_data_cells, p_distance_field, p_level_counts);
bounds = p_aabb; bounds = p_aabb;
to_cell_xform = p_to_cell_xform; to_cell_xform = p_to_cell_xform;
octree_size = p_octree_size; octree_size = p_octree_size;
} }
AABB GIProbeData::get_bounds() const { AABB VoxelGIData::get_bounds() const {
return bounds; return bounds;
} }
Vector3 GIProbeData::get_octree_size() const { Vector3 VoxelGIData::get_octree_size() const {
return octree_size; return octree_size;
} }
Vector<uint8_t> GIProbeData::get_octree_cells() const { Vector<uint8_t> VoxelGIData::get_octree_cells() const {
return RS::get_singleton()->gi_probe_get_octree_cells(probe); return RS::get_singleton()->voxel_gi_get_octree_cells(probe);
} }
Vector<uint8_t> GIProbeData::get_data_cells() const { Vector<uint8_t> VoxelGIData::get_data_cells() const {
return RS::get_singleton()->gi_probe_get_data_cells(probe); return RS::get_singleton()->voxel_gi_get_data_cells(probe);
} }
Vector<uint8_t> GIProbeData::get_distance_field() const { Vector<uint8_t> VoxelGIData::get_distance_field() const {
return RS::get_singleton()->gi_probe_get_distance_field(probe); return RS::get_singleton()->voxel_gi_get_distance_field(probe);
} }
Vector<int> GIProbeData::get_level_counts() const { Vector<int> VoxelGIData::get_level_counts() const {
return RS::get_singleton()->gi_probe_get_level_counts(probe); return RS::get_singleton()->voxel_gi_get_level_counts(probe);
} }
Transform3D GIProbeData::get_to_cell_xform() const { Transform3D VoxelGIData::get_to_cell_xform() const {
return to_cell_xform; return to_cell_xform;
} }
void GIProbeData::set_dynamic_range(float p_range) { void VoxelGIData::set_dynamic_range(float p_range) {
RS::get_singleton()->gi_probe_set_dynamic_range(probe, p_range); RS::get_singleton()->voxel_gi_set_dynamic_range(probe, p_range);
dynamic_range = p_range; dynamic_range = p_range;
} }
float GIProbeData::get_dynamic_range() const { float VoxelGIData::get_dynamic_range() const {
return dynamic_range; return dynamic_range;
} }
void GIProbeData::set_propagation(float p_propagation) { void VoxelGIData::set_propagation(float p_propagation) {
RS::get_singleton()->gi_probe_set_propagation(probe, p_propagation); RS::get_singleton()->voxel_gi_set_propagation(probe, p_propagation);
propagation = p_propagation; propagation = p_propagation;
} }
float GIProbeData::get_propagation() const { float VoxelGIData::get_propagation() const {
return propagation; return propagation;
} }
void GIProbeData::set_anisotropy_strength(float p_anisotropy_strength) { void VoxelGIData::set_anisotropy_strength(float p_anisotropy_strength) {
RS::get_singleton()->gi_probe_set_anisotropy_strength(probe, p_anisotropy_strength); RS::get_singleton()->voxel_gi_set_anisotropy_strength(probe, p_anisotropy_strength);
anisotropy_strength = p_anisotropy_strength; anisotropy_strength = p_anisotropy_strength;
} }
float GIProbeData::get_anisotropy_strength() const { float VoxelGIData::get_anisotropy_strength() const {
return anisotropy_strength; return anisotropy_strength;
} }
void GIProbeData::set_energy(float p_energy) { void VoxelGIData::set_energy(float p_energy) {
RS::get_singleton()->gi_probe_set_energy(probe, p_energy); RS::get_singleton()->voxel_gi_set_energy(probe, p_energy);
energy = p_energy; energy = p_energy;
} }
float GIProbeData::get_energy() const { float VoxelGIData::get_energy() const {
return energy; return energy;
} }
void GIProbeData::set_ao(float p_ao) { void VoxelGIData::set_ao(float p_ao) {
RS::get_singleton()->gi_probe_set_ao(probe, p_ao); RS::get_singleton()->voxel_gi_set_ao(probe, p_ao);
ao = p_ao; ao = p_ao;
} }
float GIProbeData::get_ao() const { float VoxelGIData::get_ao() const {
return ao; return ao;
} }
void GIProbeData::set_ao_size(float p_ao_size) { void VoxelGIData::set_ao_size(float p_ao_size) {
RS::get_singleton()->gi_probe_set_ao_size(probe, p_ao_size); RS::get_singleton()->voxel_gi_set_ao_size(probe, p_ao_size);
ao_size = p_ao_size; ao_size = p_ao_size;
} }
float GIProbeData::get_ao_size() const { float VoxelGIData::get_ao_size() const {
return ao_size; return ao_size;
} }
void GIProbeData::set_bias(float p_bias) { void VoxelGIData::set_bias(float p_bias) {
RS::get_singleton()->gi_probe_set_bias(probe, p_bias); RS::get_singleton()->voxel_gi_set_bias(probe, p_bias);
bias = p_bias; bias = p_bias;
} }
float GIProbeData::get_bias() const { float VoxelGIData::get_bias() const {
return bias; return bias;
} }
void GIProbeData::set_normal_bias(float p_normal_bias) { void VoxelGIData::set_normal_bias(float p_normal_bias) {
RS::get_singleton()->gi_probe_set_normal_bias(probe, p_normal_bias); RS::get_singleton()->voxel_gi_set_normal_bias(probe, p_normal_bias);
normal_bias = p_normal_bias; normal_bias = p_normal_bias;
} }
float GIProbeData::get_normal_bias() const { float VoxelGIData::get_normal_bias() const {
return normal_bias; return normal_bias;
} }
void GIProbeData::set_interior(bool p_enable) { void VoxelGIData::set_interior(bool p_enable) {
RS::get_singleton()->gi_probe_set_interior(probe, p_enable); RS::get_singleton()->voxel_gi_set_interior(probe, p_enable);
interior = p_enable; interior = p_enable;
} }
bool GIProbeData::is_interior() const { bool VoxelGIData::is_interior() const {
return interior; return interior;
} }
void GIProbeData::set_use_two_bounces(bool p_enable) { void VoxelGIData::set_use_two_bounces(bool p_enable) {
RS::get_singleton()->gi_probe_set_use_two_bounces(probe, p_enable); RS::get_singleton()->voxel_gi_set_use_two_bounces(probe, p_enable);
use_two_bounces = p_enable; use_two_bounces = p_enable;
} }
bool GIProbeData::is_using_two_bounces() const { bool VoxelGIData::is_using_two_bounces() const {
return use_two_bounces; return use_two_bounces;
} }
RID GIProbeData::get_rid() const { RID VoxelGIData::get_rid() const {
return probe; return probe;
} }
void GIProbeData::_validate_property(PropertyInfo &property) const { void VoxelGIData::_validate_property(PropertyInfo &property) const {
if (property.name == "anisotropy_strength") { if (property.name == "anisotropy_strength") {
bool anisotropy_enabled = ProjectSettings::get_singleton()->get("rendering/global_illumination/gi_probes/anisotropic"); bool anisotropy_enabled = ProjectSettings::get_singleton()->get("rendering/global_illumination/voxel_gi/anisotropic");
if (!anisotropy_enabled) { if (!anisotropy_enabled) {
property.usage = PROPERTY_USAGE_NOEDITOR; property.usage = PROPERTY_USAGE_NOEDITOR;
} }
} }
} }
void GIProbeData::_bind_methods() { void VoxelGIData::_bind_methods() {
ClassDB::bind_method(D_METHOD("allocate", "to_cell_xform", "aabb", "octree_size", "octree_cells", "data_cells", "distance_field", "level_counts"), &GIProbeData::allocate); ClassDB::bind_method(D_METHOD("allocate", "to_cell_xform", "aabb", "octree_size", "octree_cells", "data_cells", "distance_field", "level_counts"), &VoxelGIData::allocate);
ClassDB::bind_method(D_METHOD("get_bounds"), &GIProbeData::get_bounds); ClassDB::bind_method(D_METHOD("get_bounds"), &VoxelGIData::get_bounds);
ClassDB::bind_method(D_METHOD("get_octree_size"), &GIProbeData::get_octree_size); ClassDB::bind_method(D_METHOD("get_octree_size"), &VoxelGIData::get_octree_size);
ClassDB::bind_method(D_METHOD("get_to_cell_xform"), &GIProbeData::get_to_cell_xform); ClassDB::bind_method(D_METHOD("get_to_cell_xform"), &VoxelGIData::get_to_cell_xform);
ClassDB::bind_method(D_METHOD("get_octree_cells"), &GIProbeData::get_octree_cells); ClassDB::bind_method(D_METHOD("get_octree_cells"), &VoxelGIData::get_octree_cells);
ClassDB::bind_method(D_METHOD("get_data_cells"), &GIProbeData::get_data_cells); ClassDB::bind_method(D_METHOD("get_data_cells"), &VoxelGIData::get_data_cells);
ClassDB::bind_method(D_METHOD("get_level_counts"), &GIProbeData::get_level_counts); ClassDB::bind_method(D_METHOD("get_level_counts"), &VoxelGIData::get_level_counts);
ClassDB::bind_method(D_METHOD("set_dynamic_range", "dynamic_range"), &GIProbeData::set_dynamic_range); ClassDB::bind_method(D_METHOD("set_dynamic_range", "dynamic_range"), &VoxelGIData::set_dynamic_range);
ClassDB::bind_method(D_METHOD("get_dynamic_range"), &GIProbeData::get_dynamic_range); ClassDB::bind_method(D_METHOD("get_dynamic_range"), &VoxelGIData::get_dynamic_range);
ClassDB::bind_method(D_METHOD("set_energy", "energy"), &GIProbeData::set_energy); ClassDB::bind_method(D_METHOD("set_energy", "energy"), &VoxelGIData::set_energy);
ClassDB::bind_method(D_METHOD("get_energy"), &GIProbeData::get_energy); ClassDB::bind_method(D_METHOD("get_energy"), &VoxelGIData::get_energy);
ClassDB::bind_method(D_METHOD("set_bias", "bias"), &GIProbeData::set_bias); ClassDB::bind_method(D_METHOD("set_bias", "bias"), &VoxelGIData::set_bias);
ClassDB::bind_method(D_METHOD("get_bias"), &GIProbeData::get_bias); ClassDB::bind_method(D_METHOD("get_bias"), &VoxelGIData::get_bias);
ClassDB::bind_method(D_METHOD("set_normal_bias", "bias"), &GIProbeData::set_normal_bias); ClassDB::bind_method(D_METHOD("set_normal_bias", "bias"), &VoxelGIData::set_normal_bias);
ClassDB::bind_method(D_METHOD("get_normal_bias"), &GIProbeData::get_normal_bias); ClassDB::bind_method(D_METHOD("get_normal_bias"), &VoxelGIData::get_normal_bias);
ClassDB::bind_method(D_METHOD("set_propagation", "propagation"), &GIProbeData::set_propagation); ClassDB::bind_method(D_METHOD("set_propagation", "propagation"), &VoxelGIData::set_propagation);
ClassDB::bind_method(D_METHOD("get_propagation"), &GIProbeData::get_propagation); ClassDB::bind_method(D_METHOD("get_propagation"), &VoxelGIData::get_propagation);
ClassDB::bind_method(D_METHOD("set_anisotropy_strength", "strength"), &GIProbeData::set_anisotropy_strength); ClassDB::bind_method(D_METHOD("set_anisotropy_strength", "strength"), &VoxelGIData::set_anisotropy_strength);
ClassDB::bind_method(D_METHOD("get_anisotropy_strength"), &GIProbeData::get_anisotropy_strength); ClassDB::bind_method(D_METHOD("get_anisotropy_strength"), &VoxelGIData::get_anisotropy_strength);
ClassDB::bind_method(D_METHOD("set_ao", "ao"), &GIProbeData::set_ao); ClassDB::bind_method(D_METHOD("set_ao", "ao"), &VoxelGIData::set_ao);
ClassDB::bind_method(D_METHOD("get_ao"), &GIProbeData::get_ao); ClassDB::bind_method(D_METHOD("get_ao"), &VoxelGIData::get_ao);
ClassDB::bind_method(D_METHOD("set_ao_size", "strength"), &GIProbeData::set_ao_size); ClassDB::bind_method(D_METHOD("set_ao_size", "strength"), &VoxelGIData::set_ao_size);
ClassDB::bind_method(D_METHOD("get_ao_size"), &GIProbeData::get_ao_size); ClassDB::bind_method(D_METHOD("get_ao_size"), &VoxelGIData::get_ao_size);
ClassDB::bind_method(D_METHOD("set_interior", "interior"), &GIProbeData::set_interior); ClassDB::bind_method(D_METHOD("set_interior", "interior"), &VoxelGIData::set_interior);
ClassDB::bind_method(D_METHOD("is_interior"), &GIProbeData::is_interior); ClassDB::bind_method(D_METHOD("is_interior"), &VoxelGIData::is_interior);
ClassDB::bind_method(D_METHOD("set_use_two_bounces", "enable"), &GIProbeData::set_use_two_bounces); ClassDB::bind_method(D_METHOD("set_use_two_bounces", "enable"), &VoxelGIData::set_use_two_bounces);
ClassDB::bind_method(D_METHOD("is_using_two_bounces"), &GIProbeData::is_using_two_bounces); ClassDB::bind_method(D_METHOD("is_using_two_bounces"), &VoxelGIData::is_using_two_bounces);
ClassDB::bind_method(D_METHOD("_set_data", "data"), &GIProbeData::_set_data); ClassDB::bind_method(D_METHOD("_set_data", "data"), &VoxelGIData::_set_data);
ClassDB::bind_method(D_METHOD("_get_data"), &GIProbeData::_get_data); ClassDB::bind_method(D_METHOD("_get_data"), &VoxelGIData::_get_data);
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data"); ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data");
@ -285,18 +285,18 @@ void GIProbeData::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_interior", "is_interior"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_interior", "is_interior");
} }
GIProbeData::GIProbeData() { VoxelGIData::VoxelGIData() {
probe = RS::get_singleton()->gi_probe_create(); probe = RS::get_singleton()->voxel_gi_create();
} }
GIProbeData::~GIProbeData() { VoxelGIData::~VoxelGIData() {
RS::get_singleton()->free(probe); RS::get_singleton()->free(probe);
} }
////////////////////// //////////////////////
////////////////////// //////////////////////
void GIProbe::set_probe_data(const Ref<GIProbeData> &p_data) { void VoxelGI::set_probe_data(const Ref<VoxelGIData> &p_data) {
if (p_data.is_valid()) { if (p_data.is_valid()) {
RS::get_singleton()->instance_set_base(get_instance(), p_data->get_rid()); RS::get_singleton()->instance_set_base(get_instance(), p_data->get_rid());
} else { } else {
@ -306,30 +306,30 @@ void GIProbe::set_probe_data(const Ref<GIProbeData> &p_data) {
probe_data = p_data; probe_data = p_data;
} }
Ref<GIProbeData> GIProbe::get_probe_data() const { Ref<VoxelGIData> VoxelGI::get_probe_data() const {
return probe_data; return probe_data;
} }
void GIProbe::set_subdiv(Subdiv p_subdiv) { void VoxelGI::set_subdiv(Subdiv p_subdiv) {
ERR_FAIL_INDEX(p_subdiv, SUBDIV_MAX); ERR_FAIL_INDEX(p_subdiv, SUBDIV_MAX);
subdiv = p_subdiv; subdiv = p_subdiv;
update_gizmo(); update_gizmo();
} }
GIProbe::Subdiv GIProbe::get_subdiv() const { VoxelGI::Subdiv VoxelGI::get_subdiv() const {
return subdiv; return subdiv;
} }
void GIProbe::set_extents(const Vector3 &p_extents) { void VoxelGI::set_extents(const Vector3 &p_extents) {
extents = p_extents; extents = p_extents;
update_gizmo(); update_gizmo();
} }
Vector3 GIProbe::get_extents() const { Vector3 VoxelGI::get_extents() const {
return extents; return extents;
} }
void GIProbe::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) { void VoxelGI::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) {
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_at_node); MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_at_node);
if (mi && mi->get_gi_mode() == GeometryInstance3D::GI_MODE_BAKED && mi->is_visible_in_tree()) { if (mi && mi->get_gi_mode() == GeometryInstance3D::GI_MODE_BAKED && mi->is_visible_in_tree()) {
Ref<Mesh> mesh = mi->get_mesh(); Ref<Mesh> mesh = mi->get_mesh();
@ -382,11 +382,11 @@ void GIProbe::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) {
} }
} }
GIProbe::BakeBeginFunc GIProbe::bake_begin_function = nullptr; VoxelGI::BakeBeginFunc VoxelGI::bake_begin_function = nullptr;
GIProbe::BakeStepFunc GIProbe::bake_step_function = nullptr; VoxelGI::BakeStepFunc VoxelGI::bake_step_function = nullptr;
GIProbe::BakeEndFunc GIProbe::bake_end_function = nullptr; VoxelGI::BakeEndFunc VoxelGI::bake_end_function = nullptr;
Vector3i GIProbe::get_estimated_cell_size() const { Vector3i VoxelGI::get_estimated_cell_size() const {
static const int subdiv_value[SUBDIV_MAX] = { 6, 7, 8, 9 }; static const int subdiv_value[SUBDIV_MAX] = { 6, 7, 8, 9 };
int cell_subdiv = subdiv_value[subdiv]; int cell_subdiv = subdiv_value[subdiv];
int axis_cell_size[3]; int axis_cell_size[3];
@ -412,7 +412,7 @@ Vector3i GIProbe::get_estimated_cell_size() const {
return Vector3i(axis_cell_size[0], axis_cell_size[1], axis_cell_size[2]); return Vector3i(axis_cell_size[0], axis_cell_size[1], axis_cell_size[2]);
} }
void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { void VoxelGI::bake(Node *p_from_node, bool p_create_visual_debug) {
static const int subdiv_value[SUBDIV_MAX] = { 6, 7, 8, 9 }; static const int subdiv_value[SUBDIV_MAX] = { 6, 7, 8, 9 };
p_from_node = p_from_node ? p_from_node : get_parent(); p_from_node = p_from_node ? p_from_node : get_parent();
@ -464,7 +464,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
#endif #endif
} else { } else {
Ref<GIProbeData> probe_data = get_probe_data(); Ref<VoxelGIData> probe_data = get_probe_data();
if (probe_data.is_null()) { if (probe_data.is_null()) {
probe_data.instance(); probe_data.instance();
@ -476,7 +476,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
Vector<uint8_t> df = baker.get_sdf_3d_image(); Vector<uint8_t> df = baker.get_sdf_3d_image();
probe_data->allocate(baker.get_to_cell_space_xform(), AABB(-extents, extents * 2.0), baker.get_giprobe_octree_size(), baker.get_giprobe_octree_cells(), baker.get_giprobe_data_cells(), df, baker.get_giprobe_level_cell_count()); probe_data->allocate(baker.get_to_cell_space_xform(), AABB(-extents, extents * 2.0), baker.get_voxel_gi_octree_size(), baker.get_voxel_gi_octree_cells(), baker.get_voxel_gi_data_cells(), df, baker.get_voxel_gi_level_cell_count());
set_probe_data(probe_data); set_probe_data(probe_data);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
@ -491,46 +491,46 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
notify_property_list_changed(); //bake property may have changed notify_property_list_changed(); //bake property may have changed
} }
void GIProbe::_debug_bake() { void VoxelGI::_debug_bake() {
bake(nullptr, true); bake(nullptr, true);
} }
AABB GIProbe::get_aabb() const { AABB VoxelGI::get_aabb() const {
return AABB(-extents, extents * 2); return AABB(-extents, extents * 2);
} }
Vector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const { Vector<Face3> VoxelGI::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>(); return Vector<Face3>();
} }
TypedArray<String> GIProbe::get_configuration_warnings() const { TypedArray<String> VoxelGI::get_configuration_warnings() const {
TypedArray<String> warnings = Node::get_configuration_warnings(); TypedArray<String> warnings = Node::get_configuration_warnings();
if (RenderingServer::get_singleton()->is_low_end()) { if (RenderingServer::get_singleton()->is_low_end()) {
warnings.push_back(TTR("GIProbes are not supported by the GLES2 video driver.\nUse a BakedLightmap instead.")); warnings.push_back(TTR("VoxelGIs are not supported by the GLES2 video driver.\nUse a LightmapGI instead."));
} else if (probe_data.is_null()) { } else if (probe_data.is_null()) {
warnings.push_back(TTR("No GIProbe data set, so this node is disabled. Bake static objects to enable GI.")); warnings.push_back(TTR("No VoxelGI data set, so this node is disabled. Bake static objects to enable GI."));
} }
return warnings; return warnings;
} }
void GIProbe::_bind_methods() { void VoxelGI::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_probe_data", "data"), &GIProbe::set_probe_data); ClassDB::bind_method(D_METHOD("set_probe_data", "data"), &VoxelGI::set_probe_data);
ClassDB::bind_method(D_METHOD("get_probe_data"), &GIProbe::get_probe_data); ClassDB::bind_method(D_METHOD("get_probe_data"), &VoxelGI::get_probe_data);
ClassDB::bind_method(D_METHOD("set_subdiv", "subdiv"), &GIProbe::set_subdiv); ClassDB::bind_method(D_METHOD("set_subdiv", "subdiv"), &VoxelGI::set_subdiv);
ClassDB::bind_method(D_METHOD("get_subdiv"), &GIProbe::get_subdiv); ClassDB::bind_method(D_METHOD("get_subdiv"), &VoxelGI::get_subdiv);
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GIProbe::set_extents); ClassDB::bind_method(D_METHOD("set_extents", "extents"), &VoxelGI::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GIProbe::get_extents); ClassDB::bind_method(D_METHOD("get_extents"), &VoxelGI::get_extents);
ClassDB::bind_method(D_METHOD("bake", "from_node", "create_visual_debug"), &GIProbe::bake, DEFVAL(Variant()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("bake", "from_node", "create_visual_debug"), &VoxelGI::bake, DEFVAL(Variant()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("debug_bake"), &GIProbe::_debug_bake); ClassDB::bind_method(D_METHOD("debug_bake"), &VoxelGI::_debug_bake);
ClassDB::set_method_flags(get_class_static(), _scs_create("debug_bake"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR); ClassDB::set_method_flags(get_class_static(), _scs_create("debug_bake"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
ADD_PROPERTY(PropertyInfo(Variant::INT, "subdiv", PROPERTY_HINT_ENUM, "64,128,256,512"), "set_subdiv", "get_subdiv"); ADD_PROPERTY(PropertyInfo(Variant::INT, "subdiv", PROPERTY_HINT_ENUM, "64,128,256,512"), "set_subdiv", "get_subdiv");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents"), "set_extents", "get_extents"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents"), "set_extents", "get_extents");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "GIProbeData", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE), "set_probe_data", "get_probe_data"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "VoxelGIData", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE), "set_probe_data", "get_probe_data");
BIND_ENUM_CONSTANT(SUBDIV_64); BIND_ENUM_CONSTANT(SUBDIV_64);
BIND_ENUM_CONSTANT(SUBDIV_128); BIND_ENUM_CONSTANT(SUBDIV_128);
@ -539,11 +539,11 @@ void GIProbe::_bind_methods() {
BIND_ENUM_CONSTANT(SUBDIV_MAX); BIND_ENUM_CONSTANT(SUBDIV_MAX);
} }
GIProbe::GIProbe() { VoxelGI::VoxelGI() {
gi_probe = RS::get_singleton()->gi_probe_create(); voxel_gi = RS::get_singleton()->voxel_gi_create();
set_disable_scale(true); set_disable_scale(true);
} }
GIProbe::~GIProbe() { VoxelGI::~VoxelGI() {
RS::get_singleton()->free(gi_probe); RS::get_singleton()->free(voxel_gi);
} }

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* gi_probe.h */ /* voxel_gi.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef GIPROBE_H #ifndef VOXEL_GI_H
#define GIPROBE_H #define VOXEL_GI_H
#include "multimesh_instance_3d.h" #include "multimesh_instance_3d.h"
#include "scene/3d/visual_instance_3d.h" #include "scene/3d/visual_instance_3d.h"
class GIProbeData : public Resource { class VoxelGIData : public Resource {
GDCLASS(GIProbeData, Resource); GDCLASS(VoxelGIData, Resource);
RID probe; RID probe;
@ -103,12 +103,12 @@ public:
virtual RID get_rid() const override; virtual RID get_rid() const override;
GIProbeData(); VoxelGIData();
~GIProbeData(); ~VoxelGIData();
}; };
class GIProbe : public VisualInstance3D { class VoxelGI : public VisualInstance3D {
GDCLASS(GIProbe, VisualInstance3D); GDCLASS(VoxelGI, VisualInstance3D);
public: public:
enum Subdiv { enum Subdiv {
@ -125,9 +125,9 @@ public:
typedef void (*BakeEndFunc)(); typedef void (*BakeEndFunc)();
private: private:
Ref<GIProbeData> probe_data; Ref<VoxelGIData> probe_data;
RID gi_probe; RID voxel_gi;
Subdiv subdiv = SUBDIV_128; Subdiv subdiv = SUBDIV_128;
Vector3 extents = Vector3(10, 10, 10); Vector3 extents = Vector3(10, 10, 10);
@ -150,8 +150,8 @@ public:
static BakeStepFunc bake_step_function; static BakeStepFunc bake_step_function;
static BakeEndFunc bake_end_function; static BakeEndFunc bake_end_function;
void set_probe_data(const Ref<GIProbeData> &p_data); void set_probe_data(const Ref<VoxelGIData> &p_data);
Ref<GIProbeData> get_probe_data() const; Ref<VoxelGIData> get_probe_data() const;
void set_subdiv(Subdiv p_subdiv); void set_subdiv(Subdiv p_subdiv);
Subdiv get_subdiv() const; Subdiv get_subdiv() const;
@ -167,10 +167,10 @@ public:
TypedArray<String> get_configuration_warnings() const override; TypedArray<String> get_configuration_warnings() const override;
GIProbe(); VoxelGI();
~GIProbe(); ~VoxelGI();
}; };
VARIANT_ENUM_CAST(GIProbe::Subdiv) VARIANT_ENUM_CAST(VoxelGI::Subdiv)
#endif // GIPROBE_H #endif // VOXEL_GI_H

View file

@ -668,19 +668,19 @@ void Voxelizer::end_bake() {
//create the data for visual server //create the data for visual server
int Voxelizer::get_gi_probe_octree_depth() const { int Voxelizer::get_voxel_gi_octree_depth() const {
return cell_subdiv; return cell_subdiv;
} }
Vector3i Voxelizer::get_giprobe_octree_size() const { Vector3i Voxelizer::get_voxel_gi_octree_size() const {
return Vector3i(axis_cell_size[0], axis_cell_size[1], axis_cell_size[2]); return Vector3i(axis_cell_size[0], axis_cell_size[1], axis_cell_size[2]);
} }
int Voxelizer::get_giprobe_cell_count() const { int Voxelizer::get_voxel_gi_cell_count() const {
return bake_cells.size(); return bake_cells.size();
} }
Vector<uint8_t> Voxelizer::get_giprobe_octree_cells() const { Vector<uint8_t> Voxelizer::get_voxel_gi_octree_cells() const {
Vector<uint8_t> data; Vector<uint8_t> data;
data.resize((8 * 4) * bake_cells.size()); //8 uint32t values data.resize((8 * 4) * bake_cells.size()); //8 uint32t values
{ {
@ -700,7 +700,7 @@ Vector<uint8_t> Voxelizer::get_giprobe_octree_cells() const {
return data; return data;
} }
Vector<uint8_t> Voxelizer::get_giprobe_data_cells() const { Vector<uint8_t> Voxelizer::get_voxel_gi_data_cells() const {
Vector<uint8_t> data; Vector<uint8_t> data;
data.resize((4 * 4) * bake_cells.size()); //8 uint32t values data.resize((4 * 4) * bake_cells.size()); //8 uint32t values
{ {
@ -755,7 +755,7 @@ Vector<uint8_t> Voxelizer::get_giprobe_data_cells() const {
return data; return data;
} }
Vector<int> Voxelizer::get_giprobe_level_cell_count() const { Vector<int> Voxelizer::get_voxel_gi_level_cell_count() const {
uint32_t cell_count = bake_cells.size(); uint32_t cell_count = bake_cells.size();
const Cell *cells = bake_cells.ptr(); const Cell *cells = bake_cells.ptr();
Vector<int> level_count; Vector<int> level_count;
@ -819,7 +819,7 @@ static void edt(float *f, int stride, int n) {
#undef square #undef square
Vector<uint8_t> Voxelizer::get_sdf_3d_image() const { Vector<uint8_t> Voxelizer::get_sdf_3d_image() const {
Vector3i octree_size = get_giprobe_octree_size(); Vector3i octree_size = get_voxel_gi_octree_size();
uint32_t float_count = octree_size.x * octree_size.y * octree_size.z; uint32_t float_count = octree_size.x * octree_size.y * octree_size.z;
float *work_memory = memnew_arr(float, float_count); float *work_memory = memnew_arr(float, float_count);

View file

@ -117,12 +117,12 @@ public:
void plot_mesh(const Transform3D &p_xform, Ref<Mesh> &p_mesh, const Vector<Ref<Material>> &p_materials, const Ref<Material> &p_override_material); void plot_mesh(const Transform3D &p_xform, Ref<Mesh> &p_mesh, const Vector<Ref<Material>> &p_materials, const Ref<Material> &p_override_material);
void end_bake(); void end_bake();
int get_gi_probe_octree_depth() const; int get_voxel_gi_octree_depth() const;
Vector3i get_giprobe_octree_size() const; Vector3i get_voxel_gi_octree_size() const;
int get_giprobe_cell_count() const; int get_voxel_gi_cell_count() const;
Vector<uint8_t> get_giprobe_octree_cells() const; Vector<uint8_t> get_voxel_gi_octree_cells() const;
Vector<uint8_t> get_giprobe_data_cells() const; Vector<uint8_t> get_voxel_gi_data_cells() const;
Vector<int> get_giprobe_level_cell_count() const; Vector<int> get_voxel_gi_level_cell_count() const;
Vector<uint8_t> get_sdf_3d_image() const; Vector<uint8_t> get_sdf_3d_image() const;
Ref<MultiMesh> create_debug_multimesh(); Ref<MultiMesh> create_debug_multimesh();

View file

@ -3669,9 +3669,9 @@ void Viewport::_bind_methods() {
BIND_ENUM_CONSTANT(DEBUG_DRAW_OVERDRAW); BIND_ENUM_CONSTANT(DEBUG_DRAW_OVERDRAW);
BIND_ENUM_CONSTANT(DEBUG_DRAW_WIREFRAME); BIND_ENUM_CONSTANT(DEBUG_DRAW_WIREFRAME);
BIND_ENUM_CONSTANT(DEBUG_DRAW_NORMAL_BUFFER); BIND_ENUM_CONSTANT(DEBUG_DRAW_NORMAL_BUFFER);
BIND_ENUM_CONSTANT(DEBUG_DRAW_GI_PROBE_ALBEDO); BIND_ENUM_CONSTANT(DEBUG_DRAW_VOXEL_GI_ALBEDO);
BIND_ENUM_CONSTANT(DEBUG_DRAW_GI_PROBE_LIGHTING); BIND_ENUM_CONSTANT(DEBUG_DRAW_VOXEL_GI_LIGHTING);
BIND_ENUM_CONSTANT(DEBUG_DRAW_GI_PROBE_EMISSION); BIND_ENUM_CONSTANT(DEBUG_DRAW_VOXEL_GI_EMISSION);
BIND_ENUM_CONSTANT(DEBUG_DRAW_SHADOW_ATLAS); BIND_ENUM_CONSTANT(DEBUG_DRAW_SHADOW_ATLAS);
BIND_ENUM_CONSTANT(DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS); BIND_ENUM_CONSTANT(DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS);
BIND_ENUM_CONSTANT(DEBUG_DRAW_SCENE_LUMINANCE); BIND_ENUM_CONSTANT(DEBUG_DRAW_SCENE_LUMINANCE);

View file

@ -130,9 +130,9 @@ public:
DEBUG_DRAW_OVERDRAW, DEBUG_DRAW_OVERDRAW,
DEBUG_DRAW_WIREFRAME, DEBUG_DRAW_WIREFRAME,
DEBUG_DRAW_NORMAL_BUFFER, DEBUG_DRAW_NORMAL_BUFFER,
DEBUG_DRAW_GI_PROBE_ALBEDO, DEBUG_DRAW_VOXEL_GI_ALBEDO,
DEBUG_DRAW_GI_PROBE_LIGHTING, DEBUG_DRAW_VOXEL_GI_LIGHTING,
DEBUG_DRAW_GI_PROBE_EMISSION, DEBUG_DRAW_VOXEL_GI_EMISSION,
DEBUG_DRAW_SHADOW_ATLAS, DEBUG_DRAW_SHADOW_ATLAS,
DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS, DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
DEBUG_DRAW_SCENE_LUMINANCE, DEBUG_DRAW_SCENE_LUMINANCE,

View file

@ -184,18 +184,17 @@
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
#include "scene/3d/area_3d.h" #include "scene/3d/area_3d.h"
#include "scene/3d/audio_stream_player_3d.h" #include "scene/3d/audio_stream_player_3d.h"
#include "scene/3d/baked_lightmap.h"
#include "scene/3d/bone_attachment_3d.h" #include "scene/3d/bone_attachment_3d.h"
#include "scene/3d/camera_3d.h" #include "scene/3d/camera_3d.h"
#include "scene/3d/collision_polygon_3d.h" #include "scene/3d/collision_polygon_3d.h"
#include "scene/3d/collision_shape_3d.h" #include "scene/3d/collision_shape_3d.h"
#include "scene/3d/cpu_particles_3d.h" #include "scene/3d/cpu_particles_3d.h"
#include "scene/3d/decal.h" #include "scene/3d/decal.h"
#include "scene/3d/gi_probe.h"
#include "scene/3d/gpu_particles_3d.h" #include "scene/3d/gpu_particles_3d.h"
#include "scene/3d/gpu_particles_collision_3d.h" #include "scene/3d/gpu_particles_collision_3d.h"
#include "scene/3d/immediate_geometry_3d.h" #include "scene/3d/immediate_geometry_3d.h"
#include "scene/3d/light_3d.h" #include "scene/3d/light_3d.h"
#include "scene/3d/lightmap_gi.h"
#include "scene/3d/lightmap_probe.h" #include "scene/3d/lightmap_probe.h"
#include "scene/3d/listener_3d.h" #include "scene/3d/listener_3d.h"
#include "scene/3d/mesh_instance_3d.h" #include "scene/3d/mesh_instance_3d.h"
@ -220,6 +219,7 @@
#include "scene/3d/sprite_3d.h" #include "scene/3d/sprite_3d.h"
#include "scene/3d/vehicle_body_3d.h" #include "scene/3d/vehicle_body_3d.h"
#include "scene/3d/visibility_notifier_3d.h" #include "scene/3d/visibility_notifier_3d.h"
#include "scene/3d/voxel_gi.h"
#include "scene/3d/world_environment.h" #include "scene/3d/world_environment.h"
#include "scene/3d/xr_nodes.h" #include "scene/3d/xr_nodes.h"
#include "scene/resources/environment.h" #include "scene/resources/environment.h"
@ -452,10 +452,10 @@ void register_scene_types() {
ClassDB::register_class<SpotLight3D>(); ClassDB::register_class<SpotLight3D>();
ClassDB::register_class<ReflectionProbe>(); ClassDB::register_class<ReflectionProbe>();
ClassDB::register_class<Decal>(); ClassDB::register_class<Decal>();
ClassDB::register_class<GIProbe>(); ClassDB::register_class<VoxelGI>();
ClassDB::register_class<GIProbeData>(); ClassDB::register_class<VoxelGIData>();
ClassDB::register_class<BakedLightmap>(); ClassDB::register_class<LightmapGI>();
ClassDB::register_class<BakedLightmapData>(); ClassDB::register_class<LightmapGIData>();
ClassDB::register_class<LightmapProbe>(); ClassDB::register_class<LightmapProbe>();
ClassDB::register_virtual_class<Lightmapper>(); ClassDB::register_virtual_class<Lightmapper>();
ClassDB::register_class<GPUParticles3D>(); ClassDB::register_class<GPUParticles3D>();
@ -819,6 +819,10 @@ void register_scene_types() {
ClassDB::add_compatibility_class("Navigation3D", "Node3D"); ClassDB::add_compatibility_class("Navigation3D", "Node3D");
ClassDB::add_compatibility_class("Navigation2D", "Node2D"); ClassDB::add_compatibility_class("Navigation2D", "Node2D");
ClassDB::add_compatibility_class("YSort", "Node2D"); ClassDB::add_compatibility_class("YSort", "Node2D");
ClassDB::add_compatibility_class("GIProbe", "VoxelGI");
ClassDB::add_compatibility_class("GIProbeData", "VoxelGIData");
ClassDB::add_compatibility_class("BakedLightmap", "LightmapGI");
ClassDB::add_compatibility_class("BakedLightmapData", "LightmapGIData");
// Renamed in 4.0. // Renamed in 4.0.
// Keep alphabetical ordering to easily locate classes and avoid duplicates. // Keep alphabetical ordering to easily locate classes and avoid duplicates.

View file

@ -59,7 +59,7 @@ public:
void geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) override {} void geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) override {}
void geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) override {} void geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) override {}
void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) override {} void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) override {}
void geometry_instance_pair_gi_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_gi_probe_instances, uint32_t p_gi_probe_instance_count) override {} void geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) override {}
void geometry_instance_free(GeometryInstance *p_geometry_instance) override {} void geometry_instance_free(GeometryInstance *p_geometry_instance) override {}
@ -168,14 +168,14 @@ public:
RID lightmap_instance_create(RID p_lightmap) override { return RID(); } RID lightmap_instance_create(RID p_lightmap) override { return RID(); }
void lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) override {} void lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) override {}
RID gi_probe_instance_create(RID p_gi_probe) override { return RID(); } RID voxel_gi_instance_create(RID p_voxel_gi) override { return RID(); }
void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) override {} void voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) override {}
bool gi_probe_needs_update(RID p_probe) const override { return false; } bool voxel_gi_needs_update(RID p_probe) const override { return false; }
void gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects) override {} void voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects) override {}
void gi_probe_set_quality(RS::GIProbeQuality) override {} void voxel_gi_set_quality(RS::VoxelGIQuality) override {}
void render_scene(RID p_render_buffers, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr) override {} void render_scene(RID p_render_buffers, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr) override {}
void render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) override {} void render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) override {}
void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<GeometryInstance *> &p_instances) override {} void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<GeometryInstance *> &p_instances) override {}
@ -482,52 +482,52 @@ public:
AABB decal_get_aabb(RID p_decal) const override { return AABB(); } AABB decal_get_aabb(RID p_decal) const override { return AABB(); }
/* GI PROBE API */ /* VOXEL GI API */
RID gi_probe_allocate() override { return RID(); } RID voxel_gi_allocate() override { return RID(); }
void gi_probe_initialize(RID p_rid) override {} void voxel_gi_initialize(RID p_rid) override {}
void gi_probe_allocate_data(RID p_gi_probe, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) override {} void voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) override {}
AABB gi_probe_get_bounds(RID p_gi_probe) const override { return AABB(); } AABB voxel_gi_get_bounds(RID p_voxel_gi) const override { return AABB(); }
Vector3i gi_probe_get_octree_size(RID p_gi_probe) const override { return Vector3i(); } Vector3i voxel_gi_get_octree_size(RID p_voxel_gi) const override { return Vector3i(); }
Vector<uint8_t> gi_probe_get_octree_cells(RID p_gi_probe) const override { return Vector<uint8_t>(); } Vector<uint8_t> voxel_gi_get_octree_cells(RID p_voxel_gi) const override { return Vector<uint8_t>(); }
Vector<uint8_t> gi_probe_get_data_cells(RID p_gi_probe) const override { return Vector<uint8_t>(); } Vector<uint8_t> voxel_gi_get_data_cells(RID p_voxel_gi) const override { return Vector<uint8_t>(); }
Vector<uint8_t> gi_probe_get_distance_field(RID p_gi_probe) const override { return Vector<uint8_t>(); } Vector<uint8_t> voxel_gi_get_distance_field(RID p_voxel_gi) const override { return Vector<uint8_t>(); }
Vector<int> gi_probe_get_level_counts(RID p_gi_probe) const override { return Vector<int>(); } Vector<int> voxel_gi_get_level_counts(RID p_voxel_gi) const override { return Vector<int>(); }
Transform3D gi_probe_get_to_cell_xform(RID p_gi_probe) const override { return Transform3D(); } Transform3D voxel_gi_get_to_cell_xform(RID p_voxel_gi) const override { return Transform3D(); }
void gi_probe_set_dynamic_range(RID p_gi_probe, float p_range) override {} void voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) override {}
float gi_probe_get_dynamic_range(RID p_gi_probe) const override { return 0; } float voxel_gi_get_dynamic_range(RID p_voxel_gi) const override { return 0; }
void gi_probe_set_propagation(RID p_gi_probe, float p_range) override {} void voxel_gi_set_propagation(RID p_voxel_gi, float p_range) override {}
float gi_probe_get_propagation(RID p_gi_probe) const override { return 0; } float voxel_gi_get_propagation(RID p_voxel_gi) const override { return 0; }
void gi_probe_set_energy(RID p_gi_probe, float p_range) override {} void voxel_gi_set_energy(RID p_voxel_gi, float p_range) override {}
float gi_probe_get_energy(RID p_gi_probe) const override { return 0.0; } float voxel_gi_get_energy(RID p_voxel_gi) const override { return 0.0; }
void gi_probe_set_ao(RID p_gi_probe, float p_ao) override {} void voxel_gi_set_ao(RID p_voxel_gi, float p_ao) override {}
float gi_probe_get_ao(RID p_gi_probe) const override { return 0; } float voxel_gi_get_ao(RID p_voxel_gi) const override { return 0; }
void gi_probe_set_ao_size(RID p_gi_probe, float p_strength) override {} void voxel_gi_set_ao_size(RID p_voxel_gi, float p_strength) override {}
float gi_probe_get_ao_size(RID p_gi_probe) const override { return 0; } float voxel_gi_get_ao_size(RID p_voxel_gi) const override { return 0; }
void gi_probe_set_bias(RID p_gi_probe, float p_range) override {} void voxel_gi_set_bias(RID p_voxel_gi, float p_range) override {}
float gi_probe_get_bias(RID p_gi_probe) const override { return 0.0; } float voxel_gi_get_bias(RID p_voxel_gi) const override { return 0.0; }
void gi_probe_set_normal_bias(RID p_gi_probe, float p_range) override {} void voxel_gi_set_normal_bias(RID p_voxel_gi, float p_range) override {}
float gi_probe_get_normal_bias(RID p_gi_probe) const override { return 0.0; } float voxel_gi_get_normal_bias(RID p_voxel_gi) const override { return 0.0; }
void gi_probe_set_interior(RID p_gi_probe, bool p_enable) override {} void voxel_gi_set_interior(RID p_voxel_gi, bool p_enable) override {}
bool gi_probe_is_interior(RID p_gi_probe) const override { return false; } bool voxel_gi_is_interior(RID p_voxel_gi) const override { return false; }
void gi_probe_set_use_two_bounces(RID p_gi_probe, bool p_enable) override {} void voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) override {}
bool gi_probe_is_using_two_bounces(RID p_gi_probe) const override { return false; } bool voxel_gi_is_using_two_bounces(RID p_voxel_gi) const override { return false; }
void gi_probe_set_anisotropy_strength(RID p_gi_probe, float p_strength) override {} void voxel_gi_set_anisotropy_strength(RID p_voxel_gi, float p_strength) override {}
float gi_probe_get_anisotropy_strength(RID p_gi_probe) const override { return 0; } float voxel_gi_get_anisotropy_strength(RID p_voxel_gi) const override { return 0; }
uint32_t gi_probe_get_version(RID p_gi_probe) override { return 0; } uint32_t voxel_gi_get_version(RID p_voxel_gi) override { return 0; }
/* LIGHTMAP CAPTURE */ /* LIGHTMAP CAPTURE */
RID lightmap_allocate() override { return RID(); } RID lightmap_allocate() override { return RID(); }

View file

@ -1401,19 +1401,19 @@ void EffectsRD::render_sky(RD::DrawListID p_list, float p_time, RID p_fb, RID p_
RD::get_singleton()->draw_list_draw(draw_list, true); RD::get_singleton()->draw_list_draw(draw_list, true);
} }
void EffectsRD::resolve_gi(RID p_source_depth, RID p_source_normal_roughness, RID p_source_giprobe, RID p_dest_depth, RID p_dest_normal_roughness, RID p_dest_giprobe, Vector2i p_screen_size, int p_samples, uint32_t p_barrier) { void EffectsRD::resolve_gi(RID p_source_depth, RID p_source_normal_roughness, RID p_source_voxel_gi, RID p_dest_depth, RID p_dest_normal_roughness, RID p_dest_voxel_gi, Vector2i p_screen_size, int p_samples, uint32_t p_barrier) {
ResolvePushConstant push_constant; ResolvePushConstant push_constant;
push_constant.screen_size[0] = p_screen_size.x; push_constant.screen_size[0] = p_screen_size.x;
push_constant.screen_size[1] = p_screen_size.y; push_constant.screen_size[1] = p_screen_size.y;
push_constant.samples = p_samples; push_constant.samples = p_samples;
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, resolve.pipelines[p_source_giprobe.is_valid() ? RESOLVE_MODE_GI_GIPROBE : RESOLVE_MODE_GI]); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, resolve.pipelines[p_source_voxel_gi.is_valid() ? RESOLVE_MODE_GI_VOXEL_GI : RESOLVE_MODE_GI]);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture_pair(p_source_depth, p_source_normal_roughness), 0); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture_pair(p_source_depth, p_source_normal_roughness), 0);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_dest_depth, p_dest_normal_roughness), 1); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_dest_depth, p_dest_normal_roughness), 1);
if (p_source_giprobe.is_valid()) { if (p_source_voxel_gi.is_valid()) {
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_source_giprobe), 2); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_source_voxel_gi), 2);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_dest_giprobe), 3); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_dest_voxel_gi), 3);
} }
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(ResolvePushConstant)); RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(ResolvePushConstant));
@ -1907,7 +1907,7 @@ EffectsRD::EffectsRD() {
{ {
Vector<String> resolve_modes; Vector<String> resolve_modes;
resolve_modes.push_back("\n#define MODE_RESOLVE_GI\n"); resolve_modes.push_back("\n#define MODE_RESOLVE_GI\n");
resolve_modes.push_back("\n#define MODE_RESOLVE_GI\n#define GIPROBE_RESOLVE\n"); resolve_modes.push_back("\n#define MODE_RESOLVE_GI\n#define VOXEL_GI_RESOLVE\n");
resolve.shader.initialize(resolve_modes); resolve.shader.initialize(resolve_modes);

View file

@ -585,7 +585,7 @@ class EffectsRD {
enum ResolveMode { enum ResolveMode {
RESOLVE_MODE_GI, RESOLVE_MODE_GI,
RESOLVE_MODE_GI_GIPROBE, RESOLVE_MODE_GI_VOXEL_GI,
RESOLVE_MODE_MAX RESOLVE_MODE_MAX
}; };
@ -750,7 +750,7 @@ public:
void merge_specular(RID p_dest_framebuffer, RID p_specular, RID p_base, RID p_reflection); void merge_specular(RID p_dest_framebuffer, RID p_specular, RID p_base, RID p_reflection);
void sub_surface_scattering(RID p_diffuse, RID p_diffuse2, RID p_depth, const CameraMatrix &p_camera, const Size2i &p_screen_size, float p_scale, float p_depth_scale, RS::SubSurfaceScatteringQuality p_quality); void sub_surface_scattering(RID p_diffuse, RID p_diffuse2, RID p_depth, const CameraMatrix &p_camera, const Size2i &p_screen_size, float p_scale, float p_depth_scale, RS::SubSurfaceScatteringQuality p_quality);
void resolve_gi(RID p_source_depth, RID p_source_normal_roughness, RID p_source_giprobe, RID p_dest_depth, RID p_dest_normal_roughness, RID p_dest_giprobe, Vector2i p_screen_size, int p_samples, uint32_t p_barrier = RD::BARRIER_MASK_ALL); void resolve_gi(RID p_source_depth, RID p_source_normal_roughness, RID p_source_voxel_gi, RID p_dest_depth, RID p_dest_normal_roughness, RID p_dest_voxel_gi, Vector2i p_screen_size, int p_samples, uint32_t p_barrier = RD::BARRIER_MASK_ALL);
void sort_buffer(RID p_uniform_set, int p_size); void sort_buffer(RID p_uniform_set, int p_size);

View file

@ -93,8 +93,8 @@ void RenderForwardClustered::RenderBufferDataForwardClustered::ensure_specular()
} }
} }
void RenderForwardClustered::RenderBufferDataForwardClustered::ensure_giprobe() { void RenderForwardClustered::RenderBufferDataForwardClustered::ensure_voxelgi() {
if (!giprobe_buffer.is_valid()) { if (!voxelgi_buffer.is_valid()) {
RD::TextureFormat tf; RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R8G8_UINT; tf.format = RD::DATA_FORMAT_R8G8_UINT;
tf.width = width; tf.width = width;
@ -105,41 +105,41 @@ void RenderForwardClustered::RenderBufferDataForwardClustered::ensure_giprobe()
RD::TextureFormat tf_aa = tf; RD::TextureFormat tf_aa = tf;
tf_aa.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; tf_aa.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
tf_aa.samples = texture_samples; tf_aa.samples = texture_samples;
giprobe_buffer_msaa = RD::get_singleton()->texture_create(tf_aa, RD::TextureView()); voxelgi_buffer_msaa = RD::get_singleton()->texture_create(tf_aa, RD::TextureView());
} else { } else {
tf.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; tf.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
} }
tf.usage_bits |= RD::TEXTURE_USAGE_STORAGE_BIT; tf.usage_bits |= RD::TEXTURE_USAGE_STORAGE_BIT;
giprobe_buffer = RD::get_singleton()->texture_create(tf, RD::TextureView()); voxelgi_buffer = RD::get_singleton()->texture_create(tf, RD::TextureView());
Vector<RID> fb; Vector<RID> fb;
if (msaa != RS::VIEWPORT_MSAA_DISABLED) { if (msaa != RS::VIEWPORT_MSAA_DISABLED) {
fb.push_back(depth_msaa); fb.push_back(depth_msaa);
fb.push_back(normal_roughness_buffer_msaa); fb.push_back(normal_roughness_buffer_msaa);
fb.push_back(giprobe_buffer_msaa); fb.push_back(voxelgi_buffer_msaa);
} else { } else {
fb.push_back(depth); fb.push_back(depth);
fb.push_back(normal_roughness_buffer); fb.push_back(normal_roughness_buffer);
fb.push_back(giprobe_buffer); fb.push_back(voxelgi_buffer);
} }
depth_normal_roughness_giprobe_fb = RD::get_singleton()->framebuffer_create(fb); depth_normal_roughness_voxelgi_fb = RD::get_singleton()->framebuffer_create(fb);
} }
} }
void RenderForwardClustered::RenderBufferDataForwardClustered::clear() { void RenderForwardClustered::RenderBufferDataForwardClustered::clear() {
if (giprobe_buffer != RID()) { if (voxelgi_buffer != RID()) {
RD::get_singleton()->free(giprobe_buffer); RD::get_singleton()->free(voxelgi_buffer);
giprobe_buffer = RID(); voxelgi_buffer = RID();
if (giprobe_buffer_msaa.is_valid()) { if (voxelgi_buffer_msaa.is_valid()) {
RD::get_singleton()->free(giprobe_buffer_msaa); RD::get_singleton()->free(voxelgi_buffer_msaa);
giprobe_buffer_msaa = RID(); voxelgi_buffer_msaa = RID();
} }
depth_normal_roughness_giprobe_fb = RID(); depth_normal_roughness_voxelgi_fb = RID();
} }
if (color_msaa.is_valid()) { if (color_msaa.is_valid()) {
@ -398,8 +398,8 @@ void RenderForwardClustered::_render_list_template(RenderingDevice::DrawListID p
case PASS_MODE_DEPTH_NORMAL_ROUGHNESS: { case PASS_MODE_DEPTH_NORMAL_ROUGHNESS: {
shader_version = SceneShaderForwardClustered::SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS; shader_version = SceneShaderForwardClustered::SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS;
} break; } break;
case PASS_MODE_DEPTH_NORMAL_ROUGHNESS_GIPROBE: { case PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI: {
shader_version = SceneShaderForwardClustered::SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS_AND_GIPROBE; shader_version = SceneShaderForwardClustered::SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS_AND_VOXEL_GI;
} break; } break;
case PASS_MODE_DEPTH_MATERIAL: { case PASS_MODE_DEPTH_MATERIAL: {
shader_version = SceneShaderForwardClustered::SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL; shader_version = SceneShaderForwardClustered::SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL;
@ -498,8 +498,8 @@ void RenderForwardClustered::_render_list(RenderingDevice::DrawListID p_draw_lis
case PASS_MODE_DEPTH_NORMAL_ROUGHNESS: { case PASS_MODE_DEPTH_NORMAL_ROUGHNESS: {
_render_list_template<PASS_MODE_DEPTH_NORMAL_ROUGHNESS>(p_draw_list, p_framebuffer_Format, p_params, p_from_element, p_to_element); _render_list_template<PASS_MODE_DEPTH_NORMAL_ROUGHNESS>(p_draw_list, p_framebuffer_Format, p_params, p_from_element, p_to_element);
} break; } break;
case PASS_MODE_DEPTH_NORMAL_ROUGHNESS_GIPROBE: { case PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI: {
_render_list_template<PASS_MODE_DEPTH_NORMAL_ROUGHNESS_GIPROBE>(p_draw_list, p_framebuffer_Format, p_params, p_from_element, p_to_element); _render_list_template<PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI>(p_draw_list, p_framebuffer_Format, p_params, p_from_element, p_to_element);
} break; } break;
case PASS_MODE_DEPTH_MATERIAL: { case PASS_MODE_DEPTH_MATERIAL: {
_render_list_template<PASS_MODE_DEPTH_MATERIAL>(p_draw_list, p_framebuffer_Format, p_params, p_from_element, p_to_element); _render_list_template<PASS_MODE_DEPTH_MATERIAL>(p_draw_list, p_framebuffer_Format, p_params, p_from_element, p_to_element);
@ -948,14 +948,14 @@ void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, con
flags |= INSTANCE_DATA_FLAG_USE_GI_BUFFERS; flags |= INSTANCE_DATA_FLAG_USE_GI_BUFFERS;
} }
if (inst->gi_probes[0].is_valid()) { if (inst->voxel_gi_instances[0].is_valid()) {
uint32_t probe0_index = 0xFFFF; uint32_t probe0_index = 0xFFFF;
uint32_t probe1_index = 0xFFFF; uint32_t probe1_index = 0xFFFF;
for (uint32_t j = 0; j < scene_state.giprobes_used; j++) { for (uint32_t j = 0; j < scene_state.voxelgis_used; j++) {
if (scene_state.giprobe_ids[j] == inst->gi_probes[0]) { if (scene_state.voxelgi_ids[j] == inst->voxel_gi_instances[0]) {
probe0_index = j; probe0_index = j;
} else if (scene_state.giprobe_ids[j] == inst->gi_probes[1]) { } else if (scene_state.voxelgi_ids[j] == inst->voxel_gi_instances[1]) {
probe1_index = j; probe1_index = j;
} }
} }
@ -966,7 +966,7 @@ void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, con
} }
inst->gi_offset_cache = probe0_index | (probe1_index << 16); inst->gi_offset_cache = probe0_index | (probe1_index << 16);
flags |= INSTANCE_DATA_FLAG_USE_GIPROBE; flags |= INSTANCE_DATA_FLAG_USE_VOXEL_GI;
uses_gi = true; uses_gi = true;
} else { } else {
if (p_using_sdfgi && inst->can_sdfgi) { if (p_using_sdfgi && inst->can_sdfgi) {
@ -1061,10 +1061,10 @@ void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, con
} }
} }
void RenderForwardClustered::_setup_giprobes(const PagedArray<RID> &p_giprobes) { void RenderForwardClustered::_setup_voxelgis(const PagedArray<RID> &p_voxelgis) {
scene_state.giprobes_used = MIN(p_giprobes.size(), uint32_t(MAX_GI_PROBES)); scene_state.voxelgis_used = MIN(p_voxelgis.size(), uint32_t(MAX_VOXEL_GI_INSTANCESS));
for (uint32_t i = 0; i < scene_state.giprobes_used; i++) { for (uint32_t i = 0; i < scene_state.voxelgis_used; i++) {
scene_state.giprobe_ids[i] = p_giprobes[i]; scene_state.voxelgi_ids[i] = p_voxelgis[i];
} }
} }
@ -1120,7 +1120,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
bool using_separate_specular = false; bool using_separate_specular = false;
bool using_ssr = false; bool using_ssr = false;
bool using_sdfgi = false; bool using_sdfgi = false;
bool using_giprobe = false; bool using_voxelgi = false;
bool reverse_cull = false; bool reverse_cull = false;
if (render_buffer) { if (render_buffer) {
@ -1129,19 +1129,19 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
opaque_framebuffer = render_buffer->color_fb; opaque_framebuffer = render_buffer->color_fb;
if (p_render_data->gi_probes->size() > 0) { if (p_render_data->voxel_gi_instances->size() > 0) {
using_giprobe = true; using_voxelgi = true;
} }
if (!p_render_data->environment.is_valid() && using_giprobe) { if (!p_render_data->environment.is_valid() && using_voxelgi) {
depth_pass_mode = PASS_MODE_DEPTH_NORMAL_ROUGHNESS_GIPROBE; depth_pass_mode = PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI;
} else if (p_render_data->environment.is_valid() && (environment_is_ssr_enabled(p_render_data->environment) || environment_is_sdfgi_enabled(p_render_data->environment) || using_giprobe)) { } else if (p_render_data->environment.is_valid() && (environment_is_ssr_enabled(p_render_data->environment) || environment_is_sdfgi_enabled(p_render_data->environment) || using_voxelgi)) {
if (environment_is_sdfgi_enabled(p_render_data->environment)) { if (environment_is_sdfgi_enabled(p_render_data->environment)) {
depth_pass_mode = using_giprobe ? PASS_MODE_DEPTH_NORMAL_ROUGHNESS_GIPROBE : PASS_MODE_DEPTH_NORMAL_ROUGHNESS; // also giprobe depth_pass_mode = using_voxelgi ? PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI : PASS_MODE_DEPTH_NORMAL_ROUGHNESS; // also voxelgi
using_sdfgi = true; using_sdfgi = true;
} else { } else {
depth_pass_mode = using_giprobe ? PASS_MODE_DEPTH_NORMAL_ROUGHNESS_GIPROBE : PASS_MODE_DEPTH_NORMAL_ROUGHNESS; depth_pass_mode = using_voxelgi ? PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI : PASS_MODE_DEPTH_NORMAL_ROUGHNESS;
} }
if (environment_is_ssr_enabled(p_render_data->environment)) { if (environment_is_ssr_enabled(p_render_data->environment)) {
@ -1164,10 +1164,10 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
depth_framebuffer = render_buffer->depth_normal_roughness_fb; depth_framebuffer = render_buffer->depth_normal_roughness_fb;
depth_pass_clear.push_back(Color(0.5, 0.5, 0.5, 0)); depth_pass_clear.push_back(Color(0.5, 0.5, 0.5, 0));
} break; } break;
case PASS_MODE_DEPTH_NORMAL_ROUGHNESS_GIPROBE: { case PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI: {
_allocate_normal_roughness_texture(render_buffer); _allocate_normal_roughness_texture(render_buffer);
render_buffer->ensure_giprobe(); render_buffer->ensure_voxelgi();
depth_framebuffer = render_buffer->depth_normal_roughness_giprobe_fb; depth_framebuffer = render_buffer->depth_normal_roughness_voxelgi_fb;
depth_pass_clear.push_back(Color(0.5, 0.5, 0.5, 0)); depth_pass_clear.push_back(Color(0.5, 0.5, 0.5, 0));
depth_pass_clear.push_back(Color(0, 0, 0, 0)); depth_pass_clear.push_back(Color(0, 0, 0, 0));
} break; } break;
@ -1198,12 +1198,12 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
RD::get_singleton()->draw_command_begin_label("Render Setup"); RD::get_singleton()->draw_command_begin_label("Render Setup");
_setup_lightmaps(*p_render_data->lightmaps, p_render_data->cam_transform); _setup_lightmaps(*p_render_data->lightmaps, p_render_data->cam_transform);
_setup_giprobes(*p_render_data->gi_probes); _setup_voxelgis(*p_render_data->voxel_gi_instances);
_setup_environment(p_render_data, p_render_data->reflection_probe.is_valid(), screen_size, !p_render_data->reflection_probe.is_valid(), p_default_bg_color, false); _setup_environment(p_render_data, p_render_data->reflection_probe.is_valid(), screen_size, !p_render_data->reflection_probe.is_valid(), p_default_bg_color, false);
_update_render_base_uniform_set(); //may have changed due to the above (light buffer enlarged, as an example) _update_render_base_uniform_set(); //may have changed due to the above (light buffer enlarged, as an example)
_fill_render_list(RENDER_LIST_OPAQUE, p_render_data, PASS_MODE_COLOR, using_sdfgi, using_sdfgi || using_giprobe); _fill_render_list(RENDER_LIST_OPAQUE, p_render_data, PASS_MODE_COLOR, using_sdfgi, using_sdfgi || using_voxelgi);
render_list[RENDER_LIST_OPAQUE].sort_by_key(); render_list[RENDER_LIST_OPAQUE].sort_by_key();
render_list[RENDER_LIST_ALPHA].sort_by_depth(); render_list[RENDER_LIST_ALPHA].sort_by_depth();
_fill_instance_data(RENDER_LIST_OPAQUE); _fill_instance_data(RENDER_LIST_OPAQUE);
@ -1293,7 +1293,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
clear_color = p_default_bg_color; clear_color = p_default_bg_color;
} }
bool debug_giprobes = get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_ALBEDO || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION; bool debug_voxelgis = get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_VOXEL_GI_ALBEDO || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_VOXEL_GI_LIGHTING || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION;
bool debug_sdfgi_probes = get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_SDFGI_PROBES; bool debug_sdfgi_probes = get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_SDFGI_PROBES;
bool depth_pre_pass = depth_framebuffer.is_valid(); bool depth_pre_pass = depth_framebuffer.is_valid();
@ -1301,7 +1301,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
bool continue_depth = false; bool continue_depth = false;
if (depth_pre_pass) { //depth pre pass if (depth_pre_pass) { //depth pre pass
bool needs_pre_resolve = _needs_post_prepass_render(p_render_data, using_sdfgi || using_giprobe); bool needs_pre_resolve = _needs_post_prepass_render(p_render_data, using_sdfgi || using_voxelgi);
if (needs_pre_resolve) { if (needs_pre_resolve) {
RENDER_TIMESTAMP("GI + Render Depth Pre-Pass (parallel)"); RENDER_TIMESTAMP("GI + Render Depth Pre-Pass (parallel)");
} else { } else {
@ -1312,32 +1312,32 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
RD::get_singleton()->draw_list_begin(depth_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_CONTINUE, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_CONTINUE, depth_pass_clear); RD::get_singleton()->draw_list_begin(depth_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_CONTINUE, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_CONTINUE, depth_pass_clear);
RD::get_singleton()->draw_list_end(); RD::get_singleton()->draw_list_end();
//start compute processes here, so they run at the same time as depth pre-pass //start compute processes here, so they run at the same time as depth pre-pass
_post_prepass_render(p_render_data, using_sdfgi || using_giprobe); _post_prepass_render(p_render_data, using_sdfgi || using_voxelgi);
} }
RD::get_singleton()->draw_command_begin_label("Render Depth Pre-Pass"); RD::get_singleton()->draw_command_begin_label("Render Depth Pre-Pass");
RID rp_uniform_set = _setup_render_pass_uniform_set(RENDER_LIST_OPAQUE, nullptr, RID()); RID rp_uniform_set = _setup_render_pass_uniform_set(RENDER_LIST_OPAQUE, nullptr, RID());
bool finish_depth = using_ssao || using_sdfgi || using_giprobe; bool finish_depth = using_ssao || using_sdfgi || using_voxelgi;
RenderListParameters render_list_params(render_list[RENDER_LIST_OPAQUE].elements.ptr(), render_list[RENDER_LIST_OPAQUE].element_info.ptr(), render_list[RENDER_LIST_OPAQUE].elements.size(), reverse_cull, depth_pass_mode, render_buffer == nullptr, rp_uniform_set, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_WIREFRAME, Vector2(), p_render_data->lod_camera_plane, p_render_data->lod_distance_multiplier, p_render_data->screen_lod_threshold); RenderListParameters render_list_params(render_list[RENDER_LIST_OPAQUE].elements.ptr(), render_list[RENDER_LIST_OPAQUE].element_info.ptr(), render_list[RENDER_LIST_OPAQUE].elements.size(), reverse_cull, depth_pass_mode, render_buffer == nullptr, rp_uniform_set, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_WIREFRAME, Vector2(), p_render_data->lod_camera_plane, p_render_data->lod_distance_multiplier, p_render_data->screen_lod_threshold);
_render_list_with_threads(&render_list_params, depth_framebuffer, needs_pre_resolve ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, needs_pre_resolve ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_CLEAR, finish_depth ? RD::FINAL_ACTION_READ : RD::FINAL_ACTION_CONTINUE, needs_pre_resolve ? Vector<Color>() : depth_pass_clear); _render_list_with_threads(&render_list_params, depth_framebuffer, needs_pre_resolve ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, needs_pre_resolve ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_CLEAR, finish_depth ? RD::FINAL_ACTION_READ : RD::FINAL_ACTION_CONTINUE, needs_pre_resolve ? Vector<Color>() : depth_pass_clear);
RD::get_singleton()->draw_command_end_label(); RD::get_singleton()->draw_command_end_label();
if (needs_pre_resolve) { if (needs_pre_resolve) {
_pre_resolve_render(p_render_data, using_sdfgi || using_giprobe); _pre_resolve_render(p_render_data, using_sdfgi || using_voxelgi);
} }
if (render_buffer && render_buffer->msaa != RS::VIEWPORT_MSAA_DISABLED) { if (render_buffer && render_buffer->msaa != RS::VIEWPORT_MSAA_DISABLED) {
RENDER_TIMESTAMP("Resolve Depth Pre-Pass"); RENDER_TIMESTAMP("Resolve Depth Pre-Pass");
RD::get_singleton()->draw_command_begin_label("Resolve Depth Pre-Pass"); RD::get_singleton()->draw_command_begin_label("Resolve Depth Pre-Pass");
if (depth_pass_mode == PASS_MODE_DEPTH_NORMAL_ROUGHNESS || depth_pass_mode == PASS_MODE_DEPTH_NORMAL_ROUGHNESS_GIPROBE) { if (depth_pass_mode == PASS_MODE_DEPTH_NORMAL_ROUGHNESS || depth_pass_mode == PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI) {
if (needs_pre_resolve) { if (needs_pre_resolve) {
RD::get_singleton()->barrier(RD::BARRIER_MASK_RASTER, RD::BARRIER_MASK_COMPUTE); RD::get_singleton()->barrier(RD::BARRIER_MASK_RASTER, RD::BARRIER_MASK_COMPUTE);
} }
static int texture_samples[RS::VIEWPORT_MSAA_MAX] = { 1, 2, 4, 8, 16 }; static int texture_samples[RS::VIEWPORT_MSAA_MAX] = { 1, 2, 4, 8, 16 };
storage->get_effects()->resolve_gi(render_buffer->depth_msaa, render_buffer->normal_roughness_buffer_msaa, using_giprobe ? render_buffer->giprobe_buffer_msaa : RID(), render_buffer->depth, render_buffer->normal_roughness_buffer, using_giprobe ? render_buffer->giprobe_buffer : RID(), Vector2i(render_buffer->width, render_buffer->height), texture_samples[render_buffer->msaa]); storage->get_effects()->resolve_gi(render_buffer->depth_msaa, render_buffer->normal_roughness_buffer_msaa, using_voxelgi ? render_buffer->voxelgi_buffer_msaa : RID(), render_buffer->depth, render_buffer->normal_roughness_buffer, using_voxelgi ? render_buffer->voxelgi_buffer : RID(), Vector2i(render_buffer->width, render_buffer->height), texture_samples[render_buffer->msaa]);
} else if (finish_depth) { } else if (finish_depth) {
RD::get_singleton()->texture_resolve_multisample(render_buffer->depth_msaa, render_buffer->depth); RD::get_singleton()->texture_resolve_multisample(render_buffer->depth_msaa, render_buffer->depth);
} }
@ -1347,7 +1347,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
continue_depth = !finish_depth; continue_depth = !finish_depth;
} }
_pre_opaque_render(p_render_data, using_ssao, using_sdfgi || using_giprobe, render_buffer ? render_buffer->normal_roughness_buffer : RID(), render_buffer ? render_buffer->giprobe_buffer : RID()); _pre_opaque_render(p_render_data, using_ssao, using_sdfgi || using_voxelgi, render_buffer ? render_buffer->normal_roughness_buffer : RID(), render_buffer ? render_buffer->voxelgi_buffer : RID());
RD::get_singleton()->draw_command_begin_label("Render Opaque Pass"); RD::get_singleton()->draw_command_begin_label("Render Opaque Pass");
@ -1363,8 +1363,8 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
bool can_continue_depth = !scene_state.used_depth_texture && !using_ssr && !using_sss; bool can_continue_depth = !scene_state.used_depth_texture && !using_ssr && !using_sss;
{ {
bool will_continue_color = (can_continue_color || draw_sky || draw_sky_fog_only || debug_giprobes || debug_sdfgi_probes); bool will_continue_color = (can_continue_color || draw_sky || draw_sky_fog_only || debug_voxelgis || debug_sdfgi_probes);
bool will_continue_depth = (can_continue_depth || draw_sky || draw_sky_fog_only || debug_giprobes || debug_sdfgi_probes); bool will_continue_depth = (can_continue_depth || draw_sky || draw_sky_fog_only || debug_voxelgis || debug_sdfgi_probes);
//regular forward for now //regular forward for now
Vector<Color> c; Vector<Color> c;
@ -1389,8 +1389,8 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
RD::get_singleton()->draw_command_end_label(); RD::get_singleton()->draw_command_end_label();
if (debug_giprobes) { if (debug_voxelgis) {
//debug giprobes //debug voxelgis
bool will_continue_color = (can_continue_color || draw_sky || draw_sky_fog_only); bool will_continue_color = (can_continue_color || draw_sky || draw_sky_fog_only);
bool will_continue_depth = (can_continue_depth || draw_sky || draw_sky_fog_only); bool will_continue_depth = (can_continue_depth || draw_sky || draw_sky_fog_only);
@ -1398,16 +1398,16 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
dc.set_depth_correction(true); dc.set_depth_correction(true);
CameraMatrix cm = (dc * p_render_data->cam_projection) * CameraMatrix(p_render_data->cam_transform.affine_inverse()); CameraMatrix cm = (dc * p_render_data->cam_projection) * CameraMatrix(p_render_data->cam_transform.affine_inverse());
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(opaque_framebuffer, RD::INITIAL_ACTION_CONTINUE, will_continue_color ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, will_continue_depth ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ); RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(opaque_framebuffer, RD::INITIAL_ACTION_CONTINUE, will_continue_color ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, will_continue_depth ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ);
RD::get_singleton()->draw_command_begin_label("Debug GIProbes"); RD::get_singleton()->draw_command_begin_label("Debug VoxelGIs");
for (int i = 0; i < (int)p_render_data->gi_probes->size(); i++) { for (int i = 0; i < (int)p_render_data->voxel_gi_instances->size(); i++) {
gi.debug_giprobe((*p_render_data->gi_probes)[i], draw_list, opaque_framebuffer, cm, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION, 1.0); gi.debug_voxel_gi((*p_render_data->voxel_gi_instances)[i], draw_list, opaque_framebuffer, cm, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_VOXEL_GI_LIGHTING, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION, 1.0);
} }
RD::get_singleton()->draw_command_end_label(); RD::get_singleton()->draw_command_end_label();
RD::get_singleton()->draw_list_end(); RD::get_singleton()->draw_list_end();
} }
if (debug_sdfgi_probes) { if (debug_sdfgi_probes) {
//debug giprobes //debug voxelgis
bool will_continue_color = (can_continue_color || draw_sky || draw_sky_fog_only); bool will_continue_color = (can_continue_color || draw_sky || draw_sky_fog_only);
bool will_continue_depth = (can_continue_depth || draw_sky || draw_sky_fog_only); bool will_continue_depth = (can_continue_depth || draw_sky || draw_sky_fog_only);
@ -2059,11 +2059,11 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
RD::Uniform u; RD::Uniform u;
u.binding = 7; u.binding = 7;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.ids.resize(MAX_GI_PROBES); u.ids.resize(MAX_VOXEL_GI_INSTANCESS);
RID default_tex = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE); RID default_tex = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE);
for (int i = 0; i < MAX_GI_PROBES; i++) { for (int i = 0; i < MAX_VOXEL_GI_INSTANCESS; i++) {
if (p_render_data && i < (int)p_render_data->gi_probes->size()) { if (p_render_data && i < (int)p_render_data->voxel_gi_instances->size()) {
RID tex = gi.gi_probe_instance_get_texture((*p_render_data->gi_probes)[i]); RID tex = gi.voxel_gi_instance_get_texture((*p_render_data->voxel_gi_instances)[i]);
if (!tex.is_valid()) { if (!tex.is_valid()) {
tex = default_tex; tex = default_tex;
} }
@ -2170,7 +2170,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
RD::Uniform u; RD::Uniform u;
u.binding = 17; u.binding = 17;
u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER;
u.ids.push_back(rb ? render_buffers_get_gi_probe_buffer(p_render_data->render_buffers) : render_buffers_get_default_gi_probe_buffer()); u.ids.push_back(rb ? render_buffers_get_voxel_gi_buffer(p_render_data->render_buffers) : render_buffers_get_default_voxel_gi_buffer());
uniforms.push_back(u); uniforms.push_back(u);
} }
{ {
@ -2279,13 +2279,13 @@ RID RenderForwardClustered::_setup_sdfgi_render_pass_uniform_set(RID p_albedo_te
} }
{ {
// No GIProbes // No VoxelGIs
RD::Uniform u; RD::Uniform u;
u.binding = 7; u.binding = 7;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.ids.resize(MAX_GI_PROBES); u.ids.resize(MAX_VOXEL_GI_INSTANCESS);
RID default_tex = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE); RID default_tex = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE);
for (int i = 0; i < MAX_GI_PROBES; i++) { for (int i = 0; i < MAX_VOXEL_GI_INSTANCESS; i++) {
u.ids.write[i] = default_tex; u.ids.write[i] = default_tex;
} }
@ -2633,7 +2633,7 @@ void RenderForwardClustered::_geometry_instance_update(GeometryInstance *p_geome
ginstance->can_sdfgi = false; ginstance->can_sdfgi = false;
if (!lightmap_instance_is_valid(ginstance->lightmap_instance)) { if (!lightmap_instance_is_valid(ginstance->lightmap_instance)) {
if (ginstance->gi_probes[0].is_null() && (ginstance->data->use_baked_light || ginstance->data->use_dynamic_gi)) { if (ginstance->voxel_gi_instances[0].is_null() && (ginstance->data->use_baked_light || ginstance->data->use_dynamic_gi)) {
ginstance->can_sdfgi = true; ginstance->can_sdfgi = true;
} }
} }
@ -2816,7 +2816,7 @@ void RenderForwardClustered::geometry_instance_free(GeometryInstance *p_geometry
} }
uint32_t RenderForwardClustered::geometry_instance_get_pair_mask() { uint32_t RenderForwardClustered::geometry_instance_get_pair_mask() {
return (1 << RS::INSTANCE_GI_PROBE); return (1 << RS::INSTANCE_VOXEL_GI);
} }
void RenderForwardClustered::geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) { void RenderForwardClustered::geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) {
} }
@ -2837,19 +2837,19 @@ AABB RenderForwardClustered::geometry_instance_get_aabb(GeometryInstance *p_inst
return ginstance->data->aabb; return ginstance->data->aabb;
} }
void RenderForwardClustered::geometry_instance_pair_gi_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_gi_probe_instances, uint32_t p_gi_probe_instance_count) { void RenderForwardClustered::geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) {
GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance);
ERR_FAIL_COND(!ginstance); ERR_FAIL_COND(!ginstance);
if (p_gi_probe_instance_count > 0) { if (p_voxel_gi_instance_count > 0) {
ginstance->gi_probes[0] = p_gi_probe_instances[0]; ginstance->voxel_gi_instances[0] = p_voxel_gi_instances[0];
} else { } else {
ginstance->gi_probes[0] = RID(); ginstance->voxel_gi_instances[0] = RID();
} }
if (p_gi_probe_instance_count > 1) { if (p_voxel_gi_instance_count > 1) {
ginstance->gi_probes[1] = p_gi_probe_instances[1]; ginstance->voxel_gi_instances[1] = p_voxel_gi_instances[1];
} else { } else {
ginstance->gi_probes[1] = RID(); ginstance->voxel_gi_instances[1] = RID();
} }
} }

View file

@ -52,9 +52,9 @@ class RenderForwardClustered : public RendererSceneRenderRD {
enum { enum {
SDFGI_MAX_CASCADES = 8, SDFGI_MAX_CASCADES = 8,
MAX_GI_PROBES = 8, MAX_VOXEL_GI_INSTANCESS = 8,
MAX_LIGHTMAPS = 8, MAX_LIGHTMAPS = 8,
MAX_GI_PROBES_PER_INSTANCE = 2, MAX_VOXEL_GI_INSTANCESS_PER_INSTANCE = 2,
INSTANCE_DATA_BUFFER_MIN_SIZE = 4096 INSTANCE_DATA_BUFFER_MIN_SIZE = 4096
}; };
@ -79,7 +79,7 @@ class RenderForwardClustered : public RendererSceneRenderRD {
RID depth; RID depth;
RID specular; RID specular;
RID normal_roughness_buffer; RID normal_roughness_buffer;
RID giprobe_buffer; RID voxelgi_buffer;
RS::ViewportMSAA msaa; RS::ViewportMSAA msaa;
RD::TextureSamples texture_samples; RD::TextureSamples texture_samples;
@ -89,11 +89,11 @@ class RenderForwardClustered : public RendererSceneRenderRD {
RID specular_msaa; RID specular_msaa;
RID normal_roughness_buffer_msaa; RID normal_roughness_buffer_msaa;
RID roughness_buffer_msaa; RID roughness_buffer_msaa;
RID giprobe_buffer_msaa; RID voxelgi_buffer_msaa;
RID depth_fb; RID depth_fb;
RID depth_normal_roughness_fb; RID depth_normal_roughness_fb;
RID depth_normal_roughness_giprobe_fb; RID depth_normal_roughness_voxelgi_fb;
RID color_fb; RID color_fb;
RID color_specular_fb; RID color_specular_fb;
RID specular_only_fb; RID specular_only_fb;
@ -101,7 +101,7 @@ class RenderForwardClustered : public RendererSceneRenderRD {
RID render_sdfgi_uniform_set; RID render_sdfgi_uniform_set;
void ensure_specular(); void ensure_specular();
void ensure_giprobe(); void ensure_voxelgi();
void clear(); void clear();
virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa); virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa);
@ -132,7 +132,7 @@ class RenderForwardClustered : public RendererSceneRenderRD {
PASS_MODE_SHADOW_DP, PASS_MODE_SHADOW_DP,
PASS_MODE_DEPTH, PASS_MODE_DEPTH,
PASS_MODE_DEPTH_NORMAL_ROUGHNESS, PASS_MODE_DEPTH_NORMAL_ROUGHNESS,
PASS_MODE_DEPTH_NORMAL_ROUGHNESS_GIPROBE, PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI,
PASS_MODE_DEPTH_MATERIAL, PASS_MODE_DEPTH_MATERIAL,
PASS_MODE_SDF, PASS_MODE_SDF,
}; };
@ -189,7 +189,7 @@ class RenderForwardClustered : public RendererSceneRenderRD {
INSTANCE_DATA_FLAG_USE_LIGHTMAP_CAPTURE = 1 << 8, INSTANCE_DATA_FLAG_USE_LIGHTMAP_CAPTURE = 1 << 8,
INSTANCE_DATA_FLAG_USE_LIGHTMAP = 1 << 9, INSTANCE_DATA_FLAG_USE_LIGHTMAP = 1 << 9,
INSTANCE_DATA_FLAG_USE_SH_LIGHTMAP = 1 << 10, INSTANCE_DATA_FLAG_USE_SH_LIGHTMAP = 1 << 10,
INSTANCE_DATA_FLAG_USE_GIPROBE = 1 << 11, INSTANCE_DATA_FLAG_USE_VOXEL_GI = 1 << 11,
INSTANCE_DATA_FLAG_MULTIMESH = 1 << 12, INSTANCE_DATA_FLAG_MULTIMESH = 1 << 12,
INSTANCE_DATA_FLAG_MULTIMESH_FORMAT_2D = 1 << 13, INSTANCE_DATA_FLAG_MULTIMESH_FORMAT_2D = 1 << 13,
INSTANCE_DATA_FLAG_MULTIMESH_HAS_COLOR = 1 << 14, INSTANCE_DATA_FLAG_MULTIMESH_HAS_COLOR = 1 << 14,
@ -318,8 +318,8 @@ class RenderForwardClustered : public RendererSceneRenderRD {
uint32_t max_lightmap_captures; uint32_t max_lightmap_captures;
RID lightmap_capture_buffer; RID lightmap_capture_buffer;
RID giprobe_ids[MAX_GI_PROBES]; RID voxelgi_ids[MAX_VOXEL_GI_INSTANCESS];
uint32_t giprobes_used = 0; uint32_t voxelgis_used = 0;
bool used_screen_texture = false; bool used_screen_texture = false;
bool used_normal_texture = false; bool used_normal_texture = false;
@ -350,7 +350,7 @@ class RenderForwardClustered : public RendererSceneRenderRD {
static RenderForwardClustered *singleton; static RenderForwardClustered *singleton;
void _setup_environment(const RenderDataRD *p_render_data, bool p_no_fog, const Size2i &p_screen_size, bool p_flip_y, const Color &p_default_bg_color, bool p_opaque_render_buffers = false, bool p_pancake_shadows = false, int p_index = 0); void _setup_environment(const RenderDataRD *p_render_data, bool p_no_fog, const Size2i &p_screen_size, bool p_flip_y, const Color &p_default_bg_color, bool p_opaque_render_buffers = false, bool p_pancake_shadows = false, int p_index = 0);
void _setup_giprobes(const PagedArray<RID> &p_giprobes); void _setup_voxelgis(const PagedArray<RID> &p_voxelgis);
void _setup_lightmaps(const PagedArray<RID> &p_lightmaps, const Transform3D &p_cam_transform); void _setup_lightmaps(const PagedArray<RID> &p_lightmaps, const Transform3D &p_cam_transform);
struct RenderElementInfo { struct RenderElementInfo {
@ -459,7 +459,7 @@ class RenderForwardClustered : public RendererSceneRenderRD {
//used during setup //used during setup
uint32_t base_flags = 0; uint32_t base_flags = 0;
Transform3D transform; Transform3D transform;
RID gi_probes[MAX_GI_PROBES_PER_INSTANCE]; RID voxel_gi_instances[MAX_VOXEL_GI_INSTANCESS_PER_INSTANCE];
RID lightmap_instance; RID lightmap_instance;
GeometryInstanceLightmapSH *lightmap_sh = nullptr; GeometryInstanceLightmapSH *lightmap_sh = nullptr;
GeometryInstanceSurfaceDataCache *surface_caches = nullptr; GeometryInstanceSurfaceDataCache *surface_caches = nullptr;
@ -603,7 +603,7 @@ public:
virtual void geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count); virtual void geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count);
virtual void geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count); virtual void geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count);
virtual void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count); virtual void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count);
virtual void geometry_instance_pair_gi_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_gi_probe_instances, uint32_t p_gi_probe_instance_count); virtual void geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count);
virtual bool free(RID p_rid); virtual bool free(RID p_rid);

View file

@ -311,7 +311,7 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) {
//none, leave empty //none, leave empty
} else if (k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS) { } else if (k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS) {
blend_state = blend_state_depth_normal_roughness; blend_state = blend_state_depth_normal_roughness;
} else if (k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS_AND_GIPROBE) { } else if (k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS_AND_VOXEL_GI) {
blend_state = blend_state_depth_normal_roughness_giprobe; blend_state = blend_state_depth_normal_roughness_giprobe;
} else if (k == SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL) { } else if (k == SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL) {
blend_state = RD::PipelineColorBlendState::create_disabled(5); //writes to normal and roughness in opaque way blend_state = RD::PipelineColorBlendState::create_disabled(5); //writes to normal and roughness in opaque way
@ -563,7 +563,7 @@ void SceneShaderForwardClustered::init(RendererStorageRD *p_storage, const Strin
shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n"); shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n");
shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_DUAL_PARABOLOID\n"); shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_DUAL_PARABOLOID\n");
shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_RENDER_NORMAL_ROUGHNESS\n"); shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_RENDER_NORMAL_ROUGHNESS\n");
shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_RENDER_NORMAL_ROUGHNESS\n#define MODE_RENDER_GIPROBE\n"); shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_RENDER_NORMAL_ROUGHNESS\n#define MODE_RENDER_VOXEL_GI\n");
shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_RENDER_MATERIAL\n"); shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_RENDER_MATERIAL\n");
shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_RENDER_SDF\n"); shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_RENDER_SDF\n");
shader_versions.push_back(""); shader_versions.push_back("");

View file

@ -48,7 +48,7 @@ public:
SHADER_VERSION_DEPTH_PASS, SHADER_VERSION_DEPTH_PASS,
SHADER_VERSION_DEPTH_PASS_DP, SHADER_VERSION_DEPTH_PASS_DP,
SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS, SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS,
SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS_AND_GIPROBE, SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS_AND_VOXEL_GI,
SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL, SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL,
SHADER_VERSION_DEPTH_PASS_WITH_SDF, SHADER_VERSION_DEPTH_PASS_WITH_SDF,
SHADER_VERSION_COLOR_PASS, SHADER_VERSION_COLOR_PASS,

View file

@ -226,11 +226,11 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
RD::Uniform u; RD::Uniform u;
u.binding = 7; u.binding = 7;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.ids.resize(MAX_GI_PROBES); u.ids.resize(MAX_VOXEL_GI_INSTANCESS);
RID default_tex = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE); RID default_tex = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE);
for (int i = 0; i < MAX_GI_PROBES; i++) { for (int i = 0; i < MAX_VOXEL_GI_INSTANCESS; i++) {
if (i < (int)p_gi_probes.size()) { if (i < (int)p_voxel_gi_instances.size()) {
RID tex = gi.gi_probe_instance_get_texture(p_gi_probes[i]); RID tex = gi.voxel_gi_instance_get_texture(p_voxel_gi_instances[i]);
if (!tex.is_valid()) { if (!tex.is_valid()) {
tex = default_tex; tex = default_tex;
} }
@ -1725,7 +1725,7 @@ void RenderForwardMobile::geometry_instance_pair_decal_instances(GeometryInstanc
} }
} }
void RenderForwardMobile::geometry_instance_pair_gi_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_gi_probe_instances, uint32_t p_gi_probe_instance_count) { void RenderForwardMobile::geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) {
// We do not have this here! // We do not have this here!
} }

View file

@ -104,7 +104,7 @@ protected:
PASS_MODE_SHADOW_DP, PASS_MODE_SHADOW_DP,
// PASS_MODE_DEPTH, // PASS_MODE_DEPTH,
// PASS_MODE_DEPTH_NORMAL_ROUGHNESS, // PASS_MODE_DEPTH_NORMAL_ROUGHNESS,
// PASS_MODE_DEPTH_NORMAL_ROUGHNESS_GIPROBE, // PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI,
PASS_MODE_DEPTH_MATERIAL, PASS_MODE_DEPTH_MATERIAL,
// PASS_MODE_SDF, // PASS_MODE_SDF,
}; };
@ -390,7 +390,7 @@ protected:
INSTANCE_DATA_FLAG_USE_LIGHTMAP_CAPTURE = 1 << 8, INSTANCE_DATA_FLAG_USE_LIGHTMAP_CAPTURE = 1 << 8,
INSTANCE_DATA_FLAG_USE_LIGHTMAP = 1 << 9, INSTANCE_DATA_FLAG_USE_LIGHTMAP = 1 << 9,
INSTANCE_DATA_FLAG_USE_SH_LIGHTMAP = 1 << 10, INSTANCE_DATA_FLAG_USE_SH_LIGHTMAP = 1 << 10,
INSTANCE_DATA_FLAG_USE_GIPROBE = 1 << 11, INSTANCE_DATA_FLAG_USE_VOXEL_GI = 1 << 11,
INSTANCE_DATA_FLAG_MULTIMESH = 1 << 12, INSTANCE_DATA_FLAG_MULTIMESH = 1 << 12,
INSTANCE_DATA_FLAG_MULTIMESH_FORMAT_2D = 1 << 13, INSTANCE_DATA_FLAG_MULTIMESH_FORMAT_2D = 1 << 13,
INSTANCE_DATA_FLAG_MULTIMESH_HAS_COLOR = 1 << 14, INSTANCE_DATA_FLAG_MULTIMESH_HAS_COLOR = 1 << 14,
@ -587,7 +587,7 @@ public:
virtual void geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count); virtual void geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count);
virtual void geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count); virtual void geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count);
virtual void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count); virtual void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count);
virtual void geometry_instance_pair_gi_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_gi_probe_instances, uint32_t p_gi_probe_instance_count); virtual void geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count);
virtual bool free(RID p_rid); virtual bool free(RID p_rid);

View file

@ -342,7 +342,7 @@ void SceneShaderForwardMobile::ShaderData::set_code(const String &p_code) {
//none, leave empty //none, leave empty
} else if (k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS) { } else if (k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS) {
blend_state = blend_state_depth_normal_roughness; blend_state = blend_state_depth_normal_roughness;
} else if (k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS_AND_GIPROBE) { } else if (k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS_AND_VOXEL_GI) {
blend_state = blend_state_depth_normal_roughness_giprobe; blend_state = blend_state_depth_normal_roughness_giprobe;
} else if (k == SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL) { } else if (k == SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL) {
blend_state = RD::PipelineColorBlendState::create_disabled(5); //writes to normal and roughness in opaque way blend_state = RD::PipelineColorBlendState::create_disabled(5); //writes to normal and roughness in opaque way

View file

@ -2012,10 +2012,10 @@ void RendererSceneGIRD::SDFGI::render_static_lights(RID p_render_buffers, uint32
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// GIProbeInstance // VoxelGIInstance
void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects, RendererSceneRenderRD *p_scene_render) { void RendererSceneGIRD::VoxelGIInstance::update(bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects, RendererSceneRenderRD *p_scene_render) {
uint32_t data_version = storage->gi_probe_get_data_version(probe); uint32_t data_version = storage->voxel_gi_get_data_version(probe);
// (RE)CREATE IF NEEDED // (RE)CREATE IF NEEDED
@ -2034,11 +2034,11 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
dynamic_maps.clear(); dynamic_maps.clear();
Vector3i octree_size = storage->gi_probe_get_octree_size(probe); Vector3i octree_size = storage->voxel_gi_get_octree_size(probe);
if (octree_size != Vector3i()) { if (octree_size != Vector3i()) {
//can create a 3D texture //can create a 3D texture
Vector<int> levels = storage->gi_probe_get_level_counts(probe); Vector<int> levels = storage->voxel_gi_get_level_counts(probe);
RD::TextureFormat tf; RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; tf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
@ -2064,7 +2064,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
} }
for (int i = 0; i < levels.size(); i++) { for (int i = 0; i < levels.size(); i++) {
GIProbeInstance::Mipmap mipmap; VoxelGIInstance::Mipmap mipmap;
mipmap.texture = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), texture, 0, i, RD::TEXTURE_SLICE_3D); mipmap.texture = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), texture, 0, i, RD::TEXTURE_SLICE_3D);
mipmap.level = levels.size() - i - 1; mipmap.level = levels.size() - i - 1;
mipmap.cell_offset = 0; mipmap.cell_offset = 0;
@ -2078,14 +2078,14 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER;
u.binding = 1; u.binding = 1;
u.ids.push_back(storage->gi_probe_get_octree_buffer(probe)); u.ids.push_back(storage->voxel_gi_get_octree_buffer(probe));
uniforms.push_back(u); uniforms.push_back(u);
} }
{ {
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER;
u.binding = 2; u.binding = 2;
u.ids.push_back(storage->gi_probe_get_data_buffer(probe)); u.ids.push_back(storage->voxel_gi_get_data_buffer(probe));
uniforms.push_back(u); uniforms.push_back(u);
} }
@ -2100,7 +2100,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 9; u.binding = 9;
u.ids.push_back(storage->gi_probe_get_sdf_texture(probe)); u.ids.push_back(storage->voxel_gi_get_sdf_texture(probe));
uniforms.push_back(u); uniforms.push_back(u);
} }
{ {
@ -2118,11 +2118,11 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER;
u.binding = 3; u.binding = 3;
u.ids.push_back(gi->gi_probe_lights_uniform); u.ids.push_back(gi->voxel_gi_lights_uniform);
copy_uniforms.push_back(u); copy_uniforms.push_back(u);
} }
mipmap.uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, gi->giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_COMPUTE_LIGHT], 0); mipmap.uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, gi->voxel_gi_lighting_shader_version_shaders[VOXEL_GI_SHADER_VERSION_COMPUTE_LIGHT], 0);
copy_uniforms = uniforms; //restore copy_uniforms = uniforms; //restore
@ -2133,9 +2133,9 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
u.ids.push_back(texture); u.ids.push_back(texture);
copy_uniforms.push_back(u); copy_uniforms.push_back(u);
} }
mipmap.second_bounce_uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, gi->giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_COMPUTE_SECOND_BOUNCE], 0); mipmap.second_bounce_uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, gi->voxel_gi_lighting_shader_version_shaders[VOXEL_GI_SHADER_VERSION_COMPUTE_SECOND_BOUNCE], 0);
} else { } else {
mipmap.uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, gi->giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_COMPUTE_MIPMAP], 0); mipmap.uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, gi->voxel_gi_lighting_shader_version_shaders[VOXEL_GI_SHADER_VERSION_COMPUTE_MIPMAP], 0);
} }
} }
@ -2147,7 +2147,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
uniforms.push_back(u); uniforms.push_back(u);
} }
mipmap.write_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_WRITE_TEXTURE], 0); mipmap.write_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->voxel_gi_lighting_shader_version_shaders[VOXEL_GI_SHADER_VERSION_WRITE_TEXTURE], 0);
mipmaps.push_back(mipmap); mipmaps.push_back(mipmap);
} }
@ -2158,7 +2158,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
int mipmap_index = 0; int mipmap_index = 0;
while (mipmap_index < mipmaps.size()) { while (mipmap_index < mipmaps.size()) {
GIProbeInstance::DynamicMap dmap; VoxelGIInstance::DynamicMap dmap;
if (oversample > 0) { if (oversample > 0) {
dmap.size = dynamic_map_size * (1 << oversample); dmap.size = dynamic_map_size * (1 << oversample);
@ -2217,7 +2217,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER;
u.binding = 3; u.binding = 3;
u.ids.push_back(gi->gi_probe_lights_uniform); u.ids.push_back(gi->voxel_gi_lights_uniform);
uniforms.push_back(u); uniforms.push_back(u);
} }
@ -2253,7 +2253,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 9; u.binding = 9;
u.ids.push_back(storage->gi_probe_get_sdf_texture(probe)); u.ids.push_back(storage->voxel_gi_get_sdf_texture(probe));
uniforms.push_back(u); uniforms.push_back(u);
} }
{ {
@ -2278,7 +2278,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
uniforms.push_back(u); uniforms.push_back(u);
} }
dmap.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING], 0); dmap.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->voxel_gi_lighting_shader_version_shaders[VOXEL_GI_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING], 0);
} }
} else { } else {
bool plot = dmap.mipmap >= 0; bool plot = dmap.mipmap >= 0;
@ -2322,7 +2322,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 9; u.binding = 9;
u.ids.push_back(storage->gi_probe_get_sdf_texture(probe)); u.ids.push_back(storage->voxel_gi_get_sdf_texture(probe));
uniforms.push_back(u); uniforms.push_back(u);
} }
{ {
@ -2345,7 +2345,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
dmap.uniform_set = RD::get_singleton()->uniform_set_create( dmap.uniform_set = RD::get_singleton()->uniform_set_create(
uniforms, uniforms,
gi->giprobe_lighting_shader_version_shaders[(write && plot) ? GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT : (write ? GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE : GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT)], gi->voxel_gi_lighting_shader_version_shaders[(write && plot) ? VOXEL_GI_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT : (write ? VOXEL_GI_SHADER_VERSION_DYNAMIC_SHRINK_WRITE : VOXEL_GI_SHADER_VERSION_DYNAMIC_SHRINK_PLOT)],
0); 0);
} }
@ -2370,15 +2370,15 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
uint32_t light_count = 0; uint32_t light_count = 0;
if (p_update_light_instances || p_dynamic_objects.size() > 0) { if (p_update_light_instances || p_dynamic_objects.size() > 0) {
light_count = MIN(gi->gi_probe_max_lights, (uint32_t)p_light_instances.size()); light_count = MIN(gi->voxel_gi_max_lights, (uint32_t)p_light_instances.size());
{ {
Transform3D to_cell = storage->gi_probe_get_to_cell_xform(probe); Transform3D to_cell = storage->voxel_gi_get_to_cell_xform(probe);
Transform3D to_probe_xform = (transform * to_cell.affine_inverse()).affine_inverse(); Transform3D to_probe_xform = (transform * to_cell.affine_inverse()).affine_inverse();
//update lights //update lights
for (uint32_t i = 0; i < light_count; i++) { for (uint32_t i = 0; i < light_count; i++) {
GIProbeLight &l = gi->gi_probe_lights[i]; VoxelGILight &l = gi->voxel_gi_lights[i];
RID light_instance = p_light_instances[i]; RID light_instance = p_light_instances[i];
RID light = p_scene_render->light_instance_get_base_light(light_instance); RID light = p_scene_render->light_instance_get_base_light(light_instance);
@ -2415,7 +2415,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
l.has_shadow = storage->light_has_shadow(light); l.has_shadow = storage->light_has_shadow(light);
} }
RD::get_singleton()->buffer_update(gi->gi_probe_lights_uniform, 0, sizeof(GIProbeLight) * light_count, gi->gi_probe_lights); RD::get_singleton()->buffer_update(gi->voxel_gi_lights_uniform, 0, sizeof(VoxelGILight) * light_count, gi->voxel_gi_lights);
} }
} }
@ -2424,17 +2424,17 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
if (mipmaps.size()) { if (mipmaps.size()) {
//can update mipmaps //can update mipmaps
Vector3i probe_size = storage->gi_probe_get_octree_size(probe); Vector3i probe_size = storage->voxel_gi_get_octree_size(probe);
GIProbePushConstant push_constant; VoxelGIPushConstant push_constant;
push_constant.limits[0] = probe_size.x; push_constant.limits[0] = probe_size.x;
push_constant.limits[1] = probe_size.y; push_constant.limits[1] = probe_size.y;
push_constant.limits[2] = probe_size.z; push_constant.limits[2] = probe_size.z;
push_constant.stack_size = mipmaps.size(); push_constant.stack_size = mipmaps.size();
push_constant.emission_scale = 1.0; push_constant.emission_scale = 1.0;
push_constant.propagation = storage->gi_probe_get_propagation(probe); push_constant.propagation = storage->voxel_gi_get_propagation(probe);
push_constant.dynamic_range = storage->gi_probe_get_dynamic_range(probe); push_constant.dynamic_range = storage->voxel_gi_get_dynamic_range(probe);
push_constant.light_count = light_count; push_constant.light_count = light_count;
push_constant.aniso_strength = 0; push_constant.aniso_strength = 0;
@ -2446,7 +2446,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
int passes; int passes;
if (p_update_light_instances) { if (p_update_light_instances) {
passes = storage->gi_probe_is_using_two_bounces(probe) ? 2 : 1; passes = storage->voxel_gi_is_using_two_bounces(probe) ? 2 : 1;
} else { } else {
passes = 1; //only re-blitting is necessary passes = 1; //only re-blitting is necessary
} }
@ -2457,9 +2457,9 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
if (p_update_light_instances) { if (p_update_light_instances) {
for (int i = 0; i < mipmaps.size(); i++) { for (int i = 0; i < mipmaps.size(); i++) {
if (i == 0) { if (i == 0) {
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[pass == 0 ? GI_PROBE_SHADER_VERSION_COMPUTE_LIGHT : GI_PROBE_SHADER_VERSION_COMPUTE_SECOND_BOUNCE]); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->voxel_gi_lighting_shader_version_pipelines[pass == 0 ? VOXEL_GI_SHADER_VERSION_COMPUTE_LIGHT : VOXEL_GI_SHADER_VERSION_COMPUTE_SECOND_BOUNCE]);
} else if (i == 1) { } else if (i == 1) {
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_COMPUTE_MIPMAP]); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->voxel_gi_lighting_shader_version_pipelines[VOXEL_GI_SHADER_VERSION_COMPUTE_MIPMAP]);
} }
if (pass == 1 || i > 0) { if (pass == 1 || i > 0) {
@ -2477,7 +2477,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
int wg_todo = (mipmaps[i].cell_count - 1) / wg_size + 1; int wg_todo = (mipmaps[i].cell_count - 1) / wg_size + 1;
while (wg_todo) { while (wg_todo) {
int wg_count = MIN(wg_todo, wg_limit_x); int wg_count = MIN(wg_todo, wg_limit_x);
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbePushConstant)); RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(VoxelGIPushConstant));
RD::get_singleton()->compute_list_dispatch(compute_list, wg_count, 1, 1); RD::get_singleton()->compute_list_dispatch(compute_list, wg_count, 1, 1);
wg_todo -= wg_count; wg_todo -= wg_count;
push_constant.cell_offset += wg_count * wg_size; push_constant.cell_offset += wg_count * wg_size;
@ -2487,7 +2487,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
RD::get_singleton()->compute_list_add_barrier(compute_list); //wait til previous step is done RD::get_singleton()->compute_list_add_barrier(compute_list); //wait til previous step is done
} }
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_WRITE_TEXTURE]); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->voxel_gi_lighting_shader_version_pipelines[VOXEL_GI_SHADER_VERSION_WRITE_TEXTURE]);
for (int i = 0; i < mipmaps.size(); i++) { for (int i = 0; i < mipmaps.size(); i++) {
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, mipmaps[i].write_uniform_set, 0); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, mipmaps[i].write_uniform_set, 0);
@ -2498,7 +2498,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
int wg_todo = (mipmaps[i].cell_count - 1) / wg_size + 1; int wg_todo = (mipmaps[i].cell_count - 1) / wg_size + 1;
while (wg_todo) { while (wg_todo) {
int wg_count = MIN(wg_todo, wg_limit_x); int wg_count = MIN(wg_todo, wg_limit_x);
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbePushConstant)); RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(VoxelGIPushConstant));
RD::get_singleton()->compute_list_dispatch(compute_list, wg_count, 1, 1); RD::get_singleton()->compute_list_dispatch(compute_list, wg_count, 1, 1);
wg_todo -= wg_count; wg_todo -= wg_count;
push_constant.cell_offset += wg_count * wg_size; push_constant.cell_offset += wg_count * wg_size;
@ -2513,13 +2513,13 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
has_dynamic_object_data = false; //clear until dynamic object data is used again has_dynamic_object_data = false; //clear until dynamic object data is used again
if (p_dynamic_objects.size() && dynamic_maps.size()) { if (p_dynamic_objects.size() && dynamic_maps.size()) {
Vector3i octree_size = storage->gi_probe_get_octree_size(probe); Vector3i octree_size = storage->voxel_gi_get_octree_size(probe);
int multiplier = dynamic_maps[0].size / MAX(MAX(octree_size.x, octree_size.y), octree_size.z); int multiplier = dynamic_maps[0].size / MAX(MAX(octree_size.x, octree_size.y), octree_size.z);
Transform3D oversample_scale; Transform3D oversample_scale;
oversample_scale.basis.scale(Vector3(multiplier, multiplier, multiplier)); oversample_scale.basis.scale(Vector3(multiplier, multiplier, multiplier));
Transform3D to_cell = oversample_scale * storage->gi_probe_get_to_cell_xform(probe); Transform3D to_cell = oversample_scale * storage->voxel_gi_get_to_cell_xform(probe);
Transform3D to_world_xform = transform * to_cell.affine_inverse(); Transform3D to_world_xform = transform * to_cell.affine_inverse();
Transform3D to_probe_xform = to_world_xform.affine_inverse(); Transform3D to_probe_xform = to_world_xform.affine_inverse();
@ -2529,7 +2529,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
for (int i = 0; i < (int)p_dynamic_objects.size(); i++) { for (int i = 0; i < (int)p_dynamic_objects.size(); i++) {
RendererSceneRender::GeometryInstance *instance = p_dynamic_objects[i]; RendererSceneRender::GeometryInstance *instance = p_dynamic_objects[i];
//transform aabb to giprobe //transform aabb to voxel_gi
AABB aabb = (to_probe_xform * p_scene_render->geometry_instance_get_transform(instance)).xform(p_scene_render->geometry_instance_get_aabb(instance)); AABB aabb = (to_probe_xform * p_scene_render->geometry_instance_get_transform(instance)).xform(p_scene_render->geometry_instance_get_aabb(instance));
//this needs to wrap to grid resolution to avoid jitter //this needs to wrap to grid resolution to avoid jitter
@ -2601,8 +2601,8 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
p_scene_render->_render_material(to_world_xform * xform, cm, true, p_scene_render->cull_argument, dynamic_maps[0].fb, Rect2i(Vector2i(), rect.size)); p_scene_render->_render_material(to_world_xform * xform, cm, true, p_scene_render->cull_argument, dynamic_maps[0].fb, Rect2i(Vector2i(), rect.size));
GIProbeDynamicPushConstant push_constant; VoxelGIDynamicPushConstant push_constant;
memset(&push_constant, 0, sizeof(GIProbeDynamicPushConstant)); memset(&push_constant, 0, sizeof(VoxelGIDynamicPushConstant));
push_constant.limits[0] = octree_size.x; push_constant.limits[0] = octree_size.x;
push_constant.limits[1] = octree_size.y; push_constant.limits[1] = octree_size.y;
push_constant.limits[2] = octree_size.z; push_constant.limits[2] = octree_size.z;
@ -2619,7 +2619,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
push_constant.z_base = xform.origin[z_axis]; push_constant.z_base = xform.origin[z_axis];
push_constant.z_sign = (z_flip ? -1.0 : 1.0); push_constant.z_sign = (z_flip ? -1.0 : 1.0);
push_constant.pos_multiplier = float(1.0) / multiplier; push_constant.pos_multiplier = float(1.0) / multiplier;
push_constant.dynamic_range = storage->gi_probe_get_dynamic_range(probe); push_constant.dynamic_range = storage->voxel_gi_get_dynamic_range(probe);
push_constant.flip_x = x_flip; push_constant.flip_x = x_flip;
push_constant.flip_y = y_flip; push_constant.flip_y = y_flip;
push_constant.rect_pos[0] = rect.position[0]; push_constant.rect_pos[0] = rect.position[0];
@ -2631,16 +2631,16 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
push_constant.prev_rect_size[0] = 0; push_constant.prev_rect_size[0] = 0;
push_constant.prev_rect_size[1] = 0; push_constant.prev_rect_size[1] = 0;
push_constant.on_mipmap = false; push_constant.on_mipmap = false;
push_constant.propagation = storage->gi_probe_get_propagation(probe); push_constant.propagation = storage->voxel_gi_get_propagation(probe);
push_constant.pad[0] = 0; push_constant.pad[0] = 0;
push_constant.pad[1] = 0; push_constant.pad[1] = 0;
push_constant.pad[2] = 0; push_constant.pad[2] = 0;
//process lighting //process lighting
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING]); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->voxel_gi_lighting_shader_version_pipelines[VOXEL_GI_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING]);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, dynamic_maps[0].uniform_set, 0); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, dynamic_maps[0].uniform_set, 0);
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbeDynamicPushConstant)); RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(VoxelGIDynamicPushConstant));
RD::get_singleton()->compute_list_dispatch(compute_list, (rect.size.x - 1) / 8 + 1, (rect.size.y - 1) / 8 + 1, 1); RD::get_singleton()->compute_list_dispatch(compute_list, (rect.size.x - 1) / 8 + 1, (rect.size.y - 1) / 8 + 1, 1);
//print_line("rect: " + itos(i) + ": " + rect); //print_line("rect: " + itos(i) + ": " + rect);
@ -2695,14 +2695,14 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
RD::get_singleton()->compute_list_add_barrier(compute_list); RD::get_singleton()->compute_list_add_barrier(compute_list);
if (dynamic_maps[k].mipmap < 0) { if (dynamic_maps[k].mipmap < 0) {
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE]); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->voxel_gi_lighting_shader_version_pipelines[VOXEL_GI_SHADER_VERSION_DYNAMIC_SHRINK_WRITE]);
} else if (k < dynamic_maps.size() - 1) { } else if (k < dynamic_maps.size() - 1) {
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT]); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->voxel_gi_lighting_shader_version_pipelines[VOXEL_GI_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT]);
} else { } else {
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT]); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->voxel_gi_lighting_shader_version_pipelines[VOXEL_GI_SHADER_VERSION_DYNAMIC_SHRINK_PLOT]);
} }
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, dynamic_maps[k].uniform_set, 0); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, dynamic_maps[k].uniform_set, 0);
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbeDynamicPushConstant)); RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(VoxelGIDynamicPushConstant));
RD::get_singleton()->compute_list_dispatch(compute_list, (rect.size.x - 1) / 8 + 1, (rect.size.y - 1) / 8 + 1, 1); RD::get_singleton()->compute_list_dispatch(compute_list, (rect.size.x - 1) / 8 + 1, (rect.size.y - 1) / 8 + 1, 1);
} }
@ -2713,22 +2713,22 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c
has_dynamic_object_data = true; //clear until dynamic object data is used again has_dynamic_object_data = true; //clear until dynamic object data is used again
} }
last_probe_version = storage->gi_probe_get_version(probe); last_probe_version = storage->voxel_gi_get_version(probe);
} }
void RendererSceneGIRD::GIProbeInstance::debug(RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) { void RendererSceneGIRD::VoxelGIInstance::debug(RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) {
if (mipmaps.size() == 0) { if (mipmaps.size() == 0) {
return; return;
} }
CameraMatrix cam_transform = (p_camera_with_transform * CameraMatrix(transform)) * CameraMatrix(storage->gi_probe_get_to_cell_xform(probe).affine_inverse()); CameraMatrix cam_transform = (p_camera_with_transform * CameraMatrix(transform)) * CameraMatrix(storage->voxel_gi_get_to_cell_xform(probe).affine_inverse());
int level = 0; int level = 0;
Vector3i octree_size = storage->gi_probe_get_octree_size(probe); Vector3i octree_size = storage->voxel_gi_get_octree_size(probe);
GIProbeDebugPushConstant push_constant; VoxelGIDebugPushConstant push_constant;
push_constant.alpha = p_alpha; push_constant.alpha = p_alpha;
push_constant.dynamic_range = storage->gi_probe_get_dynamic_range(probe); push_constant.dynamic_range = storage->voxel_gi_get_dynamic_range(probe);
push_constant.cell_offset = mipmaps[level].cell_offset; push_constant.cell_offset = mipmaps[level].cell_offset;
push_constant.level = level; push_constant.level = level;
@ -2743,15 +2743,15 @@ void RendererSceneGIRD::GIProbeInstance::debug(RD::DrawListID p_draw_list, RID p
} }
} }
if (gi->giprobe_debug_uniform_set.is_valid()) { if (gi->voxel_gi_debug_uniform_set.is_valid()) {
RD::get_singleton()->free(gi->giprobe_debug_uniform_set); RD::get_singleton()->free(gi->voxel_gi_debug_uniform_set);
} }
Vector<RD::Uniform> uniforms; Vector<RD::Uniform> uniforms;
{ {
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER;
u.binding = 1; u.binding = 1;
u.ids.push_back(storage->gi_probe_get_data_buffer(probe)); u.ids.push_back(storage->voxel_gi_get_data_buffer(probe));
uniforms.push_back(u); uniforms.push_back(u);
} }
{ {
@ -2776,19 +2776,19 @@ void RendererSceneGIRD::GIProbeInstance::debug(RD::DrawListID p_draw_list, RID p
cell_count = mipmaps[level].cell_count; cell_count = mipmaps[level].cell_count;
} }
gi->giprobe_debug_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->giprobe_debug_shader_version_shaders[0], 0); gi->voxel_gi_debug_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->voxel_gi_debug_shader_version_shaders[0], 0);
int giprobe_debug_pipeline = GI_PROBE_DEBUG_COLOR; int voxel_gi_debug_pipeline = VOXEL_GI_DEBUG_COLOR;
if (p_emission) { if (p_emission) {
giprobe_debug_pipeline = GI_PROBE_DEBUG_EMISSION; voxel_gi_debug_pipeline = VOXEL_GI_DEBUG_EMISSION;
} else if (p_lighting) { } else if (p_lighting) {
giprobe_debug_pipeline = has_dynamic_object_data ? GI_PROBE_DEBUG_LIGHT_FULL : GI_PROBE_DEBUG_LIGHT; voxel_gi_debug_pipeline = has_dynamic_object_data ? VOXEL_GI_DEBUG_LIGHT_FULL : VOXEL_GI_DEBUG_LIGHT;
} }
RD::get_singleton()->draw_list_bind_render_pipeline( RD::get_singleton()->draw_list_bind_render_pipeline(
p_draw_list, p_draw_list,
gi->giprobe_debug_shader_version_pipelines[giprobe_debug_pipeline].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer))); gi->voxel_gi_debug_shader_version_pipelines[voxel_gi_debug_pipeline].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer)));
RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, gi->giprobe_debug_uniform_set, 0); RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, gi->voxel_gi_debug_uniform_set, 0);
RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(GIProbeDebugPushConstant)); RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(VoxelGIDebugPushConstant));
RD::get_singleton()->draw_list_draw(p_draw_list, false, cell_count, 36); RD::get_singleton()->draw_list_draw(p_draw_list, false, cell_count, 36);
} }
@ -2812,13 +2812,13 @@ void RendererSceneGIRD::init(RendererStorageRD *p_storage, RendererSceneSkyRD *p
{ {
//kinda complicated to compute the amount of slots, we try to use as many as we can //kinda complicated to compute the amount of slots, we try to use as many as we can
gi_probe_max_lights = 32; voxel_gi_max_lights = 32;
gi_probe_lights = memnew_arr(GIProbeLight, gi_probe_max_lights); voxel_gi_lights = memnew_arr(VoxelGILight, voxel_gi_max_lights);
gi_probe_lights_uniform = RD::get_singleton()->uniform_buffer_create(gi_probe_max_lights * sizeof(GIProbeLight)); voxel_gi_lights_uniform = RD::get_singleton()->uniform_buffer_create(voxel_gi_max_lights * sizeof(VoxelGILight));
gi_probe_quality = RS::GIProbeQuality(CLAMP(int(GLOBAL_GET("rendering/global_illumination/gi_probes/quality")), 0, 1)); voxel_gi_quality = RS::VoxelGIQuality(CLAMP(int(GLOBAL_GET("rendering/global_illumination/voxel_gi/quality")), 0, 1));
String defines = "\n#define MAX_LIGHTS " + itos(gi_probe_max_lights) + "\n"; String defines = "\n#define MAX_LIGHTS " + itos(voxel_gi_max_lights) + "\n";
Vector<String> versions; Vector<String> versions;
versions.push_back("\n#define MODE_COMPUTE_LIGHT\n"); versions.push_back("\n#define MODE_COMPUTE_LIGHT\n");
@ -2830,11 +2830,11 @@ void RendererSceneGIRD::init(RendererStorageRD *p_storage, RendererSceneSkyRD *p
versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_SHRINK\n#define MODE_DYNAMIC_SHRINK_PLOT\n"); versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_SHRINK\n#define MODE_DYNAMIC_SHRINK_PLOT\n");
versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_SHRINK\n#define MODE_DYNAMIC_SHRINK_PLOT\n#define MODE_DYNAMIC_SHRINK_WRITE\n"); versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_SHRINK\n#define MODE_DYNAMIC_SHRINK_PLOT\n#define MODE_DYNAMIC_SHRINK_WRITE\n");
giprobe_shader.initialize(versions, defines); voxel_gi_shader.initialize(versions, defines);
giprobe_lighting_shader_version = giprobe_shader.version_create(); voxel_gi_lighting_shader_version = voxel_gi_shader.version_create();
for (int i = 0; i < GI_PROBE_SHADER_VERSION_MAX; i++) { for (int i = 0; i < VOXEL_GI_SHADER_VERSION_MAX; i++) {
giprobe_lighting_shader_version_shaders[i] = giprobe_shader.version_get_shader(giprobe_lighting_shader_version, i); voxel_gi_lighting_shader_version_shaders[i] = voxel_gi_shader.version_get_shader(voxel_gi_lighting_shader_version, i);
giprobe_lighting_shader_version_pipelines[i] = RD::get_singleton()->compute_pipeline_create(giprobe_lighting_shader_version_shaders[i]); voxel_gi_lighting_shader_version_pipelines[i] = RD::get_singleton()->compute_pipeline_create(voxel_gi_lighting_shader_version_shaders[i]);
} }
} }
@ -2846,10 +2846,10 @@ void RendererSceneGIRD::init(RendererStorageRD *p_storage, RendererSceneSkyRD *p
versions.push_back("\n#define MODE_DEBUG_EMISSION\n"); versions.push_back("\n#define MODE_DEBUG_EMISSION\n");
versions.push_back("\n#define MODE_DEBUG_LIGHT\n#define MODE_DEBUG_LIGHT_FULL\n"); versions.push_back("\n#define MODE_DEBUG_LIGHT\n#define MODE_DEBUG_LIGHT_FULL\n");
giprobe_debug_shader.initialize(versions, defines); voxel_gi_debug_shader.initialize(versions, defines);
giprobe_debug_shader_version = giprobe_debug_shader.version_create(); voxel_gi_debug_shader_version = voxel_gi_debug_shader.version_create();
for (int i = 0; i < GI_PROBE_DEBUG_MAX; i++) { for (int i = 0; i < VOXEL_GI_DEBUG_MAX; i++) {
giprobe_debug_shader_version_shaders[i] = giprobe_debug_shader.version_get_shader(giprobe_debug_shader_version, i); voxel_gi_debug_shader_version_shaders[i] = voxel_gi_debug_shader.version_get_shader(voxel_gi_debug_shader_version, i);
RD::PipelineRasterizationState rs; RD::PipelineRasterizationState rs;
rs.cull_mode = RD::POLYGON_CULL_FRONT; rs.cull_mode = RD::POLYGON_CULL_FRONT;
@ -2858,7 +2858,7 @@ void RendererSceneGIRD::init(RendererStorageRD *p_storage, RendererSceneSkyRD *p
ds.enable_depth_write = true; ds.enable_depth_write = true;
ds.depth_compare_operator = RD::COMPARE_OP_LESS_OR_EQUAL; ds.depth_compare_operator = RD::COMPARE_OP_LESS_OR_EQUAL;
giprobe_debug_shader_version_pipelines[i].setup(giprobe_debug_shader_version_shaders[i], RD::RENDER_PRIMITIVE_TRIANGLES, rs, RD::PipelineMultisampleState(), ds, RD::PipelineColorBlendState::create_disabled(), 0); voxel_gi_debug_shader_version_pipelines[i].setup(voxel_gi_debug_shader_version_shaders[i], RD::RENDER_PRIMITIVE_TRIANGLES, rs, RD::PipelineMultisampleState(), ds, RD::PipelineColorBlendState::create_disabled(), 0);
} }
} }
@ -2944,12 +2944,12 @@ void RendererSceneGIRD::init(RendererStorageRD *p_storage, RendererSceneSkyRD *p
//calculate tables //calculate tables
String defines = "\n#define SDFGI_OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; String defines = "\n#define SDFGI_OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n";
Vector<String> gi_modes; Vector<String> gi_modes;
gi_modes.push_back("\n#define USE_GIPROBES\n"); gi_modes.push_back("\n#define USE_VOXEL_GI_INSTANCES\n");
gi_modes.push_back("\n#define USE_SDFGI\n"); gi_modes.push_back("\n#define USE_SDFGI\n");
gi_modes.push_back("\n#define USE_SDFGI\n\n#define USE_GIPROBES\n"); gi_modes.push_back("\n#define USE_SDFGI\n\n#define USE_VOXEL_GI_INSTANCES\n");
gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_GIPROBES\n"); gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_VOXEL_GI_INSTANCES\n");
gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_SDFGI\n"); gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_SDFGI\n");
gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_SDFGI\n\n#define USE_GIPROBES\n"); gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_SDFGI\n\n#define USE_VOXEL_GI_INSTANCES\n");
shader.initialize(gi_modes, defines); shader.initialize(gi_modes, defines);
shader_version = shader.version_create(); shader_version = shader.version_create();
@ -2991,17 +2991,17 @@ void RendererSceneGIRD::init(RendererStorageRD *p_storage, RendererSceneSkyRD *p
} }
} }
} }
default_giprobe_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(GIProbeData) * MAX_GIPROBES); default_voxel_gi_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(VoxelGIData) * MAX_VOXEL_GI_INSTANCES);
half_resolution = GLOBAL_GET("rendering/global_illumination/gi/use_half_resolution"); half_resolution = GLOBAL_GET("rendering/global_illumination/gi/use_half_resolution");
} }
void RendererSceneGIRD::free() { void RendererSceneGIRD::free() {
RD::get_singleton()->free(default_giprobe_buffer); RD::get_singleton()->free(default_voxel_gi_buffer);
RD::get_singleton()->free(gi_probe_lights_uniform); RD::get_singleton()->free(voxel_gi_lights_uniform);
RD::get_singleton()->free(sdfgi_ubo); RD::get_singleton()->free(sdfgi_ubo);
giprobe_debug_shader.version_free(giprobe_debug_shader_version); voxel_gi_debug_shader.version_free(voxel_gi_debug_shader_version);
giprobe_shader.version_free(giprobe_lighting_shader_version); voxel_gi_shader.version_free(voxel_gi_lighting_shader_version);
shader.version_free(shader_version); shader.version_free(shader_version);
sdfgi_shader.debug_probes.version_free(sdfgi_shader.debug_probes_shader); sdfgi_shader.debug_probes.version_free(sdfgi_shader.debug_probes_shader);
sdfgi_shader.debug.version_free(sdfgi_shader.debug_shader); sdfgi_shader.debug.version_free(sdfgi_shader.debug_shader);
@ -3009,7 +3009,7 @@ void RendererSceneGIRD::free() {
sdfgi_shader.integrate.version_free(sdfgi_shader.integrate_shader); sdfgi_shader.integrate.version_free(sdfgi_shader.integrate_shader);
sdfgi_shader.preprocess.version_free(sdfgi_shader.preprocess_shader); sdfgi_shader.preprocess.version_free(sdfgi_shader.preprocess_shader);
memdelete_arr(gi_probe_lights); memdelete_arr(voxel_gi_lights);
} }
RendererSceneGIRD::SDFGI *RendererSceneGIRD::create_sdfgi(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world_position, uint32_t p_requested_history_size) { RendererSceneGIRD::SDFGI *RendererSceneGIRD::create_sdfgi(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world_position, uint32_t p_requested_history_size) {
@ -3020,36 +3020,36 @@ RendererSceneGIRD::SDFGI *RendererSceneGIRD::create_sdfgi(RendererSceneEnvironme
return sdfgi; return sdfgi;
} }
void RendererSceneGIRD::setup_giprobes(RID p_render_buffers, const Transform3D &p_transform, const PagedArray<RID> &p_gi_probes, uint32_t &r_gi_probes_used, RendererSceneRenderRD *p_scene_render) { void RendererSceneGIRD::setup_voxel_gi_instances(RID p_render_buffers, const Transform3D &p_transform, const PagedArray<RID> &p_voxel_gi_instances, uint32_t &r_voxel_gi_instances_used, RendererSceneRenderRD *p_scene_render) {
r_gi_probes_used = 0; r_voxel_gi_instances_used = 0;
// feels a little dirty to use our container this way but.... // feels a little dirty to use our container this way but....
RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers); RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND(rb == nullptr); ERR_FAIL_COND(rb == nullptr);
RID gi_probe_buffer = p_scene_render->render_buffers_get_gi_probe_buffer(p_render_buffers); RID voxel_gi_buffer = p_scene_render->render_buffers_get_voxel_gi_buffer(p_render_buffers);
RD::get_singleton()->draw_command_begin_label("GIProbes Setup"); RD::get_singleton()->draw_command_begin_label("VoxelGIs Setup");
GIProbeData gi_probe_data[MAX_GIPROBES]; VoxelGIData voxel_gi_data[MAX_VOXEL_GI_INSTANCES];
bool giprobes_changed = false; bool voxel_gi_instances_changed = false;
Transform3D to_camera; Transform3D to_camera;
to_camera.origin = p_transform.origin; //only translation, make local to_camera.origin = p_transform.origin; //only translation, make local
for (int i = 0; i < MAX_GIPROBES; i++) { for (int i = 0; i < MAX_VOXEL_GI_INSTANCES; i++) {
RID texture; RID texture;
if (i < (int)p_gi_probes.size()) { if (i < (int)p_voxel_gi_instances.size()) {
GIProbeInstance *gipi = get_probe_instance(p_gi_probes[i]); VoxelGIInstance *gipi = get_probe_instance(p_voxel_gi_instances[i]);
if (gipi) { if (gipi) {
texture = gipi->texture; texture = gipi->texture;
GIProbeData &gipd = gi_probe_data[i]; VoxelGIData &gipd = voxel_gi_data[i];
RID base_probe = gipi->probe; RID base_probe = gipi->probe;
Transform3D to_cell = storage->gi_probe_get_to_cell_xform(gipi->probe) * gipi->transform.affine_inverse() * to_camera; Transform3D to_cell = storage->voxel_gi_get_to_cell_xform(gipi->probe) * gipi->transform.affine_inverse() * to_camera;
gipd.xform[0] = to_cell.basis.elements[0][0]; gipd.xform[0] = to_cell.basis.elements[0][0];
gipd.xform[1] = to_cell.basis.elements[1][0]; gipd.xform[1] = to_cell.basis.elements[1][0];
@ -3068,36 +3068,36 @@ void RendererSceneGIRD::setup_giprobes(RID p_render_buffers, const Transform3D &
gipd.xform[14] = to_cell.origin.z; gipd.xform[14] = to_cell.origin.z;
gipd.xform[15] = 1; gipd.xform[15] = 1;
Vector3 bounds = storage->gi_probe_get_octree_size(base_probe); Vector3 bounds = storage->voxel_gi_get_octree_size(base_probe);
gipd.bounds[0] = bounds.x; gipd.bounds[0] = bounds.x;
gipd.bounds[1] = bounds.y; gipd.bounds[1] = bounds.y;
gipd.bounds[2] = bounds.z; gipd.bounds[2] = bounds.z;
gipd.dynamic_range = storage->gi_probe_get_dynamic_range(base_probe) * storage->gi_probe_get_energy(base_probe); gipd.dynamic_range = storage->voxel_gi_get_dynamic_range(base_probe) * storage->voxel_gi_get_energy(base_probe);
gipd.bias = storage->gi_probe_get_bias(base_probe); gipd.bias = storage->voxel_gi_get_bias(base_probe);
gipd.normal_bias = storage->gi_probe_get_normal_bias(base_probe); gipd.normal_bias = storage->voxel_gi_get_normal_bias(base_probe);
gipd.blend_ambient = !storage->gi_probe_is_interior(base_probe); gipd.blend_ambient = !storage->voxel_gi_is_interior(base_probe);
gipd.anisotropy_strength = 0; gipd.anisotropy_strength = 0;
gipd.ao = storage->gi_probe_get_ao(base_probe); gipd.ao = storage->voxel_gi_get_ao(base_probe);
gipd.ao_size = Math::pow(storage->gi_probe_get_ao_size(base_probe), 4.0f); gipd.ao_size = Math::pow(storage->voxel_gi_get_ao_size(base_probe), 4.0f);
gipd.mipmaps = gipi->mipmaps.size(); gipd.mipmaps = gipi->mipmaps.size();
} }
r_gi_probes_used++; r_voxel_gi_instances_used++;
} }
if (texture == RID()) { if (texture == RID()) {
texture = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE); texture = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE);
} }
if (texture != rb->gi.giprobe_textures[i]) { if (texture != rb->gi.voxel_gi_textures[i]) {
giprobes_changed = true; voxel_gi_instances_changed = true;
rb->gi.giprobe_textures[i] = texture; rb->gi.voxel_gi_textures[i] = texture;
} }
} }
if (giprobes_changed) { if (voxel_gi_instances_changed) {
if (RD::get_singleton()->uniform_set_is_valid(rb->gi.uniform_set)) { if (RD::get_singleton()->uniform_set_is_valid(rb->gi.uniform_set)) {
RD::get_singleton()->free(rb->gi.uniform_set); RD::get_singleton()->free(rb->gi.uniform_set);
} }
@ -3112,14 +3112,14 @@ void RendererSceneGIRD::setup_giprobes(RID p_render_buffers, const Transform3D &
} }
} }
if (p_gi_probes.size() > 0) { if (p_voxel_gi_instances.size() > 0) {
RD::get_singleton()->buffer_update(gi_probe_buffer, 0, sizeof(GIProbeData) * MIN((uint64_t)MAX_GIPROBES, p_gi_probes.size()), gi_probe_data, RD::BARRIER_MASK_COMPUTE); RD::get_singleton()->buffer_update(voxel_gi_buffer, 0, sizeof(VoxelGIData) * MIN((uint64_t)MAX_VOXEL_GI_INSTANCES, p_voxel_gi_instances.size()), voxel_gi_data, RD::BARRIER_MASK_COMPUTE);
} }
RD::get_singleton()->draw_command_end_label(); RD::get_singleton()->draw_command_end_label();
} }
void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_buffer, RID p_gi_probe_buffer, RID p_environment, const CameraMatrix &p_projection, const Transform3D &p_transform, const PagedArray<RID> &p_gi_probes, RendererSceneRenderRD *p_scene_render) { void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_buffer, RID p_voxel_gi_buffer, RID p_environment, const CameraMatrix &p_projection, const Transform3D &p_transform, const PagedArray<RID> &p_voxel_gi_instances, RendererSceneRenderRD *p_scene_render) {
RD::get_singleton()->draw_command_begin_label("GI Render"); RD::get_singleton()->draw_command_begin_label("GI Render");
RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers); RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers);
@ -3157,11 +3157,11 @@ void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_
push_constant.proj_info[1] = -2.0f / (rb->height * p_projection.matrix[1][1]); push_constant.proj_info[1] = -2.0f / (rb->height * p_projection.matrix[1][1]);
push_constant.proj_info[2] = (1.0f - p_projection.matrix[0][2]) / p_projection.matrix[0][0]; push_constant.proj_info[2] = (1.0f - p_projection.matrix[0][2]) / p_projection.matrix[0][0];
push_constant.proj_info[3] = (1.0f + p_projection.matrix[1][2]) / p_projection.matrix[1][1]; push_constant.proj_info[3] = (1.0f + p_projection.matrix[1][2]) / p_projection.matrix[1][1];
push_constant.max_giprobes = MIN((uint64_t)MAX_GIPROBES, p_gi_probes.size()); push_constant.max_voxel_gi_instances = MIN((uint64_t)MAX_VOXEL_GI_INSTANCES, p_voxel_gi_instances.size());
push_constant.high_quality_vct = gi_probe_quality == RS::GI_PROBE_QUALITY_HIGH; push_constant.high_quality_vct = voxel_gi_quality == RS::VOXEL_GI_QUALITY_HIGH;
bool use_sdfgi = rb->sdfgi != nullptr; bool use_sdfgi = rb->sdfgi != nullptr;
bool use_giprobes = push_constant.max_giprobes > 0; bool use_voxel_gi_instances = push_constant.max_voxel_gi_instances > 0;
if (env) { if (env) {
push_constant.ao_color[0] = env->ao_color.r; push_constant.ao_color[0] = env->ao_color.r;
@ -3311,7 +3311,7 @@ void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 14; u.binding = 14;
RID buffer = p_gi_probe_buffer.is_valid() ? p_gi_probe_buffer : storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_BLACK); RID buffer = p_voxel_gi_buffer.is_valid() ? p_voxel_gi_buffer : storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_BLACK);
u.ids.push_back(buffer); u.ids.push_back(buffer);
uniforms.push_back(u); uniforms.push_back(u);
} }
@ -3326,15 +3326,15 @@ void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER;
u.binding = 16; u.binding = 16;
u.ids.push_back(rb->gi.giprobe_buffer); u.ids.push_back(rb->gi.voxel_gi_buffer);
uniforms.push_back(u); uniforms.push_back(u);
} }
{ {
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 17; u.binding = 17;
for (int i = 0; i < MAX_GIPROBES; i++) { for (int i = 0; i < MAX_VOXEL_GI_INSTANCES; i++) {
u.ids.push_back(rb->gi.giprobe_textures[i]); u.ids.push_back(rb->gi.voxel_gi_textures[i]);
} }
uniforms.push_back(u); uniforms.push_back(u);
} }
@ -3345,9 +3345,9 @@ void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_
Mode mode; Mode mode;
if (rb->gi.using_half_size_gi) { if (rb->gi.using_half_size_gi) {
mode = (use_sdfgi && use_giprobes) ? MODE_HALF_RES_COMBINED : (use_sdfgi ? MODE_HALF_RES_SDFGI : MODE_HALF_RES_GIPROBE); mode = (use_sdfgi && use_voxel_gi_instances) ? MODE_HALF_RES_COMBINED : (use_sdfgi ? MODE_HALF_RES_SDFGI : MODE_HALF_RES_VOXEL_GI);
} else { } else {
mode = (use_sdfgi && use_giprobes) ? MODE_COMBINED : (use_sdfgi ? MODE_SDFGI : MODE_GIPROBE); mode = (use_sdfgi && use_voxel_gi_instances) ? MODE_COMBINED : (use_sdfgi ? MODE_SDFGI : MODE_VOXEL_GI);
} }
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(true); RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(true);
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, pipelines[mode]); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, pipelines[mode]);
@ -3364,39 +3364,39 @@ void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_
RD::get_singleton()->draw_command_end_label(); RD::get_singleton()->draw_command_end_label();
} }
RID RendererSceneGIRD::gi_probe_instance_create(RID p_base) { RID RendererSceneGIRD::voxel_gi_instance_create(RID p_base) {
GIProbeInstance gi_probe; VoxelGIInstance voxel_gi;
gi_probe.gi = this; voxel_gi.gi = this;
gi_probe.storage = storage; voxel_gi.storage = storage;
gi_probe.probe = p_base; voxel_gi.probe = p_base;
RID rid = gi_probe_instance_owner.make_rid(gi_probe); RID rid = voxel_gi_instance_owner.make_rid(voxel_gi);
return rid; return rid;
} }
void RendererSceneGIRD::gi_probe_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) { void RendererSceneGIRD::voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) {
GIProbeInstance *gi_probe = get_probe_instance(p_probe); VoxelGIInstance *voxel_gi = get_probe_instance(p_probe);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->transform = p_xform; voxel_gi->transform = p_xform;
} }
bool RendererSceneGIRD::gi_probe_needs_update(RID p_probe) const { bool RendererSceneGIRD::voxel_gi_needs_update(RID p_probe) const {
GIProbeInstance *gi_probe = get_probe_instance(p_probe); VoxelGIInstance *voxel_gi = get_probe_instance(p_probe);
ERR_FAIL_COND_V(!gi_probe, false); ERR_FAIL_COND_V(!voxel_gi, false);
return gi_probe->last_probe_version != storage->gi_probe_get_version(gi_probe->probe); return voxel_gi->last_probe_version != storage->voxel_gi_get_version(voxel_gi->probe);
} }
void RendererSceneGIRD::gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects, RendererSceneRenderRD *p_scene_render) { void RendererSceneGIRD::voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects, RendererSceneRenderRD *p_scene_render) {
GIProbeInstance *gi_probe = get_probe_instance(p_probe); VoxelGIInstance *voxel_gi = get_probe_instance(p_probe);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->update(p_update_light_instances, p_light_instances, p_dynamic_objects, p_scene_render); voxel_gi->update(p_update_light_instances, p_light_instances, p_dynamic_objects, p_scene_render);
} }
void RendererSceneGIRD::debug_giprobe(RID p_gi_probe, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) { void RendererSceneGIRD::debug_voxel_gi(RID p_voxel_gi, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) {
GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_gi_probe); VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->debug(p_draw_list, p_framebuffer, p_camera_with_transform, p_lighting, p_emission, p_alpha); voxel_gi->debug(p_draw_list, p_framebuffer, p_camera_with_transform, p_lighting, p_emission, p_alpha);
} }

View file

@ -38,13 +38,13 @@
#include "servers/rendering/renderer_rd/renderer_scene_sky_rd.h" #include "servers/rendering/renderer_rd/renderer_scene_sky_rd.h"
#include "servers/rendering/renderer_rd/renderer_storage_rd.h" #include "servers/rendering/renderer_rd/renderer_storage_rd.h"
#include "servers/rendering/renderer_rd/shaders/gi.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/gi.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/giprobe.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/giprobe_debug.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/sdfgi_debug.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/sdfgi_debug.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/sdfgi_debug_probes.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/sdfgi_debug_probes.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/sdfgi_preprocess.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/sdfgi_preprocess.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/voxel_gi.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/voxel_gi_debug.glsl.gen.h"
#include "servers/rendering/renderer_scene_render.h" #include "servers/rendering/renderer_scene_render.h"
#include "servers/rendering/rendering_device.h" #include "servers/rendering/rendering_device.h"
@ -56,9 +56,9 @@ class RendererSceneGIRD {
private: private:
RendererStorageRD *storage; RendererStorageRD *storage;
/* GIPROBE INSTANCE */ /* VOXEL_GI INSTANCE */
struct GIProbeLight { struct VoxelGILight {
uint32_t type; uint32_t type;
float energy; float energy;
float radius; float radius;
@ -74,7 +74,7 @@ private:
uint32_t has_shadow; uint32_t has_shadow;
}; };
struct GIProbePushConstant { struct VoxelGIPushConstant {
int32_t limits[3]; int32_t limits[3];
uint32_t stack_size; uint32_t stack_size;
@ -89,7 +89,7 @@ private:
uint32_t pad; uint32_t pad;
}; };
struct GIProbeDynamicPushConstant { struct VoxelGIDynamicPushConstant {
int32_t limits[3]; int32_t limits[3];
uint32_t light_count; uint32_t light_count;
int32_t x_dir[3]; int32_t x_dir[3];
@ -110,36 +110,36 @@ private:
float pad[3]; float pad[3];
}; };
GIProbeLight *gi_probe_lights; VoxelGILight *voxel_gi_lights;
uint32_t gi_probe_max_lights; uint32_t voxel_gi_max_lights;
RID gi_probe_lights_uniform; RID voxel_gi_lights_uniform;
enum { enum {
GI_PROBE_SHADER_VERSION_COMPUTE_LIGHT, VOXEL_GI_SHADER_VERSION_COMPUTE_LIGHT,
GI_PROBE_SHADER_VERSION_COMPUTE_SECOND_BOUNCE, VOXEL_GI_SHADER_VERSION_COMPUTE_SECOND_BOUNCE,
GI_PROBE_SHADER_VERSION_COMPUTE_MIPMAP, VOXEL_GI_SHADER_VERSION_COMPUTE_MIPMAP,
GI_PROBE_SHADER_VERSION_WRITE_TEXTURE, VOXEL_GI_SHADER_VERSION_WRITE_TEXTURE,
GI_PROBE_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING, VOXEL_GI_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING,
GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE, VOXEL_GI_SHADER_VERSION_DYNAMIC_SHRINK_WRITE,
GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT, VOXEL_GI_SHADER_VERSION_DYNAMIC_SHRINK_PLOT,
GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT, VOXEL_GI_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT,
GI_PROBE_SHADER_VERSION_MAX VOXEL_GI_SHADER_VERSION_MAX
}; };
GiprobeShaderRD giprobe_shader; VoxelGiShaderRD voxel_gi_shader;
RID giprobe_lighting_shader_version; RID voxel_gi_lighting_shader_version;
RID giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_MAX]; RID voxel_gi_lighting_shader_version_shaders[VOXEL_GI_SHADER_VERSION_MAX];
RID giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_MAX]; RID voxel_gi_lighting_shader_version_pipelines[VOXEL_GI_SHADER_VERSION_MAX];
enum { enum {
GI_PROBE_DEBUG_COLOR, VOXEL_GI_DEBUG_COLOR,
GI_PROBE_DEBUG_LIGHT, VOXEL_GI_DEBUG_LIGHT,
GI_PROBE_DEBUG_EMISSION, VOXEL_GI_DEBUG_EMISSION,
GI_PROBE_DEBUG_LIGHT_FULL, VOXEL_GI_DEBUG_LIGHT_FULL,
GI_PROBE_DEBUG_MAX VOXEL_GI_DEBUG_MAX
}; };
struct GIProbeDebugPushConstant { struct VoxelGIDebugPushConstant {
float projection[16]; float projection[16];
uint32_t cell_offset; uint32_t cell_offset;
float dynamic_range; float dynamic_range;
@ -149,11 +149,11 @@ private:
uint32_t pad; uint32_t pad;
}; };
GiprobeDebugShaderRD giprobe_debug_shader; VoxelGiDebugShaderRD voxel_gi_debug_shader;
RID giprobe_debug_shader_version; RID voxel_gi_debug_shader_version;
RID giprobe_debug_shader_version_shaders[GI_PROBE_DEBUG_MAX]; RID voxel_gi_debug_shader_version_shaders[VOXEL_GI_DEBUG_MAX];
PipelineCacheRD giprobe_debug_shader_version_pipelines[GI_PROBE_DEBUG_MAX]; PipelineCacheRD voxel_gi_debug_shader_version_pipelines[VOXEL_GI_DEBUG_MAX];
RID giprobe_debug_uniform_set; RID voxel_gi_debug_uniform_set;
/* SDFGI */ /* SDFGI */
@ -326,11 +326,11 @@ private:
} sdfgi_shader; } sdfgi_shader;
public: public:
/* GIPROBE INSTANCE */ /* VOXEL_GI INSTANCE */
//@TODO GIProbeInstance is still directly used in the render code, we'll address this when we refactor the render code itself. //@TODO VoxelGIInstance is still directly used in the render code, we'll address this when we refactor the render code itself.
struct GIProbeInstance { struct VoxelGIInstance {
// access to our containers // access to our containers
RendererStorageRD *storage; RendererStorageRD *storage;
RendererSceneGIRD *gi; RendererSceneGIRD *gi;
@ -380,19 +380,19 @@ public:
void debug(RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha); void debug(RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha);
}; };
mutable RID_Owner<GIProbeInstance> gi_probe_instance_owner; mutable RID_Owner<VoxelGIInstance> voxel_gi_instance_owner;
_FORCE_INLINE_ GIProbeInstance *get_probe_instance(RID p_probe) const { _FORCE_INLINE_ VoxelGIInstance *get_probe_instance(RID p_probe) const {
return gi_probe_instance_owner.getornull(p_probe); return voxel_gi_instance_owner.getornull(p_probe);
}; };
_FORCE_INLINE_ RID gi_probe_instance_get_texture(RID p_probe) { _FORCE_INLINE_ RID voxel_gi_instance_get_texture(RID p_probe) {
GIProbeInstance *gi_probe = get_probe_instance(p_probe); VoxelGIInstance *voxel_gi = get_probe_instance(p_probe);
ERR_FAIL_COND_V(!gi_probe, RID()); ERR_FAIL_COND_V(!voxel_gi, RID());
return gi_probe->texture; return voxel_gi->texture;
}; };
RS::GIProbeQuality gi_probe_quality = RS::GI_PROBE_QUALITY_HIGH; RS::VoxelGIQuality voxel_gi_quality = RS::VOXEL_GI_QUALITY_HIGH;
/* SDFGI */ /* SDFGI */
@ -551,13 +551,13 @@ public:
/* GI */ /* GI */
enum { enum {
MAX_GIPROBES = 8 MAX_VOXEL_GI_INSTANCES = 8
}; };
// Struct for use in render buffer // Struct for use in render buffer
struct RenderBuffersGI { struct RenderBuffersGI {
RID giprobe_textures[MAX_GIPROBES]; RID voxel_gi_textures[MAX_VOXEL_GI_INSTANCES];
RID giprobe_buffer; RID voxel_gi_buffer;
RID full_buffer; RID full_buffer;
RID full_dispatch; RID full_dispatch;
@ -601,7 +601,7 @@ public:
ProbeCascadeData cascades[SDFGI::MAX_CASCADES]; ProbeCascadeData cascades[SDFGI::MAX_CASCADES];
}; };
struct GIProbeData { struct VoxelGIData {
float xform[16]; float xform[16];
float bounds[3]; float bounds[3];
float dynamic_range; float dynamic_range;
@ -624,7 +624,7 @@ public:
float proj_info[4]; float proj_info[4];
float ao_color[3]; float ao_color[3];
uint32_t max_giprobes; uint32_t max_voxel_gi_instances;
uint32_t high_quality_vct; uint32_t high_quality_vct;
uint32_t orthogonal; uint32_t orthogonal;
@ -635,16 +635,16 @@ public:
RID sdfgi_ubo; RID sdfgi_ubo;
enum Mode { enum Mode {
MODE_GIPROBE, MODE_VOXEL_GI,
MODE_SDFGI, MODE_SDFGI,
MODE_COMBINED, MODE_COMBINED,
MODE_HALF_RES_GIPROBE, MODE_HALF_RES_VOXEL_GI,
MODE_HALF_RES_SDFGI, MODE_HALF_RES_SDFGI,
MODE_HALF_RES_COMBINED, MODE_HALF_RES_COMBINED,
MODE_MAX MODE_MAX
}; };
RID default_giprobe_buffer; RID default_voxel_gi_buffer;
bool half_resolution = false; bool half_resolution = false;
GiShaderRD shader; GiShaderRD shader;
@ -659,14 +659,14 @@ public:
SDFGI *create_sdfgi(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world_position, uint32_t p_requested_history_size); SDFGI *create_sdfgi(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world_position, uint32_t p_requested_history_size);
void setup_giprobes(RID p_render_buffers, const Transform3D &p_transform, const PagedArray<RID> &p_gi_probes, uint32_t &r_gi_probes_used, RendererSceneRenderRD *p_scene_render); void setup_voxel_gi_instances(RID p_render_buffers, const Transform3D &p_transform, const PagedArray<RID> &p_voxel_gi_instances, uint32_t &r_voxel_gi_instances_used, RendererSceneRenderRD *p_scene_render);
void process_gi(RID p_render_buffers, RID p_normal_roughness_buffer, RID p_gi_probe_buffer, RID p_environment, const CameraMatrix &p_projection, const Transform3D &p_transform, const PagedArray<RID> &p_gi_probes, RendererSceneRenderRD *p_scene_render); void process_gi(RID p_render_buffers, RID p_normal_roughness_buffer, RID p_voxel_gi_buffer, RID p_environment, const CameraMatrix &p_projection, const Transform3D &p_transform, const PagedArray<RID> &p_voxel_gi_instances, RendererSceneRenderRD *p_scene_render);
RID gi_probe_instance_create(RID p_base); RID voxel_gi_instance_create(RID p_base);
void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform); void voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform);
bool gi_probe_needs_update(RID p_probe) const; bool voxel_gi_needs_update(RID p_probe) const;
void gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects, RendererSceneRenderRD *p_scene_render); void voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects, RendererSceneRenderRD *p_scene_render);
void debug_giprobe(RID p_gi_probe, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha); void debug_voxel_gi(RID p_voxel_gi, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha);
}; };
#endif /* !RENDERING_SERVER_SCENE_GI_RD_H */ #endif /* !RENDERING_SERVER_SCENE_GI_RD_H */

View file

@ -1326,28 +1326,28 @@ void RendererSceneRenderRD::lightmap_instance_set_transform(RID p_lightmap, cons
///////////////////////////////// /////////////////////////////////
RID RendererSceneRenderRD::gi_probe_instance_create(RID p_base) { RID RendererSceneRenderRD::voxel_gi_instance_create(RID p_base) {
return gi.gi_probe_instance_create(p_base); return gi.voxel_gi_instance_create(p_base);
} }
void RendererSceneRenderRD::gi_probe_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) { void RendererSceneRenderRD::voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) {
gi.gi_probe_instance_set_transform_to_data(p_probe, p_xform); gi.voxel_gi_instance_set_transform_to_data(p_probe, p_xform);
} }
bool RendererSceneRenderRD::gi_probe_needs_update(RID p_probe) const { bool RendererSceneRenderRD::voxel_gi_needs_update(RID p_probe) const {
if (!is_dynamic_gi_supported()) { if (!is_dynamic_gi_supported()) {
return false; return false;
} }
return gi.gi_probe_needs_update(p_probe); return gi.voxel_gi_needs_update(p_probe);
} }
void RendererSceneRenderRD::gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<GeometryInstance *> &p_dynamic_objects) { void RendererSceneRenderRD::voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<GeometryInstance *> &p_dynamic_objects) {
if (!is_dynamic_gi_supported()) { if (!is_dynamic_gi_supported()) {
return; return;
} }
gi.gi_probe_update(p_probe, p_update_light_instances, p_light_instances, p_dynamic_objects, this); gi.voxel_gi_update(p_probe, p_update_light_instances, p_light_instances, p_dynamic_objects, this);
} }
void RendererSceneRenderRD::_debug_sdfgi_probes(RID p_render_buffers, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform) { void RendererSceneRenderRD::_debug_sdfgi_probes(RID p_render_buffers, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform) {
@ -1959,17 +1959,17 @@ RID RendererSceneRenderRD::render_buffers_get_ao_texture(RID p_render_buffers) {
return rb->ssao.ao_final; return rb->ssao.ao_final;
} }
RID RendererSceneRenderRD::render_buffers_get_gi_probe_buffer(RID p_render_buffers) { RID RendererSceneRenderRD::render_buffers_get_voxel_gi_buffer(RID p_render_buffers) {
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID()); ERR_FAIL_COND_V(!rb, RID());
if (rb->gi.giprobe_buffer.is_null()) { if (rb->gi.voxel_gi_buffer.is_null()) {
rb->gi.giprobe_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(RendererSceneGIRD::GIProbeData) * RendererSceneGIRD::MAX_GIPROBES); rb->gi.voxel_gi_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(RendererSceneGIRD::VoxelGIData) * RendererSceneGIRD::MAX_VOXEL_GI_INSTANCES);
} }
return rb->gi.giprobe_buffer; return rb->gi.voxel_gi_buffer;
} }
RID RendererSceneRenderRD::render_buffers_get_default_gi_probe_buffer() { RID RendererSceneRenderRD::render_buffers_get_default_voxel_gi_buffer() {
return gi.default_giprobe_buffer; return gi.default_voxel_gi_buffer;
} }
RID RendererSceneRenderRD::render_buffers_get_gi_ambient_texture(RID p_render_buffers) { RID RendererSceneRenderRD::render_buffers_get_gi_ambient_texture(RID p_render_buffers) {
@ -3066,7 +3066,7 @@ void RendererSceneRenderRD::_volumetric_fog_erase(RenderBuffers *rb) {
rb->volumetric_fog = nullptr; rb->volumetric_fog = nullptr;
} }
void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_environment, const CameraMatrix &p_cam_projection, const Transform3D &p_cam_transform, RID p_shadow_atlas, int p_directional_light_count, bool p_use_directional_shadows, int p_positional_light_count, int p_gi_probe_count) { void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_environment, const CameraMatrix &p_cam_projection, const Transform3D &p_cam_transform, RID p_shadow_atlas, int p_directional_light_count, bool p_use_directional_shadows, int p_positional_light_count, int p_voxel_gi_count) {
ERR_FAIL_COND(!is_clustered_enabled()); // can't use volumetric fog without clustered ERR_FAIL_COND(!is_clustered_enabled()); // can't use volumetric fog without clustered
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND(!rb); ERR_FAIL_COND(!rb);
@ -3228,7 +3228,7 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER;
u.binding = 11; u.binding = 11;
u.ids.push_back(render_buffers_get_gi_probe_buffer(p_render_buffers)); u.ids.push_back(render_buffers_get_voxel_gi_buffer(p_render_buffers));
uniforms.push_back(u); uniforms.push_back(u);
} }
@ -3236,8 +3236,8 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 12; u.binding = 12;
for (int i = 0; i < RendererSceneGIRD::MAX_GIPROBES; i++) { for (int i = 0; i < RendererSceneGIRD::MAX_VOXEL_GI_INSTANCES; i++) {
u.ids.push_back(rb->gi.giprobe_textures[i]); u.ids.push_back(rb->gi.voxel_gi_textures[i]);
} }
uniforms.push_back(u); uniforms.push_back(u);
} }
@ -3362,7 +3362,7 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e
params.cam_rotation[10] = p_cam_transform.basis[2][2]; params.cam_rotation[10] = p_cam_transform.basis[2][2];
params.cam_rotation[11] = 0; params.cam_rotation[11] = 0;
params.filter_axis = 0; params.filter_axis = 0;
params.max_gi_probes = env->volumetric_fog_gi_inject > 0.001 ? p_gi_probe_count : 0; params.max_voxel_gi_instances = env->volumetric_fog_gi_inject > 0.001 ? p_voxel_gi_count : 0;
params.temporal_frame = RSG::rasterizer->get_frame_number() % VolumetricFog::MAX_TEMPORAL_FRAMES; params.temporal_frame = RSG::rasterizer->get_frame_number() % VolumetricFog::MAX_TEMPORAL_FRAMES;
Transform3D to_prev_cam_view = rb->volumetric_fog->prev_cam_transform.affine_inverse() * p_cam_transform; Transform3D to_prev_cam_view = rb->volumetric_fog->prev_cam_transform.affine_inverse() * p_cam_transform;
@ -3492,7 +3492,7 @@ void RendererSceneRenderRD::_pre_resolve_render(RenderDataRD *p_render_data, boo
} }
} }
void RendererSceneRenderRD::_pre_opaque_render(RenderDataRD *p_render_data, bool p_use_ssao, bool p_use_gi, RID p_normal_roughness_buffer, RID p_gi_probe_buffer) { void RendererSceneRenderRD::_pre_opaque_render(RenderDataRD *p_render_data, bool p_use_ssao, bool p_use_gi, RID p_normal_roughness_buffer, RID p_voxel_gi_buffer) {
// Render shadows while GI is rendering, due to how barriers are handled, this should happen at the same time // Render shadows while GI is rendering, due to how barriers are handled, this should happen at the same time
if (p_render_data->render_buffers.is_valid() && p_use_gi) { if (p_render_data->render_buffers.is_valid() && p_use_gi) {
@ -3569,7 +3569,7 @@ void RendererSceneRenderRD::_pre_opaque_render(RenderDataRD *p_render_data, bool
//start GI //start GI
if (render_gi) { if (render_gi) {
gi.process_gi(p_render_data->render_buffers, p_normal_roughness_buffer, p_gi_probe_buffer, p_render_data->environment, p_render_data->cam_projection, p_render_data->cam_transform, *p_render_data->gi_probes, this); gi.process_gi(p_render_data->render_buffers, p_normal_roughness_buffer, p_voxel_gi_buffer, p_render_data->environment, p_render_data->cam_projection, p_render_data->cam_transform, *p_render_data->voxel_gi_instances, this);
} }
//Do shadow rendering (in parallel with GI) //Do shadow rendering (in parallel with GI)
@ -3625,12 +3625,12 @@ void RendererSceneRenderRD::_pre_opaque_render(RenderDataRD *p_render_data, bool
} }
} }
if (is_volumetric_supported()) { if (is_volumetric_supported()) {
_update_volumetric_fog(p_render_data->render_buffers, p_render_data->environment, p_render_data->cam_projection, p_render_data->cam_transform, p_render_data->shadow_atlas, directional_light_count, directional_shadows, positional_light_count, render_state.gi_probe_count); _update_volumetric_fog(p_render_data->render_buffers, p_render_data->environment, p_render_data->cam_projection, p_render_data->cam_transform, p_render_data->shadow_atlas, directional_light_count, directional_shadows, positional_light_count, render_state.voxel_gi_count);
} }
} }
} }
void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data) { void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data) {
// getting this here now so we can direct call a bunch of things more easily // getting this here now so we can direct call a bunch of things more easily
RenderBuffers *rb = nullptr; RenderBuffers *rb = nullptr;
if (p_render_buffers.is_valid()) { if (p_render_buffers.is_valid()) {
@ -3652,7 +3652,7 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform3D
render_data.instances = &p_instances; render_data.instances = &p_instances;
render_data.lights = &p_lights; render_data.lights = &p_lights;
render_data.reflection_probes = &p_reflection_probes; render_data.reflection_probes = &p_reflection_probes;
render_data.gi_probes = &p_gi_probes; render_data.voxel_gi_instances = &p_voxel_gi_instances;
render_data.decals = &p_decals; render_data.decals = &p_decals;
render_data.lightmaps = &p_lightmaps; render_data.lightmaps = &p_lightmaps;
render_data.environment = p_environment; render_data.environment = p_environment;
@ -3683,7 +3683,7 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform3D
if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) { if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
render_data.lights = &empty; render_data.lights = &empty;
render_data.reflection_probes = &empty; render_data.reflection_probes = &empty;
render_data.gi_probes = &empty; render_data.voxel_gi_instances = &empty;
} }
//sdfgi first //sdfgi first
@ -3703,12 +3703,12 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform3D
clear_color = storage->get_default_clear_color(); clear_color = storage->get_default_clear_color();
} }
//assign render indices to giprobes //assign render indices to voxel_gi_instances
if (is_dynamic_gi_supported()) { if (is_dynamic_gi_supported()) {
for (uint32_t i = 0; i < (uint32_t)p_gi_probes.size(); i++) { for (uint32_t i = 0; i < (uint32_t)p_voxel_gi_instances.size(); i++) {
RendererSceneGIRD::GIProbeInstance *giprobe_inst = gi.gi_probe_instance_owner.getornull(p_gi_probes[i]); RendererSceneGIRD::VoxelGIInstance *voxel_gi_inst = gi.voxel_gi_instance_owner.getornull(p_voxel_gi_instances[i]);
if (giprobe_inst) { if (voxel_gi_inst) {
giprobe_inst->render_index = i; voxel_gi_inst->render_index = i;
} }
} }
} }
@ -3736,9 +3736,9 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform3D
rb->sdfgi->pre_process_gi(p_cam_transform, &render_data, this); rb->sdfgi->pre_process_gi(p_cam_transform, &render_data, this);
} }
render_state.gi_probe_count = 0; render_state.voxel_gi_count = 0;
if (rb != nullptr && rb->sdfgi != nullptr) { if (rb != nullptr && rb->sdfgi != nullptr) {
gi.setup_giprobes(render_data.render_buffers, render_data.cam_transform, *render_data.gi_probes, render_state.gi_probe_count, this); gi.setup_voxel_gi_instances(render_data.render_buffers, render_data.cam_transform, *render_data.voxel_gi_instances, render_state.voxel_gi_count, this);
rb->sdfgi->update_light(); rb->sdfgi->update_light();
} }
@ -4018,19 +4018,19 @@ bool RendererSceneRenderRD::free(RID p_rid) {
decal_instance_owner.free(p_rid); decal_instance_owner.free(p_rid);
} else if (lightmap_instance_owner.owns(p_rid)) { } else if (lightmap_instance_owner.owns(p_rid)) {
lightmap_instance_owner.free(p_rid); lightmap_instance_owner.free(p_rid);
} else if (gi.gi_probe_instance_owner.owns(p_rid)) { } else if (gi.voxel_gi_instance_owner.owns(p_rid)) {
RendererSceneGIRD::GIProbeInstance *gi_probe = gi.gi_probe_instance_owner.getornull(p_rid); RendererSceneGIRD::VoxelGIInstance *voxel_gi = gi.voxel_gi_instance_owner.getornull(p_rid);
if (gi_probe->texture.is_valid()) { if (voxel_gi->texture.is_valid()) {
RD::get_singleton()->free(gi_probe->texture); RD::get_singleton()->free(voxel_gi->texture);
RD::get_singleton()->free(gi_probe->write_buffer); RD::get_singleton()->free(voxel_gi->write_buffer);
} }
for (int i = 0; i < gi_probe->dynamic_maps.size(); i++) { for (int i = 0; i < voxel_gi->dynamic_maps.size(); i++) {
RD::get_singleton()->free(gi_probe->dynamic_maps[i].texture); RD::get_singleton()->free(voxel_gi->dynamic_maps[i].texture);
RD::get_singleton()->free(gi_probe->dynamic_maps[i].depth); RD::get_singleton()->free(voxel_gi->dynamic_maps[i].depth);
} }
gi.gi_probe_instance_owner.free(p_rid); gi.voxel_gi_instance_owner.free(p_rid);
} else if (sky.sky_owner.owns(p_rid)) { } else if (sky.sky_owner.owns(p_rid)) {
sky.update_dirty_skys(); sky.update_dirty_skys();
sky.free_sky(p_rid); sky.free_sky(p_rid);

View file

@ -56,7 +56,7 @@ struct RenderDataRD {
const PagedArray<RendererSceneRender::GeometryInstance *> *instances = nullptr; const PagedArray<RendererSceneRender::GeometryInstance *> *instances = nullptr;
const PagedArray<RID> *lights = nullptr; const PagedArray<RID> *lights = nullptr;
const PagedArray<RID> *reflection_probes = nullptr; const PagedArray<RID> *reflection_probes = nullptr;
const PagedArray<RID> *gi_probes = nullptr; const PagedArray<RID> *voxel_gi_instances = nullptr;
const PagedArray<RID> *decals = nullptr; const PagedArray<RID> *decals = nullptr;
const PagedArray<RID> *lightmaps = nullptr; const PagedArray<RID> *lightmaps = nullptr;
RID environment = RID(); RID environment = RID();
@ -123,7 +123,7 @@ protected:
void _post_prepass_render(RenderDataRD *p_render_data, bool p_use_gi); void _post_prepass_render(RenderDataRD *p_render_data, bool p_use_gi);
void _pre_resolve_render(RenderDataRD *p_render_data, bool p_use_gi); void _pre_resolve_render(RenderDataRD *p_render_data, bool p_use_gi);
void _pre_opaque_render(RenderDataRD *p_render_data, bool p_use_ssao, bool p_use_gi, RID p_normal_roughness_buffer, RID p_gi_probe_buffer); void _pre_opaque_render(RenderDataRD *p_render_data, bool p_use_ssao, bool p_use_gi, RID p_normal_roughness_buffer, RID p_voxel_gi_buffer);
// needed for a single argument calls (material and uv2) // needed for a single argument calls (material and uv2)
PagedArrayPool<GeometryInstance *> cull_argument_pool; PagedArrayPool<GeometryInstance *> cull_argument_pool;
@ -631,7 +631,7 @@ private:
int render_sdfgi_region_count = 0; int render_sdfgi_region_count = 0;
const RendererSceneRender::RenderSDFGIUpdateData *sdfgi_update_data = nullptr; const RendererSceneRender::RenderSDFGIUpdateData *sdfgi_update_data = nullptr;
uint32_t gi_probe_count = 0; uint32_t voxel_gi_count = 0;
LocalVector<int> cube_shadows; LocalVector<int> cube_shadows;
LocalVector<int> shadows; LocalVector<int> shadows;
@ -692,7 +692,7 @@ private:
float detail_spread; float detail_spread;
float gi_inject; float gi_inject;
uint32_t max_gi_probes; uint32_t max_voxel_gi_instances;
uint32_t cluster_type_size; uint32_t cluster_type_size;
float screen_size[2]; float screen_size[2];
@ -721,7 +721,7 @@ private:
bool volumetric_fog_filter_active = true; bool volumetric_fog_filter_active = true;
void _volumetric_fog_erase(RenderBuffers *rb); void _volumetric_fog_erase(RenderBuffers *rb);
void _update_volumetric_fog(RID p_render_buffers, RID p_environment, const CameraMatrix &p_cam_projection, const Transform3D &p_cam_transform, RID p_shadow_atlas, int p_directional_light_count, bool p_use_directional_shadows, int p_positional_light_count, int p_gi_probe_count); void _update_volumetric_fog(RID p_render_buffers, RID p_environment, const CameraMatrix &p_cam_projection, const Transform3D &p_cam_transform, RID p_shadow_atlas, int p_directional_light_count, bool p_use_directional_shadows, int p_positional_light_count, int p_voxel_gi_count);
RID shadow_sampler; RID shadow_sampler;
@ -1109,11 +1109,11 @@ public:
/* gi light probes */ /* gi light probes */
RID gi_probe_instance_create(RID p_base); RID voxel_gi_instance_create(RID p_base);
void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform); void voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform);
bool gi_probe_needs_update(RID p_probe) const; bool voxel_gi_needs_update(RID p_probe) const;
void gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects); void voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects);
void gi_probe_set_quality(RS::GIProbeQuality p_quality) { gi.gi_probe_quality = p_quality; } void voxel_gi_set_quality(RS::VoxelGIQuality p_quality) { gi.voxel_gi_quality = p_quality; }
/* render buffers */ /* render buffers */
@ -1123,8 +1123,8 @@ public:
RID render_buffers_get_ao_texture(RID p_render_buffers); RID render_buffers_get_ao_texture(RID p_render_buffers);
RID render_buffers_get_back_buffer_texture(RID p_render_buffers); RID render_buffers_get_back_buffer_texture(RID p_render_buffers);
RID render_buffers_get_gi_probe_buffer(RID p_render_buffers); RID render_buffers_get_voxel_gi_buffer(RID p_render_buffers);
RID render_buffers_get_default_gi_probe_buffer(); RID render_buffers_get_default_voxel_gi_buffer();
RID render_buffers_get_gi_ambient_texture(RID p_render_buffers); RID render_buffers_get_gi_ambient_texture(RID p_render_buffers);
RID render_buffers_get_gi_reflection_texture(RID p_render_buffers); RID render_buffers_get_gi_reflection_texture(RID p_render_buffers);
@ -1147,7 +1147,7 @@ public:
float render_buffers_get_volumetric_fog_end(RID p_render_buffers); float render_buffers_get_volumetric_fog_end(RID p_render_buffers);
float render_buffers_get_volumetric_fog_detail_spread(RID p_render_buffers); float render_buffers_get_volumetric_fog_detail_spread(RID p_render_buffers);
void render_scene(RID p_render_buffers, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr); void render_scene(RID p_render_buffers, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr);
void render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region); void render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region);

View file

@ -6324,36 +6324,36 @@ AABB RendererStorageRD::decal_get_aabb(RID p_decal) const {
return AABB(-decal->extents, decal->extents * 2.0); return AABB(-decal->extents, decal->extents * 2.0);
} }
RID RendererStorageRD::gi_probe_allocate() { RID RendererStorageRD::voxel_gi_allocate() {
return gi_probe_owner.allocate_rid(); return voxel_gi_owner.allocate_rid();
} }
void RendererStorageRD::gi_probe_initialize(RID p_gi_probe) { void RendererStorageRD::voxel_gi_initialize(RID p_voxel_gi) {
gi_probe_owner.initialize_rid(p_gi_probe, GIProbe()); voxel_gi_owner.initialize_rid(p_voxel_gi, VoxelGI());
} }
void RendererStorageRD::gi_probe_allocate_data(RID p_gi_probe, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) { void RendererStorageRD::voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
if (gi_probe->octree_buffer.is_valid()) { if (voxel_gi->octree_buffer.is_valid()) {
RD::get_singleton()->free(gi_probe->octree_buffer); RD::get_singleton()->free(voxel_gi->octree_buffer);
RD::get_singleton()->free(gi_probe->data_buffer); RD::get_singleton()->free(voxel_gi->data_buffer);
if (gi_probe->sdf_texture.is_valid()) { if (voxel_gi->sdf_texture.is_valid()) {
RD::get_singleton()->free(gi_probe->sdf_texture); RD::get_singleton()->free(voxel_gi->sdf_texture);
} }
gi_probe->sdf_texture = RID(); voxel_gi->sdf_texture = RID();
gi_probe->octree_buffer = RID(); voxel_gi->octree_buffer = RID();
gi_probe->data_buffer = RID(); voxel_gi->data_buffer = RID();
gi_probe->octree_buffer_size = 0; voxel_gi->octree_buffer_size = 0;
gi_probe->data_buffer_size = 0; voxel_gi->data_buffer_size = 0;
gi_probe->cell_count = 0; voxel_gi->cell_count = 0;
} }
gi_probe->to_cell_xform = p_to_cell_xform; voxel_gi->to_cell_xform = p_to_cell_xform;
gi_probe->bounds = p_aabb; voxel_gi->bounds = p_aabb;
gi_probe->octree_size = p_octree_size; voxel_gi->octree_size = p_octree_size;
gi_probe->level_counts = p_level_counts; voxel_gi->level_counts = p_level_counts;
if (p_octree_cells.size()) { if (p_octree_cells.size()) {
ERR_FAIL_COND(p_octree_cells.size() % 32 != 0); //cells size must be a multiple of 32 ERR_FAIL_COND(p_octree_cells.size() % 32 != 0); //cells size must be a multiple of 32
@ -6362,42 +6362,42 @@ void RendererStorageRD::gi_probe_allocate_data(RID p_gi_probe, const Transform3D
ERR_FAIL_COND(p_data_cells.size() != (int)cell_count * 16); //see that data size matches ERR_FAIL_COND(p_data_cells.size() != (int)cell_count * 16); //see that data size matches
gi_probe->cell_count = cell_count; voxel_gi->cell_count = cell_count;
gi_probe->octree_buffer = RD::get_singleton()->storage_buffer_create(p_octree_cells.size(), p_octree_cells); voxel_gi->octree_buffer = RD::get_singleton()->storage_buffer_create(p_octree_cells.size(), p_octree_cells);
gi_probe->octree_buffer_size = p_octree_cells.size(); voxel_gi->octree_buffer_size = p_octree_cells.size();
gi_probe->data_buffer = RD::get_singleton()->storage_buffer_create(p_data_cells.size(), p_data_cells); voxel_gi->data_buffer = RD::get_singleton()->storage_buffer_create(p_data_cells.size(), p_data_cells);
gi_probe->data_buffer_size = p_data_cells.size(); voxel_gi->data_buffer_size = p_data_cells.size();
if (p_distance_field.size()) { if (p_distance_field.size()) {
RD::TextureFormat tf; RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R8_UNORM; tf.format = RD::DATA_FORMAT_R8_UNORM;
tf.width = gi_probe->octree_size.x; tf.width = voxel_gi->octree_size.x;
tf.height = gi_probe->octree_size.y; tf.height = voxel_gi->octree_size.y;
tf.depth = gi_probe->octree_size.z; tf.depth = voxel_gi->octree_size.z;
tf.texture_type = RD::TEXTURE_TYPE_3D; tf.texture_type = RD::TEXTURE_TYPE_3D;
tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT; tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT;
Vector<Vector<uint8_t>> s; Vector<Vector<uint8_t>> s;
s.push_back(p_distance_field); s.push_back(p_distance_field);
gi_probe->sdf_texture = RD::get_singleton()->texture_create(tf, RD::TextureView(), s); voxel_gi->sdf_texture = RD::get_singleton()->texture_create(tf, RD::TextureView(), s);
} }
#if 0 #if 0
{ {
RD::TextureFormat tf; RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R8_UNORM; tf.format = RD::DATA_FORMAT_R8_UNORM;
tf.width = gi_probe->octree_size.x; tf.width = voxel_gi->octree_size.x;
tf.height = gi_probe->octree_size.y; tf.height = voxel_gi->octree_size.y;
tf.depth = gi_probe->octree_size.z; tf.depth = voxel_gi->octree_size.z;
tf.type = RD::TEXTURE_TYPE_3D; tf.type = RD::TEXTURE_TYPE_3D;
tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT; tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT;
tf.shareable_formats.push_back(RD::DATA_FORMAT_R8_UNORM); tf.shareable_formats.push_back(RD::DATA_FORMAT_R8_UNORM);
tf.shareable_formats.push_back(RD::DATA_FORMAT_R8_UINT); tf.shareable_formats.push_back(RD::DATA_FORMAT_R8_UINT);
gi_probe->sdf_texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); voxel_gi->sdf_texture = RD::get_singleton()->texture_create(tf, RD::TextureView());
} }
RID shared_tex; RID shared_tex;
{ {
RD::TextureView tv; RD::TextureView tv;
tv.format_override = RD::DATA_FORMAT_R8_UINT; tv.format_override = RD::DATA_FORMAT_R8_UINT;
shared_tex = RD::get_singleton()->texture_create_shared(tv, gi_probe->sdf_texture); shared_tex = RD::get_singleton()->texture_create_shared(tv, voxel_gi->sdf_texture);
} }
//update SDF texture //update SDF texture
Vector<RD::Uniform> uniforms; Vector<RD::Uniform> uniforms;
@ -6405,14 +6405,14 @@ void RendererStorageRD::gi_probe_allocate_data(RID p_gi_probe, const Transform3D
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER;
u.binding = 1; u.binding = 1;
u.ids.push_back(gi_probe->octree_buffer); u.ids.push_back(voxel_gi->octree_buffer);
uniforms.push_back(u); uniforms.push_back(u);
} }
{ {
RD::Uniform u; RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER;
u.binding = 2; u.binding = 2;
u.ids.push_back(gi_probe->data_buffer); u.ids.push_back(voxel_gi->data_buffer);
uniforms.push_back(u); uniforms.push_back(u);
} }
{ {
@ -6423,24 +6423,24 @@ void RendererStorageRD::gi_probe_allocate_data(RID p_gi_probe, const Transform3D
uniforms.push_back(u); uniforms.push_back(u);
} }
RID uniform_set = RD::get_singleton()->uniform_set_create(uniforms, giprobe_sdf_shader_version_shader, 0); RID uniform_set = RD::get_singleton()->uniform_set_create(uniforms, voxel_gi_sdf_shader_version_shader, 0);
{ {
uint32_t push_constant[4] = { 0, 0, 0, 0 }; uint32_t push_constant[4] = { 0, 0, 0, 0 };
for (int i = 0; i < gi_probe->level_counts.size() - 1; i++) { for (int i = 0; i < voxel_gi->level_counts.size() - 1; i++) {
push_constant[0] += gi_probe->level_counts[i]; push_constant[0] += voxel_gi->level_counts[i];
} }
push_constant[1] = push_constant[0] + gi_probe->level_counts[gi_probe->level_counts.size() - 1]; push_constant[1] = push_constant[0] + voxel_gi->level_counts[voxel_gi->level_counts.size() - 1];
print_line("offset: " + itos(push_constant[0])); print_line("offset: " + itos(push_constant[0]));
print_line("size: " + itos(push_constant[1])); print_line("size: " + itos(push_constant[1]));
//create SDF //create SDF
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, giprobe_sdf_shader_pipeline); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, voxel_gi_sdf_shader_pipeline);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, uniform_set, 0); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, uniform_set, 0);
RD::get_singleton()->compute_list_set_push_constant(compute_list, push_constant, sizeof(uint32_t) * 4); RD::get_singleton()->compute_list_set_push_constant(compute_list, push_constant, sizeof(uint32_t) * 4);
RD::get_singleton()->compute_list_dispatch(compute_list, gi_probe->octree_size.x / 4, gi_probe->octree_size.y / 4, gi_probe->octree_size.z / 4); RD::get_singleton()->compute_list_dispatch(compute_list, voxel_gi->octree_size.x / 4, voxel_gi->octree_size.y / 4, voxel_gi->octree_size.z / 4);
RD::get_singleton()->compute_list_end(); RD::get_singleton()->compute_list_end();
} }
@ -6450,232 +6450,232 @@ void RendererStorageRD::gi_probe_allocate_data(RID p_gi_probe, const Transform3D
#endif #endif
} }
gi_probe->version++; voxel_gi->version++;
gi_probe->data_version++; voxel_gi->data_version++;
gi_probe->dependency.changed_notify(DEPENDENCY_CHANGED_AABB); voxel_gi->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
} }
AABB RendererStorageRD::gi_probe_get_bounds(RID p_gi_probe) const { AABB RendererStorageRD::voxel_gi_get_bounds(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, AABB()); ERR_FAIL_COND_V(!voxel_gi, AABB());
return gi_probe->bounds; return voxel_gi->bounds;
} }
Vector3i RendererStorageRD::gi_probe_get_octree_size(RID p_gi_probe) const { Vector3i RendererStorageRD::voxel_gi_get_octree_size(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, Vector3i()); ERR_FAIL_COND_V(!voxel_gi, Vector3i());
return gi_probe->octree_size; return voxel_gi->octree_size;
} }
Vector<uint8_t> RendererStorageRD::gi_probe_get_octree_cells(RID p_gi_probe) const { Vector<uint8_t> RendererStorageRD::voxel_gi_get_octree_cells(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, Vector<uint8_t>()); ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
if (gi_probe->octree_buffer.is_valid()) { if (voxel_gi->octree_buffer.is_valid()) {
return RD::get_singleton()->buffer_get_data(gi_probe->octree_buffer); return RD::get_singleton()->buffer_get_data(voxel_gi->octree_buffer);
} }
return Vector<uint8_t>(); return Vector<uint8_t>();
} }
Vector<uint8_t> RendererStorageRD::gi_probe_get_data_cells(RID p_gi_probe) const { Vector<uint8_t> RendererStorageRD::voxel_gi_get_data_cells(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, Vector<uint8_t>()); ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
if (gi_probe->data_buffer.is_valid()) { if (voxel_gi->data_buffer.is_valid()) {
return RD::get_singleton()->buffer_get_data(gi_probe->data_buffer); return RD::get_singleton()->buffer_get_data(voxel_gi->data_buffer);
} }
return Vector<uint8_t>(); return Vector<uint8_t>();
} }
Vector<uint8_t> RendererStorageRD::gi_probe_get_distance_field(RID p_gi_probe) const { Vector<uint8_t> RendererStorageRD::voxel_gi_get_distance_field(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, Vector<uint8_t>()); ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
if (gi_probe->data_buffer.is_valid()) { if (voxel_gi->data_buffer.is_valid()) {
return RD::get_singleton()->texture_get_data(gi_probe->sdf_texture, 0); return RD::get_singleton()->texture_get_data(voxel_gi->sdf_texture, 0);
} }
return Vector<uint8_t>(); return Vector<uint8_t>();
} }
Vector<int> RendererStorageRD::gi_probe_get_level_counts(RID p_gi_probe) const { Vector<int> RendererStorageRD::voxel_gi_get_level_counts(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, Vector<int>()); ERR_FAIL_COND_V(!voxel_gi, Vector<int>());
return gi_probe->level_counts; return voxel_gi->level_counts;
} }
Transform3D RendererStorageRD::gi_probe_get_to_cell_xform(RID p_gi_probe) const { Transform3D RendererStorageRD::voxel_gi_get_to_cell_xform(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, Transform3D()); ERR_FAIL_COND_V(!voxel_gi, Transform3D());
return gi_probe->to_cell_xform; return voxel_gi->to_cell_xform;
} }
void RendererStorageRD::gi_probe_set_dynamic_range(RID p_gi_probe, float p_range) { void RendererStorageRD::voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->dynamic_range = p_range; voxel_gi->dynamic_range = p_range;
gi_probe->version++; voxel_gi->version++;
} }
float RendererStorageRD::gi_probe_get_dynamic_range(RID p_gi_probe) const { float RendererStorageRD::voxel_gi_get_dynamic_range(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->dynamic_range; return voxel_gi->dynamic_range;
} }
void RendererStorageRD::gi_probe_set_propagation(RID p_gi_probe, float p_range) { void RendererStorageRD::voxel_gi_set_propagation(RID p_voxel_gi, float p_range) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->propagation = p_range; voxel_gi->propagation = p_range;
gi_probe->version++; voxel_gi->version++;
} }
float RendererStorageRD::gi_probe_get_propagation(RID p_gi_probe) const { float RendererStorageRD::voxel_gi_get_propagation(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->propagation; return voxel_gi->propagation;
} }
void RendererStorageRD::gi_probe_set_energy(RID p_gi_probe, float p_energy) { void RendererStorageRD::voxel_gi_set_energy(RID p_voxel_gi, float p_energy) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->energy = p_energy; voxel_gi->energy = p_energy;
} }
float RendererStorageRD::gi_probe_get_energy(RID p_gi_probe) const { float RendererStorageRD::voxel_gi_get_energy(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->energy; return voxel_gi->energy;
} }
void RendererStorageRD::gi_probe_set_ao(RID p_gi_probe, float p_ao) { void RendererStorageRD::voxel_gi_set_ao(RID p_voxel_gi, float p_ao) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->ao = p_ao; voxel_gi->ao = p_ao;
} }
float RendererStorageRD::gi_probe_get_ao(RID p_gi_probe) const { float RendererStorageRD::voxel_gi_get_ao(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->ao; return voxel_gi->ao;
} }
void RendererStorageRD::gi_probe_set_ao_size(RID p_gi_probe, float p_strength) { void RendererStorageRD::voxel_gi_set_ao_size(RID p_voxel_gi, float p_strength) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->ao_size = p_strength; voxel_gi->ao_size = p_strength;
} }
float RendererStorageRD::gi_probe_get_ao_size(RID p_gi_probe) const { float RendererStorageRD::voxel_gi_get_ao_size(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->ao_size; return voxel_gi->ao_size;
} }
void RendererStorageRD::gi_probe_set_bias(RID p_gi_probe, float p_bias) { void RendererStorageRD::voxel_gi_set_bias(RID p_voxel_gi, float p_bias) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->bias = p_bias; voxel_gi->bias = p_bias;
} }
float RendererStorageRD::gi_probe_get_bias(RID p_gi_probe) const { float RendererStorageRD::voxel_gi_get_bias(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->bias; return voxel_gi->bias;
} }
void RendererStorageRD::gi_probe_set_normal_bias(RID p_gi_probe, float p_normal_bias) { void RendererStorageRD::voxel_gi_set_normal_bias(RID p_voxel_gi, float p_normal_bias) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->normal_bias = p_normal_bias; voxel_gi->normal_bias = p_normal_bias;
} }
float RendererStorageRD::gi_probe_get_normal_bias(RID p_gi_probe) const { float RendererStorageRD::voxel_gi_get_normal_bias(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->normal_bias; return voxel_gi->normal_bias;
} }
void RendererStorageRD::gi_probe_set_anisotropy_strength(RID p_gi_probe, float p_strength) { void RendererStorageRD::voxel_gi_set_anisotropy_strength(RID p_voxel_gi, float p_strength) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->anisotropy_strength = p_strength; voxel_gi->anisotropy_strength = p_strength;
} }
float RendererStorageRD::gi_probe_get_anisotropy_strength(RID p_gi_probe) const { float RendererStorageRD::voxel_gi_get_anisotropy_strength(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->anisotropy_strength; return voxel_gi->anisotropy_strength;
} }
void RendererStorageRD::gi_probe_set_interior(RID p_gi_probe, bool p_enable) { void RendererStorageRD::voxel_gi_set_interior(RID p_voxel_gi, bool p_enable) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->interior = p_enable; voxel_gi->interior = p_enable;
} }
void RendererStorageRD::gi_probe_set_use_two_bounces(RID p_gi_probe, bool p_enable) { void RendererStorageRD::voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND(!gi_probe); ERR_FAIL_COND(!voxel_gi);
gi_probe->use_two_bounces = p_enable; voxel_gi->use_two_bounces = p_enable;
gi_probe->version++; voxel_gi->version++;
} }
bool RendererStorageRD::gi_probe_is_using_two_bounces(RID p_gi_probe) const { bool RendererStorageRD::voxel_gi_is_using_two_bounces(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, false); ERR_FAIL_COND_V(!voxel_gi, false);
return gi_probe->use_two_bounces; return voxel_gi->use_two_bounces;
} }
bool RendererStorageRD::gi_probe_is_interior(RID p_gi_probe) const { bool RendererStorageRD::voxel_gi_is_interior(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->interior; return voxel_gi->interior;
} }
uint32_t RendererStorageRD::gi_probe_get_version(RID p_gi_probe) { uint32_t RendererStorageRD::voxel_gi_get_version(RID p_voxel_gi) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->version; return voxel_gi->version;
} }
uint32_t RendererStorageRD::gi_probe_get_data_version(RID p_gi_probe) { uint32_t RendererStorageRD::voxel_gi_get_data_version(RID p_voxel_gi) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, 0); ERR_FAIL_COND_V(!voxel_gi, 0);
return gi_probe->data_version; return voxel_gi->data_version;
} }
RID RendererStorageRD::gi_probe_get_octree_buffer(RID p_gi_probe) const { RID RendererStorageRD::voxel_gi_get_octree_buffer(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, RID()); ERR_FAIL_COND_V(!voxel_gi, RID());
return gi_probe->octree_buffer; return voxel_gi->octree_buffer;
} }
RID RendererStorageRD::gi_probe_get_data_buffer(RID p_gi_probe) const { RID RendererStorageRD::voxel_gi_get_data_buffer(RID p_voxel_gi) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, RID()); ERR_FAIL_COND_V(!voxel_gi, RID());
return gi_probe->data_buffer; return voxel_gi->data_buffer;
} }
RID RendererStorageRD::gi_probe_get_sdf_texture(RID p_gi_probe) { RID RendererStorageRD::voxel_gi_get_sdf_texture(RID p_voxel_gi) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
ERR_FAIL_COND_V(!gi_probe, RID()); ERR_FAIL_COND_V(!voxel_gi, RID());
return gi_probe->sdf_texture; return voxel_gi->sdf_texture;
} }
/* LIGHTMAP API */ /* LIGHTMAP API */
@ -7566,8 +7566,8 @@ void RendererStorageRD::base_update_dependency(RID p_base, DependencyTracker *p_
} else if (decal_owner.owns(p_base)) { } else if (decal_owner.owns(p_base)) {
Decal *decal = decal_owner.getornull(p_base); Decal *decal = decal_owner.getornull(p_base);
p_instance->update_dependency(&decal->dependency); p_instance->update_dependency(&decal->dependency);
} else if (gi_probe_owner.owns(p_base)) { } else if (voxel_gi_owner.owns(p_base)) {
GIProbe *gip = gi_probe_owner.getornull(p_base); VoxelGI *gip = voxel_gi_owner.getornull(p_base);
p_instance->update_dependency(&gip->dependency); p_instance->update_dependency(&gip->dependency);
} else if (lightmap_owner.owns(p_base)) { } else if (lightmap_owner.owns(p_base)) {
Lightmap *lm = lightmap_owner.getornull(p_base); Lightmap *lm = lightmap_owner.getornull(p_base);
@ -7604,8 +7604,8 @@ RS::InstanceType RendererStorageRD::get_base_type(RID p_rid) const {
if (decal_owner.owns(p_rid)) { if (decal_owner.owns(p_rid)) {
return RS::INSTANCE_DECAL; return RS::INSTANCE_DECAL;
} }
if (gi_probe_owner.owns(p_rid)) { if (voxel_gi_owner.owns(p_rid)) {
return RS::INSTANCE_GI_PROBE; return RS::INSTANCE_VOXEL_GI;
} }
if (light_owner.owns(p_rid)) { if (light_owner.owns(p_rid)) {
return RS::INSTANCE_LIGHT; return RS::INSTANCE_LIGHT;
@ -8662,11 +8662,11 @@ bool RendererStorageRD::free(RID p_rid) {
} }
decal->dependency.deleted_notify(p_rid); decal->dependency.deleted_notify(p_rid);
decal_owner.free(p_rid); decal_owner.free(p_rid);
} else if (gi_probe_owner.owns(p_rid)) { } else if (voxel_gi_owner.owns(p_rid)) {
gi_probe_allocate_data(p_rid, Transform3D(), AABB(), Vector3i(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<int>()); //deallocate voxel_gi_allocate_data(p_rid, Transform3D(), AABB(), Vector3i(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<int>()); //deallocate
GIProbe *gi_probe = gi_probe_owner.getornull(p_rid); VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_rid);
gi_probe->dependency.deleted_notify(p_rid); voxel_gi->dependency.deleted_notify(p_rid);
gi_probe_owner.free(p_rid); voxel_gi_owner.free(p_rid);
} else if (lightmap_owner.owns(p_rid)) { } else if (lightmap_owner.owns(p_rid)) {
lightmap_set_textures(p_rid, RID(), false); lightmap_set_textures(p_rid, RID(), false);
Lightmap *lightmap = lightmap_owner.getornull(p_rid); Lightmap *lightmap = lightmap_owner.getornull(p_rid);
@ -9181,10 +9181,10 @@ RendererStorageRD::RendererStorageRD() {
{ {
Vector<String> sdf_versions; Vector<String> sdf_versions;
sdf_versions.push_back(""); //one only sdf_versions.push_back(""); //one only
giprobe_sdf_shader.initialize(sdf_versions); voxel_gi_sdf_shader.initialize(sdf_versions);
giprobe_sdf_shader_version = giprobe_sdf_shader.version_create(); voxel_gi_sdf_shader_version = voxel_gi_sdf_shader.version_create();
giprobe_sdf_shader_version_shader = giprobe_sdf_shader.version_get_shader(giprobe_sdf_shader_version, 0); voxel_gi_sdf_shader_version_shader = voxel_gi_sdf_shader.version_get_shader(voxel_gi_sdf_shader_version, 0);
giprobe_sdf_shader_pipeline = RD::get_singleton()->compute_pipeline_create(giprobe_sdf_shader_version_shader); voxel_gi_sdf_shader_pipeline = RD::get_singleton()->compute_pipeline_create(voxel_gi_sdf_shader_version_shader);
} }
using_lightmap_array = true; // high end using_lightmap_array = true; // high end
@ -9400,7 +9400,7 @@ RendererStorageRD::~RendererStorageRD() {
RD::get_singleton()->free(mesh_default_rd_buffers[i]); RD::get_singleton()->free(mesh_default_rd_buffers[i]);
} }
giprobe_sdf_shader.version_free(giprobe_sdf_shader_version); voxel_gi_sdf_shader.version_free(voxel_gi_sdf_shader_version);
particles_shader.copy_shader.version_free(particles_shader.copy_shader_version); particles_shader.copy_shader.version_free(particles_shader.copy_shader_version);
rt_sdf.shader.version_free(rt_sdf.shader_version); rt_sdf.shader.version_free(rt_sdf.shader_version);

View file

@ -38,10 +38,10 @@
#include "servers/rendering/renderer_rd/effects_rd.h" #include "servers/rendering/renderer_rd/effects_rd.h"
#include "servers/rendering/renderer_rd/shader_compiler_rd.h" #include "servers/rendering/renderer_rd/shader_compiler_rd.h"
#include "servers/rendering/renderer_rd/shaders/canvas_sdf.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/canvas_sdf.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/giprobe_sdf.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/particles.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/particles.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/particles_copy.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/particles_copy.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/skeleton.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/skeleton.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/voxel_gi_sdf.glsl.gen.h"
#include "servers/rendering/renderer_scene_render.h" #include "servers/rendering/renderer_scene_render.h"
#include "servers/rendering/rendering_device.h" #include "servers/rendering/rendering_device.h"
class RendererStorageRD : public RendererStorage { class RendererStorageRD : public RendererStorage {
@ -1045,9 +1045,9 @@ private:
mutable RID_Owner<Decal, true> decal_owner; mutable RID_Owner<Decal, true> decal_owner;
/* GI PROBE */ /* VOXEL GI */
struct GIProbe { struct VoxelGI {
RID octree_buffer; RID octree_buffer;
RID data_buffer; RID data_buffer;
RID sdf_texture; RID sdf_texture;
@ -1081,12 +1081,12 @@ private:
Dependency dependency; Dependency dependency;
}; };
GiprobeSdfShaderRD giprobe_sdf_shader; VoxelGiSdfShaderRD voxel_gi_sdf_shader;
RID giprobe_sdf_shader_version; RID voxel_gi_sdf_shader_version;
RID giprobe_sdf_shader_version_shader; RID voxel_gi_sdf_shader_version_shader;
RID giprobe_sdf_shader_pipeline; RID voxel_gi_sdf_shader_pipeline;
mutable RID_Owner<GIProbe, true> gi_probe_owner; mutable RID_Owner<VoxelGI, true> voxel_gi_owner;
/* REFLECTION PROBE */ /* REFLECTION PROBE */
@ -2019,59 +2019,59 @@ public:
virtual AABB decal_get_aabb(RID p_decal) const; virtual AABB decal_get_aabb(RID p_decal) const;
/* GI PROBE API */ /* VOXEL GI API */
RID gi_probe_allocate(); RID voxel_gi_allocate();
void gi_probe_initialize(RID p_gi_probe); void voxel_gi_initialize(RID p_voxel_gi);
void gi_probe_allocate_data(RID p_gi_probe, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts); void voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts);
AABB gi_probe_get_bounds(RID p_gi_probe) const; AABB voxel_gi_get_bounds(RID p_voxel_gi) const;
Vector3i gi_probe_get_octree_size(RID p_gi_probe) const; Vector3i voxel_gi_get_octree_size(RID p_voxel_gi) const;
Vector<uint8_t> gi_probe_get_octree_cells(RID p_gi_probe) const; Vector<uint8_t> voxel_gi_get_octree_cells(RID p_voxel_gi) const;
Vector<uint8_t> gi_probe_get_data_cells(RID p_gi_probe) const; Vector<uint8_t> voxel_gi_get_data_cells(RID p_voxel_gi) const;
Vector<uint8_t> gi_probe_get_distance_field(RID p_gi_probe) const; Vector<uint8_t> voxel_gi_get_distance_field(RID p_voxel_gi) const;
Vector<int> gi_probe_get_level_counts(RID p_gi_probe) const; Vector<int> voxel_gi_get_level_counts(RID p_voxel_gi) const;
Transform3D gi_probe_get_to_cell_xform(RID p_gi_probe) const; Transform3D voxel_gi_get_to_cell_xform(RID p_voxel_gi) const;
void gi_probe_set_dynamic_range(RID p_gi_probe, float p_range); void voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range);
float gi_probe_get_dynamic_range(RID p_gi_probe) const; float voxel_gi_get_dynamic_range(RID p_voxel_gi) const;
void gi_probe_set_propagation(RID p_gi_probe, float p_range); void voxel_gi_set_propagation(RID p_voxel_gi, float p_range);
float gi_probe_get_propagation(RID p_gi_probe) const; float voxel_gi_get_propagation(RID p_voxel_gi) const;
void gi_probe_set_energy(RID p_gi_probe, float p_energy); void voxel_gi_set_energy(RID p_voxel_gi, float p_energy);
float gi_probe_get_energy(RID p_gi_probe) const; float voxel_gi_get_energy(RID p_voxel_gi) const;
void gi_probe_set_ao(RID p_gi_probe, float p_ao); void voxel_gi_set_ao(RID p_voxel_gi, float p_ao);
float gi_probe_get_ao(RID p_gi_probe) const; float voxel_gi_get_ao(RID p_voxel_gi) const;
void gi_probe_set_ao_size(RID p_gi_probe, float p_strength); void voxel_gi_set_ao_size(RID p_voxel_gi, float p_strength);
float gi_probe_get_ao_size(RID p_gi_probe) const; float voxel_gi_get_ao_size(RID p_voxel_gi) const;
void gi_probe_set_bias(RID p_gi_probe, float p_bias); void voxel_gi_set_bias(RID p_voxel_gi, float p_bias);
float gi_probe_get_bias(RID p_gi_probe) const; float voxel_gi_get_bias(RID p_voxel_gi) const;
void gi_probe_set_normal_bias(RID p_gi_probe, float p_range); void voxel_gi_set_normal_bias(RID p_voxel_gi, float p_range);
float gi_probe_get_normal_bias(RID p_gi_probe) const; float voxel_gi_get_normal_bias(RID p_voxel_gi) const;
void gi_probe_set_interior(RID p_gi_probe, bool p_enable); void voxel_gi_set_interior(RID p_voxel_gi, bool p_enable);
bool gi_probe_is_interior(RID p_gi_probe) const; bool voxel_gi_is_interior(RID p_voxel_gi) const;
void gi_probe_set_use_two_bounces(RID p_gi_probe, bool p_enable); void voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable);
bool gi_probe_is_using_two_bounces(RID p_gi_probe) const; bool voxel_gi_is_using_two_bounces(RID p_voxel_gi) const;
void gi_probe_set_anisotropy_strength(RID p_gi_probe, float p_strength); void voxel_gi_set_anisotropy_strength(RID p_voxel_gi, float p_strength);
float gi_probe_get_anisotropy_strength(RID p_gi_probe) const; float voxel_gi_get_anisotropy_strength(RID p_voxel_gi) const;
uint32_t gi_probe_get_version(RID p_probe); uint32_t voxel_gi_get_version(RID p_probe);
uint32_t gi_probe_get_data_version(RID p_probe); uint32_t voxel_gi_get_data_version(RID p_probe);
RID gi_probe_get_octree_buffer(RID p_gi_probe) const; RID voxel_gi_get_octree_buffer(RID p_voxel_gi) const;
RID gi_probe_get_data_buffer(RID p_gi_probe) const; RID voxel_gi_get_data_buffer(RID p_voxel_gi) const;
RID gi_probe_get_sdf_texture(RID p_gi_probe); RID voxel_gi_get_sdf_texture(RID p_voxel_gi);
/* LIGHTMAP CAPTURE */ /* LIGHTMAP CAPTURE */

View file

@ -35,7 +35,7 @@ layout(set = 0, binding = 11) uniform texture2DArray lightprobe_texture;
layout(set = 0, binding = 12) uniform texture2D depth_buffer; layout(set = 0, binding = 12) uniform texture2D depth_buffer;
layout(set = 0, binding = 13) uniform texture2D normal_roughness_buffer; layout(set = 0, binding = 13) uniform texture2D normal_roughness_buffer;
layout(set = 0, binding = 14) uniform utexture2D giprobe_buffer; layout(set = 0, binding = 14) uniform utexture2D voxel_gi_buffer;
layout(set = 0, binding = 15, std140) uniform SDFGI { layout(set = 0, binding = 15, std140) uniform SDFGI {
vec3 grid_size; vec3 grid_size;
@ -65,9 +65,9 @@ layout(set = 0, binding = 15, std140) uniform SDFGI {
} }
sdfgi; sdfgi;
#define MAX_GI_PROBES 8 #define MAX_VOXEL_GI_INSTANCES 8
struct GIProbeData { struct VoxelGIData {
mat4 xform; mat4 xform;
vec3 bounds; vec3 bounds;
float dynamic_range; float dynamic_range;
@ -83,12 +83,12 @@ struct GIProbeData {
uint mipmaps; uint mipmaps;
}; };
layout(set = 0, binding = 16, std140) uniform GIProbes { layout(set = 0, binding = 16, std140) uniform VoxelGIs {
GIProbeData data[MAX_GI_PROBES]; VoxelGIData data[MAX_VOXEL_GI_INSTANCES];
} }
gi_probes; voxel_gi_instances;
layout(set = 0, binding = 17) uniform texture3D gi_probe_textures[MAX_GI_PROBES]; layout(set = 0, binding = 17) uniform texture3D voxel_gi_textures[MAX_VOXEL_GI_INSTANCES];
layout(push_constant, binding = 0, std430) uniform Params { layout(push_constant, binding = 0, std430) uniform Params {
ivec2 screen_size; ivec2 screen_size;
@ -98,7 +98,7 @@ layout(push_constant, binding = 0, std430) uniform Params {
vec4 proj_info; vec4 proj_info;
vec3 ao_color; vec3 ao_color;
uint max_giprobes; uint max_voxel_gi_instances;
bool high_quality_vct; bool high_quality_vct;
bool orthogonal; bool orthogonal;
@ -155,7 +155,7 @@ vec3 reconstruct_position(ivec2 screen_pos) {
return pos; return pos;
} }
void sdfgi_probe_process(uint cascade, vec3 cascade_pos, vec3 cam_pos, vec3 cam_normal, vec3 cam_specular_normal, float roughness, out vec3 diffuse_light, out vec3 specular_light) { void sdfvoxel_gi_process(uint cascade, vec3 cascade_pos, vec3 cam_pos, vec3 cam_normal, vec3 cam_specular_normal, float roughness, out vec3 diffuse_light, out vec3 specular_light) {
cascade_pos += cam_normal * sdfgi.normal_bias; cascade_pos += cam_normal * sdfgi.normal_bias;
vec3 base_pos = floor(cascade_pos); vec3 base_pos = floor(cascade_pos);
@ -293,7 +293,7 @@ void sdfgi_process(vec3 vertex, vec3 normal, vec3 reflection, float roughness, o
float blend; float blend;
vec3 diffuse, specular; vec3 diffuse, specular;
sdfgi_probe_process(cascade, cascade_pos, cam_pos, cam_normal, reflection, roughness, diffuse, specular); sdfvoxel_gi_process(cascade, cascade_pos, cam_pos, cam_normal, reflection, roughness, diffuse, specular);
{ {
//process blend //process blend
@ -323,7 +323,7 @@ void sdfgi_process(vec3 vertex, vec3 normal, vec3 reflection, float roughness, o
} else { } else {
vec3 diffuse2, specular2; vec3 diffuse2, specular2;
cascade_pos = (cam_pos - sdfgi.cascades[cascade + 1].position) * sdfgi.cascades[cascade + 1].to_probe; cascade_pos = (cam_pos - sdfgi.cascades[cascade + 1].position) * sdfgi.cascades[cascade + 1].to_probe;
sdfgi_probe_process(cascade + 1, cascade_pos, cam_pos, cam_normal, reflection, roughness, diffuse2, specular2); sdfvoxel_gi_process(cascade + 1, cascade_pos, cam_pos, cam_normal, reflection, roughness, diffuse2, specular2);
diffuse = mix(diffuse, diffuse2, blend); diffuse = mix(diffuse, diffuse2, blend);
specular = mix(specular, specular2, blend); specular = mix(specular, specular2, blend);
} }
@ -494,26 +494,26 @@ vec4 voxel_cone_trace_45_degrees(texture3D probe, vec3 cell_size, vec3 pos, vec3
return color; return color;
} }
void gi_probe_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3 normal_xform, float roughness, inout vec4 out_spec, inout vec4 out_diff, inout float out_blend) { void voxel_gi_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3 normal_xform, float roughness, inout vec4 out_spec, inout vec4 out_diff, inout float out_blend) {
position = (gi_probes.data[index].xform * vec4(position, 1.0)).xyz; position = (voxel_gi_instances.data[index].xform * vec4(position, 1.0)).xyz;
ref_vec = normalize((gi_probes.data[index].xform * vec4(ref_vec, 0.0)).xyz); ref_vec = normalize((voxel_gi_instances.data[index].xform * vec4(ref_vec, 0.0)).xyz);
normal = normalize((gi_probes.data[index].xform * vec4(normal, 0.0)).xyz); normal = normalize((voxel_gi_instances.data[index].xform * vec4(normal, 0.0)).xyz);
position += normal * gi_probes.data[index].normal_bias; position += normal * voxel_gi_instances.data[index].normal_bias;
//this causes corrupted pixels, i have no idea why.. //this causes corrupted pixels, i have no idea why..
if (any(bvec2(any(lessThan(position, vec3(0.0))), any(greaterThan(position, gi_probes.data[index].bounds))))) { if (any(bvec2(any(lessThan(position, vec3(0.0))), any(greaterThan(position, voxel_gi_instances.data[index].bounds))))) {
return; return;
} }
mat3 dir_xform = mat3(gi_probes.data[index].xform) * normal_xform; mat3 dir_xform = mat3(voxel_gi_instances.data[index].xform) * normal_xform;
vec3 blendv = abs(position / gi_probes.data[index].bounds * 2.0 - 1.0); vec3 blendv = abs(position / voxel_gi_instances.data[index].bounds * 2.0 - 1.0);
float blend = clamp(1.0 - max(blendv.x, max(blendv.y, blendv.z)), 0.0, 1.0); float blend = clamp(1.0 - max(blendv.x, max(blendv.y, blendv.z)), 0.0, 1.0);
//float blend=1.0; //float blend=1.0;
float max_distance = length(gi_probes.data[index].bounds); float max_distance = length(voxel_gi_instances.data[index].bounds);
vec3 cell_size = 1.0 / gi_probes.data[index].bounds; vec3 cell_size = 1.0 / voxel_gi_instances.data[index].bounds;
//irradiance //irradiance
@ -534,7 +534,7 @@ void gi_probe_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3
for (uint i = 0; i < cone_dir_count; i++) { for (uint i = 0; i < cone_dir_count; i++) {
vec3 dir = normalize(dir_xform * cone_dirs[i]); vec3 dir = normalize(dir_xform * cone_dirs[i]);
light += cone_weights[i] * voxel_cone_trace(gi_probe_textures[index], cell_size, position, dir, cone_angle_tan, max_distance, gi_probes.data[index].bias); light += cone_weights[i] * voxel_cone_trace(voxel_gi_textures[index], cell_size, position, dir, cone_angle_tan, max_distance, voxel_gi_instances.data[index].bias);
} }
} else { } else {
const uint cone_dir_count = 4; const uint cone_dir_count = 4;
@ -547,42 +547,42 @@ void gi_probe_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3
float cone_weights[cone_dir_count] = float[](0.25, 0.25, 0.25, 0.25); float cone_weights[cone_dir_count] = float[](0.25, 0.25, 0.25, 0.25);
for (int i = 0; i < cone_dir_count; i++) { for (int i = 0; i < cone_dir_count; i++) {
vec3 dir = normalize(dir_xform * cone_dirs[i]); vec3 dir = normalize(dir_xform * cone_dirs[i]);
light += cone_weights[i] * voxel_cone_trace_45_degrees(gi_probe_textures[index], cell_size, position, dir, max_distance, gi_probes.data[index].bias); light += cone_weights[i] * voxel_cone_trace_45_degrees(voxel_gi_textures[index], cell_size, position, dir, max_distance, voxel_gi_instances.data[index].bias);
} }
} }
if (gi_probes.data[index].ambient_occlusion > 0.001) { if (voxel_gi_instances.data[index].ambient_occlusion > 0.001) {
float size = 1.0 + gi_probes.data[index].ambient_occlusion_size * 7.0; float size = 1.0 + voxel_gi_instances.data[index].ambient_occlusion_size * 7.0;
float taps, blend; float taps, blend;
blend = modf(size, taps); blend = modf(size, taps);
float ao = 0.0; float ao = 0.0;
for (float i = 1.0; i <= taps; i++) { for (float i = 1.0; i <= taps; i++) {
vec3 ofs = (position + normal * (i * 0.5 + 1.0)) * cell_size; vec3 ofs = (position + normal * (i * 0.5 + 1.0)) * cell_size;
ao += textureLod(sampler3D(gi_probe_textures[index], linear_sampler_with_mipmaps), ofs, i - 1.0).a * i; ao += textureLod(sampler3D(voxel_gi_textures[index], linear_sampler_with_mipmaps), ofs, i - 1.0).a * i;
} }
if (blend > 0.001) { if (blend > 0.001) {
vec3 ofs = (position + normal * ((taps + 1.0) * 0.5 + 1.0)) * cell_size; vec3 ofs = (position + normal * ((taps + 1.0) * 0.5 + 1.0)) * cell_size;
ao += textureLod(sampler3D(gi_probe_textures[index], linear_sampler_with_mipmaps), ofs, taps).a * (taps + 1.0) * blend; ao += textureLod(sampler3D(voxel_gi_textures[index], linear_sampler_with_mipmaps), ofs, taps).a * (taps + 1.0) * blend;
} }
ao = 1.0 - min(1.0, ao); ao = 1.0 - min(1.0, ao);
light.rgb = mix(params.ao_color, light.rgb, mix(1.0, ao, gi_probes.data[index].ambient_occlusion)); light.rgb = mix(params.ao_color, light.rgb, mix(1.0, ao, voxel_gi_instances.data[index].ambient_occlusion));
} }
light.rgb *= gi_probes.data[index].dynamic_range; light.rgb *= voxel_gi_instances.data[index].dynamic_range;
if (!gi_probes.data[index].blend_ambient) { if (!voxel_gi_instances.data[index].blend_ambient) {
light.a = 1.0; light.a = 1.0;
} }
out_diff += light * blend; out_diff += light * blend;
//radiance //radiance
vec4 irr_light = voxel_cone_trace(gi_probe_textures[index], cell_size, position, ref_vec, tan(roughness * 0.5 * M_PI * 0.99), max_distance, gi_probes.data[index].bias); vec4 irr_light = voxel_cone_trace(voxel_gi_textures[index], cell_size, position, ref_vec, tan(roughness * 0.5 * M_PI * 0.99), max_distance, voxel_gi_instances.data[index].bias);
irr_light.rgb *= gi_probes.data[index].dynamic_range; irr_light.rgb *= voxel_gi_instances.data[index].dynamic_range;
if (!gi_probes.data[index].blend_ambient) { if (!voxel_gi_instances.data[index].blend_ambient) {
irr_light.a = 1.0; irr_light.a = 1.0;
} }
@ -614,9 +614,9 @@ void process_gi(ivec2 pos, vec3 vertex, inout vec4 ambient_light, inout vec4 ref
sdfgi_process(vertex, normal, reflection, roughness, ambient_light, reflection_light); sdfgi_process(vertex, normal, reflection, roughness, ambient_light, reflection_light);
#endif #endif
#ifdef USE_GIPROBES #ifdef USE_VOXEL_GI_INSTANCES
{ {
uvec2 giprobe_tex = texelFetch(usampler2D(giprobe_buffer, linear_sampler), pos, 0).rg; uvec2 voxel_gi_tex = texelFetch(usampler2D(voxel_gi_buffer, linear_sampler), pos, 0).rg;
roughness *= roughness; roughness *= roughness;
//find arbitrary tangent and bitangent, then build a matrix //find arbitrary tangent and bitangent, then build a matrix
vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0); vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0);
@ -628,9 +628,9 @@ void process_gi(ivec2 pos, vec3 vertex, inout vec4 ambient_light, inout vec4 ref
vec4 spec_accum = vec4(0.0); vec4 spec_accum = vec4(0.0);
float blend_accum = 0.0; float blend_accum = 0.0;
for (uint i = 0; i < params.max_giprobes; i++) { for (uint i = 0; i < params.max_voxel_gi_instances; i++) {
if (any(equal(uvec2(i), giprobe_tex))) { if (any(equal(uvec2(i), voxel_gi_tex))) {
gi_probe_compute(i, vertex, normal, reflection, normal_mat, roughness, spec_accum, amb_accum, blend_accum); voxel_gi_compute(i, vertex, normal, reflection, normal_mat, roughness, spec_accum, amb_accum, blend_accum);
} }
} }
if (blend_accum > 0.0) { if (blend_accum > 0.0) {

View file

@ -13,9 +13,9 @@ layout(set = 0, binding = 1) uniform sampler2DMS source_normal_roughness;
layout(r32f, set = 1, binding = 0) uniform restrict writeonly image2D dest_depth; layout(r32f, set = 1, binding = 0) uniform restrict writeonly image2D dest_depth;
layout(rgba8, set = 1, binding = 1) uniform restrict writeonly image2D dest_normal_roughness; layout(rgba8, set = 1, binding = 1) uniform restrict writeonly image2D dest_normal_roughness;
#ifdef GIPROBE_RESOLVE #ifdef VOXEL_GI_RESOLVE
layout(set = 2, binding = 0) uniform usampler2DMS source_giprobe; layout(set = 2, binding = 0) uniform usampler2DMS source_voxel_gi;
layout(rg8ui, set = 3, binding = 0) uniform restrict writeonly uimage2D dest_giprobe; layout(rg8ui, set = 3, binding = 0) uniform restrict writeonly uimage2D dest_voxel_gi;
#endif #endif
#endif #endif
@ -38,8 +38,8 @@ void main() {
float best_depth = 1e20; float best_depth = 1e20;
vec4 best_normal_roughness = vec4(0.0); vec4 best_normal_roughness = vec4(0.0);
#ifdef GIPROBE_RESOLVE #ifdef VOXEL_GI_RESOLVE
uvec2 best_giprobe; uvec2 best_voxel_gi;
#endif #endif
#if 0 #if 0
@ -50,8 +50,8 @@ void main() {
best_depth = depth; best_depth = depth;
best_normal_roughness = texelFetch(source_normal_roughness,pos,i); best_normal_roughness = texelFetch(source_normal_roughness,pos,i);
#ifdef GIPROBE_RESOLVE #ifdef VOXEL_GI_RESOLVE
best_giprobe = texelFetch(source_giprobe,pos,i).rg; best_voxel_gi = texelFetch(source_voxel_gi,pos,i).rg;
#endif #endif
} }
} }
@ -204,16 +204,16 @@ void main() {
#endif #endif
best_depth = texelFetch(source_depth, pos, best_index).r; best_depth = texelFetch(source_depth, pos, best_index).r;
best_normal_roughness = texelFetch(source_normal_roughness, pos, best_index); best_normal_roughness = texelFetch(source_normal_roughness, pos, best_index);
#ifdef GIPROBE_RESOLVE #ifdef VOXEL_GI_RESOLVE
best_giprobe = texelFetch(source_giprobe, pos, best_index).rg; best_voxel_gi = texelFetch(source_voxel_gi, pos, best_index).rg;
#endif #endif
#endif #endif
imageStore(dest_depth, pos, vec4(best_depth)); imageStore(dest_depth, pos, vec4(best_depth));
imageStore(dest_normal_roughness, pos, vec4(best_normal_roughness)); imageStore(dest_normal_roughness, pos, vec4(best_normal_roughness));
#ifdef GIPROBE_RESOLVE #ifdef VOXEL_GI_RESOLVE
imageStore(dest_giprobe, pos, uvec4(best_giprobe, 0, 0)); imageStore(dest_voxel_gi, pos, uvec4(best_voxel_gi, 0, 0));
#endif #endif
#endif #endif

View file

@ -426,8 +426,8 @@ layout(location = 4) out float depth_output_buffer;
#ifdef MODE_RENDER_NORMAL_ROUGHNESS #ifdef MODE_RENDER_NORMAL_ROUGHNESS
layout(location = 0) out vec4 normal_roughness_output_buffer; layout(location = 0) out vec4 normal_roughness_output_buffer;
#ifdef MODE_RENDER_GIPROBE #ifdef MODE_RENDER_VOXEL_GI
layout(location = 1) out uvec2 giprobe_buffer; layout(location = 1) out uvec2 voxel_gi_buffer;
#endif #endif
#endif //MODE_RENDER_NORMAL #endif //MODE_RENDER_NORMAL
@ -1042,7 +1042,7 @@ void main() {
} }
} }
if (bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_GIPROBE)) { // process giprobes if (bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_VOXEL_GI)) { // process voxel_gi_instances
uint index1 = instances.data[instance_index].gi_offset & 0xFFFF; uint index1 = instances.data[instance_index].gi_offset & 0xFFFF;
vec3 ref_vec = normalize(reflect(normalize(vertex), normal)); vec3 ref_vec = normalize(reflect(normalize(vertex), normal));
@ -1054,12 +1054,12 @@ void main() {
vec4 amb_accum = vec4(0.0); vec4 amb_accum = vec4(0.0);
vec4 spec_accum = vec4(0.0); vec4 spec_accum = vec4(0.0);
gi_probe_compute(index1, vertex, normal, ref_vec, normal_mat, roughness * roughness, ambient_light, specular_light, spec_accum, amb_accum); voxel_gi_compute(index1, vertex, normal, ref_vec, normal_mat, roughness * roughness, ambient_light, specular_light, spec_accum, amb_accum);
uint index2 = instances.data[instance_index].gi_offset >> 16; uint index2 = instances.data[instance_index].gi_offset >> 16;
if (index2 != 0xFFFF) { if (index2 != 0xFFFF) {
gi_probe_compute(index2, vertex, normal, ref_vec, normal_mat, roughness * roughness, ambient_light, specular_light, spec_accum, amb_accum); voxel_gi_compute(index2, vertex, normal, ref_vec, normal_mat, roughness * roughness, ambient_light, specular_light, spec_accum, amb_accum);
} }
if (amb_accum.a > 0.0) { if (amb_accum.a > 0.0) {
@ -1929,15 +1929,15 @@ void main() {
#ifdef MODE_RENDER_NORMAL_ROUGHNESS #ifdef MODE_RENDER_NORMAL_ROUGHNESS
normal_roughness_output_buffer = vec4(normal * 0.5 + 0.5, roughness); normal_roughness_output_buffer = vec4(normal * 0.5 + 0.5, roughness);
#ifdef MODE_RENDER_GIPROBE #ifdef MODE_RENDER_VOXEL_GI
if (bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_GIPROBE)) { // process giprobes if (bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_VOXEL_GI)) { // process voxel_gi_instances
uint index1 = instances.data[instance_index].gi_offset & 0xFFFF; uint index1 = instances.data[instance_index].gi_offset & 0xFFFF;
uint index2 = instances.data[instance_index].gi_offset >> 16; uint index2 = instances.data[instance_index].gi_offset >> 16;
giprobe_buffer.x = index1 & 0xFF; voxel_gi_buffer.x = index1 & 0xFF;
giprobe_buffer.y = index2 & 0xFF; voxel_gi_buffer.y = index2 & 0xFF;
} else { } else {
giprobe_buffer.x = 0xFF; voxel_gi_buffer.x = 0xFF;
giprobe_buffer.y = 0xFF; voxel_gi_buffer.y = 0xFF;
} }
#endif #endif

View file

@ -1,7 +1,7 @@
#define M_PI 3.14159265359 #define M_PI 3.14159265359
#define ROUGHNESS_MAX_LOD 5 #define ROUGHNESS_MAX_LOD 5
#define MAX_GI_PROBES 8 #define MAX_VOXEL_GI_INSTANCES 8
#if defined(has_GL_KHR_shader_subgroup_ballot) && defined(has_GL_KHR_shader_subgroup_arithmetic) #if defined(has_GL_KHR_shader_subgroup_ballot) && defined(has_GL_KHR_shader_subgroup_arithmetic)
@ -15,7 +15,7 @@
#include "cluster_data_inc.glsl" #include "cluster_data_inc.glsl"
#include "decal_data_inc.glsl" #include "decal_data_inc.glsl"
#if !defined(MODE_RENDER_DEPTH) || defined(MODE_RENDER_MATERIAL) || defined(MODE_RENDER_SDF) || defined(MODE_RENDER_NORMAL_ROUGHNESS) || defined(MODE_RENDER_GIPROBE) || defined(TANGENT_USED) || defined(NORMAL_MAP_USED) #if !defined(MODE_RENDER_DEPTH) || defined(MODE_RENDER_MATERIAL) || defined(MODE_RENDER_SDF) || defined(MODE_RENDER_NORMAL_ROUGHNESS) || defined(MODE_RENDER_VOXEL_GI) || defined(TANGENT_USED) || defined(NORMAL_MAP_USED)
#ifndef NORMAL_USED #ifndef NORMAL_USED
#define NORMAL_USED #define NORMAL_USED
#endif #endif
@ -57,7 +57,7 @@ layout(set = 0, binding = 2) uniform sampler shadow_sampler;
#define INSTANCE_FLAGS_USE_LIGHTMAP_CAPTURE (1 << 8) #define INSTANCE_FLAGS_USE_LIGHTMAP_CAPTURE (1 << 8)
#define INSTANCE_FLAGS_USE_LIGHTMAP (1 << 9) #define INSTANCE_FLAGS_USE_LIGHTMAP (1 << 9)
#define INSTANCE_FLAGS_USE_SH_LIGHTMAP (1 << 10) #define INSTANCE_FLAGS_USE_SH_LIGHTMAP (1 << 10)
#define INSTANCE_FLAGS_USE_GIPROBE (1 << 11) #define INSTANCE_FLAGS_USE_VOXEL_GI (1 << 11)
#define INSTANCE_FLAGS_MULTIMESH (1 << 12) #define INSTANCE_FLAGS_MULTIMESH (1 << 12)
#define INSTANCE_FLAGS_MULTIMESH_FORMAT_2D (1 << 13) #define INSTANCE_FLAGS_MULTIMESH_FORMAT_2D (1 << 13)
#define INSTANCE_FLAGS_MULTIMESH_HAS_COLOR (1 << 14) #define INSTANCE_FLAGS_MULTIMESH_HAS_COLOR (1 << 14)
@ -122,7 +122,7 @@ layout(set = 0, binding = 12, std430) restrict readonly buffer GlobalVariableDat
} }
global_variables; global_variables;
struct SDFGIProbeCascadeData { struct SDFVoxelGICascadeData {
vec3 position; vec3 position;
float to_probe; float to_probe;
ivec3 probe_world_offset; ivec3 probe_world_offset;
@ -153,7 +153,7 @@ layout(set = 0, binding = 13, std140) uniform SDFGI {
vec3 cascade_probe_size; vec3 cascade_probe_size;
uint pad5; uint pad5;
SDFGIProbeCascadeData cascades[SDFGI_MAX_CASCADES]; SDFVoxelGICascadeData cascades[SDFGI_MAX_CASCADES];
} }
sdfgi; sdfgi;
@ -275,7 +275,7 @@ layout(set = 1, binding = 5) uniform texture2D directional_shadow_atlas;
layout(set = 1, binding = 6) uniform texture2DArray lightmap_textures[MAX_LIGHTMAP_TEXTURES]; layout(set = 1, binding = 6) uniform texture2DArray lightmap_textures[MAX_LIGHTMAP_TEXTURES];
layout(set = 1, binding = 7) uniform texture3D gi_probe_textures[MAX_GI_PROBES]; layout(set = 1, binding = 7) uniform texture3D voxel_gi_textures[MAX_VOXEL_GI_INSTANCES];
layout(set = 1, binding = 8, std430) buffer restrict readonly ClusterBuffer { layout(set = 1, binding = 8, std430) buffer restrict readonly ClusterBuffer {
uint data[]; uint data[];
@ -306,7 +306,7 @@ layout(set = 1, binding = 14) uniform texture2D reflection_buffer;
layout(set = 1, binding = 15) uniform texture2DArray sdfgi_lightprobe_texture; layout(set = 1, binding = 15) uniform texture2DArray sdfgi_lightprobe_texture;
layout(set = 1, binding = 16) uniform texture3D sdfgi_occlusion_cascades; layout(set = 1, binding = 16) uniform texture3D sdfgi_occlusion_cascades;
struct GIProbeData { struct VoxelGIData {
mat4 xform; mat4 xform;
vec3 bounds; vec3 bounds;
float dynamic_range; float dynamic_range;
@ -322,10 +322,10 @@ struct GIProbeData {
uint mipmaps; uint mipmaps;
}; };
layout(set = 1, binding = 17, std140) uniform GIProbes { layout(set = 1, binding = 17, std140) uniform VoxelGIs {
GIProbeData data[MAX_GI_PROBES]; VoxelGIData data[MAX_VOXEL_GI_INSTANCES];
} }
gi_probes; voxel_gi_instances;
layout(set = 1, binding = 18) uniform texture3D volumetric_fog_texture; layout(set = 1, binding = 18) uniform texture3D volumetric_fog_texture;

View file

@ -48,24 +48,24 @@ vec4 voxel_cone_trace_45_degrees(texture3D probe, vec3 cell_size, vec3 pos, vec3
return color; return color;
} }
void gi_probe_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3 normal_xform, float roughness, vec3 ambient, vec3 environment, inout vec4 out_spec, inout vec4 out_diff) { void voxel_gi_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3 normal_xform, float roughness, vec3 ambient, vec3 environment, inout vec4 out_spec, inout vec4 out_diff) {
position = (gi_probes.data[index].xform * vec4(position, 1.0)).xyz; position = (voxel_gi_instances.data[index].xform * vec4(position, 1.0)).xyz;
ref_vec = normalize((gi_probes.data[index].xform * vec4(ref_vec, 0.0)).xyz); ref_vec = normalize((voxel_gi_instances.data[index].xform * vec4(ref_vec, 0.0)).xyz);
normal = normalize((gi_probes.data[index].xform * vec4(normal, 0.0)).xyz); normal = normalize((voxel_gi_instances.data[index].xform * vec4(normal, 0.0)).xyz);
position += normal * gi_probes.data[index].normal_bias; position += normal * voxel_gi_instances.data[index].normal_bias;
//this causes corrupted pixels, i have no idea why.. //this causes corrupted pixels, i have no idea why..
if (any(bvec2(any(lessThan(position, vec3(0.0))), any(greaterThan(position, gi_probes.data[index].bounds))))) { if (any(bvec2(any(lessThan(position, vec3(0.0))), any(greaterThan(position, voxel_gi_instances.data[index].bounds))))) {
return; return;
} }
vec3 blendv = abs(position / gi_probes.data[index].bounds * 2.0 - 1.0); vec3 blendv = abs(position / voxel_gi_instances.data[index].bounds * 2.0 - 1.0);
float blend = clamp(1.0 - max(blendv.x, max(blendv.y, blendv.z)), 0.0, 1.0); float blend = clamp(1.0 - max(blendv.x, max(blendv.y, blendv.z)), 0.0, 1.0);
//float blend=1.0; //float blend=1.0;
float max_distance = length(gi_probes.data[index].bounds); float max_distance = length(voxel_gi_instances.data[index].bounds);
vec3 cell_size = 1.0 / gi_probes.data[index].bounds; vec3 cell_size = 1.0 / voxel_gi_instances.data[index].bounds;
//radiance //radiance
@ -83,26 +83,26 @@ void gi_probe_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3
vec3 light = vec3(0.0); vec3 light = vec3(0.0);
for (int i = 0; i < MAX_CONE_DIRS; i++) { for (int i = 0; i < MAX_CONE_DIRS; i++) {
vec3 dir = normalize((gi_probes.data[index].xform * vec4(normal_xform * cone_dirs[i], 0.0)).xyz); vec3 dir = normalize((voxel_gi_instances.data[index].xform * vec4(normal_xform * cone_dirs[i], 0.0)).xyz);
vec4 cone_light = voxel_cone_trace_45_degrees(gi_probe_textures[index], cell_size, position, dir, cone_angle_tan, max_distance, gi_probes.data[index].bias); vec4 cone_light = voxel_cone_trace_45_degrees(voxel_gi_textures[index], cell_size, position, dir, cone_angle_tan, max_distance, voxel_gi_instances.data[index].bias);
if (gi_probes.data[index].blend_ambient) { if (voxel_gi_instances.data[index].blend_ambient) {
cone_light.rgb = mix(ambient, cone_light.rgb, min(1.0, cone_light.a / 0.95)); cone_light.rgb = mix(ambient, cone_light.rgb, min(1.0, cone_light.a / 0.95));
} }
light += cone_weights[i] * cone_light.rgb; light += cone_weights[i] * cone_light.rgb;
} }
light *= gi_probes.data[index].dynamic_range; light *= voxel_gi_instances.data[index].dynamic_range;
out_diff += vec4(light * blend, blend); out_diff += vec4(light * blend, blend);
//irradiance //irradiance
vec4 irr_light = voxel_cone_trace(gi_probe_textures[index], cell_size, position, ref_vec, tan(roughness * 0.5 * M_PI * 0.99), max_distance, gi_probes.data[index].bias); vec4 irr_light = voxel_cone_trace(voxel_gi_textures[index], cell_size, position, ref_vec, tan(roughness * 0.5 * M_PI * 0.99), max_distance, voxel_gi_instances.data[index].bias);
if (gi_probes.data[index].blend_ambient) { if (voxel_gi_instances.data[index].blend_ambient) {
irr_light.rgb = mix(environment, irr_light.rgb, min(1.0, irr_light.a / 0.95)); irr_light.rgb = mix(environment, irr_light.rgb, min(1.0, irr_light.a / 0.95));
} }
irr_light.rgb *= gi_probes.data[index].dynamic_range; irr_light.rgb *= voxel_gi_instances.data[index].dynamic_range;
//irr_light=vec3(0.0); //irr_light=vec3(0.0);
out_spec += vec4(irr_light.rgb * blend, blend); out_spec += vec4(irr_light.rgb * blend, blend);

View file

@ -51,7 +51,7 @@ layout(set = 0, binding = 2) uniform sampler shadow_sampler;
#define INSTANCE_FLAGS_USE_LIGHTMAP_CAPTURE (1 << 8) #define INSTANCE_FLAGS_USE_LIGHTMAP_CAPTURE (1 << 8)
#define INSTANCE_FLAGS_USE_LIGHTMAP (1 << 9) #define INSTANCE_FLAGS_USE_LIGHTMAP (1 << 9)
#define INSTANCE_FLAGS_USE_SH_LIGHTMAP (1 << 10) #define INSTANCE_FLAGS_USE_SH_LIGHTMAP (1 << 10)
#define INSTANCE_FLAGS_USE_GIPROBE (1 << 11) #define INSTANCE_FLAGS_USE_VOXEL_GI (1 << 11)
#define INSTANCE_FLAGS_MULTIMESH (1 << 12) #define INSTANCE_FLAGS_MULTIMESH (1 << 12)
#define INSTANCE_FLAGS_MULTIMESH_FORMAT_2D (1 << 13) #define INSTANCE_FLAGS_MULTIMESH_FORMAT_2D (1 << 13)
#define INSTANCE_FLAGS_MULTIMESH_HAS_COLOR (1 << 14) #define INSTANCE_FLAGS_MULTIMESH_HAS_COLOR (1 << 14)

View file

@ -72,9 +72,9 @@ layout(rgba16f, set = 0, binding = 9) uniform restrict writeonly image3D dest_ma
layout(set = 0, binding = 10) uniform sampler shadow_sampler; layout(set = 0, binding = 10) uniform sampler shadow_sampler;
#define MAX_GI_PROBES 8 #define MAX_VOXEL_GI_INSTANCES 8
struct GIProbeData { struct VoxelGIData {
mat4 xform; mat4 xform;
vec3 bounds; vec3 bounds;
float dynamic_range; float dynamic_range;
@ -90,12 +90,12 @@ struct GIProbeData {
uint mipmaps; uint mipmaps;
}; };
layout(set = 0, binding = 11, std140) uniform GIProbes { layout(set = 0, binding = 11, std140) uniform VoxelGIs {
GIProbeData data[MAX_GI_PROBES]; VoxelGIData data[MAX_VOXEL_GI_INSTANCES];
} }
gi_probes; voxel_gi_instances;
layout(set = 0, binding = 12) uniform texture3D gi_probe_textures[MAX_GI_PROBES]; layout(set = 0, binding = 12) uniform texture3D voxel_gi_textures[MAX_VOXEL_GI_INSTANCES];
layout(set = 0, binding = 13) uniform sampler linear_sampler_with_mipmaps; layout(set = 0, binding = 13) uniform sampler linear_sampler_with_mipmaps;
@ -104,7 +104,7 @@ layout(set = 0, binding = 13) uniform sampler linear_sampler_with_mipmaps;
// SDFGI Integration on set 1 // SDFGI Integration on set 1
#define SDFGI_MAX_CASCADES 8 #define SDFGI_MAX_CASCADES 8
struct SDFGIProbeCascadeData { struct SDFVoxelGICascadeData {
vec3 position; vec3 position;
float to_probe; float to_probe;
ivec3 probe_world_offset; ivec3 probe_world_offset;
@ -135,7 +135,7 @@ layout(set = 1, binding = 0, std140) uniform SDFGI {
vec3 cascade_probe_size; vec3 cascade_probe_size;
uint pad5; uint pad5;
SDFGIProbeCascadeData cascades[SDFGI_MAX_CASCADES]; SDFVoxelGICascadeData cascades[SDFGI_MAX_CASCADES];
} }
sdfgi; sdfgi;
@ -162,7 +162,7 @@ layout(set = 0, binding = 14, std140) uniform Params {
float detail_spread; float detail_spread;
float gi_inject; float gi_inject;
uint max_gi_probes; uint max_voxel_gi_instances;
uint cluster_type_size; uint cluster_type_size;
vec2 screen_size; vec2 screen_size;
@ -533,21 +533,21 @@ void main() {
vec3 world_pos = mat3(params.cam_rotation) * view_pos; vec3 world_pos = mat3(params.cam_rotation) * view_pos;
for (uint i = 0; i < params.max_gi_probes; i++) { for (uint i = 0; i < params.max_voxel_gi_instances; i++) {
vec3 position = (gi_probes.data[i].xform * vec4(world_pos, 1.0)).xyz; vec3 position = (voxel_gi_instances.data[i].xform * vec4(world_pos, 1.0)).xyz;
//this causes corrupted pixels, i have no idea why.. //this causes corrupted pixels, i have no idea why..
if (all(bvec2(all(greaterThanEqual(position, vec3(0.0))), all(lessThan(position, gi_probes.data[i].bounds))))) { if (all(bvec2(all(greaterThanEqual(position, vec3(0.0))), all(lessThan(position, voxel_gi_instances.data[i].bounds))))) {
position /= gi_probes.data[i].bounds; position /= voxel_gi_instances.data[i].bounds;
vec4 light = vec4(0.0); vec4 light = vec4(0.0);
for (uint j = 0; j < gi_probes.data[i].mipmaps; j++) { for (uint j = 0; j < voxel_gi_instances.data[i].mipmaps; j++) {
vec4 slight = textureLod(sampler3D(gi_probe_textures[i], linear_sampler_with_mipmaps), position, float(j)); vec4 slight = textureLod(sampler3D(voxel_gi_textures[i], linear_sampler_with_mipmaps), position, float(j));
float a = (1.0 - light.a); float a = (1.0 - light.a);
light += a * slight; light += a * slight;
} }
light.rgb *= gi_probes.data[i].dynamic_range * params.gi_inject; light.rgb *= voxel_gi_instances.data[i].dynamic_range * params.gi_inject;
total_light += light.rgb; total_light += light.rgb;
} }

View file

@ -196,7 +196,7 @@ public:
virtual void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) = 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 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 voxel_gi_set_quality(RS::VoxelGIQuality) = 0;
virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) = 0; virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) = 0;

View file

@ -190,26 +190,26 @@ void RendererSceneCull::_instance_pair(Instance *p_A, Instance *p_B) {
((RendererSceneCull *)self)->_instance_queue_update(A, false, false); //need to update capture ((RendererSceneCull *)self)->_instance_queue_update(A, false, false); //need to update capture
} }
} else if (self->geometry_instance_pair_mask & (1 << RS::INSTANCE_GI_PROBE) && B->base_type == RS::INSTANCE_GI_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { } else if (self->geometry_instance_pair_mask & (1 << RS::INSTANCE_VOXEL_GI) && B->base_type == RS::INSTANCE_VOXEL_GI && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data); InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
geom->gi_probes.insert(B); geom->voxel_gi_instances.insert(B);
if (A->dynamic_gi) { if (A->dynamic_gi) {
gi_probe->dynamic_geometries.insert(A); voxel_gi->dynamic_geometries.insert(A);
} else { } else {
gi_probe->geometries.insert(A); voxel_gi->geometries.insert(A);
} }
if (A->scenario && A->array_index >= 0) { if (A->scenario && A->array_index >= 0) {
InstanceData &idata = A->scenario->instance_data[A->array_index]; InstanceData &idata = A->scenario->instance_data[A->array_index];
idata.flags |= InstanceData::FLAG_GEOM_GI_PROBE_DIRTY; idata.flags |= InstanceData::FLAG_GEOM_VOXEL_GI_DIRTY;
} }
} else if (B->base_type == RS::INSTANCE_GI_PROBE && A->base_type == RS::INSTANCE_LIGHT) { } else if (B->base_type == RS::INSTANCE_VOXEL_GI && A->base_type == RS::INSTANCE_LIGHT) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data); InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(B->base_data);
gi_probe->lights.insert(A); voxel_gi->lights.insert(A);
} else if (B->base_type == RS::INSTANCE_PARTICLES_COLLISION && A->base_type == RS::INSTANCE_PARTICLES) { } else if (B->base_type == RS::INSTANCE_PARTICLES_COLLISION && A->base_type == RS::INSTANCE_PARTICLES) {
InstanceParticlesCollisionData *collision = static_cast<InstanceParticlesCollisionData *>(B->base_data); InstanceParticlesCollisionData *collision = static_cast<InstanceParticlesCollisionData *>(B->base_data);
RSG::storage->particles_add_collision(A->base, collision->instance); RSG::storage->particles_add_collision(A->base, collision->instance);
@ -281,25 +281,25 @@ void RendererSceneCull::_instance_unpair(Instance *p_A, Instance *p_B) {
((RendererSceneCull *)self)->_instance_queue_update(A, false, false); //need to update capture ((RendererSceneCull *)self)->_instance_queue_update(A, false, false); //need to update capture
} }
} else if (self->geometry_instance_pair_mask & (1 << RS::INSTANCE_GI_PROBE) && B->base_type == RS::INSTANCE_GI_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { } else if (self->geometry_instance_pair_mask & (1 << RS::INSTANCE_VOXEL_GI) && B->base_type == RS::INSTANCE_VOXEL_GI && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data); InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
geom->gi_probes.erase(B); geom->voxel_gi_instances.erase(B);
if (A->dynamic_gi) { if (A->dynamic_gi) {
gi_probe->dynamic_geometries.erase(A); voxel_gi->dynamic_geometries.erase(A);
} else { } else {
gi_probe->geometries.erase(A); voxel_gi->geometries.erase(A);
} }
if (A->scenario && A->array_index >= 0) { if (A->scenario && A->array_index >= 0) {
InstanceData &idata = A->scenario->instance_data[A->array_index]; InstanceData &idata = A->scenario->instance_data[A->array_index];
idata.flags |= InstanceData::FLAG_GEOM_GI_PROBE_DIRTY; idata.flags |= InstanceData::FLAG_GEOM_VOXEL_GI_DIRTY;
} }
} else if (B->base_type == RS::INSTANCE_GI_PROBE && A->base_type == RS::INSTANCE_LIGHT) { } else if (B->base_type == RS::INSTANCE_VOXEL_GI && A->base_type == RS::INSTANCE_LIGHT) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data); InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(B->base_data);
gi_probe->lights.erase(A); voxel_gi->lights.erase(A);
} else if (B->base_type == RS::INSTANCE_PARTICLES_COLLISION && A->base_type == RS::INSTANCE_PARTICLES) { } else if (B->base_type == RS::INSTANCE_PARTICLES_COLLISION && A->base_type == RS::INSTANCE_PARTICLES) {
InstanceParticlesCollisionData *collision = static_cast<InstanceParticlesCollisionData *>(B->base_data); InstanceParticlesCollisionData *collision = static_cast<InstanceParticlesCollisionData *>(B->base_data);
RSG::storage->particles_remove_collision(A->base, collision->instance); RSG::storage->particles_remove_collision(A->base, collision->instance);
@ -494,23 +494,23 @@ void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) {
} }
scene_render->free(lightmap_data->instance); scene_render->free(lightmap_data->instance);
} break; } break;
case RS::INSTANCE_GI_PROBE: { case RS::INSTANCE_VOXEL_GI: {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data); InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(instance->base_data);
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (gi_probe->geometries.size()) { if (voxel_gi->geometries.size()) {
ERR_PRINT("BUG, indexing did not unpair geometries from GIProbe."); ERR_PRINT("BUG, indexing did not unpair geometries from VoxelGI.");
} }
#endif #endif
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (gi_probe->lights.size()) { if (voxel_gi->lights.size()) {
ERR_PRINT("BUG, indexing did not unpair lights from GIProbe."); ERR_PRINT("BUG, indexing did not unpair lights from VoxelGI.");
} }
#endif #endif
if (gi_probe->update_element.in_list()) { if (voxel_gi->update_element.in_list()) {
gi_probe_update_list.remove(&gi_probe->update_element); voxel_gi_update_list.remove(&voxel_gi->update_element);
} }
scene_render->free(gi_probe->probe_instance); scene_render->free(voxel_gi->probe_instance);
} break; } break;
case RS::INSTANCE_OCCLUDER: { case RS::INSTANCE_OCCLUDER: {
@ -602,16 +602,16 @@ void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) {
instance->base_data = lightmap_data; instance->base_data = lightmap_data;
lightmap_data->instance = scene_render->lightmap_instance_create(p_base); lightmap_data->instance = scene_render->lightmap_instance_create(p_base);
} break; } break;
case RS::INSTANCE_GI_PROBE: { case RS::INSTANCE_VOXEL_GI: {
InstanceGIProbeData *gi_probe = memnew(InstanceGIProbeData); InstanceVoxelGIData *voxel_gi = memnew(InstanceVoxelGIData);
instance->base_data = gi_probe; instance->base_data = voxel_gi;
gi_probe->owner = instance; voxel_gi->owner = instance;
if (scenario && !gi_probe->update_element.in_list()) { if (scenario && !voxel_gi->update_element.in_list()) {
gi_probe_update_list.add(&gi_probe->update_element); voxel_gi_update_list.add(&voxel_gi->update_element);
} }
gi_probe->probe_instance = scene_render->gi_probe_instance_create(p_base); voxel_gi->probe_instance = scene_render->voxel_gi_instance_create(p_base);
} break; } break;
case RS::INSTANCE_OCCLUDER: { case RS::INSTANCE_OCCLUDER: {
@ -668,22 +668,22 @@ void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
case RS::INSTANCE_PARTICLES_COLLISION: { case RS::INSTANCE_PARTICLES_COLLISION: {
heightfield_particle_colliders_update_list.erase(instance); heightfield_particle_colliders_update_list.erase(instance);
} break; } break;
case RS::INSTANCE_GI_PROBE: { case RS::INSTANCE_VOXEL_GI: {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data); InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(instance->base_data);
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (gi_probe->geometries.size()) { if (voxel_gi->geometries.size()) {
ERR_PRINT("BUG, indexing did not unpair geometries from GIProbe."); ERR_PRINT("BUG, indexing did not unpair geometries from VoxelGI.");
} }
#endif #endif
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (gi_probe->lights.size()) { if (voxel_gi->lights.size()) {
ERR_PRINT("BUG, indexing did not unpair lights from GIProbe."); ERR_PRINT("BUG, indexing did not unpair lights from VoxelGI.");
} }
#endif #endif
if (gi_probe->update_element.in_list()) { if (voxel_gi->update_element.in_list()) {
gi_probe_update_list.remove(&gi_probe->update_element); voxel_gi_update_list.remove(&voxel_gi->update_element);
} }
} break; } break;
case RS::INSTANCE_OCCLUDER: { case RS::INSTANCE_OCCLUDER: {
@ -714,10 +714,10 @@ void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
light->D = scenario->directional_lights.push_back(instance); light->D = scenario->directional_lights.push_back(instance);
} }
} break; } break;
case RS::INSTANCE_GI_PROBE: { case RS::INSTANCE_VOXEL_GI: {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data); InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(instance->base_data);
if (!gi_probe->update_element.in_list()) { if (!voxel_gi->update_element.in_list()) {
gi_probe_update_list.add(&gi_probe->update_element); voxel_gi_update_list.add(&voxel_gi->update_element);
} }
} break; } break;
case RS::INSTANCE_OCCLUDER: { case RS::INSTANCE_OCCLUDER: {
@ -1253,10 +1253,10 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
InstanceLightmapData *lightmap = static_cast<InstanceLightmapData *>(p_instance->base_data); InstanceLightmapData *lightmap = static_cast<InstanceLightmapData *>(p_instance->base_data);
scene_render->lightmap_instance_set_transform(lightmap->instance, p_instance->transform); scene_render->lightmap_instance_set_transform(lightmap->instance, p_instance->transform);
} else if (p_instance->base_type == RS::INSTANCE_GI_PROBE) { } else if (p_instance->base_type == RS::INSTANCE_VOXEL_GI) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(p_instance->base_data); InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(p_instance->base_data);
scene_render->gi_probe_instance_set_transform_to_data(gi_probe->probe_instance, p_instance->transform); scene_render->voxel_gi_instance_set_transform_to_data(voxel_gi->probe_instance, p_instance->transform);
} else if (p_instance->base_type == RS::INSTANCE_PARTICLES) { } else if (p_instance->base_type == RS::INSTANCE_PARTICLES) {
RSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform); RSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform);
} else if (p_instance->base_type == RS::INSTANCE_PARTICLES_COLLISION) { } else if (p_instance->base_type == RS::INSTANCE_PARTICLES_COLLISION) {
@ -1371,8 +1371,8 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
case RS::INSTANCE_LIGHTMAP: { case RS::INSTANCE_LIGHTMAP: {
idata.instance_data_rid = static_cast<InstanceLightmapData *>(p_instance->base_data)->instance.get_id(); idata.instance_data_rid = static_cast<InstanceLightmapData *>(p_instance->base_data)->instance.get_id();
} break; } break;
case RS::INSTANCE_GI_PROBE: { case RS::INSTANCE_VOXEL_GI: {
idata.instance_data_rid = static_cast<InstanceGIProbeData *>(p_instance->base_data)->probe_instance.get_id(); idata.instance_data_rid = static_cast<InstanceVoxelGIData *>(p_instance->base_data)->probe_instance.get_id();
} break; } break;
default: { default: {
} }
@ -1425,7 +1425,7 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) { if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
pair.pair_mask |= 1 << RS::INSTANCE_LIGHT; pair.pair_mask |= 1 << RS::INSTANCE_LIGHT;
pair.pair_mask |= 1 << RS::INSTANCE_GI_PROBE; pair.pair_mask |= 1 << RS::INSTANCE_VOXEL_GI;
pair.pair_mask |= 1 << RS::INSTANCE_LIGHTMAP; pair.pair_mask |= 1 << RS::INSTANCE_LIGHTMAP;
if (p_instance->base_type == RS::INSTANCE_PARTICLES) { if (p_instance->base_type == RS::INSTANCE_PARTICLES) {
pair.pair_mask |= 1 << RS::INSTANCE_PARTICLES_COLLISION; pair.pair_mask |= 1 << RS::INSTANCE_PARTICLES_COLLISION;
@ -1439,7 +1439,7 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
pair.bvh = &p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY]; pair.bvh = &p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY];
if (RSG::storage->light_get_bake_mode(p_instance->base) == RS::LIGHT_BAKE_DYNAMIC) { if (RSG::storage->light_get_bake_mode(p_instance->base) == RS::LIGHT_BAKE_DYNAMIC) {
pair.pair_mask |= (1 << RS::INSTANCE_GI_PROBE); pair.pair_mask |= (1 << RS::INSTANCE_VOXEL_GI);
pair.bvh2 = &p_instance->scenario->indexers[Scenario::INDEXER_VOLUMES]; pair.bvh2 = &p_instance->scenario->indexers[Scenario::INDEXER_VOLUMES];
} }
} else if (geometry_instance_pair_mask & (1 << RS::INSTANCE_REFLECTION_PROBE) && (p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE)) { } else if (geometry_instance_pair_mask & (1 << RS::INSTANCE_REFLECTION_PROBE) && (p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE)) {
@ -1451,7 +1451,7 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
} else if (p_instance->base_type == RS::INSTANCE_PARTICLES_COLLISION) { } else if (p_instance->base_type == RS::INSTANCE_PARTICLES_COLLISION) {
pair.pair_mask = (1 << RS::INSTANCE_PARTICLES); pair.pair_mask = (1 << RS::INSTANCE_PARTICLES);
pair.bvh = &p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY]; pair.bvh = &p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY];
} else if (p_instance->base_type == RS::INSTANCE_GI_PROBE) { } else if (p_instance->base_type == RS::INSTANCE_VOXEL_GI) {
//lights and geometries //lights and geometries
pair.pair_mask = RS::INSTANCE_GEOMETRY_MASK | (1 << RS::INSTANCE_LIGHT); pair.pair_mask = RS::INSTANCE_GEOMETRY_MASK | (1 << RS::INSTANCE_LIGHT);
pair.bvh = &p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY]; pair.bvh = &p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY];
@ -1504,7 +1504,7 @@ void RendererSceneCull::_unpair_instance(Instance *p_instance) {
scene_render->geometry_instance_pair_light_instances(geom->geometry_instance, nullptr, 0); scene_render->geometry_instance_pair_light_instances(geom->geometry_instance, nullptr, 0);
scene_render->geometry_instance_pair_reflection_probe_instances(geom->geometry_instance, nullptr, 0); scene_render->geometry_instance_pair_reflection_probe_instances(geom->geometry_instance, nullptr, 0);
scene_render->geometry_instance_pair_decal_instances(geom->geometry_instance, nullptr, 0); scene_render->geometry_instance_pair_decal_instances(geom->geometry_instance, nullptr, 0);
scene_render->geometry_instance_pair_gi_probe_instances(geom->geometry_instance, nullptr, 0); scene_render->geometry_instance_pair_voxel_gi_instances(geom->geometry_instance, nullptr, 0);
} }
} }
@ -1566,8 +1566,8 @@ void RendererSceneCull::_update_instance_aabb(Instance *p_instance) {
new_aabb = RSG::storage->decal_get_aabb(p_instance->base); new_aabb = RSG::storage->decal_get_aabb(p_instance->base);
} break; } break;
case RenderingServer::INSTANCE_GI_PROBE: { case RenderingServer::INSTANCE_VOXEL_GI: {
new_aabb = RSG::storage->gi_probe_get_bounds(p_instance->base); new_aabb = RSG::storage->voxel_gi_get_bounds(p_instance->base);
} break; } break;
case RenderingServer::INSTANCE_LIGHTMAP: { case RenderingServer::INSTANCE_LIGHTMAP: {
@ -2384,14 +2384,14 @@ void RendererSceneCull::_frustum_cull(CullData &cull_data, FrustumCullResult &cu
} else if (base_type == RS::INSTANCE_DECAL) { } else if (base_type == RS::INSTANCE_DECAL) {
cull_result.decals.push_back(RID::from_uint64(idata.instance_data_rid)); cull_result.decals.push_back(RID::from_uint64(idata.instance_data_rid));
} else if (base_type == RS::INSTANCE_GI_PROBE) { } else if (base_type == RS::INSTANCE_VOXEL_GI) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(idata.instance->base_data); InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(idata.instance->base_data);
cull_data.cull->lock.lock(); cull_data.cull->lock.lock();
if (!gi_probe->update_element.in_list()) { if (!voxel_gi->update_element.in_list()) {
gi_probe_update_list.add(&gi_probe->update_element); voxel_gi_update_list.add(&voxel_gi->update_element);
} }
cull_data.cull->lock.unlock(); cull_data.cull->lock.unlock();
cull_result.gi_probes.push_back(RID::from_uint64(idata.instance_data_rid)); cull_result.voxel_gi_instances.push_back(RID::from_uint64(idata.instance_data_rid));
} else if (base_type == RS::INSTANCE_LIGHTMAP) { } else if (base_type == RS::INSTANCE_LIGHTMAP) {
cull_result.lightmaps.push_back(RID::from_uint64(idata.instance_data_rid)); cull_result.lightmaps.push_back(RID::from_uint64(idata.instance_data_rid));
@ -2468,20 +2468,20 @@ void RendererSceneCull::_frustum_cull(CullData &cull_data, FrustumCullResult &cu
idata.flags &= ~uint32_t(InstanceData::FLAG_GEOM_DECAL_DIRTY); idata.flags &= ~uint32_t(InstanceData::FLAG_GEOM_DECAL_DIRTY);
} }
if (idata.flags & InstanceData::FLAG_GEOM_GI_PROBE_DIRTY) { if (idata.flags & InstanceData::FLAG_GEOM_VOXEL_GI_DIRTY) {
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data);
uint32_t idx = 0; uint32_t idx = 0;
for (Set<Instance *>::Element *E = geom->gi_probes.front(); E; E = E->next()) { for (Set<Instance *>::Element *E = geom->voxel_gi_instances.front(); E; E = E->next()) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(E->get()->base_data); InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(E->get()->base_data);
instance_pair_buffer[idx++] = gi_probe->probe_instance; instance_pair_buffer[idx++] = voxel_gi->probe_instance;
if (idx == MAX_INSTANCE_PAIRS) { if (idx == MAX_INSTANCE_PAIRS) {
break; break;
} }
} }
scene_render->geometry_instance_pair_gi_probe_instances(geom->geometry_instance, instance_pair_buffer, idx); scene_render->geometry_instance_pair_voxel_gi_instances(geom->geometry_instance, instance_pair_buffer, idx);
idata.flags &= ~uint32_t(InstanceData::FLAG_GEOM_GI_PROBE_DIRTY); idata.flags &= ~uint32_t(InstanceData::FLAG_GEOM_VOXEL_GI_DIRTY);
} }
if ((idata.flags & InstanceData::FLAG_LIGHTMAP_CAPTURE) && idata.instance->last_frame_pass != frame_number && !idata.instance->lightmap_target_sh.is_empty() && !idata.instance->lightmap_sh.is_empty()) { if ((idata.flags & InstanceData::FLAG_LIGHTMAP_CAPTURE) && idata.instance->last_frame_pass != frame_number && !idata.instance->lightmap_target_sh.is_empty() && !idata.instance->lightmap_sh.is_empty()) {
@ -2864,7 +2864,7 @@ void RendererSceneCull::_render_scene(const Transform3D &p_cam_transform, const
} }
RENDER_TIMESTAMP("Render Scene "); RENDER_TIMESTAMP("Render Scene ");
scene_render->render_scene(p_render_buffers, p_cam_transform, p_cam_projection, p_cam_orthogonal, frustum_cull_result.geometry_instances, frustum_cull_result.light_instances, frustum_cull_result.reflections, frustum_cull_result.gi_probes, frustum_cull_result.decals, frustum_cull_result.lightmaps, p_environment, camera_effects, p_shadow_atlas, occluders_tex, p_reflection_probe.is_valid() ? RID() : scenario->reflection_atlas, p_reflection_probe, p_reflection_probe_pass, p_screen_lod_threshold, render_shadow_data, max_shadows_used, render_sdfgi_data, cull.sdfgi.region_count, &sdfgi_update_data); scene_render->render_scene(p_render_buffers, p_cam_transform, p_cam_projection, p_cam_orthogonal, frustum_cull_result.geometry_instances, frustum_cull_result.light_instances, frustum_cull_result.reflections, frustum_cull_result.voxel_gi_instances, frustum_cull_result.decals, frustum_cull_result.lightmaps, p_environment, camera_effects, p_shadow_atlas, occluders_tex, p_reflection_probe.is_valid() ? RID() : scenario->reflection_atlas, p_reflection_probe, p_reflection_probe_pass, p_screen_lod_threshold, render_shadow_data, max_shadows_used, render_sdfgi_data, cull.sdfgi.region_count, &sdfgi_update_data);
for (uint32_t i = 0; i < max_shadows_used; i++) { for (uint32_t i = 0; i < max_shadows_used; i++) {
render_shadow_data[i].instances.clear(); render_shadow_data[i].instances.clear();
@ -2875,7 +2875,7 @@ void RendererSceneCull::_render_scene(const Transform3D &p_cam_transform, const
render_sdfgi_data[i].instances.clear(); render_sdfgi_data[i].instances.clear();
} }
// virtual void render_scene(RID p_render_buffers, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold,const RenderShadowData *p_render_shadows,int p_render_shadow_count,const RenderSDFGIData *p_render_sdfgi_regions,int p_render_sdfgi_region_count,const RenderSDFGIStaticLightData *p_render_sdfgi_static_lights=nullptr) = 0; // virtual void render_scene(RID p_render_buffers, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold,const RenderShadowData *p_render_shadows,int p_render_shadow_count,const RenderSDFGIData *p_render_sdfgi_regions,int p_render_sdfgi_region_count,const RenderSDFGIStaticLightData *p_render_sdfgi_static_lights=nullptr) = 0;
} }
RID RendererSceneCull::_render_get_environment(RID p_camera, RID p_scenario) { RID RendererSceneCull::_render_get_environment(RID p_camera, RID p_scenario) {
@ -3033,18 +3033,18 @@ void RendererSceneCull::render_probes() {
ref_probe = next; ref_probe = next;
} }
/* GI PROBES */ /* VOXEL GIS */
SelfList<InstanceGIProbeData> *gi_probe = gi_probe_update_list.first(); SelfList<InstanceVoxelGIData> *voxel_gi = voxel_gi_update_list.first();
if (gi_probe) { if (voxel_gi) {
RENDER_TIMESTAMP("Render GI Probes"); RENDER_TIMESTAMP("Render GI Probes");
} }
while (gi_probe) { while (voxel_gi) {
SelfList<InstanceGIProbeData> *next = gi_probe->next(); SelfList<InstanceVoxelGIData> *next = voxel_gi->next();
InstanceGIProbeData *probe = gi_probe->self(); InstanceVoxelGIData *probe = voxel_gi->self();
//Instance *instance_probe = probe->owner; //Instance *instance_probe = probe->owner;
//check if probe must be setup, but don't do if on the lighting thread //check if probe must be setup, but don't do if on the lighting thread
@ -3053,7 +3053,7 @@ void RendererSceneCull::render_probes() {
int cache_count = 0; int cache_count = 0;
{ {
int light_cache_size = probe->light_cache.size(); int light_cache_size = probe->light_cache.size();
const InstanceGIProbeData::LightCache *caches = probe->light_cache.ptr(); const InstanceVoxelGIData::LightCache *caches = probe->light_cache.ptr();
const RID *instance_caches = probe->light_instances.ptr(); const RID *instance_caches = probe->light_instances.ptr();
int idx = 0; //must count visible lights int idx = 0; //must count visible lights
@ -3068,7 +3068,7 @@ void RendererSceneCull::render_probes() {
} else if (idx >= light_cache_size) { } else if (idx >= light_cache_size) {
cache_dirty = true; cache_dirty = true;
} else { } else {
const InstanceGIProbeData::LightCache *cache = &caches[idx]; const InstanceVoxelGIData::LightCache *cache = &caches[idx];
if ( if (
instance_caches[idx] != instance_light->instance || instance_caches[idx] != instance_light->instance ||
@ -3100,7 +3100,7 @@ void RendererSceneCull::render_probes() {
} else if (idx >= light_cache_size) { } else if (idx >= light_cache_size) {
cache_dirty = true; cache_dirty = true;
} else { } else {
const InstanceGIProbeData::LightCache *cache = &caches[idx]; const InstanceVoxelGIData::LightCache *cache = &caches[idx];
if ( if (
instance_caches[idx] != instance_light->instance || instance_caches[idx] != instance_light->instance ||
@ -3129,14 +3129,14 @@ void RendererSceneCull::render_probes() {
cache_count = idx; cache_count = idx;
} }
bool update_lights = scene_render->gi_probe_needs_update(probe->probe_instance); bool update_lights = scene_render->voxel_gi_needs_update(probe->probe_instance);
if (cache_dirty) { if (cache_dirty) {
probe->light_cache.resize(cache_count); probe->light_cache.resize(cache_count);
probe->light_instances.resize(cache_count); probe->light_instances.resize(cache_count);
if (cache_count) { if (cache_count) {
InstanceGIProbeData::LightCache *caches = probe->light_cache.ptrw(); InstanceVoxelGIData::LightCache *caches = probe->light_cache.ptrw();
RID *instance_caches = probe->light_instances.ptrw(); RID *instance_caches = probe->light_instances.ptrw();
int idx = 0; //must count visible lights int idx = 0; //must count visible lights
@ -3147,7 +3147,7 @@ void RendererSceneCull::render_probes() {
continue; continue;
} }
InstanceGIProbeData::LightCache *cache = &caches[idx]; InstanceVoxelGIData::LightCache *cache = &caches[idx];
instance_caches[idx] = instance_light->instance; instance_caches[idx] = instance_light->instance;
cache->has_shadow = RSG::storage->light_has_shadow(instance->base); cache->has_shadow = RSG::storage->light_has_shadow(instance->base);
@ -3170,7 +3170,7 @@ void RendererSceneCull::render_probes() {
continue; continue;
} }
InstanceGIProbeData::LightCache *cache = &caches[idx]; InstanceVoxelGIData::LightCache *cache = &caches[idx];
instance_caches[idx] = instance_light->instance; instance_caches[idx] = instance_light->instance;
cache->has_shadow = RSG::storage->light_has_shadow(instance->base); cache->has_shadow = RSG::storage->light_has_shadow(instance->base);
@ -3203,30 +3203,30 @@ void RendererSceneCull::render_probes() {
} }
InstanceGeometryData *geom = (InstanceGeometryData *)ins->base_data; InstanceGeometryData *geom = (InstanceGeometryData *)ins->base_data;
if (ins->scenario && ins->array_index >= 0 && (ins->scenario->instance_data[ins->array_index].flags & InstanceData::FLAG_GEOM_GI_PROBE_DIRTY)) { if (ins->scenario && ins->array_index >= 0 && (ins->scenario->instance_data[ins->array_index].flags & InstanceData::FLAG_GEOM_VOXEL_GI_DIRTY)) {
uint32_t idx = 0; uint32_t idx = 0;
for (Set<Instance *>::Element *F = geom->gi_probes.front(); F; F = F->next()) { for (Set<Instance *>::Element *F = geom->voxel_gi_instances.front(); F; F = F->next()) {
InstanceGIProbeData *gi_probe2 = static_cast<InstanceGIProbeData *>(F->get()->base_data); InstanceVoxelGIData *voxel_gi2 = static_cast<InstanceVoxelGIData *>(F->get()->base_data);
instance_pair_buffer[idx++] = gi_probe2->probe_instance; instance_pair_buffer[idx++] = voxel_gi2->probe_instance;
if (idx == MAX_INSTANCE_PAIRS) { if (idx == MAX_INSTANCE_PAIRS) {
break; break;
} }
} }
scene_render->geometry_instance_pair_gi_probe_instances(geom->geometry_instance, instance_pair_buffer, idx); scene_render->geometry_instance_pair_voxel_gi_instances(geom->geometry_instance, instance_pair_buffer, idx);
ins->scenario->instance_data[ins->array_index].flags &= ~uint32_t(InstanceData::FLAG_GEOM_GI_PROBE_DIRTY); ins->scenario->instance_data[ins->array_index].flags &= ~uint32_t(InstanceData::FLAG_GEOM_VOXEL_GI_DIRTY);
} }
frustum_cull_result.geometry_instances.push_back(geom->geometry_instance); frustum_cull_result.geometry_instances.push_back(geom->geometry_instance);
} }
scene_render->gi_probe_update(probe->probe_instance, update_lights, probe->light_instances, frustum_cull_result.geometry_instances); scene_render->voxel_gi_update(probe->probe_instance, update_lights, probe->light_instances, frustum_cull_result.geometry_instances);
gi_probe_update_list.remove(gi_probe); voxel_gi_update_list.remove(voxel_gi);
gi_probe = next; voxel_gi = next;
} }
} }

View file

@ -253,7 +253,7 @@ public:
FLAG_GEOM_LIGHTING_DIRTY = (1 << 11), FLAG_GEOM_LIGHTING_DIRTY = (1 << 11),
FLAG_GEOM_REFLECTION_DIRTY = (1 << 12), FLAG_GEOM_REFLECTION_DIRTY = (1 << 12),
FLAG_GEOM_DECAL_DIRTY = (1 << 13), FLAG_GEOM_DECAL_DIRTY = (1 << 13),
FLAG_GEOM_GI_PROBE_DIRTY = (1 << 14), FLAG_GEOM_VOXEL_GI_DIRTY = (1 << 14),
FLAG_LIGHTMAP_CAPTURE = (1 << 15), FLAG_LIGHTMAP_CAPTURE = (1 << 15),
FLAG_USES_BAKED_LIGHT = (1 << 16), FLAG_USES_BAKED_LIGHT = (1 << 16),
FLAG_USES_MESH_INSTANCE = (1 << 17), FLAG_USES_MESH_INSTANCE = (1 << 17),
@ -535,7 +535,7 @@ public:
Set<Instance *> decals; Set<Instance *> decals;
Set<Instance *> reflection_probes; Set<Instance *> reflection_probes;
Set<Instance *> gi_probes; Set<Instance *> voxel_gi_instances;
Set<Instance *> lightmap_captures; Set<Instance *> lightmap_captures;
InstanceGeometryData() { InstanceGeometryData() {
@ -599,7 +599,7 @@ public:
} }
}; };
struct InstanceGIProbeData : public InstanceBaseData { struct InstanceVoxelGIData : public InstanceBaseData {
Instance *owner; Instance *owner;
Set<Instance *> geometries; Set<Instance *> geometries;
@ -629,16 +629,16 @@ public:
bool invalid; bool invalid;
uint32_t base_version; uint32_t base_version;
SelfList<InstanceGIProbeData> update_element; SelfList<InstanceVoxelGIData> update_element;
InstanceGIProbeData() : InstanceVoxelGIData() :
update_element(this) { update_element(this) {
invalid = true; invalid = true;
base_version = 0; base_version = 0;
} }
}; };
SelfList<InstanceGIProbeData>::List gi_probe_update_list; SelfList<InstanceVoxelGIData>::List voxel_gi_update_list;
struct InstanceLightmapData : public InstanceBaseData { struct InstanceLightmapData : public InstanceBaseData {
RID instance; RID instance;
@ -724,7 +724,7 @@ public:
PagedArray<RID> lightmaps; PagedArray<RID> lightmaps;
PagedArray<RID> reflections; PagedArray<RID> reflections;
PagedArray<RID> decals; PagedArray<RID> decals;
PagedArray<RID> gi_probes; PagedArray<RID> voxel_gi_instances;
PagedArray<RID> mesh_instances; PagedArray<RID> mesh_instances;
struct DirectionalShadow { struct DirectionalShadow {
@ -741,7 +741,7 @@ public:
lightmaps.clear(); lightmaps.clear();
reflections.clear(); reflections.clear();
decals.clear(); decals.clear();
gi_probes.clear(); voxel_gi_instances.clear();
mesh_instances.clear(); mesh_instances.clear();
for (int i = 0; i < RendererSceneRender::MAX_DIRECTIONAL_LIGHTS; i++) { for (int i = 0; i < RendererSceneRender::MAX_DIRECTIONAL_LIGHTS; i++) {
for (int j = 0; j < RendererSceneRender::MAX_DIRECTIONAL_LIGHT_CASCADES; j++) { for (int j = 0; j < RendererSceneRender::MAX_DIRECTIONAL_LIGHT_CASCADES; j++) {
@ -765,7 +765,7 @@ public:
lightmaps.reset(); lightmaps.reset();
reflections.reset(); reflections.reset();
decals.reset(); decals.reset();
gi_probes.reset(); voxel_gi_instances.reset();
mesh_instances.reset(); mesh_instances.reset();
for (int i = 0; i < RendererSceneRender::MAX_DIRECTIONAL_LIGHTS; i++) { for (int i = 0; i < RendererSceneRender::MAX_DIRECTIONAL_LIGHTS; i++) {
for (int j = 0; j < RendererSceneRender::MAX_DIRECTIONAL_LIGHT_CASCADES; j++) { for (int j = 0; j < RendererSceneRender::MAX_DIRECTIONAL_LIGHT_CASCADES; j++) {
@ -789,7 +789,7 @@ public:
lightmaps.merge_unordered(p_cull_result.lightmaps); lightmaps.merge_unordered(p_cull_result.lightmaps);
reflections.merge_unordered(p_cull_result.reflections); reflections.merge_unordered(p_cull_result.reflections);
decals.merge_unordered(p_cull_result.decals); decals.merge_unordered(p_cull_result.decals);
gi_probes.merge_unordered(p_cull_result.gi_probes); voxel_gi_instances.merge_unordered(p_cull_result.voxel_gi_instances);
mesh_instances.merge_unordered(p_cull_result.mesh_instances); mesh_instances.merge_unordered(p_cull_result.mesh_instances);
for (int i = 0; i < RendererSceneRender::MAX_DIRECTIONAL_LIGHTS; i++) { for (int i = 0; i < RendererSceneRender::MAX_DIRECTIONAL_LIGHTS; i++) {
@ -814,7 +814,7 @@ public:
lightmaps.set_page_pool(p_rid_pool); lightmaps.set_page_pool(p_rid_pool);
reflections.set_page_pool(p_rid_pool); reflections.set_page_pool(p_rid_pool);
decals.set_page_pool(p_rid_pool); decals.set_page_pool(p_rid_pool);
gi_probes.set_page_pool(p_rid_pool); voxel_gi_instances.set_page_pool(p_rid_pool);
mesh_instances.set_page_pool(p_rid_pool); mesh_instances.set_page_pool(p_rid_pool);
for (int i = 0; i < RendererSceneRender::MAX_DIRECTIONAL_LIGHTS; i++) { for (int i = 0; i < RendererSceneRender::MAX_DIRECTIONAL_LIGHTS; i++) {
for (int j = 0; j < RendererSceneRender::MAX_DIRECTIONAL_LIGHT_CASCADES; j++) { for (int j = 0; j < RendererSceneRender::MAX_DIRECTIONAL_LIGHT_CASCADES; j++) {
@ -975,7 +975,7 @@ public:
#define PASSBASE scene_render #define PASSBASE scene_render
PASS2(directional_shadow_atlas_set_size, int, bool) PASS2(directional_shadow_atlas_set_size, int, bool)
PASS1(gi_probe_set_quality, RS::GIProbeQuality) PASS1(voxel_gi_set_quality, RS::VoxelGIQuality)
/* SKY API */ /* SKY API */

View file

@ -65,7 +65,7 @@ public:
virtual void geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) = 0; virtual void geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) = 0;
virtual void geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) = 0; virtual void geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) = 0;
virtual void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) = 0; virtual void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) = 0;
virtual void geometry_instance_pair_gi_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_gi_probe_instances, uint32_t p_gi_probe_instance_count) = 0; virtual void geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) = 0;
virtual void geometry_instance_free(GeometryInstance *p_geometry_instance) = 0; virtual void geometry_instance_free(GeometryInstance *p_geometry_instance) = 0;
@ -187,12 +187,12 @@ public:
virtual RID lightmap_instance_create(RID p_lightmap) = 0; virtual RID lightmap_instance_create(RID p_lightmap) = 0;
virtual void lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) = 0; virtual void lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) = 0;
virtual RID gi_probe_instance_create(RID p_gi_probe) = 0; virtual RID voxel_gi_instance_create(RID p_voxel_gi) = 0;
virtual void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) = 0; virtual void voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) = 0;
virtual bool gi_probe_needs_update(RID p_probe) const = 0; virtual bool voxel_gi_needs_update(RID p_probe) const = 0;
virtual void gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<GeometryInstance *> &p_dynamic_objects) = 0; virtual void voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<GeometryInstance *> &p_dynamic_objects) = 0;
virtual void gi_probe_set_quality(RS::GIProbeQuality) = 0; virtual void voxel_gi_set_quality(RS::VoxelGIQuality) = 0;
struct RenderShadowData { struct RenderShadowData {
RID light; RID light;
@ -216,7 +216,7 @@ public:
uint32_t positional_light_count; uint32_t positional_light_count;
}; };
virtual void render_scene(RID p_render_buffers, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr) = 0; virtual void render_scene(RID p_render_buffers, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr) = 0;
virtual void render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) = 0; virtual void render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) = 0;
virtual void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<GeometryInstance *> &p_instances) = 0; virtual void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<GeometryInstance *> &p_instances) = 0;

View file

@ -413,53 +413,53 @@ public:
virtual AABB decal_get_aabb(RID p_decal) const = 0; virtual AABB decal_get_aabb(RID p_decal) const = 0;
/* GI PROBE API */ /* VOXEL GI API */
virtual RID gi_probe_allocate() = 0; virtual RID voxel_gi_allocate() = 0;
virtual void gi_probe_initialize(RID p_rid) = 0; virtual void voxel_gi_initialize(RID p_rid) = 0;
virtual void gi_probe_allocate_data(RID p_gi_probe, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) = 0; virtual void voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) = 0;
virtual AABB gi_probe_get_bounds(RID p_gi_probe) const = 0; virtual AABB voxel_gi_get_bounds(RID p_voxel_gi) const = 0;
virtual Vector3i gi_probe_get_octree_size(RID p_gi_probe) const = 0; virtual Vector3i voxel_gi_get_octree_size(RID p_voxel_gi) const = 0;
virtual Vector<uint8_t> gi_probe_get_octree_cells(RID p_gi_probe) const = 0; virtual Vector<uint8_t> voxel_gi_get_octree_cells(RID p_voxel_gi) const = 0;
virtual Vector<uint8_t> gi_probe_get_data_cells(RID p_gi_probe) const = 0; virtual Vector<uint8_t> voxel_gi_get_data_cells(RID p_voxel_gi) const = 0;
virtual Vector<uint8_t> gi_probe_get_distance_field(RID p_gi_probe) const = 0; virtual Vector<uint8_t> voxel_gi_get_distance_field(RID p_voxel_gi) const = 0;
virtual Vector<int> gi_probe_get_level_counts(RID p_gi_probe) const = 0; virtual Vector<int> voxel_gi_get_level_counts(RID p_voxel_gi) const = 0;
virtual Transform3D gi_probe_get_to_cell_xform(RID p_gi_probe) const = 0; virtual Transform3D voxel_gi_get_to_cell_xform(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_dynamic_range(RID p_gi_probe, float p_range) = 0; virtual void voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) = 0;
virtual float gi_probe_get_dynamic_range(RID p_gi_probe) const = 0; virtual float voxel_gi_get_dynamic_range(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_propagation(RID p_gi_probe, float p_range) = 0; virtual void voxel_gi_set_propagation(RID p_voxel_gi, float p_range) = 0;
virtual float gi_probe_get_propagation(RID p_gi_probe) const = 0; virtual float voxel_gi_get_propagation(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_energy(RID p_gi_probe, float p_energy) = 0; virtual void voxel_gi_set_energy(RID p_voxel_gi, float p_energy) = 0;
virtual float gi_probe_get_energy(RID p_gi_probe) const = 0; virtual float voxel_gi_get_energy(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_ao(RID p_gi_probe, float p_ao) = 0; virtual void voxel_gi_set_ao(RID p_voxel_gi, float p_ao) = 0;
virtual float gi_probe_get_ao(RID p_gi_probe) const = 0; virtual float voxel_gi_get_ao(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_ao_size(RID p_gi_probe, float p_strength) = 0; virtual void voxel_gi_set_ao_size(RID p_voxel_gi, float p_strength) = 0;
virtual float gi_probe_get_ao_size(RID p_gi_probe) const = 0; virtual float voxel_gi_get_ao_size(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_bias(RID p_gi_probe, float p_bias) = 0; virtual void voxel_gi_set_bias(RID p_voxel_gi, float p_bias) = 0;
virtual float gi_probe_get_bias(RID p_gi_probe) const = 0; virtual float voxel_gi_get_bias(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_normal_bias(RID p_gi_probe, float p_range) = 0; virtual void voxel_gi_set_normal_bias(RID p_voxel_gi, float p_range) = 0;
virtual float gi_probe_get_normal_bias(RID p_gi_probe) const = 0; virtual float voxel_gi_get_normal_bias(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_interior(RID p_gi_probe, bool p_enable) = 0; virtual void voxel_gi_set_interior(RID p_voxel_gi, bool p_enable) = 0;
virtual bool gi_probe_is_interior(RID p_gi_probe) const = 0; virtual bool voxel_gi_is_interior(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_use_two_bounces(RID p_gi_probe, bool p_enable) = 0; virtual void voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) = 0;
virtual bool gi_probe_is_using_two_bounces(RID p_gi_probe) const = 0; virtual bool voxel_gi_is_using_two_bounces(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_anisotropy_strength(RID p_gi_probe, float p_strength) = 0; virtual void voxel_gi_set_anisotropy_strength(RID p_voxel_gi, float p_strength) = 0;
virtual float gi_probe_get_anisotropy_strength(RID p_gi_probe) const = 0; virtual float voxel_gi_get_anisotropy_strength(RID p_voxel_gi) const = 0;
virtual uint32_t gi_probe_get_version(RID p_probe) = 0; virtual uint32_t voxel_gi_get_version(RID p_probe) = 0;
/* LIGHTMAP */ /* LIGHTMAP */

View file

@ -418,47 +418,47 @@ public:
/* BAKED LIGHT API */ /* BAKED LIGHT API */
FUNCRIDSPLIT(gi_probe) FUNCRIDSPLIT(voxel_gi)
FUNC8(gi_probe_allocate_data, RID, const Transform3D &, const AABB &, const Vector3i &, const Vector<uint8_t> &, const Vector<uint8_t> &, const Vector<uint8_t> &, const Vector<int> &) FUNC8(voxel_gi_allocate_data, RID, const Transform3D &, const AABB &, const Vector3i &, const Vector<uint8_t> &, const Vector<uint8_t> &, const Vector<uint8_t> &, const Vector<int> &)
FUNC1RC(AABB, gi_probe_get_bounds, RID) FUNC1RC(AABB, voxel_gi_get_bounds, RID)
FUNC1RC(Vector3i, gi_probe_get_octree_size, RID) FUNC1RC(Vector3i, voxel_gi_get_octree_size, RID)
FUNC1RC(Vector<uint8_t>, gi_probe_get_octree_cells, RID) FUNC1RC(Vector<uint8_t>, voxel_gi_get_octree_cells, RID)
FUNC1RC(Vector<uint8_t>, gi_probe_get_data_cells, RID) FUNC1RC(Vector<uint8_t>, voxel_gi_get_data_cells, RID)
FUNC1RC(Vector<uint8_t>, gi_probe_get_distance_field, RID) FUNC1RC(Vector<uint8_t>, voxel_gi_get_distance_field, RID)
FUNC1RC(Vector<int>, gi_probe_get_level_counts, RID) FUNC1RC(Vector<int>, voxel_gi_get_level_counts, RID)
FUNC1RC(Transform3D, gi_probe_get_to_cell_xform, RID) FUNC1RC(Transform3D, voxel_gi_get_to_cell_xform, RID)
FUNC2(gi_probe_set_dynamic_range, RID, float) FUNC2(voxel_gi_set_dynamic_range, RID, float)
FUNC1RC(float, gi_probe_get_dynamic_range, RID) FUNC1RC(float, voxel_gi_get_dynamic_range, RID)
FUNC2(gi_probe_set_propagation, RID, float) FUNC2(voxel_gi_set_propagation, RID, float)
FUNC1RC(float, gi_probe_get_propagation, RID) FUNC1RC(float, voxel_gi_get_propagation, RID)
FUNC2(gi_probe_set_energy, RID, float) FUNC2(voxel_gi_set_energy, RID, float)
FUNC1RC(float, gi_probe_get_energy, RID) FUNC1RC(float, voxel_gi_get_energy, RID)
FUNC2(gi_probe_set_ao, RID, float) FUNC2(voxel_gi_set_ao, RID, float)
FUNC1RC(float, gi_probe_get_ao, RID) FUNC1RC(float, voxel_gi_get_ao, RID)
FUNC2(gi_probe_set_ao_size, RID, float) FUNC2(voxel_gi_set_ao_size, RID, float)
FUNC1RC(float, gi_probe_get_ao_size, RID) FUNC1RC(float, voxel_gi_get_ao_size, RID)
FUNC2(gi_probe_set_bias, RID, float) FUNC2(voxel_gi_set_bias, RID, float)
FUNC1RC(float, gi_probe_get_bias, RID) FUNC1RC(float, voxel_gi_get_bias, RID)
FUNC2(gi_probe_set_normal_bias, RID, float) FUNC2(voxel_gi_set_normal_bias, RID, float)
FUNC1RC(float, gi_probe_get_normal_bias, RID) FUNC1RC(float, voxel_gi_get_normal_bias, RID)
FUNC2(gi_probe_set_interior, RID, bool) FUNC2(voxel_gi_set_interior, RID, bool)
FUNC1RC(bool, gi_probe_is_interior, RID) FUNC1RC(bool, voxel_gi_is_interior, RID)
FUNC2(gi_probe_set_use_two_bounces, RID, bool) FUNC2(voxel_gi_set_use_two_bounces, RID, bool)
FUNC1RC(bool, gi_probe_is_using_two_bounces, RID) FUNC1RC(bool, voxel_gi_is_using_two_bounces, RID)
FUNC2(gi_probe_set_anisotropy_strength, RID, float) FUNC2(voxel_gi_set_anisotropy_strength, RID, float)
FUNC1RC(float, gi_probe_get_anisotropy_strength, RID) FUNC1RC(float, voxel_gi_get_anisotropy_strength, RID)
/* LIGHTMAP */ /* LIGHTMAP */
@ -624,7 +624,7 @@ public:
#define server_name RSG::scene #define server_name RSG::scene
FUNC2(directional_shadow_atlas_set_size, int, bool) FUNC2(directional_shadow_atlas_set_size, int, bool)
FUNC1(gi_probe_set_quality, GIProbeQuality) FUNC1(voxel_gi_set_quality, VoxelGIQuality)
/* SKY API */ /* SKY API */

View file

@ -1569,32 +1569,32 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_cull_mask); ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_cull_mask);
#ifndef _MSC_VER #ifndef _MSC_VER
#warning TODO all giprobe methods need re-binding #warning TODO all voxel_gi methods need re-binding
#endif #endif
#if 0 #if 0
ClassDB::bind_method(D_METHOD("gi_probe_create"), &RenderingServer::gi_probe_create); ClassDB::bind_method(D_METHOD("voxel_gi_create"), &RenderingServer::voxel_gi_create);
ClassDB::bind_method(D_METHOD("gi_probe_set_bounds", "probe", "bounds"), &RenderingServer::gi_probe_set_bounds); ClassDB::bind_method(D_METHOD("voxel_gi_set_bounds", "probe", "bounds"), &RenderingServer::voxel_gi_set_bounds);
ClassDB::bind_method(D_METHOD("gi_probe_get_bounds", "probe"), &RenderingServer::gi_probe_get_bounds); ClassDB::bind_method(D_METHOD("voxel_gi_get_bounds", "probe"), &RenderingServer::voxel_gi_get_bounds);
ClassDB::bind_method(D_METHOD("gi_probe_set_cell_size", "probe", "range"), &RenderingServer::gi_probe_set_cell_size); ClassDB::bind_method(D_METHOD("voxel_gi_set_cell_size", "probe", "range"), &RenderingServer::voxel_gi_set_cell_size);
ClassDB::bind_method(D_METHOD("gi_probe_get_cell_size", "probe"), &RenderingServer::gi_probe_get_cell_size); ClassDB::bind_method(D_METHOD("voxel_gi_get_cell_size", "probe"), &RenderingServer::voxel_gi_get_cell_size);
ClassDB::bind_method(D_METHOD("gi_probe_set_to_cell_xform", "probe", "xform"), &RenderingServer::gi_probe_set_to_cell_xform); ClassDB::bind_method(D_METHOD("voxel_gi_set_to_cell_xform", "probe", "xform"), &RenderingServer::voxel_gi_set_to_cell_xform);
ClassDB::bind_method(D_METHOD("gi_probe_get_to_cell_xform", "probe"), &RenderingServer::gi_probe_get_to_cell_xform); ClassDB::bind_method(D_METHOD("voxel_gi_get_to_cell_xform", "probe"), &RenderingServer::voxel_gi_get_to_cell_xform);
ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_data", "probe", "data"), &RenderingServer::gi_probe_set_dynamic_data); ClassDB::bind_method(D_METHOD("voxel_gi_set_dynamic_data", "probe", "data"), &RenderingServer::voxel_gi_set_dynamic_data);
ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_data", "probe"), &RenderingServer::gi_probe_get_dynamic_data); ClassDB::bind_method(D_METHOD("voxel_gi_get_dynamic_data", "probe"), &RenderingServer::voxel_gi_get_dynamic_data);
ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_range", "probe", "range"), &RenderingServer::gi_probe_set_dynamic_range); ClassDB::bind_method(D_METHOD("voxel_gi_set_dynamic_range", "probe", "range"), &RenderingServer::voxel_gi_set_dynamic_range);
ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_range", "probe"), &RenderingServer::gi_probe_get_dynamic_range); ClassDB::bind_method(D_METHOD("voxel_gi_get_dynamic_range", "probe"), &RenderingServer::voxel_gi_get_dynamic_range);
ClassDB::bind_method(D_METHOD("gi_probe_set_energy", "probe", "energy"), &RenderingServer::gi_probe_set_energy); ClassDB::bind_method(D_METHOD("voxel_gi_set_energy", "probe", "energy"), &RenderingServer::voxel_gi_set_energy);
ClassDB::bind_method(D_METHOD("gi_probe_get_energy", "probe"), &RenderingServer::gi_probe_get_energy); ClassDB::bind_method(D_METHOD("voxel_gi_get_energy", "probe"), &RenderingServer::voxel_gi_get_energy);
ClassDB::bind_method(D_METHOD("gi_probe_set_bias", "probe", "bias"), &RenderingServer::gi_probe_set_bias); ClassDB::bind_method(D_METHOD("voxel_gi_set_bias", "probe", "bias"), &RenderingServer::voxel_gi_set_bias);
ClassDB::bind_method(D_METHOD("gi_probe_get_bias", "probe"), &RenderingServer::gi_probe_get_bias); ClassDB::bind_method(D_METHOD("voxel_gi_get_bias", "probe"), &RenderingServer::voxel_gi_get_bias);
ClassDB::bind_method(D_METHOD("gi_probe_set_normal_bias", "probe", "bias"), &RenderingServer::gi_probe_set_normal_bias); ClassDB::bind_method(D_METHOD("voxel_gi_set_normal_bias", "probe", "bias"), &RenderingServer::voxel_gi_set_normal_bias);
ClassDB::bind_method(D_METHOD("gi_probe_get_normal_bias", "probe"), &RenderingServer::gi_probe_get_normal_bias); ClassDB::bind_method(D_METHOD("voxel_gi_get_normal_bias", "probe"), &RenderingServer::voxel_gi_get_normal_bias);
ClassDB::bind_method(D_METHOD("gi_probe_set_propagation", "probe", "propagation"), &RenderingServer::gi_probe_set_propagation); ClassDB::bind_method(D_METHOD("voxel_gi_set_propagation", "probe", "propagation"), &RenderingServer::voxel_gi_set_propagation);
ClassDB::bind_method(D_METHOD("gi_probe_get_propagation", "probe"), &RenderingServer::gi_probe_get_propagation); ClassDB::bind_method(D_METHOD("voxel_gi_get_propagation", "probe"), &RenderingServer::voxel_gi_get_propagation);
ClassDB::bind_method(D_METHOD("gi_probe_set_interior", "probe", "enable"), &RenderingServer::gi_probe_set_interior); ClassDB::bind_method(D_METHOD("voxel_gi_set_interior", "probe", "enable"), &RenderingServer::voxel_gi_set_interior);
ClassDB::bind_method(D_METHOD("gi_probe_is_interior", "probe"), &RenderingServer::gi_probe_is_interior); ClassDB::bind_method(D_METHOD("voxel_gi_is_interior", "probe"), &RenderingServer::voxel_gi_is_interior);
ClassDB::bind_method(D_METHOD("gi_probe_set_compress", "probe", "enable"), &RenderingServer::gi_probe_set_compress); ClassDB::bind_method(D_METHOD("voxel_gi_set_compress", "probe", "enable"), &RenderingServer::voxel_gi_set_compress);
ClassDB::bind_method(D_METHOD("gi_probe_is_compressed", "probe"), &RenderingServer::gi_probe_is_compressed); ClassDB::bind_method(D_METHOD("voxel_gi_is_compressed", "probe"), &RenderingServer::voxel_gi_is_compressed);
#endif #endif
/* /*
ClassDB::bind_method(D_METHOD("lightmap_create()"), &RenderingServer::lightmap_capture_create); ClassDB::bind_method(D_METHOD("lightmap_create()"), &RenderingServer::lightmap_capture_create);
@ -2022,9 +2022,9 @@ void RenderingServer::_bind_methods() {
BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OVERDRAW); BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OVERDRAW);
BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_WIREFRAME); BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_WIREFRAME);
BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER); BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER);
BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_GI_PROBE_ALBEDO); BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_ALBEDO);
BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING); BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_LIGHTING);
BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION); BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION);
BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS); BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS);
BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS); BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS);
BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE); BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE);
@ -2117,7 +2117,7 @@ void RenderingServer::_bind_methods() {
BIND_ENUM_CONSTANT(INSTANCE_LIGHT); BIND_ENUM_CONSTANT(INSTANCE_LIGHT);
BIND_ENUM_CONSTANT(INSTANCE_REFLECTION_PROBE); BIND_ENUM_CONSTANT(INSTANCE_REFLECTION_PROBE);
BIND_ENUM_CONSTANT(INSTANCE_DECAL); BIND_ENUM_CONSTANT(INSTANCE_DECAL);
BIND_ENUM_CONSTANT(INSTANCE_GI_PROBE); BIND_ENUM_CONSTANT(INSTANCE_VOXEL_GI);
BIND_ENUM_CONSTANT(INSTANCE_LIGHTMAP); BIND_ENUM_CONSTANT(INSTANCE_LIGHTMAP);
BIND_ENUM_CONSTANT(INSTANCE_OCCLUDER); BIND_ENUM_CONSTANT(INSTANCE_OCCLUDER);
BIND_ENUM_CONSTANT(INSTANCE_MAX); BIND_ENUM_CONSTANT(INSTANCE_MAX);
@ -2324,9 +2324,9 @@ RenderingServer::RenderingServer() {
GLOBAL_DEF("rendering/global_illumination/gi/use_half_resolution", false); GLOBAL_DEF("rendering/global_illumination/gi/use_half_resolution", false);
GLOBAL_DEF("rendering/global_illumination/gi_probes/anisotropic", false); GLOBAL_DEF("rendering/global_illumination/voxel_gi/anisotropic", false);
GLOBAL_DEF("rendering/global_illumination/gi_probes/quality", 1); GLOBAL_DEF("rendering/global_illumination/voxel_gi/quality", 1);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/global_illumination/gi_probes/quality", PropertyInfo(Variant::INT, "rendering/global_illumination/gi_probes/quality", PROPERTY_HINT_ENUM, "Low (4 Cones - Fast),High (6 Cones - Slow)")); ProjectSettings::get_singleton()->set_custom_property_info("rendering/global_illumination/voxel_gi/quality", PropertyInfo(Variant::INT, "rendering/global_illumination/voxel_gi/quality", PROPERTY_HINT_ENUM, "Low (4 Cones - Fast),High (6 Cones - Slow)"));
GLOBAL_DEF("rendering/shading/overrides/force_vertex_shading", false); GLOBAL_DEF("rendering/shading/overrides/force_vertex_shading", false);
GLOBAL_DEF("rendering/shading/overrides/force_vertex_shading.mobile", true); GLOBAL_DEF("rendering/shading/overrides/force_vertex_shading.mobile", true);

View file

@ -548,56 +548,56 @@ public:
virtual void decal_set_fade(RID p_decal, float p_above, float p_below) = 0; virtual void decal_set_fade(RID p_decal, float p_above, float p_below) = 0;
virtual void decal_set_normal_fade(RID p_decal, float p_fade) = 0; virtual void decal_set_normal_fade(RID p_decal, float p_fade) = 0;
/* GI PROBE API */ /* VOXEL GI API */
virtual RID gi_probe_create() = 0; virtual RID voxel_gi_create() = 0;
virtual void gi_probe_allocate_data(RID p_gi_probe, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) = 0; virtual void voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) = 0;
virtual AABB gi_probe_get_bounds(RID p_gi_probe) const = 0; virtual AABB voxel_gi_get_bounds(RID p_voxel_gi) const = 0;
virtual Vector3i gi_probe_get_octree_size(RID p_gi_probe) const = 0; virtual Vector3i voxel_gi_get_octree_size(RID p_voxel_gi) const = 0;
virtual Vector<uint8_t> gi_probe_get_octree_cells(RID p_gi_probe) const = 0; virtual Vector<uint8_t> voxel_gi_get_octree_cells(RID p_voxel_gi) const = 0;
virtual Vector<uint8_t> gi_probe_get_data_cells(RID p_gi_probe) const = 0; virtual Vector<uint8_t> voxel_gi_get_data_cells(RID p_voxel_gi) const = 0;
virtual Vector<uint8_t> gi_probe_get_distance_field(RID p_gi_probe) const = 0; virtual Vector<uint8_t> voxel_gi_get_distance_field(RID p_voxel_gi) const = 0;
virtual Vector<int> gi_probe_get_level_counts(RID p_gi_probe) const = 0; virtual Vector<int> voxel_gi_get_level_counts(RID p_voxel_gi) const = 0;
virtual Transform3D gi_probe_get_to_cell_xform(RID p_gi_probe) const = 0; virtual Transform3D voxel_gi_get_to_cell_xform(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_dynamic_range(RID p_gi_probe, float p_range) = 0; virtual void voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) = 0;
virtual float gi_probe_get_dynamic_range(RID p_gi_probe) const = 0; virtual float voxel_gi_get_dynamic_range(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_propagation(RID p_gi_probe, float p_range) = 0; virtual void voxel_gi_set_propagation(RID p_voxel_gi, float p_range) = 0;
virtual float gi_probe_get_propagation(RID p_gi_probe) const = 0; virtual float voxel_gi_get_propagation(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_energy(RID p_gi_probe, float p_energy) = 0; virtual void voxel_gi_set_energy(RID p_voxel_gi, float p_energy) = 0;
virtual float gi_probe_get_energy(RID p_gi_probe) const = 0; virtual float voxel_gi_get_energy(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_ao(RID p_gi_probe, float p_ao) = 0; virtual void voxel_gi_set_ao(RID p_voxel_gi, float p_ao) = 0;
virtual float gi_probe_get_ao(RID p_gi_probe) const = 0; virtual float voxel_gi_get_ao(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_ao_size(RID p_gi_probe, float p_strength) = 0; virtual void voxel_gi_set_ao_size(RID p_voxel_gi, float p_strength) = 0;
virtual float gi_probe_get_ao_size(RID p_gi_probe) const = 0; virtual float voxel_gi_get_ao_size(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_bias(RID p_gi_probe, float p_bias) = 0; virtual void voxel_gi_set_bias(RID p_voxel_gi, float p_bias) = 0;
virtual float gi_probe_get_bias(RID p_gi_probe) const = 0; virtual float voxel_gi_get_bias(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_normal_bias(RID p_gi_probe, float p_range) = 0; virtual void voxel_gi_set_normal_bias(RID p_voxel_gi, float p_range) = 0;
virtual float gi_probe_get_normal_bias(RID p_gi_probe) const = 0; virtual float voxel_gi_get_normal_bias(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_interior(RID p_gi_probe, bool p_enable) = 0; virtual void voxel_gi_set_interior(RID p_voxel_gi, bool p_enable) = 0;
virtual bool gi_probe_is_interior(RID p_gi_probe) const = 0; virtual bool voxel_gi_is_interior(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_use_two_bounces(RID p_gi_probe, bool p_enable) = 0; virtual void voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) = 0;
virtual bool gi_probe_is_using_two_bounces(RID p_gi_probe) const = 0; virtual bool voxel_gi_is_using_two_bounces(RID p_voxel_gi) const = 0;
virtual void gi_probe_set_anisotropy_strength(RID p_gi_probe, float p_strength) = 0; virtual void voxel_gi_set_anisotropy_strength(RID p_voxel_gi, float p_strength) = 0;
virtual float gi_probe_get_anisotropy_strength(RID p_gi_probe) const = 0; virtual float voxel_gi_get_anisotropy_strength(RID p_voxel_gi) const = 0;
enum GIProbeQuality { enum VoxelGIQuality {
GI_PROBE_QUALITY_LOW, VOXEL_GI_QUALITY_LOW,
GI_PROBE_QUALITY_HIGH, VOXEL_GI_QUALITY_HIGH,
}; };
virtual void gi_probe_set_quality(GIProbeQuality) = 0; virtual void voxel_gi_set_quality(VoxelGIQuality) = 0;
/* LIGHTMAP */ /* LIGHTMAP */
@ -882,9 +882,9 @@ public:
VIEWPORT_DEBUG_DRAW_OVERDRAW, VIEWPORT_DEBUG_DRAW_OVERDRAW,
VIEWPORT_DEBUG_DRAW_WIREFRAME, VIEWPORT_DEBUG_DRAW_WIREFRAME,
VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER, VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER,
VIEWPORT_DEBUG_DRAW_GI_PROBE_ALBEDO, VIEWPORT_DEBUG_DRAW_VOXEL_GI_ALBEDO,
VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING, VIEWPORT_DEBUG_DRAW_VOXEL_GI_LIGHTING,
VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION, VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION,
VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS, VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS,
VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS, VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE, VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE,
@ -1145,7 +1145,7 @@ public:
INSTANCE_LIGHT, INSTANCE_LIGHT,
INSTANCE_REFLECTION_PROBE, INSTANCE_REFLECTION_PROBE,
INSTANCE_DECAL, INSTANCE_DECAL,
INSTANCE_GI_PROBE, INSTANCE_VOXEL_GI,
INSTANCE_LIGHTMAP, INSTANCE_LIGHTMAP,
INSTANCE_OCCLUDER, INSTANCE_OCCLUDER,
INSTANCE_MAX, INSTANCE_MAX,