Загрузка данных


# TASK: FIX 4 VISUAL BUGS (do them ONE at a time, wait for my "next")
Reply in Russian, code comments in English. Obey ALL golden rules from before: never delete working code, edit only needed lines, full files, no "..." placeholders, end with the report format. Change only the files named in each step.

## BUG 1: ALIEN WATER MASK (blue holes, white squares underwater)
Files: gbuffers_textured.fsh, gbuffers_hand.fsh, gbuffers_entities.fsh, gbuffers_terrain.fsh, gbuffers_basic.fsh, gbuffers_clouds.fsh, composite.fsh.
Cause: only gbuffers_water writes the mask in colortex2. Particles, hand, entities and terrain leave garbage there.
Fix:
- EVERY gbuffers_* fragment shader must write colortex2 = vec4(0.0, 0.5, lmcoord.y, 1.0) (mask = 0) and have a matching DRAWBUFFERS comment including 2 (e.g. /* DRAWBUFFERS:012 */) and matching gl_FragData writes.
- In shaders.properties add: clear colortex2 to 0 each frame (const vec4 colortex2ClearColor = vec4(0.0,0.0,0.0,0.0); and make sure colortex2 is NOT in the list of non-cleared buffers).
- In composite.fsh treat water only if mask > 0.9 (not 0.5).
- Particles (bubbles, rain, etc.) must keep their normal color with no water effects.

## BUG 2: HAND "AURA" SEES THROUGH WATER
Files: composite.fsh, gbuffers_hand.fsh.
- In composite.fsh, FIRST line of the water block: float d0 = texture2D(depthtex0, uv).r; if (d0 < 0.56) { pass colortex0 through unchanged; return; } (hand pixels have depth < 0.56 in Iris/OptiFine).
- Refraction sampling must also check that the sampled pixel's depth is not hand (d >= 0.56) and its mask is water, otherwise use the original uv.
- gbuffers_hand.fsh writes mask 0 (see Bug 1).

## BUG 3: UNDERWATER LOOK (camera inside water)
Files: lib/water.glsl, composite.fsh (new block "UNDERWATER" with BEGIN/END markers), final.fsh only if needed.
Uniforms: uniform int isEyeInWater; (1 = in water), uniform float rainStrength, uniform vec3 skyColor.
When isEyeInWater == 1:
- DO NOT run surface SSR, fresnel reflection or refraction on the water surface (skip the normal water block).
- Apply distance fog with Beer-Lambert from the CAMERA: dist = length(viewPos of depthtex0); transmittance = exp(-vec3(0.25, 0.07, 0.04) * dist * UNDERWATER_DENSITY); color = scene * transmittance + underwaterFogColor * (1.0 - transmittance). underwaterFogColor = deep teal (0.0, 0.18, 0.22) scaled by sky light and daylight (dark at night).
- Add light shafts (cheap): brightness boost near the sun direction, scaled by sunlight, only in daytime.
- Add caustics on the sea floor: animated procedural pattern (two scrolling voronoi/noise layers) multiplied onto lit terrain only, scaled by sun shadow.
- Keep visibility ~20-40 blocks by default, with slider UNDERWATER_DENSITY (0.3 to 3.0) and UNDERWATER_CAUSTICS on/off.
- Sky must NOT be visible as a blue flat fill: pixels with depth == 1.0 use underwaterFogColor.

## BUG 4: UGLY NIGHT
Files: lib/sky.glsl, lib/lighting.glsl, gbuffers_skybasic.*, gbuffers_skytextured.*, composite.fsh (SKY and LIGHTING blocks), lib/water.glsl.
Use uniforms: sunPosition, moonPosition, worldTime, sunAngle, rainStrength, upPosition.
- Compute sunHeight = dot(normalize(sunPosition), normalize(upPosition)) and nightFactor = smoothstep(0.1, -0.15, sunHeight).
- Sky at night: gradient from deep navy (0.01, 0.02, 0.06) at zenith to blue-teal (0.03, 0.06, 0.12) at horizon. NEVER pure black. Sunset/sunrise colors (orange/purple) must fade out completely when sunHeight < -0.1 (this removes the purple band at night).
- Moon: visible disc with soft glow, brightness HDR ~2.0, so bloom picks it up. Moon phases are optional.
- Stars: denser, with different sizes and slight twinkle (hash noise + frameTimeCounter), visible only when nightFactor > 0.
- Moonlight: color (0.35, 0.45, 0.75), intensity ~0.15-0.25 of daylight, still casts soft shadows (shadows use shadowLightPosition which is the moon at night). Ambient at night: (0.02, 0.03, 0.06) minimum so nothing is pitch black.
- Block light (torches) stays warm and bright at night so it looks good against blue moonlight.
- Water at night: darker color, reflects the NIGHT sky and moon (not the day sky), moon specular highlight with the same GGX code as the sun. Water must NOT be brighter than the sky.
- Add slider NIGHT_BRIGHTNESS (0.5 to 2.0).

## AFTER EACH BUG
1. FILES CHANGED / FILES NOT TOUCHED.
2. FEATURE CHECKLIST (yes/no): shadows, sun and moon, sky, clouds, lighting, bloom, tonemap, wind, emissive, water, underwater.
3. HOW TO TEST in Russian (put me in the exact situation: for Bug 2 hold an item above water, for Bug 3 dive, for Bug 4 use /time set midnight).

START WITH BUG 1 AND BUG 2 ONLY. Then stop and wait for me.