fix chunk boundaries
This commit is contained in:
parent
ee5c2662e3
commit
bc58e13a61
@ -36,7 +36,8 @@ func create_device(world_size: int):
|
|||||||
pipeline2 = rd.compute_pipeline_create(shader_pass2)
|
pipeline2 = rd.compute_pipeline_create(shader_pass2)
|
||||||
|
|
||||||
# 3. Pre-allocate Buffers (assuming world_size is constant)
|
# 3. Pre-allocate Buffers (assuming world_size is constant)
|
||||||
var total = world_size ** 3
|
# add 1 to look at adjacent voxels for chunk boundaries
|
||||||
|
var total = (world_size + 2) ** 3
|
||||||
|
|
||||||
# We create them once with empty/zero data of the correct size
|
# We create them once with empty/zero data of the correct size
|
||||||
buffer = rd.storage_buffer_create(total * 4)
|
buffer = rd.storage_buffer_create(total * 4)
|
||||||
@ -49,6 +50,7 @@ func create_device(world_size: int):
|
|||||||
params_buffer = rd.uniform_buffer_create(16) # world_size, threshold, time, etc
|
params_buffer = rd.uniform_buffer_create(16) # world_size, threshold, time, etc
|
||||||
|
|
||||||
func compute_mesh(world_size: int, threshold: float, chunk_pos: Vector3) -> ArrayMesh:
|
func compute_mesh(world_size: int, threshold: float, chunk_pos: Vector3) -> ArrayMesh:
|
||||||
|
world_size += 2
|
||||||
|
|
||||||
# 1. Update existing buffers with NEW data for THIS chunk
|
# 1. Update existing buffers with NEW data for THIS chunk
|
||||||
var chunk_pos_data = PackedFloat32Array([chunk_pos.x, chunk_pos.y, chunk_pos.z, 0.0]).to_byte_array()
|
var chunk_pos_data = PackedFloat32Array([chunk_pos.x, chunk_pos.y, chunk_pos.z, 0.0]).to_byte_array()
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
constant = Color(0.30202293, 0.6060653, 0.9109474, 1)
|
constant = Color(0.30202293, 0.6060653, 0.9109474, 1)
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
modes/cull = 2
|
||||||
nodes/vertex/0/position = Vector2(360, 220)
|
nodes/vertex/0/position = Vector2(360, 220)
|
||||||
nodes/fragment/0/position = Vector2(660, 140)
|
nodes/fragment/0/position = Vector2(660, 140)
|
||||||
nodes/fragment/2/node = SubResource("VisualShaderNodeColorConstant_sxi40")
|
nodes/fragment/2/node = SubResource("VisualShaderNodeColorConstant_sxi40")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user