EEVEE: Rename and move old gtao properties

- Move `gtao_distance` to view layer and rename to
  `ambient_occlusion_distance` (API change).
- Remove `gtao_quality` from the RNA (API change).
- Remove `use_gtao` (unused) from the RNA (API change).
- Rename `gtao_focus` to `fast_gi_bias` in the DNA (no API
  change).
- Rename `gtao_resolution` to `fast_gi_resolution` in the
  DNA (no API change).

Pull Request: https://projects.blender.org/blender/blender/pulls/140298
This commit is contained in:
Clément Foucault
2025-06-13 15:36:17 +02:00
committed by Clément Foucault
parent a996490b83
commit 1c29a2e2e5
19 changed files with 77 additions and 48 deletions

View File

@@ -141,8 +141,7 @@ class VIEWLAYER_PT_eevee_layer_passes_light(ViewLayerButtonsPanel, Panel):
col = layout.column()
col.active = view_layer.use_pass_ambient_occlusion
# TODO Move to view layer.
col.prop(context.scene.eevee, "gtao_distance", text="Occlusion Distance")
col.prop(view_layer_eevee, "ambient_occlusion_distance", text="Occlusion Distance")
class ViewLayerAOVPanelHelper(ViewLayerButtonsPanel):

View File

@@ -117,6 +117,7 @@ set(SRC_DNA_DEFAULTS_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_grease_pencil_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_image_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lattice_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_layer_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_light_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lightprobe_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_linestyle_defaults.h

View File

@@ -27,7 +27,7 @@
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 9
#define BLENDER_FILE_SUBVERSION 10
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@@ -37,6 +37,7 @@
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_defaults.h"
#include "DNA_layer_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
@@ -164,6 +165,8 @@ static ViewLayer *view_layer_add(const char *name)
}
ViewLayer *view_layer = MEM_callocN<ViewLayer>("View Layer");
*view_layer = *DNA_struct_default_get(ViewLayer);
view_layer->flag = VIEW_LAYER_RENDER | VIEW_LAYER_FREESTYLE;
STRNCPY_UTF8(view_layer->name, name);

View File

@@ -3438,7 +3438,7 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain)
scene->eevee.volumetric_light_clamp = 0.0f;
scene->eevee.volumetric_shadow_samples = 16;
scene->eevee.gtao_distance = 0.2f;
scene->eevee.fast_gi_distance = 0.2f;
scene->eevee.fast_gi_quality = 0.25f;
scene->eevee.bokeh_max_size = 100.0f;

View File

@@ -935,7 +935,7 @@ void blo_do_versions_410(FileData *fd, Library * /*lib*/, Main *bmain)
SceneEEVEE default_eevee = *DNA_struct_default_get(SceneEEVEE);
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
scene->eevee.gtao_thickness = default_eevee.gtao_thickness;
scene->eevee.gtao_focus = default_eevee.gtao_focus;
scene->eevee.fast_gi_bias = default_eevee.fast_gi_bias;
}
}

View File

@@ -881,7 +881,7 @@ void blo_do_versions_420(FileData *fd, Library * /*lib*/, Main *bmain)
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 10)) {
if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "int", "gtao_resolution")) {
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
scene->eevee.gtao_resolution = 2;
scene->eevee.fast_gi_resolution = 2;
}
}
}

View File

@@ -174,6 +174,14 @@ void blo_do_versions_500(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 10)) {
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
view_layer->eevee.ambient_occlusion_distance = scene->eevee.gtao_distance;
}
}
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.

View File

