Use Geometry Shader to generate the Mesh #5

Merged
EmaMaker merged 6 commits from vram-reduce into main 2023-07-19 13:19:19 +02:00

Instead of using greedy meshing to generate full quads on the CPU, greedy meshing only generates a cloud of points corresponding to the bottom-left corner of the quad. Three separate buffers are used to store information on vertex position, extent of the quad (in x,y,z) and other info about the texture and normal (block type, whether it's a backface or not).

Complete information about vertex normal and texture coordinates are derived from backface and extent data.
The other 3 vertices are generated on the GPU with a geometry shader using data from the cloud of points.

This means that a lot less data is sent to the GPU about each mesh, and this brings down VRAM usage:
In the standard world (seeds 12345, CHUNK_SIZE=32, RENDER_DISTANCE=16, camera centered at (512, 80, 512) ):

W/out geometry shader: 82MB
w/ geometry shader: 20MB

Instead of using greedy meshing to generate full quads on the CPU, greedy meshing only generates a cloud of points corresponding to the bottom-left corner of the quad. Three separate buffers are used to store information on vertex position, extent of the quad (in x,y,z) and other info about the texture and normal (block type, whether it's a backface or not). Complete information about vertex normal and texture coordinates are derived from backface and extent data. The other 3 vertices are generated on the GPU with a geometry shader using data from the cloud of points. This means that a lot less data is sent to the GPU about each mesh, and this brings down VRAM usage: In the standard world (seeds 12345, CHUNK_SIZE=32, RENDER_DISTANCE=16, camera centered at (512, 80, 512) ): W/out geometry shader: 82MB w/ geometry shader: 20MB
EmaMaker added 6 commits 2023-07-19 13:19:01 +02:00
EmaMaker merged commit 8313ee97bc into main 2023-07-19 13:19:19 +02:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: EmaMaker/voxel-engine#5
There is no content yet.