Repository navigation
Ariadne: physically based materials and the scene's environment - #1503
Merged
Merged
Conversation
A geometry node's `material: { pbr: { metallic, roughness, emissive, coat } }`
shades it with VTK's PBR instead of Phong, and `scene: environment: { sky,
horizon, ground }` lights it from all round (image-based lighting from a
generated gradient). A scene with a pbr: node and no environment: gets a
default one; `environment: false` uses the lights alone. Gap item 5 of the
scene-format plan.
- GeometryNode::setPBR, setMetallic, setRoughness, setEmissive, setCoat
(state keys pbr, metallic, roughness, emissive_r/g/b, coat, coat_roughness).
Three post-replacement edits to VTK's PBR shader, on both its poly-data
mappers: the base colour read as sRGB (made linear) as a Phong surface takes
it; the lights' sum times pi, so a light lights a PBR surface face on as
brightly as a Phong one with diffuse 1; emissive without an emissive texture.
- SceneGraph::setImageBasedLighting / setEnvironment / resetEnvironment: an
8-bit sRGB equirectangular gradient, +z up, following the scene onto a new
renderer; ViewportManager's mirrors copy it with the lights.
- Loader: SceneNode::pbr_*, Scene::environment_*; realize_scene turns the
environment on; apply_node_material (and mesh_lab's copy) switch pbr: nodes.
- docs/ARIADNE.md §5.4 "Physically based materials"; example
examples/ariadne/documents/pbr_materials.ari.
- Tests: cvcgl_pbr_material (pixels against VTK's BRDF in closed form),
cvcgl_ariadne_pbr, loader PbrMaterialAndEnvironment.
…e/pbr-materials # Conflicts: # src/cvcGL/CMakeLists.txt
transfix
enabled auto-merge (squash)
November 23, 2026 21:32
The closed schema (#1464, merged into this branch from master) gains a material's pbr (a flag, or { metallic, roughness, emissive, coat } with coat a number or { strength, roughness }) and environment in both scene definitions (a flag, none, or { sky, horizon, ground }). Checked with the validator built in: ariadne_schema_test 13 (one skip), ariadne_loader_test 263, and pbr_materials.ari and cvcgl_ariadne_pbr's document validate.
src/cvcGL/CMakeLists.txt conflicted where this branch registers cvcgl_ariadne_pbr and #1491 cvcgl_ariadne_node_pick at the same place: both kept. With the validator: ariadne_schema_test 13 (one skip), ariadne_loader_test 264; cvcgl_pbr_material, cvcgl_ariadne_pbr 17/17 and cvcgl_ariadne_node_pick 23/23 on the merge.
transfix
added a commit
that referenced
this pull request
Nov 24, 2026
…ment, #1469 # Conflicts: # src/cvc/ariadne/loader.cpp # src/cvc/tests/ariadne_loader_test.cpp
transfix
added a commit
that referenced
this pull request
Nov 24, 2026
…ment # Conflicts: # src/cvc/ariadne/schema/ari.v1.schema.json # src/cvc/tests/ariadne_loader_test.cpp # src/cvcGL/ariadne/scene_realize.cpp
transfix
added a commit
that referenced
this pull request
Nov 24, 2026
…R materials and environment) # Conflicts: # src/cvc/tests/ariadne_loader_test.cpp
transfix
added a commit
that referenced
this pull request
Nov 24, 2026
…adow cache) Conflict in ViewportManager.cpp: master's #1503 copies a scene's image-based lighting into a mirror; SH2 syncs a mirror's lights only on a change. Both kept, the lights first, then the environment.
This was referenced Nov 24, 2026
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.
A geometry node can now be shaded physically. Until now a scene material was Phong only (
color,ambient,diffuse,specular), so a document could not say "brushed metal" or "car paint". This is item 5 of the Ariadne scene-format gap plan.The keys
material: { pbr: ... }shades the node with VTK's PBR instead of Phong.metallicis 0 (default) for a dielectric and 1 for a metal.roughnessis 0 for a mirror and 1 for matte (default 0.5).emissive: [r, g, b]is a colour the node glows with, lit or not.coatis a clear coat, as a strength or{ strength, roughness }.pbr: truetakes the defaults.color,textureor mesh colours, read as sRGB.ambient,diffuse,specular,specular_power) do not apply, and warn besidepbr:.scene: environment:is image-based lighting from a gradient:skystraight up, throughhorizon, togroundstraight down, about +z.pbr:node and noenvironment:gets a default, about as bright as Phong'sambient: 0.2.environment: false(ornone) uses the lights alone.Three choices to review
VTK's PBR doesn't fit next to Phong nodes as it stands. Each point below is one post-replacement line in the PBR shader, on both VTK mappers (desktop and the low-memory one WebGL uses).
pow(color, 1/2.2), which turned[0.8, 0.2, 0.2]into a pale pink. The shader now linearises the base colour (uniform, texture or per-vertex) first, so a colour means the same on a PBR node as on a Phong one. The emissive colour is linearised the same way.diffuse: 1. three.js's legacy (non-physical) light mode did the same.Without the environment, VTK's PBR has no ambient term at all, so a side the lights miss is black. That is why a
pbr:node gets a default environment.Changes
GeometryNode:setPBR,setMetallic,setRoughness,setEmissive,setCoat. State keyspbr,metallic,roughness,emissive_r/g/b,coatandcoat_roughnessare made only when first set. Off by default; off again, the node is Phong-shaded as before.SceneGraph:setImageBasedLighting,setEnvironment,resetEnvironment,environment,environmentTexture.ViewportManager: a mirror viewport copies its source's image-based lighting along with its lights, soviewportwidgets are lit the same.SceneNode::pbr_*andScene::environment_*.apply_node_materialswitches apbr:node, which covers its mesh,model:, LOD rungs, a dataset's meshes and ribbons. mesh_lab's own copy of the material code takespbr:too.realize_sceneturns the environment on for a scene withenvironment:or apbr:node.examples/ariadne/documents/pbr_materials.ari, with rows of paint and gold spheres across roughness, coated car paint, a lamp and a Phong sphere to compare.Tests
cvcgl_pbr_material, offscreen. A plate faces a light and the camera straight on, so its centre pixel has N = V = L and VTK's BRDF has a closed form.setPBRswitches the actor toVTK_PBRand back (a script's"off"or"True"in state too). Values clamp, a value set before the switch applies, and emissive is made linear.[0.8, 0.2, 0.2]lit at intensity 1 draws (202, 58, 58), exactly the closed form. VTK as it stands would draw (120, 34, 34), and linear with no π, a pale (227, 123, 123).(0.5, 0.25, 0), unlit, draws (128, 64, 0).setPBR(false)brings exactly that back.cvcgl_ariadne_pbr, 17 checks:pbr:node is PBR with its values and a Phong node stays Phong. The main view and the viewport widget's mirror are lit by the document's environment, and an emissive node glows orange.realize_scenealone: apbr:node gets the default environment,environment: falseturns it off, a scene with neither turns nothing on, and anenvironment:alone turns it on.ariadne_loader_testPbrMaterialAndEnvironment:pbr:warn;environment:spelledfalse,none,trueand a list.Verified locally
Windows, MSVC, with cvcGL (no examples, no pycvc). The full ctest suite ran twice.
On the original base (master 5949edc), 8,405 tests:
cvcgl_contour_labandcvcgl_volume_grid_contours(this build has nocvc::planar), andcvcgl_ari_golden's seven goldens, with the same pixel counts as code without this change.Merged with master 7f388fc, 8,541 tests at
-j 12:cvcmedia_audio_output, all pass rerun at-j 2.contour_tilerandvolume_grid_contourschanged pixel counts relative to the first run. Master's own changes moved them: master plus Ariadne: a scene node's own on_pick: #1491, with no PBR code, gives the same counts.pbr_materials.ariloads underShippedExamplesDeclareWhatTheyNeed.Not verified: Linux, macOS, wasm (WebGL2's prefilter pass renders to half-float cube maps; the environment image itself is 8-bit for that reason), and pycvc.
Schema
#1464 (the closed schema, which every load checks) merged first, so this PR carries its own keys (c10a837, after merging master in as 3a27560):
pbr: a flag, or{ metallic, roughness, emissive, coat }, where coat is a number or{ strength, roughness };environmentin both scene definitions: a flag,none, or{ sky, horizon, ground }.With the validator built in:
ariadne_schema_testpasses 13 (one skip, the without-validator case) andariadne_loader_testpasses 263.pbr_materials.ariandcvcgl_ariadne_pbr's document validate (ari validate). On the merged code,cvcgl_pbr_materialandcvcgl_ariadne_pbr(17/17) pass.Not done
cvc::model::materialalready has metallic, roughness and emissive).material:by design.