Skip to content

light terrain through the lightmap and wire up brightness - #803

Merged
Purdze merged 8 commits into
masterfrom
lightmap
Oct 27, 2026
Merged

Purdze merged 8 commits into
masterfrom
lightmap

Conversation

@Purdze

@Purdze Purdze commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / code cleanup
  • Performance improvement
  • Chore / tooling
  • Documentation

Summary

lights terrain through a lightmap: terrain now darkens at night and in storms, torches light warm, the nether and end get their light colours, and brightness works.

lightmap:

  • a 16x16 lightmap redrawn after each tick by a port of core/lightmap.fsh (block tint and flicker, sky factor and colour, ambient, brightness's notGamma mix; night vision, darkness and boss fog wired as 0 for now)
  • its inputs come from the dimension's environment attributes and its timelines' tracks, read from the synced registries (timeline tags resolved at the end of configuration), then the rain and thunder layers, as EnvironmentAttributeSystem resolves them
  • terrain samples it per vertex like terrain.vsh, through a new chunk pipeline set

terrain vertices:

  • block light in light_tint's first byte, sky light in the uv's free top byte, and the colour is tint x ao x face shade; still 16 bytes
  • smooth and flat lighting are a port of BlockModelLighter: smoothBlend, corner permeability, partial faces, emission and emissive blocks, and the flat path's own-state rule; models' ambientocclusion and elements' light_emission are read
  • fluids, lod and the missing cube sample world light through it instead of drawing fullbright
  • rotated models get their face corners rewound like FaceBakery.recalculateWinding, and blockstate turns are exact quarter turns
  • shading multiplies in gamma space with the exact srgb transfer instead of a 2.2 power, which crushed dark values

options: brightness is a real slider, labelled moody / default / bright or a number, and settable from the harness.

just mesh-hash also prints a geometry hash (quads' positions, uvs and sprites, however they split into triangles).

not here: effects in the lightmap, and entities, items, particles and weather through it.

Reference

Lightmap, LightmapRenderStateExtractor, core/lightmap.fsh, include/sample_lightmap.glsl, core/terrain.vsh, EnvironmentAttributeSystem, EnvironmentAttributes, WeatherAttributes, KeyframeTrack/KeyframeTrackSampler, Timeline, DimensionType, LightCoordsUtil, Options.gamma, BlockModelLighter, ModelBlockRenderer, FaceBakery

Testing

  • just ingame-test: 43 of 43, including the new world/lightmap (noon, midnight, moody, bright, thunder, a torch-lit room, lit and rotated blocks, the nether)
  • against the vanilla client on the same script, every shot is within ~2 per channel
  • geometry mesh hash unchanged from master; just bench mesh within ~2%
  • fmt, clippy with and without the harness, client tests

# Conflicts:
#	pomme-client/src/cpu_bench/mesh_hash.rs
#	pomme-client/src/cpu_bench/mod.rs
#	pomme-client/src/renderer/chunk/mesher.rs
#	pomme-client/src/renderer/shaders/chunk.vert
#	pomme-client/src/renderer/shaders/water.vert
@github-actions github-actions Bot added bug Something isn't working enhancement New feature or request labels Oct 27, 2026
@Purdze
Purdze merged commit 33f4ca2 into master Oct 27, 2026
15 of 16 checks passed
@Purdze
Purdze deleted the lightmap branch October 27, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant