mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-01 00:27:12 +01:00
Removed the Lightmapper and BakedLightmap classes.
This commit is contained in:
parent
ba4cda4890
commit
9e6d2fa653
@ -116,7 +116,6 @@
|
||||
#include "editor/plugins/animation_tree_player_editor_plugin.h"
|
||||
#include "editor/plugins/asset_library_editor_plugin.h"
|
||||
#include "editor/plugins/audio_stream_editor_plugin.h"
|
||||
#include "editor/plugins/baked_lightmap_editor_plugin.h"
|
||||
#include "editor/plugins/camera_editor_plugin.h"
|
||||
#include "editor/plugins/canvas_item_editor_plugin.h"
|
||||
#include "editor/plugins/collision_polygon_2d_editor_plugin.h"
|
||||
@ -6949,7 +6948,6 @@ EditorNode::EditorNode() {
|
||||
add_editor_plugin(memnew(TextureRegionEditorPlugin(this)));
|
||||
add_editor_plugin(memnew(Particles2DEditorPlugin(this)));
|
||||
add_editor_plugin(memnew(GIProbeEditorPlugin(this)));
|
||||
add_editor_plugin(memnew(BakedLightmapEditorPlugin(this)));
|
||||
add_editor_plugin(memnew(RoomManagerEditorPlugin(this)));
|
||||
add_editor_plugin(memnew(RoomEditorPlugin(this)));
|
||||
add_editor_plugin(memnew(OccluderEditorPlugin(this)));
|
||||
|
@ -1,177 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* baked_lightmap_editor_plugin.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "baked_lightmap_editor_plugin.h"
|
||||
|
||||
void BakedLightmapEditorPlugin::_bake_select_file(const String &p_file) {
|
||||
if (lightmap) {
|
||||
BakedLightmap::BakeError err;
|
||||
if (get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root() == lightmap) {
|
||||
err = lightmap->bake(lightmap, p_file);
|
||||
} else {
|
||||
err = lightmap->bake(lightmap->get_parent(), p_file);
|
||||
}
|
||||
|
||||
switch (err) {
|
||||
case BakedLightmap::BAKE_ERROR_NO_SAVE_PATH: {
|
||||
String scene_path = lightmap->get_filename();
|
||||
if (scene_path == String()) {
|
||||
scene_path = lightmap->get_owner()->get_filename();
|
||||
}
|
||||
if (scene_path == String()) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Can't determine a save path for lightmap images.\nSave your scene and try again."));
|
||||
break;
|
||||
}
|
||||
scene_path = scene_path.get_basename() + ".lmbake";
|
||||
|
||||
file_dialog->set_current_path(scene_path);
|
||||
file_dialog->popup_centered_ratio();
|
||||
|
||||
} break;
|
||||
case BakedLightmap::BAKE_ERROR_NO_MESHES:
|
||||
EditorNode::get_singleton()->show_warning(TTR("No meshes to bake. Make sure they contain an UV2 channel and that the 'Use In Baked Light' and 'Generate Lightmap' flags are on."));
|
||||
break;
|
||||
case BakedLightmap::BAKE_ERROR_CANT_CREATE_IMAGE:
|
||||
EditorNode::get_singleton()->show_warning(TTR("Failed creating lightmap images, make sure path is writable."));
|
||||
break;
|
||||
case BakedLightmap::BAKE_ERROR_LIGHTMAP_SIZE:
|
||||
EditorNode::get_singleton()->show_warning(TTR("Failed determining lightmap size. Maximum lightmap size too small?"));
|
||||
break;
|
||||
case BakedLightmap::BAKE_ERROR_INVALID_MESH:
|
||||
EditorNode::get_singleton()->show_warning(TTR("Some mesh is invalid. Make sure the UV2 channel values are contained within the [0.0,1.0] square region."));
|
||||
break;
|
||||
case BakedLightmap::BAKE_ERROR_NO_LIGHTMAPPER:
|
||||
EditorNode::get_singleton()->show_warning(TTR("Godot editor was built without ray tracing support, lightmaps can't be baked."));
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BakedLightmapEditorPlugin::_bake() {
|
||||
_bake_select_file("");
|
||||
}
|
||||
|
||||
void BakedLightmapEditorPlugin::edit(Object *p_object) {
|
||||
BakedLightmap *s = Object::cast_to<BakedLightmap>(p_object);
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
|
||||
lightmap = s;
|
||||
}
|
||||
|
||||
bool BakedLightmapEditorPlugin::handles(Object *p_object) const {
|
||||
return p_object->is_class("BakedLightmap");
|
||||
}
|
||||
|
||||
void BakedLightmapEditorPlugin::make_visible(bool p_visible) {
|
||||
if (p_visible) {
|
||||
bake->show();
|
||||
} else {
|
||||
bake->hide();
|
||||
}
|
||||
}
|
||||
|
||||
EditorProgress *BakedLightmapEditorPlugin::tmp_progress = nullptr;
|
||||
EditorProgress *BakedLightmapEditorPlugin::tmp_subprogress = nullptr;
|
||||
|
||||
bool BakedLightmapEditorPlugin::bake_func_step(float p_progress, const String &p_description, void *, bool p_force_refresh) {
|
||||
if (!tmp_progress) {
|
||||
tmp_progress = memnew(EditorProgress("bake_lightmaps", TTR("Bake Lightmaps"), 1000, true));
|
||||
ERR_FAIL_COND_V(tmp_progress == nullptr, false);
|
||||
}
|
||||
return tmp_progress->step(p_description, p_progress * 1000, p_force_refresh);
|
||||
}
|
||||
|
||||
bool BakedLightmapEditorPlugin::bake_func_substep(float p_progress, const String &p_description, void *, bool p_force_refresh) {
|
||||
if (!tmp_subprogress) {
|
||||
tmp_subprogress = memnew(EditorProgress("bake_lightmaps_substep", "", 1000, true));
|
||||
ERR_FAIL_COND_V(tmp_subprogress == nullptr, false);
|
||||
}
|
||||
return tmp_subprogress->step(p_description, p_progress * 1000, p_force_refresh);
|
||||
}
|
||||
|
||||
void BakedLightmapEditorPlugin::bake_func_end(uint32_t p_time_started) {
|
||||
if (tmp_progress != nullptr) {
|
||||
memdelete(tmp_progress);
|
||||
tmp_progress = nullptr;
|
||||
}
|
||||
|
||||
if (tmp_subprogress != nullptr) {
|
||||
memdelete(tmp_subprogress);
|
||||
tmp_subprogress = nullptr;
|
||||
}
|
||||
|
||||
const int time_taken = (OS::get_singleton()->get_ticks_msec() - p_time_started) * 0.001;
|
||||
if (time_taken >= 1) {
|
||||
// Only print a message and request attention if baking lightmaps took at least 1 second.
|
||||
// Otherwise, attempting to bake in an erroneous situation (e.g. no meshes to bake)
|
||||
// would print the "done baking lightmaps" message and request attention for no good reason.
|
||||
print_line(vformat("Done baking lightmaps in %02d:%02d:%02d.", time_taken / 3600, (time_taken % 3600) / 60, time_taken % 60));
|
||||
|
||||
// Request attention in case the user was doing something else.
|
||||
// Baking lightmaps is likely the editor task that can take the most time,
|
||||
// so only request the attention for baking lightmaps.
|
||||
OS::get_singleton()->request_attention();
|
||||
}
|
||||
}
|
||||
|
||||
void BakedLightmapEditorPlugin::_bind_methods() {
|
||||
ClassDB::bind_method("_bake", &BakedLightmapEditorPlugin::_bake);
|
||||
ClassDB::bind_method("_bake_select_file", &BakedLightmapEditorPlugin::_bake_select_file);
|
||||
}
|
||||
|
||||
BakedLightmapEditorPlugin::BakedLightmapEditorPlugin(EditorNode *p_node) {
|
||||
editor = p_node;
|
||||
bake = memnew(ToolButton);
|
||||
bake->set_icon(editor->get_gui_base()->get_icon("Bake", "EditorIcons"));
|
||||
bake->set_text(TTR("Bake Lightmaps"));
|
||||
bake->hide();
|
||||
bake->connect("pressed", this, "_bake");
|
||||
|
||||
file_dialog = memnew(EditorFileDialog);
|
||||
file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
|
||||
file_dialog->add_filter("*.lmbake ; " + TTR("LightMap Bake"));
|
||||
file_dialog->set_title(TTR("Select lightmap bake file:"));
|
||||
file_dialog->connect("file_selected", this, "_bake_select_file");
|
||||
bake->add_child(file_dialog);
|
||||
|
||||
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake);
|
||||
lightmap = nullptr;
|
||||
|
||||
BakedLightmap::bake_step_function = bake_func_step;
|
||||
BakedLightmap::bake_substep_function = bake_func_substep;
|
||||
BakedLightmap::bake_end_function = bake_func_end;
|
||||
}
|
||||
|
||||
BakedLightmapEditorPlugin::~BakedLightmapEditorPlugin() {
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* baked_lightmap_editor_plugin.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef BAKED_LIGHTMAP_EDITOR_PLUGIN_H
|
||||
#define BAKED_LIGHTMAP_EDITOR_PLUGIN_H
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_plugin.h"
|
||||
#include "scene/3d/baked_lightmap.h"
|
||||
#include "scene/resources/material.h"
|
||||
|
||||
class BakedLightmapEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(BakedLightmapEditorPlugin, EditorPlugin);
|
||||
|
||||
BakedLightmap *lightmap;
|
||||
|
||||
ToolButton *bake;
|
||||
EditorNode *editor;
|
||||
|
||||
EditorFileDialog *file_dialog;
|
||||
static EditorProgress *tmp_progress;
|
||||
static EditorProgress *tmp_subprogress;
|
||||
|
||||
static bool bake_func_step(float p_progress, const String &p_description, void *, bool p_force_refresh);
|
||||
static bool bake_func_substep(float p_progress, const String &p_description, void *, bool p_force_refresh);
|
||||
static void bake_func_end(uint32_t p_time_started);
|
||||
|
||||
void _bake_select_file(const String &p_file);
|
||||
void _bake();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual String get_name() const { return "BakedLightmap"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
virtual void edit(Object *p_object);
|
||||
virtual bool handles(Object *p_object) const;
|
||||
virtual void make_visible(bool p_visible);
|
||||
|
||||
BakedLightmapEditorPlugin(EditorNode *p_node);
|
||||
~BakedLightmapEditorPlugin();
|
||||
};
|
||||
|
||||
#endif // BAKED_LIGHTMAP_EDITOR_PLUGIN_H
|
@ -6544,7 +6544,6 @@ void SpatialEditor::_register_all_gizmos() {
|
||||
add_gizmo_plugin(Ref<CPUParticlesGizmoPlugin>(memnew(CPUParticlesGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<ReflectionProbeGizmoPlugin>(memnew(ReflectionProbeGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<GIProbeGizmoPlugin>(memnew(GIProbeGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<BakedIndirectLightGizmoPlugin>(memnew(BakedIndirectLightGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<CollisionObjectGizmoPlugin>(memnew(CollisionObjectGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<CollisionShapeSpatialGizmoPlugin>(memnew(CollisionShapeSpatialGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<CollisionPolygonSpatialGizmoPlugin>(memnew(CollisionPolygonSpatialGizmoPlugin)));
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "core/math/convex_hull.h"
|
||||
#include "core/math/geometry.h"
|
||||
#include "scene/3d/audio_stream_player_3d.h"
|
||||
#include "scene/3d/baked_lightmap.h"
|
||||
#include "scene/3d/collision_polygon.h"
|
||||
#include "scene/3d/collision_shape.h"
|
||||
#include "scene/3d/cpu_particles.h"
|
||||
@ -2864,135 +2863,6 @@ void GIProbeGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
|
||||
|
||||
////
|
||||
|
||||
BakedIndirectLightGizmoPlugin::BakedIndirectLightGizmoPlugin() {
|
||||
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/baked_indirect_light", Color(0.5, 0.6, 1));
|
||||
|
||||
create_material("baked_indirect_light_material", gizmo_color);
|
||||
|
||||
gizmo_color.a = 0.1;
|
||||
create_material("baked_indirect_light_internal_material", gizmo_color);
|
||||
|
||||
create_icon_material("baked_indirect_light_icon", SpatialEditor::get_singleton()->get_icon("GizmoBakedLightmap", "EditorIcons"));
|
||||
create_handle_material("handles");
|
||||
}
|
||||
|
||||
String BakedIndirectLightGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
|
||||
switch (p_idx) {
|
||||
case 0:
|
||||
return "Extents X";
|
||||
case 1:
|
||||
return "Extents Y";
|
||||
case 2:
|
||||
return "Extents Z";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
Variant BakedIndirectLightGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
|
||||
BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node());
|
||||
return baker->get_extents();
|
||||
}
|
||||
void BakedIndirectLightGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
|
||||
BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node());
|
||||
|
||||
Transform gt = baker->get_global_transform();
|
||||
Transform gi = gt.affine_inverse();
|
||||
|
||||
Vector3 extents = baker->get_extents();
|
||||
|
||||
Vector3 ray_from = p_camera->project_ray_origin(p_point);
|
||||
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
|
||||
|
||||
Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) };
|
||||
|
||||
Vector3 axis;
|
||||
axis[p_idx] = 1.0;
|
||||
|
||||
Vector3 ra, rb;
|
||||
Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
|
||||
float d = ra[p_idx];
|
||||
if (SpatialEditor::get_singleton()->is_snap_enabled()) {
|
||||
d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
|
||||
}
|
||||
|
||||
if (d < 0.001) {
|
||||
d = 0.001;
|
||||
}
|
||||
|
||||
extents[p_idx] = d;
|
||||
baker->set_extents(extents);
|
||||
}
|
||||
|
||||
void BakedIndirectLightGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
|
||||
BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node());
|
||||
|
||||
Vector3 restore = p_restore;
|
||||
|
||||
if (p_cancel) {
|
||||
baker->set_extents(restore);
|
||||
return;
|
||||
}
|
||||
|
||||
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
|
||||
ur->create_action(TTR("Change Probe Extents"));
|
||||
ur->add_do_method(baker, "set_extents", baker->get_extents());
|
||||
ur->add_undo_method(baker, "set_extents", restore);
|
||||
ur->commit_action();
|
||||
}
|
||||
|
||||
bool BakedIndirectLightGizmoPlugin::has_gizmo(Spatial *p_spatial) {
|
||||
return Object::cast_to<BakedLightmap>(p_spatial) != nullptr;
|
||||
}
|
||||
|
||||
String BakedIndirectLightGizmoPlugin::get_name() const {
|
||||
return "BakedLightmap";
|
||||
}
|
||||
|
||||
int BakedIndirectLightGizmoPlugin::get_priority() const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void BakedIndirectLightGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
|
||||
BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node());
|
||||
|
||||
Ref<Material> material = get_material("baked_indirect_light_material", p_gizmo);
|
||||
Ref<Material> icon = get_material("baked_indirect_light_icon", p_gizmo);
|
||||
Ref<Material> material_internal = get_material("baked_indirect_light_internal_material", p_gizmo);
|
||||
|
||||
p_gizmo->clear();
|
||||
|
||||
Vector<Vector3> lines;
|
||||
Vector3 extents = baker->get_extents();
|
||||
|
||||
AABB aabb = AABB(-extents, extents * 2);
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
Vector3 a, b;
|
||||
aabb.get_edge(i, a, b);
|
||||
lines.push_back(a);
|
||||
lines.push_back(b);
|
||||
}
|
||||
|
||||
p_gizmo->add_lines(lines, material);
|
||||
|
||||
Vector<Vector3> handles;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Vector3 ax;
|
||||
ax[i] = aabb.position[i] + aabb.size[i];
|
||||
handles.push_back(ax);
|
||||
}
|
||||
|
||||
if (p_gizmo->is_selected()) {
|
||||
p_gizmo->add_solid_box(material_internal, aabb.get_size());
|
||||
}
|
||||
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05);
|
||||
p_gizmo->add_handles(handles, get_material("handles"));
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
CollisionObjectGizmoPlugin::CollisionObjectGizmoPlugin() {
|
||||
const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
|
||||
create_material("shape_material", gizmo_color);
|
||||
|
@ -300,23 +300,6 @@ public:
|
||||
GIProbeGizmoPlugin();
|
||||
};
|
||||
|
||||
class BakedIndirectLightGizmoPlugin : public EditorSpatialGizmoPlugin {
|
||||
GDCLASS(BakedIndirectLightGizmoPlugin, EditorSpatialGizmoPlugin);
|
||||
|
||||
public:
|
||||
bool has_gizmo(Spatial *p_spatial);
|
||||
String get_name() const;
|
||||
int get_priority() const;
|
||||
void redraw(EditorSpatialGizmo *p_gizmo);
|
||||
|
||||
String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
|
||||
Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
|
||||
void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
|
||||
void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
|
||||
|
||||
BakedIndirectLightGizmoPlugin();
|
||||
};
|
||||
|
||||
class CollisionObjectGizmoPlugin : public EditorSpatialGizmoPlugin {
|
||||
GDCLASS(CollisionObjectGizmoPlugin, EditorSpatialGizmoPlugin);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,288 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* baked_lightmap.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef BAKED_INDIRECT_LIGHT_H
|
||||
#define BAKED_INDIRECT_LIGHT_H
|
||||
|
||||
#include "core/local_vector.h"
|
||||
#include "multimesh_instance.h"
|
||||
#include "scene/3d/light.h"
|
||||
#include "scene/3d/lightmapper.h"
|
||||
#include "scene/3d/visual_instance.h"
|
||||
|
||||
class BakedLightmapData : public Resource {
|
||||
GDCLASS(BakedLightmapData, Resource);
|
||||
RES_BASE_EXTENSION("lmbake")
|
||||
|
||||
RID baked_light;
|
||||
AABB bounds;
|
||||
float energy;
|
||||
bool interior;
|
||||
int cell_subdiv;
|
||||
Transform cell_space_xform;
|
||||
|
||||
struct User {
|
||||
NodePath path;
|
||||
struct {
|
||||
Ref<Texture> single;
|
||||
Ref<TextureLayered> layered;
|
||||
} lightmap;
|
||||
int lightmap_slice;
|
||||
Rect2 lightmap_uv_rect;
|
||||
int instance_index;
|
||||
};
|
||||
|
||||
Vector<User> users;
|
||||
|
||||
void _set_user_data(const Array &p_data);
|
||||
Array _get_user_data() const;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_bounds(const AABB &p_bounds);
|
||||
AABB get_bounds() const;
|
||||
|
||||
void set_octree(const PoolVector<uint8_t> &p_octree);
|
||||
PoolVector<uint8_t> get_octree() const;
|
||||
|
||||
void set_cell_space_transform(const Transform &p_xform);
|
||||
Transform get_cell_space_transform() const;
|
||||
|
||||
void set_cell_subdiv(int p_cell_subdiv);
|
||||
int get_cell_subdiv() const;
|
||||
|
||||
void set_energy(float p_energy);
|
||||
float get_energy() const;
|
||||
|
||||
void set_interior(bool p_interior);
|
||||
bool is_interior() const;
|
||||
|
||||
void add_user(const NodePath &p_path, const Ref<Resource> &p_lightmap, int p_lightmap_slice, const Rect2 &p_lightmap_uv_rect, int p_instance);
|
||||
int get_user_count() const;
|
||||
NodePath get_user_path(int p_user) const;
|
||||
Ref<Resource> get_user_lightmap(int p_user) const;
|
||||
int get_user_lightmap_slice(int p_user) const;
|
||||
Rect2 get_user_lightmap_uv_rect(int p_user) const;
|
||||
int get_user_instance(int p_user) const;
|
||||
void clear_users();
|
||||
void clear_data();
|
||||
|
||||
virtual RID get_rid() const;
|
||||
BakedLightmapData();
|
||||
~BakedLightmapData();
|
||||
};
|
||||
|
||||
class BakedLightmap : public VisualInstance {
|
||||
GDCLASS(BakedLightmap, VisualInstance);
|
||||
|
||||
public:
|
||||
enum BakeQuality {
|
||||
BAKE_QUALITY_LOW,
|
||||
BAKE_QUALITY_MEDIUM,
|
||||
BAKE_QUALITY_HIGH,
|
||||
BAKE_QUALITY_ULTRA
|
||||
};
|
||||
|
||||
enum BakeError {
|
||||
BAKE_ERROR_OK,
|
||||
BAKE_ERROR_NO_SAVE_PATH,
|
||||
BAKE_ERROR_NO_MESHES,
|
||||
BAKE_ERROR_CANT_CREATE_IMAGE,
|
||||
BAKE_ERROR_LIGHTMAP_SIZE,
|
||||
BAKE_ERROR_INVALID_MESH,
|
||||
BAKE_ERROR_USER_ABORTED,
|
||||
BAKE_ERROR_NO_LIGHTMAPPER,
|
||||
BAKE_ERROR_NO_ROOT,
|
||||
};
|
||||
|
||||
enum EnvironmentMode {
|
||||
ENVIRONMENT_MODE_DISABLED,
|
||||
ENVIRONMENT_MODE_SCENE,
|
||||
ENVIRONMENT_MODE_CUSTOM_SKY,
|
||||
ENVIRONMENT_MODE_CUSTOM_COLOR
|
||||
};
|
||||
|
||||
struct BakeStepUD {
|
||||
Lightmapper::BakeStepFunc func;
|
||||
void *ud;
|
||||
float from_percent;
|
||||
float to_percent;
|
||||
};
|
||||
|
||||
struct LightsFound {
|
||||
Transform xform;
|
||||
Light *light;
|
||||
};
|
||||
|
||||
struct MeshesFound {
|
||||
Transform xform;
|
||||
NodePath node_path;
|
||||
int32_t subindex;
|
||||
Ref<Mesh> mesh;
|
||||
int32_t lightmap_scale;
|
||||
Vector<Ref<Material>> overrides;
|
||||
bool cast_shadows;
|
||||
bool generate_lightmap;
|
||||
};
|
||||
|
||||
private:
|
||||
Vector3 extents;
|
||||
float default_texels_per_unit;
|
||||
float bias;
|
||||
BakeQuality bake_quality;
|
||||
bool generate_atlas;
|
||||
int max_atlas_size;
|
||||
bool capture_enabled;
|
||||
int bounces;
|
||||
float bounce_indirect_energy;
|
||||
bool use_denoiser;
|
||||
bool use_hdr;
|
||||
bool use_color;
|
||||
|
||||
EnvironmentMode environment_mode;
|
||||
Ref<Sky> environment_custom_sky;
|
||||
Vector3 environment_custom_sky_rotation_degrees;
|
||||
Color environment_custom_color;
|
||||
float environment_custom_energy;
|
||||
Color environment_min_light;
|
||||
|
||||
BakeQuality capture_quality;
|
||||
float capture_propagation;
|
||||
float capture_cell_size;
|
||||
|
||||
String image_path; // (Deprecated property)
|
||||
|
||||
Ref<BakedLightmapData> light_data;
|
||||
|
||||
void _assign_lightmaps();
|
||||
void _clear_lightmaps();
|
||||
|
||||
void _get_material_images(const MeshesFound &p_found_mesh, Lightmapper::MeshData &r_mesh_data, Vector<Ref<Texture>> &r_albedo_textures, Vector<Ref<Texture>> &r_emission_textures);
|
||||
Ref<Image> _get_irradiance_from_sky(Ref<Sky> p_sky, float p_energy, Vector2i p_size);
|
||||
Ref<Image> _get_irradiance_map(Ref<Environment> p_env, Vector2i p_size);
|
||||
void _find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound> &meshes, Vector<LightsFound> &lights);
|
||||
Vector2i _compute_lightmap_size(const MeshesFound &p_mesh);
|
||||
|
||||
static bool _lightmap_bake_step_function(float p_completion, const String &p_text, void *ud, bool p_refresh);
|
||||
void _save_image(String &r_base_path, Ref<Image> p_img, bool p_use_srgb);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
void _validate_property(PropertyInfo &property) const;
|
||||
void _notification(int p_what);
|
||||
|
||||
public:
|
||||
static Lightmapper::BakeStepFunc bake_step_function;
|
||||
static Lightmapper::BakeStepFunc bake_substep_function;
|
||||
static Lightmapper::BakeEndFunc bake_end_function;
|
||||
|
||||
void set_light_data(const Ref<BakedLightmapData> &p_data);
|
||||
Ref<BakedLightmapData> get_light_data() const;
|
||||
|
||||
void set_capture_cell_size(float p_cell_size);
|
||||
float get_capture_cell_size() const;
|
||||
|
||||
void set_extents(const Vector3 &p_extents);
|
||||
Vector3 get_extents() const;
|
||||
|
||||
void set_default_texels_per_unit(const float &p_extents);
|
||||
float get_default_texels_per_unit() const;
|
||||
|
||||
void set_capture_propagation(float p_propagation);
|
||||
float get_capture_propagation() const;
|
||||
|
||||
void set_capture_quality(BakeQuality p_quality);
|
||||
BakeQuality get_capture_quality() const;
|
||||
|
||||
void set_bake_quality(BakeQuality p_quality);
|
||||
BakeQuality get_bake_quality() const;
|
||||
|
||||
void set_generate_atlas(bool p_enabled);
|
||||
bool is_generate_atlas_enabled() const;
|
||||
|
||||
void set_max_atlas_size(int p_size);
|
||||
int get_max_atlas_size() const;
|
||||
|
||||
void set_capture_enabled(bool p_enable);
|
||||
bool get_capture_enabled() const;
|
||||
|
||||
void set_image_path(const String &p_path);
|
||||
String get_image_path() const;
|
||||
|
||||
void set_environment_mode(EnvironmentMode p_mode);
|
||||
EnvironmentMode get_environment_mode() const;
|
||||
|
||||
void set_environment_custom_sky(const Ref<Sky> &p_sky);
|
||||
Ref<Sky> get_environment_custom_sky() const;
|
||||
|
||||
void set_environment_custom_sky_rotation_degrees(const Vector3 &p_rotation);
|
||||
Vector3 get_environment_custom_sky_rotation_degrees() const;
|
||||
|
||||
void set_environment_custom_color(const Color &p_color);
|
||||
Color get_environment_custom_color() const;
|
||||
|
||||
void set_environment_custom_energy(float p_energy);
|
||||
float get_environment_custom_energy() const;
|
||||
|
||||
void set_environment_min_light(Color p_min_light);
|
||||
Color get_environment_min_light() const;
|
||||
|
||||
void set_use_denoiser(bool p_enable);
|
||||
bool is_using_denoiser() const;
|
||||
|
||||
void set_use_hdr(bool p_enable);
|
||||
bool is_using_hdr() const;
|
||||
|
||||
void set_use_color(bool p_enable);
|
||||
bool is_using_color() const;
|
||||
|
||||
void set_bounces(int p_bounces);
|
||||
int get_bounces() const;
|
||||
|
||||
void set_bounce_indirect_energy(float p_indirect_energy);
|
||||
float get_bounce_indirect_energy() const;
|
||||
|
||||
void set_bias(float p_bias);
|
||||
float get_bias() const;
|
||||
|
||||
AABB get_aabb() const;
|
||||
PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
|
||||
|
||||
BakeError bake(Node *p_from_node, String p_data_save_path = "");
|
||||
BakedLightmap();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(BakedLightmap::BakeQuality);
|
||||
VARIANT_ENUM_CAST(BakedLightmap::BakeError);
|
||||
VARIANT_ENUM_CAST(BakedLightmap::EnvironmentMode);
|
||||
|
||||
#endif // BAKED_INDIRECT_LIGHT_H
|
@ -1,76 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* lightmapper.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "lightmapper.h"
|
||||
|
||||
LightmapDenoiser *(*LightmapDenoiser::create_function)() = nullptr;
|
||||
|
||||
Ref<LightmapDenoiser> LightmapDenoiser::create() {
|
||||
if (create_function) {
|
||||
return Ref<LightmapDenoiser>(create_function());
|
||||
}
|
||||
return Ref<LightmapDenoiser>();
|
||||
}
|
||||
|
||||
LightmapRaycaster *(*LightmapRaycaster::create_function)() = nullptr;
|
||||
|
||||
Ref<LightmapRaycaster> LightmapRaycaster::create() {
|
||||
if (create_function) {
|
||||
return Ref<LightmapRaycaster>(create_function());
|
||||
}
|
||||
return Ref<LightmapRaycaster>();
|
||||
}
|
||||
|
||||
Lightmapper::CreateFunc Lightmapper::create_custom = nullptr;
|
||||
Lightmapper::CreateFunc Lightmapper::create_gpu = nullptr;
|
||||
Lightmapper::CreateFunc Lightmapper::create_cpu = nullptr;
|
||||
|
||||
Ref<Lightmapper> Lightmapper::create() {
|
||||
Lightmapper *lm = nullptr;
|
||||
if (create_custom) {
|
||||
lm = create_custom();
|
||||
}
|
||||
|
||||
if (!lm && create_gpu) {
|
||||
lm = create_gpu();
|
||||
}
|
||||
|
||||
if (!lm && create_cpu) {
|
||||
lm = create_cpu();
|
||||
}
|
||||
if (!lm) {
|
||||
return Ref<Lightmapper>();
|
||||
} else {
|
||||
return Ref<Lightmapper>(lm);
|
||||
}
|
||||
}
|
||||
|
||||
Lightmapper::Lightmapper() {
|
||||
}
|
@ -1,197 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* lightmapper.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef LIGHTMAPPER_H
|
||||
#define LIGHTMAPPER_H
|
||||
|
||||
#include "scene/resources/mesh.h"
|
||||
|
||||
#if !defined(__aligned)
|
||||
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
#define __aligned(...) __declspec(align(__VA_ARGS__))
|
||||
#else
|
||||
#define __aligned(...) __attribute__((aligned(__VA_ARGS__)))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
class LightmapDenoiser : public Reference {
|
||||
GDCLASS(LightmapDenoiser, Reference)
|
||||
protected:
|
||||
static LightmapDenoiser *(*create_function)();
|
||||
|
||||
public:
|
||||
virtual Ref<Image> denoise_image(const Ref<Image> &p_image) = 0;
|
||||
static Ref<LightmapDenoiser> create();
|
||||
};
|
||||
|
||||
class LightmapRaycaster : public Reference {
|
||||
GDCLASS(LightmapRaycaster, Reference)
|
||||
protected:
|
||||
static LightmapRaycaster *(*create_function)();
|
||||
|
||||
public:
|
||||
// compatible with embree3 rays
|
||||
struct __aligned(16) Ray {
|
||||
const static unsigned int INVALID_GEOMETRY_ID = ((unsigned int)-1); // from rtcore_common.h
|
||||
|
||||
/*! Default construction does nothing. */
|
||||
_FORCE_INLINE_ Ray() :
|
||||
geomID(INVALID_GEOMETRY_ID) {}
|
||||
|
||||
/*! Constructs a ray from origin, direction, and ray segment. Near
|
||||
* has to be smaller than far. */
|
||||
_FORCE_INLINE_ Ray(const Vector3 &org,
|
||||
const Vector3 &dir,
|
||||
float tnear = 0.0f,
|
||||
float tfar = INFINITY) :
|
||||
org(org),
|
||||
tnear(tnear),
|
||||
dir(dir),
|
||||
time(0.0f),
|
||||
tfar(tfar),
|
||||
mask(-1),
|
||||
u(0.0),
|
||||
v(0.0),
|
||||
primID(INVALID_GEOMETRY_ID),
|
||||
geomID(INVALID_GEOMETRY_ID),
|
||||
instID(INVALID_GEOMETRY_ID) {}
|
||||
|
||||
/*! Tests if we hit something. */
|
||||
_FORCE_INLINE_ explicit operator bool() const { return geomID != INVALID_GEOMETRY_ID; }
|
||||
|
||||
public:
|
||||
Vector3 org; //!< Ray origin + tnear
|
||||
float tnear; //!< Start of ray segment
|
||||
Vector3 dir; //!< Ray direction + tfar
|
||||
float time; //!< Time of this ray for motion blur.
|
||||
float tfar; //!< End of ray segment
|
||||
unsigned int mask; //!< used to mask out objects during traversal
|
||||
unsigned int id; //!< ray ID
|
||||
unsigned int flags; //!< ray flags
|
||||
|
||||
Vector3 normal; //!< Not normalized geometry normal
|
||||
float u; //!< Barycentric u coordinate of hit
|
||||
float v; //!< Barycentric v coordinate of hit
|
||||
unsigned int primID; //!< primitive ID
|
||||
unsigned int geomID; //!< geometry ID
|
||||
unsigned int instID; //!< instance ID
|
||||
};
|
||||
|
||||
virtual bool intersect(Ray &p_ray) = 0;
|
||||
|
||||
virtual void intersect(Vector<Ray> &r_rays) = 0;
|
||||
|
||||
virtual void add_mesh(const Vector<Vector3> &p_vertices, const Vector<Vector3> &p_normals, const Vector<Vector2> &p_uv2s, unsigned int p_id) = 0;
|
||||
virtual void set_mesh_alpha_texture(Ref<Image> p_alpha_texture, unsigned int p_id) = 0;
|
||||
virtual void commit() = 0;
|
||||
|
||||
virtual void set_mesh_filter(const Set<int> &p_mesh_ids) = 0;
|
||||
virtual void clear_mesh_filter() = 0;
|
||||
|
||||
static Ref<LightmapRaycaster> create();
|
||||
};
|
||||
|
||||
class Lightmapper : public Reference {
|
||||
GDCLASS(Lightmapper, Reference)
|
||||
public:
|
||||
enum LightType {
|
||||
LIGHT_TYPE_DIRECTIONAL,
|
||||
LIGHT_TYPE_OMNI,
|
||||
LIGHT_TYPE_SPOT
|
||||
};
|
||||
|
||||
enum BakeError {
|
||||
BAKE_ERROR_LIGHTMAP_TOO_SMALL,
|
||||
BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES,
|
||||
BAKE_ERROR_NO_MESHES,
|
||||
BAKE_ERROR_USER_ABORTED,
|
||||
BAKE_ERROR_NO_RAYCASTER,
|
||||
BAKE_OK
|
||||
};
|
||||
|
||||
enum BakeQuality {
|
||||
BAKE_QUALITY_LOW,
|
||||
BAKE_QUALITY_MEDIUM,
|
||||
BAKE_QUALITY_HIGH,
|
||||
BAKE_QUALITY_ULTRA,
|
||||
};
|
||||
|
||||
typedef Lightmapper *(*CreateFunc)();
|
||||
|
||||
static CreateFunc create_custom;
|
||||
static CreateFunc create_gpu;
|
||||
static CreateFunc create_cpu;
|
||||
|
||||
protected:
|
||||
public:
|
||||
typedef bool (*BakeStepFunc)(float, const String &, void *, bool); //progress, step description, userdata, force refresh
|
||||
typedef void (*BakeEndFunc)(uint32_t); // time_started
|
||||
|
||||
struct MeshData {
|
||||
struct TextureDef {
|
||||
RID tex_rid;
|
||||
Color mul;
|
||||
Color add;
|
||||
};
|
||||
|
||||
//triangle data
|
||||
Vector<Vector3> points;
|
||||
Vector<Vector2> uv;
|
||||
Vector<Vector2> uv2;
|
||||
Vector<Vector3> normal;
|
||||
Vector<TextureDef> albedo;
|
||||
Vector<TextureDef> emission;
|
||||
Vector<int> surface_facecounts;
|
||||
Variant userdata;
|
||||
};
|
||||
|
||||
virtual void add_albedo_texture(Ref<Texture> p_texture) = 0;
|
||||
virtual void add_emission_texture(Ref<Texture> p_texture) = 0;
|
||||
virtual void add_mesh(const MeshData &p_mesh, Vector2i p_size) = 0;
|
||||
virtual void add_directional_light(bool p_bake_direct, const Vector3 &p_direction, const Color &p_color, float p_energy, float p_indirect_multiplier, float p_size) = 0;
|
||||
virtual void add_omni_light(bool p_bake_direct, const Vector3 &p_position, const Color &p_color, float p_energy, float p_indirect_multiplier, float p_range, float p_attenuation, float p_size) = 0;
|
||||
virtual void add_spot_light(bool p_bake_direct, const Vector3 &p_position, const Vector3 p_direction, const Color &p_color, float p_energy, float p_indirect_multiplier, float p_range, float p_attenuation, float p_spot_angle, float p_spot_attenuation, float p_size) = 0;
|
||||
virtual BakeError bake(BakeQuality p_quality, bool p_use_denoiser, int p_bounces, float p_bounce_indirect_energy, float p_bias, bool p_generate_atlas, int p_max_texture_size, const Ref<Image> &p_environment_panorama, const Basis &p_environment_transform, BakeStepFunc p_step_function = nullptr, void *p_step_userdata = nullptr, BakeStepFunc p_substep_function = nullptr) = 0;
|
||||
|
||||
virtual int get_bake_texture_count() const = 0;
|
||||
virtual Ref<Image> get_bake_texture(int p_index) const = 0;
|
||||
virtual int get_bake_mesh_count() const = 0;
|
||||
virtual Variant get_bake_mesh_userdata(int p_index) const = 0;
|
||||
virtual Rect2 get_bake_mesh_uv_scale(int p_index) const = 0;
|
||||
virtual int get_bake_mesh_texture_slice(int p_index) const = 0;
|
||||
|
||||
static Ref<Lightmapper> create();
|
||||
|
||||
Lightmapper();
|
||||
};
|
||||
|
||||
#endif // LIGHTMAPPER_H
|
@ -180,7 +180,6 @@
|
||||
#include "scene/3d/area.h"
|
||||
#include "scene/3d/arvr_nodes.h"
|
||||
#include "scene/3d/audio_stream_player_3d.h"
|
||||
#include "scene/3d/baked_lightmap.h"
|
||||
#include "scene/3d/bone_attachment.h"
|
||||
#include "scene/3d/camera.h"
|
||||
#include "scene/3d/collision_polygon.h"
|
||||
@ -441,8 +440,6 @@ void register_scene_types() {
|
||||
ClassDB::register_class<ReflectionProbe>();
|
||||
ClassDB::register_class<GIProbe>();
|
||||
ClassDB::register_class<GIProbeData>();
|
||||
ClassDB::register_class<BakedLightmap>();
|
||||
ClassDB::register_class<BakedLightmapData>();
|
||||
ClassDB::register_class<Particles>();
|
||||
ClassDB::register_class<CPUParticles>();
|
||||
ClassDB::register_class<Position3D>();
|
||||
|
Loading…
Reference in New Issue
Block a user