diff options
Diffstat (limited to 'scene/3d/gi_probe.cpp')
-rw-r--r-- | scene/3d/gi_probe.cpp | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 52c4efb7f1..2423c0a7a3 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -41,6 +41,7 @@ void GIProbeData::_set_data(const Dictionary &p_data) { ERR_FAIL_COND(!p_data.has("octree_size")); ERR_FAIL_COND(!p_data.has("octree_cells")); ERR_FAIL_COND(!p_data.has("octree_data")); + ERR_FAIL_COND(!p_data.has("octree_df")); ERR_FAIL_COND(!p_data.has("level_counts")); ERR_FAIL_COND(!p_data.has("to_cell_xform")); @@ -48,10 +49,11 @@ void GIProbeData::_set_data(const Dictionary &p_data) { Vector3 octree_size = p_data["octree_size"]; PoolVector<uint8_t> octree_cells = p_data["octree_cells"]; PoolVector<uint8_t> octree_data = p_data["octree_data"]; + PoolVector<uint8_t> octree_df = p_data["octree_df"]; PoolVector<int> octree_levels = p_data["level_counts"]; Transform to_cell_xform = p_data["to_cell_xform"]; - allocate(to_cell_xform, bounds, octree_size, octree_cells, octree_data, octree_levels); + allocate(to_cell_xform, bounds, octree_size, octree_cells, octree_data, octree_df, octree_levels); } Dictionary GIProbeData::_get_data() const { @@ -60,13 +62,14 @@ Dictionary GIProbeData::_get_data() const { d["octree_size"] = get_octree_size(); d["octree_cells"] = get_octree_cells(); d["octree_data"] = get_data_cells(); + d["octree_df"] = get_distance_field(); d["level_counts"] = get_level_counts(); d["to_cell_xform"] = get_to_cell_xform(); return d; } -void GIProbeData::allocate(const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3 &p_octree_size, const PoolVector<uint8_t> &p_octree_cells, const PoolVector<uint8_t> &p_data_cells, const PoolVector<int> &p_level_counts) { - VS::get_singleton()->gi_probe_allocate(probe, p_to_cell_xform, p_aabb, p_octree_size, p_octree_cells, p_data_cells, p_level_counts); +void GIProbeData::allocate(const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3 &p_octree_size, const PoolVector<uint8_t> &p_octree_cells, const PoolVector<uint8_t> &p_data_cells, const PoolVector<uint8_t> &p_distance_field, const PoolVector<int> &p_level_counts) { + VS::get_singleton()->gi_probe_allocate(probe, p_to_cell_xform, p_aabb, p_octree_size, p_octree_cells, p_data_cells, p_distance_field, p_level_counts); bounds = p_aabb; to_cell_xform = p_to_cell_xform; octree_size = p_octree_size; @@ -84,6 +87,10 @@ PoolVector<uint8_t> GIProbeData::get_octree_cells() const { PoolVector<uint8_t> GIProbeData::get_data_cells() const { return VS::get_singleton()->gi_probe_get_data_cells(probe); } +PoolVector<uint8_t> GIProbeData::get_distance_field() const { + return VS::get_singleton()->gi_probe_get_distance_field(probe); +} + PoolVector<int> GIProbeData::get_level_counts() const { return VS::get_singleton()->gi_probe_get_level_counts(probe); } @@ -127,6 +134,24 @@ float GIProbeData::get_energy() const { return energy; } +void GIProbeData::set_ao(float p_ao) { + VS::get_singleton()->gi_probe_set_ao(probe, p_ao); + ao = p_ao; +} + +float GIProbeData::get_ao() const { + return ao; +} + +void GIProbeData::set_ao_strength(float p_ao_strength) { + VS::get_singleton()->gi_probe_set_ao_strength(probe, p_ao_strength); + ao_strength = p_ao_strength; +} + +float GIProbeData::get_ao_strength() const { + return ao_strength; +} + void GIProbeData::set_bias(float p_bias) { VS::get_singleton()->gi_probe_set_bias(probe, p_bias); bias = p_bias; @@ -206,6 +231,12 @@ void GIProbeData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_anisotropy_strength", "strength"), &GIProbeData::set_anisotropy_strength); ClassDB::bind_method(D_METHOD("get_anisotropy_strength"), &GIProbeData::get_anisotropy_strength); + ClassDB::bind_method(D_METHOD("set_ao", "ao"), &GIProbeData::set_ao); + ClassDB::bind_method(D_METHOD("get_ao"), &GIProbeData::get_ao); + + ClassDB::bind_method(D_METHOD("set_ao_strength", "strength"), &GIProbeData::set_ao_strength); + ClassDB::bind_method(D_METHOD("get_ao_strength"), &GIProbeData::get_ao_strength); + ClassDB::bind_method(D_METHOD("set_interior", "interior"), &GIProbeData::set_interior); ClassDB::bind_method(D_METHOD("is_interior"), &GIProbeData::is_interior); @@ -223,12 +254,16 @@ void GIProbeData::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "normal_bias", PROPERTY_HINT_RANGE, "0,8,0.01"), "set_normal_bias", "get_normal_bias"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "propagation", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_propagation", "get_propagation"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "anisotropy_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_anisotropy_strength", "get_anisotropy_strength"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ao", "get_ao"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ao_strength", "get_ao_strength"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_two_bounces"), "set_use_two_bounces", "is_using_two_bounces"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_interior", "is_interior"); } GIProbeData::GIProbeData() { + ao = 0.0; + ao_strength = 0.5; dynamic_range = 4; energy = 1.0; bias = 1.5; @@ -406,7 +441,13 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { if (probe_data.is_null()) probe_data.instance(); - probe_data->allocate(baker.get_to_cell_space_xform(), AABB(-extents, extents * 2.0), baker.get_giprobe_octree_size(), baker.get_giprobe_octree_cells(), baker.get_giprobe_data_cells(), baker.get_giprobe_level_cell_count()); + if (bake_step_function) { + bake_step_function(pmc++, RTR("Generating Distance Field")); + } + + PoolVector<uint8_t> df = baker.get_sdf_3d_image(); + + probe_data->allocate(baker.get_to_cell_space_xform(), AABB(-extents, extents * 2.0), baker.get_giprobe_octree_size(), baker.get_giprobe_octree_cells(), baker.get_giprobe_data_cells(), df, baker.get_giprobe_level_cell_count()); set_probe_data(probe_data); probe_data->set_edited(true); //so it gets saved |