17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-07 06:28:08 +01:00

feat(terrain): holes cut in the heightmap terrain and shader grass painted over it

This commit is contained in:
2026-10-20 01:32:01 +02:00
parent d7ba6926fc
commit f3bdadad66
32 changed files with 2020 additions and 30 deletions

View File

@@ -51,6 +51,12 @@ void main()
{
// place within the chunk, 0..1 along x and z, and the paint samples around it
vec2 local = clamp(vec2(f_coord.x - param[2].x, -f_coord.y - param[2].y) * param[2].z, 0.0, 1.0);
#if TERRAIN_HOLES
// the openings cut in the ground (mat_terrain_holes.frag): the mask led between its samples, cut over the half.
// discarded at the end, the neighbours of the fragment still need it for their derivatives
float holeside = float(textureSize(holes, 0).x);
bool cut = (texture(holes, (local * (holeside - 1.0) + 0.5) / holeside).r > 0.5);
#endif
float samples = param[2].w;
vec2 paintcoord = (local * samples + 0.5) / (samples + 1.0);
vec4 w0 = texture(weights0, paintcoord);
@@ -122,6 +128,10 @@ void main()
vec3 fragcolor = ambient;
fragcolor = apply_lights(fragcolor, fragnormal, albedo, reflectivity, specularity, shadow_tone);
#if TERRAIN_HOLES
if (cut)
discard;
#endif
vec4 color = vec4(apply_fog(fragcolor), alpha_mult);
#if POSTFX_ENABLED
out_color = color;