Use Geometry Shader to generate the Mesh #5
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "vram-reduce"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
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