Skip to main content

Crate bevy_cube_marcher

Crate bevy_cube_marcher 

Source
Expand description

A shader-based marching cubes implementation for Bevy.

To get started, add the MarchingCubesPlugin to your app.

The plugin takes a type argument similar to a Bevy material, ChunkComputeShader. The ShaderRef provided by this type is a wgsl compute shader that takes a coordinate and returns the density of the chunk’s mass at that point, generally with positive values representing being inside the mass and negative values being in air, although the threshold can be configured with ChunkGeneratorSettings. See this example asset for more details.

The plugin also takes a type argument implementing GpuExtraBufferCache, defining additional buffers to be used in the density sampler. This example uses this to determine the final position of a Point Of Interest based on terrain generation.

ChunkGeneratorSettings must be inserted.

ChunkMaterial must be inserted.

An entity must also be given ChunkLoader to start generating any chunks.

Structs§

BufferCache
Holds the main vertex/triangles buffers. May be hashed and used as an identifying key for a loading chunk.
Chunk
Marker component for each chunk.
ChunkGenSystems
SystemSet for chunk generation systems.
ChunkGeneratorCache
Holds the loading states of all the chunks.
ChunkGeneratorSettings
Settings for a chunk generator. Also controls whether said generator is running.
ChunkLoader
Loads nearby chunks.
ChunkMaterial
Holds the actual material chunks should be spawned with.
ChunkRenderData
Holds the buffers for a chunk being generated.
ClearBufferCache
Event meaning any extra buffers should be cleared entirely to prevent memory leaks, like when the chunk generator is destroyed.
GpuChunkGeneratorCache
Holds extra buffers to be used when sampling the density field.
MarchingCubesPlugin
The plugin. Add this to your app or the crate won’t work!
ReadbackReallyComplete
Event that needs to be sent when an extra buffer has been finished reading from. Otherwise, the chunk will never finish generating.

Enums§

ChunkGeneratorRunning
Controls for whether the generator should be running.
LoadState
Whether a chunk is loading or has finished loading.
ShaderRef
A reference to a shader asset.

Traits§

ChunkComputeShader
Reference to the shader used for sampling the density field.
GpuExtraBufferCache
Defines extra buffers to be used in the density sampler.

Functions§

is_generator_running
Run condition for whether a chunk generator is running and listening to ChunkLoaders, regardless of whether it’s actually generating anything.
value_data
Converts a ShaderType into Vec<u8> data.