Repository navigation
fix: turn off all lighting for raster layers - #670
Merged
Merged
Conversation
MeshTextureLayer's fragment shader was vendored from SimpleMeshLayer, which runs every fragment through Phong lighting. The default material from #423 (ambient 1, diffuse 0) only cancels that out against deck.gl's default lights (white ambient at intensity 1). Any user-supplied LightingEffect changes the raster: an ambient intensity of 0.4 renders it at ~40% brightness, and a LightingEffect with only directional lights renders it black. The mesh is flat, so lighting can only ever scale the whole raster by a constant. Drop the lighting call and write the sampled color directly, like BitmapLayer. `material` no longer has any effect, so remove its default and exclude it from MeshTextureLayerProps. Closes #612 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
kylebarron
enabled auto-merge (squash)
September 23, 2026 22:40
kylebarron
added a commit
that referenced
this pull request
Nov 10, 2026
…#874) > [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Follows up #670. ### Problem #670 removed the lighting call from `MeshTextureLayer`'s fragment shader, but the layer still inherits `SimpleMeshLayer`'s `phongMaterial` shader module, which pulls in `lighting`. Nothing in the shaders reads them, yet deck.gl still computes and uploads both modules' uniforms on every draw. Every raster tile pays for lighting it never applies. ### Change `MeshTextureLayer.getShaders()` drops `phongMaterial` from the inherited modules. `lighting` was only there as its dependency, so it goes too. The vertex and fragment shaders don't reference either module. deck.gl's `LightingEffect` still sends `lighting` and `phongMaterial` props to every layer. luma.gl's `ShaderInputs` would warn `Module lighting not found` for them, but deck.gl's `Layer.getShaders()` sets `disableWarnings: true` on every model. That's the same path that already silences the `shadow` and `gouraudMaterial` props `LightingEffect` sends to every `SimpleMeshLayer`. I checked this with luma.gl's real `ShaderInputs`, the layer's shaders, and the props `LightingEffect` and the picking pass send: nothing is logged. ### Measurement This was measured in an app with about 300 COG tile meshes in view, in a production build: - **View:** 288 tile meshes at zoom 12. - **Browser:** headless Chrome at 2× DPR. - **Metric:** deck's draw time (`renderLayers`) per frame, averaged over 120 frames. The zoom was nudged every frame so the view uniforms change. Two runs each. It was measured by patching `MeshTextureLayer.prototype.getShaders` at runtime in the built app to filter out the same two modules, then rebuilding the tiles. It was not measured with this exact diff. | | draw time per frame | per tile mesh | |---|---|---| | with `phongMaterial` + `lighting` | 4.5 ms | 15.6 µs | | without them | **3.2 ms** | **11.1 µs** | That's about 29% less draw time. ### Tests - New test: the resolved shader modules of a `MeshTextureLayer` contain neither `phongMaterial` nor `lighting`. It fails without the change. - `pnpm -r --filter="!docs" typecheck`, `biome ci .` and the `deck.gl-raster` tests pass locally. No visible change: the shader already ignored lighting, so there are no screenshots. 🤖 Written by [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This turns off all lighting support for the raster layer.
Note
This PR was written by Claude (Claude Code) on behalf of @kylebarron.
Closes #612. Alternative to and closes #613.
Problem
MeshTextureLayer's fragment shader is vendored fromSimpleMeshLayer, which runs every fragment through Phong lighting (lighting_getLightColor). #423 set a default material (ambient: 1, diffuse: 0) that cancels lighting out, but only against deck.gl's default lights (a white ambient light at intensity 1.0). With a user-suppliedLightingEffect, raster colors change:BitmapLayerdoesn't have this problem because its shader never applies lighting.Change
The raster mesh is flat, so lighting can only multiply the whole raster by a constant. It never tells you anything about the data. This PR removes the lighting call from the fragment shader and writes the sampled color directly, like
BitmapLayer:materialno longer has any effect, so its default is removed and it's excluded fromMeshTextureLayerProps.MeshTextureLayerisn't exported from the package, so the public API doesn't change.Unlike #613, this doesn't add a
materialprop toRasterLayer/RasterTileLayeror override shader module props indraw(). The fact thatmaterial: falsedoesn't disable lighting in deck.gl v9 is an upstream bug: visgl/deck.gl#9696.If lighting becomes useful later (e.g. for extruded terrain), it can come back as an opt-in along with real mesh normals.
Testing
Checked
examples/cog-basicin Chrome with a temporaryLightingEffectpassed to the overlay, e.g.:mainAmbientLight, intensity 0.4DirectionalLightonlyNo new console errors or warnings.
tsc --noEmitandvitestpass. There's no new automated test, because a unit test could only check the shader source text.🤖 Written by Claude Code