NF: refactor webgl lighting - #679
Merged
Merged
Conversation
Closed
Adds an opt-in single grazing light from the upper left, following the top-left lighting convention used for shaded-relief topographic maps. This makes sulci read as valleys and gyri as ridges, which is what makes bumpy flatmaps legible. #310 made this the unconditional default, but the lighting setup applies to every view, not just flatmaps, while bumpy_flatmap itself defaults to false -- and a single near-tangential light is noticeably dimmer than the existing three-light setup. Putting it behind a config flag alongside uniform_illumination keeps the default rendering untouched. Default and missing-key paths produce the same three lights, positions and intensities as before. Split out of #310. Co-Authored-By: alexhuth <alex.huth@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
mvdoc
force-pushed
the
enh/topleft-lighting-option
branch
from
August 21, 2026 21:56
5f4514f to
885b87a
Compare
The bump displacement and the flatBumpNorms normal perturbation only ever existed in Shaders.surface_pixel, so toggling bumpy_flatmap while showing a Vertex dataview did nothing at all: no HASFLAT define, no flatheight attribute, and vNormal left as the unperturbed surface normal, which is what made the flatmap read as a flat sheet even though the geometry underneath it had already been displaced. Port the HASFLAT blocks from surface_pixel into surface_vertex verbatim, so the two shaders now displace and shade the flatmap identically and the new lighting controls behave the same way for volume and vertex data. Note that the pick and depth shaders still use the old thickness-based displacement and are unaware of the bump, so picking on a bumpy flatmap tests against undisplaced geometry. That was already true for volume data before this change and is left alone here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Splits the lighting change out of #310 (which has been sitting since 2019 and no longer merges cleanly), and makes it opt-in.
What it does
Rationalize the lighting system. Now lighting options are controlled through a new "lighting" submenu under the surface GUI. This menu contains three options: topleft_lighting, uniform_illumination (moved here), and specularity (moved here):
topleft_lightingfades between two light setups: the standard VTK-inspired 3-light setup (at zero) and a single light from above and to the left of the camera (at one), following the top-left lighting convention used for shaded-relief topographic maps. This makes sulci read as valleys and gyri as ridges, which is what makes bumpy flatmaps legible — see @alexhuth's before/after screenshots in bumpy flatmap fixes #310. There is a switch for this in the config file, but it should probably be ignored and removed.uniform_illuminationfades between the standard lighting model (at zero) and uniform emissive shading for the surface (at one).specularitysmoothly adjusts the amount of specular reflection. There is a switch in the config that sets the default specularity to on or off.Each of these controls will automatically change as the surface morphs into its flattened mode, depending on whether
bumpy_flatmapis turned on or not.If
bumpy_flatmapis turned off:topleft_lightingwill always stay offuniform_illuminationwill go to 1.0 as the surface flattens, and then back to 0.0 as it folds up againspecularitywill go to 0.0 as the surface flattens, then back to its default value (0 or 1) as it folds upIf
bumpy_flatmapis turned on:topleft_lightingwill go to 1.0 as the surface flattens (giving nice hillshading), and back to 0.0 as it folds upuniform_illuminationwill always stay at 0.0specularitywill always stay at the default value