perf(render3d): the terrain's height and normal in R32F + RG16F, 128 MB where one RGBA32F was 256
The first generation pass's R32F height is kept as ter_height_tex (not copied into an RGBA32F), so every reader of the height - placement, the read-back, physics, selftest16's 9 mm - sees the same 32 bits. ternormal.frag writes the baked normal's x and z into ter_normal_tex (RG16F), and the six places that read it (terrain.frag twice, tersun.frag, grass.vert, grass.mesh, grass_cull.comp, which takes a third texture at binding 6) rebuild y. SPIR-V regenerated. Maroon Lake's play, headless Vulkan: 2793 -> 2647 MB. The camp's frame: 0.066% of pixels differ by more than 8 (mean 0.024/255), isolated grass blades at the slope gate. ludic-dev test 307/307. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f1049953c4
commit
1675eb451f
26 changed files with 77 additions and 36 deletions
|
|
@ -25,8 +25,9 @@ layout(set = 0, binding = 0) uniform Params {
|
|||
layout(set = 0, binding = 1) readonly buffer Tiles { vec4 tiles[]; }; // corner x/z, indices per cell, cells per side
|
||||
layout(set = 0, binding = 2) buffer Out { vec4 outv[]; }; // 4 per blade
|
||||
layout(set = 0, binding = 3) buffer Cmds { uint cmds[]; }; // VkDrawIndexedIndirectCommand per band
|
||||
layout(set = 0, binding = 4) uniform sampler2D u_height; // height, normal (terrain's u_ts_height)
|
||||
layout(set = 0, binding = 4) uniform sampler2D u_height; // the height (terrain's u_ts_height)
|
||||
layout(set = 0, binding = 5) uniform sampler2D u_ortho; // the photograph
|
||||
layout(set = 0, binding = 6) uniform sampler2D u_ter_normal; // the normal: x and z, y rebuilt
|
||||
|
||||
const float CELL = 4.0; // grass.ludic GRASS_CELL
|
||||
|
||||
|
|
@ -92,7 +93,8 @@ void main() {
|
|||
// the frustum, on a sphere round the blade (it stands at most 0.9 m tall)
|
||||
vec3 root = vec3(xz.x, ht.r, xz.y);
|
||||
for (int k = 0; k < 4; k++) { if (dot(pr.planes[k].xyz, root) + pr.planes[k].w < -1.0) return; }
|
||||
vec3 gn = normalize(ht.gba);
|
||||
vec2 gxz = textureLod(u_ter_normal, huv, 0.0).rg;
|
||||
vec3 gn = vec3(gxz.x, sqrt(max(1.0 - dot(gxz, gxz), 0.0)), gxz.y);
|
||||
float h3 = bladeHash(ci, j, 2), h4 = bladeHash(ci, j, 3);
|
||||
float wl = pr.lev.y;
|
||||
if (pr.lake.z > 0.0) { vec2 q = (xz - pr.lake.xy) / pr.lake.zw; if (dot(q, q) < 1.0) wl = max(wl, pr.lev.x); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue