0f9de6dbb0
With a pack whose gbuffers_terrain (or a fallback) loads, solid and cutout terrain is drawn by it into the pack's buffers, in place, between prepare and deferred, and Horizon's own solid terrain draw is skipped. - depthtex0 is now a Depth32Float attachment: the blit writes the world's depth there (GL window depth, GL rows), terrain tests and writes against it, so entities and terrain occlude each other; later programs sample it as before. - The vertex glue reads Horizon's TerrainVertex on both draw paths (instanced, and flat with the page tables in bind group 1) and gives atlas coordinates, lightmap coordinates in 0-240, the vertex colour, mc_midTexCoord at the sprite's centre and mc_Entity = -1. Normals, tangents and block ids come later. - texture/gtexture/tex sample the block atlas, lightmap the lightmap; atlasSize is set. - Occlusion culling is off while a pack draws terrain (it reads the depth of Horizon's terrain draw), and flat draws stay on. - Uniforms a program reads that are not provided yet are reported. - Program building is shared by quads and terrain (build_pass, bind). - terrain-test: Horizon's own pack for this slice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
538 B
GLSL
20 lines
538 B
GLSL
#version 120
|
|
|
|
uniform sampler2D colortex0;
|
|
uniform sampler2D depthtex0;
|
|
uniform mat4 gbufferProjectionInverse;
|
|
uniform float far;
|
|
|
|
varying vec2 texcoord;
|
|
|
|
void main() {
|
|
vec3 color = texture2D(colortex0, texcoord).rgb;
|
|
if (texcoord.x > 0.5) {
|
|
float depth = texture2D(depthtex0, texcoord).r;
|
|
vec4 view = gbufferProjectionInverse * vec4(vec3(texcoord, depth) * 2.0 - 1.0, 1.0);
|
|
color.b = clamp(length(view.xyz / view.w) / far, 0.0, 1.0);
|
|
}
|
|
/* DRAWBUFFERS:0 */
|
|
gl_FragData[0] = vec4(color, 1.0);
|
|
}
|