2017-03-05 14:47:28 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* gi_probe.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2017-03-05 14:47:28 +00:00
|
|
|
/*************************************************************************/
|
2020-01-01 10:16:22 +00:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2017-03-05 14:47:28 +00:00
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2016-12-20 03:21:07 +00:00
|
|
|
#ifndef GIPROBE_H
|
|
|
|
#define GIPROBE_H
|
|
|
|
|
|
|
|
#include "multimesh_instance.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/3d/visual_instance.h"
|
2016-12-20 03:21:07 +00:00
|
|
|
|
|
|
|
class GIProbeData : public Resource {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(GIProbeData, Resource);
|
2016-12-20 03:21:07 +00:00
|
|
|
|
|
|
|
RID probe;
|
|
|
|
|
2019-10-03 20:39:08 +00:00
|
|
|
void _set_data(const Dictionary &p_data);
|
|
|
|
Dictionary _get_data() const;
|
|
|
|
|
|
|
|
Transform to_cell_xform;
|
|
|
|
AABB bounds;
|
|
|
|
Vector3 octree_size;
|
|
|
|
|
|
|
|
float dynamic_range;
|
|
|
|
float energy;
|
|
|
|
float bias;
|
|
|
|
float normal_bias;
|
|
|
|
float propagation;
|
|
|
|
float anisotropy_strength;
|
2019-10-14 06:45:44 +00:00
|
|
|
float ao;
|
2019-11-04 21:17:53 +00:00
|
|
|
float ao_size;
|
2019-10-03 20:39:08 +00:00
|
|
|
bool interior;
|
|
|
|
bool use_two_bounces;
|
|
|
|
|
2016-12-23 03:37:38 +00:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2019-10-03 20:39:08 +00:00
|
|
|
void _validate_property(PropertyInfo &property) const;
|
2016-12-20 03:21:07 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2020-02-17 21:06:54 +00:00
|
|
|
void allocate(const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3 &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts);
|
2017-11-17 02:09:00 +00:00
|
|
|
AABB get_bounds() const;
|
2019-10-03 20:39:08 +00:00
|
|
|
Vector3 get_octree_size() const;
|
2020-02-17 21:06:54 +00:00
|
|
|
Vector<uint8_t> get_octree_cells() const;
|
|
|
|
Vector<uint8_t> get_data_cells() const;
|
|
|
|
Vector<uint8_t> get_distance_field() const;
|
|
|
|
Vector<int> get_level_counts() const;
|
2016-12-20 03:21:07 +00:00
|
|
|
Transform get_to_cell_xform() const;
|
|
|
|
|
2019-10-03 20:39:08 +00:00
|
|
|
void set_dynamic_range(float p_range);
|
|
|
|
float get_dynamic_range() const;
|
2016-12-20 03:21:07 +00:00
|
|
|
|
2019-10-03 20:39:08 +00:00
|
|
|
void set_propagation(float p_propagation);
|
2017-02-06 08:12:15 +00:00
|
|
|
float get_propagation() const;
|
|
|
|
|
2019-10-03 20:39:08 +00:00
|
|
|
void set_anisotropy_strength(float p_anisotropy_strength);
|
|
|
|
float get_anisotropy_strength() const;
|
|
|
|
|
2019-10-14 06:45:44 +00:00
|
|
|
void set_ao(float p_ao);
|
|
|
|
float get_ao() const;
|
|
|
|
|
2019-11-04 21:17:53 +00:00
|
|
|
void set_ao_size(float p_ao_size);
|
|
|
|
float get_ao_size() const;
|
2019-10-14 06:45:44 +00:00
|
|
|
|
2019-10-03 20:39:08 +00:00
|
|
|
void set_energy(float p_energy);
|
2016-12-22 13:00:15 +00:00
|
|
|
float get_energy() const;
|
|
|
|
|
2019-10-03 20:39:08 +00:00
|
|
|
void set_bias(float p_bias);
|
2017-02-16 11:55:11 +00:00
|
|
|
float get_bias() const;
|
|
|
|
|
2019-10-03 20:39:08 +00:00
|
|
|
void set_normal_bias(float p_normal_bias);
|
2017-07-16 02:24:37 +00:00
|
|
|
float get_normal_bias() const;
|
|
|
|
|
2016-12-22 13:00:15 +00:00
|
|
|
void set_interior(bool p_enable);
|
|
|
|
bool is_interior() const;
|
2016-12-20 03:21:07 +00:00
|
|
|
|
2019-10-03 20:39:08 +00:00
|
|
|
void set_use_two_bounces(bool p_enable);
|
|
|
|
bool is_using_two_bounces() const;
|
2016-12-31 13:53:29 +00:00
|
|
|
|
2016-12-20 03:21:07 +00:00
|
|
|
virtual RID get_rid() const;
|
|
|
|
|
|
|
|
GIProbeData();
|
|
|
|
~GIProbeData();
|
|
|
|
};
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
class GIProbe : public VisualInstance {
|
|
|
|
GDCLASS(GIProbe, VisualInstance);
|
2016-12-23 03:37:38 +00:00
|
|
|
|
2016-12-20 03:21:07 +00:00
|
|
|
public:
|
2017-03-05 15:44:50 +00:00
|
|
|
enum Subdiv {
|
2016-12-20 03:21:07 +00:00
|
|
|
SUBDIV_64,
|
|
|
|
SUBDIV_128,
|
|
|
|
SUBDIV_256,
|
|
|
|
SUBDIV_512,
|
|
|
|
SUBDIV_MAX
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-10-30 19:33:07 +00:00
|
|
|
typedef void (*BakeBeginFunc)(int);
|
|
|
|
typedef void (*BakeStepFunc)(int, const String &);
|
|
|
|
typedef void (*BakeEndFunc)();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
private:
|
2016-12-20 03:21:07 +00:00
|
|
|
Ref<GIProbeData> probe_data;
|
|
|
|
|
|
|
|
RID gi_probe;
|
|
|
|
|
|
|
|
Subdiv subdiv;
|
|
|
|
Vector3 extents;
|
|
|
|
|
2017-12-14 11:59:46 +00:00
|
|
|
struct PlotMesh {
|
|
|
|
Ref<Material> override_material;
|
2020-03-17 06:33:00 +00:00
|
|
|
Vector<Ref<Material>> instance_materials;
|
2017-12-14 11:59:46 +00:00
|
|
|
Ref<Mesh> mesh;
|
|
|
|
Transform local_xform;
|
|
|
|
};
|
2016-12-20 03:21:07 +00:00
|
|
|
|
2017-12-14 11:59:46 +00:00
|
|
|
void _find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes);
|
2016-12-20 03:21:07 +00:00
|
|
|
void _debug_bake();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2017-10-30 19:33:07 +00:00
|
|
|
static BakeBeginFunc bake_begin_function;
|
|
|
|
static BakeStepFunc bake_step_function;
|
|
|
|
static BakeEndFunc bake_end_function;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_probe_data(const Ref<GIProbeData> &p_data);
|
2016-12-20 03:21:07 +00:00
|
|
|
Ref<GIProbeData> get_probe_data() const;
|
|
|
|
|
|
|
|
void set_subdiv(Subdiv p_subdiv);
|
|
|
|
Subdiv get_subdiv() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_extents(const Vector3 &p_extents);
|
2016-12-20 03:21:07 +00:00
|
|
|
Vector3 get_extents() const;
|
2019-10-31 22:54:21 +00:00
|
|
|
Vector3i get_estimated_cell_size() const;
|
2016-12-20 03:21:07 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void bake(Node *p_from_node = NULL, bool p_create_visual_debug = false);
|
2016-12-20 03:21:07 +00:00
|
|
|
|
2017-11-17 02:09:00 +00:00
|
|
|
virtual AABB get_aabb() const;
|
2020-02-17 21:06:54 +00:00
|
|
|
virtual Vector<Face3> get_faces(uint32_t p_usage_flags) const;
|
2016-12-20 03:21:07 +00:00
|
|
|
|
2019-03-02 23:45:14 +00:00
|
|
|
virtual String get_configuration_warning() const;
|
|
|
|
|
2016-12-20 03:21:07 +00:00
|
|
|
GIProbe();
|
|
|
|
~GIProbe();
|
|
|
|
};
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(GIProbe::Subdiv)
|
|
|
|
|
|
|
|
#endif // GIPROBE_H
|