Skip to content

NF: refactor webgl lighting - #679

Merged
mvdoc merged 4 commits into
mainfrom
enh/topleft-lighting-option
Aug 21, 2026
Merged

NF: refactor webgl lighting#679
mvdoc merged 4 commits into
mainfrom
enh/topleft-lighting-option

Conversation

@mvdoc

@mvdoc mvdoc commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

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_lighting fades 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_illumination fades between the standard lighting model (at zero) and uniform emissive shading for the surface (at one).
  • specularity smoothly 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_flatmap is turned on or not.

If bumpy_flatmap is turned off:

  • topleft_lighting will always stay off
  • uniform_illumination will go to 1.0 as the surface flattens, and then back to 0.0 as it folds up again
  • specularity will go to 0.0 as the surface flattens, then back to its default value (0 or 1) as it folds up

If bumpy_flatmap is turned on:

  • topleft_lighting will go to 1.0 as the surface flattens (giving nice hillshading), and back to 0.0 as it folds up
  • uniform_illumination will always stay at 0.0
  • specularity will always stay at the default value

@mvdoc mvdoc mentioned this pull request Aug 20, 2026
mvdoc and others added 2 commits August 21, 2026 14:56
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
mvdoc force-pushed the enh/topleft-lighting-option branch from 5f4514f to 885b87a Compare August 21, 2026 21:56
@alexhuth alexhuth changed the title NF: add webgl_viewopts.topleft_lighting config option NF: refactor webgl lighting Aug 21, 2026
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>
@mvdoc
mvdoc merged commit 0fa99b3 into main Aug 21, 2026
13 checks passed
@mvdoc
mvdoc deleted the enh/topleft-lighting-option branch August 21, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant