Merge pull request #107382 from Calinou/editor-lightmapprobe-add-gizmo-size-setting
Add a LightmapProbe gizmo size editor setting
This commit is contained in:
@ -518,6 +518,9 @@
|
||||
<member name="editors/3d_gizmos/gizmo_settings/bone_shape" type="int" setter="" getter="">
|
||||
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).
|
||||
</member>
|
||||
<member name="editors/3d_gizmos/gizmo_settings/lightmap_gi_probe_size" type="float" setter="" getter="">
|
||||
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.
|
||||
</member>
|
||||
<member name="editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size" type="float" setter="" getter="">
|
||||
Size of the disk gizmo displayed when editing [Path3D]'s tilt handles.
|
||||
</member>
|
||||
|
||||
@ -850,6 +850,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> 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.
|
||||
|
||||
@ -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,8 +132,9 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
LocalVector<Vector3> vertices;
|
||||
LocalVector<Color> colors;
|
||||
LocalVector<int> indices;
|
||||
float radius = 0.3;
|
||||
float radius = probe_size * 0.5f;
|
||||
|
||||
if (!Math::is_zero_approx(radius)) {
|
||||
// L2 Spherical Harmonics evaluation and diffuse convolution coefficients.
|
||||
const float sh_coeffs[5] = {
|
||||
static_cast<float>(sqrt(1.0 / (4.0 * Math::PI)) * Math::PI),
|
||||
@ -217,3 +221,4 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
|
||||
p_gizmo->add_mesh(mesh);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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,8 +73,10 @@ void LightmapProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
float stack_step = Math::PI / stack_count;
|
||||
|
||||
Vector<Vector3> 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;
|
||||
|
||||
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)
|
||||
@ -114,8 +119,8 @@ void LightmapProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
}
|
||||
}
|
||||
|
||||
const Ref<Material> icon = get_material("lightmap_probe_icon", p_gizmo);
|
||||
|
||||
p_gizmo->add_lines(lines, material_lines);
|
||||
}
|
||||
const Ref<Material> icon = get_material("lightmap_probe_icon", p_gizmo);
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user