Repository navigation
cvcGL: a generated world's trees lean and sway in the scene's wind - #1323
Merged
Merged
Conversation
…in both seas (O13) - cvc::algo::wind_field: the scene's gusts as one deterministic function of (x, y, t): two scales of integer-hashed value noise carried downwind and ABYSSAL's pulse over time. cvc/gl/WindGLSL.h is the same in GLSL, no texture. Everything the wind moves (O14: the clouds, the trees, the air physics) can sample it at the same point and time. - cvc::ocean: fetch.h (the fetch map in one upwind sweep, coarse, capped by each body's extent; each cascade scaled by sqrt(F / F_full), F_full where its band is fully grown), sea_lag.h (the sea's wind follows with a time constant and steps by keyframes, at most one per crossfade), current.h (a divergence-free curl-noise current and a two-phase flow map). sea_surface takes a sea_forcing: the h0 crossfade, the fetch scales, the ripples' gust weight, the current. - Ariadne: scene_wind.h reads a node's wind in one place (O14 points it at wind.*). SceneWaterSeaClock steps the keyframes both seas use. New water keys: gustiness, lee, sea_lag, sea_fade, current (water_controls.ari, ARIADNE.md). - cvcGL: OceanWind (one RG32F texture of the two keyframes' fetch maps; the gusts and the current hashed per vertex). The water node and lsystem_coast draw the lee, the gusts (the ripples' weight, cat's paws in the shading), the current carrying the two short cascades, and mix the two keyframes' h0 on the CPU only while a crossfade runs. - Tests: ocean_wind_test (fetch behind an island and on a lake, the lag and its debounce, a continuous crossfade, golden hashes of the fetch map, the gusts and the current, a divergence-free current, the physics sea's lee and current), a floating crate in the lee against one in the open (ariadne_scene_world_test), the water node's new keys (cvcgl_ariadne_realize). No golden hash moved: a sea_surface without a forcing has the same digest and values as before.
… its push on bodies (O14) A document's scene: wind: seeds wind.speed, wind.dir and wind.gustiness. While wind.speed is set, the water (both seas), cloud_sky's drift and orographic heading, and the forest's lean and sway all follow those keys, sampling the same gust field at the same (x, y, t). Each node's own wind keys are the fallback. SceneWind::azimuth is dir + 90 (O13 had it mirrored). cvc::physics: field::wind takes a flow_velocity (a velocity in space and time, with a digest). wind_flow is the scene's wind over a power-law height profile, linear below 0.1 m. A flow with a wind may have no volume (then it is air everywhere). The field step reads the wind once per body and its profile at nine heights across the body, and clips cells to the wind's base. The wind's digest is in save() and state_hash(); a world without one hashes as before. A vehicle's aero drag reads the wind at its centre of mass. The push: SceneWorld adds the wind as a flow field. WorldVehicles' dynamic, dynamic4w and kinematic fleets get the wind's share of the drag through the drive's external force. The room rules carry the wind to arisrv: dynamic avatars stand in a flow field, and kinematic avatars drift once the wind's drag beats the walker's grip, the drift folded into the intent. wind_controls.ari; docs: roadmap As built (O14), ARIADNE.md Wind, PHYSICS_API.md flow hook.
…ater and clouds, and a Wind panel in Settings The water's and the clouds' own winds stay as fallbacks. The Water and Sky panels' wind sliders say they are unused while the scene has a wind.
…th the wind on and off
Every prop mesh of a generated_world (the wood, which holds the native trees' crowns, the leaves, the needles, on every LOD rung) leans downwind and sways in the vertex shader while the scene has a wind, from uniforms alone: the wind's direction, the lean and sway, the clock, the camera and the gust field (cvc_wind_gust). No texture and no vertex array, which the low-memory mapper would spend a unit on. A vertex's height above the ground rides in its normal's length (1 + h / 64): the lighting normalises it away, and the shader reads it back, so a point moves as (h - 0.3)^2 and a trunk's foot stays put. The phase is the vertex's world position. The displacement goes in at //VTK::Clip::Impl as a #define of vertexMC, so either mapper's position code follows it. The inputs skip the shadow bake, so the trees' shadows stay at rest. The sway fades out 300-450 m from the camera. world.sway (prop sway, 1; Tree sway on the Terrain Lab panel) scales it; world.lean_dir publishes the way the trees lean. Without a scene wind they stand still, as before.
The trees' shadow map is baked at rest, and a swayed point that had moved behind its own rest-pose surface read as shadowed: dark streaks along the trunk and limbs, faint at 9 m/s close up and the trunk nearly black at 25 m/s. A prop mesh now passes its unswayed view-space position to the fragments and points the first shadow lookup (calcShadow of the FilteredShadowMapPass) at it, so a swaying tree is shaded as the at-rest map says. One varying, no texture or uniform. Docs: the roadmap's trees note gets this and the frame cost measured on a quiet machine (a GPU timer: a few tenths of a millisecond near the trees; nothing arigl's frame shows).
…intent The test runs 120 frames while a writer thread replaces vehicle a's intent, then expects a to be moving. A thread can start late: on a busy machine all 120 frames (a few tens of milliseconds) passed before the writer ran, no intent reached a, and only the last 6 frames moved it. That reads 0.10766078436440293 m/s, which is what recipe / windows-2022 / Release read on #1318, and what a writer held back until the frames end reads here, bit for bit. The frames now start once the writer has landed an intent (10 s at most). A failure says a's speed after the threaded frames, how many intents landed during them, and whether a existed. It passes with the writer started 300 ms late.
…s mid-run After its first intent the writer may still be descheduled for all 120 frames (a few tens of milliseconds on a busy machine), which would fail the check that an intent landed while the world stepped. The world now steps on, a frame at a time, until one does (10 s at most).
This branch carried #1311's original commit (b6ab0c4), whose files are identical in the squash. The add/add conflicts (wind_field.h/.cpp, scene_wind.h/.cpp) and water_controls.ari take this branch's side, which is #1311 plus #1317's changes. docs/ARIADNE.md is a three-way merge on b6ab0c4 as its base, so master's later edits and #1317's both stand. Against master, the result is exactly #1317's own diff against b6ab0c4: the same 44 files and the same changed lines.
…ne-wind # Conflicts: # docs/PHYSICS_API.md
master fails to build arisrvx's python_engine.cpp: #1302 (bridged users) added room(), bridge_presence(), bridge_absent(), bridge_post() and listen_chat() calling server_link() with no argument, written against the process-wide server link that the P0a cleanup replaced with the module's own state, server_link(PyObject *self). Each of the five now names its module argument self and passes it, as the other server ops (lent(), publish(), ...) already do. Found in #1324's pycvc-linux / cp312 job (run 43956686020), which builds the PR merged with master.
…ne-wind # Conflicts: # src/cvcGL/test/cvcgl_ariadne_realize.cpp
The realize suite runs every node type's checks in one process. In a Linux Debug job (Xvfb, llvmpipe) it took 250.6 s, 50 s under the 300 s a test without a TIMEOUT gets; on a slower runner (#1309's Debug job, where PhConvoy and Ewave also ran about 1.3x longer) it timed out on all three attempts. As cvcgl_ewave, cvcgl_wake and cvcgl_volren_node have, it gets a budget of its own with headroom, so only a real hang fails it.
…ter's arisrvx build
…ize's Debug timeout
…ne-wind # Conflicts: # src/cvc/ariadne/scene_world.cpp # src/cvc/ariadne/world_vehicles.cpp # src/cvc/tests/ariadne_scene_world_test.cpp
…ne-wind # Conflicts: # docs/ARIADNE.md # examples/ariadne/documents/terrain_lab.ari # src/cvc/ariadne/components/INDEX.ari # src/cvc/ariadne/components/sky_controls.ari # src/cvcGL/ariadne/lsystem_nodes.cpp # src/cvcGL/test/cvcgl_ariadne_realize.cpp
…feat/scene-wind #1322 moved each cell's reads into read_cell() (and ahead of the loop, on the field workers, for a free surface's cells). The scene wind's per-cell work moves with it: body_wind holds a body's wind (its reference at the centre of mass and its height profile), made once per body and field as before, and read_cell takes it to clip the cell at the wind's base and to read its velocity. A wind is a flow's and a free surface a fluid's, so the workers' reads never need it. The arithmetic is the branch's, in the same order. world.cpp keeps #1322's timing and the branch's field_time() for the vehicles' pre_step; the tests are both sides'.
…ne-wind # Conflicts: # docs/ARIADNE.md # examples/ariadne/documents/terrain_lab.ari # src/cvcGL/test/cvcgl_ariadne_realize.cpp
…e-wind world_vehicles.cpp: the runtime keeps both the scene's wind (set_wind) and the boats' still water. The wind's push on the plants that feel no field now leaves the boat fleet out as it leaves out the jolt vehicles: a boat's hull is a dynamic body in the scene's physics world, so the wind's flow field already drags on its part in the air, and the push would charge it twice.
transfix
enabled auto-merge (squash)
November 17, 2026 18:05
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.
terrain_lab's trees lean and sway with the scene's wind and its gusts. They're the generated world's prop meshes, which had never moved.
Stacked on #1317 (O14), which is stacked on #1311. The base is
feat/scene-wind; retarget down the stack as each one merges. It's independent of #1318.What changed, and where
All of it is in
src/cvcGL/ariadne/world_nodes.cpp:What sways. Every prop mesh of a
generated_world, on every LOD rung, leans downwind and sways in the vertex shader while the scene has a wind:native_pineandnative_branchy, so their crowns are in the wood mesh);Without a scene wind the trees stand still, as before.
Uniforms only, no new samplers, no new vertex array. The low-memory mapper keeps each vertex array in a texture unit, so even a new attribute would cost a unit. The inputs are shared by all the prop meshes (
GeometryNode::ShaderInputs, keycvc.foliage_wind, set once a frame):uFwOn(on/off),uFwDir(the way it blows);uFwMotion: lean, sway and the clock;cvc_wind_gustfromWindGLSL.h.Height above the trunk base, without a new attribute. The meshes are merged and the shader has no ground to sample. So when a prop cell's meshes are made, each vertex's normal is computed and lengthened to 1 + h/64, h being its height above the world's ground (
with_lift_normals). VTK's lighting normalises the normal, so shading is unchanged, and the shader reads h back from the length. This also spares GeometryNode itsvtkPolyDataNormalspass for these meshes.The motion. A point moves downwind by a·(h − 0.3)²/10. a is the lean plus a sway term, sin(1.3t + φ), times the gust at the vertex.
New keys.
world.swayscales the motion (propsway, default 1; 0 holds the trees). It's on the Terrain Lab panel as "Tree sway", applied at once with no Regenerate.world.lean_dirpublishes the way the trees lean, asforest.lean_dirdoes forforest_trees.Both mappers. The displacement goes in at
//VTK::Clip::Implas a#define vertexMC, the way DrapedLinkNode drapes. That's the earliest point where the low-memory mapper has declaredvertexMCandnormalMC, so VTK's own position code follows it in either mapper.Shadows stay at rest. The inputs skip the shadow bake (
skip_shadow_bake, souFwOnreads 0 there). The strided baker only re-bakes when something it tracks changes, and a GPU sway isn't one of those, so swaying shadows would freeze at whatever moment a bake caught. The bake itself is untouched.Shaded as at rest (second commit). Against the at-rest map, a point that had swayed behind its own rest-pose surface read as shadowed. That showed as dark streaks along the trunk and limbs: faint at 9 m/s close up, the trunk nearly black at 25 m/s. Now each prop mesh passes its unswayed view-space position to the fragments as a varying (
cvcFwRestVC), and the first shadow lookup (calcShadowfrom cvcGL's FilteredShadowMapPass) uses it. A swaying tree is then shaded exactly as the map says, with no texture and no extra uniform.LOD and distance. All three rungs carry the code. Rungs 1 and 2 are a few vertices a tree, so leaving them out would save nothing. Instead the sway fades out 300–450 m from the camera (
uFwEye), where it's about a pixel in terrain_lab's view, and a farther vertex skips the gust noise.Docs:
docs/ARIADNE.md(the Wind section's trees), and the roadmap's "As built (after O14): the generated world's trees in the wind".How it was checked (Windows 11, MSVC Release; arigl on the Intel Arc iGPU)
cvcgl_ariadne_realize, in the O14 block (its generated world now has 24 trees):uFwOn1,uFwDirthe wind's direction, the gust and eye uniforms, andskip_shadow_bakeset;world.lean_dirreads 30;wind.dirchange (30 → 120) turnsworld.lean_dir,uFwDir, the water, the clouds and the forest together on the next tick;wind.speedsetsuFwOnto 0 and emptiesworld.lean_dir, so the trees stand still.Frames, terrain_lab, 1280×720, one camera held on the lakeside trees, a 25 m/s wind (a storm, so the lean shows in a still):
world.sway=0: the trees stand upright.wind.dir=120: they bend to the screen's left, trunks curving from a fixed foot.wind.dir=300: the same trees bend to the right.Shadow frames, close on one lakeside tree, sun from the west-southwest:
Native 16-unit check (
CVCGL_LOWMEM_MAPPER=force CVCGL_TEXTURE_UNITS=16). cvcGL: shader textures fit WebGL2's 16 units: the reserve is the mapper's arrays (terrain_lab's water in the browser) #1313 isn't merged, so I ran this on a local branch with cvcGL: a shader-input texture holds its unit only for its own draw (terrain_lab's browser lock-up) #1304 (3976ae2) and cvcGL: shader textures fit WebGL2's 16 units: the reserve is the mapper's arrays (terrain_lab's water in the browser) #1313 (ba9f40b) cherry-picked. That branch isn't pushed and isn't part of this PR.far/near: no texture unit left for cloudShadeTex (16 in all, 5 kept for the mapper's vertex data, 11 shader textures). That's water: fetch and lee, gusts, the sea lagging the wind, and currents, in both seas (O13) #1311's ninth water sampler (uWindFetch) plus the cloud shade's two, against WebGL2's 16 with the mapper's arrays and the shadow map. In the browser, the water would draw without one of the cloud-shade textures. It needs fixing in water: fetch and lee, gusts, the sea lagging the wind, and currents, in both seas (O13) #1311's water (packuWindFetchinto a channel of an existing texture), not here.Frame cost, measured again on a quiet machine (CPU about 9 %, nothing building), sway on (as shipped, 9 m/s) vs
world.sway=0, with the fade:GL_TIME_ELAPSEDquery (vtkOpenGLRenderTimer) brackets each block. Eight interleaved rounds:The earlier measurement, on a loaded machine, is kept for the record: (720-frame run − 120-frame run) / 600,
arigl snapshot1280×720, ABBA order:AriadneComponentsloadsworld_controls.ariwith its new slider.Not done, not checked