Skip to content

Conversation

CuddlyBunion341
Copy link
Owner

@CuddlyBunion341 CuddlyBunion341 commented Mar 21, 2025

Vertex Data Packing

Currently the terrain uses up a lot of memory. This could be the cause for all the lag spikes when rendering the world.
One optimization is reducing the amount of data each vertex holds by packing multiple attributes into one number and extracting the individual values in a vertex shader, adding a little overhead to every render.

The following plan is based on the Information Theory class from ZHAW:

image

Copy link
Owner Author

@CuddlyBunion341 CuddlyBunion341 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wip

chunk_position: Vec3,
mesh_type: MeshType,
material_handle: Handle<StandardMaterial>,
material_handle: Handle<ExtendedMaterial<StandardMaterial, MyExtension>>,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define Type Alias for the material

Suggested change
material_handle: Handle<ExtendedMaterial<StandardMaterial, MyExtension>>,
material_handle: Handle<ChunkMaterial>,

Comment on lines 26 to 27
@location(0) position: vec3<f32>,
@location(1) blend_color: vec4<f32>,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use packed data

Suggested change
@location(0) position: vec3<f32>,
@location(1) blend_color: vec4<f32>,
@location(0) packed_data: f32,

Comment on lines 10 to 13
// We need to ensure that the bindings of the base material and the extension do not conflict,
// so we start from binding slot 100, leaving slots 0-99 for the base material.
#[uniform(100)]
pub quantize_steps: u32,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No parameter needed, wie just override the vertex shader

Suggested change
// We need to ensure that the bindings of the base material and the extension do not conflict,
// so we start from binding slot 100, leaving slots 0-99 for the base material.
#[uniform(100)]
pub quantize_steps: u32,

@CuddlyBunion341 CuddlyBunion341 changed the title wip Vertex data packing Mar 29, 2025
@CuddlyBunion341 CuddlyBunion341 marked this pull request as draft March 30, 2025 14:33
@CuddlyBunion341
Copy link
Owner Author

This PR has been abandoned in favour of implementing own RayTracer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant