perf(terrain): single shared VAO/VBO/EBO for all landblocks
Replace 25 per-landblock VAOs with one shared buffer set. Vertex positions are now baked in world space during AddLandblock (worldOrigin added to each vertex), so uModel is eliminated from terrain.vert entirely. Buffer rebuild happens on the cold path (landblock load/unload) via RebuildGpuBuffers. Draw loop: bind VAO once, then one glDrawElements per visible landblock into its sub-range of the shared EBO — same frustum-cull logic, no VAO/VBO rebind overhead per landblock. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
787e0f0aff
commit
d35e4b6de7
2 changed files with 171 additions and 100 deletions
|
|
@ -6,7 +6,6 @@ layout(location = 3) in uvec4 aPacked1; // bytes: ovl1Tex, ovl1Alpha, ovl2Tex,
|
|||
layout(location = 4) in uvec4 aPacked2; // bytes: road0Tex, road0Alpha, road1Tex, road1Alpha
|
||||
layout(location = 5) in uvec4 aPacked3; // bits: rot fields + splitDir (see below)
|
||||
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
|
|
@ -89,7 +88,8 @@ void main() {
|
|||
else baseUV = vec2(0.0, 0.0);
|
||||
|
||||
vBaseUV = baseUV;
|
||||
vWorldNormal = normalize(mat3(uModel) * aNormal);
|
||||
// Vertices are baked in world space; normals need no model transform.
|
||||
vWorldNormal = normalize(aNormal);
|
||||
|
||||
float baseTex = float(aPacked0.x);
|
||||
if (baseTex >= 254.0) baseTex = -1.0;
|
||||
|
|
@ -101,5 +101,5 @@ void main() {
|
|||
vRoad0 = unpackOverlayLayer(aPacked2.x, aPacked2.y, rotRd0, baseUV);
|
||||
vRoad1 = unpackOverlayLayer(aPacked2.z, aPacked2.w, rotRd1, baseUV);
|
||||
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPos, 1.0);
|
||||
gl_Position = uProjection * uView * vec4(aPos, 1.0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue