diff options
Diffstat (limited to 'servers/visual')
-rw-r--r-- | servers/visual/rasterizer.h | 4 | ||||
-rw-r--r-- | servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp | 28 | ||||
-rw-r--r-- | servers/visual/rasterizer_rd/rasterizer_storage_rd.h | 4 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 3 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 3 |
5 files changed, 35 insertions, 7 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 5a39a6dbfd..51acd3a797 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -488,12 +488,14 @@ public: virtual RID gi_probe_create() = 0; - virtual void gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const PoolVector<uint8_t> &p_octree_cells, const PoolVector<uint8_t> &p_data_cells, const PoolVector<int> &p_level_counts) = 0; + virtual void gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &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) = 0; virtual AABB gi_probe_get_bounds(RID p_gi_probe) const = 0; virtual Vector3i gi_probe_get_octree_size(RID p_gi_probe) const = 0; virtual PoolVector<uint8_t> gi_probe_get_octree_cells(RID p_gi_probe) const = 0; virtual PoolVector<uint8_t> gi_probe_get_data_cells(RID p_gi_probe) const = 0; + virtual PoolVector<uint8_t> gi_probe_get_distance_field(RID p_gi_probe) const = 0; + virtual PoolVector<int> gi_probe_get_level_counts(RID p_gi_probe) const = 0; virtual Transform gi_probe_get_to_cell_xform(RID p_gi_probe) const = 0; diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp index 4c5b9b94fb..fa4cd39049 100644 --- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp @@ -3552,7 +3552,7 @@ RID RasterizerStorageRD::gi_probe_create() { return gi_probe_owner.make_rid(GIProbe()); } -void RasterizerStorageRD::gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const PoolVector<uint8_t> &p_octree_cells, const PoolVector<uint8_t> &p_data_cells, const PoolVector<int> &p_level_counts) { +void RasterizerStorageRD::gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &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) { GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); ERR_FAIL_COND(!gi_probe); @@ -3591,7 +3591,19 @@ void RasterizerStorageRD::gi_probe_allocate(RID p_gi_probe, const Transform &p_t gi_probe->data_buffer = RD::get_singleton()->storage_buffer_create(p_data_cells.size(), p_data_cells); gi_probe->data_buffer_size = p_data_cells.size(); - { + if (p_distance_field.size()) { + RD::TextureFormat tf; + tf.format = RD::DATA_FORMAT_R8_UNORM; + tf.width = gi_probe->octree_size.x; + tf.height = gi_probe->octree_size.y; + tf.depth = gi_probe->octree_size.z; + tf.type = RD::TEXTURE_TYPE_3D; + tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT; + Vector<PoolVector<uint8_t> > s; + s.push_back(p_distance_field); + gi_probe->sdf_texture = RD::get_singleton()->texture_create(tf, RD::TextureView(), s); + } +#if 0 { RD::TextureFormat tf; tf.format = RD::DATA_FORMAT_R8_UNORM; @@ -3659,6 +3671,7 @@ void RasterizerStorageRD::gi_probe_allocate(RID p_gi_probe, const Transform &p_t RD::get_singleton()->free(uniform_set); RD::get_singleton()->free(shared_tex); } +#endif } gi_probe->version++; @@ -3697,6 +3710,15 @@ PoolVector<uint8_t> RasterizerStorageRD::gi_probe_get_data_cells(RID p_gi_probe) } return PoolVector<uint8_t>(); } +PoolVector<uint8_t> RasterizerStorageRD::gi_probe_get_distance_field(RID p_gi_probe) const { + GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); + ERR_FAIL_COND_V(!gi_probe, PoolVector<uint8_t>()); + + if (gi_probe->data_buffer.is_valid()) { + return RD::get_singleton()->texture_get_data(gi_probe->sdf_texture, 0); + } + return PoolVector<uint8_t>(); +} PoolVector<int> RasterizerStorageRD::gi_probe_get_level_counts(RID p_gi_probe) const { GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe); ERR_FAIL_COND_V(!gi_probe, PoolVector<int>()); @@ -4341,7 +4363,7 @@ bool RasterizerStorageRD::free(RID p_rid) { reflection_probe->instance_dependency.instance_notify_deleted(p_rid); reflection_probe_owner.free(p_rid); } else if (gi_probe_owner.owns(p_rid)) { - gi_probe_allocate(p_rid, Transform(), AABB(), Vector3i(), PoolVector<uint8_t>(), PoolVector<uint8_t>(), PoolVector<int>()); //deallocate + gi_probe_allocate(p_rid, Transform(), AABB(), Vector3i(), PoolVector<uint8_t>(), PoolVector<uint8_t>(), PoolVector<uint8_t>(), PoolVector<int>()); //deallocate GIProbe *gi_probe = gi_probe_owner.getornull(p_rid); gi_probe->instance_dependency.instance_notify_deleted(p_rid); gi_probe_owner.free(p_rid); diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.h b/servers/visual/rasterizer_rd/rasterizer_storage_rd.h index 63713c6add..f24933a349 100644 --- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.h +++ b/servers/visual/rasterizer_rd/rasterizer_storage_rd.h @@ -967,12 +967,14 @@ public: RID gi_probe_create(); - void gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const PoolVector<uint8_t> &p_octree_cells, const PoolVector<uint8_t> &p_data_cells, const PoolVector<int> &p_level_counts); + void gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &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); AABB gi_probe_get_bounds(RID p_gi_probe) const; Vector3i gi_probe_get_octree_size(RID p_gi_probe) const; PoolVector<uint8_t> gi_probe_get_octree_cells(RID p_gi_probe) const; PoolVector<uint8_t> gi_probe_get_data_cells(RID p_gi_probe) const; + PoolVector<uint8_t> gi_probe_get_distance_field(RID p_gi_probe) const; + PoolVector<int> gi_probe_get_level_counts(RID p_gi_probe) const; Transform gi_probe_get_to_cell_xform(RID p_gi_probe) const; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 38f5c1ec58..0edb2762fa 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -344,12 +344,13 @@ public: BIND0R(RID, gi_probe_create) - BIND7(gi_probe_allocate, RID, const Transform &, const AABB &, const Vector3i &, const PoolVector<uint8_t> &, const PoolVector<uint8_t> &, const PoolVector<int> &) + BIND8(gi_probe_allocate, RID, const Transform &, const AABB &, const Vector3i &, const PoolVector<uint8_t> &, const PoolVector<uint8_t> &, const PoolVector<uint8_t> &, const PoolVector<int> &) BIND1RC(AABB, gi_probe_get_bounds, RID) BIND1RC(Vector3i, gi_probe_get_octree_size, RID) BIND1RC(PoolVector<uint8_t>, gi_probe_get_octree_cells, RID) BIND1RC(PoolVector<uint8_t>, gi_probe_get_data_cells, RID) + BIND1RC(PoolVector<uint8_t>, gi_probe_get_distance_field, RID) BIND1RC(PoolVector<int>, gi_probe_get_level_counts, RID) BIND1RC(Transform, gi_probe_get_to_cell_xform, RID) diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 37a2fffa7a..29f2f20941 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -268,12 +268,13 @@ public: FUNCRID(gi_probe) - FUNC7(gi_probe_allocate, RID, const Transform &, const AABB &, const Vector3i &, const PoolVector<uint8_t> &, const PoolVector<uint8_t> &, const PoolVector<int> &) + FUNC8(gi_probe_allocate, RID, const Transform &, const AABB &, const Vector3i &, const PoolVector<uint8_t> &, const PoolVector<uint8_t> &, const PoolVector<uint8_t> &, const PoolVector<int> &) FUNC1RC(AABB, gi_probe_get_bounds, RID) FUNC1RC(Vector3i, gi_probe_get_octree_size, RID) FUNC1RC(PoolVector<uint8_t>, gi_probe_get_octree_cells, RID) FUNC1RC(PoolVector<uint8_t>, gi_probe_get_data_cells, RID) + FUNC1RC(PoolVector<uint8_t>, gi_probe_get_distance_field, RID) FUNC1RC(PoolVector<int>, gi_probe_get_level_counts, RID) FUNC1RC(Transform, gi_probe_get_to_cell_xform, RID) |