Skip to content

Conversation

@cb341
Copy link
Owner

@cb341 cb341 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

@cb341 cb341 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,

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

cb341 commented Mar 31, 2025

This PR has been abandoned in favour of implementing own RayTracer

@cb341 cb341 closed this Mar 31, 2025
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.

2 participants