diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 6bac7694dcc..efdb56a1d52 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -518,6 +518,9 @@
The shape of [Skeleton3D] bone gizmos in the 3D editor. [b]Wire[/b] is a thin line, while [b]Octahedron[/b] is a set of lines that represent a thicker hollow line pointing in a specific direction (similar to most 3D animation software).
+
+ Size of probe gizmos displayed when editing [LightmapGI] and [LightmapProbe] nodes. Setting this to [code]0.0[/code] will hide the probe spheres of [LightmapGI] and wireframes of [LightmapProbe] nodes, but will keep the wireframes linking probes from [LightmapGI] and billboard icons from [LightmapProbe] intact.
+
Size of the disk gizmo displayed when editing [Path3D]'s tilt handles.
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index c6cbe68dc60..44448d1803e 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -850,6 +850,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) {
_initial_set("editors/3d_gizmos/gizmo_settings/bone_axis_length", (float)0.1);
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d_gizmos/gizmo_settings/bone_shape", 1, "Wire,Octahedron");
EDITOR_SETTING_USAGE(Variant::FLOAT, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size", 0.8, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
+ EDITOR_SETTING_USAGE(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d_gizmos/gizmo_settings/lightmap_gi_probe_size", 0.4, "0.0,1.0,0.001,or_greater", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
// If a line is a multiple of this, it uses the primary grid color.
// Use a power of 2 value by default as it's more common to use powers of 2 in level design.
diff --git a/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.cpp b/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.cpp
index 3ed2e32c1a4..7eb205803a0 100644
--- a/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.cpp
+++ b/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.cpp
@@ -36,7 +36,10 @@
#include "scene/3d/lightmap_gi.h"
LightmapGIGizmoPlugin::LightmapGIGizmoPlugin() {
+ // NOTE: This gizmo only renders solid spheres for previewing indirect lighting on dynamic objects.
+ // The wireframe representation for LightmapProbe nodes is handled in LightmapProbeGizmoPlugin.
Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/lightmap_lines");
+ probe_size = EDITOR_GET("editors/3d_gizmos/gizmo_settings/lightmap_gi_probe_size");
gizmo_color.a = 0.1;
create_material("lightmap_lines", gizmo_color);
@@ -45,8 +48,8 @@ LightmapGIGizmoPlugin::LightmapGIGizmoPlugin() {
mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
// Fade out probes when camera gets too close to them.
mat->set_distance_fade(StandardMaterial3D::DISTANCE_FADE_PIXEL_DITHER);
- mat->set_distance_fade_min_distance(0.5);
- mat->set_distance_fade_max_distance(1.5);
+ mat->set_distance_fade_min_distance(probe_size * 0.5);
+ mat->set_distance_fade_max_distance(probe_size * 1.5);
mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, false);
mat->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
@@ -129,91 +132,93 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
LocalVector vertices;
LocalVector colors;
LocalVector indices;
- float radius = 0.3;
+ float radius = probe_size * 0.5f;
- // L2 Spherical Harmonics evaluation and diffuse convolution coefficients.
- const float sh_coeffs[5] = {
- static_cast(sqrt(1.0 / (4.0 * Math::PI)) * Math::PI),
- static_cast(sqrt(3.0 / (4.0 * Math::PI)) * Math::PI * 2.0 / 3.0),
- static_cast(sqrt(15.0 / (4.0 * Math::PI)) * Math::PI * 1.0 / 4.0),
- static_cast(sqrt(5.0 / (16.0 * Math::PI)) * Math::PI * 1.0 / 4.0),
- static_cast(sqrt(15.0 / (16.0 * Math::PI)) * Math::PI * 1.0 / 4.0)
- };
+ if (!Math::is_zero_approx(radius)) {
+ // L2 Spherical Harmonics evaluation and diffuse convolution coefficients.
+ const float sh_coeffs[5] = {
+ static_cast(sqrt(1.0 / (4.0 * Math::PI)) * Math::PI),
+ static_cast(sqrt(3.0 / (4.0 * Math::PI)) * Math::PI * 2.0 / 3.0),
+ static_cast(sqrt(15.0 / (4.0 * Math::PI)) * Math::PI * 1.0 / 4.0),
+ static_cast(sqrt(5.0 / (16.0 * Math::PI)) * Math::PI * 1.0 / 4.0),
+ static_cast(sqrt(15.0 / (16.0 * Math::PI)) * Math::PI * 1.0 / 4.0)
+ };
- for (int p = 0; p < points.size(); p++) {
- int vertex_base = vertices.size();
- Vector3 sh_col[9];
- for (int i = 0; i < 9; i++) {
- sh_col[i].x = sh[p * 9 + i].r;
- sh_col[i].y = sh[p * 9 + i].g;
- sh_col[i].z = sh[p * 9 + i].b;
- }
-
- for (int i = 0; i <= stack_count; ++i) {
- float stack_angle = Math::PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
- float xy = radius * Math::cos(stack_angle); // r * cos(u)
- float z = radius * Math::sin(stack_angle); // r * sin(u)
-
- // add (sector_count+1) vertices per stack
- // the first and last vertices have same position and normal, but different tex coords
- for (int j = 0; j <= sector_count; ++j) {
- float sector_angle = j * sector_step; // starting from 0 to 2pi
-
- // vertex position (x, y, z)
- float x = xy * Math::cos(sector_angle); // r * cos(u) * cos(v)
- float y = xy * Math::sin(sector_angle); // r * cos(u) * sin(v)
-
- Vector3 n = Vector3(x, z, y);
- vertices.push_back(points[p] + n);
- n.normalize();
-
- const Vector3 light = (sh_coeffs[0] * sh_col[0] +
- sh_coeffs[1] * sh_col[1] * n.y +
- sh_coeffs[1] * sh_col[2] * n.z +
- sh_coeffs[1] * sh_col[3] * n.x +
- sh_coeffs[2] * sh_col[4] * n.x * n.y +
- sh_coeffs[2] * sh_col[5] * n.y * n.z +
- sh_coeffs[3] * sh_col[6] * (3.0 * n.z * n.z - 1.0) +
- sh_coeffs[2] * sh_col[7] * n.x * n.z +
- sh_coeffs[4] * sh_col[8] * (n.x * n.x - n.y * n.y));
-
- colors.push_back(Color(light.x, light.y, light.z, 1));
+ for (int p = 0; p < points.size(); p++) {
+ int vertex_base = vertices.size();
+ Vector3 sh_col[9];
+ for (int i = 0; i < 9; i++) {
+ sh_col[i].x = sh[p * 9 + i].r;
+ sh_col[i].y = sh[p * 9 + i].g;
+ sh_col[i].z = sh[p * 9 + i].b;
}
- }
- for (int i = 0; i < stack_count; ++i) {
- int k1 = i * (sector_count + 1); // beginning of current stack
- int k2 = k1 + sector_count + 1; // beginning of next stack
+ for (int i = 0; i <= stack_count; ++i) {
+ float stack_angle = Math::PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
+ float xy = radius * Math::cos(stack_angle); // r * cos(u)
+ float z = radius * Math::sin(stack_angle); // r * sin(u)
- for (int j = 0; j < sector_count; ++j, ++k1, ++k2) {
- // 2 triangles per sector excluding first and last stacks
- // k1 => k2 => k1+1
- if (i != 0) {
- indices.push_back(vertex_base + k1);
- indices.push_back(vertex_base + k2);
- indices.push_back(vertex_base + k1 + 1);
+ // add (sector_count+1) vertices per stack
+ // the first and last vertices have same position and normal, but different tex coords
+ for (int j = 0; j <= sector_count; ++j) {
+ float sector_angle = j * sector_step; // starting from 0 to 2pi
+
+ // vertex position (x, y, z)
+ float x = xy * Math::cos(sector_angle); // r * cos(u) * cos(v)
+ float y = xy * Math::sin(sector_angle); // r * cos(u) * sin(v)
+
+ Vector3 n = Vector3(x, z, y);
+ vertices.push_back(points[p] + n);
+ n.normalize();
+
+ const Vector3 light = (sh_coeffs[0] * sh_col[0] +
+ sh_coeffs[1] * sh_col[1] * n.y +
+ sh_coeffs[1] * sh_col[2] * n.z +
+ sh_coeffs[1] * sh_col[3] * n.x +
+ sh_coeffs[2] * sh_col[4] * n.x * n.y +
+ sh_coeffs[2] * sh_col[5] * n.y * n.z +
+ sh_coeffs[3] * sh_col[6] * (3.0 * n.z * n.z - 1.0) +
+ sh_coeffs[2] * sh_col[7] * n.x * n.z +
+ sh_coeffs[4] * sh_col[8] * (n.x * n.x - n.y * n.y));
+
+ colors.push_back(Color(light.x, light.y, light.z, 1));
}
+ }
- // k1+1 => k2 => k2+1
- if (i != (stack_count - 1)) {
- indices.push_back(vertex_base + k1 + 1);
- indices.push_back(vertex_base + k2);
- indices.push_back(vertex_base + k2 + 1);
+ for (int i = 0; i < stack_count; ++i) {
+ int k1 = i * (sector_count + 1); // beginning of current stack
+ int k2 = k1 + sector_count + 1; // beginning of next stack
+
+ for (int j = 0; j < sector_count; ++j, ++k1, ++k2) {
+ // 2 triangles per sector excluding first and last stacks
+ // k1 => k2 => k1+1
+ if (i != 0) {
+ indices.push_back(vertex_base + k1);
+ indices.push_back(vertex_base + k2);
+ indices.push_back(vertex_base + k1 + 1);
+ }
+
+ // k1+1 => k2 => k2+1
+ if (i != (stack_count - 1)) {
+ indices.push_back(vertex_base + k1 + 1);
+ indices.push_back(vertex_base + k2);
+ indices.push_back(vertex_base + k2 + 1);
+ }
}
}
}
+
+ Array array;
+ array.resize(RS::ARRAY_MAX);
+ array[RS::ARRAY_VERTEX] = Vector(vertices);
+ array[RS::ARRAY_INDEX] = Vector(indices);
+ array[RS::ARRAY_COLOR] = Vector(colors);
+
+ Ref mesh;
+ mesh.instantiate();
+ mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, array, Array(), Dictionary(), 0); //no compression
+ mesh->surface_set_material(0, material_probes);
+
+ p_gizmo->add_mesh(mesh);
}
-
- Array array;
- array.resize(RS::ARRAY_MAX);
- array[RS::ARRAY_VERTEX] = Vector(vertices);
- array[RS::ARRAY_INDEX] = Vector(indices);
- array[RS::ARRAY_COLOR] = Vector(colors);
-
- Ref mesh;
- mesh.instantiate();
- mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, array, Array(), Dictionary(), 0); //no compression
- mesh->surface_set_material(0, material_probes);
-
- p_gizmo->add_mesh(mesh);
}
diff --git a/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.h b/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.h
index 94a521da369..882be1c7eff 100644
--- a/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.h
+++ b/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.h
@@ -35,6 +35,8 @@
class LightmapGIGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(LightmapGIGizmoPlugin, EditorNode3DGizmoPlugin);
+ float probe_size = 0.4f;
+
public:
bool has_gizmo(Node3D *p_spatial) override;
String get_gizmo_name() const override;
diff --git a/editor/plugins/gizmos/lightmap_probe_gizmo_plugin.cpp b/editor/plugins/gizmos/lightmap_probe_gizmo_plugin.cpp
index 9cf9b29db63..c01b3592f2b 100644
--- a/editor/plugins/gizmos/lightmap_probe_gizmo_plugin.cpp
+++ b/editor/plugins/gizmos/lightmap_probe_gizmo_plugin.cpp
@@ -36,9 +36,12 @@
#include "scene/3d/lightmap_probe.h"
LightmapProbeGizmoPlugin::LightmapProbeGizmoPlugin() {
+ // NOTE: This gizmo only renders LightmapProbe nodes as wireframes.
+ // The solid sphere representation is handled in LightmapGIGizmoPlugin.
create_icon_material("lightmap_probe_icon", EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("GizmoLightmapProbe"), EditorStringName(EditorIcons)));
Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/lightprobe_lines");
+ probe_size = EDITOR_GET("editors/3d_gizmos/gizmo_settings/lightmap_gi_probe_size");
gizmo_color.a = 0.3;
create_material("lightprobe_lines", gizmo_color);
@@ -70,52 +73,54 @@ void LightmapProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
float stack_step = Math::PI / stack_count;
Vector vertices;
- float radius = 0.2;
+ // Make the lines' radius slightly smaller than its mesh representation to avoid Z-fighting.
+ float radius = probe_size * 0.495f;
- for (int i = 0; i <= stack_count; ++i) {
- float stack_angle = Math::PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
- float xy = radius * Math::cos(stack_angle); // r * cos(u)
- float z = radius * Math::sin(stack_angle); // r * sin(u)
+ if (!Math::is_zero_approx(radius)) {
+ for (int i = 0; i <= stack_count; ++i) {
+ float stack_angle = Math::PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
+ float xy = radius * Math::cos(stack_angle); // r * cos(u)
+ float z = radius * Math::sin(stack_angle); // r * sin(u)
- // add (sector_count+1) vertices per stack
- // the first and last vertices have same position and normal, but different tex coords
- for (int j = 0; j <= sector_count; ++j) {
- float sector_angle = j * sector_step; // starting from 0 to 2pi
+ // add (sector_count+1) vertices per stack
+ // the first and last vertices have same position and normal, but different tex coords
+ for (int j = 0; j <= sector_count; ++j) {
+ float sector_angle = j * sector_step; // starting from 0 to 2pi
- // vertex position (x, y, z)
- float x = xy * Math::cos(sector_angle); // r * cos(u) * cos(v)
- float y = xy * Math::sin(sector_angle); // r * cos(u) * sin(v)
+ // vertex position (x, y, z)
+ float x = xy * Math::cos(sector_angle); // r * cos(u) * cos(v)
+ float y = xy * Math::sin(sector_angle); // r * cos(u) * sin(v)
- Vector3 n = Vector3(x, z, y);
- vertices.push_back(n);
- }
- }
-
- for (int i = 0; i < stack_count; ++i) {
- int k1 = i * (sector_count + 1); // beginning of current stack
- int k2 = k1 + sector_count + 1; // beginning of next stack
-
- for (int j = 0; j < sector_count; ++j, ++k1, ++k2) {
- // 2 triangles per sector excluding first and last stacks
- // k1 => k2 => k1+1
- if (i != 0) {
- lines.push_back(vertices[k1]);
- lines.push_back(vertices[k2]);
- lines.push_back(vertices[k1]);
- lines.push_back(vertices[k1 + 1]);
- }
-
- if (i != (stack_count - 1)) {
- lines.push_back(vertices[k1 + 1]);
- lines.push_back(vertices[k2]);
- lines.push_back(vertices[k2]);
- lines.push_back(vertices[k2 + 1]);
+ Vector3 n = Vector3(x, z, y);
+ vertices.push_back(n);
}
}
- }
+ for (int i = 0; i < stack_count; ++i) {
+ int k1 = i * (sector_count + 1); // beginning of current stack
+ int k2 = k1 + sector_count + 1; // beginning of next stack
+
+ for (int j = 0; j < sector_count; ++j, ++k1, ++k2) {
+ // 2 triangles per sector excluding first and last stacks
+ // k1 => k2 => k1+1
+ if (i != 0) {
+ lines.push_back(vertices[k1]);
+ lines.push_back(vertices[k2]);
+ lines.push_back(vertices[k1]);
+ lines.push_back(vertices[k1 + 1]);
+ }
+
+ if (i != (stack_count - 1)) {
+ lines.push_back(vertices[k1 + 1]);
+ lines.push_back(vertices[k2]);
+ lines.push_back(vertices[k2]);
+ lines.push_back(vertices[k2 + 1]);
+ }
+ }
+ }
+
+ p_gizmo->add_lines(lines, material_lines);
+ }
const Ref icon = get_material("lightmap_probe_icon", p_gizmo);
-
- p_gizmo->add_lines(lines, material_lines);
p_gizmo->add_unscaled_billboard(icon, 0.05);
}
diff --git a/editor/plugins/gizmos/lightmap_probe_gizmo_plugin.h b/editor/plugins/gizmos/lightmap_probe_gizmo_plugin.h
index 885ada5561c..a17d9b9c840 100644
--- a/editor/plugins/gizmos/lightmap_probe_gizmo_plugin.h
+++ b/editor/plugins/gizmos/lightmap_probe_gizmo_plugin.h
@@ -35,6 +35,8 @@
class LightmapProbeGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(LightmapProbeGizmoPlugin, EditorNode3DGizmoPlugin);
+ float probe_size = 0.4f;
+
public:
bool has_gizmo(Node3D *p_spatial) override;
String get_gizmo_name() const override;