Skip to content
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
6 changes: 6 additions & 0 deletions doc/classes/LightmapGIData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
Clear all objects that are considered baked within this [LightmapGIData].
</description>
</method>
<method name="create_placeholder" qualifiers="const">
<return type="Resource" />
<description>
Creates a placeholder version of this resource ([PlaceholderLightmapGIData]).
</description>
</method>
<method name="get_user_count" qualifiers="const">
<return type="int" />
<description>
Expand Down
12 changes: 12 additions & 0 deletions doc/classes/PlaceholderLightmapGIData.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PlaceholderLightmapGIData" inherits="LightmapGIData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Placeholder class for [LightmapGIData].
</brief_description>
<description>
This class is used when loading a project that uses a [LightmapGIData] subclass, if the project was exported in dedicated server mode. In this mode, only the resource reference is kept, with no actual light probe data. This allows reducing the exported PCK's size significantly.
[b]Note:[/b] This is not intended to be used as an actual resource for rendering.
</description>
<tutorials>
</tutorials>
</class>
12 changes: 12 additions & 0 deletions doc/classes/PlaceholderVoxelGIData.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PlaceholderVoxelGIData" inherits="VoxelGIData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Placeholder class for [VoxelGIData].
</brief_description>
<description>
This class is used when loading a project that uses a [VoxelGIData] subclass, if the project was exported in dedicated server mode. In this mode, only the resource reference is kept, with no actual voxel data. This allows reducing the exported PCK's size significantly.
[b]Note:[/b] This is not intended to be used as an actual resource for rendering.
</description>
<tutorials>
</tutorials>
</class>
6 changes: 6 additions & 0 deletions doc/classes/VoxelGIData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
<description>
</description>
</method>
<method name="create_placeholder" qualifiers="const">
<return type="Resource" />
<description>
Creates a placeholder version of this resource ([PlaceholderVoxelGIData]).
</description>
</method>
<method name="get_bounds" qualifiers="const">
<return type="AABB" />
<description>
Expand Down
23 changes: 23 additions & 0 deletions scene/3d/lightmap_gi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ Array LightmapGIData::_get_light_textures_data() const {
}
#endif

Ref<Resource> LightmapGIData::create_placeholder() const {
Ref<PlaceholderLightmapGIData> data;
data.instantiate();
return data;
}

void LightmapGIData::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_user_data", "data"), &LightmapGIData::_set_user_data);
ClassDB::bind_method(D_METHOD("_get_user_data"), &LightmapGIData::_get_user_data);
Expand All @@ -347,6 +353,8 @@ void LightmapGIData::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_probe_data", "data"), &LightmapGIData::_set_probe_data);
ClassDB::bind_method(D_METHOD("_get_probe_data"), &LightmapGIData::_get_probe_data);

