@3driseai/3drise-viewer 0.1.41 → 0.1.43
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/ClipsRuntime.d.ts +16 -1
- package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -1
- package/dist/animationsV2/ClipsRuntime.js +144 -25
- package/dist/animationsV2/appliers.d.ts +9 -0
- package/dist/animationsV2/appliers.d.ts.map +1 -1
- package/dist/animationsV2/appliers.js +62 -2
- package/dist/animationsV2/clipUtils.d.ts +30 -0
- package/dist/animationsV2/clipUtils.d.ts.map +1 -1
- package/dist/animationsV2/clipUtils.js +163 -17
- package/dist/animationsV2/elementSettings.d.ts +5 -0
- package/dist/animationsV2/elementSettings.d.ts.map +1 -1
- package/dist/animationsV2/elementSettings.js +6 -3
- package/dist/animationsV2/sequenceUtils.js +4 -4
- package/dist/animationsV2/types.d.ts +23 -0
- package/dist/animationsV2/types.d.ts.map +1 -1
- package/dist/api/sceneHandle.js +2 -2
- package/dist/components/CreatedObject.d.ts +3 -0
- package/dist/components/CreatedObject.d.ts.map +1 -1
- package/dist/components/CreatedObject.js +6 -2
- package/dist/components/CustomPrimitive.d.ts.map +1 -1
- package/dist/components/CustomPrimitive.js +1 -10
- package/dist/components/EnvironmentManager.d.ts.map +1 -1
- package/dist/components/EnvironmentManager.js +11 -5
- package/dist/components/GeometryShape.d.ts +5 -2
- package/dist/components/GeometryShape.d.ts.map +1 -1
- package/dist/components/GeometryShape.js +71 -10
- package/dist/components/LandObject.d.ts.map +1 -1
- package/dist/components/LandObject.js +1 -1
- package/dist/components/LayoutInstances.d.ts +2 -1
- package/dist/components/LayoutInstances.d.ts.map +1 -1
- package/dist/components/LayoutInstances.js +39 -6
- package/dist/components/LightObject.d.ts.map +1 -1
- package/dist/components/LightObject.js +3 -0
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +62 -13
- package/dist/components/OceanBuilder.d.ts +2 -0
- package/dist/components/OceanBuilder.d.ts.map +1 -1
- package/dist/components/OceanBuilder.js +2 -1
- package/dist/components/RenderEffects.d.ts +8 -0
- package/dist/components/RenderEffects.d.ts.map +1 -0
- package/dist/components/RenderEffects.js +120 -0
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SceneBuilder.js +18 -9
- package/dist/components/SportsObject.d.ts +9 -0
- package/dist/components/SportsObject.d.ts.map +1 -0
- package/dist/components/SportsObject.js +20 -0
- package/dist/components/UrbanObject.d.ts +9 -0
- package/dist/components/UrbanObject.d.ts.map +1 -0
- package/dist/components/UrbanObject.js +28 -0
- package/dist/components/VegetationObject.d.ts +9 -0
- package/dist/components/VegetationObject.d.ts.map +1 -0
- package/dist/components/VegetationObject.js +26 -0
- package/dist/components/WaterObject.d.ts +15 -0
- package/dist/components/WaterObject.d.ts.map +1 -0
- package/dist/components/WaterObject.js +29 -0
- package/dist/components/index.d.ts +7 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -1
- package/dist/components/land/LandPatch.d.ts +3 -1
- package/dist/components/land/LandPatch.d.ts.map +1 -1
- package/dist/components/land/LandPatch.js +80 -7
- package/dist/components/layout/InstancedLayout.d.ts +19 -0
- package/dist/components/layout/InstancedLayout.d.ts.map +1 -0
- package/dist/components/layout/InstancedLayout.js +154 -0
- package/dist/components/layout/LayoutGrounds.d.ts +19 -0
- package/dist/components/layout/LayoutGrounds.d.ts.map +1 -0
- package/dist/components/layout/LayoutGrounds.js +104 -0
- package/dist/components/layout/LinkProxies.d.ts +5 -0
- package/dist/components/layout/LinkProxies.d.ts.map +1 -0
- package/dist/components/layout/LinkProxies.js +51 -0
- package/dist/components/layout/LinkedSource.d.ts +14 -0
- package/dist/components/layout/LinkedSource.d.ts.map +1 -0
- package/dist/components/layout/LinkedSource.js +129 -0
- package/dist/components/projector/Projector.d.ts +14 -0
- package/dist/components/projector/Projector.d.ts.map +1 -0
- package/dist/components/projector/Projector.js +44 -0
- package/dist/components/projector/index.d.ts +4 -0
- package/dist/components/projector/index.d.ts.map +1 -0
- package/dist/components/projector/index.js +2 -0
- package/dist/components/projector/projectorCore.d.ts +19 -0
- package/dist/components/projector/projectorCore.d.ts.map +1 -0
- package/dist/components/projector/projectorCore.js +545 -0
- package/dist/components/sports/SportsBall.d.ts +9 -0
- package/dist/components/sports/SportsBall.d.ts.map +1 -0
- package/dist/components/sports/SportsBall.js +23 -0
- package/dist/components/sports/SportsCourt.d.ts +9 -0
- package/dist/components/sports/SportsCourt.d.ts.map +1 -0
- package/dist/components/sports/SportsCourt.js +23 -0
- package/dist/components/sports/SportsEquipment.d.ts +9 -0
- package/dist/components/sports/SportsEquipment.d.ts.map +1 -0
- package/dist/components/sports/SportsEquipment.js +23 -0
- package/dist/components/sports/SportsGoal.d.ts +9 -0
- package/dist/components/sports/SportsGoal.d.ts.map +1 -0
- package/dist/components/sports/SportsGoal.js +23 -0
- package/dist/components/sports/core/ball.d.ts +166 -0
- package/dist/components/sports/core/ball.d.ts.map +1 -0
- package/dist/components/sports/core/ball.js +402 -0
- package/dist/components/sports/core/court.d.ts +442 -0
- package/dist/components/sports/core/court.d.ts.map +1 -0
- package/dist/components/sports/core/court.js +658 -0
- package/dist/components/sports/core/equipment.d.ts +103 -0
- package/dist/components/sports/core/equipment.d.ts.map +1 -0
- package/dist/components/sports/core/equipment.js +403 -0
- package/dist/components/sports/core/goal.d.ts +98 -0
- package/dist/components/sports/core/goal.d.ts.map +1 -0
- package/dist/components/sports/core/goal.js +44 -0
- package/dist/components/sports/index.d.ts +11 -0
- package/dist/components/sports/index.d.ts.map +1 -0
- package/dist/components/sports/index.js +8 -0
- package/dist/components/sports/sportsCore.d.ts +195 -0
- package/dist/components/sports/sportsCore.d.ts.map +1 -0
- package/dist/components/sports/sportsCore.js +758 -0
- package/dist/components/sports/useSportsInstance.d.ts +35 -0
- package/dist/components/sports/useSportsInstance.d.ts.map +1 -0
- package/dist/components/sports/useSportsInstance.js +47 -0
- package/dist/components/terrain/TerrainSurface.d.ts.map +1 -1
- package/dist/components/terrain/TerrainSurface.js +14 -0
- package/dist/components/urban/UrbanBlock.d.ts +9 -0
- package/dist/components/urban/UrbanBlock.d.ts.map +1 -0
- package/dist/components/urban/UrbanBlock.js +23 -0
- package/dist/components/urban/UrbanBuilding.d.ts +9 -0
- package/dist/components/urban/UrbanBuilding.d.ts.map +1 -0
- package/dist/components/urban/UrbanBuilding.js +23 -0
- package/dist/components/urban/UrbanJunction.d.ts +9 -0
- package/dist/components/urban/UrbanJunction.d.ts.map +1 -0
- package/dist/components/urban/UrbanJunction.js +23 -0
- package/dist/components/urban/UrbanPark.d.ts +9 -0
- package/dist/components/urban/UrbanPark.d.ts.map +1 -0
- package/dist/components/urban/UrbanPark.js +23 -0
- package/dist/components/urban/UrbanParkingLot.d.ts +9 -0
- package/dist/components/urban/UrbanParkingLot.d.ts.map +1 -0
- package/dist/components/urban/UrbanParkingLot.js +23 -0
- package/dist/components/urban/UrbanPlaza.d.ts +9 -0
- package/dist/components/urban/UrbanPlaza.d.ts.map +1 -0
- package/dist/components/urban/UrbanPlaza.js +23 -0
- package/dist/components/urban/UrbanRoad.d.ts +9 -0
- package/dist/components/urban/UrbanRoad.d.ts.map +1 -0
- package/dist/components/urban/UrbanRoad.js +23 -0
- package/dist/components/urban/UrbanSignage.d.ts +9 -0
- package/dist/components/urban/UrbanSignage.d.ts.map +1 -0
- package/dist/components/urban/UrbanSignage.js +23 -0
- package/dist/components/urban/UrbanSkyline.d.ts +9 -0
- package/dist/components/urban/UrbanSkyline.d.ts.map +1 -0
- package/dist/components/urban/UrbanSkyline.js +23 -0
- package/dist/components/urban/UrbanStreetFurniture.d.ts +9 -0
- package/dist/components/urban/UrbanStreetFurniture.d.ts.map +1 -0
- package/dist/components/urban/UrbanStreetFurniture.js +23 -0
- package/dist/components/urban/UrbanStreetGrid.d.ts +9 -0
- package/dist/components/urban/UrbanStreetGrid.d.ts.map +1 -0
- package/dist/components/urban/UrbanStreetGrid.js +34 -0
- package/dist/components/urban/UrbanTraffic.d.ts +9 -0
- package/dist/components/urban/UrbanTraffic.d.ts.map +1 -0
- package/dist/components/urban/UrbanTraffic.js +23 -0
- package/dist/components/urban/core/block.d.ts +119 -0
- package/dist/components/urban/core/block.d.ts.map +1 -0
- package/dist/components/urban/core/block.js +266 -0
- package/dist/components/urban/core/building.d.ts +128 -0
- package/dist/components/urban/core/building.d.ts.map +1 -0
- package/dist/components/urban/core/building.js +741 -0
- package/dist/components/urban/core/junction.d.ts +152 -0
- package/dist/components/urban/core/junction.d.ts.map +1 -0
- package/dist/components/urban/core/junction.js +617 -0
- package/dist/components/urban/core/park.d.ts +67 -0
- package/dist/components/urban/core/park.d.ts.map +1 -0
- package/dist/components/urban/core/park.js +176 -0
- package/dist/components/urban/core/parkingLot.d.ts +82 -0
- package/dist/components/urban/core/parkingLot.d.ts.map +1 -0
- package/dist/components/urban/core/parkingLot.js +284 -0
- package/dist/components/urban/core/plaza.d.ts +24 -0
- package/dist/components/urban/core/plaza.d.ts.map +1 -0
- package/dist/components/urban/core/plaza.js +243 -0
- package/dist/components/urban/core/road.d.ts +113 -0
- package/dist/components/urban/core/road.d.ts.map +1 -0
- package/dist/components/urban/core/road.js +347 -0
- package/dist/components/urban/core/signage.d.ts +83 -0
- package/dist/components/urban/core/signage.d.ts.map +1 -0
- package/dist/components/urban/core/signage.js +209 -0
- package/dist/components/urban/core/skyline.d.ts +100 -0
- package/dist/components/urban/core/skyline.d.ts.map +1 -0
- package/dist/components/urban/core/skyline.js +89 -0
- package/dist/components/urban/core/streetFurniture.d.ts +75 -0
- package/dist/components/urban/core/streetFurniture.d.ts.map +1 -0
- package/dist/components/urban/core/streetFurniture.js +193 -0
- package/dist/components/urban/core/streetGrid.d.ts +134 -0
- package/dist/components/urban/core/streetGrid.d.ts.map +1 -0
- package/dist/components/urban/core/streetGrid.js +422 -0
- package/dist/components/urban/core/traffic.d.ts +125 -0
- package/dist/components/urban/core/traffic.d.ts.map +1 -0
- package/dist/components/urban/core/traffic.js +305 -0
- package/dist/components/urban/index.d.ts +29 -0
- package/dist/components/urban/index.d.ts.map +1 -0
- package/dist/components/urban/index.js +16 -0
- package/dist/components/urban/textureSetResolver.d.ts +8 -0
- package/dist/components/urban/textureSetResolver.d.ts.map +1 -0
- package/dist/components/urban/textureSetResolver.js +16 -0
- package/dist/components/urban/urbanCore.d.ts +262 -0
- package/dist/components/urban/urbanCore.d.ts.map +1 -0
- package/dist/components/urban/urbanCore.js +928 -0
- package/dist/components/urban/useUrbanInstance.d.ts +53 -0
- package/dist/components/urban/useUrbanInstance.d.ts.map +1 -0
- package/dist/components/urban/useUrbanInstance.js +100 -0
- package/dist/components/vegetation/VegetationBush.d.ts +9 -0
- package/dist/components/vegetation/VegetationBush.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationBush.js +23 -0
- package/dist/components/vegetation/VegetationCrops.d.ts +9 -0
- package/dist/components/vegetation/VegetationCrops.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationCrops.js +23 -0
- package/dist/components/vegetation/VegetationFlowers.d.ts +9 -0
- package/dist/components/vegetation/VegetationFlowers.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationFlowers.js +23 -0
- package/dist/components/vegetation/VegetationForest.d.ts +9 -0
- package/dist/components/vegetation/VegetationForest.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationForest.js +23 -0
- package/dist/components/vegetation/VegetationFruit.d.ts +9 -0
- package/dist/components/vegetation/VegetationFruit.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationFruit.js +23 -0
- package/dist/components/vegetation/VegetationGrass.d.ts +9 -0
- package/dist/components/vegetation/VegetationGrass.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationGrass.js +23 -0
- package/dist/components/vegetation/VegetationHedge.d.ts +9 -0
- package/dist/components/vegetation/VegetationHedge.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationHedge.js +23 -0
- package/dist/components/vegetation/VegetationIvy.d.ts +9 -0
- package/dist/components/vegetation/VegetationIvy.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationIvy.js +23 -0
- package/dist/components/vegetation/VegetationTree.d.ts +9 -0
- package/dist/components/vegetation/VegetationTree.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationTree.js +23 -0
- package/dist/components/vegetation/VegetationVegetable.d.ts +9 -0
- package/dist/components/vegetation/VegetationVegetable.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationVegetable.js +23 -0
- package/dist/components/vegetation/core/bush.d.ts +1256 -0
- package/dist/components/vegetation/core/bush.d.ts.map +1 -0
- package/dist/components/vegetation/core/bush.js +376 -0
- package/dist/components/vegetation/core/crops.d.ts +1033 -0
- package/dist/components/vegetation/core/crops.d.ts.map +1 -0
- package/dist/components/vegetation/core/crops.js +378 -0
- package/dist/components/vegetation/core/flowers.d.ts +648 -0
- package/dist/components/vegetation/core/flowers.d.ts.map +1 -0
- package/dist/components/vegetation/core/flowers.js +225 -0
- package/dist/components/vegetation/core/forest.d.ts +138 -0
- package/dist/components/vegetation/core/forest.d.ts.map +1 -0
- package/dist/components/vegetation/core/forest.js +310 -0
- package/dist/components/vegetation/core/fruit.d.ts +99 -0
- package/dist/components/vegetation/core/fruit.d.ts.map +1 -0
- package/dist/components/vegetation/core/fruit.js +77 -0
- package/dist/components/vegetation/core/grass.d.ts +103 -0
- package/dist/components/vegetation/core/grass.d.ts.map +1 -0
- package/dist/components/vegetation/core/grass.js +102 -0
- package/dist/components/vegetation/core/hedge.d.ts +193 -0
- package/dist/components/vegetation/core/hedge.d.ts.map +1 -0
- package/dist/components/vegetation/core/hedge.js +243 -0
- package/dist/components/vegetation/core/ivy.d.ts +213 -0
- package/dist/components/vegetation/core/ivy.d.ts.map +1 -0
- package/dist/components/vegetation/core/ivy.js +173 -0
- package/dist/components/vegetation/core/tree.d.ts +1117 -0
- package/dist/components/vegetation/core/tree.d.ts.map +1 -0
- package/dist/components/vegetation/core/tree.js +408 -0
- package/dist/components/vegetation/core/vegetable.d.ts +99 -0
- package/dist/components/vegetation/core/vegetable.d.ts.map +1 -0
- package/dist/components/vegetation/core/vegetable.js +76 -0
- package/dist/components/vegetation/index.d.ts +23 -0
- package/dist/components/vegetation/index.d.ts.map +1 -0
- package/dist/components/vegetation/index.js +14 -0
- package/dist/components/vegetation/produceCore.d.ts +929 -0
- package/dist/components/vegetation/produceCore.d.ts.map +1 -0
- package/dist/components/vegetation/produceCore.js +723 -0
- package/dist/components/vegetation/useVegetationInstance.d.ts +39 -0
- package/dist/components/vegetation/useVegetationInstance.d.ts.map +1 -0
- package/dist/components/vegetation/useVegetationInstance.js +45 -0
- package/dist/components/vegetation/vegetationCore.d.ts +412 -0
- package/dist/components/vegetation/vegetationCore.d.ts.map +1 -0
- package/dist/components/vegetation/vegetationCore.js +1728 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts +5 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts.map +1 -1
- package/dist/components/volumetricClouds/VolumetricCloudsPass.js +39 -13
- package/dist/components/water/OceanSurface.d.ts.map +1 -1
- package/dist/components/water/OceanSurface.js +3 -2
- package/dist/components/water/WaterBody.d.ts.map +1 -1
- package/dist/components/water/WaterBody.js +31 -10
- package/dist/components/water/WaterFountain.d.ts +9 -0
- package/dist/components/water/WaterFountain.d.ts.map +1 -0
- package/dist/components/water/WaterFountain.js +24 -0
- package/dist/components/water/WaterStream.d.ts +9 -0
- package/dist/components/water/WaterStream.d.ts.map +1 -0
- package/dist/components/water/WaterStream.js +24 -0
- package/dist/components/water/WaterWaterfall.d.ts +9 -0
- package/dist/components/water/WaterWaterfall.d.ts.map +1 -0
- package/dist/components/water/WaterWaterfall.js +24 -0
- package/dist/components/water/core/fountain.d.ts +70 -0
- package/dist/components/water/core/fountain.d.ts.map +1 -0
- package/dist/components/water/core/fountain.js +619 -0
- package/dist/components/water/core/stream.d.ts +72 -0
- package/dist/components/water/core/stream.d.ts.map +1 -0
- package/dist/components/water/core/stream.js +167 -0
- package/dist/components/water/core/waterfall.d.ts +78 -0
- package/dist/components/water/core/waterfall.d.ts.map +1 -0
- package/dist/components/water/core/waterfall.js +325 -0
- package/dist/components/water/index.d.ts +8 -0
- package/dist/components/water/index.d.ts.map +1 -1
- package/dist/components/water/index.js +7 -0
- package/dist/components/water/types.d.ts +3 -0
- package/dist/components/water/types.d.ts.map +1 -1
- package/dist/components/water/useWaterInstance.d.ts +43 -0
- package/dist/components/water/useWaterInstance.d.ts.map +1 -0
- package/dist/components/water/useWaterInstance.js +89 -0
- package/dist/components/water/waterCore.d.ts +179 -0
- package/dist/components/water/waterCore.d.ts.map +1 -0
- package/dist/components/water/waterCore.js +516 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +9 -1
- package/dist/hooks/index.d.ts +7 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +5 -2
- package/dist/hooks/useActionPatch.d.ts +23 -0
- package/dist/hooks/useActionPatch.d.ts.map +1 -0
- package/dist/hooks/useActionPatch.js +38 -0
- package/dist/hooks/useCloudSun.d.ts.map +1 -1
- package/dist/hooks/useCloudSun.js +3 -2
- package/dist/hooks/useCommittedInstance.d.ts +6 -0
- package/dist/hooks/useCommittedInstance.d.ts.map +1 -0
- package/dist/hooks/useCommittedInstance.js +42 -0
- package/dist/hooks/useConfigLive.d.ts +1 -1
- package/dist/hooks/useConfigLive.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.js +36 -20
- package/dist/hooks/useGridLayout.d.ts +7 -0
- package/dist/hooks/useGridLayout.d.ts.map +1 -0
- package/dist/hooks/useGridLayout.js +10 -0
- package/dist/hooks/useInteractionEffects.d.ts.map +1 -1
- package/dist/hooks/useInteractionEffects.js +48 -9
- package/dist/hooks/useLightLive.d.ts.map +1 -1
- package/dist/hooks/useLightLive.js +2 -0
- package/dist/hooks/useLinkStatus.d.ts +7 -0
- package/dist/hooks/useLinkStatus.d.ts.map +1 -0
- package/dist/hooks/useLinkStatus.js +20 -0
- package/dist/hooks/useMaterialApplication.d.ts +6 -1
- package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
- package/dist/hooks/useMaterialApplication.js +7 -2
- package/dist/hooks/useOceanMaterial.d.ts +11 -1
- package/dist/hooks/useOceanMaterial.d.ts.map +1 -1
- package/dist/hooks/useOceanMaterial.js +185 -27
- package/dist/hooks/usePathAnimation.d.ts +8 -0
- package/dist/hooks/usePathAnimation.d.ts.map +1 -1
- package/dist/hooks/usePathAnimation.js +140 -59
- package/dist/hooks/useResolvedLayout.d.ts +10 -0
- package/dist/hooks/useResolvedLayout.d.ts.map +1 -0
- package/dist/hooks/useResolvedLayout.js +17 -0
- package/dist/hooks/useTimeLighting.d.ts +36 -0
- package/dist/hooks/useTimeLighting.d.ts.map +1 -0
- package/dist/hooks/useTimeLighting.js +67 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/operations/catalogue/shaderLayers.d.ts.map +1 -1
- package/dist/operations/catalogue/shaderLayers.js +26 -3
- package/dist/render/renderLive.d.ts +11 -0
- package/dist/render/renderLive.d.ts.map +1 -0
- package/dist/render/renderLive.js +57 -0
- 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 +35 -5
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts +12 -0
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts.map +1 -1
- package/dist/shaders/ocean/OceanSurfaceMaterial.js +55 -7
- package/dist/shaders/terrain/TerrainMaterial.d.ts.map +1 -1
- package/dist/shaders/terrain/TerrainMaterial.js +28 -0
- package/dist/triggers/kinds/change.js +1 -1
- package/dist/ui/UiLayers.d.ts +17 -1
- package/dist/ui/UiLayers.d.ts.map +1 -1
- package/dist/ui/UiLayers.js +76 -3
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/utils/composerHostedPass.d.ts +74 -0
- package/dist/utils/composerHostedPass.d.ts.map +1 -0
- package/dist/utils/composerHostedPass.js +63 -0
- package/dist/utils/geometryScript.d.ts +17 -0
- package/dist/utils/geometryScript.d.ts.map +1 -0
- package/dist/utils/geometryScript.js +92 -0
- package/dist/utils/geometryScript.worker.d.ts +2 -0
- package/dist/utils/geometryScript.worker.d.ts.map +1 -0
- package/dist/utils/geometryScript.worker.js +42 -0
- package/dist/utils/groundRegistry.d.ts +11 -0
- package/dist/utils/groundRegistry.d.ts.map +1 -0
- package/dist/utils/groundRegistry.js +39 -0
- package/dist/utils/instancingSupport.d.ts +9 -0
- package/dist/utils/instancingSupport.d.ts.map +1 -0
- package/dist/utils/instancingSupport.js +13 -0
- package/dist/utils/landPatch.d.ts +26 -5
- package/dist/utils/landPatch.d.ts.map +1 -1
- package/dist/utils/landPatch.js +124 -9
- package/dist/utils/layoutPlacement.d.ts +30 -0
- package/dist/utils/layoutPlacement.d.ts.map +1 -0
- package/dist/utils/layoutPlacement.js +113 -0
- package/dist/utils/linkRegistry.d.ts +15 -0
- package/dist/utils/linkRegistry.d.ts.map +1 -0
- package/dist/utils/linkRegistry.js +11 -0
- package/dist/utils/shapes.d.ts +28 -2
- package/dist/utils/shapes.d.ts.map +1 -1
- package/dist/utils/shapes.js +32 -3
- package/dist/utils/sharedParts.d.ts +61 -0
- package/dist/utils/sharedParts.d.ts.map +1 -0
- package/dist/utils/sharedParts.js +268 -0
- package/dist/utils/svgAsset.d.ts +6 -0
- package/dist/utils/svgAsset.d.ts.map +1 -0
- package/dist/utils/svgAsset.js +46 -0
- package/dist/utils/waterLight.d.ts +29 -0
- package/dist/utils/waterLight.d.ts.map +1 -0
- package/dist/utils/waterLight.js +67 -0
- package/dist/utils/waterReflection.d.ts +185 -0
- package/dist/utils/waterReflection.d.ts.map +1 -0
- package/dist/utils/waterReflection.js +616 -0
- package/package.json +4 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// useTimeLighting — objects that answer the scene's time of day (TimeControls)
|
|
3
|
+
// =============================================================================
|
|
4
|
+
//
|
|
5
|
+
// The one pattern for objects lit by the time of day with no real lights (urban roads with their
|
|
6
|
+
// street lamps, buildings with their windows, sports courts with their floodlights…):
|
|
7
|
+
//
|
|
8
|
+
// - the scene sun: useCloudSun follows the sky system (TimeControls -> setTimeSettings) or the
|
|
9
|
+
// rendered sky; every frame each uniform set that carries the sun block (uSunDir…) gets
|
|
10
|
+
// applySun with the object's `lighting` override (auto | day | night) — uNight follows the
|
|
11
|
+
// sun's height, and the shaders fade lamp pools, window glow and floodlight heads by it;
|
|
12
|
+
// - the lamp list (urbanCore's lampRegistry): an object's lamps register in WORLD space (the
|
|
13
|
+
// object's core keeps their positions current in its update). When the list changes or the
|
|
14
|
+
// object moves, each surface re-gathers the lamps that reach its bounds (gatherLamps into
|
|
15
|
+
// uLamps / uLampColors), or re-bakes its lamp field for a large merged surface — nothing
|
|
16
|
+
// recompiles.
|
|
17
|
+
//
|
|
18
|
+
// A component passes its instance (uniformSets, local bounds(), optional lampTargets()) and its
|
|
19
|
+
// per-frame update, which runs between the sun and the lamp gathering (so lamps the core moved
|
|
20
|
+
// this frame are gathered this frame). relight() forces a re-gather (after an apply / rebuild).
|
|
21
|
+
//
|
|
22
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
23
|
+
import * as THREE from 'three';
|
|
24
|
+
import { useFrame } from '@react-three/fiber';
|
|
25
|
+
import { useCloudSun } from './useCloudSun.js';
|
|
26
|
+
import { applySun, gatherLamps, bakeLampField, lampRegistry } from '../components/urban/urbanCore.js';
|
|
27
|
+
const _box = new THREE.Box3();
|
|
28
|
+
export function useTimeLighting({ rootRef, instance, lighting, update }) {
|
|
29
|
+
const sun = useCloudSun();
|
|
30
|
+
const lampVersion = useRef(-1);
|
|
31
|
+
const lastWorld = useMemo(() => new THREE.Matrix4(), []);
|
|
32
|
+
const relight = useCallback(() => { lampVersion.current = -1; }, []);
|
|
33
|
+
useEffect(relight, [instance, relight]); // a new instance gathers on its first frame
|
|
34
|
+
useFrame((state, delta) => {
|
|
35
|
+
const dt = Math.min(delta, 0.1);
|
|
36
|
+
const s = sun.update();
|
|
37
|
+
const mode = lighting || 'auto';
|
|
38
|
+
const sets = instance.uniformSets ?? [];
|
|
39
|
+
for (const u of sets)
|
|
40
|
+
if (u.uSunDir)
|
|
41
|
+
applySun(u, s, mode);
|
|
42
|
+
update?.(dt, state);
|
|
43
|
+
const root = rootRef.current;
|
|
44
|
+
if (!root)
|
|
45
|
+
return;
|
|
46
|
+
root.updateMatrixWorld();
|
|
47
|
+
const moved = !lastWorld.equals(root.matrixWorld);
|
|
48
|
+
if (moved)
|
|
49
|
+
lastWorld.copy(root.matrixWorld);
|
|
50
|
+
if (lampVersion.current === lampRegistry.version && !moved)
|
|
51
|
+
return;
|
|
52
|
+
lampVersion.current = lampRegistry.version;
|
|
53
|
+
const targets = instance.lampTargets
|
|
54
|
+
? instance.lampTargets()
|
|
55
|
+
: instance.bounds
|
|
56
|
+
? sets.filter((u) => u.uLamps).map((u) => ({ u, bounds: instance.bounds() }))
|
|
57
|
+
: [];
|
|
58
|
+
for (const t of targets) {
|
|
59
|
+
_box.copy(t.bounds).applyMatrix4(root.matrixWorld);
|
|
60
|
+
if (t.field)
|
|
61
|
+
bakeLampField(t.field, _box);
|
|
62
|
+
else if (t.u)
|
|
63
|
+
gatherLamps(t.u, _box, null);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return { relight };
|
|
67
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './types';
|
|
|
4
4
|
export * from './components';
|
|
5
5
|
export * from './hooks';
|
|
6
6
|
export { createSceneHandle } from './api/sceneHandle';
|
|
7
|
+
export { applyRenderValue, registerRenderEffect, registerRenderTargets, RENDER_LIVE_PATHS } from './render/renderLive';
|
|
7
8
|
export { default as GalleryRuntime, GALLERY_ALL, GALLERY_IN_VIEW } from './galleryRuntime';
|
|
8
9
|
export type { GalleryControls, GalleryInfo, GalleryChangeEvent } from './galleryRuntime';
|
|
9
10
|
export * from './animationsV2';
|
|
@@ -18,6 +19,9 @@ export { cameraManager } from './utils/CameraSingleton';
|
|
|
18
19
|
export { applyAnchorSettings, createCurves, createSunPosition, randomRange, } from './utils/utils3d';
|
|
19
20
|
export { applyAnchorSettings as applyAnchorSettingsLegacy } from './utils/anchorUtils';
|
|
20
21
|
export * from './utils/shapes';
|
|
22
|
+
export { buildScriptGeometry, cachedScriptGeometry, clearScriptGeometryCache, ScriptGeometryError } from './utils/geometryScript';
|
|
23
|
+
export type { ScriptBuild } from './utils/geometryScript';
|
|
24
|
+
export { loadSvgAsset, svgAssetSync, svgAssetError } from './utils/svgAsset';
|
|
21
25
|
export * from './utils/pickProxy';
|
|
22
26
|
export { hasHoverAnimation } from './utils/hasHoverAnimation';
|
|
23
27
|
export { findById } from './utils/sceneQuery';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG5F,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC3F,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACzF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,g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AAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,sBAAsB,EACtB,eAAe,EACf,uBAAuB,GACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,8 @@ export * from './components/index.js';
|
|
|
8
8
|
export * from './hooks/index.js';
|
|
9
9
|
// External control of a loaded project (ProjectLoader ref / onSceneReady)
|
|
10
10
|
export { createSceneHandle } from './api/sceneHandle.js';
|
|
11
|
+
// The `render` target's per-frame writes (post-processing instances, exposure, HDR).
|
|
12
|
+
export { applyRenderValue, registerRenderEffect, registerRenderTargets, RENDER_LIVE_PATHS } from './render/renderLive.js';
|
|
11
13
|
// The live galleries and their navigation contract (next / prev / goTo), shared by SceneHandle.galleries, the 'gallery' trigger and the studio.
|
|
12
14
|
export { default as GalleryRuntime, GALLERY_ALL, GALLERY_IN_VIEW } from './galleryRuntime.js';
|
|
13
15
|
export * from './animationsV2/index.js';
|
|
@@ -22,6 +24,8 @@ export { cameraManager } from './utils/CameraSingleton.js';
|
|
|
22
24
|
export { applyAnchorSettings, createCurves, createSunPosition, randomRange, } from './utils/utils3d.js';
|
|
23
25
|
export { applyAnchorSettings as applyAnchorSettingsLegacy } from './utils/anchorUtils.js';
|
|
24
26
|
export * from './utils/shapes.js';
|
|
27
|
+
export { buildScriptGeometry, cachedScriptGeometry, clearScriptGeometryCache, ScriptGeometryError } from './utils/geometryScript.js';
|
|
28
|
+
export { loadSvgAsset, svgAssetSync, svgAssetError } from './utils/svgAsset.js';
|
|
25
29
|
export * from './utils/pickProxy.js';
|
|
26
30
|
export { hasHoverAnimation } from './utils/hasHoverAnimation.js';
|
|
27
31
|
export { findById } from './utils/sceneQuery.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaderLayers.d.ts","sourceRoot":"","sources":["../../../src/operations/catalogue/shaderLayers.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhD,MAAM,WAAW,WAAW;IACxB,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC7C,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MA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C,EAAE,GAAG,GAAG,MAAM,CAYxD;AAED,iDAAiD;AACjD,eAAO,MAAM,UAAU,4rBAWtB,CAAC;AAEF,0DAA0D;AAC1D,eAAO,MAAM,QAAQ,4XAUpB,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,WAAW,4rBAoBvB,CAAC"}
|
|
@@ -176,6 +176,29 @@ export async function commitPendingLayers(root) {
|
|
|
176
176
|
setTimeout(() => clones.forEach(c => c.dispose()), 1500);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Instanced meshes (object layouts — InstancedLayout) share the master's material, so
|
|
181
|
+
* one layer reaches every copy. Layer GLSL reads the object's place with
|
|
182
|
+
* `modelMatrix * vec4(transformed, 1.0)`, which on an InstancedMesh is the
|
|
183
|
+
* layout root, not the copy: every copy would see the effect in the master's frame
|
|
184
|
+
* (a sweep running on all of them at once instead of across the layout). In the
|
|
185
|
+
* layer's vertex code `modelMatrix` / `modelViewMatrix` therefore become the
|
|
186
|
+
* per-instance matrices under USE_INSTANCING (and stay as they are otherwise).
|
|
187
|
+
*/
|
|
188
|
+
const FX_INSTANCED_MATRICES = /* glsl */ `
|
|
189
|
+
#ifndef FX_INSTANCED_MATRICES
|
|
190
|
+
#define FX_INSTANCED_MATRICES
|
|
191
|
+
#ifdef USE_INSTANCING
|
|
192
|
+
#define FX_MODEL_MATRIX (modelMatrix * instanceMatrix)
|
|
193
|
+
#define FX_MODEL_VIEW_MATRIX (modelViewMatrix * instanceMatrix)
|
|
194
|
+
#else
|
|
195
|
+
#define FX_MODEL_MATRIX modelMatrix
|
|
196
|
+
#define FX_MODEL_VIEW_MATRIX modelViewMatrix
|
|
197
|
+
#endif
|
|
198
|
+
#endif`;
|
|
199
|
+
const instanced = (glsl) => (glsl ?? '')
|
|
200
|
+
.replace(/\bmodelMatrix\b(?!\s*\*\s*instanceMatrix)/g, 'FX_MODEL_MATRIX')
|
|
201
|
+
.replace(/\bmodelViewMatrix\b(?!\s*\*\s*instanceMatrix)/g, 'FX_MODEL_VIEW_MATRIX');
|
|
179
202
|
function commitLayer(mat, key, layer) {
|
|
180
203
|
if (!canLayer(mat))
|
|
181
204
|
return false;
|
|
@@ -196,9 +219,9 @@ function commitLayer(mat, key, layer) {
|
|
|
196
219
|
for (const l of own.layers.values()) {
|
|
197
220
|
const decl = Object.keys(l.uniforms).map(n => uniformDecl(n, l.uniforms[n].value)).join('\n');
|
|
198
221
|
shader.vertexShader = shader.vertexShader
|
|
199
|
-
.replace('#include <common>', `#include <common>\n${decl}\n${l.common ?? ''}\n${l.vertexPars
|
|
200
|
-
.replace(N_ANCHOR, `${N_ANCHOR}\n${l.normal
|
|
201
|
-
.replace(V_ANCHOR, `${V_ANCHOR}\n${l.vertex
|
|
222
|
+
.replace('#include <common>', `#include <common>\n${FX_INSTANCED_MATRICES}\n${decl}\n${l.common ?? ''}\n${instanced(l.vertexPars)}`)
|
|
223
|
+
.replace(N_ANCHOR, `${N_ANCHOR}\n${instanced(l.normal)}`)
|
|
224
|
+
.replace(V_ANCHOR, `${V_ANCHOR}\n${instanced(l.vertex)}`);
|
|
202
225
|
shader.fragmentShader = shader.fragmentShader
|
|
203
226
|
.replace('#include <common>', `#include <common>\n${decl}\n${l.common ?? ''}\n${l.fragmentPars ?? ''}`)
|
|
204
227
|
.replace(D_ANCHOR, `${D_ANCHOR}\n${l.diffuse ?? ''}`)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RenderEffectKey } from '@3driseai/3drise-core';
|
|
2
|
+
type Any = any;
|
|
3
|
+
/** RenderEffects: an effect instance mounted (or null when it unmounts). */
|
|
4
|
+
export declare function registerRenderEffect(slot: RenderEffectKey | 'gradingHue', instance: Any | null): void;
|
|
5
|
+
/** The canvas's renderer and scene (exposure, HDR intensity / rotation). */
|
|
6
|
+
export declare function registerRenderTargets(renderer: Any, s: Any): void;
|
|
7
|
+
/** Every path the `render` target writes live. */
|
|
8
|
+
export declare const RENDER_LIVE_PATHS: readonly ["exposure", "ssao.intensity", "ssao.radius", "bloom.intensity", "bloom.threshold", "grading.brightness", "grading.contrast", "grading.saturation", "grading.hue", "dof.focusDistance", "dof.bokehScale", "vignette.offset", "vignette.darkness", "hdr.intensity", "hdr.rotation", "hdr.backgroundIntensity", "hdr.backgroundBlur"];
|
|
9
|
+
export declare function applyRenderValue(path: string, value: unknown): boolean;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=renderLive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderLive.d.ts","sourceRoot":"","sources":["../../src/render/renderLive.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,KAAK,GAAG,GAAG,GAAG,CAAC;AAMf,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,GAAG,YAAY,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,CAGrG;AAED,4EAA4E;AAC5E,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,IAAI,CAGjE;AAID,kDAAkD;AAClD,eAAO,MAAM,iBAAiB,8UAQpB,CAAC;AAEX,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CA2BtE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const effects = new Map();
|
|
2
|
+
let gl = null;
|
|
3
|
+
let scene = null;
|
|
4
|
+
/** RenderEffects: an effect instance mounted (or null when it unmounts). */
|
|
5
|
+
export function registerRenderEffect(slot, instance) {
|
|
6
|
+
if (instance)
|
|
7
|
+
effects.set(slot, instance);
|
|
8
|
+
else
|
|
9
|
+
effects.delete(slot);
|
|
10
|
+
}
|
|
11
|
+
/** The canvas's renderer and scene (exposure, HDR intensity / rotation). */
|
|
12
|
+
export function registerRenderTargets(renderer, s) {
|
|
13
|
+
gl = renderer;
|
|
14
|
+
scene = s;
|
|
15
|
+
}
|
|
16
|
+
const set = (o, k, v) => { if (!o)
|
|
17
|
+
return false; o[k] = v; return true; };
|
|
18
|
+
/** Every path the `render` target writes live. */
|
|
19
|
+
export const RENDER_LIVE_PATHS = [
|
|
20
|
+
'exposure',
|
|
21
|
+
'ssao.intensity', 'ssao.radius',
|
|
22
|
+
'bloom.intensity', 'bloom.threshold',
|
|
23
|
+
'grading.brightness', 'grading.contrast', 'grading.saturation', 'grading.hue',
|
|
24
|
+
'dof.focusDistance', 'dof.bokehScale',
|
|
25
|
+
'vignette.offset', 'vignette.darkness',
|
|
26
|
+
'hdr.intensity', 'hdr.rotation', 'hdr.backgroundIntensity', 'hdr.backgroundBlur',
|
|
27
|
+
];
|
|
28
|
+
export function applyRenderValue(path, value) {
|
|
29
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
30
|
+
return false;
|
|
31
|
+
switch (path) {
|
|
32
|
+
case 'exposure': return set(gl, 'toneMappingExposure', value);
|
|
33
|
+
case 'ssao.intensity': return set(effects.get('ssao'), 'intensity', value);
|
|
34
|
+
case 'ssao.radius': return set(effects.get('ssao'), 'radius', value);
|
|
35
|
+
case 'bloom.intensity': return set(effects.get('bloom'), 'intensity', value);
|
|
36
|
+
case 'bloom.threshold': return set(effects.get('bloom')?.luminanceMaterial, 'threshold', value);
|
|
37
|
+
case 'grading.brightness': return set(effects.get('grading'), 'brightness', value);
|
|
38
|
+
case 'grading.contrast': return set(effects.get('grading'), 'contrast', value);
|
|
39
|
+
case 'grading.saturation': return set(effects.get('gradingHue'), 'saturation', value);
|
|
40
|
+
case 'grading.hue': return set(effects.get('gradingHue'), 'hue', value);
|
|
41
|
+
case 'dof.focusDistance': return set(effects.get('dof')?.cocMaterial, 'focusDistance', value);
|
|
42
|
+
case 'dof.bokehScale': return set(effects.get('dof'), 'bokehScale', value);
|
|
43
|
+
case 'vignette.offset': return set(effects.get('vignette'), 'offset', value);
|
|
44
|
+
case 'vignette.darkness': return set(effects.get('vignette'), 'darkness', value);
|
|
45
|
+
case 'hdr.intensity': return set(scene, 'environmentIntensity', value);
|
|
46
|
+
case 'hdr.rotation': {
|
|
47
|
+
if (!scene)
|
|
48
|
+
return false;
|
|
49
|
+
scene.environmentRotation?.set?.(0, value, 0);
|
|
50
|
+
scene.backgroundRotation?.set?.(0, value, 0);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
case 'hdr.backgroundIntensity': return set(scene, 'backgroundIntensity', value);
|
|
54
|
+
case 'hdr.backgroundBlur': return set(scene, 'backgroundBlurriness', value);
|
|
55
|
+
default: return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
/** Hard cap on the wave table. The loop is bounded by it because GLSL ES 1.00
|
|
43
43
|
* requires a constant bound; `u_waveCount` breaks out early. */
|
|
44
44
|
export declare const MAX_WAVES = 32;
|
|
45
|
-
export declare const oceanUniforms = "\n#define MAX_WAVES 32\n\n// Per component: (dirX, dirZ, amplitude, wavenumber k).\nuniform vec4 u_waveA[MAX_WAVES];\n// Per component: (angular frequency w, phase, steepness Q, wavelength).\nuniform vec4 u_waveB[MAX_WAVES];\nuniform float u_waveCount;\n\nuniform float u_time;\nuniform float u_waterLevel;\nuniform float u_choppiness;\nuniform float u_amplitudeScale;\n\n// Half-extent of a placed body, and the width of its rim taper. Both zero on the\n// world host, which is what switches the taper off - a sea has no rim.\nuniform vec2 u_bodyHalf;\nuniform float u_edgeFade;\n\nuniform vec3 u_deepColor;\nuniform vec3 u_shallowColor;\nuniform vec3 u_foamColor;\nuniform vec3 u_sssColor;\nuniform float u_absorption;\nuniform float u_clarity;\nuniform float u_roughness;\nuniform float u_specular;\nuniform float u_sssStrength;\nuniform float u_detailStrength;\nuniform float u_detailScale; // 1 / detailSize\nuniform float u_detailFade; // 1 / detailFadeDistance\n// World size of one pixel at one unit of distance: 2*tan(fov/2) / viewportHeight.\n// What turns a distance into a screen-space footprint, which is the only thing\n// that decides whether a ripple is a shape or a shimmer.\nuniform float u_pixelScale;\nuniform float u_foamAmount;\nuniform float u_foamDecay;\nuniform float u_foamScale; // 1 / foamSize\nuniform float u_ambientScale;\nuniform float u_fogDensity;\nuniform float u_exposure;\nuniform float u_curvature;\nuniform float u_receiveShadows;\n\n// Filled by applySunUniforms and applyTerrainAmbient, exactly as on the terrain\n// material - one atmosphere for the sky, the clouds, the ground and the water.\nuniform vec3 u_skyAmbient;\nuniform vec3 u_groundAmbient;\n\n// Moonlight (useOceanMaterial, from the same moon as the key light and the\n// moon disc). u_moonColor already carries strength: black by day, so the moon\n// terms below cost two dot products and add nothing.\nuniform vec3 u_moonDir;\nuniform vec3 u_moonColor;\n";
|
|
45
|
+
export declare const oceanUniforms = "\n#define MAX_WAVES 32\n\n// Per component: (dirX, dirZ, amplitude, wavenumber k).\nuniform vec4 u_waveA[MAX_WAVES];\n// Per component: (angular frequency w, phase, steepness Q, wavelength).\nuniform vec4 u_waveB[MAX_WAVES];\nuniform float u_waveCount;\n\nuniform float u_time;\n// The current (config flowSpeed / flowDirection). Offsets are the distance the\n// water has carried the field so far, integrated on the CPU (offset += v * dt),\n// never speed * time: animating the speed must not make the pattern jump.\n// u_flowOffset is in the field's own frame (a body's local metres, the world on\n// the world host); u_flowOffsetW and u_flowDirW are in world XZ for the\n// per-fragment ripple. All zero for still water.\nuniform vec2 u_flowOffset;\nuniform vec2 u_flowOffsetW;\nuniform vec2 u_flowDirW;\nuniform float u_flowStretch;\nuniform float u_waterLevel;\nuniform float u_choppiness;\nuniform float u_amplitudeScale;\n\n// Half-extent of a placed body, and the width of its rim taper. Both zero on the\n// world host, which is what switches the taper off - a sea has no rim.\nuniform vec2 u_bodyHalf;\nuniform float u_edgeFade;\n\nuniform vec3 u_deepColor;\nuniform vec3 u_shallowColor;\nuniform vec3 u_foamColor;\nuniform vec3 u_sssColor;\nuniform float u_absorption;\nuniform float u_clarity;\nuniform float u_roughness;\nuniform float u_specular;\nuniform float u_sssStrength;\nuniform float u_detailStrength;\nuniform float u_detailScale; // 1 / detailSize\nuniform float u_detailFade; // 1 / detailFadeDistance\n// World size of one pixel at one unit of distance: 2*tan(fov/2) / viewportHeight.\n// What turns a distance into a screen-space footprint, which is the only thing\n// that decides whether a ripple is a shape or a shimmer.\nuniform float u_pixelScale;\nuniform float u_foamAmount;\nuniform float u_foamDecay;\nuniform float u_foamScale; // 1 / foamSize\nuniform float u_ambientScale;\nuniform float u_fogDensity;\nuniform float u_exposure;\nuniform float u_curvature;\nuniform float u_receiveShadows;\n\n// Filled by applySunUniforms and applyTerrainAmbient, exactly as on the terrain\n// material - one atmosphere for the sky, the clouds, the ground and the water.\nuniform vec3 u_skyAmbient;\n/** How bright the sky dome is drawn (skyBrightnessForSunElevation): 1 by day,\n * 0.08 at night. The analytic skyRadiance never goes dark on its own (Preetham's\n * Rayleigh term lights a sun-less sky in full daylight blue), so every place\n * the water reads the sky scales by this - or a pool glows blue at midnight. */\nuniform float u_skyBrightness;\nuniform vec3 u_groundAmbient;\n\n// Moonlight (useOceanMaterial, from the same moon as the key light and the\n// moon disc). u_moonColor already carries strength: black by day, so the moon\n// terms below cost two dot products and add nothing.\nuniform vec3 u_moonDir;\nuniform vec3 u_moonColor;\n";
|
|
46
46
|
export declare const oceanWaves = "\n/**\n * One trochoidal component, accumulated.\n *\n * Gerstner displaces along the direction of travel as well as vertically:\n *\n * x' = x + d * Q * A * sin(theta)\n * y = A * cos(theta)\n * theta = k * dot(d, x) + w * t + phase\n *\n * Q is what peaks the crests and flattens the troughs. It also compresses the\n * horizontal map near a crest, and where that compression turns the map\n * degenerate the wave is breaking - which is where the foam is. That falls out\n * of the same derivatives, for free, so foam here is measured rather than faked.\n *\n * Everything is differentiated in closed form. A central difference would need\n * four more evaluations of the whole sum for the normal alone; this is the same\n * decision, and the same 13x, that the terrain height field made.\n */\nvoid oceanWaveSum(\n vec2 p, float cellLod, float amp,\n out vec3 disp, // displacement from the flat plane, world units\n out vec3 nrm, // analytic surface normal\n out float jacobian, // det of the horizontal map. < 1 compresses, < 0 folds\n out float relHeight // vertical displacement in standard deviations of the surface\n){\n disp = vec3(0.0);\n jacobian = 0.0;\n relHeight = 0.0;\n\n // Horizontal derivatives of the horizontal displacement, and of the height.\n float dXdx = 0.0, dXdz = 0.0, dZdx = 0.0, dZdz = 0.0;\n float dYdx = 0.0, dYdz = 0.0;\n float totalSq = 0.0;\n\n for (int i = 0; i < MAX_WAVES; i++) {\n if (float(i) >= u_waveCount) break;\n\n vec4 a = u_waveA[i];\n vec4 b = u_waveB[i];\n vec2 d = a.xy;\n float A = a.z * amp;\n float k = a.w;\n float w = b.x;\n float phase = b.y;\n float Q = b.z;\n float wl = b.w;\n\n // Per-ring wave LOD. A component of wavelength L cannot be represented on a\n // cell coarser than about L/4 - sampled there it aliases into crawling\n // noise, which is what a naive clipmap ocean looks like at the horizon. So\n // it fades out as the cell approaches its wavelength.\n //\n // cellLod is aCell * (1 + aMorph), the same morphing LOD the terrain uses,\n // which is what makes the two sides of a ring seam agree: the outer edge of\n // ring l evaluates at exactly ring l+1's cell size, so both sides fade the\n // same components by the same amount and the surface is continuous across\n // the boundary.\n float lod = 1.0 - smoothstep(wl * 0.25, wl * 0.75, cellLod);\n A *= lod;\n\n float theta = k * dot(d, p) + w * u_time + phase;\n float S = sin(theta);\n float C = cos(theta);\n\n float QA = Q * A;\n\n disp.x += d.x * QA * S;\n disp.z += d.y * QA * S;\n disp.y += A * C;\n totalSq += A * A;\n\n float kQA = k * QA;\n dXdx += d.x * d.x * kQA * C;\n dXdz += d.x * d.y * kQA * C;\n dZdx += d.y * d.x * kQA * C;\n dZdz += d.y * d.y * kQA * C;\n\n float kA = k * A;\n dYdx -= d.x * kA * S;\n dYdz -= d.y * kA * S;\n }\n\n // Tangent frame of the displaced surface. Taking the cross product rather than\n // the usual closed-form shortcut costs three multiplies and stays correct when\n // choppiness is high, where the shortcut - which assumes the horizontal map is\n // near-identity - visibly tilts the crests the wrong way.\n vec3 tx = vec3(1.0 + dXdx, dYdx, dZdx);\n vec3 tz = vec3(dXdz, dYdz, 1.0 + dZdz);\n nrm = normalize(cross(tz, tx));\n\n jacobian = (1.0 + dXdx) * (1.0 + dZdz) - dXdz * dZdx;\n\n // Height in standard deviations of the surface, NOT as a fraction of the\n // summed amplitudes. Dividing by the sum is the obvious thing and it is wrong\n // by a factor of sqrt(2N): random-phase components almost never align, so the\n // surface only ever reaches a fraction of that sum, and everything keyed on\n // relative height - the foam's crest gate, the subsurface term - was being\n // multiplied by ~0.15 and silently doing nothing. A storm with whitecaps\n // turned up had no foam at all, which is how this was found.\n //\n // sigma is the RMS surface elevation, so this is roughly -3..3 with the usual\n // excursion at +-1, and a threshold expressed in it means what it looks like.\n relHeight = disp.y / max(sqrt(totalSq * 0.5), 1e-4);\n}\n\n/** Rim taper for a placed body: displacement to zero at the edge, so the\n * boundary is still water rather than a sawn-off cliff of it. Returns 1 on the\n * world host, where u_bodyHalf is zero. */\nfloat oceanEdgeMask(vec2 local){\n if (u_bodyHalf.x <= 0.0) return 1.0;\n vec2 t = abs(local) / max(u_bodyHalf, vec2(1e-3));\n float e = max(t.x, t.y);\n float band = max(u_edgeFade, 1e-3);\n return 1.0 - smoothstep(1.0 - band, 1.0, e);\n}\n";
|
|
47
|
-
export declare const oceanShade = "\n/** Arithmetic hash. Never the fract(sin(dot())) one: four hashes per octave of\n * two sines each was most of the terrain frame budget before it was replaced,\n * and every noise tutorial online still teaches the expensive version. */\nvec2 oHash(vec2 p){\n vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));\n p3 += dot(p3, p3.yzx + 33.33);\n return fract((p3.xx + p3.yz) * p3.zy) * 2.0 - 1.0;\n}\n\n/** Gradient noise with its derivative, so a detail normal costs one evaluation\n * instead of three. */\nvec3 oNoised(vec2 x){\n vec2 i = floor(x);\n vec2 f = fract(x);\n vec2 u = f * f * (3.0 - 2.0 * f);\n vec2 du = 6.0 * f * (1.0 - f);\n\n vec2 ga = oHash(i + vec2(0.0, 0.0));\n vec2 gb = oHash(i + vec2(1.0, 0.0));\n vec2 gc = oHash(i + vec2(0.0, 1.0));\n vec2 gd = oHash(i + vec2(1.0, 1.0));\n\n float va = dot(ga, f - vec2(0.0, 0.0));\n float vb = dot(gb, f - vec2(1.0, 0.0));\n float vc = dot(gc, f - vec2(0.0, 1.0));\n float vd = dot(gd, f - vec2(1.0, 1.0));\n\n float v = va + u.x * (vb - va) + u.y * (vc - va) + u.x * u.y * (va - vb - vc + vd);\n vec2 g = ga + u.x * (gb - ga) + u.y * (gc - ga) + u.x * u.y * (ga - gb - gc + gd)\n + du * (u.yx * (va - vb - vc + vd) + vec2(vb, vc) - va);\n return vec3(v, g);\n}\n\n/**\n * Ripple below the mesh.\n *\n * This is not decoration: the per-ring LOD in oceanWaveSum deletes every\n * component shorter than the cell, and near the camera that is most of the\n * high-frequency energy in the sea. Putting it back as a normal perturbation is\n * cheaper than carrying it in geometry and, past a few metres, indistinguishable\n * - a ripple two pixels across is a normal, not a shape.\n *\n * Two octaves drifting in opposite directions, because one drifting field reads\n * as a texture being dragged across the water.\n */\nfloat oceanDetailFade(float dist){\n // Two fades, and the second is the one that matters. Distance alone is not\n // what makes a ripple alias - a screen-space footprint is. A two-metre ripple\n // is a shape at fifty metres and sub-pixel noise at two thousand, and which of\n // those it is depends on the field of view and the resolution, not on the\n // distance. Fading on the footprint means the same water looks right in a\n // wide shot and a telephoto one.\n float footprint = dist * u_pixelScale;\n float size = 1.0 / max(u_detailScale, 1e-4);\n float screen = 1.0 - smoothstep(size * 0.35, size * 1.4, footprint);\n return exp(-dist * u_detailFade) * screen;\n}\n\nvec3 oceanDetailNormal(vec3 n, vec3 wp, float fade){\n float amt = u_detailStrength * fade;\n if (amt <= 0.001) return n;\n\n vec2 p = wp.xz * u_detailScale;\n vec2 drift = vec2(u_time * 0.06, u_time * 0.043);\n\n vec3 a = oNoised(p + drift);\n vec3 b = oNoised(p * 2.17 - drift * 1.6);\n vec2 g = a.yz + b.yz * 0.5;\n\n // Perturb in the surface plane, so a steep wave face keeps its own orientation\n // and only gains texture.\n vec3 t = normalize(cross(vec3(0.0, 1.0, 0.0), n) + vec3(1e-5, 0.0, 0.0));\n vec3 bt = cross(n, t);\n // 0.12, not 0.4. The gradient of the noise is order 1, so the constant IS the\n // maximum slope the ripple adds: at 0.4 the default strength tilts the normal\n // by twelve degrees, and at grazing angles - which is most of an ocean - a\n // twelve degree tilt swings the Fresnel term between reflecting the sky and\n // not. The whole surface then boils with white speckle, which is exactly what\n // it did. Sub-metre ripple on open water is a few degrees of slope.\n return normalize(n - (t * g.x + bt * g.y) * amt * 0.12);\n}\n\n/**\n * Whitecaps, from the Jacobian of the horizontal map.\n *\n * Where the determinant falls toward zero the surface is folding into itself,\n * which is physically what a breaking crest is. It is the same quantity an FFT\n * ocean reads off its displacement cascade, and a Gerstner sum hands it over for\n * nothing, so foam is measured here rather than paint over the crests.\n *\n * u_foamDecay is a stand-in for a real accumulation buffer: it widens the\n * threshold on the trailing side, so foam persists behind the crest instead of\n * flickering on and off with it. The honest version writes into a persistent\n * target and advects it - deferred with the FFT phase.\n */\nfloat oceanFoam(float jacobian, float relHeight, vec3 wp){\n float compress = saturate(1.0 - jacobian);\n\n // Thresholds are calibrated against the compression the wave table actually\n // produces, which is a much narrower range than it looks: at the defaults the\n // Jacobian sits just above zero at the sharpest crest and near 1 everywhere\n // else. A threshold picked by eye either foams the whole sea or none of it.\n float thr = mix(0.85, 0.15, saturate(u_foamAmount * 0.6));\n float sharp = smoothstep(thr, thr + 0.15, compress);\n float trail = smoothstep(thr * 0.55, thr + 0.4, compress);\n float f = mix(sharp, max(sharp, trail), saturate(u_foamDecay));\n\n // Foam belongs on and just behind the crest, never in the trough.\n f *= smoothstep(-0.15, 0.45, relHeight);\n\n // Break it up, or it reads as a decal following the wave.\n vec2 q = wp.xz * u_foamScale;\n float n = oNoised(q + vec2(u_time * 0.05, -u_time * 0.03)).x * 0.5 + 0.5;\n n = mix(n, 1.0, 0.35);\n return saturate(f * n * u_foamAmount);\n}\n\n/**\n * The water shading.\n *\n * Reflection is the whole story above a few degrees of grazing - most of what\n * you see looking at the sea is the sky - so the Fresnel split, the sky radiance\n * and the aerial perspective all have to come from the same atmosphere the sky\n * itself is drawn with, or the water is obviously pasted onto the scene. That is\n * skyRadiance from cloudCore, driven by applySunUniforms off the same\n * useCloudSun state as the clouds and the terrain.\n */\nvec3 oceanLight(\n vec3 wp, vec3 n, vec3 viewDir, // viewDir points FROM the camera TO the surface\n float foam, float relHeight, float shadow, float depthFactor,\n float roughnessBoost, // specular antialiasing, see the caller\n vec3 reflectionColor\n){\n vec3 V = -viewDir;\n vec3 L = normalize(u_sunDir);\n float NdotL = max(dot(n, L), 0.0);\n vec3 sun = u_sunColor * u_sunIntensity * shadow;\n\n // Reflection. Bending the reflected ray back above the horizon is a cheat, and\n // the alternative is worse: at grazing angles a wave face routinely reflects\n // just below the horizon, and sampling the sky's ground term there puts a band\n // of dirt across the brightest part of the water.\n vec3 R = reflect(viewDir, n);\n R.y = max(R.y, 0.015);\n vec3 sky = length(reflectionColor) > 0.0 ? reflectionColor : skyRadiance(R);\n\n // Prefilter the reflection by the same roughness the specular lobe uses.\n // Without this the specular is filtered and the reflection is not, and on\n // water that is the wrong half: reflection is most of what you see, and a\n // mirror sampled through a noisy normal aliases exactly as hard as a highlight\n // does. u_skyAmbient is already the hemispheric average of this sky, so it is\n // the infinitely-rough end of the same lobe and costs nothing to mix toward.\n float rough = clamp(u_roughness + roughnessBoost, 0.01, 1.0);\n sky = mix(sky, u_skyAmbient * 0.6, saturate(rough * 2.2));\n\n float fres = 0.02 + 0.98 * pow(1.0 - saturate(dot(V, n)), 5.0);\n\n // Body colour. depthFactor is 1 in open water and ramps to 0 as the bottom\n // comes up; until the refraction grab exists it is 1 everywhere.\n vec3 body = mix(u_shallowColor, u_deepColor, saturate(depthFactor));\n body = mix(body, u_shallowColor, u_clarity * 0.35);\n vec3 bodyLit = body * (u_skyAmbient * u_ambientScale * 0.22 + sun * (0.25 + 0.55 * NdotL));\n\n // Subsurface. A wave lit from behind glows through its own crest, and the\n // effect is strongest where the surface is steep and thin - so it keys off the\n // wave's own height rather than off thickness we do not have.\n float back = pow(saturate(dot(V, -L) * 0.5 + 0.5), 3.0);\n float thin = saturate(relHeight * 1.4);\n vec3 sss = u_sssColor * u_sssStrength * back * thin * u_sunColor * u_sunIntensity * (0.35 + 0.65 * shadow);\n\n // GGX. The glitter path from the horizon to the camera is most of what says\n // \"water\" at distance, and it is a specular lobe on a normal that is moving -\n // which is why the detail normal matters as much as the mesh does.\n // Water is nearly smooth, which is exactly what makes it alias: a specular\n // lobe this tight flips between nothing and a blown-out highlight across one\n // pixel, and a sea of them boils. The fix is not a softer sea - it is to widen\n // the lobe by however much the normal varies inside the pixel, so the energy\n // is kept and the flicker is not. roughnessBoost carries that in, and the\n // reflection above is filtered by the same number.\n float a = max(rough * rough, 2e-4);\n vec3 h = normalize(L + V);\n float ndh = max(dot(n, h), 0.0);\n float denom = ndh * ndh * (a * a - 1.0) + 1.0;\n float ggx = (a * a) / (PI * denom * denom);\n vec3 spec = sun * ggx * u_specular * fres;\n\n // The moon: its own glitter path down the water toward the camera, and a\n // little light on the body. Same lobe, same filtering, so the path breaks up\n // on the waves exactly as the sun's does. Below the horizon u_moonColor is 0.\n vec3 Lm = normalize(u_moonDir);\n vec3 hm = normalize(Lm + V);\n float ndhm = max(dot(n, hm), 0.0);\n float denomM = ndhm * ndhm * (a * a - 1.0) + 1.0;\n float ggxM = (a * a) / (PI * denomM * denomM);\n spec += u_moonColor * ggxM * u_specular * fres;\n bodyLit += body * u_moonColor * (0.25 + 0.55 * max(dot(n, Lm), 0.0));\n\n vec3 col = mix(bodyLit + sss, sky, fres) + spec;\n\n // Foam is a rough dielectric, so it takes the sky and the sun diffusely and\n // kills the reflection under it.\n vec3 foamLit = u_foamColor * (u_skyAmbient * u_ambientScale * 0.5 + sun * (0.3 + 0.7 * NdotL));\n col = mix(col, foamLit, saturate(foam));\n\n return col;\n}\n\n/** Fade into the sky the water is seen through. Same term as the terrain's,\n * and it needs to be stronger here: an ocean runs to the horizon in every\n * direction, so it is the only thing stopping the far field reading as a\n * painted plane. */\nvec3 oceanAerial(vec3 col, vec3 rd, float dist){\n float f = 1.0 - exp(-u_fogDensity * dist);\n if (f < 0.002) return col;\n return mix(col, skyRadiance(rd), f);\n}\n";
|
|
47
|
+
export declare const oceanShade = "\n/** Arithmetic hash. Never the fract(sin(dot())) one: four hashes per octave of\n * two sines each was most of the terrain frame budget before it was replaced,\n * and every noise tutorial online still teaches the expensive version. */\nvec2 oHash(vec2 p){\n vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));\n p3 += dot(p3, p3.yzx + 33.33);\n return fract((p3.xx + p3.yz) * p3.zy) * 2.0 - 1.0;\n}\n\n/** Gradient noise with its derivative, so a detail normal costs one evaluation\n * instead of three. */\nvec3 oNoised(vec2 x){\n vec2 i = floor(x);\n vec2 f = fract(x);\n vec2 u = f * f * (3.0 - 2.0 * f);\n vec2 du = 6.0 * f * (1.0 - f);\n\n vec2 ga = oHash(i + vec2(0.0, 0.0));\n vec2 gb = oHash(i + vec2(1.0, 0.0));\n vec2 gc = oHash(i + vec2(0.0, 1.0));\n vec2 gd = oHash(i + vec2(1.0, 1.0));\n\n float va = dot(ga, f - vec2(0.0, 0.0));\n float vb = dot(gb, f - vec2(1.0, 0.0));\n float vc = dot(gc, f - vec2(0.0, 1.0));\n float vd = dot(gd, f - vec2(1.0, 1.0));\n\n float v = va + u.x * (vb - va) + u.y * (vc - va) + u.x * u.y * (va - vb - vc + vd);\n vec2 g = ga + u.x * (gb - ga) + u.y * (gc - ga) + u.x * u.y * (ga - gb - gc + gd)\n + du * (u.yx * (va - vb - vc + vd) + vec2(vb, vc) - va);\n return vec3(v, g);\n}\n\n/**\n * Ripple below the mesh.\n *\n * This is not decoration: the per-ring LOD in oceanWaveSum deletes every\n * component shorter than the cell, and near the camera that is most of the\n * high-frequency energy in the sea. Putting it back as a normal perturbation is\n * cheaper than carrying it in geometry and, past a few metres, indistinguishable\n * - a ripple two pixels across is a normal, not a shape.\n *\n * Two octaves drifting in opposite directions, because one drifting field reads\n * as a texture being dragged across the water.\n */\nfloat oceanDetailFade(float dist){\n // Two fades, and the second is the one that matters. Distance alone is not\n // what makes a ripple alias - a screen-space footprint is. A two-metre ripple\n // is a shape at fifty metres and sub-pixel noise at two thousand, and which of\n // those it is depends on the field of view and the resolution, not on the\n // distance. Fading on the footprint means the same water looks right in a\n // wide shot and a telephoto one.\n float footprint = dist * u_pixelScale;\n float size = 1.0 / max(u_detailScale, 1e-4);\n float screen = 1.0 - smoothstep(size * 0.35, size * 1.4, footprint);\n return exp(-dist * u_detailFade) * screen;\n}\n\nvec3 oceanDetailNormal(vec3 n, vec3 wp, float fade){\n float amt = u_detailStrength * fade;\n if (amt <= 0.001) return n;\n\n // Running water: the ripple is carried downstream with the current and\n // stretched along it, into the streaks that say \"flowing\" rather than\n // \"wind-blown\". Sampled in the flow's frame (along, across) with the along axis\n // compressed; the gradient is mapped back with the transpose (chain rule), so\n // the perturbation stays in world XZ. Still water skips it (uniform branch).\n vec2 xz = wp.xz - u_flowOffsetW;\n float along = 1.0 / (1.0 + u_flowStretch);\n vec2 fd = u_flowDirW;\n vec2 fn = vec2(-fd.y, fd.x);\n bool flowing = u_flowStretch > 0.0;\n vec2 q = flowing ? vec2(dot(xz, fd) * along, dot(xz, fn)) : xz;\n\n vec2 p = q * u_detailScale;\n vec2 drift = vec2(u_time * 0.06, u_time * 0.043);\n\n vec3 a = oNoised(p + drift);\n vec3 b = oNoised(p * 2.17 - drift * 1.6);\n vec2 g = a.yz + b.yz * 0.5;\n if (flowing) g = fd * (g.x * along) + fn * g.y;\n\n // Perturb in the surface plane, so a steep wave face keeps its own orientation\n // and only gains texture.\n vec3 t = normalize(cross(vec3(0.0, 1.0, 0.0), n) + vec3(1e-5, 0.0, 0.0));\n vec3 bt = cross(n, t);\n // 0.12, not 0.4. The gradient of the noise is order 1, so the constant IS the\n // maximum slope the ripple adds: at 0.4 the default strength tilts the normal\n // by twelve degrees, and at grazing angles - which is most of an ocean - a\n // twelve degree tilt swings the Fresnel term between reflecting the sky and\n // not. The whole surface then boils with white speckle, which is exactly what\n // it did. Sub-metre ripple on open water is a few degrees of slope.\n return normalize(n - (t * g.x + bt * g.y) * amt * 0.12);\n}\n\n/**\n * Whitecaps, from the Jacobian of the horizontal map.\n *\n * Where the determinant falls toward zero the surface is folding into itself,\n * which is physically what a breaking crest is. It is the same quantity an FFT\n * ocean reads off its displacement cascade, and a Gerstner sum hands it over for\n * nothing, so foam is measured here rather than paint over the crests.\n *\n * u_foamDecay is a stand-in for a real accumulation buffer: it widens the\n * threshold on the trailing side, so foam persists behind the crest instead of\n * flickering on and off with it. The honest version writes into a persistent\n * target and advects it - deferred with the FFT phase.\n */\nfloat oceanFoam(float jacobian, float relHeight, vec3 wp){\n float compress = saturate(1.0 - jacobian);\n\n // Thresholds are calibrated against the compression the wave table actually\n // produces, which is a much narrower range than it looks: at the defaults the\n // Jacobian sits just above zero at the sharpest crest and near 1 everywhere\n // else. A threshold picked by eye either foams the whole sea or none of it.\n float thr = mix(0.85, 0.15, saturate(u_foamAmount * 0.6));\n float sharp = smoothstep(thr, thr + 0.15, compress);\n float trail = smoothstep(thr * 0.55, thr + 0.4, compress);\n float f = mix(sharp, max(sharp, trail), saturate(u_foamDecay));\n\n // Foam belongs on and just behind the crest, never in the trough.\n f *= smoothstep(-0.15, 0.45, relHeight);\n\n // Break it up, or it reads as a decal following the wave.\n vec2 q = wp.xz * u_foamScale;\n float n = oNoised(q + vec2(u_time * 0.05, -u_time * 0.03)).x * 0.5 + 0.5;\n n = mix(n, 1.0, 0.35);\n return saturate(f * n * u_foamAmount);\n}\n\n/**\n * The water shading.\n *\n * Reflection is the whole story above a few degrees of grazing - most of what\n * you see looking at the sea is the sky - so the Fresnel split, the sky radiance\n * and the aerial perspective all have to come from the same atmosphere the sky\n * itself is drawn with, or the water is obviously pasted onto the scene. That is\n * skyRadiance from cloudCore, driven by applySunUniforms off the same\n * useCloudSun state as the clouds and the terrain.\n */\nvec3 oceanLight(\n vec3 wp, vec3 n, vec3 viewDir, // viewDir points FROM the camera TO the surface\n float foam, float relHeight, float shadow, float depthFactor,\n float roughnessBoost, // specular antialiasing, see the caller\n vec3 reflectionColor // 0: the sky; negative: no reflection (off)\n){\n vec3 V = -viewDir;\n vec3 L = normalize(u_sunDir);\n float NdotL = max(dot(n, L), 0.0);\n vec3 sun = u_sunColor * u_sunIntensity * shadow;\n\n // Reflection. Bending the reflected ray back above the horizon is a cheat, and\n // the alternative is worse: at grazing angles a wave face routinely reflects\n // just below the horizon, and sampling the sky's ground term there puts a band\n // of dirt across the brightest part of the water.\n vec3 R = reflect(viewDir, n);\n R.y = max(R.y, 0.015);\n vec3 sky = length(reflectionColor) > 0.0 ? reflectionColor : skyRadiance(R) * u_skyBrightness;\n\n // Prefilter the reflection by the same roughness the specular lobe uses.\n // Without this the specular is filtered and the reflection is not, and on\n // water that is the wrong half: reflection is most of what you see, and a\n // mirror sampled through a noisy normal aliases exactly as hard as a highlight\n // does. u_skyAmbient is already the hemispheric average of this sky, so it is\n // the infinitely-rough end of the same lobe and costs nothing to mix toward.\n float rough = clamp(u_roughness + roughnessBoost, 0.01, 1.0);\n sky = mix(sky, u_skyAmbient * 0.6, saturate(rough * 2.2));\n\n float fres = 0.02 + 0.98 * pow(1.0 - saturate(dot(V, n)), 5.0);\n\n // Body colour. depthFactor is 1 in open water and ramps to 0 as the bottom\n // comes up; until the refraction grab exists it is 1 everywhere.\n vec3 body = mix(u_shallowColor, u_deepColor, saturate(depthFactor));\n body = mix(body, u_shallowColor, u_clarity * 0.35);\n vec3 bodyLit = body * (u_skyAmbient * u_ambientScale * 0.22 + sun * (0.25 + 0.55 * NdotL));\n\n // Subsurface. A wave lit from behind glows through its own crest, and the\n // effect is strongest where the surface is steep and thin - so it keys off the\n // wave's own height rather than off thickness we do not have.\n float back = pow(saturate(dot(V, -L) * 0.5 + 0.5), 3.0);\n float thin = saturate(relHeight * 1.4);\n vec3 sss = u_sssColor * u_sssStrength * back * thin * u_sunColor * u_sunIntensity * (0.35 + 0.65 * shadow);\n\n // GGX. The glitter path from the horizon to the camera is most of what says\n // \"water\" at distance, and it is a specular lobe on a normal that is moving -\n // which is why the detail normal matters as much as the mesh does.\n // Water is nearly smooth, which is exactly what makes it alias: a specular\n // lobe this tight flips between nothing and a blown-out highlight across one\n // pixel, and a sea of them boils. The fix is not a softer sea - it is to widen\n // the lobe by however much the normal varies inside the pixel, so the energy\n // is kept and the flicker is not. roughnessBoost carries that in, and the\n // reflection above is filtered by the same number.\n float a = max(rough * rough, 2e-4);\n vec3 h = normalize(L + V);\n float ndh = max(dot(n, h), 0.0);\n float denom = ndh * ndh * (a * a - 1.0) + 1.0;\n float ggx = (a * a) / (PI * denom * denom);\n vec3 spec = sun * ggx * u_specular * fres;\n\n // The moon: its own glitter path down the water toward the camera, and a\n // little light on the body. Same lobe, same filtering, so the path breaks up\n // on the waves exactly as the sun's does. Below the horizon u_moonColor is 0.\n vec3 Lm = normalize(u_moonDir);\n vec3 hm = normalize(Lm + V);\n float ndhm = max(dot(n, hm), 0.0);\n float denomM = ndhm * ndhm * (a * a - 1.0) + 1.0;\n float ggxM = (a * a) / (PI * denomM * denomM);\n spec += u_moonColor * ggxM * u_specular * fres;\n bodyLit += body * u_moonColor * (0.25 + 0.55 * max(dot(n, Lm), 0.0));\n\n // Reflection off: the water shows only its own colour (and the sun's glint),\n // never the sky \u2014 not even the roughness fill above.\n vec3 col = (reflectionColor.x < 0.0 ? bodyLit + sss : mix(bodyLit + sss, sky, fres)) + spec;\n\n // Foam is a rough dielectric, so it takes the sky and the sun diffusely and\n // kills the reflection under it.\n vec3 foamLit = u_foamColor * (u_skyAmbient * u_ambientScale * 0.5 + sun * (0.3 + 0.7 * NdotL));\n col = mix(col, foamLit, saturate(foam));\n\n return col;\n}\n\n/** Fade into the sky the water is seen through. Same term as the terrain's,\n * and it needs to be stronger here: an ocean runs to the horizon in every\n * direction, so it is the only thing stopping the far field reading as a\n * painted plane. */\nvec3 oceanAerial(vec3 col, vec3 rd, float dist){\n float f = 1.0 - exp(-u_fogDensity * dist);\n if (f < 0.002) return col;\n return mix(col, skyRadiance(rd) * u_skyBrightness, f);\n}\n";
|
|
48
48
|
/** Height field only — what a vertex stage needs. */
|
|
49
49
|
export declare const oceanField: string;
|
|
50
50
|
/** The whole model. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oceanCore.glsl.d.ts","sourceRoot":"","sources":["../../../src/shaders/glsl/oceanCore.glsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;iEACiE;AACjE,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"oceanCore.glsl.d.ts","sourceRoot":"","sources":["../../../src/shaders/glsl/oceanCore.glsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;iEACiE;AACjE,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,eAAO,MAAM,aAAa,o2FAqEzB,CAAC;AAEF,eAAO,MAAM,UAAU,gjJAoHtB,CAAC;AAEF,eAAO,MAAM,UAAU,opWAwOtB,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,UAAU,QAAyC,CAAC;AAEjE,uBAAuB;AACvB,eAAO,MAAM,SAAS,QAAqD,CAAC"}
|
|
@@ -52,6 +52,16 @@ uniform vec4 u_waveB[MAX_WAVES];
|
|
|
52
52
|
uniform float u_waveCount;
|
|
53
53
|
|
|
54
54
|
uniform float u_time;
|
|
55
|
+
// The current (config flowSpeed / flowDirection). Offsets are the distance the
|
|
56
|
+
// water has carried the field so far, integrated on the CPU (offset += v * dt),
|
|
57
|
+
// never speed * time: animating the speed must not make the pattern jump.
|
|
58
|
+
// u_flowOffset is in the field's own frame (a body's local metres, the world on
|
|
59
|
+
// the world host); u_flowOffsetW and u_flowDirW are in world XZ for the
|
|
60
|
+
// per-fragment ripple. All zero for still water.
|
|
61
|
+
uniform vec2 u_flowOffset;
|
|
62
|
+
uniform vec2 u_flowOffsetW;
|
|
63
|
+
uniform vec2 u_flowDirW;
|
|
64
|
+
uniform float u_flowStretch;
|
|
55
65
|
uniform float u_waterLevel;
|
|
56
66
|
uniform float u_choppiness;
|
|
57
67
|
uniform float u_amplitudeScale;
|
|
@@ -89,6 +99,11 @@ uniform float u_receiveShadows;
|
|
|
89
99
|
// Filled by applySunUniforms and applyTerrainAmbient, exactly as on the terrain
|
|
90
100
|
// material - one atmosphere for the sky, the clouds, the ground and the water.
|
|
91
101
|
uniform vec3 u_skyAmbient;
|
|
102
|
+
/** How bright the sky dome is drawn (skyBrightnessForSunElevation): 1 by day,
|
|
103
|
+
* 0.08 at night. The analytic skyRadiance never goes dark on its own (Preetham's
|
|
104
|
+
* Rayleigh term lights a sun-less sky in full daylight blue), so every place
|
|
105
|
+
* the water reads the sky scales by this - or a pool glows blue at midnight. */
|
|
106
|
+
uniform float u_skyBrightness;
|
|
92
107
|
uniform vec3 u_groundAmbient;
|
|
93
108
|
|
|
94
109
|
// Moonlight (useOceanMaterial, from the same moon as the key light and the
|
|
@@ -277,12 +292,25 @@ vec3 oceanDetailNormal(vec3 n, vec3 wp, float fade){
|
|
|
277
292
|
float amt = u_detailStrength * fade;
|
|
278
293
|
if (amt <= 0.001) return n;
|
|
279
294
|
|
|
280
|
-
|
|
295
|
+
// Running water: the ripple is carried downstream with the current and
|
|
296
|
+
// stretched along it, into the streaks that say "flowing" rather than
|
|
297
|
+
// "wind-blown". Sampled in the flow's frame (along, across) with the along axis
|
|
298
|
+
// compressed; the gradient is mapped back with the transpose (chain rule), so
|
|
299
|
+
// the perturbation stays in world XZ. Still water skips it (uniform branch).
|
|
300
|
+
vec2 xz = wp.xz - u_flowOffsetW;
|
|
301
|
+
float along = 1.0 / (1.0 + u_flowStretch);
|
|
302
|
+
vec2 fd = u_flowDirW;
|
|
303
|
+
vec2 fn = vec2(-fd.y, fd.x);
|
|
304
|
+
bool flowing = u_flowStretch > 0.0;
|
|
305
|
+
vec2 q = flowing ? vec2(dot(xz, fd) * along, dot(xz, fn)) : xz;
|
|
306
|
+
|
|
307
|
+
vec2 p = q * u_detailScale;
|
|
281
308
|
vec2 drift = vec2(u_time * 0.06, u_time * 0.043);
|
|
282
309
|
|
|
283
310
|
vec3 a = oNoised(p + drift);
|
|
284
311
|
vec3 b = oNoised(p * 2.17 - drift * 1.6);
|
|
285
312
|
vec2 g = a.yz + b.yz * 0.5;
|
|
313
|
+
if (flowing) g = fd * (g.x * along) + fn * g.y;
|
|
286
314
|
|
|
287
315
|
// Perturb in the surface plane, so a steep wave face keeps its own orientation
|
|
288
316
|
// and only gains texture.
|
|
@@ -346,7 +374,7 @@ vec3 oceanLight(
|
|
|
346
374
|
vec3 wp, vec3 n, vec3 viewDir, // viewDir points FROM the camera TO the surface
|
|
347
375
|
float foam, float relHeight, float shadow, float depthFactor,
|
|
348
376
|
float roughnessBoost, // specular antialiasing, see the caller
|
|
349
|
-
vec3 reflectionColor
|
|
377
|
+
vec3 reflectionColor // 0: the sky; negative: no reflection (off)
|
|
350
378
|
){
|
|
351
379
|
vec3 V = -viewDir;
|
|
352
380
|
vec3 L = normalize(u_sunDir);
|
|
@@ -359,7 +387,7 @@ vec3 oceanLight(
|
|
|
359
387
|
// of dirt across the brightest part of the water.
|
|
360
388
|
vec3 R = reflect(viewDir, n);
|
|
361
389
|
R.y = max(R.y, 0.015);
|
|
362
|
-
vec3 sky = length(reflectionColor) > 0.0 ? reflectionColor : skyRadiance(R);
|
|
390
|
+
vec3 sky = length(reflectionColor) > 0.0 ? reflectionColor : skyRadiance(R) * u_skyBrightness;
|
|
363
391
|
|
|
364
392
|
// Prefilter the reflection by the same roughness the specular lobe uses.
|
|
365
393
|
// Without this the specular is filtered and the reflection is not, and on
|
|
@@ -412,7 +440,9 @@ vec3 oceanLight(
|
|
|
412
440
|
spec += u_moonColor * ggxM * u_specular * fres;
|
|
413
441
|
bodyLit += body * u_moonColor * (0.25 + 0.55 * max(dot(n, Lm), 0.0));
|
|
414
442
|
|
|
415
|
-
|
|
443
|
+
// Reflection off: the water shows only its own colour (and the sun's glint),
|
|
444
|
+
// never the sky — not even the roughness fill above.
|
|
445
|
+
vec3 col = (reflectionColor.x < 0.0 ? bodyLit + sss : mix(bodyLit + sss, sky, fres)) + spec;
|
|
416
446
|
|
|
417
447
|
// Foam is a rough dielectric, so it takes the sky and the sun diffusely and
|
|
418
448
|
// kills the reflection under it.
|
|
@@ -429,7 +459,7 @@ vec3 oceanLight(
|
|
|
429
459
|
vec3 oceanAerial(vec3 col, vec3 rd, float dist){
|
|
430
460
|
float f = 1.0 - exp(-u_fogDensity * dist);
|
|
431
461
|
if (f < 0.002) return col;
|
|
432
|
-
return mix(col, skyRadiance(rd), f);
|
|
462
|
+
return mix(col, skyRadiance(rd) * u_skyBrightness, f);
|
|
433
463
|
}
|
|
434
464
|
`;
|
|
435
465
|
/** Height field only — what a vertex stage needs. */
|
|
@@ -11,6 +11,7 @@ export declare const oceanMaterialDefaults: {
|
|
|
11
11
|
u_skyAmbient: THREE.Color;
|
|
12
12
|
u_groundAmbient: THREE.Color;
|
|
13
13
|
u_sunIntensity: number;
|
|
14
|
+
u_skyBrightness: number;
|
|
14
15
|
u_moonDir: THREE.Vector3;
|
|
15
16
|
u_moonColor: THREE.Color;
|
|
16
17
|
u_turbidity: number;
|
|
@@ -44,11 +45,22 @@ export declare const oceanMaterialDefaults: {
|
|
|
44
45
|
u_waveB: THREE.Vector4[];
|
|
45
46
|
u_waveCount: number;
|
|
46
47
|
u_time: number;
|
|
48
|
+
u_flowOffset: THREE.Vector2;
|
|
49
|
+
u_flowOffsetW: THREE.Vector2;
|
|
50
|
+
u_flowDirW: THREE.Vector2;
|
|
51
|
+
u_flowStretch: number;
|
|
47
52
|
u_waterLevel: number;
|
|
48
53
|
u_choppiness: number;
|
|
49
54
|
u_amplitudeScale: number;
|
|
50
55
|
u_bodyHalf: THREE.Vector2;
|
|
51
56
|
u_edgeFade: number;
|
|
57
|
+
u_bodyScale: THREE.Vector3;
|
|
58
|
+
u_reflectionMode: number;
|
|
59
|
+
u_reflectionMap: THREE.Texture | null;
|
|
60
|
+
u_reflectionMatrix: THREE.Matrix4;
|
|
61
|
+
u_reflectionCube: THREE.Texture | null;
|
|
62
|
+
u_probePos: THREE.Vector3;
|
|
63
|
+
u_probeRadius: number;
|
|
52
64
|
u_deepColor: THREE.Color;
|
|
53
65
|
u_shallowColor: THREE.Color;
|
|
54
66
|
u_foamColor: THREE.Color;
|
|
@@ -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;
|
|
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;AA6T9D,MAAM,WAAW,qBAAqB;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAA;CAChC;AAMD;yEACyE;AACzE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoBL,KAAK,CAAC,OAAO,GAAG,IAAI;;sBAEnB,KAAK,CAAC,OAAO,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CjD,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"}
|
|
@@ -3,6 +3,7 @@ import { extend } from '@react-three/fiber';
|
|
|
3
3
|
import { skyLib } from '../glsl/cloudCore.glsl.js';
|
|
4
4
|
import { oceanFull, MAX_WAVES } from '../glsl/oceanCore.glsl.js';
|
|
5
5
|
import { terrainFieldOnly } from '../glsl/terrainCore.glsl.js';
|
|
6
|
+
import { waterReflectionGlsl } from '../../utils/waterReflection.js';
|
|
6
7
|
/**
|
|
7
8
|
* The water surface material. Used by both hosts — the world clipmap and a
|
|
8
9
|
* placed body — and by all four water types, which differ in the spectrum the
|
|
@@ -54,6 +55,12 @@ ${oceanFull}
|
|
|
54
55
|
${terrainFieldOnly}
|
|
55
56
|
#endif
|
|
56
57
|
uniform float u_shoreDepth;
|
|
58
|
+
/** World scale of a placed body's transform. The body is a unit-ish grid sized
|
|
59
|
+
* by its transform, but the waves are metres: the field is evaluated in local
|
|
60
|
+
* x scale (world metres), and the displacement divided back out, so a pool
|
|
61
|
+
* scaled x8 gets the same ripples as a pool built 8 m wide. (1,1,1) on the
|
|
62
|
+
* world host. */
|
|
63
|
+
uniform vec3 u_bodyScale;
|
|
57
64
|
|
|
58
65
|
/** World size of this vertex's cell. Per-vertex so one material serves every
|
|
59
66
|
* clipmap ring, and a placed body sets it from its own grid. */
|
|
@@ -87,7 +94,16 @@ void main(){
|
|
|
87
94
|
// The LOD cell morphs with the vertex, so a ring's outer edge samples at
|
|
88
95
|
// exactly the next ring's cell size and both sides of the seam fade the same
|
|
89
96
|
// components by the same amount.
|
|
90
|
-
|
|
97
|
+
bool isBody = u_bodyHalf.x > 0.0;
|
|
98
|
+
float bodyCell = isBody ? max(u_bodyScale.x, u_bodyScale.z) : 1.0;
|
|
99
|
+
float cellLod = aCell * bodyCell * (1.0 + aMorph);
|
|
100
|
+
// ...and by what the SCREEN can carry. The grid LOD keeps every wave the mesh
|
|
101
|
+
// can draw, but from far away (or high above) a 4 m wave on a 1 m grid is two
|
|
102
|
+
// pixels wide: its crests land on different pixels every frame and the water
|
|
103
|
+
// shimmers in bright dashes. Treat the pixel footprint (x2) as a cell size, so
|
|
104
|
+
// components fade out as they approach ~3 px and distant water reads calm.
|
|
105
|
+
// The per-fragment ripple already fades the same way (oceanDetailFade).
|
|
106
|
+
cellLod = max(cellLod, distance(worldFlat.xyz, cameraPosition) * u_pixelScale * 2.0);
|
|
91
107
|
|
|
92
108
|
float edge = oceanEdgeMask(local);
|
|
93
109
|
|
|
@@ -95,8 +111,7 @@ void main(){
|
|
|
95
111
|
// because its clipmap slides under a camera that moves through the world and
|
|
96
112
|
// the sea must not slide with it. A placed body is evaluated in its OWN space,
|
|
97
113
|
// so its waves rotate with it and stay inside its rim.
|
|
98
|
-
|
|
99
|
-
vec2 fieldXZ = isBody ? local : wxz;
|
|
114
|
+
vec2 fieldXZ = isBody ? local * u_bodyScale.xz : wxz;
|
|
100
115
|
|
|
101
116
|
// Water depth from the terrain height field under this vertex.
|
|
102
117
|
//
|
|
@@ -123,10 +138,16 @@ void main(){
|
|
|
123
138
|
}
|
|
124
139
|
#endif
|
|
125
140
|
|
|
141
|
+
// The current carries the whole wave field (and its foam) downstream: sample it
|
|
142
|
+
// where this water was u_flowOffset metres ago. Zero for still water.
|
|
143
|
+
vec2 fieldP = fieldXZ - u_flowOffset;
|
|
144
|
+
|
|
126
145
|
vec3 disp; vec3 nrm; float jac; float rel;
|
|
127
|
-
oceanWaveSum(
|
|
146
|
+
oceanWaveSum(fieldP, cellLod, u_amplitudeScale * edge * shoal, disp, nrm, jac, rel);
|
|
128
147
|
|
|
129
|
-
vFoam = oceanFoam(jac, rel, vec3(
|
|
148
|
+
vFoam = oceanFoam(jac, rel, vec3(fieldP.x, 0.0, fieldP.y));
|
|
149
|
+
// Metres back into the body's local units (the transform scales them up again).
|
|
150
|
+
if (isBody) disp /= u_bodyScale;
|
|
130
151
|
vRelHeight = rel;
|
|
131
152
|
|
|
132
153
|
// 1 in open water, ramping to 0 as the bottom comes up (shallow colour). Open
|
|
@@ -150,7 +171,11 @@ void main(){
|
|
|
150
171
|
}
|
|
151
172
|
|
|
152
173
|
vec3 world = (modelMatrix * vec4(transformed, 1.0)).xyz;
|
|
153
|
-
|
|
174
|
+
// The wave normal is already in metres; on a scaled body only the transform's
|
|
175
|
+
// rotation may touch it (M = R*S, so M * (n / S) = R * n).
|
|
176
|
+
vec3 nLocal = normalize(mix(vec3(0.0, 1.0, 0.0), nrm, edge));
|
|
177
|
+
if (isBody) nLocal /= u_bodyScale;
|
|
178
|
+
vNormal_ = normalize(mat3(modelMatrix) * nLocal);
|
|
154
179
|
|
|
155
180
|
vWorld = world;
|
|
156
181
|
vDist = distance(world, cameraPosition);
|
|
@@ -193,6 +218,8 @@ varying float vTerrainShadow;
|
|
|
193
218
|
uniform float u_shoreDepth;
|
|
194
219
|
uniform float u_shoreFoam;
|
|
195
220
|
|
|
221
|
+
${waterReflectionGlsl}
|
|
222
|
+
|
|
196
223
|
void main(){
|
|
197
224
|
vec3 viewDir = normalize(vWorld - cameraPosition);
|
|
198
225
|
|
|
@@ -235,7 +262,15 @@ void main(){
|
|
|
235
262
|
foam = max(foam, saturate(band * (0.45 + 0.55 * wash) * u_shoreFoam));
|
|
236
263
|
}
|
|
237
264
|
|
|
238
|
-
|
|
265
|
+
// What the surface reflects: the one planar pass when this surface won it
|
|
266
|
+
// this frame, the sky it is drawn under otherwise, a flat fill when off. See
|
|
267
|
+
// utils/waterReflection.ts. The detail normal bends the planar lookup, which
|
|
268
|
+
// is what makes a mirrored building wobble with the ripples.
|
|
269
|
+
vec3 reflectionColor = vec3(0.0);
|
|
270
|
+
if (u_reflectionMode == 2) reflectionColor = max(waterPlanarReflection(vWorld, n, 0.045), vec3(1e-4));
|
|
271
|
+
else if (u_reflectionMode == 3) reflectionColor = max(waterProbeReflection(vWorld, viewDir, n, 0.15), vec3(1e-4));
|
|
272
|
+
else if (u_reflectionMode == 0) reflectionColor = vec3(-1.0); // off: no reflection at all (oceanLight)
|
|
273
|
+
vec3 col = oceanLight(vWorld, n, viewDir, foam, vRelHeight, sceneShadow, vDepthFactor, roughAA, reflectionColor);
|
|
239
274
|
col = oceanAerial(col, viewDir, vDist);
|
|
240
275
|
col *= u_exposure;
|
|
241
276
|
|
|
@@ -286,11 +321,23 @@ export const oceanMaterialDefaults = {
|
|
|
286
321
|
u_waveB: emptyWaveTable(),
|
|
287
322
|
u_waveCount: 0,
|
|
288
323
|
u_time: 0,
|
|
324
|
+
u_flowOffset: new THREE.Vector2(0, 0),
|
|
325
|
+
u_flowOffsetW: new THREE.Vector2(0, 0),
|
|
326
|
+
u_flowDirW: new THREE.Vector2(1, 0),
|
|
327
|
+
u_flowStretch: 0,
|
|
289
328
|
u_waterLevel: 0,
|
|
290
329
|
u_choppiness: 0.85,
|
|
291
330
|
u_amplitudeScale: 1,
|
|
292
331
|
u_bodyHalf: new THREE.Vector2(0, 0),
|
|
293
332
|
u_edgeFade: 0.15,
|
|
333
|
+
u_bodyScale: new THREE.Vector3(1, 1, 1),
|
|
334
|
+
// Reflection (utils/waterReflection.ts): 1 = the sky until a pass is handed over.
|
|
335
|
+
u_reflectionMode: 1,
|
|
336
|
+
u_reflectionMap: null,
|
|
337
|
+
u_reflectionMatrix: new THREE.Matrix4(),
|
|
338
|
+
u_reflectionCube: null,
|
|
339
|
+
u_probePos: new THREE.Vector3(),
|
|
340
|
+
u_probeRadius: 0,
|
|
294
341
|
u_deepColor: new THREE.Color('#052539'),
|
|
295
342
|
u_shallowColor: new THREE.Color('#1b7f8c'),
|
|
296
343
|
u_foamColor: new THREE.Color('#eef6f8'),
|
|
@@ -324,6 +371,7 @@ export const oceanMaterialDefaults = {
|
|
|
324
371
|
u_skyAmbient: new THREE.Color(0.6, 0.9, 1.6),
|
|
325
372
|
u_groundAmbient: new THREE.Color(0.45, 0.42, 0.37),
|
|
326
373
|
u_sunIntensity: 1,
|
|
374
|
+
u_skyBrightness: 1,
|
|
327
375
|
// Moonlight, set by useOceanMaterial; black = no moon.
|
|
328
376
|
u_moonDir: new THREE.Vector3(0, 1, 0),
|
|
329
377
|
u_moonColor: new THREE.Color(0, 0, 0),
|
|
@@ -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;AA6S9D,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"}
|