@@ -368,6 +368,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
/* Disable Z pass by default. */
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
view_layer->passflag &= ~SCE_PASS_Z;
view_layer->eevee.ambient_occlusion_distance = 10.0f;
}
if (scene->ed) {

View File

@@ -37,14 +37,15 @@ void AmbientOcclusion::init()
render_pass_enabled_ = inst_.film.enabled_passes_get() & EEVEE_RENDER_PASS_AO;
const SceneEEVEE &sce_eevee = inst_.scene->eevee;
const ViewLayerEEVEE &view_layer_eevee = inst_.view_layer->eevee;
data_.distance = sce_eevee.gtao_distance;
data_.distance = view_layer_eevee.ambient_occlusion_distance;
data_.gi_distance = (sce_eevee.fast_gi_distance > 0.0f) ? sce_eevee.fast_gi_distance : 1e16f;
/* AO node uses its own number of samples. */
data_.lod_factor_ao = 1.0f / (1.0f + sce_eevee.fast_gi_quality * 4.0f);
data_.lod_factor = (4.0f / sce_eevee.fast_gi_step_count) /
(1.0f + sce_eevee.fast_gi_quality * 4.0f);
data_.angle_bias = 1.0 / max_ff(1e-8f, 1.0 - sce_eevee.gtao_focus);
data_.angle_bias = 1.0 / max_ff(1e-8f, 1.0 - sce_eevee.fast_gi_bias);
data_.thickness_near = sce_eevee.fast_gi_thickness_near;
data_.thickness_far = sce_eevee.fast_gi_thickness_far;
/* Size is multiplied by 2 because it is applied in NDC [-1..1] range. */

View File

@@ -412,7 +412,7 @@ RayTraceResult RayTraceModule::render(RayTraceBuffer &rt_buffer,
const int resolution_scale = max_ii(1, power_of_2_max_i(options.resolution_scale));
const int horizon_resolution_scale = max_ii(
1, power_of_2_max_i(inst_.scene->eevee.gtao_resolution));
1, power_of_2_max_i(inst_.scene->eevee.fast_gi_resolution));
const int2 extent = inst_.film.render_extent_get();
const int2 tracing_res = math::divide_ceil(extent, int2(resolution_scale));

View File

@@ -0,0 +1,29 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup DNA
*/
#pragma once
/* clang-format off */
/* -------------------------------------------------------------------- */
/** \name Scene ViewLayer
* \{ */
#define _DNA_DEFAULT_ViewLayerEEVEE \
{ \
.ambient_occlusion_distance = 10.0f, \
}
#define _DNA_DEFAULT_ViewLayer \
{ \
.eevee = _DNA_DEFAULT_ViewLayerEEVEE, \
}
/** \} */
/* clang-format on */

View File

@@ -117,7 +117,7 @@ typedef struct LayerCollection {
/* Type containing EEVEE settings per view-layer */
typedef struct ViewLayerEEVEE {
int render_passes;
int _pad[1];
float ambient_occlusion_distance;
} ViewLayerEEVEE;
/** AOV Render-pass definition. */

View File

@@ -199,11 +199,8 @@
.volumetric_light_clamp = 0.0f, \
.volumetric_shadow_samples = 16, \
\
.gtao_distance = 0.2f, \
.gtao_thickness = 0.5f, \
.gtao_focus = 0.05f, \
.gtao_resolution = 2, \
\
.fast_gi_bias = 0.05f, \
.fast_gi_resolution = 2, \
.fast_gi_step_count = 8, \
.fast_gi_ray_count = 2, \
.fast_gi_quality = 0.25f, \

View File

@@ -1968,11 +1968,11 @@ typedef struct SceneEEVEE {
int volumetric_shadow_samples;
int volumetric_ray_depth;
float gtao_distance;
float gtao_thickness;
float gtao_focus;
int gtao_resolution;
float gtao_distance DNA_DEPRECATED;
float gtao_thickness DNA_DEPRECATED;
float fast_gi_bias;
int fast_gi_resolution;
int fast_gi_step_count;
int fast_gi_ray_count;
float fast_gi_quality;

View File

@@ -94,6 +94,7 @@
#include "DNA_image_types.h"
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
#include "DNA_layer_types.h"
#include "DNA_light_types.h"
#include "DNA_lightprobe_types.h"
#include "DNA_linestyle_types.h"
@@ -127,6 +128,7 @@
#include "DNA_grease_pencil_defaults.h"
#include "DNA_image_defaults.h"
#include "DNA_lattice_defaults.h"
#include "DNA_layer_defaults.h"
#include "DNA_light_defaults.h"
#include "DNA_lightprobe_defaults.h"
#include "DNA_linestyle_defaults.h"
@@ -193,6 +195,9 @@ SDNA_DEFAULT_DECL_STRUCT(GreasePencil);
/* DNA_lattice_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Lattice);
/* DNA_layer_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(ViewLayer);
/* DNA_light_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Light);
@@ -446,6 +451,9 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
/* DNA_lattice_defaults.h */
SDNA_DEFAULT_DECL(Lattice),
/* DNA_layer_defaults.h */
SDNA_DEFAULT_DECL(ViewLayer),
/* DNA_light_defaults.h */
SDNA_DEFAULT_DECL(Light),

View File

@@ -192,6 +192,8 @@ DNA_STRUCT_RENAME_MEMBER(SceneEEVEE, gtao_quality, fast_gi_quality)
DNA_STRUCT_RENAME_MEMBER(SceneEEVEE, motion_blur_position, motion_blur_position_deprecated)
DNA_STRUCT_RENAME_MEMBER(SceneEEVEE, motion_blur_shutter, motion_blur_shutter_deprecated)
DNA_STRUCT_RENAME_MEMBER(SceneEEVEE, shadow_cube_size, shadow_cube_size_deprecated)
DNA_STRUCT_RENAME_MEMBER(SceneEEVEE, gtao_resolution, fast_gi_resolution)
DNA_STRUCT_RENAME_MEMBER(SceneEEVEE, gtao_focus, fast_gi_bias)
DNA_STRUCT_RENAME_MEMBER(SpaceImage, pixel_snap_mode, pixel_round_mode)
DNA_STRUCT_RENAME_MEMBER(SpaceSeq, overlay_type, overlay_frame_type)
DNA_STRUCT_RENAME_MEMBER(Strip, machine, channel)

View File

@@ -4919,6 +4919,13 @@ static void rna_def_view_layer_eevee(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Transparent", "Deliver alpha blended surfaces in a separate pass");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
prop = RNA_def_property(srna, "ambient_occlusion_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_range(prop, 0.0f, 100000.0f);
RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
RNA_def_property_ui_text(
prop, "Distance", "Distance of object that contribute to the ambient occlusion effect");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
}
static void rna_def_view_layer_aovs(BlenderRNA *brna, PropertyRNA *cprop)
@@ -8454,32 +8461,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
"Enable custom start and end clip distances for volume computation");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
/* Ambient Occlusion */
prop = RNA_def_property(srna, "use_gtao", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", SCE_EEVEE_GTAO_ENABLED);
RNA_def_property_ui_text(prop,
"Ambient Occlusion",
"Enable ambient occlusion to simulate medium scale indirect shadowing");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
/* TODO: remove this, kept for EEVEE 4.2 compatibility,
* this is a duplicate of "fast_gi_quality"). */
prop = RNA_def_property(srna, "gtao_quality", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, nullptr, "fast_gi_quality");
RNA_def_property_ui_text(prop, "Trace Precision", "Precision of the horizon search");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
prop = RNA_def_property(srna, "gtao_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_ui_text(
prop, "Distance", "Distance of object that contribute to the ambient occlusion effect");
RNA_def_property_range(prop, 0.0f, 100000.0f);
RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
/* Fast GI approximation */
prop = RNA_def_property(srna, "use_fast_gi", PROP_BOOLEAN, PROP_NONE);
@@ -8545,7 +8526,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
prop = RNA_def_property(srna, "fast_gi_bias", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, nullptr, "gtao_focus");
RNA_def_property_ui_text(
prop, "Bias", "Bias the shading normal to reduce self intersection artifacts");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -8554,7 +8534,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
prop = RNA_def_property(srna, "fast_gi_resolution", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, nullptr, "gtao_resolution");
RNA_def_property_enum_items(prop, eevee_resolution_scale_items);
RNA_def_property_ui_text(prop,
"Resolution",

View File

@@ -83,7 +83,8 @@ def setup():
eevee.overscan_size = 50.0
# Ambient Occlusion Pass
eevee.gtao_distance = 1
for view_layer in scene.view_layers:
view_layer.eevee.ambient_occlusion_distance = 1
# Lights
eevee.light_threshold = 0.001