ClassDB::bind_method(D_METHOD("create_placeholder"), &LightmapGIData::create_placeholder);

ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "lightmap_textures", PROPERTY_HINT_ARRAY_TYPE, "TextureLayered", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_READ_ONLY), "set_lightmap_textures", "get_lightmap_textures");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "shadowmask_textures", PROPERTY_HINT_ARRAY_TYPE, "TextureLayered", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_READ_ONLY), "set_shadowmask_textures", "get_shadowmask_textures");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "uses_spherical_harmonics", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "set_uses_spherical_harmonics", "is_using_spherical_harmonics");
Expand Down Expand Up @@ -381,6 +389,21 @@ LightmapGIData::~LightmapGIData() {

///////////////////////////

RID PlaceholderLightmapGIData::get_rid() const {
return lightmap;
}

PlaceholderLightmapGIData::PlaceholderLightmapGIData() {
lightmap = RS::get_singleton()->lightmap_create();
}

PlaceholderLightmapGIData::~PlaceholderLightmapGIData() {
ERR_FAIL_NULL(RenderingServer::get_singleton());
RS::get_singleton()->free_rid(lightmap);
}

///////////////////////////

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);
if (mi && mi->get_gi_mode() == GeometryInstance3D::GI_MODE_STATIC && mi->is_visible_in_tree()) {
Expand Down
14 changes: 14 additions & 0 deletions scene/3d/lightmap_gi.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

class Sky;
class CameraAttributes;
class PlaceholderLightmapGIData;

class LightmapGIData : public Resource {
GDCLASS(LightmapGIData, Resource);
Expand Down Expand Up @@ -138,11 +139,24 @@ class LightmapGIData : public Resource {
void clear_shadowmask_textures();
bool has_shadowmask_textures();

Ref<Resource> create_placeholder() const;

virtual RID get_rid() const override;
LightmapGIData();
~LightmapGIData();
};

class PlaceholderLightmapGIData : public LightmapGIData {
GDCLASS(PlaceholderLightmapGIData, LightmapGIData);

RID lightmap;

public:
virtual RID get_rid() const override;
PlaceholderLightmapGIData();
~PlaceholderLightmapGIData();
};

class LightmapGI : public VisualInstance3D {
GDCLASS(LightmapGI, VisualInstance3D);

Expand Down
18 changes: 18 additions & 0 deletions scene/3d/voxel_gi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ void VoxelGIData::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_data", "data"), &VoxelGIData::_set_data);
ClassDB::bind_method(D_METHOD("_get_data"), &VoxelGIData::_get_data);

ClassDB::bind_method(D_METHOD("create_placeholder"), &VoxelGIData::create_placeholder);

ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data");

ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dynamic_range", PROPERTY_HINT_RANGE, "1,8,0.01"), "set_dynamic_range", "get_dynamic_range");
Expand Down Expand Up @@ -264,6 +266,16 @@ VoxelGIData::~VoxelGIData() {
}

//////////////////////

PlaceholderVoxelGIData::PlaceholderVoxelGIData() {
probe = RS::get_singleton()->voxel_gi_create();
}

PlaceholderVoxelGIData::~PlaceholderVoxelGIData() {
ERR_FAIL_NULL(RenderingServer::get_singleton());
RS::get_singleton()->free_rid(probe);
}

//////////////////////

void VoxelGI::set_probe_data(const Ref<VoxelGIData> &p_data) {
Expand Down Expand Up @@ -537,6 +549,12 @@ AABB VoxelGI::get_aabb() const {
return AABB(-size / 2, size);
}

Ref<Resource> VoxelGIData::create_placeholder() const {
Ref<PlaceholderVoxelGIData> data;
data.instantiate();
return data;
}

PackedStringArray VoxelGI::get_configuration_warnings() const {
PackedStringArray warnings = VisualInstance3D::get_configuration_warnings();

Expand Down
13 changes: 13 additions & 0 deletions scene/3d/voxel_gi.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "scene/3d/visual_instance_3d.h"

class CameraAttributes;
class PlaceholderVoxelGIData;

class VoxelGIData : public Resource {
GDCLASS(VoxelGIData, Resource);
Expand Down Expand Up @@ -88,12 +89,24 @@ class VoxelGIData : public Resource {
void set_use_two_bounces(bool p_enable);
bool is_using_two_bounces() const;

Ref<Resource> create_placeholder() const;

virtual RID get_rid() const override;

VoxelGIData();
~VoxelGIData();
};

class PlaceholderVoxelGIData : public VoxelGIData {
GDCLASS(PlaceholderVoxelGIData, VoxelGIData);

RID probe;

public:
PlaceholderVoxelGIData();
~PlaceholderVoxelGIData();
};

class VoxelGI : public VisualInstance3D {
GDCLASS(VoxelGI, VisualInstance3D);

Expand Down
2 changes: 2 additions & 0 deletions scene/register_scene_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,10 @@ void register_scene_types() {
GDREGISTER_CLASS(Decal);
GDREGISTER_CLASS(VoxelGI);
GDREGISTER_CLASS(VoxelGIData);
GDREGISTER_CLASS(PlaceholderVoxelGIData);
GDREGISTER_CLASS(LightmapGI);
GDREGISTER_CLASS(LightmapGIData);
GDREGISTER_CLASS(PlaceholderLightmapGIData);
GDREGISTER_CLASS(LightmapProbe);
GDREGISTER_ABSTRACT_CLASS(Lightmapper);
GDREGISTER_CLASS(GPUParticles3D);
Expand Down
Loading