Repository navigation
cloud_sky: near clouds over far ones, far clouds drawn by VolSliceNode - #1096
Merged
Merged
Conversation
Near clouds showed behind far ones for two reasons. A near volume drew the copy of its cloud nearest the ground's centre, but the deck's pattern repeats out to far_reach, so with the camera at the ground's edge or past it the clouds in front of it were drawn by the coarse far deck, fuzzy, over crisp volumes further off. The near volumes now take the copies nearest the camera, ranking clouds out of view last. And the near volumes drew in whatever order they joined the renderer; they now draw after the far deck, farthest first. The far deck is drawn as VolSlice draws a volume: planes facing the camera, cut to the deck's box by cvc::volslice (new compute_slices_at, the same plane/box clip at the caller's distances) and blended back to front, spaced wider with distance, at most 64. Each slice marches the slab behind it, within the deck, so seen edge-on the far clouds no longer break into horizontal streaks.
…acOS) The test asserted that agent 2 ends somewhere different under the two policies, but scatter_free's draw differs between standard libraries, and on macOS that agent starts where neither policy moves it: both runs leave it at the same point and the check fails. Compare every agent's position instead. The same change as #1097.
The far clouds were their own mesh of view-aligned slices that only borrowed cvc::volslice's plane clip. They are now a VolSliceNode, given the deck's coarse opacity as its volume, which gains what they need: - distance slicing (setDistanceSlicing): planes facing the camera at distances growing by a fixed fraction, from compute_slices_at, each cut to the box grown by a share of its slab's depth; - a sample shader of the caller's (setSampleShader) in place of the volume-then-LUT lookup, seeing the fragment's local position and the camera's eye, view direction and the slices' growth; - repeat wrap on the volume texture (setVolumeWrap) and vertices past the far plane drawn on it (setClampToFarPlane); - a node drawn with the volumes leaves the renderer's order-independent translucency on. The clouds' lighting march is the sample shader. Native snapshots match the previous mesh's from all five views. setDistanceSlicing is left out of pycvc (std::optional of a nested struct).
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.
Joe reported two things in terrain_lab: "the near clouds appear to render behind the far clouds", and "the lower resolution fuzzy clouds should be rendering like volslice, viewplane aligned slices".
Near clouds behind far ones
There were two causes.
far_reach(4 km), but a near volume drew the copy of its cloud nearest the ground's centre. With the camera at the ground's edge or past it, which is where it is for most views of the whole world, the clouds right in front of it were copies no volume drew. The coarse far deck drew them, fuzzy, over crisp volumes further away. The near volumes now take the copies nearest the camera. Clouds out of view (the diagonal half-angle plus about 15 degrees) rank 4x farther, so the volumes go to clouds on screen rather than to ones beside or behind the camera.orderDecknow keeps the order as: the far deck, then the near volumes farthest first. It reorders only when two clouds' distances differ by more than 5%, and it runs after the near clouds are placed each frame.Far clouds drawn by VolSliceNode
The far deck is now a
VolSliceNode. Its volume is the deck's coarse opacity, and the clouds' lighting is its sample shader. VolSliceNode gains what that needs, all opt-in, with defaults unchanged:setDistanceSlicing). Planes face the camera at distances from its eye that grow by a fixed fraction, instead of the even sweep. Here: from 0.1 cloud half-widths out to the deck's far corner, each at least 6% farther than the last, at most 64.cvc::volslice::compute_slices_atruns it at the caller's distances.setSampleShader) in place of the volume-then-colour-table lookup. It sees the fragment's local position (volsliceMC), the camera (volsliceEye,volsliceView) and the slices' growth (volsliceGrowth). The clouds' shader marches the part of each slab inside the deck, with about four samples per deck depth (at most six), plus the sunlight march, the near cut-outs and the distance fade.setVolumeWrap): the deck's pattern repeats.setClampToFarPlane): the deck reaches past the scene's bounds, so vertices beyond the far plane are drawn on it.setDistanceSlicingis left out of pycvc (astd::optionalof a nested struct). SWIG generates both modules cleanly with the rest.Master's horizontal shells showed as streaks and stripes seen edge-on from inside or near the deck. Those are gone.
Checked
cloud-near-over-far/.Slicer.SlicesAtDistancesFaceTheViewInTheGivenOrder.cvcgl_volslice_node, distance slicing and sample shader:volsliceMC.xpaints red left of centre and green right of it;volsliceEye,volsliceViewandvolsliceGrowthreach the shader;cvcgl_ariadne_realizechecks four things:Not checked
The browser (WebGL2) build. The shader stays GLSL ES 3.0: constant loop bounds with
break, highp samplers (VolSliceNode's), no new extensions.Also in this PR
Master's macOS CI fails
NavSimWorldAgents.EachPolicyDrivesItsOwnAgents(from #1077). On macOS, one agent's random start leaves it where neither policy moves it. This PR merges master and makes the same one-line change as #1097: compare every agent's position.