Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a debug draw mode for displaying UV2 (lightmap) texel density #62987

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 36 additions & 17 deletions doc/classes/RenderingServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,14 @@
<description>
</description>
</method>
<method name="instance_geometry_set_lightmap_scale">
<return type="void" />
<param index="0" name="instance" type="RID" />
<param index="1" name="lightmap_scale" type="float" />
<description>
clayjohn marked this conversation as resolved.
Show resolved Hide resolved
Sets the lightmap scale for the given geometry instance.
</description>
</method>
<method name="instance_geometry_set_lod_bias">
<return type="void" />
<param index="0" name="instance" type="RID" />
Expand Down Expand Up @@ -1990,6 +1998,14 @@
Sets a mesh's custom aabb.
</description>
</method>
<method name="mesh_set_lightmap_size_hint">
<return type="void" />
<param index="0" name="mesh" type="RID" />
<param index="1" name="size" type="Vector2" />
<description>
Sets a mesh's lightmap size hint.
</description>
</method>
<method name="mesh_set_shadow_mesh">
<return type="void" />
<param index="0" name="mesh" type="RID" />
Expand Down Expand Up @@ -4185,44 +4201,47 @@
<constant name="VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION" value="8" enum="ViewportDebugDraw">
Objects are displayed with only the emission color from [VoxelGI]s.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS" value="9" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_UV2_TEXEL_DENSITY" value="9" enum="ViewportDebugDraw">
Objects are displayed with a checkerboard pattern indicative of their UV2 texel density. Each square of the checkerboard pattern is 10 texels by 10 texels in size.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS" value="10" enum="ViewportDebugDraw">
Draws the shadow atlas that stores shadows from [OmniLight3D]s and [SpotLight3D]s in the upper left quadrant of the [Viewport].
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS" value="10" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS" value="11" enum="ViewportDebugDraw">
Draws the shadow atlas that stores shadows from [DirectionalLight3D]s in the upper left quadrant of the [Viewport].
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE" value="11" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE" value="12" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SSAO" value="12" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_SSAO" value="13" enum="ViewportDebugDraw">
Draws the screen space ambient occlusion texture instead of the scene so that you can clearly see how it is affecting objects. In order for this display mode to work, you must have [member Environment.ssao_enabled] set in your [WorldEnvironment].
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SSIL" value="13" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_SSIL" value="14" enum="ViewportDebugDraw">
Draws the screen space indirect lighting texture instead of the scene so that you can clearly see how it is affecting objects. In order for this display mode to work, you must have [member Environment.ssil_enabled] set in your [WorldEnvironment].
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_PSSM_SPLITS" value="14" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_PSSM_SPLITS" value="15" enum="ViewportDebugDraw">
Colors each PSSM split for the [DirectionalLight3D]s in the scene a different color so you can see where the splits are. In order they will be colored red, green, blue, yellow.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_DECAL_ATLAS" value="15" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_DECAL_ATLAS" value="16" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SDFGI" value="16" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_SDFGI" value="17" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SDFGI_PROBES" value="17" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_SDFGI_PROBES" value="18" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_GI_BUFFER" value="18" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_GI_BUFFER" value="19" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_DISABLE_LOD" value="19" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_DISABLE_LOD" value="20" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_OMNI_LIGHTS" value="20" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_OMNI_LIGHTS" value="21" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_SPOT_LIGHTS" value="21" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_SPOT_LIGHTS" value="22" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_DECALS" value="22" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_DECALS" value="23" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_REFLECTION_PROBES" value="23" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_REFLECTION_PROBES" value="24" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_OCCLUDERS" value="24" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_OCCLUDERS" value="25" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_MOTION_VECTORS" value="25" enum="ViewportDebugDraw">
<constant name="VIEWPORT_DEBUG_DRAW_MOTION_VECTORS" value="26" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_VRS_DISABLED" value="0" enum="ViewportVRSMode">
VRS is disabled.
Expand Down
37 changes: 20 additions & 17 deletions doc/classes/Viewport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -417,45 +417,48 @@
<constant name="DEBUG_DRAW_VOXEL_GI_EMISSION" value="8" enum="DebugDraw">
Objects are displayed with only the emission color from [VoxelGI]s.
</constant>
<constant name="DEBUG_DRAW_SHADOW_ATLAS" value="9" enum="DebugDraw">
<constant name="DEBUG_DRAW_UV2_TEXEL_DENSITY" value="9" enum="DebugDraw">
Objects are displayed with a checkerboard pattern indicative of their UV2 texel density. Each square of the checkerboard pattern is 10 texels by 10 texels in size.
</constant>
<constant name="DEBUG_DRAW_SHADOW_ATLAS" value="10" enum="DebugDraw">
Draws the shadow atlas that stores shadows from [OmniLight3D]s and [SpotLight3D]s in the upper left quadrant of the [Viewport].
</constant>
<constant name="DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS" value="10" enum="DebugDraw">
<constant name="DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS" value="11" enum="DebugDraw">
Draws the shadow atlas that stores shadows from [DirectionalLight3D]s in the upper left quadrant of the [Viewport].
</constant>
<constant name="DEBUG_DRAW_SCENE_LUMINANCE" value="11" enum="DebugDraw">
<constant name="DEBUG_DRAW_SCENE_LUMINANCE" value="12" enum="DebugDraw">
</constant>
<constant name="DEBUG_DRAW_SSAO" value="12" enum="DebugDraw">
<constant name="DEBUG_DRAW_SSAO" value="13" enum="DebugDraw">
Draws the screen-space ambient occlusion texture instead of the scene so that you can clearly see how it is affecting objects. In order for this display mode to work, you must have [member Environment.ssao_enabled] set in your [WorldEnvironment].
</constant>
<constant name="DEBUG_DRAW_SSIL" value="13" enum="DebugDraw">
<constant name="DEBUG_DRAW_SSIL" value="14" enum="DebugDraw">
Draws the screen-space indirect lighting texture instead of the scene so that you can clearly see how it is affecting objects. In order for this display mode to work, you must have [member Environment.ssil_enabled] set in your [WorldEnvironment].
</constant>
<constant name="DEBUG_DRAW_PSSM_SPLITS" value="14" enum="DebugDraw">
<constant name="DEBUG_DRAW_PSSM_SPLITS" value="15" enum="DebugDraw">
Colors each PSSM split for the [DirectionalLight3D]s in the scene a different color so you can see where the splits are. In order, they will be colored red, green, blue, and yellow.
</constant>
<constant name="DEBUG_DRAW_DECAL_ATLAS" value="15" enum="DebugDraw">
<constant name="DEBUG_DRAW_DECAL_ATLAS" value="16" enum="DebugDraw">
Draws the decal atlas used by [Decal]s and light projector textures in the upper left quadrant of the [Viewport].
</constant>
<constant name="DEBUG_DRAW_SDFGI" value="16" enum="DebugDraw">
<constant name="DEBUG_DRAW_SDFGI" value="17" enum="DebugDraw">
</constant>
<constant name="DEBUG_DRAW_SDFGI_PROBES" value="17" enum="DebugDraw">
<constant name="DEBUG_DRAW_SDFGI_PROBES" value="18" enum="DebugDraw">
</constant>
<constant name="DEBUG_DRAW_GI_BUFFER" value="18" enum="DebugDraw">
<constant name="DEBUG_DRAW_GI_BUFFER" value="19" enum="DebugDraw">
</constant>
<constant name="DEBUG_DRAW_DISABLE_LOD" value="19" enum="DebugDraw">
<constant name="DEBUG_DRAW_DISABLE_LOD" value="20" enum="DebugDraw">
</constant>
<constant name="DEBUG_DRAW_CLUSTER_OMNI_LIGHTS" value="20" enum="DebugDraw">
<constant name="DEBUG_DRAW_CLUSTER_OMNI_LIGHTS" value="21" enum="DebugDraw">
</constant>
<constant name="DEBUG_DRAW_CLUSTER_SPOT_LIGHTS" value="21" enum="DebugDraw">
<constant name="DEBUG_DRAW_CLUSTER_SPOT_LIGHTS" value="22" enum="DebugDraw">
</constant>
<constant name="DEBUG_DRAW_CLUSTER_DECALS" value="22" enum="DebugDraw">
<constant name="DEBUG_DRAW_CLUSTER_DECALS" value="23" enum="DebugDraw">
</constant>
<constant name="DEBUG_DRAW_CLUSTER_REFLECTION_PROBES" value="23" enum="DebugDraw">
<constant name="DEBUG_DRAW_CLUSTER_REFLECTION_PROBES" value="24" enum="DebugDraw">
</constant>
<constant name="DEBUG_DRAW_OCCLUDERS" value="24" enum="DebugDraw">
<constant name="DEBUG_DRAW_OCCLUDERS" value="25" enum="DebugDraw">
</constant>
<constant name="DEBUG_DRAW_MOTION_VECTORS" value="25" enum="DebugDraw">
<constant name="DEBUG_DRAW_MOTION_VECTORS" value="26" enum="DebugDraw">
</constant>
<constant name="DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST" value="0" enum="DefaultCanvasItemTextureFilter">
The texture filter reads from the nearest pixel only. The simplest and fastest method of filtering, but the texture will look pixelized.
Expand Down
3 changes: 3 additions & 0 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ void RasterizerSceneGLES3::GeometryInstanceGLES3::_mark_dirty() {
void RasterizerSceneGLES3::GeometryInstanceGLES3::set_use_lightmap(RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) {
}

void RasterizerSceneGLES3::GeometryInstanceGLES3::set_lightmap_scale(float p_lightmap_scale) {
}

void RasterizerSceneGLES3::GeometryInstanceGLES3::set_lightmap_capture(const Color *p_sh9) {
}

Expand Down
1 change: 1 addition & 0 deletions drivers/gles3/rasterizer_scene_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ class RasterizerSceneGLES3 : public RendererSceneRender {

virtual void _mark_dirty() override;
virtual void set_use_lightmap(RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) override;
virtual void set_lightmap_scale(float p_lightmap_scale) override;
virtual void set_lightmap_capture(const Color *p_sh9) override;

virtual void pair_light_instances(const RID *p_light_instances, uint32_t p_light_instance_count) override;
Expand Down
51 changes: 51 additions & 0 deletions drivers/gles3/storage/material_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2291,6 +2291,57 @@ GLuint MaterialStorage::global_shader_parameters_get_uniform_buffer() const {
return global_shader_uniforms.buffer;
}

//An alternative way of allocating global shader uniforms.
//Allocates a single variable and returns its position in the global shader uniform buffer.
//Intended to be used for debug drawing purposes and should not be used for anything substantial.
int32_t MaterialStorage::global_shader_parameters_unit_variable_allocate() {
int32_t pos = _global_shader_uniform_allocate(1);
ERR_FAIL_COND_V_MSG(pos < 0, -1, "Too many instances using shader instance variables. Increase buffer size in Project Settings.");
global_shader_uniforms.buffer_usage[pos].elements = 1;
return pos;
}

void MaterialStorage::global_shader_parameters_unit_variable_free(int32_t p_pos) {
ERR_FAIL_COND(p_pos < 0);
global_shader_uniforms.buffer_usage[p_pos].elements = 0;
}

void MaterialStorage::global_shader_parameters_unit_variable_update(int32_t p_pos, const Variant &p_value) {
ERR_FAIL_COND(p_pos < 0);
ERR_FAIL_COND_MSG(p_value.get_type() > Variant::COLOR, "Unsupported variant type."); //anything greater not supported

const ShaderLanguage::DataType datatype_from_value[Variant::COLOR + 1] = {
ShaderLanguage::TYPE_MAX, //nil
ShaderLanguage::TYPE_BOOL, //bool
ShaderLanguage::TYPE_INT, //int
ShaderLanguage::TYPE_FLOAT, //float
ShaderLanguage::TYPE_MAX, //string
ShaderLanguage::TYPE_VEC2, //vec2
ShaderLanguage::TYPE_IVEC2, //vec2i
ShaderLanguage::TYPE_VEC4, //rect2
ShaderLanguage::TYPE_IVEC4, //rect2i
ShaderLanguage::TYPE_VEC3, // vec3
ShaderLanguage::TYPE_IVEC3, //vec3i
ShaderLanguage::TYPE_MAX, //xform2d not supported here
ShaderLanguage::TYPE_VEC4, //vec4
ShaderLanguage::TYPE_IVEC4, //vec4i
ShaderLanguage::TYPE_VEC4, //plane
ShaderLanguage::TYPE_VEC4, //quat
ShaderLanguage::TYPE_MAX, //aabb not supported here
ShaderLanguage::TYPE_MAX, //basis not supported here
ShaderLanguage::TYPE_MAX, //xform not supported here
ShaderLanguage::TYPE_MAX, //projection not supported here
ShaderLanguage::TYPE_VEC4 //color
};

ShaderLanguage::DataType datatype = datatype_from_value[p_value.get_type()];

ERR_FAIL_COND_MSG(datatype == ShaderLanguage::TYPE_MAX, "Unsupported variant type.");

_fill_std140_variant_ubo_value(datatype, 0, p_value, (uint8_t *)&global_shader_uniforms.buffer_values[p_pos]);
_global_shader_uniform_mark_buffer_dirty(p_pos, 1);
}

int32_t MaterialStorage::global_shader_parameters_instance_allocate(RID p_instance) {
ERR_FAIL_COND_V(global_shader_uniforms.instance_buffer_pos.has(p_instance), -1);
int32_t pos = _global_shader_uniform_allocate(ShaderLanguage::MAX_INSTANCE_UNIFORM_INDICES);
Expand Down
4 changes: 4 additions & 0 deletions drivers/gles3/storage/material_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@ class MaterialStorage : public RendererMaterialStorage {
virtual void global_shader_parameters_load_settings(bool p_load_textures = true) override;
virtual void global_shader_parameters_clear() override;

virtual int32_t global_shader_parameters_unit_variable_allocate() override;
virtual void global_shader_parameters_unit_variable_free(int32_t p_pos) override;
virtual void global_shader_parameters_unit_variable_update(int32_t p_pos, const Variant &p_value) override;

virtual int32_t global_shader_parameters_instance_allocate(RID p_instance) override;
virtual void global_shader_parameters_instance_free(RID p_instance) override;
virtual void global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) override;
Expand Down
6 changes: 6 additions & 0 deletions drivers/gles3/storage/mesh_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ void MeshStorage::mesh_free(RID p_rid) {
mesh_owner.free(p_rid);
}

void MeshStorage::mesh_set_lightmap_size_hint(RID p_mesh, const Size2 &p_size) {
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
mesh->lightmap_size_hint = p_size;
}

void MeshStorage::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) {
ERR_FAIL_COND(p_blend_shape_count < 0);

Expand Down
12 changes: 12 additions & 0 deletions drivers/gles3/storage/mesh_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ struct Mesh {
RID shadow_mesh;
HashSet<Mesh *> shadow_owners;

Size2 lightmap_size_hint;

Dependency dependency;
};

Expand Down Expand Up @@ -276,6 +278,9 @@ class MeshStorage : public RendererMeshStorage {

virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton = RID()) override;
virtual void mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) override;

virtual void mesh_set_lightmap_size_hint(RID p_mesh, const Size2 &p_size) override;

virtual void mesh_clear(RID p_mesh) override;

_FORCE_INLINE_ const RID *mesh_get_surface_count_and_materials(RID p_mesh, uint32_t &r_surface_count) {
Expand Down Expand Up @@ -310,6 +315,13 @@ class MeshStorage : public RendererMeshStorage {
return mesh->shadow_mesh;
}

_FORCE_INLINE_ Size2 mesh_get_lightmap_size_hint(RID p_mesh) {
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, Size2());

return mesh->lightmap_size_hint;
}

_FORCE_INLINE_ RS::PrimitiveType mesh_surface_get_primitive(void *p_surface) {
Mesh::Surface *surface = reinterpret_cast<Mesh::Surface *>(p_surface);
return surface->primitive;
Expand Down
5 changes: 5 additions & 0 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3143,6 +3143,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_DISPLAY_SHADELESS:
case VIEW_DISPLAY_LIGHTING:
case VIEW_DISPLAY_NORMAL_BUFFER:
case VIEW_DISPLAY_DEBUG_UV2_TEXEL_DENSITY:
case VIEW_DISPLAY_DEBUG_SHADOW_ATLAS:
case VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS:
case VIEW_DISPLAY_DEBUG_VOXEL_GI_ALBEDO:
Expand Down Expand Up @@ -3171,6 +3172,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
VIEW_DISPLAY_LIGHTING,
VIEW_DISPLAY_NORMAL_BUFFER,
VIEW_DISPLAY_WIREFRAME,
VIEW_DISPLAY_DEBUG_UV2_TEXEL_DENSITY,
VIEW_DISPLAY_DEBUG_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_VOXEL_GI_ALBEDO,
Expand Down Expand Up @@ -3201,6 +3203,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
Viewport::DEBUG_DRAW_LIGHTING,
Viewport::DEBUG_DRAW_NORMAL_BUFFER,
Viewport::DEBUG_DRAW_WIREFRAME,
Viewport::DEBUG_DRAW_UV2_TEXEL_DENSITY,
Viewport::DEBUG_DRAW_SHADOW_ATLAS,
Viewport::DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
Viewport::DEBUG_DRAW_VOXEL_GI_ALBEDO,
Expand Down Expand Up @@ -4719,6 +4722,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
display_submenu->add_separator();
display_submenu->add_radio_check_item(TTR("Normal Buffer"), VIEW_DISPLAY_NORMAL_BUFFER);
display_submenu->add_separator();
display_submenu->add_radio_check_item(TTR("UV2 Texel Density"), VIEW_DISPLAY_DEBUG_UV2_TEXEL_DENSITY);
display_submenu->add_separator();
display_submenu->add_radio_check_item(TTR("Shadow Atlas"), VIEW_DISPLAY_DEBUG_SHADOW_ATLAS);
display_submenu->add_radio_check_item(TTR("Directional Shadow Map"), VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS);
display_submenu->add_separator();
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/node_3d_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Node3DEditorViewport : public Control {
VIEW_DISPLAY_LIGHTING,
VIEW_DISPLAY_ADVANCED,
VIEW_DISPLAY_NORMAL_BUFFER,
VIEW_DISPLAY_DEBUG_UV2_TEXEL_DENSITY,
VIEW_DISPLAY_DEBUG_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_VOXEL_GI_ALBEDO,
Expand Down
3 changes: 3 additions & 0 deletions scene/3d/visual_instance_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ void GeometryInstance3D::set_custom_aabb(AABB aabb) {
void GeometryInstance3D::set_lightmap_scale(LightmapScale p_scale) {
ERR_FAIL_INDEX(p_scale, LIGHTMAP_SCALE_MAX);
lightmap_scale = p_scale;

static const float lightmap_scales[LIGHTMAP_SCALE_MAX] = { 1.0, 2.0, 4.0, 8.0 };
RS::get_singleton()->instance_geometry_set_lightmap_scale(get_instance(), lightmap_scales[p_scale]);
}

GeometryInstance3D::LightmapScale GeometryInstance3D::get_lightmap_scale() const {
Expand Down
1 change: 1 addition & 0 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3928,6 +3928,7 @@ void Viewport::_bind_methods() {
BIND_ENUM_CONSTANT(DEBUG_DRAW_VOXEL_GI_ALBEDO);
BIND_ENUM_CONSTANT(DEBUG_DRAW_VOXEL_GI_LIGHTING);
BIND_ENUM_CONSTANT(DEBUG_DRAW_VOXEL_GI_EMISSION);
BIND_ENUM_CONSTANT(DEBUG_DRAW_UV2_TEXEL_DENSITY);
BIND_ENUM_CONSTANT(DEBUG_DRAW_SHADOW_ATLAS);
BIND_ENUM_CONSTANT(DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS);
BIND_ENUM_CONSTANT(DEBUG_DRAW_SCENE_LUMINANCE);
Expand Down
1 change: 1 addition & 0 deletions scene/main/viewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Viewport : public Node {
DEBUG_DRAW_VOXEL_GI_ALBEDO,
DEBUG_DRAW_VOXEL_GI_LIGHTING,
DEBUG_DRAW_VOXEL_GI_EMISSION,
DEBUG_DRAW_UV2_TEXEL_DENSITY,
DEBUG_DRAW_SHADOW_ATLAS,
DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
DEBUG_DRAW_SCENE_LUMINANCE,
Expand Down
1 change: 1 addition & 0 deletions scene/resources/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {

void Mesh::set_lightmap_size_hint(const Size2i &p_size) {
lightmap_size_hint = p_size;
RS::get_singleton()->mesh_set_lightmap_size_hint(get_rid(), p_size);
}

Size2i Mesh::get_lightmap_size_hint() const {
Expand Down
Loading