Sodium

Sodium

35M Downloads

Consider using vertex pulling to more efficiently encode chunk geometry

jellysquid3 opened this issue ยท 0 comments

commented

There is currently a branch here which implements vertex pulling for quad geometry.

This has already enabled a number of significant advantages:

  • We can more efficiently pack the vertex data, which allows us to easily use 8-bit light values (#2228) and possibly even 20-bit vertex positions (fixing various problems with resource packs.)
  • We can access the shading attributes of all the quad's corners from the fragment shader, making it possible to implement proper smooth lighting and color blending for all geometry.
    • We have already made progress on also further improving the shading code to get rid of many artifacts present in vanilla.
    • This also eliminates the need for re-orienting quads, which was never quite correct and caused some problems in extremely specific cases with certain mods.
  • Mods like Iris are currently duplicating a lot of data per-vertex, which greatly increases VRAM consumption. Vertex pulling allows this duplicated data to be eliminated, with support on their side.

The biggest issues are somewhat obvious:

  • The current implementation is slow. This seems to be a problem with having the vertex shader read the entire quad struct on each invocation, and it needing to shove so much data across to the fragment shader. We can likely fix this problem by splitting vertex data (Positions, Texture UVs, etc) and quad data (Colors, Light Values, etc) into separate shader inputs.
  • OpenGL 4.x is required unless workarounds are implemented. For the most part, it seems feasible to emulate SSBOs with TBOs on OpenGL 3.x.
    • Data alignment may be a problem, and performance is not guaranteed to be identical.