@3driseai/3drise-viewer 0.1.27 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animationsV2/ClipPlayer.d.ts.map +1 -1
- package/dist/animationsV2/ClipPlayer.js +13 -9
- package/dist/animationsV2/ClipsRuntime.d.ts +44 -3
- package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -1
- package/dist/animationsV2/ClipsRuntime.js +173 -55
- package/dist/animationsV2/appliers.d.ts.map +1 -1
- package/dist/animationsV2/appliers.js +21 -5
- package/dist/animationsV2/index.d.ts +1 -1
- package/dist/animationsV2/index.d.ts.map +1 -1
- package/dist/animationsV2/normalize.d.ts.map +1 -1
- package/dist/animationsV2/normalize.js +7 -3
- package/dist/animationsV2/sequenceUtils.d.ts +44 -6
- package/dist/animationsV2/sequenceUtils.d.ts.map +1 -1
- package/dist/animationsV2/sequenceUtils.js +58 -12
- package/dist/animationsV2/types.d.ts +22 -12
- package/dist/animationsV2/types.d.ts.map +1 -1
- package/dist/api/sceneHandle.d.ts +35 -1
- package/dist/api/sceneHandle.d.ts.map +1 -1
- package/dist/api/sceneHandle.js +88 -17
- package/dist/components/AdvancedGrid.d.ts +1 -5
- package/dist/components/AdvancedGrid.d.ts.map +1 -1
- package/dist/components/AdvancedGrid.js +6 -35
- package/dist/components/AnimatedObject.d.ts.map +1 -1
- package/dist/components/AnimatedObject.js +9 -4
- package/dist/components/ApollonianGrid.d.ts +25 -0
- package/dist/components/ApollonianGrid.d.ts.map +1 -0
- package/dist/components/ApollonianGrid.js +55 -0
- package/dist/components/ChladniGrid.d.ts +1 -1
- package/dist/components/ChladniGrid.d.ts.map +1 -1
- package/dist/components/ChladniGrid.js +6 -35
- package/dist/components/CircuitGrid.d.ts +1 -1
- package/dist/components/CircuitGrid.d.ts.map +1 -1
- package/dist/components/CircuitGrid.js +6 -34
- package/dist/components/ConformalGrid.d.ts +25 -0
- package/dist/components/ConformalGrid.d.ts.map +1 -0
- package/dist/components/ConformalGrid.js +66 -0
- package/dist/components/ContourGrid.d.ts +1 -1
- package/dist/components/ContourGrid.d.ts.map +1 -1
- package/dist/components/ContourGrid.js +6 -34
- package/dist/components/CustomPrimitive.js +1 -1
- package/dist/components/EnvironmentObject.d.ts.map +1 -1
- package/dist/components/EnvironmentObject.js +9 -7
- package/dist/components/FlowNetGrid.d.ts +1 -1
- package/dist/components/FlowNetGrid.d.ts.map +1 -1
- package/dist/components/FlowNetGrid.js +6 -34
- package/dist/components/FractalGrid.d.ts +1 -1
- package/dist/components/FractalGrid.d.ts.map +1 -1
- package/dist/components/FractalGrid.js +6 -37
- package/dist/components/Galaxy.d.ts.map +1 -1
- package/dist/components/Galaxy.js +9 -23
- package/dist/components/GirihGrid.d.ts +1 -1
- package/dist/components/GirihGrid.d.ts.map +1 -1
- package/dist/components/GirihGrid.js +6 -35
- package/dist/components/GravWaveGrid.d.ts +1 -1
- package/dist/components/GravWaveGrid.d.ts.map +1 -1
- package/dist/components/GravWaveGrid.js +6 -35
- package/dist/components/GridsGenerator.d.ts +2 -2
- package/dist/components/GridsGenerator.d.ts.map +1 -1
- package/dist/components/GridsGenerator.js +21 -0
- package/dist/components/HexGrid.d.ts +1 -5
- package/dist/components/HexGrid.d.ts.map +1 -1
- package/dist/components/HexGrid.js +6 -36
- package/dist/components/HilbertGrid.d.ts +25 -0
- package/dist/components/HilbertGrid.d.ts.map +1 -0
- package/dist/components/HilbertGrid.js +66 -0
- package/dist/components/HyperbolicGrid.d.ts +1 -1
- package/dist/components/HyperbolicGrid.d.ts.map +1 -1
- package/dist/components/HyperbolicGrid.js +6 -34
- package/dist/components/LandObject.d.ts +9 -0
- package/dist/components/LandObject.d.ts.map +1 -0
- package/dist/components/LandObject.js +15 -0
- package/dist/components/LensingGrid.d.ts +25 -0
- package/dist/components/LensingGrid.d.ts.map +1 -0
- package/dist/components/LensingGrid.js +55 -0
- package/dist/components/LightsManager.d.ts.map +1 -1
- package/dist/components/LightsManager.js +8 -0
- package/dist/components/ModelBoundary.d.ts +2 -0
- package/dist/components/ModelBoundary.d.ts.map +1 -1
- package/dist/components/ModelBoundary.js +3 -0
- package/dist/components/ModelPrimitive.d.ts.map +1 -1
- package/dist/components/ModelPrimitive.js +6 -0
- package/dist/components/MoireGrid.d.ts +1 -1
- package/dist/components/MoireGrid.d.ts.map +1 -1
- package/dist/components/MoireGrid.js +6 -35
- package/dist/components/MoonDisc.d.ts +11 -0
- package/dist/components/MoonDisc.d.ts.map +1 -0
- package/dist/components/MoonDisc.js +128 -0
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +15 -4
- package/dist/components/ObjectsRenderer.d.ts.map +1 -1
- package/dist/components/ObjectsRenderer.js +7 -5
- package/dist/components/OceanBuilder.d.ts.map +1 -1
- package/dist/components/OceanBuilder.js +2 -0
- package/dist/components/ParastichyGrid.d.ts +25 -0
- package/dist/components/ParastichyGrid.d.ts.map +1 -0
- package/dist/components/ParastichyGrid.js +55 -0
- package/dist/components/PhyllotaxisGrid.d.ts +25 -0
- package/dist/components/PhyllotaxisGrid.d.ts.map +1 -0
- package/dist/components/PhyllotaxisGrid.js +66 -0
- package/dist/components/ProjectLoader.d.ts +5 -3
- package/dist/components/ProjectLoader.d.ts.map +1 -1
- package/dist/components/ProjectLoader.js +6 -3
- package/dist/components/QuasiGrid.d.ts +1 -1
- package/dist/components/QuasiGrid.d.ts.map +1 -1
- package/dist/components/QuasiGrid.js +6 -33
- package/dist/components/RadarGrid.d.ts +1 -1
- package/dist/components/RadarGrid.d.ts.map +1 -1
- package/dist/components/RadarGrid.js +6 -34
- package/dist/components/ReactionDiffusionGrid.d.ts +1 -1
- package/dist/components/ReactionDiffusionGrid.d.ts.map +1 -1
- package/dist/components/ReactionDiffusionGrid.js +6 -35
- package/dist/components/SceneBuilder.d.ts +25 -3
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SceneBuilder.js +68 -38
- package/dist/components/SkyController.d.ts +25 -1
- package/dist/components/SkyController.d.ts.map +1 -1
- package/dist/components/SkyController.js +189 -130
- package/dist/components/SkyMesh.d.ts.map +1 -1
- package/dist/components/SkyMesh.js +26 -1
- package/dist/components/SkyStars.d.ts +11 -0
- package/dist/components/SkyStars.d.ts.map +1 -0
- package/dist/components/SkyStars.js +187 -0
- package/dist/components/SkySystem.d.ts +3 -3
- package/dist/components/SkySystem.d.ts.map +1 -1
- package/dist/components/SkySystem.js +8 -2
- package/dist/components/Sun.d.ts +15 -1
- package/dist/components/Sun.d.ts.map +1 -1
- package/dist/components/Sun.js +64 -3
- package/dist/components/SunLight.d.ts +6 -1
- package/dist/components/SunLight.d.ts.map +1 -1
- package/dist/components/SunLight.js +96 -44
- package/dist/components/TerrainBuilder.d.ts.map +1 -1
- package/dist/components/TerrainBuilder.js +2 -0
- package/dist/components/TextGenerator.d.ts +9 -0
- package/dist/components/TextGenerator.d.ts.map +1 -0
- package/dist/components/TextGenerator.js +29 -0
- package/dist/components/TruchetGrid.d.ts +25 -0
- package/dist/components/TruchetGrid.d.ts.map +1 -0
- package/dist/components/TruchetGrid.js +55 -0
- package/dist/components/VoronoiGrid.d.ts +1 -1
- package/dist/components/VoronoiGrid.d.ts.map +1 -1
- package/dist/components/VoronoiGrid.js +6 -33
- package/dist/components/WallpaperGrid.d.ts +1 -1
- package/dist/components/WallpaperGrid.d.ts.map +1 -1
- package/dist/components/WallpaperGrid.js +6 -35
- package/dist/components/environment/Rain.d.ts +15 -0
- package/dist/components/environment/Rain.d.ts.map +1 -0
- package/dist/components/environment/Rain.js +110 -0
- package/dist/components/environment/Rainbow.d.ts +20 -0
- package/dist/components/environment/Rainbow.d.ts.map +1 -0
- package/dist/components/environment/Rainbow.js +974 -0
- package/dist/components/environment/Sandstorm.d.ts +20 -0
- package/dist/components/environment/Sandstorm.d.ts.map +1 -0
- package/dist/components/environment/Sandstorm.js +776 -0
- package/dist/components/environment/Snow.d.ts +20 -0
- package/dist/components/environment/Snow.d.ts.map +1 -0
- package/dist/components/environment/Snow.js +609 -0
- package/dist/components/environment/Thunderstorm.d.ts +20 -0
- package/dist/components/environment/Thunderstorm.d.ts.map +1 -0
- package/dist/components/environment/Thunderstorm.js +731 -0
- package/dist/components/environment/Tornado.d.ts +20 -0
- package/dist/components/environment/Tornado.d.ts.map +1 -0
- package/dist/components/environment/Tornado.js +762 -0
- package/dist/components/environment/index.d.ts +13 -0
- package/dist/components/environment/index.d.ts.map +1 -0
- package/dist/components/environment/index.js +7 -0
- package/dist/components/index.d.ts +24 -10
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +15 -6
- package/dist/components/land/LandPatch.d.ts +15 -0
- package/dist/components/land/LandPatch.d.ts.map +1 -0
- package/dist/components/land/LandPatch.js +170 -0
- package/dist/components/land/index.d.ts +3 -0
- package/dist/components/land/index.d.ts.map +1 -0
- package/dist/components/land/index.js +1 -0
- package/dist/components/space/Earth.d.ts +16 -0
- package/dist/components/space/Earth.d.ts.map +1 -0
- package/dist/components/space/Earth.js +75 -0
- package/dist/components/space/ShootingStar.d.ts +21 -0
- package/dist/components/space/ShootingStar.d.ts.map +1 -0
- package/dist/components/space/ShootingStar.js +101 -0
- package/dist/components/space/ShootingStars.d.ts +16 -0
- package/dist/components/space/ShootingStars.d.ts.map +1 -0
- package/dist/components/space/ShootingStars.js +71 -0
- package/dist/components/space/SolarSystem.d.ts +16 -0
- package/dist/components/space/SolarSystem.d.ts.map +1 -0
- package/dist/components/space/SolarSystem.js +141 -0
- package/dist/components/space/Stars.d.ts +20 -0
- package/dist/components/space/Stars.d.ts.map +1 -0
- package/dist/components/space/Stars.js +160 -0
- package/dist/components/space/index.d.ts +11 -0
- package/dist/components/space/index.d.ts.map +1 -0
- package/dist/components/space/index.js +8 -0
- package/dist/components/terrain/TerrainSurface.d.ts.map +1 -1
- package/dist/components/terrain/TerrainSurface.js +27 -3
- package/dist/components/terrain/types.d.ts +5 -1
- package/dist/components/terrain/types.d.ts.map +1 -1
- package/dist/components/text/BurnAwayText.d.ts +15 -0
- package/dist/components/text/BurnAwayText.d.ts.map +1 -0
- package/dist/components/text/BurnAwayText.js +4 -0
- package/dist/components/text/ChalkboardText.d.ts +15 -0
- package/dist/components/text/ChalkboardText.d.ts.map +1 -0
- package/dist/components/text/ChalkboardText.js +4 -0
- package/dist/components/text/ConstellationText.d.ts +15 -0
- package/dist/components/text/ConstellationText.d.ts.map +1 -0
- package/dist/components/text/ConstellationText.js +4 -0
- package/dist/components/text/EmbroideryText.d.ts +15 -0
- package/dist/components/text/EmbroideryText.d.ts.map +1 -0
- package/dist/components/text/EmbroideryText.js +4 -0
- package/dist/components/text/FourierSketchText.d.ts +15 -0
- package/dist/components/text/FourierSketchText.d.ts.map +1 -0
- package/dist/components/text/FourierSketchText.js +4 -0
- package/dist/components/text/FrostGrowthText.d.ts +15 -0
- package/dist/components/text/FrostGrowthText.d.ts.map +1 -0
- package/dist/components/text/FrostGrowthText.js +4 -0
- package/dist/components/text/HandwritingText.d.ts +15 -0
- package/dist/components/text/HandwritingText.d.ts.map +1 -0
- package/dist/components/text/HandwritingText.js +4 -0
- package/dist/components/text/InkBleedText.d.ts +15 -0
- package/dist/components/text/InkBleedText.d.ts.map +1 -0
- package/dist/components/text/InkBleedText.js +4 -0
- package/dist/components/text/LightPaintingText.d.ts +15 -0
- package/dist/components/text/LightPaintingText.d.ts.map +1 -0
- package/dist/components/text/LightPaintingText.js +4 -0
- package/dist/components/text/LiquidMetalText.d.ts +15 -0
- package/dist/components/text/LiquidMetalText.d.ts.map +1 -0
- package/dist/components/text/LiquidMetalText.js +4 -0
- package/dist/components/text/NeonTubeText.d.ts +15 -0
- package/dist/components/text/NeonTubeText.d.ts.map +1 -0
- package/dist/components/text/NeonTubeText.js +4 -0
- package/dist/components/text/PlasmaDischargeText.d.ts +15 -0
- package/dist/components/text/PlasmaDischargeText.d.ts.map +1 -0
- package/dist/components/text/PlasmaDischargeText.js +4 -0
- package/dist/components/text/TextObjectView.d.ts +12 -0
- package/dist/components/text/TextObjectView.d.ts.map +1 -0
- package/dist/components/text/TextObjectView.js +11 -0
- package/dist/components/text/engine/fieldkit.d.ts +24 -0
- package/dist/components/text/engine/fieldkit.d.ts.map +1 -0
- package/dist/components/text/engine/fieldkit.js +201 -0
- package/dist/components/text/engine/glyphs.d.ts +19 -0
- package/dist/components/text/engine/glyphs.d.ts.map +1 -0
- package/dist/components/text/engine/glyphs.js +269 -0
- package/dist/components/text/engine/looks/burnAway.d.ts +144 -0
- package/dist/components/text/engine/looks/burnAway.d.ts.map +1 -0
- package/dist/components/text/engine/looks/burnAway.js +593 -0
- package/dist/components/text/engine/looks/chalkboard.d.ts +135 -0
- package/dist/components/text/engine/looks/chalkboard.d.ts.map +1 -0
- package/dist/components/text/engine/looks/chalkboard.js +426 -0
- package/dist/components/text/engine/looks/constellation.d.ts +111 -0
- package/dist/components/text/engine/looks/constellation.d.ts.map +1 -0
- package/dist/components/text/engine/looks/constellation.js +496 -0
- package/dist/components/text/engine/looks/embroidery.d.ts +165 -0
- package/dist/components/text/engine/looks/embroidery.d.ts.map +1 -0
- package/dist/components/text/engine/looks/embroidery.js +645 -0
- package/dist/components/text/engine/looks/frostGrowth.d.ts +109 -0
- package/dist/components/text/engine/looks/frostGrowth.d.ts.map +1 -0
- package/dist/components/text/engine/looks/frostGrowth.js +727 -0
- package/dist/components/text/engine/looks/index.d.ts +2 -0
- package/dist/components/text/engine/looks/index.d.ts.map +1 -0
- package/dist/components/text/engine/looks/index.js +48 -0
- package/dist/components/text/engine/looks/inkBleed.d.ts +103 -0
- package/dist/components/text/engine/looks/inkBleed.d.ts.map +1 -0
- package/dist/components/text/engine/looks/inkBleed.js +590 -0
- package/dist/components/text/engine/looks/lightPainting.d.ts +132 -0
- package/dist/components/text/engine/looks/lightPainting.d.ts.map +1 -0
- package/dist/components/text/engine/looks/lightPainting.js +567 -0
- package/dist/components/text/engine/looks/liquidMetal.d.ts +135 -0
- package/dist/components/text/engine/looks/liquidMetal.d.ts.map +1 -0
- package/dist/components/text/engine/looks/liquidMetal.js +655 -0
- package/dist/components/text/engine/looks/plasmaDischarge.d.ts +126 -0
- package/dist/components/text/engine/looks/plasmaDischarge.d.ts.map +1 -0
- package/dist/components/text/engine/looks/plasmaDischarge.js +763 -0
- package/dist/components/text/engine/methods.d.ts +19 -0
- package/dist/components/text/engine/methods.d.ts.map +1 -0
- package/dist/components/text/engine/methods.js +126 -0
- package/dist/components/text/engine/playback.d.ts +40 -0
- package/dist/components/text/engine/playback.d.ts.map +1 -0
- package/dist/components/text/engine/playback.js +114 -0
- package/dist/components/text/engine/ribbon.d.ts +58 -0
- package/dist/components/text/engine/ribbon.d.ts.map +1 -0
- package/dist/components/text/engine/ribbon.js +250 -0
- package/dist/components/text/engine/variants.d.ts +159 -0
- package/dist/components/text/engine/variants.d.ts.map +1 -0
- package/dist/components/text/engine/variants.js +378 -0
- package/dist/components/text/fonts/architects-daughter.outline.d.ts +3 -0
- package/dist/components/text/fonts/architects-daughter.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/architects-daughter.outline.js +4 -0
- package/dist/components/text/fonts/architects-daughter.strokes.d.ts +3 -0
- package/dist/components/text/fonts/architects-daughter.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/architects-daughter.strokes.js +4 -0
- package/dist/components/text/fonts/caveat.outline.d.ts +3 -0
- package/dist/components/text/fonts/caveat.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/caveat.outline.js +4 -0
- package/dist/components/text/fonts/caveat.strokes.d.ts +3 -0
- package/dist/components/text/fonts/caveat.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/caveat.strokes.js +4 -0
- package/dist/components/text/fonts/courgette.outline.d.ts +3 -0
- package/dist/components/text/fonts/courgette.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/courgette.outline.js +4 -0
- package/dist/components/text/fonts/courgette.strokes.d.ts +3 -0
- package/dist/components/text/fonts/courgette.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/courgette.strokes.js +4 -0
- package/dist/components/text/fonts/dancing-script.outline.d.ts +3 -0
- package/dist/components/text/fonts/dancing-script.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/dancing-script.outline.js +4 -0
- package/dist/components/text/fonts/dancing-script.strokes.d.ts +3 -0
- package/dist/components/text/fonts/dancing-script.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/dancing-script.strokes.js +4 -0
- package/dist/components/text/fonts/gochi-hand.outline.d.ts +3 -0
- package/dist/components/text/fonts/gochi-hand.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/gochi-hand.outline.js +4 -0
- package/dist/components/text/fonts/gochi-hand.strokes.d.ts +3 -0
- package/dist/components/text/fonts/gochi-hand.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/gochi-hand.strokes.js +4 -0
- package/dist/components/text/fonts/handlee.outline.d.ts +3 -0
- package/dist/components/text/fonts/handlee.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/handlee.outline.js +4 -0
- package/dist/components/text/fonts/handlee.strokes.d.ts +3 -0
- package/dist/components/text/fonts/handlee.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/handlee.strokes.js +4 -0
- package/dist/components/text/fonts/index.d.ts +5 -0
- package/dist/components/text/fonts/index.d.ts.map +1 -0
- package/dist/components/text/fonts/index.js +44 -0
- package/dist/components/text/fonts/indie-flower.outline.d.ts +3 -0
- package/dist/components/text/fonts/indie-flower.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/indie-flower.outline.js +4 -0
- package/dist/components/text/fonts/indie-flower.strokes.d.ts +3 -0
- package/dist/components/text/fonts/indie-flower.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/indie-flower.strokes.js +4 -0
- package/dist/components/text/fonts/kalam.outline.d.ts +3 -0
- package/dist/components/text/fonts/kalam.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/kalam.outline.js +4 -0
- package/dist/components/text/fonts/kalam.strokes.d.ts +3 -0
- package/dist/components/text/fonts/kalam.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/kalam.strokes.js +4 -0
- package/dist/components/text/fonts/kaushan-script.outline.d.ts +3 -0
- package/dist/components/text/fonts/kaushan-script.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/kaushan-script.outline.js +4 -0
- package/dist/components/text/fonts/kaushan-script.strokes.d.ts +3 -0
- package/dist/components/text/fonts/kaushan-script.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/kaushan-script.strokes.js +4 -0
- package/dist/components/text/fonts/mynerve.outline.d.ts +3 -0
- package/dist/components/text/fonts/mynerve.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/mynerve.outline.js +4 -0
- package/dist/components/text/fonts/mynerve.strokes.d.ts +3 -0
- package/dist/components/text/fonts/mynerve.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/mynerve.strokes.js +4 -0
- package/dist/components/text/fonts/nanum-pen-script.outline.d.ts +3 -0
- package/dist/components/text/fonts/nanum-pen-script.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/nanum-pen-script.outline.js +4 -0
- package/dist/components/text/fonts/nanum-pen-script.strokes.d.ts +3 -0
- package/dist/components/text/fonts/nanum-pen-script.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/nanum-pen-script.strokes.js +4 -0
- package/dist/components/text/fonts/pacifico.outline.d.ts +3 -0
- package/dist/components/text/fonts/pacifico.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/pacifico.outline.js +4 -0
- package/dist/components/text/fonts/pacifico.strokes.d.ts +3 -0
- package/dist/components/text/fonts/pacifico.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/pacifico.strokes.js +4 -0
- package/dist/components/text/fonts/patrick-hand.outline.d.ts +3 -0
- package/dist/components/text/fonts/patrick-hand.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/patrick-hand.outline.js +4 -0
- package/dist/components/text/fonts/patrick-hand.strokes.d.ts +3 -0
- package/dist/components/text/fonts/patrick-hand.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/patrick-hand.strokes.js +4 -0
- package/dist/components/text/fonts/poppins.outline.d.ts +3 -0
- package/dist/components/text/fonts/poppins.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/poppins.outline.js +4 -0
- package/dist/components/text/fonts/poppins.strokes.d.ts +3 -0
- package/dist/components/text/fonts/poppins.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/poppins.strokes.js +4 -0
- package/dist/components/text/fonts/satisfy.outline.d.ts +3 -0
- package/dist/components/text/fonts/satisfy.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/satisfy.outline.js +4 -0
- package/dist/components/text/fonts/satisfy.strokes.d.ts +3 -0
- package/dist/components/text/fonts/satisfy.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/satisfy.strokes.js +4 -0
- package/dist/components/text/fonts/sriracha.outline.d.ts +3 -0
- package/dist/components/text/fonts/sriracha.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/sriracha.outline.js +4 -0
- package/dist/components/text/fonts/sriracha.strokes.d.ts +3 -0
- package/dist/components/text/fonts/sriracha.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/sriracha.strokes.js +4 -0
- package/dist/components/text/index.d.ts +27 -0
- package/dist/components/text/index.d.ts.map +1 -0
- package/dist/components/text/index.js +13 -0
- package/dist/components/text/useTextObject.d.ts +21 -0
- package/dist/components/text/useTextObject.d.ts.map +1 -0
- package/dist/components/text/useTextObject.js +118 -0
- package/dist/components/water/OceanSurface.d.ts.map +1 -1
- package/dist/components/water/OceanSurface.js +3 -1
- package/dist/components/water/WaterBody.d.ts.map +1 -1
- package/dist/components/water/WaterBody.js +3 -1
- package/dist/components/water/types.d.ts +5 -1
- package/dist/components/water/types.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useCloudSun.d.ts +9 -4
- package/dist/hooks/useCloudSun.d.ts.map +1 -1
- package/dist/hooks/useCloudSun.js +17 -7
- package/dist/hooks/useConfigLive.d.ts +3 -2
- package/dist/hooks/useConfigLive.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.js +4 -10
- package/dist/hooks/useEnvironmentProbe.d.ts +3 -22
- package/dist/hooks/useEnvironmentProbe.d.ts.map +1 -1
- package/dist/hooks/useEnvironmentProbe.js +47 -8
- package/dist/hooks/useGridSurface.d.ts +3 -10
- package/dist/hooks/useGridSurface.d.ts.map +1 -1
- package/dist/hooks/useGridSurface.js +5 -31
- package/dist/hooks/useInteraction.d.ts.map +1 -1
- package/dist/hooks/useInteraction.js +19 -72
- package/dist/hooks/useLightConfig.d.ts +2 -1
- package/dist/hooks/useLightConfig.d.ts.map +1 -1
- package/dist/hooks/useOceanMaterial.d.ts +6 -2
- package/dist/hooks/useOceanMaterial.d.ts.map +1 -1
- package/dist/hooks/useOceanMaterial.js +37 -2
- package/dist/hooks/useSkyLive.d.ts +23 -0
- package/dist/hooks/useSkyLive.d.ts.map +1 -0
- package/dist/hooks/useSkyLive.js +30 -0
- package/dist/hooks/useSkyUniforms.d.ts.map +1 -1
- package/dist/hooks/useSkyUniforms.js +2 -10
- package/dist/hooks/useTerrainLive.d.ts +3 -1
- package/dist/hooks/useTerrainLive.d.ts.map +1 -1
- package/dist/hooks/useTerrainTextures.d.ts +38 -0
- package/dist/hooks/useTerrainTextures.d.ts.map +1 -0
- package/dist/hooks/useTerrainTextures.js +149 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/operations/catalogue/blastOff.d.ts +3 -0
- package/dist/operations/catalogue/blastOff.d.ts.map +1 -0
- package/dist/operations/catalogue/blastOff.js +118 -0
- package/dist/operations/catalogue/bounce.d.ts +3 -0
- package/dist/operations/catalogue/bounce.d.ts.map +1 -0
- package/dist/operations/catalogue/bounce.js +34 -0
- package/dist/operations/catalogue/curlSmoke.d.ts.map +1 -1
- package/dist/operations/catalogue/curlSmoke.js +3 -1
- package/dist/operations/catalogue/dissolve.d.ts.map +1 -1
- package/dist/operations/catalogue/dissolve.js +2 -1
- package/dist/operations/catalogue/driftUp.d.ts +3 -0
- package/dist/operations/catalogue/driftUp.d.ts.map +1 -0
- package/dist/operations/catalogue/driftUp.js +57 -0
- package/dist/operations/catalogue/emberAsh.d.ts.map +1 -1
- package/dist/operations/catalogue/emberAsh.js +2 -1
- package/dist/operations/catalogue/flip.d.ts.map +1 -1
- package/dist/operations/catalogue/flip.js +19 -9
- package/dist/operations/catalogue/float.d.ts +3 -0
- package/dist/operations/catalogue/float.d.ts.map +1 -0
- package/dist/operations/catalogue/float.js +39 -0
- package/dist/operations/catalogue/flyBy.d.ts +3 -0
- package/dist/operations/catalogue/flyBy.d.ts.map +1 -0
- package/dist/operations/catalogue/flyBy.js +79 -0
- package/dist/operations/catalogue/frost.d.ts.map +1 -1
- package/dist/operations/catalogue/frost.js +10 -3
- package/dist/operations/catalogue/grow.d.ts +3 -0
- package/dist/operations/catalogue/grow.d.ts.map +1 -0
- package/dist/operations/catalogue/grow.js +19 -0
- package/dist/operations/catalogue/hologram.d.ts.map +1 -1
- package/dist/operations/catalogue/hologram.js +11 -5
- package/dist/operations/catalogue/jelly.d.ts.map +1 -1
- package/dist/operations/catalogue/jelly.js +18 -8
- package/dist/operations/catalogue/knockAway.d.ts +3 -0
- package/dist/operations/catalogue/knockAway.d.ts.map +1 -0
- package/dist/operations/catalogue/knockAway.js +74 -0
- package/dist/operations/catalogue/leafFall.d.ts +3 -0
- package/dist/operations/catalogue/leafFall.d.ts.map +1 -0
- package/dist/operations/catalogue/leafFall.js +74 -0
- package/dist/operations/catalogue/lidarScan.d.ts.map +1 -1
- package/dist/operations/catalogue/lidarScan.js +4 -1
- package/dist/operations/catalogue/metalize.d.ts.map +1 -1
- package/dist/operations/catalogue/metalize.js +8 -2
- package/dist/operations/catalogue/motionTrail.d.ts +6 -0
- package/dist/operations/catalogue/motionTrail.d.ts.map +1 -0
- package/dist/operations/catalogue/motionTrail.js +221 -0
- package/dist/operations/catalogue/petrify.d.ts.map +1 -1
- package/dist/operations/catalogue/petrify.js +9 -3
- package/dist/operations/catalogue/physicalExit.d.ts +55 -0
- package/dist/operations/catalogue/physicalExit.d.ts.map +1 -0
- package/dist/operations/catalogue/physicalExit.js +165 -0
- package/dist/operations/catalogue/physicalHeld.d.ts +41 -0
- package/dist/operations/catalogue/physicalHeld.d.ts.map +1 -0
- package/dist/operations/catalogue/physicalHeld.js +78 -0
- package/dist/operations/catalogue/physicalMix.d.ts +45 -0
- package/dist/operations/catalogue/physicalMix.d.ts.map +1 -0
- package/dist/operations/catalogue/physicalMix.js +144 -0
- package/dist/operations/catalogue/pop.d.ts +3 -0
- package/dist/operations/catalogue/pop.d.ts.map +1 -0
- package/dist/operations/catalogue/pop.js +44 -0
- package/dist/operations/catalogue/print3d.d.ts.map +1 -1
- package/dist/operations/catalogue/print3d.js +5 -1
- package/dist/operations/catalogue/pulse.d.ts +3 -0
- package/dist/operations/catalogue/pulse.d.ts.map +1 -0
- package/dist/operations/catalogue/pulse.js +29 -0
- package/dist/operations/catalogue/restPose.d.ts +5 -7
- package/dist/operations/catalogue/restPose.d.ts.map +1 -1
- package/dist/operations/catalogue/restPose.js +18 -48
- package/dist/operations/catalogue/rotate.d.ts +3 -0
- package/dist/operations/catalogue/rotate.d.ts.map +1 -0
- package/dist/operations/catalogue/rotate.js +49 -0
- package/dist/operations/catalogue/shake.d.ts +3 -0
- package/dist/operations/catalogue/shake.d.ts.map +1 -0
- package/dist/operations/catalogue/shake.js +31 -0
- package/dist/operations/catalogue/shatter.d.ts.map +1 -1
- package/dist/operations/catalogue/shatter.js +5 -1
- package/dist/operations/catalogue/slam.d.ts +3 -0
- package/dist/operations/catalogue/slam.d.ts.map +1 -0
- package/dist/operations/catalogue/slam.js +89 -0
- package/dist/operations/catalogue/slingshot.d.ts +3 -0
- package/dist/operations/catalogue/slingshot.d.ts.map +1 -0
- package/dist/operations/catalogue/slingshot.js +88 -0
- package/dist/operations/catalogue/spin.d.ts.map +1 -1
- package/dist/operations/catalogue/spin.js +24 -13
- package/dist/operations/catalogue/sway.d.ts +3 -0
- package/dist/operations/catalogue/sway.d.ts.map +1 -0
- package/dist/operations/catalogue/sway.js +23 -0
- package/dist/operations/catalogue/swirl.d.ts.map +1 -1
- package/dist/operations/catalogue/swirl.js +6 -5
- package/dist/operations/catalogue/trailCore.d.ts +89 -0
- package/dist/operations/catalogue/trailCore.d.ts.map +1 -0
- package/dist/operations/catalogue/trailCore.js +190 -0
- package/dist/operations/catalogue/trailGhosts.d.ts +5 -0
- package/dist/operations/catalogue/trailGhosts.d.ts.map +1 -0
- package/dist/operations/catalogue/trailGhosts.js +179 -0
- package/dist/operations/catalogue/trailStampStyles.d.ts +11 -0
- package/dist/operations/catalogue/trailStampStyles.d.ts.map +1 -0
- package/dist/operations/catalogue/trailStampStyles.js +479 -0
- package/dist/operations/catalogue/trailStamps.d.ts +57 -0
- package/dist/operations/catalogue/trailStamps.d.ts.map +1 -0
- package/dist/operations/catalogue/trailStamps.js +349 -0
- package/dist/operations/catalogue/trailStreaks.d.ts +3 -0
- package/dist/operations/catalogue/trailStreaks.d.ts.map +1 -0
- package/dist/operations/catalogue/trailStreaks.js +147 -0
- package/dist/operations/catalogue/transitionField.d.ts +30 -0
- package/dist/operations/catalogue/transitionField.d.ts.map +1 -1
- package/dist/operations/catalogue/transitionField.js +21 -0
- package/dist/operations/catalogue/turnAway.d.ts +3 -0
- package/dist/operations/catalogue/turnAway.d.ts.map +1 -0
- package/dist/operations/catalogue/turnAway.js +54 -0
- package/dist/operations/catalogue/vortexDrain.d.ts +3 -0
- package/dist/operations/catalogue/vortexDrain.d.ts.map +1 -0
- package/dist/operations/catalogue/vortexDrain.js +68 -0
- package/dist/operations/catalogue/warp.d.ts +3 -0
- package/dist/operations/catalogue/warp.d.ts.map +1 -0
- package/dist/operations/catalogue/warp.js +73 -0
- package/dist/operations/catalogue/whoosh.d.ts +3 -0
- package/dist/operations/catalogue/whoosh.d.ts.map +1 -0
- package/dist/operations/catalogue/whoosh.js +84 -0
- package/dist/operations/catalogue/wobble.d.ts +3 -0
- package/dist/operations/catalogue/wobble.d.ts.map +1 -0
- package/dist/operations/catalogue/wobble.js +23 -0
- package/dist/operations/clipPreview.d.ts +3 -0
- package/dist/operations/clipPreview.d.ts.map +1 -0
- package/dist/operations/clipPreview.js +20 -0
- package/dist/operations/groupFanout.d.ts +96 -0
- package/dist/operations/groupFanout.d.ts.map +1 -0
- package/dist/operations/groupFanout.js +365 -0
- package/dist/operations/groups.d.ts +20 -0
- package/dist/operations/groups.d.ts.map +1 -0
- package/dist/operations/groups.js +66 -0
- package/dist/operations/index.d.ts +5 -2
- package/dist/operations/index.d.ts.map +1 -1
- package/dist/operations/index.js +5 -2
- package/dist/operations/objectEffects.d.ts +161 -6
- package/dist/operations/objectEffects.d.ts.map +1 -1
- package/dist/operations/objectEffects.js +1091 -17
- package/dist/operations/registry.d.ts.map +1 -1
- package/dist/operations/registry.js +24 -2
- package/dist/operations/runtime.d.ts +57 -2
- package/dist/operations/runtime.d.ts.map +1 -1
- package/dist/operations/runtime.js +161 -18
- package/dist/operations/types.d.ts +60 -3
- package/dist/operations/types.d.ts.map +1 -1
- package/dist/operations/types.js +5 -1
- package/dist/operations/useObjectEffectLayers.d.ts +2 -2
- package/dist/operations/useObjectEffectLayers.d.ts.map +1 -1
- package/dist/operations/useObjectEffectLayers.js +31 -10
- package/dist/operations/usePresentedVisibility.d.ts +10 -0
- package/dist/operations/usePresentedVisibility.d.ts.map +1 -0
- package/dist/operations/usePresentedVisibility.js +53 -0
- package/dist/presets/terrainBiomes.d.ts +67 -0
- package/dist/presets/terrainBiomes.d.ts.map +1 -0
- package/dist/presets/terrainBiomes.js +294 -0
- package/dist/presets/terrainPresets.d.ts +6 -0
- package/dist/presets/terrainPresets.d.ts.map +1 -1
- package/dist/presets/terrainPresets.js +26 -38
- package/dist/shaders/glsl/oceanCore.glsl.d.ts +2 -2
- package/dist/shaders/glsl/oceanCore.glsl.d.ts.map +1 -1
- package/dist/shaders/glsl/oceanCore.glsl.js +17 -0
- package/dist/shaders/glsl/surfaceCore.glsl.d.ts +21 -0
- package/dist/shaders/glsl/surfaceCore.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/surfaceCore.glsl.js +120 -0
- package/dist/shaders/glsl/terrainCore.glsl.d.ts +16 -3
- package/dist/shaders/glsl/terrainCore.glsl.d.ts.map +1 -1
- package/dist/shaders/glsl/terrainCore.glsl.js +266 -20
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts +2 -0
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts.map +1 -1
- package/dist/shaders/ocean/OceanSurfaceMaterial.js +3 -0
- package/dist/shaders/terrain/TerrainMaterial.d.ts +17 -0
- package/dist/shaders/terrain/TerrainMaterial.d.ts.map +1 -1
- package/dist/shaders/terrain/TerrainMaterial.js +107 -8
- package/dist/triggers/engine.d.ts +44 -0
- package/dist/triggers/engine.d.ts.map +1 -0
- package/dist/triggers/engine.js +165 -0
- package/dist/triggers/hosts/actions.d.ts +8 -0
- package/dist/triggers/hosts/actions.d.ts.map +1 -0
- package/dist/triggers/hosts/actions.js +22 -0
- package/dist/triggers/hosts/interactions.d.ts +6 -0
- package/dist/triggers/hosts/interactions.d.ts.map +1 -0
- package/dist/triggers/hosts/interactions.js +4 -0
- package/dist/triggers/hosts/timelineCues.d.ts +2 -0
- package/dist/triggers/hosts/timelineCues.d.ts.map +1 -0
- package/dist/triggers/hosts/timelineCues.js +22 -0
- package/dist/triggers/index.d.ts +13 -0
- package/dist/triggers/index.d.ts.map +1 -0
- package/dist/triggers/index.js +9 -0
- package/dist/triggers/kinds/action.d.ts +2 -0
- package/dist/triggers/kinds/action.d.ts.map +1 -0
- package/dist/triggers/kinds/action.js +31 -0
- package/dist/triggers/kinds/animations.d.ts +2 -0
- package/dist/triggers/kinds/animations.d.ts.map +1 -0
- package/dist/triggers/kinds/animations.js +75 -0
- package/dist/triggers/kinds/effects.d.ts +2 -0
- package/dist/triggers/kinds/effects.d.ts.map +1 -0
- package/dist/triggers/kinds/effects.js +27 -0
- package/dist/triggers/kinds/index.d.ts +4 -0
- package/dist/triggers/kinds/index.d.ts.map +1 -0
- package/dist/triggers/kinds/index.js +4 -0
- package/dist/triggers/log.d.ts +21 -0
- package/dist/triggers/log.d.ts.map +1 -0
- package/dist/triggers/log.js +43 -0
- package/dist/triggers/readiness.d.ts +40 -0
- package/dist/triggers/readiness.d.ts.map +1 -0
- package/dist/triggers/readiness.js +158 -0
- package/dist/triggers/registry.d.ts +41 -0
- package/dist/triggers/registry.d.ts.map +1 -0
- package/dist/triggers/registry.js +7 -0
- package/dist/types/gridConfigs.d.ts +117 -19
- package/dist/types/gridConfigs.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/UiAnchorUpdater.d.ts +10 -0
- package/dist/ui/UiAnchorUpdater.d.ts.map +1 -0
- package/dist/ui/UiAnchorUpdater.js +111 -0
- package/dist/ui/UiLayers.d.ts +20 -0
- package/dist/ui/UiLayers.d.ts.map +1 -0
- package/dist/ui/UiLayers.js +57 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +6 -0
- package/dist/ui/uiAnchors.d.ts +21 -0
- package/dist/ui/uiAnchors.d.ts.map +1 -0
- package/dist/ui/uiAnchors.js +22 -0
- package/dist/ui/uiBaseStyles.d.ts +2 -0
- package/dist/ui/uiBaseStyles.d.ts.map +1 -0
- package/dist/ui/uiBaseStyles.js +100 -0
- package/dist/ui/uiBinder.d.ts +30 -0
- package/dist/ui/uiBinder.d.ts.map +1 -0
- package/dist/ui/uiBinder.js +344 -0
- package/dist/utils/configAnimations.d.ts.map +1 -1
- package/dist/utils/configAnimations.js +5 -1
- package/dist/utils/gridConfig.d.ts +1 -1
- package/dist/utils/gridConfig.d.ts.map +1 -1
- package/dist/utils/gridConfig.js +1 -1
- package/dist/utils/landPatch.d.ts +33 -0
- package/dist/utils/landPatch.d.ts.map +1 -0
- package/dist/utils/landPatch.js +114 -0
- package/dist/utils/renderedSky.d.ts +32 -0
- package/dist/utils/renderedSky.d.ts.map +1 -0
- package/dist/utils/renderedSky.js +57 -0
- package/dist/utils/skyMoon.d.ts +35 -0
- package/dist/utils/skyMoon.d.ts.map +1 -0
- package/dist/utils/skyMoon.js +41 -0
- package/dist/utils/terrainHeight.d.ts +4 -0
- package/dist/utils/terrainHeight.d.ts.map +1 -0
- package/dist/utils/terrainHeight.js +150 -0
- package/dist/utils/terrainTextureResolver.d.ts +18 -0
- package/dist/utils/terrainTextureResolver.d.ts.map +1 -0
- package/dist/utils/terrainTextureResolver.js +17 -0
- package/dist/utils/terrainUniforms.d.ts +17 -0
- package/dist/utils/terrainUniforms.d.ts.map +1 -1
- package/dist/utils/terrainUniforms.js +84 -0
- package/dist/utils/textureArrays.d.ts +29 -0
- package/dist/utils/textureArrays.d.ts.map +1 -0
- package/dist/utils/textureArrays.js +140 -0
- package/package.json +2 -2
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* billions of transcendentals per frame.
|
|
28
28
|
*/
|
|
29
29
|
/** Every uniform the height field and the shading read. */
|
|
30
|
-
export declare const terrainUniforms = "\nuniform int u_terrainType;\n\nuniform float u_elevation;\nuniform float u_seaLevel;\nuniform float u_baseScale; // 1 / featureSize\nuniform int u_octaves;\nuniform float u_lacunarity;\nuniform float u_gain;\nuniform float u_ridge;\nuniform float u_warpStrength;\nuniform float u_warpScale;\nuniform float u_erosion;\nuniform float u_terraces;\nuniform float u_terraceSharp;\nuniform vec2 u_bearingDir;\nuniform float u_duneFreq; // 2pi / duneWavelength\nuniform float u_duneAsym;\nuniform float u_plateau;\nuniform float u_valleyDepth;\nuniform float u_valleyWidth;\n\nuniform float u_cellSize;\nuniform float u_curvature;\n\n// surface\nuniform vec3 u_lowColor, u_midColor, u_rockColor, u_peakColor;\nuniform float u_slopeRockStart, u_slopeRockEnd;\nuniform float u_peakLevel, u_peakBlend, u_peakSlopeFalloff;\nuniform float u_macroVariation, u_macroScale;\nuniform float u_detailStrength, u_detailScale, u_detailFade;\nuniform float u_roughness, u_specular;\n\n// lighting. u_skyAmbient and u_groundAmbient come from useCloudSun through\n// applySunUniforms - the same objects that light the clouds. They are constant\n// across the frame, so computing them on the CPU rather than calling skyRadiance\n// per pixel removes an acos, a pow and three exps from every fragment.\nuniform vec3 u_skyAmbient;\nuniform vec3 u_groundAmbient;\nuniform float u_ambient, u_bounce, u_sunShadow, u_shadowSoftness;\nuniform float u_shadowDistance;\nuniform float u_fogDensity, u_exposure;\nuniform int u_shadowSteps;\n";
|
|
30
|
+
export declare const terrainUniforms = "\nuniform int u_terrainType;\n\nuniform float u_elevation;\nuniform float u_seaLevel;\nuniform float u_baseScale; // 1 / featureSize\nuniform int u_octaves;\nuniform float u_lacunarity;\nuniform float u_gain;\nuniform float u_ridge;\nuniform float u_warpStrength;\nuniform float u_warpScale;\nuniform float u_erosion;\nuniform float u_terraces;\nuniform float u_terraceSharp;\nuniform vec2 u_bearingDir;\nuniform float u_duneFreq; // 2pi / duneWavelength\nuniform float u_duneAsym;\nuniform float u_plateau;\nuniform float u_valleyDepth;\nuniform float u_valleyWidth;\n\nuniform float u_cellSize;\nuniform float u_curvature;\n\n// surface\nuniform vec3 u_lowColor, u_midColor, u_rockColor, u_peakColor;\nuniform float u_slopeRockStart, u_slopeRockEnd;\nuniform float u_peakLevel, u_peakBlend, u_peakSlopeFalloff;\nuniform float u_macroVariation, u_macroScale;\nuniform float u_detailStrength, u_detailScale, u_detailFade;\nuniform float u_roughness, u_specular;\n\n// lighting. u_skyAmbient and u_groundAmbient come from useCloudSun through\n// applySunUniforms - the same objects that light the clouds. They are constant\n// across the frame, so computing them on the CPU rather than calling skyRadiance\n// per pixel removes an acos, a pow and three exps from every fragment.\nuniform vec3 u_skyAmbient;\nuniform vec3 u_groundAmbient;\nuniform float u_ambient, u_bounce, u_sunShadow, u_shadowSoftness;\nuniform float u_shadowDistance;\nuniform float u_fogDensity, u_exposure;\nuniform int u_shadowSteps;\n\n// Ground textures. The far colour per layer is always set: the flat colour for an\n// untextured layer, the texture's own mean x tint for a textured one, so the\n// near-to-far fade has no colour jump.\nuniform vec3 u_tFar[4];\n#ifdef TERRAIN_TEXTURED\nuniform sampler2DArray u_tColor; // albedo, sRGB\nuniform sampler2DArray u_tNormal; // rgb tangent normal (GL), a surface height\nuniform sampler2DArray u_tOrm; // r ambient occlusion, g roughness\nuniform vec4 u_tLayer[4]; // 1/tileSize, normalStrength, textured 0|1, -\nuniform vec3 u_tTint[4]; // layer colour / texture mean: the texture averages to the layer colour\nuniform vec4 u_tMeanC[4]; // per-array layer means, for the stochastic blend\nuniform vec4 u_tMeanN[4];\nuniform vec4 u_tMeanO[4];\nuniform float u_tDistance;\nuniform float u_tHeightBlend;\n#endif\n\n// A land object: a bounded patch of this field, placed by its object's transform.\n// Its \"terrain space\" is metres from the object's origin, unrotated, plus a seed\n// offset; height is above the object's base. See TerrainMaterial's patch vertex.\n#ifdef TERRAIN_PATCH\nuniform vec2 u_patchSize; // footprint in metres (object scale x / z)\nuniform vec2 u_patchOffset; // terrain-space centre: the seed's offset into the field\nuniform float u_edgeWidth; // metres over which the land eases down to its base\nuniform vec3 u_camTerrain; // the camera, in terrain space\nuniform float u_scaleY; // object scale y: terrain metres = local y x this\nuniform float u_patchCell; // metres per grid cell\n#define TERRAIN_CAM u_camTerrain\n#else\n#define TERRAIN_CAM cameraPosition\n#endif\n";
|
|
31
31
|
/**
|
|
32
32
|
* Gradient noise with an analytic derivative.
|
|
33
33
|
*
|
|
@@ -53,7 +53,7 @@ export declare const terrainNoise = "\nvec2 tHash(vec2 p){\n vec3 p3 = fract(ve
|
|
|
53
53
|
* terrain crawl), and it is most of the cost saving, because the outer rings —
|
|
54
54
|
* which carry three quarters of the vertices — run four octaves instead of nine.
|
|
55
55
|
*/
|
|
56
|
-
export declare const terrainHeight = "\n#define TERRAIN_MOUNTAINS 0\n#define TERRAIN_DUNES 1\n#define TERRAIN_HILLS 2\n#define TERRAIN_CANYON 3\n\n#define TERRAIN_MAX_OCTAVES 12\n\n/** Normalised fBm in [0,1], derivative-damped, with d/d(worldXZ) in grad. */\nfloat terrainFbmD(vec2 p, float lodCell, out vec2 grad){\n vec2 q = p * u_baseScale;\n\n // Domain warp. Without it fBm reads as fBm: blobs with no direction and no\n // drainage. Warping the sample point by a slower copy of the same noise bends\n // ridge lines into the branching curves erosion actually produces.\n //\n // Its Jacobian is carried rather than assumed to be the identity. That shortcut\n // is the usual one and it shows: at warpStrength 0.3 the normal is wrong by up\n // to 30% precisely where the warp bends a ridge, which is where the eye goes.\n vec2 qw = q;\n mat2 J = mat2(1.0, 0.0, 0.0, 1.0);\n if (u_warpStrength > 0.0){\n vec3 w0 = tNoised(q * u_warpScale + vec2(11.3, 5.7));\n vec3 w1 = tNoised(q * u_warpScale + vec2(-7.1, 19.2));\n qw = q + vec2(w0.x, w1.x) * u_warpStrength;\n float k = u_warpStrength * u_warpScale;\n // Columns, so that (v * J) evaluates transpose(J) * v - which is the chain\n // rule direction we need, and GLSL ES 1.00 has no transpose().\n J = mat2(1.0 + k * w0.y, k * w1.y,\n k * w0.z, 1.0 + k * w1.z);\n }\n\n float amp = 1.0;\n float freq = 1.0;\n float sum = 0.0;\n float norm = 0.0;\n vec2 gradW = vec2(0.0); // d(sum) / d(qw)\n vec2 slope = vec2(0.0); // bounded erosion accumulator, octave-local units\n\n // Wavelength of the first octave, in world units.\n float wl = 1.0 / max(u_baseScale, 1e-9);\n\n for (int i = 0; i < TERRAIN_MAX_OCTAVES; i++){\n if (i >= u_octaves) break;\n\n // Fade an octave out as its wavelength approaches the shading cell, then\n // stop. Popping it off with a hard test leaves a visible ring where the\n // clipmap level changes; fading is what makes the transition invisible.\n float limit = 2.0 * lodCell;\n float fade = clamp(wl / max(limit, 1e-4) - 1.0, 0.0, 1.0);\n if (fade <= 0.001) break;\n\n // A constant per-octave offset rather than a rotation matrix: rotating the\n // domain would need the transpose applied to the derivative as well, and the\n // offset decorrelates the octaves just as effectively.\n vec3 n = tNoised(qw * freq + float(i) * vec2(37.13, 61.91));\n float v = n.x;\n vec2 g = n.yz;\n\n // Ridge shaping, with the chain rule carried through so both the erosion term\n // and the surface normal still see a true slope. 1 - |v| folds the noise about\n // zero; squaring sharpens the crest.\n if (u_ridge > 0.0){\n // Ramp the fold in by octave. 1 - |v| is C1-discontinuous along the whole\n // v = 0 contour, and on octave 0 that contour is a kilometre-long smooth\n // arc - so the crease runs right across the terrain and reads as a\n // modelling seam, not as a ridge. Found by baking presets to heightmaps\n // and hillshading them, where the arcs are unmistakable; on the lit\n // terrain they hide as a suspiciously straight shadow edge.\n //\n // A crest only reads as a crest at a scale where a crest is plausible, so\n // the base octave stays smooth, the next is half folded and everything\n // finer is fully ridged. Sharpness at the scales that matter is unchanged.\n float ridgeAmt = u_ridge * clamp(float(i) * 0.5, 0.0, 1.0);\n float s = sign(v);\n float r = 1.0 - abs(v);\n float rv = r * r * 2.0 - 1.0;\n vec2 rg = -4.0 * r * s * g;\n v = mix(v, rv, ridgeAmt);\n g = mix(g, rg, ridgeAmt);\n }\n\n // The erosion term. Slope accumulated so far suppresses everything finer.\n // Deliberately fed the OCTAVE-LOCAL derivative, not the frequency-scaled one:\n // scaled, it grows like lacunarity^i, the damping collapses by the third\n // octave and every finer octave vanishes - a terrain that is flat however high\n // its elevation is set. Its own derivative is ignored, which is the standard\n // approximation and invisible at these amplitudes.\n float damp = 1.0 / (1.0 + u_erosion * 1.5 * dot(slope, slope));\n float wgt = amp * damp * fade;\n\n sum += wgt * v;\n norm += amp * fade;\n gradW += wgt * g * freq;\n slope += g * amp * damp;\n\n amp *= u_gain;\n freq *= u_lacunarity;\n wl /= u_lacunarity;\n }\n\n float inv = 1.0 / max(norm, 1e-4);\n\n // Contrast, and it is not a taste knob.\n //\n // Dividing by the summed amplitude is the textbook normalisation and it is\n // wrong for terrain: octaves of gradient noise almost never align, so the sum\n // lands in about a quarter of the range the divisor assumes and the field comes\n // out spanning 0.45-0.69 instead of 0-1. A 1400 m elevation then renders as a\n // 320 m swell, and no amount of extra octaves fixes it because they are being\n // divided away too. Measured against the height field directly: 3.2 recovers\n // roughly 740 m of the 1400, which is a real range at a real grade.\n //\n // The soft clamp rather than a hard one, so a peak that would overshoot rolls\n // off instead of arriving with a flat top.\n float t = sum * inv * 3.2;\n float rs = inversesqrt(1.0 + t * t);\n\n // d(height)/d(qw) -> d/d(q) via the warp Jacobian -> d/d(world).\n vec2 dqw = gradW * (0.5 * 3.2 * rs * rs * rs * inv);\n grad = (dqw * J) * u_baseScale;\n\n return 0.5 + 0.5 * t * rs;\n}\n\n/**\n * Height above sea level in world units at a world XZ, and the surface gradient\n * d(height)/d(worldXZ). The normal is normalize(vec3(-grad.x, 1, -grad.y)).\n *\n * Curvature is deliberately NOT applied here. It is a view-relative bend applied\n * at the vertex, and folding it in would make the height field depend on where\n * the camera is \u2014 which the shadow march and the normals both sample, and would\n * mean a shadow that moves when you turn your head.\n */\nfloat terrainSample(vec2 p, float lodCell, out vec2 grad){\n vec2 gh;\n float h = terrainFbmD(p, lodCell, gh);\n\n if (u_terrainType == TERRAIN_DUNES){\n // Dunes are a wave train transverse to the wind, not a noise field. The fBm\n // bends the crest lines and sets how tall each dune is; the sine is the dune.\n vec2 d = vec2(u_bearingDir.y, -u_bearingDir.x);\n float phase = dot(p, d) * u_duneFreq + 7.0 * h;\n vec2 dphase = d * u_duneFreq + 7.0 * gh;\n\n float u = 0.5 + 0.5 * sin(phase);\n vec2 du = 0.5 * cos(phase) * dphase;\n\n // Asymmetry: a real dune is a long windward ramp and a short slip face at the\n // angle of repose. Raising the crest to a power does that in one instruction.\n float k = mix(1.0, 3.2, u_duneAsym);\n float us = max(u, 1e-4);\n float s = pow(us, k);\n vec2 ds = k * pow(us, k - 1.0) * du;\n\n // The envelope keeps dune height varying across the field rather than\n // stamping one ridge repeated to the horizon.\n float env = 0.45 + 0.55 * h;\n float a = 0.15 + 0.5 * h;\n float b = s * env;\n vec2 da = 0.5 * gh;\n vec2 db = ds * env + s * 0.55 * gh;\n h = mix(a, b, 0.8);\n gh = mix(da, db, 0.8);\n }\n else if (u_terrainType == TERRAIN_CANYON){\n // Canyon country is a plateau with things taken out of it, not a mountain\n // range. Flatten the top first, then cut.\n float om = 1.0 - h;\n float mesa = mix(h, 1.0 - om * om * om, u_plateau);\n float dmf = mix(1.0, 3.0 * om * om, u_plateau);\n\n // Channel network: ridged noise is near 1 along its zero set, which is a\n // connected branching line \u2014 a drainage network, for free.\n vec3 cn = tNoised(p * (u_baseScale * 1.7) + vec2(4.2, -9.1));\n float ch = 1.0 - abs(cn.x);\n vec2 dch = -sign(cn.x) * cn.yz * (u_baseScale * 1.7);\n\n float e0 = 1.0 - u_valleyWidth;\n float ct = clamp((ch - e0) / max(1.0 - e0, 1e-4), 0.0, 1.0);\n float carve = ct * ct * (3.0 - 2.0 * ct);\n float dcarve = 6.0 * ct * (1.0 - ct) / max(1.0 - e0, 1e-4);\n\n h = mesa - u_valleyDepth * carve;\n gh = dmf * gh - (u_valleyDepth * dcarve) * dch;\n }\n\n // Sedimentary banding. Applied after shaping, so it bands the finished landform\n // rather than the raw noise.\n if (u_terraces >= 0.5){\n float n = u_terraces;\n\n // The aliasing bound is HORIZONTAL, not vertical. What aliases is how far\n // across the ground a riser takes to climb, and that scales with the\n // landform's own size divided by the number of bands stacked on it. Widening\n // the riser is not enough on its own either: smoothstep(0, 1, fr) still has a\n // flat spot at each end, so a \"fully softened\" terrace is still a staircase.\n // Fade all the way to the identity ramp, which is the un-terraced surface.\n float featureSize = 1.0 / max(u_baseScale, 1e-9);\n float soft = clamp(lodCell * n * 8.0 / featureSize, 0.0, 1.0);\n float w = max(1.0 - 0.95 * u_terraceSharp, 0.02);\n\n float x = h * n;\n float fr = fract(x);\n float ct = clamp(fr / w, 0.0, 1.0);\n float k = mix(ct * ct * (3.0 - 2.0 * ct), fr, soft);\n float dk = mix(6.0 * ct * (1.0 - ct) / w, 1.0, soft);\n\n h = (floor(x) + k) / n;\n gh = dk * gh;\n }\n\n grad = gh * u_elevation;\n return u_seaLevel + u_elevation * h;\n}\n\n/**\n * Height only, and a genuinely separate path rather than terrainSample with the\n * gradient thrown away.\n *\n * This is the shadow march's inner loop - fourteen calls per shaded point - and\n * it is the one place where paying for a derivative nobody reads actually shows\n * up. No warp Jacobian, no gradient accumulation, no chain rule through the\n * shaping: about half the work of the full sample.\n */\nfloat terrainHeightAt(vec2 p, float lodCell){\n vec2 q = p * u_baseScale;\n if (u_warpStrength > 0.0){\n q += vec2(\n tNoise(q * u_warpScale + vec2(11.3, 5.7)),\n tNoise(q * u_warpScale + vec2(-7.1, 19.2))\n ) * u_warpStrength;\n }\n\n float amp = 1.0, freq = 1.0, sum = 0.0, norm = 0.0;\n vec2 slope = vec2(0.0);\n float wl = 1.0 / max(u_baseScale, 1e-9);\n\n for (int i = 0; i < TERRAIN_MAX_OCTAVES; i++){\n if (i >= u_octaves) break;\n float limit = 2.0 * lodCell;\n float fade = clamp(wl / max(limit, 1e-4) - 1.0, 0.0, 1.0);\n if (fade <= 0.001) break;\n\n vec3 n = tNoised(q * freq + float(i) * vec2(37.13, 61.91));\n float v = n.x;\n vec2 g = n.yz;\n if (u_ridge > 0.0){\n // Same octave ramp as the derivative path above - the two must agree or a\n // height query and the rendered surface disagree by the fold amount.\n float ridgeAmt = u_ridge * clamp(float(i) * 0.5, 0.0, 1.0);\n float sg = sign(v);\n float r = 1.0 - abs(v);\n v = mix(v, r * r * 2.0 - 1.0, ridgeAmt);\n g = mix(g, -4.0 * r * sg * g, ridgeAmt);\n }\n float damp = 1.0 / (1.0 + u_erosion * 1.5 * dot(slope, slope));\n sum += amp * damp * fade * v;\n norm += amp * fade;\n slope += g * amp * damp;\n\n amp *= u_gain;\n freq *= u_lacunarity;\n wl /= u_lacunarity;\n }\n\n float t = (sum / max(norm, 1e-4)) * 3.2;\n float h = 0.5 + 0.5 * t * inversesqrt(1.0 + t * t);\n\n if (u_terrainType == TERRAIN_DUNES){\n vec2 d = vec2(u_bearingDir.y, -u_bearingDir.x);\n float u = 0.5 + 0.5 * sin(dot(p, d) * u_duneFreq + 7.0 * h);\n float s = pow(max(u, 1e-4), mix(1.0, 3.2, u_duneAsym));\n h = mix(0.15 + 0.5 * h, s * (0.45 + 0.55 * h), 0.8);\n }\n else if (u_terrainType == TERRAIN_CANYON){\n float om = 1.0 - h;\n float mesa = mix(h, 1.0 - om * om * om, u_plateau);\n float ch = 1.0 - abs(tNoise(p * (u_baseScale * 1.7) + vec2(4.2, -9.1)));\n h = mesa - u_valleyDepth * smoothstep(1.0 - u_valleyWidth, 1.0, ch);\n }\n\n if (u_terraces >= 0.5){\n float n = u_terraces;\n float featureSize = 1.0 / max(u_baseScale, 1e-9);\n float soft = clamp(lodCell * n * 8.0 / featureSize, 0.0, 1.0);\n float w = max(1.0 - 0.95 * u_terraceSharp, 0.02);\n float x = h * n;\n float fr = fract(x);\n h = (floor(x) + mix(smoothstep(0.0, w, fr), fr, soft)) / n;\n }\n\n return u_seaLevel + u_elevation * h;\n}\n\nvec3 terrainNormal(vec2 grad){\n return normalize(vec3(-grad.x, 1.0, -grad.y));\n}\n";
|
|
56
|
+
export declare const terrainHeight = "\n#define TERRAIN_MOUNTAINS 0\n#define TERRAIN_DUNES 1\n#define TERRAIN_HILLS 2\n#define TERRAIN_CANYON 3\n\n#define TERRAIN_MAX_OCTAVES 12\n\n/** Normalised fBm in [0,1], derivative-damped, with d/d(worldXZ) in grad. */\nfloat terrainFbmD(vec2 p, float lodCell, out vec2 grad){\n vec2 q = p * u_baseScale;\n\n // Domain warp. Without it fBm reads as fBm: blobs with no direction and no\n // drainage. Warping the sample point by a slower copy of the same noise bends\n // ridge lines into the branching curves erosion actually produces.\n //\n // Its Jacobian is carried rather than assumed to be the identity. That shortcut\n // is the usual one and it shows: at warpStrength 0.3 the normal is wrong by up\n // to 30% precisely where the warp bends a ridge, which is where the eye goes.\n vec2 qw = q;\n mat2 J = mat2(1.0, 0.0, 0.0, 1.0);\n if (u_warpStrength > 0.0){\n vec3 w0 = tNoised(q * u_warpScale + vec2(11.3, 5.7));\n vec3 w1 = tNoised(q * u_warpScale + vec2(-7.1, 19.2));\n qw = q + vec2(w0.x, w1.x) * u_warpStrength;\n float k = u_warpStrength * u_warpScale;\n // Columns, so that (v * J) evaluates transpose(J) * v - which is the chain\n // rule direction we need, and GLSL ES 1.00 has no transpose().\n J = mat2(1.0 + k * w0.y, k * w1.y,\n k * w0.z, 1.0 + k * w1.z);\n }\n\n float amp = 1.0;\n float freq = 1.0;\n float sum = 0.0;\n float norm = 0.0;\n vec2 gradW = vec2(0.0); // d(sum) / d(qw)\n vec2 slope = vec2(0.0); // bounded erosion accumulator, octave-local units\n\n // Wavelength of the first octave, in world units.\n float wl = 1.0 / max(u_baseScale, 1e-9);\n\n for (int i = 0; i < TERRAIN_MAX_OCTAVES; i++){\n if (i >= u_octaves) break;\n\n // Fade an octave out as its wavelength approaches the shading cell, then\n // stop. Popping it off with a hard test leaves a visible ring where the\n // clipmap level changes; fading is what makes the transition invisible.\n float limit = 2.0 * lodCell;\n float fade = clamp(wl / max(limit, 1e-4) - 1.0, 0.0, 1.0);\n if (fade <= 0.001) break;\n\n // A constant per-octave offset rather than a rotation matrix: rotating the\n // domain would need the transpose applied to the derivative as well, and the\n // offset decorrelates the octaves just as effectively.\n vec3 n = tNoised(qw * freq + float(i) * vec2(37.13, 61.91));\n float v = n.x;\n vec2 g = n.yz;\n\n // Ridge shaping, with the chain rule carried through so both the erosion term\n // and the surface normal still see a true slope. 1 - |v| folds the noise about\n // zero; squaring sharpens the crest.\n if (u_ridge > 0.0){\n // Ramp the fold in by octave. 1 - |v| is C1-discontinuous along the whole\n // v = 0 contour, and on octave 0 that contour is a kilometre-long smooth\n // arc - so the crease runs right across the terrain and reads as a\n // modelling seam, not as a ridge. Found by baking presets to heightmaps\n // and hillshading them, where the arcs are unmistakable; on the lit\n // terrain they hide as a suspiciously straight shadow edge.\n //\n // A crest only reads as a crest at a scale where a crest is plausible, so\n // the base octave stays smooth, the next is half folded and everything\n // finer is fully ridged. Sharpness at the scales that matter is unchanged.\n float ridgeAmt = u_ridge * clamp(float(i) * 0.5, 0.0, 1.0);\n float s = sign(v);\n float r = 1.0 - abs(v);\n float rv = r * r * 2.0 - 1.0;\n vec2 rg = -4.0 * r * s * g;\n v = mix(v, rv, ridgeAmt);\n g = mix(g, rg, ridgeAmt);\n }\n\n // The erosion term. Slope accumulated so far suppresses everything finer.\n // Deliberately fed the OCTAVE-LOCAL derivative, not the frequency-scaled one:\n // scaled, it grows like lacunarity^i, the damping collapses by the third\n // octave and every finer octave vanishes - a terrain that is flat however high\n // its elevation is set. Its own derivative is ignored, which is the standard\n // approximation and invisible at these amplitudes.\n float damp = 1.0 / (1.0 + u_erosion * 1.5 * dot(slope, slope));\n float wgt = amp * damp * fade;\n\n sum += wgt * v;\n norm += amp * fade;\n gradW += wgt * g * freq;\n slope += g * amp * damp;\n\n amp *= u_gain;\n freq *= u_lacunarity;\n wl /= u_lacunarity;\n }\n\n float inv = 1.0 / max(norm, 1e-4);\n\n // Contrast, and it is not a taste knob.\n //\n // Dividing by the summed amplitude is the textbook normalisation and it is\n // wrong for terrain: octaves of gradient noise almost never align, so the sum\n // lands in about a quarter of the range the divisor assumes and the field comes\n // out spanning 0.45-0.69 instead of 0-1. A 1400 m elevation then renders as a\n // 320 m swell, and no amount of extra octaves fixes it because they are being\n // divided away too. Measured against the height field directly: 3.2 recovers\n // roughly 740 m of the 1400, which is a real range at a real grade.\n //\n // The soft clamp rather than a hard one, so a peak that would overshoot rolls\n // off instead of arriving with a flat top.\n float t = sum * inv * 3.2;\n float rs = inversesqrt(1.0 + t * t);\n\n // d(height)/d(qw) -> d/d(q) via the warp Jacobian -> d/d(world).\n vec2 dqw = gradW * (0.5 * 3.2 * rs * rs * rs * inv);\n grad = (dqw * J) * u_baseScale;\n\n return 0.5 + 0.5 * t * rs;\n}\n\n/**\n * Height above sea level in world units at a world XZ, and the surface gradient\n * d(height)/d(worldXZ). The normal is normalize(vec3(-grad.x, 1, -grad.y)).\n *\n * Curvature is deliberately NOT applied here. It is a view-relative bend applied\n * at the vertex, and folding it in would make the height field depend on where\n * the camera is \u2014 which the shadow march and the normals both sample, and would\n * mean a shadow that moves when you turn your head.\n */\nfloat terrainSample(vec2 p, float lodCell, out vec2 grad){\n vec2 gh;\n float h = terrainFbmD(p, lodCell, gh);\n\n if (u_terrainType == TERRAIN_DUNES){\n // Dunes are a wave train transverse to the wind, not a noise field. The fBm\n // bends the crest lines and sets how tall each dune is; the sine is the dune.\n vec2 d = vec2(u_bearingDir.y, -u_bearingDir.x);\n float phase = dot(p, d) * u_duneFreq + 7.0 * h;\n vec2 dphase = d * u_duneFreq + 7.0 * gh;\n\n float u = 0.5 + 0.5 * sin(phase);\n vec2 du = 0.5 * cos(phase) * dphase;\n\n // Asymmetry: a real dune is a long windward ramp and a short slip face at the\n // angle of repose. Raising the crest to a power does that in one instruction.\n float k = mix(1.0, 3.2, u_duneAsym);\n float us = max(u, 1e-4);\n float s = pow(us, k);\n vec2 ds = k * pow(us, k - 1.0) * du;\n\n // The envelope keeps dune height varying across the field rather than\n // stamping one ridge repeated to the horizon.\n float env = 0.45 + 0.55 * h;\n float a = 0.15 + 0.5 * h;\n float b = s * env;\n vec2 da = 0.5 * gh;\n vec2 db = ds * env + s * 0.55 * gh;\n h = mix(a, b, 0.8);\n gh = mix(da, db, 0.8);\n }\n else if (u_terrainType == TERRAIN_CANYON){\n // Canyon country is a plateau with things taken out of it, not a mountain\n // range. Flatten the top first, then cut.\n float om = 1.0 - h;\n float mesa = mix(h, 1.0 - om * om * om, u_plateau);\n float dmf = mix(1.0, 3.0 * om * om, u_plateau);\n\n // Channel network: ridged noise is near 1 along its zero set, which is a\n // connected branching line \u2014 a drainage network, for free.\n vec3 cn = tNoised(p * (u_baseScale * 1.7) + vec2(4.2, -9.1));\n float ch = 1.0 - abs(cn.x);\n vec2 dch = -sign(cn.x) * cn.yz * (u_baseScale * 1.7);\n\n float e0 = 1.0 - u_valleyWidth;\n float ct = clamp((ch - e0) / max(1.0 - e0, 1e-4), 0.0, 1.0);\n float carve = ct * ct * (3.0 - 2.0 * ct);\n float dcarve = 6.0 * ct * (1.0 - ct) / max(1.0 - e0, 1e-4);\n\n h = mesa - u_valleyDepth * carve;\n gh = dmf * gh - (u_valleyDepth * dcarve) * dch;\n }\n\n // Sedimentary banding. Applied after shaping, so it bands the finished landform\n // rather than the raw noise.\n if (u_terraces >= 0.5){\n float n = u_terraces;\n\n // The aliasing bound is HORIZONTAL, not vertical. What aliases is how far\n // across the ground a riser takes to climb, and that scales with the\n // landform's own size divided by the number of bands stacked on it. Widening\n // the riser is not enough on its own either: smoothstep(0, 1, fr) still has a\n // flat spot at each end, so a \"fully softened\" terrace is still a staircase.\n // Fade all the way to the identity ramp, which is the un-terraced surface.\n float featureSize = 1.0 / max(u_baseScale, 1e-9);\n float soft = clamp(lodCell * n * 8.0 / featureSize, 0.0, 1.0);\n float w = max(1.0 - 0.95 * u_terraceSharp, 0.02);\n\n float x = h * n;\n float fr = fract(x);\n float ct = clamp(fr / w, 0.0, 1.0);\n float k = mix(ct * ct * (3.0 - 2.0 * ct), fr, soft);\n float dk = mix(6.0 * ct * (1.0 - ct) / w, 1.0, soft);\n\n h = (floor(x) + k) / n;\n gh = dk * gh;\n }\n\n grad = gh * u_elevation;\n return u_seaLevel + u_elevation * h;\n}\n\n/**\n * Height only, and a genuinely separate path rather than terrainSample with the\n * gradient thrown away.\n *\n * This is the shadow march's inner loop - fourteen calls per shaded point - and\n * it is the one place where paying for a derivative nobody reads actually shows\n * up. No warp Jacobian, no gradient accumulation, no chain rule through the\n * shaping: about half the work of the full sample.\n */\nfloat terrainHeightAt(vec2 p, float lodCell){\n vec2 q = p * u_baseScale;\n if (u_warpStrength > 0.0){\n q += vec2(\n tNoise(q * u_warpScale + vec2(11.3, 5.7)),\n tNoise(q * u_warpScale + vec2(-7.1, 19.2))\n ) * u_warpStrength;\n }\n\n float amp = 1.0, freq = 1.0, sum = 0.0, norm = 0.0;\n vec2 slope = vec2(0.0);\n float wl = 1.0 / max(u_baseScale, 1e-9);\n\n for (int i = 0; i < TERRAIN_MAX_OCTAVES; i++){\n if (i >= u_octaves) break;\n float limit = 2.0 * lodCell;\n float fade = clamp(wl / max(limit, 1e-4) - 1.0, 0.0, 1.0);\n if (fade <= 0.001) break;\n\n vec3 n = tNoised(q * freq + float(i) * vec2(37.13, 61.91));\n float v = n.x;\n vec2 g = n.yz;\n if (u_ridge > 0.0){\n // Same octave ramp as the derivative path above - the two must agree or a\n // height query and the rendered surface disagree by the fold amount.\n float ridgeAmt = u_ridge * clamp(float(i) * 0.5, 0.0, 1.0);\n float sg = sign(v);\n float r = 1.0 - abs(v);\n v = mix(v, r * r * 2.0 - 1.0, ridgeAmt);\n g = mix(g, -4.0 * r * sg * g, ridgeAmt);\n }\n float damp = 1.0 / (1.0 + u_erosion * 1.5 * dot(slope, slope));\n sum += amp * damp * fade * v;\n norm += amp * fade;\n slope += g * amp * damp;\n\n amp *= u_gain;\n freq *= u_lacunarity;\n wl /= u_lacunarity;\n }\n\n float t = (sum / max(norm, 1e-4)) * 3.2;\n float h = 0.5 + 0.5 * t * inversesqrt(1.0 + t * t);\n\n if (u_terrainType == TERRAIN_DUNES){\n vec2 d = vec2(u_bearingDir.y, -u_bearingDir.x);\n float u = 0.5 + 0.5 * sin(dot(p, d) * u_duneFreq + 7.0 * h);\n float s = pow(max(u, 1e-4), mix(1.0, 3.2, u_duneAsym));\n h = mix(0.15 + 0.5 * h, s * (0.45 + 0.55 * h), 0.8);\n }\n else if (u_terrainType == TERRAIN_CANYON){\n float om = 1.0 - h;\n float mesa = mix(h, 1.0 - om * om * om, u_plateau);\n float ch = 1.0 - abs(tNoise(p * (u_baseScale * 1.7) + vec2(4.2, -9.1)));\n h = mesa - u_valleyDepth * smoothstep(1.0 - u_valleyWidth, 1.0, ch);\n }\n\n if (u_terraces >= 0.5){\n float n = u_terraces;\n float featureSize = 1.0 / max(u_baseScale, 1e-9);\n float soft = clamp(lodCell * n * 8.0 / featureSize, 0.0, 1.0);\n float w = max(1.0 - 0.95 * u_terraceSharp, 0.02);\n float x = h * n;\n float fr = fract(x);\n h = (floor(x) + mix(smoothstep(0.0, w, fr), fr, soft)) / n;\n }\n\n return u_seaLevel + u_elevation * h;\n}\n\nvec3 terrainNormal(vec2 grad){\n return normalize(vec3(-grad.x, 1.0, -grad.y));\n}\n\n/**\n * The surface as drawn. For the environment terrain it is the field itself; for a\n * land object the field is eased down to the base across the edge band, so the\n * patch meets whatever it stands on instead of ending in a cliff. The mask is\n * applied to the height AND its gradient (product rule), so normals, slope rock\n * and the shadow march all see the same eased surface the vertices do.\n */\n#ifdef TERRAIN_PATCH\nfloat terrainPatchMask(vec2 p, out vec2 dmask){\n vec2 l = (p - u_patchOffset) / u_patchSize; // -0.5 .. 0.5 inside\n vec2 d = (0.5 - abs(l)) * u_patchSize; // metres to each pair of edges\n vec2 sgn = vec2(l.x < 0.0 ? 1.0 : -1.0, l.y < 0.0 ? 1.0 : -1.0);\n float dist = min(d.x, d.y);\n vec2 ddist = d.x < d.y ? vec2(sgn.x, 0.0) : vec2(0.0, sgn.y);\n if (dist <= 0.0){ dmask = vec2(0.0); return 0.0; }\n if (u_edgeWidth <= 1e-3){ dmask = vec2(0.0); return 1.0; }\n float x = clamp(dist / u_edgeWidth, 0.0, 1.0);\n dmask = ddist * (6.0 * x * (1.0 - x) / u_edgeWidth);\n return x * x * (3.0 - 2.0 * x);\n}\nfloat terrainSurfaceAt(vec2 p, float lodCell, out vec2 grad){\n vec2 g;\n float h = terrainSample(p, lodCell, g) - u_seaLevel;\n vec2 dm;\n float m = terrainPatchMask(p, dm);\n grad = g * m + h * dm;\n return u_seaLevel + h * m;\n}\nfloat terrainOccluderAt(vec2 p, float lodCell){\n vec2 dm;\n float m = terrainPatchMask(p, dm);\n if (m <= 0.0) return u_seaLevel;\n return u_seaLevel + (terrainHeightAt(p, lodCell) - u_seaLevel) * m;\n}\n#else\nfloat terrainSurfaceAt(vec2 p, float lodCell, out vec2 grad){ return terrainSample(p, lodCell, grad); }\nfloat terrainOccluderAt(vec2 p, float lodCell){ return terrainHeightAt(p, lodCell); }\n#endif\n";
|
|
57
57
|
/**
|
|
58
58
|
* Shading: the analytic self-shadow, the splat, and the light.
|
|
59
59
|
*
|
|
@@ -70,7 +70,20 @@ export declare const terrainHeight = "\n#define TERRAIN_MOUNTAINS 0\n#define TER
|
|
|
70
70
|
* The terminator itself stays per-pixel: `terrainLight` takes N·L from the
|
|
71
71
|
* fragment's own normal, so only the CAST shadow is interpolated.
|
|
72
72
|
*/
|
|
73
|
-
export declare const terrainShading = "\n/** 1 lit, 0 shadowed, soft in between. */\nfloat terrainSunShadow(vec3 p, vec3 n, float lodCell, int steps){\n if (steps < 1 || u_sunShadow <= 0.0) return 1.0;\n // Below the horizon there is nothing to shadow; the march would also walk\n // downhill forever.\n if (u_sunDir.y <= 0.015) return 1.0;\n // A surface facing away from the sun is shadowed by definition, and marching\n // from it only finds the ground it is already part of.\n if (dot(n, u_sunDir) <= 0.0) return 0.0;\n\n // Lift off the surface before starting, or every sample on a steep face - a\n // terrace riser above all - reads its own ground as an occluder and the whole\n // wall goes black in a grid of triangles. Start ON the offset surface and\n // compare raw heights; subtracting the bias from the height difference instead\n // makes the first sample fail on any slope tilted a few degrees from the sun.\n float bias = max(lodCell, u_elevation * 0.003);\n vec3 origin = p + n * bias;\n\n float shadowLod = (1.0 / max(u_baseScale, 1e-9)) * 0.008;\n\n float res = 1.0;\n float t = bias * 3.0;\n float maxT = (u_elevation * 2.5) / max(u_sunDir.y, 0.05);\n\n for (int i = 0; i < 48; i++){\n if (i >= steps || t > maxT) break;\n vec3 sp = origin + u_sunDir * t;\n // The occluder is sampled at the SHADING lod, coarsening with distance -\n // never at a fixed coarse lod. Testing a fine surface point against a coarse\n // height field puts the whole valley floor in shadow, because the coarse\n // field sits above the fine one wherever the fine one has been cut down.\n // Sampled MUCH coarser than the surface being shaded. A shadow does not need\n // nine octaves: what casts a visible shadow is the landform, and marching the\n // fine field costs the same nine octaves per step for detail that is below a\n // pixel by the time it lands. Floored against the landform's own size, so the\n // march runs about five octaves instead of nine wherever it starts.\n float h =
|
|
73
|
+
export declare const terrainShading = "\n/** 1 lit, 0 shadowed, soft in between. */\nfloat terrainSunShadow(vec3 p, vec3 n, float lodCell, int steps){\n if (steps < 1 || u_sunShadow <= 0.0) return 1.0;\n // Below the horizon there is nothing to shadow; the march would also walk\n // downhill forever.\n if (u_sunDir.y <= 0.015) return 1.0;\n // A surface facing away from the sun is shadowed by definition, and marching\n // from it only finds the ground it is already part of.\n if (dot(n, u_sunDir) <= 0.0) return 0.0;\n\n // Lift off the surface before starting, or every sample on a steep face - a\n // terrace riser above all - reads its own ground as an occluder and the whole\n // wall goes black in a grid of triangles. Start ON the offset surface and\n // compare raw heights; subtracting the bias from the height difference instead\n // makes the first sample fail on any slope tilted a few degrees from the sun.\n float bias = max(lodCell, u_elevation * 0.003);\n vec3 origin = p + n * bias;\n\n float shadowLod = (1.0 / max(u_baseScale, 1e-9)) * 0.008;\n\n float res = 1.0;\n float t = bias * 3.0;\n float maxT = (u_elevation * 2.5) / max(u_sunDir.y, 0.05);\n\n for (int i = 0; i < 48; i++){\n if (i >= steps || t > maxT) break;\n vec3 sp = origin + u_sunDir * t;\n // The occluder is sampled at the SHADING lod, coarsening with distance -\n // never at a fixed coarse lod. Testing a fine surface point against a coarse\n // height field puts the whole valley floor in shadow, because the coarse\n // field sits above the fine one wherever the fine one has been cut down.\n // Sampled MUCH coarser than the surface being shaded. A shadow does not need\n // nine octaves: what casts a visible shadow is the landform, and marching the\n // fine field costs the same nine octaves per step for detail that is below a\n // pixel by the time it lands. Floored against the landform's own size, so the\n // march runs about five octaves instead of nine wherever it starts.\n float h = terrainOccluderAt(sp.xz, max(max(lodCell * 2.0, t * 0.06), shadowLod));\n float diff = sp.y - h;\n res = min(res, u_shadowSoftness * diff / t);\n if (res <= 0.0) return 0.0;\n // Geometric growth: near the surface the occluder is metres away, at the end\n // of the march it is kilometres, and a linear step wastes every sample at one\n // end or the other. 1.7 rather than 1.42 so twelve steps actually reach maxT -\n // at 1.42 the march ran out around 700 m and long shadows at low sun simply\n // did not exist, which is a quality bug that happened to look like a cheap one.\n t = t * 1.7 + bias;\n }\n return saturate(res);\n}\n\n/**\n * The shadow, faded out with distance and given a step budget that falls with it.\n *\n * The march is the most expensive thing left in the renderer, and past a few\n * kilometres it is buying nothing: aerial perspective has already washed most of\n * the contrast out of the ground, and a ridge shadow out there is a couple of\n * pixels wide. Skipping it entirely beyond u_shadowDistance drops the outer\n * clipmap rings - which are two thirds of the vertices - out of the march\n * completely, and the rings in between run four steps instead of fourteen.\n *\n * Faded rather than cut, or the cut-off would draw a visible circle on the ground.\n */\nfloat terrainShadowAt(vec3 p, vec3 n, float lodCell, float dist){\n float fade = 1.0 - saturate(dist / max(u_shadowDistance, 1.0));\n if (fade <= 0.002) return 1.0;\n int steps = int(mix(4.0, float(u_shadowSteps), fade));\n return mix(1.0, terrainSunShadow(p, n, lodCell, steps), fade);\n}\n\n/**\n * Albedo.\n *\n * Rock is splatted by SLOPE, everything else by height. That ordering is the\n * whole trick: it means a cliff is bare rock whether it is in a valley or on a\n * summit, which is how real ground works and why height-only splatting always\n * reads as a painted contour map.\n */\n/**\n * Splat weights for the four layers, in layer order: low, mid, rock, peak.\n * Exactly the old colour mixes written as weights \u2014 low/mid by height, the peak\n * held back on steep ground (snow does not sit on a vertical face), rock by slope\n * and applied last, which is why a cliff reads as a cliff at any altitude.\n */\nvec4 terrainLayerWeights(float h01, float slope){\n float m = smoothstep(0.05, 0.55, h01);\n float p = saturate(smoothstep(u_peakLevel, u_peakLevel + u_peakBlend, h01 - slope * u_peakSlopeFalloff * 0.6));\n float r = smoothstep(u_slopeRockStart, u_slopeRockEnd, slope);\n return vec4((1.0 - m) * (1.0 - p) * (1.0 - r), m * (1.0 - p) * (1.0 - r), r, p * (1.0 - r));\n}\n\n/** Large-scale variation. Without it a splat layer is one flat colour across\n * kilometres, and the eye reads flat colour as untextured rather than as ground. */\nfloat terrainMacro(vec3 wp){\n float macro = tNoise(wp.xz * u_macroScale) * 0.5 + 0.5;\n return 1.0 + u_macroVariation * (macro - 0.5) * 2.0;\n}\n\n/** The far-field albedo: each layer's far colour by its weight. */\nvec3 terrainAlbedo(vec3 wp, vec4 w){\n vec3 col = u_tFar[0] * w.x + u_tFar[1] * w.y + u_tFar[2] * w.z + u_tFar[3] * w.w;\n return col * terrainMacro(wp);\n}\n\n/** High-frequency bump, well below the mesh resolution, faded out with distance\n * so it never becomes a field of crawling pixels on the horizon. One evaluation:\n * the noise carries its own derivative, so the three taps a finite difference\n * would need are not. */\nvec3 terrainDetailNormal(vec3 n, vec3 wp, float dist){\n float fade = 1.0 - saturate(dist * u_detailFade);\n float amt = u_detailStrength * fade * fade;\n if (amt <= 0.001) return n;\n vec3 d = tNoised(wp.xz * u_detailScale);\n return normalize(n + vec3(-d.y, 0.0, -d.z) * amt * 0.9);\n}\n\n/**\n * Direct sun, sky fill and ground bounce.\n *\n * Sun irradiance is in the units skyRadiance returns, calibrated against it rather\n * than guessed: a 0.3-albedo surface in full sun lands a little below the sky at\n * the horizon, which is the relationship the eye reads as daylight. Set it to the\n * clouds' SUN_RADIANCE and every ground surface clips to white.\n */\nconst float TERRAIN_SUN = 2.2;\n\nvec3 terrainLight(vec3 albedo, vec3 n, vec3 viewDir, float shadow, float sceneShadow, float roughness, float ao){\n float ndl = max(dot(n, u_sunDir), 0.0);\n // Wrap the terminator slightly: bare ground is not a Lambertian sphere, and a\n // hard terminator across a whole hillside reads as CG.\n float wrap = max((dot(n, u_sunDir) + 0.2) / 1.2, 0.0);\n float diff = mix(ndl, wrap, 0.4);\n\n vec3 sun = u_sunColor * u_sunIntensity * TERRAIN_SUN * diff * shadow * sceneShadow;\n\n // Sky fill from the same atmosphere the sky is drawn with, so it darkens and\n // warms with the sun instead of freezing at a constant blue - but supplied as a\n // uniform rather than evaluated here, since it is the same for every pixel.\n // Whitened a little: a single-scattering zenith colour is very saturated, and\n // at full saturation every shadowed slope - snow above all - comes out cyan.\n vec3 fill = mix(u_skyAmbient, vec3(dot(u_skyAmbient, vec3(0.3333))), 0.4);\n vec3 ambient = fill * (0.5 + 0.5 * n.y) * u_ambient * 1.05;\n\n // Ground bounce, tinted by whatever the ground is. Keeps overhangs and shaded\n // faces off pure black without flattening them the way raising ambient does.\n vec3 bounce = u_tFar[0] * u_groundAmbient * (0.5 - 0.5 * n.y) * u_bounce * 1.3;\n\n // Occlusion is a property of the small-scale surface, so it darkens the light\n // that arrives from everywhere \u2014 sky fill and bounce \u2014 and leaves the sun alone.\n vec3 col = albedo * (sun + (ambient + bounce) * ao);\n\n // A single specular lobe. Rock barely needs it; wet sand and snow at low sun\n // are almost entirely this.\n if (u_specular > 0.0){\n vec3 hv = normalize(u_sunDir - viewDir);\n float a = max(roughness * roughness, 0.002);\n float nh = max(dot(n, hv), 0.0);\n float dd = nh * nh * (a - 1.0) + 1.0;\n float d = a / max(3.14159265 * dd * dd, 1e-4);\n col += u_sunColor * u_sunIntensity * TERRAIN_SUN * d * u_specular * shadow * sceneShadow * ndl;\n }\n\n return col;\n}\n\n/**\n * Aerial perspective.\n *\n * The single most important line in this shader for the horizon. Ground fades\n * into the exact sky colour it is seen through, at a rate that thins with\n * altitude because the atmosphere does \u2014 so a distant ridge sits behind the haze\n * and a peak above it stands clear of it, which is what tells you the scene is\n * kilometres across rather than metres.\n *\n * The one remaining per-pixel skyRadiance call, and it has to be: the colour is\n * the sky in the view direction, which is different for every fragment.\n */\nvec3 terrainAerial(vec3 col, vec3 rd, float dist, float height){\n float scaleHeight = exp(-max(height - u_seaLevel, 0.0) / 1400.0);\n float f = 1.0 - exp(-dist * u_fogDensity * scaleHeight);\n if (f < 0.002) return col;\n return mix(col, skyRadiance(rd), saturate(f));\n}\n";
|
|
74
|
+
/**
|
|
75
|
+
* The textured near field. Needs `surfaceSampling` (surfaceCore.glsl) before it.
|
|
76
|
+
*
|
|
77
|
+
* Only the two heaviest layers are sampled per pixel. Two layers overlap almost
|
|
78
|
+
* everywhere a boundary is; three meet only at triple points, and halving the
|
|
79
|
+
* fetches is worth a slightly harder edge there. The rock layer is projected
|
|
80
|
+
* biplanar — it is the only one that ever sits on a steep face — and the other
|
|
81
|
+
* three straight down.
|
|
82
|
+
*
|
|
83
|
+
* Gradients come in from main (see sfSample): which layer a pixel samples is a
|
|
84
|
+
* per-pixel decision, so nothing in here may call dFdx.
|
|
85
|
+
*/
|
|
86
|
+
export declare const terrainTextured = "\n#ifdef TERRAIN_TEXTURED\nstruct TerrainGrads { vec2 topX; vec2 topY; vec2 sideXX; vec2 sideXY; vec2 sideZX; vec2 sideZY; };\n\n// The large-scale sample is the same texture, T_MACRO times bigger.\n#define T_MACRO 8.0\n\n/**\n * One layer's three arrays at one projection, at two scales.\n *\n * A ground scan is millimetres per texel: a gravel tile shows its pebbles for a\n * few metres and is a flat average colour from fifty. So past the point where a\n * pixel covers a fifth of a tile, the same texture is sampled again T_MACRO times\n * larger, and its pebbles become patches, its cracks become streaks \u2014 the set's\n * character survives out to hundreds of metres instead of dissolving into a flat\n * colour, and picking a different set is visible from where people actually look\n * at terrain. The switch is by pixel footprint, so it is the same at any tile\n * size and any camera height. Each scale is skipped when its weight is zero.\n */\nvoid terrainTap(int L, vec2 uv, vec2 dx, vec2 dy, out vec4 c, out vec4 nh, out vec4 o){\n float layer = float(L);\n float fp = max(length(dx), length(dy));\n float m = smoothstep(0.04, 0.25, fp);\n vec4 cd = vec4(0.0);\n vec4 nd = vec4(0.0);\n vec4 od = vec4(0.0);\n vec4 cm = vec4(0.0);\n vec4 nm = vec4(0.0);\n vec4 om = vec4(0.0);\n if (m < 0.999){\n cd = sfSample(u_tColor, uv, dx, dy, layer, u_tMeanC[L]);\n nd = sfSample(u_tNormal, uv, dx, dy, layer, u_tMeanN[L]);\n od = sfSample(u_tOrm, uv, dx, dy, layer, u_tMeanO[L]);\n }\n if (m > 0.001){\n vec2 mu = uv / T_MACRO;\n vec2 mdx = dx / T_MACRO;\n vec2 mdy = dy / T_MACRO;\n cm = sfSample(u_tColor, mu, mdx, mdy, layer, u_tMeanC[L]);\n nm = sfSample(u_tNormal, mu, mdx, mdy, layer, u_tMeanN[L]);\n om = sfSample(u_tOrm, mu, mdx, mdy, layer, u_tMeanO[L]);\n // No height blending at the large scale. A height map blown up 8x has\n // tens-of-metres blobs, and blending layers along those contours paints\n // the ground in camouflage. Mid height = an ordinary cross-fade.\n nm.a = 0.5;\n }\n c = mix(cd, cm, m);\n nh = mix(nd, nm, m);\n o = mix(od, om, m);\n}\n\n/** One layer: albedo (tinted), an unnormalised world normal, surface height,\n * roughness and occlusion. An untextured layer returns its flat colour. */\nvoid terrainLayerSample(int L, vec3 wp, vec3 n, TerrainGrads g,\n out vec3 col, out vec3 wn, out float h, out float rough, out float ao){\n col = u_tFar[L];\n wn = n;\n h = 0.5;\n rough = u_roughness;\n ao = 1.0;\n if (u_tLayer[L].z > 0.5){\n float inv = u_tLayer[L].x;\n float ns = u_tLayer[L].y;\n vec4 c = vec4(0.0);\n vec4 nh = vec4(0.0);\n vec4 o = vec4(0.0);\n vec3 acc = vec3(0.0);\n if (L == 2){\n // Biplanar: the two strongest axes. The third adds a fraction of a percent\n // anywhere that is not an exact corner and costs a third of the fetches.\n vec3 an = abs(n);\n an = an * an * an;\n an /= max(an.x + an.y + an.z, 1e-4);\n float lo = min(an.x, min(an.y, an.z));\n vec3 bw = max(an - lo, 0.0);\n bw /= max(bw.x + bw.y + bw.z, 1e-4);\n vec4 c1, n1, o1;\n if (bw.y > 0.002){\n terrainTap(L, wp.xz * inv, g.topX * inv, g.topY * inv, c1, n1, o1);\n c += c1 * bw.y; nh += n1 * bw.y; o += o1 * bw.y;\n acc += sfWhiteoutTop(n, sfUnpackNormal(n1.rgb, ns)) * bw.y;\n }\n if (bw.x > 0.002){\n terrainTap(L, wp.zy * inv, g.sideXX * inv, g.sideXY * inv, c1, n1, o1);\n c += c1 * bw.x; nh += n1 * bw.x; o += o1 * bw.x;\n acc += sfWhiteoutX(n, sfUnpackNormal(n1.rgb, ns)) * bw.x;\n }\n if (bw.z > 0.002){\n terrainTap(L, wp.xy * inv, g.sideZX * inv, g.sideZY * inv, c1, n1, o1);\n c += c1 * bw.z; nh += n1 * bw.z; o += o1 * bw.z;\n acc += sfWhiteoutZ(n, sfUnpackNormal(n1.rgb, ns)) * bw.z;\n }\n } else {\n terrainTap(L, wp.xz * inv, g.topX * inv, g.topY * inv, c, nh, o);\n acc = sfWhiteoutTop(n, sfUnpackNormal(nh.rgb, ns));\n }\n col = c.rgb * u_tTint[L];\n wn = acc;\n h = nh.a;\n rough = o.g;\n ao = o.r;\n }\n}\n\n/** Near-field surface for weights w. Outputs albedo (no macro), normal,\n * roughness and occlusion. */\nvoid terrainSurfaceNear(vec3 wp, vec3 n, vec4 w, TerrainGrads g,\n out vec3 albedo, out vec3 nrm, out float rough, out float ao){\n float ws[4];\n ws[0] = w.x; ws[1] = w.y; ws[2] = w.z; ws[3] = w.w;\n int i0 = 0;\n float b0 = -1.0;\n for (int i = 0; i < 4; i++){ if (ws[i] > b0){ b0 = ws[i]; i0 = i; } }\n ws[i0] = -1.0;\n int i1 = 0;\n float b1 = -1.0;\n for (int i = 0; i < 4; i++){ if (ws[i] > b1){ b1 = ws[i]; i1 = i; } }\n b0 = max(b0, 0.0);\n b1 = max(b1, 0.0);\n float bs = max(b0 + b1, 1e-4);\n b0 /= bs;\n b1 /= bs;\n\n vec3 c0, n0, c1, n1;\n float h0, r0, a0, h1, r1, a1;\n terrainLayerSample(i0, wp, n, g, c0, n0, h0, r0, a0);\n if (b1 > 0.001){\n terrainLayerSample(i1, wp, n, g, c1, n1, h1, r1, a1);\n } else {\n c1 = c0; n1 = n0; h1 = h0; r1 = r0; a1 = a0;\n }\n\n // Height blend: the layer whose own surface is higher at this texel wins, so\n // gravel comes through grass along the gravel's grain and rock emerges from\n // soil along its cracks, instead of the two cross-fading into mud.\n float hb = u_tHeightBlend;\n float range = mix(1.0, 0.04, hb);\n float v0 = b0 + h0 * hb;\n float v1 = b1 + h1 * hb;\n float peak = max(v0, v1);\n float w0 = max(v0 - (peak - range), 0.0);\n float w1 = max(v1 - (peak - range), 0.0);\n if (b1 <= 0.001) w1 = 0.0;\n float ws2 = max(w0 + w1, 1e-4);\n w0 /= ws2;\n w1 /= ws2;\n\n albedo = c0 * w0 + c1 * w1;\n nrm = normalize(n0 * w0 + n1 * w1);\n rough = r0 * w0 + r1 * w1;\n ao = a0 * w0 + a1 * w1;\n}\n#endif\n";
|
|
74
87
|
/** Everything a surface material needs, in include order. Requires three's
|
|
75
88
|
* `<common>` and `skyLib` from cloudCore before it. */
|
|
76
89
|
export declare const terrainField: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terrainCore.glsl.d.ts","sourceRoot":"","sources":["../../../src/shaders/glsl/terrainCore.glsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,2DAA2D;AAC3D,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"terrainCore.glsl.d.ts","sourceRoot":"","sources":["../../../src/shaders/glsl/terrainCore.glsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,2DAA2D;AAC3D,eAAO,MAAM,eAAe,wpGA2E3B,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,uiCAiCxB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,mqbAiVzB,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,s0RAuL1B,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,4pLAyJ3B,CAAA;AAED;wDACwD;AACxD,eAAO,MAAM,YAAY,QAA4D,CAAA;AAErF,eAAO,MAAM,WAAW,QAA4C,CAAA"}
|
|
@@ -70,6 +70,38 @@ uniform float u_ambient, u_bounce, u_sunShadow, u_shadowSoftness;
|
|
|
70
70
|
uniform float u_shadowDistance;
|
|
71
71
|
uniform float u_fogDensity, u_exposure;
|
|
72
72
|
uniform int u_shadowSteps;
|
|
73
|
+
|
|
74
|
+
// Ground textures. The far colour per layer is always set: the flat colour for an
|
|
75
|
+
// untextured layer, the texture's own mean x tint for a textured one, so the
|
|
76
|
+
// near-to-far fade has no colour jump.
|
|
77
|
+
uniform vec3 u_tFar[4];
|
|
78
|
+
#ifdef TERRAIN_TEXTURED
|
|
79
|
+
uniform sampler2DArray u_tColor; // albedo, sRGB
|
|
80
|
+
uniform sampler2DArray u_tNormal; // rgb tangent normal (GL), a surface height
|
|
81
|
+
uniform sampler2DArray u_tOrm; // r ambient occlusion, g roughness
|
|
82
|
+
uniform vec4 u_tLayer[4]; // 1/tileSize, normalStrength, textured 0|1, -
|
|
83
|
+
uniform vec3 u_tTint[4]; // layer colour / texture mean: the texture averages to the layer colour
|
|
84
|
+
uniform vec4 u_tMeanC[4]; // per-array layer means, for the stochastic blend
|
|
85
|
+
uniform vec4 u_tMeanN[4];
|
|
86
|
+
uniform vec4 u_tMeanO[4];
|
|
87
|
+
uniform float u_tDistance;
|
|
88
|
+
uniform float u_tHeightBlend;
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
// A land object: a bounded patch of this field, placed by its object's transform.
|
|
92
|
+
// Its "terrain space" is metres from the object's origin, unrotated, plus a seed
|
|
93
|
+
// offset; height is above the object's base. See TerrainMaterial's patch vertex.
|
|
94
|
+
#ifdef TERRAIN_PATCH
|
|
95
|
+
uniform vec2 u_patchSize; // footprint in metres (object scale x / z)
|
|
96
|
+
uniform vec2 u_patchOffset; // terrain-space centre: the seed's offset into the field
|
|
97
|
+
uniform float u_edgeWidth; // metres over which the land eases down to its base
|
|
98
|
+
uniform vec3 u_camTerrain; // the camera, in terrain space
|
|
99
|
+
uniform float u_scaleY; // object scale y: terrain metres = local y x this
|
|
100
|
+
uniform float u_patchCell; // metres per grid cell
|
|
101
|
+
#define TERRAIN_CAM u_camTerrain
|
|
102
|
+
#else
|
|
103
|
+
#define TERRAIN_CAM cameraPosition
|
|
104
|
+
#endif
|
|
73
105
|
`;
|
|
74
106
|
/**
|
|
75
107
|
* Gradient noise with an analytic derivative.
|
|
@@ -427,6 +459,45 @@ float terrainHeightAt(vec2 p, float lodCell){
|
|
|
427
459
|
vec3 terrainNormal(vec2 grad){
|
|
428
460
|
return normalize(vec3(-grad.x, 1.0, -grad.y));
|
|
429
461
|
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* The surface as drawn. For the environment terrain it is the field itself; for a
|
|
465
|
+
* land object the field is eased down to the base across the edge band, so the
|
|
466
|
+
* patch meets whatever it stands on instead of ending in a cliff. The mask is
|
|
467
|
+
* applied to the height AND its gradient (product rule), so normals, slope rock
|
|
468
|
+
* and the shadow march all see the same eased surface the vertices do.
|
|
469
|
+
*/
|
|
470
|
+
#ifdef TERRAIN_PATCH
|
|
471
|
+
float terrainPatchMask(vec2 p, out vec2 dmask){
|
|
472
|
+
vec2 l = (p - u_patchOffset) / u_patchSize; // -0.5 .. 0.5 inside
|
|
473
|
+
vec2 d = (0.5 - abs(l)) * u_patchSize; // metres to each pair of edges
|
|
474
|
+
vec2 sgn = vec2(l.x < 0.0 ? 1.0 : -1.0, l.y < 0.0 ? 1.0 : -1.0);
|
|
475
|
+
float dist = min(d.x, d.y);
|
|
476
|
+
vec2 ddist = d.x < d.y ? vec2(sgn.x, 0.0) : vec2(0.0, sgn.y);
|
|
477
|
+
if (dist <= 0.0){ dmask = vec2(0.0); return 0.0; }
|
|
478
|
+
if (u_edgeWidth <= 1e-3){ dmask = vec2(0.0); return 1.0; }
|
|
479
|
+
float x = clamp(dist / u_edgeWidth, 0.0, 1.0);
|
|
480
|
+
dmask = ddist * (6.0 * x * (1.0 - x) / u_edgeWidth);
|
|
481
|
+
return x * x * (3.0 - 2.0 * x);
|
|
482
|
+
}
|
|
483
|
+
float terrainSurfaceAt(vec2 p, float lodCell, out vec2 grad){
|
|
484
|
+
vec2 g;
|
|
485
|
+
float h = terrainSample(p, lodCell, g) - u_seaLevel;
|
|
486
|
+
vec2 dm;
|
|
487
|
+
float m = terrainPatchMask(p, dm);
|
|
488
|
+
grad = g * m + h * dm;
|
|
489
|
+
return u_seaLevel + h * m;
|
|
490
|
+
}
|
|
491
|
+
float terrainOccluderAt(vec2 p, float lodCell){
|
|
492
|
+
vec2 dm;
|
|
493
|
+
float m = terrainPatchMask(p, dm);
|
|
494
|
+
if (m <= 0.0) return u_seaLevel;
|
|
495
|
+
return u_seaLevel + (terrainHeightAt(p, lodCell) - u_seaLevel) * m;
|
|
496
|
+
}
|
|
497
|
+
#else
|
|
498
|
+
float terrainSurfaceAt(vec2 p, float lodCell, out vec2 grad){ return terrainSample(p, lodCell, grad); }
|
|
499
|
+
float terrainOccluderAt(vec2 p, float lodCell){ return terrainHeightAt(p, lodCell); }
|
|
500
|
+
#endif
|
|
430
501
|
`;
|
|
431
502
|
/**
|
|
432
503
|
* Shading: the analytic self-shadow, the splat, and the light.
|
|
@@ -481,7 +552,7 @@ float terrainSunShadow(vec3 p, vec3 n, float lodCell, int steps){
|
|
|
481
552
|
// fine field costs the same nine octaves per step for detail that is below a
|
|
482
553
|
// pixel by the time it lands. Floored against the landform's own size, so the
|
|
483
554
|
// march runs about five octaves instead of nine wherever it starts.
|
|
484
|
-
float h =
|
|
555
|
+
float h = terrainOccluderAt(sp.xz, max(max(lodCell * 2.0, t * 0.06), shadowLod));
|
|
485
556
|
float diff = sp.y - h;
|
|
486
557
|
res = min(res, u_shadowSoftness * diff / t);
|
|
487
558
|
if (res <= 0.0) return 0.0;
|
|
@@ -522,23 +593,30 @@ float terrainShadowAt(vec3 p, vec3 n, float lodCell, float dist){
|
|
|
522
593
|
* summit, which is how real ground works and why height-only splatting always
|
|
523
594
|
* reads as a painted contour map.
|
|
524
595
|
*/
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
596
|
+
/**
|
|
597
|
+
* Splat weights for the four layers, in layer order: low, mid, rock, peak.
|
|
598
|
+
* Exactly the old colour mixes written as weights — low/mid by height, the peak
|
|
599
|
+
* held back on steep ground (snow does not sit on a vertical face), rock by slope
|
|
600
|
+
* and applied last, which is why a cliff reads as a cliff at any altitude.
|
|
601
|
+
*/
|
|
602
|
+
vec4 terrainLayerWeights(float h01, float slope){
|
|
603
|
+
float m = smoothstep(0.05, 0.55, h01);
|
|
604
|
+
float p = saturate(smoothstep(u_peakLevel, u_peakLevel + u_peakBlend, h01 - slope * u_peakSlopeFalloff * 0.6));
|
|
605
|
+
float r = smoothstep(u_slopeRockStart, u_slopeRockEnd, slope);
|
|
606
|
+
return vec4((1.0 - m) * (1.0 - p) * (1.0 - r), m * (1.0 - p) * (1.0 - r), r, p * (1.0 - r));
|
|
607
|
+
}
|
|
537
608
|
|
|
538
|
-
|
|
539
|
-
|
|
609
|
+
/** Large-scale variation. Without it a splat layer is one flat colour across
|
|
610
|
+
* kilometres, and the eye reads flat colour as untextured rather than as ground. */
|
|
611
|
+
float terrainMacro(vec3 wp){
|
|
612
|
+
float macro = tNoise(wp.xz * u_macroScale) * 0.5 + 0.5;
|
|
613
|
+
return 1.0 + u_macroVariation * (macro - 0.5) * 2.0;
|
|
614
|
+
}
|
|
540
615
|
|
|
541
|
-
|
|
616
|
+
/** The far-field albedo: each layer's far colour by its weight. */
|
|
617
|
+
vec3 terrainAlbedo(vec3 wp, vec4 w){
|
|
618
|
+
vec3 col = u_tFar[0] * w.x + u_tFar[1] * w.y + u_tFar[2] * w.z + u_tFar[3] * w.w;
|
|
619
|
+
return col * terrainMacro(wp);
|
|
542
620
|
}
|
|
543
621
|
|
|
544
622
|
/** High-frequency bump, well below the mesh resolution, faded out with distance
|
|
@@ -563,7 +641,7 @@ vec3 terrainDetailNormal(vec3 n, vec3 wp, float dist){
|
|
|
563
641
|
*/
|
|
564
642
|
const float TERRAIN_SUN = 2.2;
|
|
565
643
|
|
|
566
|
-
vec3 terrainLight(vec3 albedo, vec3 n, vec3 viewDir, float shadow, float sceneShadow){
|
|
644
|
+
vec3 terrainLight(vec3 albedo, vec3 n, vec3 viewDir, float shadow, float sceneShadow, float roughness, float ao){
|
|
567
645
|
float ndl = max(dot(n, u_sunDir), 0.0);
|
|
568
646
|
// Wrap the terminator slightly: bare ground is not a Lambertian sphere, and a
|
|
569
647
|
// hard terminator across a whole hillside reads as CG.
|
|
@@ -582,15 +660,17 @@ vec3 terrainLight(vec3 albedo, vec3 n, vec3 viewDir, float shadow, float sceneSh
|
|
|
582
660
|
|
|
583
661
|
// Ground bounce, tinted by whatever the ground is. Keeps overhangs and shaded
|
|
584
662
|
// faces off pure black without flattening them the way raising ambient does.
|
|
585
|
-
vec3 bounce =
|
|
663
|
+
vec3 bounce = u_tFar[0] * u_groundAmbient * (0.5 - 0.5 * n.y) * u_bounce * 1.3;
|
|
586
664
|
|
|
587
|
-
|
|
665
|
+
// Occlusion is a property of the small-scale surface, so it darkens the light
|
|
666
|
+
// that arrives from everywhere — sky fill and bounce — and leaves the sun alone.
|
|
667
|
+
vec3 col = albedo * (sun + (ambient + bounce) * ao);
|
|
588
668
|
|
|
589
669
|
// A single specular lobe. Rock barely needs it; wet sand and snow at low sun
|
|
590
670
|
// are almost entirely this.
|
|
591
671
|
if (u_specular > 0.0){
|
|
592
672
|
vec3 hv = normalize(u_sunDir - viewDir);
|
|
593
|
-
float a = max(
|
|
673
|
+
float a = max(roughness * roughness, 0.002);
|
|
594
674
|
float nh = max(dot(n, hv), 0.0);
|
|
595
675
|
float dd = nh * nh * (a - 1.0) + 1.0;
|
|
596
676
|
float d = a / max(3.14159265 * dd * dd, 1e-4);
|
|
@@ -619,6 +699,172 @@ vec3 terrainAerial(vec3 col, vec3 rd, float dist, float height){
|
|
|
619
699
|
return mix(col, skyRadiance(rd), saturate(f));
|
|
620
700
|
}
|
|
621
701
|
`;
|
|
702
|
+
/**
|
|
703
|
+
* The textured near field. Needs `surfaceSampling` (surfaceCore.glsl) before it.
|
|
704
|
+
*
|
|
705
|
+
* Only the two heaviest layers are sampled per pixel. Two layers overlap almost
|
|
706
|
+
* everywhere a boundary is; three meet only at triple points, and halving the
|
|
707
|
+
* fetches is worth a slightly harder edge there. The rock layer is projected
|
|
708
|
+
* biplanar — it is the only one that ever sits on a steep face — and the other
|
|
709
|
+
* three straight down.
|
|
710
|
+
*
|
|
711
|
+
* Gradients come in from main (see sfSample): which layer a pixel samples is a
|
|
712
|
+
* per-pixel decision, so nothing in here may call dFdx.
|
|
713
|
+
*/
|
|
714
|
+
export const terrainTextured = /* glsl */ `
|
|
715
|
+
#ifdef TERRAIN_TEXTURED
|
|
716
|
+
struct TerrainGrads { vec2 topX; vec2 topY; vec2 sideXX; vec2 sideXY; vec2 sideZX; vec2 sideZY; };
|
|
717
|
+
|
|
718
|
+
// The large-scale sample is the same texture, T_MACRO times bigger.
|
|
719
|
+
#define T_MACRO 8.0
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* One layer's three arrays at one projection, at two scales.
|
|
723
|
+
*
|
|
724
|
+
* A ground scan is millimetres per texel: a gravel tile shows its pebbles for a
|
|
725
|
+
* few metres and is a flat average colour from fifty. So past the point where a
|
|
726
|
+
* pixel covers a fifth of a tile, the same texture is sampled again T_MACRO times
|
|
727
|
+
* larger, and its pebbles become patches, its cracks become streaks — the set's
|
|
728
|
+
* character survives out to hundreds of metres instead of dissolving into a flat
|
|
729
|
+
* colour, and picking a different set is visible from where people actually look
|
|
730
|
+
* at terrain. The switch is by pixel footprint, so it is the same at any tile
|
|
731
|
+
* size and any camera height. Each scale is skipped when its weight is zero.
|
|
732
|
+
*/
|
|
733
|
+
void terrainTap(int L, vec2 uv, vec2 dx, vec2 dy, out vec4 c, out vec4 nh, out vec4 o){
|
|
734
|
+
float layer = float(L);
|
|
735
|
+
float fp = max(length(dx), length(dy));
|
|
736
|
+
float m = smoothstep(0.04, 0.25, fp);
|
|
737
|
+
vec4 cd = vec4(0.0);
|
|
738
|
+
vec4 nd = vec4(0.0);
|
|
739
|
+
vec4 od = vec4(0.0);
|
|
740
|
+
vec4 cm = vec4(0.0);
|
|
741
|
+
vec4 nm = vec4(0.0);
|
|
742
|
+
vec4 om = vec4(0.0);
|
|
743
|
+
if (m < 0.999){
|
|
744
|
+
cd = sfSample(u_tColor, uv, dx, dy, layer, u_tMeanC[L]);
|
|
745
|
+
nd = sfSample(u_tNormal, uv, dx, dy, layer, u_tMeanN[L]);
|
|
746
|
+
od = sfSample(u_tOrm, uv, dx, dy, layer, u_tMeanO[L]);
|
|
747
|
+
}
|
|
748
|
+
if (m > 0.001){
|
|
749
|
+
vec2 mu = uv / T_MACRO;
|
|
750
|
+
vec2 mdx = dx / T_MACRO;
|
|
751
|
+
vec2 mdy = dy / T_MACRO;
|
|
752
|
+
cm = sfSample(u_tColor, mu, mdx, mdy, layer, u_tMeanC[L]);
|
|
753
|
+
nm = sfSample(u_tNormal, mu, mdx, mdy, layer, u_tMeanN[L]);
|
|
754
|
+
om = sfSample(u_tOrm, mu, mdx, mdy, layer, u_tMeanO[L]);
|
|
755
|
+
// No height blending at the large scale. A height map blown up 8x has
|
|
756
|
+
// tens-of-metres blobs, and blending layers along those contours paints
|
|
757
|
+
// the ground in camouflage. Mid height = an ordinary cross-fade.
|
|
758
|
+
nm.a = 0.5;
|
|
759
|
+
}
|
|
760
|
+
c = mix(cd, cm, m);
|
|
761
|
+
nh = mix(nd, nm, m);
|
|
762
|
+
o = mix(od, om, m);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/** One layer: albedo (tinted), an unnormalised world normal, surface height,
|
|
766
|
+
* roughness and occlusion. An untextured layer returns its flat colour. */
|
|
767
|
+
void terrainLayerSample(int L, vec3 wp, vec3 n, TerrainGrads g,
|
|
768
|
+
out vec3 col, out vec3 wn, out float h, out float rough, out float ao){
|
|
769
|
+
col = u_tFar[L];
|
|
770
|
+
wn = n;
|
|
771
|
+
h = 0.5;
|
|
772
|
+
rough = u_roughness;
|
|
773
|
+
ao = 1.0;
|
|
774
|
+
if (u_tLayer[L].z > 0.5){
|
|
775
|
+
float inv = u_tLayer[L].x;
|
|
776
|
+
float ns = u_tLayer[L].y;
|
|
777
|
+
vec4 c = vec4(0.0);
|
|
778
|
+
vec4 nh = vec4(0.0);
|
|
779
|
+
vec4 o = vec4(0.0);
|
|
780
|
+
vec3 acc = vec3(0.0);
|
|
781
|
+
if (L == 2){
|
|
782
|
+
// Biplanar: the two strongest axes. The third adds a fraction of a percent
|
|
783
|
+
// anywhere that is not an exact corner and costs a third of the fetches.
|
|
784
|
+
vec3 an = abs(n);
|
|
785
|
+
an = an * an * an;
|
|
786
|
+
an /= max(an.x + an.y + an.z, 1e-4);
|
|
787
|
+
float lo = min(an.x, min(an.y, an.z));
|
|
788
|
+
vec3 bw = max(an - lo, 0.0);
|
|
789
|
+
bw /= max(bw.x + bw.y + bw.z, 1e-4);
|
|
790
|
+
vec4 c1, n1, o1;
|
|
791
|
+
if (bw.y > 0.002){
|
|
792
|
+
terrainTap(L, wp.xz * inv, g.topX * inv, g.topY * inv, c1, n1, o1);
|
|
793
|
+
c += c1 * bw.y; nh += n1 * bw.y; o += o1 * bw.y;
|
|
794
|
+
acc += sfWhiteoutTop(n, sfUnpackNormal(n1.rgb, ns)) * bw.y;
|
|
795
|
+
}
|
|
796
|
+
if (bw.x > 0.002){
|
|
797
|
+
terrainTap(L, wp.zy * inv, g.sideXX * inv, g.sideXY * inv, c1, n1, o1);
|
|
798
|
+
c += c1 * bw.x; nh += n1 * bw.x; o += o1 * bw.x;
|
|
799
|
+
acc += sfWhiteoutX(n, sfUnpackNormal(n1.rgb, ns)) * bw.x;
|
|
800
|
+
}
|
|
801
|
+
if (bw.z > 0.002){
|
|
802
|
+
terrainTap(L, wp.xy * inv, g.sideZX * inv, g.sideZY * inv, c1, n1, o1);
|
|
803
|
+
c += c1 * bw.z; nh += n1 * bw.z; o += o1 * bw.z;
|
|
804
|
+
acc += sfWhiteoutZ(n, sfUnpackNormal(n1.rgb, ns)) * bw.z;
|
|
805
|
+
}
|
|
806
|
+
} else {
|
|
807
|
+
terrainTap(L, wp.xz * inv, g.topX * inv, g.topY * inv, c, nh, o);
|
|
808
|
+
acc = sfWhiteoutTop(n, sfUnpackNormal(nh.rgb, ns));
|
|
809
|
+
}
|
|
810
|
+
col = c.rgb * u_tTint[L];
|
|
811
|
+
wn = acc;
|
|
812
|
+
h = nh.a;
|
|
813
|
+
rough = o.g;
|
|
814
|
+
ao = o.r;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/** Near-field surface for weights w. Outputs albedo (no macro), normal,
|
|
819
|
+
* roughness and occlusion. */
|
|
820
|
+
void terrainSurfaceNear(vec3 wp, vec3 n, vec4 w, TerrainGrads g,
|
|
821
|
+
out vec3 albedo, out vec3 nrm, out float rough, out float ao){
|
|
822
|
+
float ws[4];
|
|
823
|
+
ws[0] = w.x; ws[1] = w.y; ws[2] = w.z; ws[3] = w.w;
|
|
824
|
+
int i0 = 0;
|
|
825
|
+
float b0 = -1.0;
|
|
826
|
+
for (int i = 0; i < 4; i++){ if (ws[i] > b0){ b0 = ws[i]; i0 = i; } }
|
|
827
|
+
ws[i0] = -1.0;
|
|
828
|
+
int i1 = 0;
|
|
829
|
+
float b1 = -1.0;
|
|
830
|
+
for (int i = 0; i < 4; i++){ if (ws[i] > b1){ b1 = ws[i]; i1 = i; } }
|
|
831
|
+
b0 = max(b0, 0.0);
|
|
832
|
+
b1 = max(b1, 0.0);
|
|
833
|
+
float bs = max(b0 + b1, 1e-4);
|
|
834
|
+
b0 /= bs;
|
|
835
|
+
b1 /= bs;
|
|
836
|
+
|
|
837
|
+
vec3 c0, n0, c1, n1;
|
|
838
|
+
float h0, r0, a0, h1, r1, a1;
|
|
839
|
+
terrainLayerSample(i0, wp, n, g, c0, n0, h0, r0, a0);
|
|
840
|
+
if (b1 > 0.001){
|
|
841
|
+
terrainLayerSample(i1, wp, n, g, c1, n1, h1, r1, a1);
|
|
842
|
+
} else {
|
|
843
|
+
c1 = c0; n1 = n0; h1 = h0; r1 = r0; a1 = a0;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// Height blend: the layer whose own surface is higher at this texel wins, so
|
|
847
|
+
// gravel comes through grass along the gravel's grain and rock emerges from
|
|
848
|
+
// soil along its cracks, instead of the two cross-fading into mud.
|
|
849
|
+
float hb = u_tHeightBlend;
|
|
850
|
+
float range = mix(1.0, 0.04, hb);
|
|
851
|
+
float v0 = b0 + h0 * hb;
|
|
852
|
+
float v1 = b1 + h1 * hb;
|
|
853
|
+
float peak = max(v0, v1);
|
|
854
|
+
float w0 = max(v0 - (peak - range), 0.0);
|
|
855
|
+
float w1 = max(v1 - (peak - range), 0.0);
|
|
856
|
+
if (b1 <= 0.001) w1 = 0.0;
|
|
857
|
+
float ws2 = max(w0 + w1, 1e-4);
|
|
858
|
+
w0 /= ws2;
|
|
859
|
+
w1 /= ws2;
|
|
860
|
+
|
|
861
|
+
albedo = c0 * w0 + c1 * w1;
|
|
862
|
+
nrm = normalize(n0 * w0 + n1 * w1);
|
|
863
|
+
rough = r0 * w0 + r1 * w1;
|
|
864
|
+
ao = a0 * w0 + a1 * w1;
|
|
865
|
+
}
|
|
866
|
+
#endif
|
|
867
|
+
`;
|
|
622
868
|
/** Everything a surface material needs, in include order. Requires three's
|
|
623
869
|
* `<common>` and `skyLib` from cloudCore before it. */
|
|
624
870
|
export const terrainField = [terrainUniforms, terrainNoise, terrainHeight].join('\n');
|
|
@@ -41,6 +41,8 @@ export declare const oceanMaterialDefaults: {
|
|
|
41
41
|
u_skyAmbient: THREE.Color;
|
|
42
42
|
u_groundAmbient: THREE.Color;
|
|
43
43
|
u_sunIntensity: number;
|
|
44
|
+
u_moonDir: THREE.Vector3;
|
|
45
|
+
u_moonColor: THREE.Color;
|
|
44
46
|
u_turbidity: number;
|
|
45
47
|
u_rayleigh: number;
|
|
46
48
|
u_mieCoefficient: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OceanSurfaceMaterial.d.ts","sourceRoot":"","sources":["../../../src/shaders/ocean/OceanSurfaceMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAmM9D,MAAM,WAAW,qBAAqB;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAA;CAChC;AAMD;yEACyE;AACzE,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"OceanSurfaceMaterial.d.ts","sourceRoot":"","sources":["../../../src/shaders/ocean/OceanSurfaceMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAmM9D,MAAM,WAAW,qBAAqB;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAA;CAChC;AAMD;yEACyE;AACzE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDjC,CAAA;AAgBD,qBAAa,oBAAqB,SAAQ,KAAK,CAAC,cAAc;;CAa7D;AAID,OAAO,QAAQ,oBAAoB,CAAC;IAChC,UAAU,aAAa;QACnB,oBAAoB,EAAE,YAAY,CAAC,OAAO,oBAAoB,CAAC,CAAA;KAClE;CACJ"}
|
|
@@ -233,6 +233,9 @@ export const oceanMaterialDefaults = {
|
|
|
233
233
|
u_skyAmbient: new THREE.Color(0.6, 0.9, 1.6),
|
|
234
234
|
u_groundAmbient: new THREE.Color(0.45, 0.42, 0.37),
|
|
235
235
|
u_sunIntensity: 1,
|
|
236
|
+
// Moonlight, set by useOceanMaterial; black = no moon.
|
|
237
|
+
u_moonDir: new THREE.Vector3(0, 1, 0),
|
|
238
|
+
u_moonColor: new THREE.Color(0, 0, 0),
|
|
236
239
|
u_turbidity: 2,
|
|
237
240
|
u_rayleigh: 1,
|
|
238
241
|
u_mieCoefficient: 0.005,
|
|
@@ -27,6 +27,12 @@ export declare const terrainMaterialDefaults: {
|
|
|
27
27
|
u_valleyWidth: number;
|
|
28
28
|
u_cellSize: number;
|
|
29
29
|
u_curvature: number;
|
|
30
|
+
u_patchSize: THREE.Vector2;
|
|
31
|
+
u_patchOffset: THREE.Vector2;
|
|
32
|
+
u_edgeWidth: number;
|
|
33
|
+
u_camTerrain: THREE.Vector3;
|
|
34
|
+
u_scaleY: number;
|
|
35
|
+
u_patchCell: number;
|
|
30
36
|
u_lowColor: THREE.Color;
|
|
31
37
|
u_midColor: THREE.Color;
|
|
32
38
|
u_rockColor: THREE.Color;
|
|
@@ -43,6 +49,17 @@ export declare const terrainMaterialDefaults: {
|
|
|
43
49
|
u_detailFade: number;
|
|
44
50
|
u_roughness: number;
|
|
45
51
|
u_specular: number;
|
|
52
|
+
u_tFar: THREE.Color[];
|
|
53
|
+
u_tColor: THREE.DataArrayTexture | null;
|
|
54
|
+
u_tNormal: THREE.DataArrayTexture | null;
|
|
55
|
+
u_tOrm: THREE.DataArrayTexture | null;
|
|
56
|
+
u_tLayer: THREE.Vector4[];
|
|
57
|
+
u_tTint: THREE.Color[];
|
|
58
|
+
u_tMeanC: THREE.Vector4[];
|
|
59
|
+
u_tMeanN: THREE.Vector4[];
|
|
60
|
+
u_tMeanO: THREE.Vector4[];
|
|
61
|
+
u_tDistance: number;
|
|
62
|
+
u_tHeightBlend: number;
|
|
46
63
|
u_ambient: number;
|
|
47
64
|
u_bounce: number;
|
|
48
65
|
u_sunShadow: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerrainMaterial.d.ts","sourceRoot":"","sources":["../../../src/shaders/terrain/TerrainMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"TerrainMaterial.d.ts","sourceRoot":"","sources":["../../../src/shaders/terrain/TerrainMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAiR9D,MAAM,WAAW,uBAAuB;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAA;CAChC;AAED;yEACyE;AACzE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqDd,KAAK,CAAC,gBAAgB,GAAG,IAAI;eAC5B,KAAK,CAAC,gBAAgB,GAAG,IAAI;YAChC,KAAK,CAAC,gBAAgB,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BhD,CAAA;AAqBD;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,KAAK,CAAC,cAAc;;CAWxD;AAID,OAAO,QAAQ,oBAAoB,CAAC;IAChC,UAAU,aAAa;QACnB,eAAe,EAAE,YAAY,CAAC,OAAO,eAAe,CAAC,CAAA;KACxD;CACJ"}
|