@call-me-sensei/toonlab 0.3.0 → 0.4.19
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/README.md +549 -184
- package/agents/README.md +59 -0
- package/agents/references/anime-art-direction.md +24 -0
- package/agents/references/asset-sourcing-policy.md +23 -0
- package/agents/references/custom-gap-report.md +16 -0
- package/agents/references/geology-playbook.md +118 -0
- package/agents/references/mcp-asset-discovery.md +104 -0
- package/agents/references/runtime-entry-points.md +174 -0
- package/agents/references/style-bundles.md +71 -0
- package/agents/skills/claude/asset-sourcing/SKILL.md +275 -0
- package/agents/skills/claude/environment/SKILL.md +59 -0
- package/agents/skills/claude/game-dev/SKILL.md +100 -0
- package/agents/skills/claude/karst-cliff-construction/SKILL.md +258 -0
- package/agents/skills/claude/outdoor-world/SKILL.md +492 -0
- package/agents/skills/claude/outdoor-world/references/coastal-landform-formation.md +100 -0
- package/agents/skills/claude/post-processing/SKILL.md +44 -0
- package/agents/skills/claude/rock-ground-shaders/SKILL.md +118 -0
- package/agents/skills/claude/rockgen/SKILL.md +30 -0
- package/agents/skills/claude/scene-style-application/SKILL.md +74 -0
- package/agents/skills/claude/style-presets/SKILL.md +101 -0
- package/agents/skills/claude/toon-shading/SKILL.md +44 -0
- package/agents/skills/claude/vegetation-sky/SKILL.md +167 -0
- package/agents/skills/claude/visual-verification/SKILL.md +136 -0
- package/agents/skills/claude/water/SKILL.md +105 -0
- package/agents/skills/codex/asset-sourcing/SKILL.md +275 -0
- package/agents/skills/codex/environment/SKILL.md +59 -0
- package/agents/skills/codex/game-dev/SKILL.md +100 -0
- package/agents/skills/codex/karst-cliff-construction/SKILL.md +258 -0
- package/agents/skills/codex/outdoor-world/SKILL.md +492 -0
- package/agents/skills/codex/outdoor-world/references/coastal-landform-formation.md +100 -0
- package/agents/skills/codex/post-processing/SKILL.md +44 -0
- package/agents/skills/codex/rock-ground-shaders/SKILL.md +118 -0
- package/agents/skills/codex/rockgen/SKILL.md +30 -0
- package/agents/skills/codex/scene-style-application/SKILL.md +74 -0
- package/agents/skills/codex/style-presets/SKILL.md +101 -0
- package/agents/skills/codex/toon-shading/SKILL.md +44 -0
- package/agents/skills/codex/vegetation-sky/SKILL.md +167 -0
- package/agents/skills/codex/visual-verification/SKILL.md +136 -0
- package/agents/skills/codex/water/SKILL.md +105 -0
- package/cli/toonlab.mjs +52 -0
- package/compose.yaml +20 -0
- package/database/apply-sql.mjs +141 -0
- package/database/client.mjs +39 -0
- package/database/creation-tags.mjs +23 -0
- package/database/env.mjs +16 -0
- package/database/generation-service.mjs +314 -0
- package/database/migrations/0001_local_workspace.sql +120 -0
- package/database/migrations/0002_file_ownership.sql +11 -0
- package/database/migrations/0003_remove_autosaves_from_library.sql +7 -0
- package/database/migrations/0004_catalog_asset_packs.sql +39 -0
- package/database/migrations/0005_creation_tag_discovery.sql +1 -0
- package/database/migrations/0006_normalize_creation_tags.sql +28 -0
- package/database/providers.mjs +465 -0
- package/database/repository.mjs +625 -0
- package/database/seeds/catalog/0001_empty_official_catalog.sql +4 -0
- package/database/seeds/catalog/0002_2026-08.sql +19454 -0
- package/mcp/lab-management.mjs +629 -0
- package/mcp/public-catalog.mjs +168 -0
- package/mcp/server.mjs +1026 -63
- package/mcp/vite-plugin.mjs +443 -26
- package/mcp/workspace.mjs +26 -1
- package/package.json +312 -45
- package/scripts/generate-catalog-seed.mjs +297 -0
- package/scripts/setup-local.mjs +128 -0
- package/src/agents/index.js +7 -0
- package/src/agents/sceneStyleOperations.js +169 -0
- package/src/asset-policy/catalogLicenses.js +44 -0
- package/src/asset-policy/index.js +315 -0
- package/src/assetlib/assetRef.js +1 -1
- package/src/assetlib/galleryMaterialFamily.js +165 -0
- package/src/assetlib/index.js +6 -2
- package/src/assetlib/plateau.js +188 -0
- package/src/assetlib/plateauLandmarks.js +144 -0
- package/src/assetlib/plateauViewer.js +348 -0
- package/src/assetlib/sources.js +16 -2
- package/src/catalog/manifest.js +11 -1
- package/src/catalog/officialCatalog.js +4 -0
- package/src/catalog/officialCatalogAssetRuntime.js +313 -0
- package/src/catalog/officialCatalogLod.js +150 -0
- package/src/catalog/officialCatalogPlacement.js +228 -0
- package/src/catalog/officialCatalogProvider.js +334 -0
- package/src/character/animationRetarget.js +1082 -0
- package/src/character/characterRuntime.js +376 -0
- package/src/character/groundStabilizer.js +137 -0
- package/src/character/index.js +8 -0
- package/src/character/locomotionActions.js +74 -0
- package/src/character/locomotionStateMachine.js +241 -0
- package/src/character/mannequinAsset.js +15 -0
- package/src/character/mannequinAssetUrl.browser.js +4 -0
- package/src/character/mannequinAssetUrl.node.js +3 -0
- package/src/character/modelLoader.js +92 -12
- package/src/character/walkableCharacterRuntime.js +284 -0
- package/src/character/waterInteractionController.js +217 -0
- package/src/cloud/ambientSkyBaker.js +248 -0
- package/src/cloud/cloudLighting.js +1114 -0
- package/src/cloud/cloudParams.js +819 -0
- package/src/cloud/cloudReprojection.js +563 -0
- package/src/cloud/cloudStyle.js +780 -0
- package/src/cloud/cloudStyleSnapshots.js +387 -0
- package/src/cloud/cloudVolume.js +1903 -0
- package/src/cloud/heroCloudRecipe.js +404 -0
- package/src/cloud/index.js +42 -0
- package/src/cloud/noise/baseShapeVolume.js +331 -0
- package/src/cloud/noise/cirrusMap.js +131 -0
- package/src/cloud/noise/curlNoise.js +289 -0
- package/src/cloud/noise/erosionVolume.js +188 -0
- package/src/cloud/noise/noiseVolume.js +202 -0
- package/src/cloud/noise/periodicNoise3.js +295 -0
- package/src/cloud/noise/weatherMap.js +470 -0
- package/src/cloud/paramSchema.js +458 -0
- package/src/collisionMetadata.js +320 -0
- package/src/core/systemStylePolicy.js +32 -0
- package/src/environment/dayCurves.js +146 -0
- package/src/environment/environmentGroundFieldPass.js +354 -0
- package/src/environment/environmentMaterialAdapter.js +114 -6
- package/src/environment/environmentPresets.js +396 -90
- package/src/environment/environmentRigs.js +17 -2
- package/src/environment/environmentSettings.js +37 -1
- package/src/environment/environmentShaderMaterials.js +37 -6
- package/src/environment/environmentState.js +133 -0
- package/src/environment/environmentSunShadowPass.js +357 -6
- package/src/environment/environmentTextureResolver.js +7 -0
- package/src/environment/index.js +51 -0
- package/src/environment/manufacturedMaterialContract.js +837 -0
- package/src/environment/manufacturedReflectionProvider.js +114 -0
- package/src/environment/scanAssetStylize.js +4 -4
- package/src/environment/surfaceMaterialModes.js +71 -0
- package/src/environment/toonLabEnvironmentMaterials.js +353 -0
- package/src/environment/toonLabMaterialPassCoupling.js +347 -0
- package/src/environment/toonLabNormalIntegration.js +171 -0
- package/src/environment/toonLabRockMaterialResolver.js +592 -0
- package/src/environment/toonLabSourceDefaultLit.js +444 -0
- package/src/environment/toonLabSourceLibrary.js +762 -0
- package/src/environment/toonLabSourceMaterials.js +3718 -0
- package/src/environment/toonLabSourceSubsurfaceLighting.js +415 -0
- package/src/environment/toonLabSourceTemporal.js +717 -0
- package/src/environment/toonLabSurfaceLighting.js +364 -0
- package/src/environment/toonLabTextureReadiness.js +105 -0
- package/src/environment/toonLabTreeMaterials.js +450 -0
- package/src/environment/transparentMaterialProfile.js +87 -0
- package/src/environment/urbanPropMaterial.js +2874 -0
- package/src/ground-shader/groundPrintLayer.js +375 -0
- package/src/ground-shader/groundShaderMaterial.js +851 -0
- package/src/ground-shader/groundShaderSettings.js +468 -0
- package/src/ground-shader/index.js +3 -0
- package/src/index.js +52 -22
- package/src/lighting/callMeSenseiLightingContract.js +163 -0
- package/src/lighting/index.js +14 -7
- package/src/lighting/lightingCapabilities.js +2 -2
- package/src/lighting/lightingPresets.js +6 -3
- package/src/lighting/lightingStyle.js +41 -6
- package/src/lighting/lightingSystem.js +140 -1
- package/src/lighting/{unrealExport.js → toonLabExport.js} +40 -41
- package/src/post/postProcessing.js +71 -12
- package/src/react/index.js +66 -0
- package/src/renderer/index.js +9 -0
- package/src/renderer/rendererConfiguration.js +250 -0
- package/src/rock-shader/index.js +3 -0
- package/src/rock-shader/rockMaterial.js +1843 -0
- package/src/rock-shader/rockShaderRuntime.js +494 -0
- package/src/rock-shader/rockShaderSettings.js +869 -0
- package/src/rockgen/export/glbExport.js +104 -14
- package/src/rockgen/index.js +4 -3
- package/src/rockgen/lod/index.js +6 -0
- package/src/rockgen/lod/rockLodMetrics.js +168 -0
- package/src/rockgen/lod/rockLodPlanner.js +372 -0
- package/src/rockgen/lod/rockLodPolicy.js +235 -0
- package/src/rockgen/lod/rockLodRuntime.js +124 -0
- package/src/rockgen/lod/rockLodSimplifier.js +173 -0
- package/src/rockgen/lod/rockLodValidation.js +113 -0
- package/src/rockgen/mesh/meshAttributes.js +17 -0
- package/src/rockgen/mesh/meshDocument.js +6 -0
- package/src/rockgen/rockDocument.js +352 -9
- package/src/rockgen/rockgenPresets.js +114 -13
- package/src/rockgen/rockgenSettings.js +62 -11
- package/src/runtime/index.js +14 -0
- package/src/runtime/sceneCollisionRuntime.js +317 -0
- package/src/runtime/sceneSurfaceRuntime.js +451 -0
- package/src/runtime/sceneUpdateScheduler.js +203 -0
- package/src/shaders-tsl/anime.js +9 -2
- package/src/shaders-tsl/chunks/environment-ground-field.js +174 -0
- package/src/shaders-tsl/chunks/environment-state.js +79 -0
- package/src/shaders-tsl/chunks/environment-sun-shadow.js +99 -32
- package/src/shaders-tsl/chunks/normalized-hue.js +41 -0
- package/src/shaders-tsl/chunks/pass-depth-color.js +4 -2
- package/src/shaders-tsl/chunks/scene-depth-color-pass.js +273 -0
- package/src/shaders-tsl/chunks/vegetation-style.js +116 -8
- package/src/shaders-tsl/chunks/water-color.js +19 -5
- package/src/shaders-tsl/chunks/water-shore-state.js +8 -1
- package/src/shaders-tsl/chunks/world-noise.js +30 -0
- package/src/shaders-tsl/environment.js +123 -17
- package/src/shaders-tsl/flower.js +51 -8
- package/src/shaders-tsl/grass.js +194 -29
- package/src/shaders-tsl/post-composite.js +83 -2
- package/src/shaders-tsl/tree-leaf.js +107 -16
- package/src/shaders-tsl/water-breaker.js +18 -4
- package/src/shaders-tsl/water.js +43 -3
- package/src/shaders-tsl/woody-surface.js +59 -7
- package/src/sky/atmosphereDome.js +193 -0
- package/src/sky/atmosphereParams.js +396 -0
- package/src/sky/atmosphereScattering.js +593 -0
- package/src/sky/atmosphereSky.js +371 -0
- package/src/sky/cloudShadow.js +355 -0
- package/src/sky/godRays.js +257 -0
- package/src/sky/index.js +55 -1
- package/src/sky/nightSky.js +1190 -0
- package/src/sky/renderLayers.js +120 -0
- package/src/sky/skyColor.js +582 -0
- package/src/sky/skyDayCycle.js +244 -0
- package/src/sky/skyParams.js +661 -0
- package/src/sky/skyPresets.js +772 -0
- package/src/sky/skyQualityTiers.js +383 -0
- package/src/sky/skyShaderSettings.js +699 -0
- package/src/sky/skyStyleSnapshots.js +211 -0
- package/src/sky/skySystem.js +1438 -0
- package/src/sky/skyTimeKeyframes.js +361 -0
- package/src/sky/stylizedSky.js +405 -116
- package/src/sky/sunDriver.js +499 -0
- package/src/sky/timeOfDay.js +335 -0
- package/src/styles/animeGameProfile.js +44 -0
- package/src/styles/index.js +134 -0
- package/src/styles/manufacturedStyleLabeling.js +204 -0
- package/src/styles/sceneLayerDocuments.js +185 -0
- package/src/styles/sceneLookComposition.js +156 -0
- package/src/styles/sceneQualityApplication.js +152 -0
- package/src/styles/sceneQualityProfiles.js +268 -0
- package/src/styles/sceneStyleAudit.js +512 -0
- package/src/styles/sceneStyleRuntime.js +876 -0
- package/src/styles/styleAdapters.js +166 -0
- package/src/styles/styleApplication.js +369 -0
- package/src/styles/styleBundle.js +444 -91
- package/src/styles/styleBundleProvider.js +83 -0
- package/src/styles/styleDomains.js +21 -0
- package/src/styles/styleInspector.js +262 -0
- package/src/styles/styleMaterialContract.js +375 -0
- package/src/styles/styleMetadata.js +73 -0
- package/src/styles/styleTargetDiscovery.js +162 -0
- package/src/styles/styleTargetLabels.js +206 -0
- package/src/styles/styleTargetMaterialCoverage.js +137 -0
- package/src/styles/styleTransaction.js +272 -0
- package/src/texgen/textureGenerators.js +21 -5
- package/src/toon/toonSettings.js +4 -0
- package/src/vegetation/branchTree.js +302 -0
- package/src/vegetation/callMeSenseiGrass.js +183 -0
- package/src/vegetation/compiledTree.js +506 -0
- package/src/vegetation/contactShadowField.js +107 -0
- package/src/vegetation/flowerSpecies.js +10 -2
- package/src/vegetation/grass.js +13 -0
- package/src/vegetation/grassClump.js +1179 -0
- package/src/vegetation/importedVegetationMaterial.js +183 -0
- package/src/vegetation/index.js +15 -1
- package/src/vegetation/legacyTreePresets.js +120 -0
- package/src/vegetation/scatter.js +322 -3
- package/src/vegetation/stylizedBush.js +14 -0
- package/src/vegetation/stylizedFlower.js +31 -0
- package/src/vegetation/stylizedFlowers.js +59 -7
- package/src/vegetation/stylizedForest.js +455 -147
- package/src/vegetation/stylizedGrass.js +188 -24
- package/src/vegetation/stylizedTree.js +378 -46
- package/src/vegetation/stylizedTreeFoliage.js +889 -38
- package/src/vegetation/stylizedUnderstory.js +230 -0
- package/src/vegetation/treeExport.js +262 -47
- package/src/vegetation/treeSurfaceTextures.js +337 -0
- package/src/vegetation/vegetationShaders.js +617 -28
- package/src/version.js +3 -0
- package/src/water/water.js +2 -0
- package/src/water/waterBreakerSystem.js +2 -0
- package/src/water/waterCurrentField.js +1 -0
- package/src/water/waterMaterial.js +3 -0
- package/src/water/waterRain.js +2 -0
- package/src/water/waterScenePasses.js +170 -7
- package/src/water/waterSettings.js +235 -43
- package/src/water/waterShoreMaterial.js +16 -2
- package/src/water/waterShoreStateField.js +1 -1
- package/src/water/waterSplashSystem.js +2 -0
- package/src/water/waterStageSettings.js +60 -0
- package/src/water/waterSurface.js +144 -4
- package/src/water/waterUnderwaterAtmosphere.js +288 -0
- package/src/water/waterVegetation.js +20 -4
- package/src/worldCollision.js +64 -9
- package/types/agents/index.d.ts +1 -0
- package/types/agents/sceneStyleOperations.d.ts +484 -0
- package/types/asset-policy/catalogLicenses.d.ts +5 -0
- package/types/asset-policy/index.d.ts +18 -0
- package/types/assetlib/ambientcg.d.ts +81 -0
- package/types/assetlib/assetRef.d.ts +26 -0
- package/types/assetlib/galleryMaterialFamily.d.ts +13 -0
- package/types/assetlib/importedEntry.d.ts +18 -0
- package/types/assetlib/index.d.ts +16 -0
- package/types/assetlib/kaykit.d.ts +112 -0
- package/types/assetlib/kaykitStaticIndex.d.ts +38 -0
- package/types/assetlib/loadImported.d.ts +54 -0
- package/types/assetlib/opensource3d.d.ts +55 -0
- package/types/assetlib/plateau.d.ts +67 -0
- package/types/assetlib/plateauLandmarks.d.ts +238 -0
- package/types/assetlib/plateauViewer.d.ts +3 -0
- package/types/assetlib/polyhaven.d.ts +90 -0
- package/types/assetlib/polypizza.d.ts +10 -0
- package/types/assetlib/smithsonian.d.ts +9 -0
- package/types/assetlib/sources.d.ts +22 -0
- package/types/assetlib/zip.d.ts +8 -0
- package/types/catalog/manifest.d.ts +26 -0
- package/types/catalog/officialCatalog.d.ts +4 -0
- package/types/catalog/officialCatalogAssetRuntime.d.ts +2 -0
- package/types/catalog/officialCatalogLod.d.ts +5 -0
- package/types/catalog/officialCatalogPlacement.d.ts +49 -0
- package/types/catalog/officialCatalogProvider.d.ts +7 -0
- package/types/character/animationRetarget.d.ts +20 -0
- package/types/character/characterRig.d.ts +28 -0
- package/types/character/characterRuntime.d.ts +4 -0
- package/types/character/freestyleSwimClip.d.ts +5 -0
- package/types/character/groundStabilizer.d.ts +55 -0
- package/types/character/index.d.ts +10 -0
- package/types/character/locomotionActions.d.ts +4 -0
- package/types/character/locomotionStateMachine.d.ts +62 -0
- package/types/character/mannequinAsset.d.ts +12 -0
- package/types/character/mannequinAssetUrl.node.d.ts +1 -0
- package/types/character/modelLoader.d.ts +7 -0
- package/types/character/walkableCharacterRuntime.d.ts +343 -0
- package/types/character/waterInteractionController.d.ts +114 -0
- package/types/cloud/ambientSkyBaker.d.ts +18 -0
- package/types/cloud/cloudLighting.d.ts +38 -0
- package/types/cloud/cloudParams.d.ts +18 -0
- package/types/cloud/cloudReprojection.d.ts +15 -0
- package/types/cloud/cloudStyle.d.ts +1380 -0
- package/types/cloud/cloudStyleSnapshots.d.ts +10 -0
- package/types/cloud/cloudVolume.d.ts +43 -0
- package/types/cloud/heroCloudRecipe.d.ts +167 -0
- package/types/cloud/index.d.ts +12 -0
- package/types/cloud/noise/baseShapeVolume.d.ts +86 -0
- package/types/cloud/noise/cirrusMap.d.ts +24 -0
- package/types/cloud/noise/curlNoise.d.ts +106 -0
- package/types/cloud/noise/erosionVolume.d.ts +58 -0
- package/types/cloud/noise/noiseVolume.d.ts +63 -0
- package/types/cloud/noise/periodicNoise3.d.ts +75 -0
- package/types/cloud/noise/weatherMap.d.ts +227 -0
- package/types/cloud/paramSchema.d.ts +142 -0
- package/types/collisionMetadata.d.ts +11 -0
- package/types/core/generation.d.ts +95 -0
- package/types/core/materialRoles.d.ts +102 -0
- package/types/core/presetDocuments.d.ts +25 -0
- package/types/core/systemStylePolicy.d.ts +4 -0
- package/types/environment/dayCurves.d.ts +47 -0
- package/types/environment/environmentAmbientProbe.d.ts +2 -0
- package/types/environment/environmentGroundFieldPass.d.ts +2 -0
- package/types/environment/environmentMaterialAdapter.d.ts +42 -0
- package/types/environment/environmentMaterialClassifier.d.ts +26 -0
- package/types/environment/environmentPlanarReflection.d.ts +3 -0
- package/types/environment/environmentPresets.d.ts +171 -0
- package/types/environment/environmentRigs.d.ts +13 -0
- package/types/environment/environmentSettings.d.ts +161 -0
- package/types/environment/environmentShaderMaterials.d.ts +14 -0
- package/types/environment/environmentState.d.ts +6 -0
- package/types/environment/environmentSunShadowPass.d.ts +2 -0
- package/types/environment/environmentTextureResolver.d.ts +30 -0
- package/types/environment/environmentTimeOfDay.d.ts +25 -0
- package/types/environment/environmentVertexAo.d.ts +18 -0
- package/types/environment/index.d.ts +27 -0
- package/types/environment/manufacturedMaterialContract.d.ts +129 -0
- package/types/environment/manufacturedReflectionProvider.d.ts +3 -0
- package/types/environment/scanAssetStylize.d.ts +43 -0
- package/types/environment/surfaceMaterialModes.d.ts +14 -0
- package/types/environment/toonLabEnvironmentMaterials.d.ts +139 -0
- package/types/environment/toonLabMaterialPassCoupling.d.ts +7 -0
- package/types/environment/toonLabNormalIntegration.d.ts +29 -0
- package/types/environment/toonLabRockMaterialResolver.d.ts +270 -0
- package/types/environment/toonLabSourceDefaultLit.d.ts +136 -0
- package/types/environment/toonLabSourceLibrary.d.ts +19 -0
- package/types/environment/toonLabSourceMaterials.d.ts +14 -0
- package/types/environment/toonLabSourceSubsurfaceLighting.d.ts +85 -0
- package/types/environment/toonLabSourceTemporal.d.ts +20 -0
- package/types/environment/toonLabSurfaceLighting.d.ts +136 -0
- package/types/environment/toonLabTextureReadiness.d.ts +8 -0
- package/types/environment/toonLabTreeMaterials.d.ts +7 -0
- package/types/environment/transparentMaterialProfile.d.ts +76 -0
- package/types/environment/urbanPropMaterial.d.ts +25 -0
- package/types/ground-shader/groundPrintLayer.d.ts +4 -0
- package/types/ground-shader/groundShaderMaterial.d.ts +11 -0
- package/types/ground-shader/groundShaderSettings.d.ts +90 -0
- package/types/ground-shader/index.d.ts +3 -0
- package/types/index.d.ts +1502 -0
- package/types/lighting/callMeSenseiLightingContract.d.ts +14 -0
- package/types/lighting/colorIntensity.d.ts +44 -0
- package/types/lighting/index.d.ts +12 -0
- package/types/lighting/lightDescriptors.d.ts +803 -0
- package/types/lighting/lightingCapabilities.d.ts +85 -0
- package/types/lighting/lightingDocuments.d.ts +140 -0
- package/types/lighting/lightingFixtures.d.ts +171 -0
- package/types/lighting/lightingGenerator.d.ts +403 -0
- package/types/lighting/lightingPresets.d.ts +264 -0
- package/types/lighting/lightingRuntime.d.ts +401 -0
- package/types/lighting/lightingStyle.d.ts +156 -0
- package/types/lighting/lightingSystem.d.ts +433 -0
- package/types/lighting/toonLabExport.d.ts +46 -0
- package/types/lighting/utils.d.ts +18 -0
- package/types/loaders/index.d.ts +1 -0
- package/types/post/index.d.ts +2 -0
- package/types/post/postGenerator.d.ts +282 -0
- package/types/post/postProcessing.d.ts +16 -0
- package/types/react/index.d.ts +1765 -0
- package/types/renderer/index.d.ts +1 -0
- package/types/renderer/rendererConfiguration.d.ts +8 -0
- package/types/rock-shader/index.d.ts +3 -0
- package/types/rock-shader/rockMaterial.d.ts +18 -0
- package/types/rock-shader/rockShaderRuntime.d.ts +8 -0
- package/types/rock-shader/rockShaderSettings.d.ts +170 -0
- package/types/rockgen/export/glbExport.d.ts +58 -0
- package/types/rockgen/heightfield/heightfieldErosion.d.ts +10 -0
- package/types/rockgen/heightfield/heightfieldPatch.d.ts +15 -0
- package/types/rockgen/heightfield/stylizedErosionSim.d.ts +41 -0
- package/types/rockgen/index.d.ts +11 -0
- package/types/rockgen/lod/index.d.ts +6 -0
- package/types/rockgen/lod/rockLodMetrics.d.ts +62 -0
- package/types/rockgen/lod/rockLodPlanner.d.ts +86 -0
- package/types/rockgen/lod/rockLodPolicy.d.ts +76 -0
- package/types/rockgen/lod/rockLodRuntime.d.ts +95 -0
- package/types/rockgen/lod/rockLodSimplifier.d.ts +15 -0
- package/types/rockgen/lod/rockLodValidation.d.ts +16 -0
- package/types/rockgen/mesh/meshAttributes.d.ts +32 -0
- package/types/rockgen/mesh/meshDocument.d.ts +40 -0
- package/types/rockgen/mesh/surfaceNets.d.ts +42 -0
- package/types/rockgen/noise/cellularNoise3.d.ts +24 -0
- package/types/rockgen/noise/prng.d.ts +16 -0
- package/types/rockgen/noise/simplexNoise3.d.ts +2 -0
- package/types/rockgen/noise/valueNoise3.d.ts +12 -0
- package/types/rockgen/rockDocument.d.ts +215 -0
- package/types/rockgen/rockHelpers.d.ts +2 -0
- package/types/rockgen/rockgenPresets.d.ts +10 -0
- package/types/rockgen/rockgenSettings.d.ts +531 -0
- package/types/rockgen/sdf/fieldCompiler.d.ts +20 -0
- package/types/rockgen/sdf/sculptEdits.d.ts +30 -0
- package/types/rockgen/sdf/sdfModifiers.d.ts +19 -0
- package/types/rockgen/sdf/sdfOps.d.ts +8 -0
- package/types/rockgen/sdf/sdfPrimitives.d.ts +22 -0
- package/types/runtime/index.d.ts +3 -0
- package/types/runtime/sceneCollisionRuntime.d.ts +94 -0
- package/types/runtime/sceneSurfaceRuntime.d.ts +90 -0
- package/types/runtime/sceneUpdateScheduler.d.ts +28 -0
- package/types/shaders-tsl/anime.d.ts +9 -0
- package/types/shaders-tsl/chunks/character-color.d.ts +6 -0
- package/types/shaders-tsl/chunks/character-highlights.d.ts +12 -0
- package/types/shaders-tsl/chunks/character-lighting.d.ts +20 -0
- package/types/shaders-tsl/chunks/character-material-maps.d.ts +18 -0
- package/types/shaders-tsl/chunks/character-roles.d.ts +21 -0
- package/types/shaders-tsl/chunks/character-scene-lights.d.ts +48 -0
- package/types/shaders-tsl/chunks/character-shadow-color.d.ts +5 -0
- package/types/shaders-tsl/chunks/character-skinning.d.ts +23 -0
- package/types/shaders-tsl/chunks/environment-color.d.ts +9 -0
- package/types/shaders-tsl/chunks/environment-debug.d.ts +24 -0
- package/types/shaders-tsl/chunks/environment-ground-field.d.ts +40 -0
- package/types/shaders-tsl/chunks/environment-lighting.d.ts +22 -0
- package/types/shaders-tsl/chunks/environment-state.d.ts +42 -0
- package/types/shaders-tsl/chunks/environment-sun-shadow.d.ts +19 -0
- package/types/shaders-tsl/chunks/foliage-fog.d.ts +21 -0
- package/types/shaders-tsl/chunks/normalized-hue.d.ts +1 -0
- package/types/shaders-tsl/chunks/pass-depth-color.d.ts +20 -0
- package/types/shaders-tsl/chunks/projected-water-caustics.d.ts +24 -0
- package/types/shaders-tsl/chunks/scene-depth-color-pass.d.ts +39 -0
- package/types/shaders-tsl/chunks/stylized-cloud-shadow.d.ts +9 -0
- package/types/shaders-tsl/chunks/vegetation-style.d.ts +60 -0
- package/types/shaders-tsl/chunks/water-color.d.ts +15 -0
- package/types/shaders-tsl/chunks/water-common.d.ts +9 -0
- package/types/shaders-tsl/chunks/water-foam.d.ts +8 -0
- package/types/shaders-tsl/chunks/water-lighting.d.ts +9 -0
- package/types/shaders-tsl/chunks/water-ripple.d.ts +8 -0
- package/types/shaders-tsl/chunks/water-shore-state.d.ts +7 -0
- package/types/shaders-tsl/chunks/water-waves.d.ts +18 -0
- package/types/shaders-tsl/chunks/world-noise.d.ts +4 -0
- package/types/shaders-tsl/environment-ao-overlay.d.ts +5 -0
- package/types/shaders-tsl/environment.d.ts +34 -0
- package/types/shaders-tsl/flower.d.ts +6 -0
- package/types/shaders-tsl/grass.d.ts +4 -0
- package/types/shaders-tsl/post-composite.d.ts +25 -0
- package/types/shaders-tsl/sky.d.ts +4 -0
- package/types/shaders-tsl/tree-leaf.d.ts +2 -0
- package/types/shaders-tsl/water-breaker.d.ts +15 -0
- package/types/shaders-tsl/water-kelp.d.ts +5 -0
- package/types/shaders-tsl/water-rain.d.ts +10 -0
- package/types/shaders-tsl/water-shore-state-simulation.d.ts +12 -0
- package/types/shaders-tsl/water-simulation.d.ts +5 -0
- package/types/shaders-tsl/water-splash.d.ts +12 -0
- package/types/shaders-tsl/water.d.ts +22 -0
- package/types/shaders-tsl/woody-surface.d.ts +3 -0
- package/types/sky/atmosphereDome.d.ts +2 -0
- package/types/sky/atmosphereParams.d.ts +185 -0
- package/types/sky/atmosphereScattering.d.ts +11 -0
- package/types/sky/atmosphereSky.d.ts +2 -0
- package/types/sky/cloudShadow.d.ts +68 -0
- package/types/sky/godRays.d.ts +5 -0
- package/types/sky/index.d.ts +18 -0
- package/types/sky/nightSky.d.ts +22 -0
- package/types/sky/renderLayers.d.ts +59 -0
- package/types/sky/sceneOverrideLayers.d.ts +10 -0
- package/types/sky/skyColor.d.ts +704 -0
- package/types/sky/skyDayCycle.d.ts +86 -0
- package/types/sky/skyParams.d.ts +3407 -0
- package/types/sky/skyPresets.d.ts +160 -0
- package/types/sky/skyQuality.d.ts +21 -0
- package/types/sky/skyQualityTiers.d.ts +223 -0
- package/types/sky/skyShaderSettings.d.ts +152 -0
- package/types/sky/skyStyleSnapshots.d.ts +11 -0
- package/types/sky/skySystem.d.ts +3 -0
- package/types/sky/skyTimeKeyframes.d.ts +230 -0
- package/types/sky/stylizedSky.d.ts +341 -0
- package/types/sky/sunDriver.d.ts +15 -0
- package/types/sky/timeOfDay.d.ts +145 -0
- package/types/styles/animeGameProfile.d.ts +27 -0
- package/types/styles/index.d.ts +17 -0
- package/types/styles/manufacturedStyleLabeling.d.ts +119 -0
- package/types/styles/sceneLayerDocuments.d.ts +145 -0
- package/types/styles/sceneLookComposition.d.ts +53 -0
- package/types/styles/sceneQualityApplication.d.ts +34 -0
- package/types/styles/sceneQualityProfiles.d.ts +13 -0
- package/types/styles/sceneStyleAudit.d.ts +80 -0
- package/types/styles/sceneStyleRuntime.d.ts +1782 -0
- package/types/styles/styleAdapters.d.ts +14 -0
- package/types/styles/styleApplication.d.ts +47 -0
- package/types/styles/styleBundle.d.ts +19 -0
- package/types/styles/styleBundleProvider.d.ts +44 -0
- package/types/styles/styleDomains.d.ts +18 -0
- package/types/styles/styleInspector.d.ts +59 -0
- package/types/styles/styleMaterialContract.d.ts +46 -0
- package/types/styles/styleMetadata.d.ts +11 -0
- package/types/styles/styleTargetDiscovery.d.ts +48 -0
- package/types/styles/styleTargetLabels.d.ts +32 -0
- package/types/styles/styleTargetMaterialCoverage.d.ts +20 -0
- package/types/styles/styleTransaction.d.ts +10 -0
- package/types/styles/styleTypes.d.ts +66 -0
- package/types/texgen/evaluateTexture.d.ts +40 -0
- package/types/texgen/index.d.ts +7 -0
- package/types/texgen/noise2.d.ts +46 -0
- package/types/texgen/textureAi.d.ts +6 -0
- package/types/texgen/textureGenerators.d.ts +261 -0
- package/types/texgen/texturePresets.d.ts +45 -0
- package/types/texgen/textureSettings.d.ts +121 -0
- package/types/texgen/textureThree.d.ts +13 -0
- package/types/toon/characterRenderPasses.d.ts +3 -0
- package/types/toon/index.d.ts +3 -0
- package/types/toon/settings/alphaSettings.d.ts +125 -0
- package/types/toon/settings/averageShadowSettings.d.ts +39 -0
- package/types/toon/settings/baseTextureSettings.d.ts +39 -0
- package/types/toon/settings/celShadeSettings.d.ts +37 -0
- package/types/toon/settings/contactShadowSettings.d.ts +30 -0
- package/types/toon/settings/eyeHighlightSettings.d.ts +55 -0
- package/types/toon/settings/faceLightingSettings.d.ts +32 -0
- package/types/toon/settings/furSettings.d.ts +23 -0
- package/types/toon/settings/glitterSettings.d.ts +43 -0
- package/types/toon/settings/hairHighlightSettings.d.ts +89 -0
- package/types/toon/settings/indirectLightSettings.d.ts +43 -0
- package/types/toon/settings/localLightSettings.d.ts +46 -0
- package/types/toon/settings/materialMapSettings.d.ts +86 -0
- package/types/toon/settings/outlineSettings.d.ts +125 -0
- package/types/toon/settings/perspectiveRemovalSettings.d.ts +14 -0
- package/types/toon/settings/rimLightSettings.d.ts +79 -0
- package/types/toon/settings/sceneShadowSettings.d.ts +32 -0
- package/types/toon/settings/selfShadowSettings.d.ts +44 -0
- package/types/toon/settings/shadowColorSettings.d.ts +77 -0
- package/types/toon/settings/skinToneSettings.d.ts +30 -0
- package/types/toon/settings/specularSettings.d.ts +96 -0
- package/types/toon/settings/stickerSettings.d.ts +40 -0
- package/types/toon/toonMaterialAdapter.d.ts +883 -0
- package/types/toon/toonSettings.d.ts +1182 -0
- package/types/vegetation/branchTree.d.ts +10 -0
- package/types/vegetation/callMeSenseiGrass.d.ts +8 -0
- package/types/vegetation/compiledTree.d.ts +75 -0
- package/types/vegetation/contactShadowField.d.ts +26 -0
- package/types/vegetation/flowerSpecies.d.ts +107 -0
- package/types/vegetation/grass.d.ts +4 -0
- package/types/vegetation/grassClump.d.ts +7 -0
- package/types/vegetation/grassPalettes.d.ts +29 -0
- package/types/vegetation/importedVegetationMaterial.d.ts +13 -0
- package/types/vegetation/index.d.ts +216 -0
- package/types/vegetation/legacyTreePresets.d.ts +22 -0
- package/types/vegetation/scatter.d.ts +12 -0
- package/types/vegetation/stylizedBush.d.ts +2 -0
- package/types/vegetation/stylizedFlower.d.ts +2 -0
- package/types/vegetation/stylizedFlowers.d.ts +8 -0
- package/types/vegetation/stylizedForest.d.ts +3 -0
- package/types/vegetation/stylizedGrass.d.ts +21 -0
- package/types/vegetation/stylizedTree.d.ts +19 -0
- package/types/vegetation/stylizedTreeFoliage.d.ts +18 -0
- package/types/vegetation/stylizedUnderstory.d.ts +50 -0
- package/types/vegetation/treeExport.d.ts +6 -0
- package/types/vegetation/treeSurfaceTextures.d.ts +72 -0
- package/types/vegetation/vegetationShaders.d.ts +74 -0
- package/types/version.d.ts +1 -0
- package/types/water/index.d.ts +1 -0
- package/types/water/sceneOverrideLayers.d.ts +16 -0
- package/types/water/water.d.ts +17 -0
- package/types/water/waterBreakerSystem.d.ts +46 -0
- package/types/water/waterCurrentField.d.ts +115 -0
- package/types/water/waterInteraction.d.ts +21 -0
- package/types/water/waterMaterial.d.ts +60 -0
- package/types/water/waterNearshorePhase.d.ts +5 -0
- package/types/water/waterRain.d.ts +17 -0
- package/types/water/waterRippleSimulation.d.ts +52 -0
- package/types/water/waterScenePasses.d.ts +70 -0
- package/types/water/waterSettings.d.ts +648 -0
- package/types/water/waterShoreMaterial.d.ts +3 -0
- package/types/water/waterShoreStateField.d.ts +2 -0
- package/types/water/waterSplashSystem.d.ts +2 -0
- package/types/water/waterStageSettings.d.ts +9 -0
- package/types/water/waterSurface.d.ts +2 -0
- package/types/water/waterUnderwaterAtmosphere.d.ts +103 -0
- package/types/water/waterVegetation.d.ts +16 -0
- package/types/worldCollision.d.ts +22 -0
- package/AGENTS.md +0 -254
- package/ATTRIBUTION.md +0 -78
- package/docs/characters.md +0 -144
- package/docs/debug-panel.md +0 -126
- package/docs/docs.css +0 -589
- package/docs/environment.md +0 -186
- package/docs/getting-started.md +0 -180
- package/docs/index.html +0 -14
- package/docs/lab-architecture.md +0 -100
- package/docs/lighting.md +0 -825
- package/docs/main.jsx +0 -739
- package/docs/mcp.md +0 -97
- package/docs/post-processing.md +0 -98
- package/docs/settings-reference.md +0 -1878
- package/docs/shader-constants.md +0 -77
- package/docs/sky.md +0 -182
- package/docs/style-labs.md +0 -309
- package/docs/texture-lab.md +0 -135
- package/docs/toon-shading.md +0 -183
- package/docs/tsl-conventions.md +0 -167
- package/docs/vegetation-sky.md +0 -275
- package/docs/water.md +0 -430
- package/docs/weather.md +0 -200
- package/docs/world-scale.md +0 -111
- package/mcp/style-lab-tools.mjs +0 -371
- package/src/ambientfx/INTEGRATION.md +0 -164
- package/src/ambientfx/ambientFxPresets.js +0 -83
- package/src/ambientfx/ambientFxSettings.js +0 -368
- package/src/ambientfx/emitters.js +0 -169
- package/src/ambientfx/index.js +0 -5
- package/src/ambientfx/particleBackbone.js +0 -493
- package/src/ambientfx/stylizedAmbientFx.js +0 -450
- package/src/biome/biomeGenerator.js +0 -385
- package/src/biome/biomeRuntime.js +0 -299
- package/src/biome/index.js +0 -2
- package/src/buildinggen/buildingAsset.js +0 -44
- package/src/buildinggen/buildingGrammar.js +0 -311
- package/src/buildinggen/buildingMesh.js +0 -451
- package/src/buildinggen/buildingPresets.js +0 -46
- package/src/buildinggen/buildingRecipe.js +0 -100
- package/src/buildinggen/buildingSettings.js +0 -238
- package/src/buildinggen/index.js +0 -6
- package/src/camera/cameraDirector.js +0 -157
- package/src/camera/cameraGenerator.js +0 -367
- package/src/camera/cameraRig.js +0 -570
- package/src/camera/cameraSettings.js +0 -236
- package/src/camera/index.js +0 -7
- package/src/catalog/builtinEntries.js +0 -245
- package/src/catalog/catalog.js +0 -210
- package/src/catalog/index.js +0 -3
- package/src/core/shaderBackend.js +0 -24
- package/src/debrisgen/debrisFields.js +0 -544
- package/src/debrisgen/debrisGenerator.js +0 -1929
- package/src/debrisgen/debrisPalettes.js +0 -71
- package/src/debrisgen/debrisPhysics.js +0 -198
- package/src/debrisgen/debrisPresets.js +0 -162
- package/src/debrisgen/debrisSettings.js +0 -333
- package/src/debrisgen/debrisTextures.js +0 -380
- package/src/debrisgen/index.js +0 -5
- package/src/debug/fieldValues.js +0 -95
- package/src/debug/index.js +0 -7
- package/src/debug/settingsPanel.js +0 -170
- package/src/fauna/INTEGRATION.md +0 -174
- package/src/fauna/boids.js +0 -861
- package/src/fauna/faunaBodies.js +0 -492
- package/src/fauna/faunaPresets.js +0 -52
- package/src/fauna/faunaSettings.js +0 -525
- package/src/fauna/index.js +0 -5
- package/src/fauna/stylizedFauna.js +0 -395
- package/src/game-feel/gameFeelGenerator.js +0 -402
- package/src/game-feel/gameFeelRuntime.js +0 -549
- package/src/game-feel/index.js +0 -2
- package/src/motion/index.js +0 -5
- package/src/motion/motionClip.js +0 -441
- package/src/motion/motionController.js +0 -628
- package/src/motion/motionDocuments.js +0 -225
- package/src/motion/motionGraph.js +0 -307
- package/src/motion/motionSettings.js +0 -222
- package/src/pathgen/index.js +0 -7
- package/src/pathgen/pathBridge.js +0 -232
- package/src/pathgen/pathPresets.js +0 -35
- package/src/pathgen/pathRibbon.js +0 -410
- package/src/pathgen/pathRouter.js +0 -380
- package/src/pathgen/pathSettings.js +0 -335
- package/src/pathgen/pathTextures.js +0 -123
- package/src/pathgen/stylizedPaths.js +0 -453
- package/src/propgen/generatorsWave1.js +0 -379
- package/src/propgen/generatorsWave2.js +0 -462
- package/src/propgen/index.js +0 -5
- package/src/propgen/propAsset.js +0 -323
- package/src/propgen/propParts.js +0 -170
- package/src/propgen/propPlacement.js +0 -459
- package/src/propgen/propPresets.js +0 -82
- package/src/propgen/propSettings.js +0 -395
- package/src/soundscape/index.js +0 -4
- package/src/soundscape/soundscapeGenerator.js +0 -179
- package/src/soundscape/soundscapeRuntime.js +0 -806
- package/src/soundscape/soundscapeSettings.js +0 -292
- package/src/stylizedTerrain.js +0 -631
- package/src/stylizedWorld.js +0 -903
- package/src/vegetation/treeRecipe.js +0 -647
- package/src/vfxgen/INTEGRATION.md +0 -145
- package/src/vfxgen/core/burstBackbone.js +0 -380
- package/src/vfxgen/core/projectileCore.js +0 -92
- package/src/vfxgen/core/spriteShapes.js +0 -98
- package/src/vfxgen/core/trailRibbon.js +0 -272
- package/src/vfxgen/core/vfxRandom.js +0 -29
- package/src/vfxgen/effects/emitHelpers.js +0 -37
- package/src/vfxgen/effects/magicEffects.js +0 -162
- package/src/vfxgen/effects/movementEffects.js +0 -87
- package/src/vfxgen/effects/weaponEffects.js +0 -118
- package/src/vfxgen/index.js +0 -18
- package/src/vfxgen/moves/moveController.js +0 -146
- package/src/vfxgen/moves/moveLibrary.js +0 -335
- package/src/vfxgen/vfxPresets.js +0 -98
- package/src/vfxgen/vfxSettings.js +0 -384
- package/src/vfxgen/vfxSystem.js +0 -449
- package/src/vfxgen/weapons/stylizedWeapons.js +0 -137
- package/src/villagegen/index.js +0 -4
- package/src/villagegen/stylizedVillage.js +0 -490
- package/src/villagegen/villageArchetypes.js +0 -160
- package/src/villagegen/villageNames.js +0 -40
- package/src/villagegen/villageSites.js +0 -105
- package/src/weather/index.js +0 -6
- package/src/weather/weatherPrecipitation.js +0 -221
- package/src/weather/weatherPresets.js +0 -258
- package/src/weather/weatherSettings.js +0 -269
- package/src/weather/weatherSystem.js +0 -871
- package/src/worldMinimap.js +0 -214
- package/src/worldPresets.js +0 -125
|
@@ -0,0 +1,2874 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { MeshToonNodeMaterial } from 'three/webgpu';
|
|
3
|
+
import {
|
|
4
|
+
abs,
|
|
5
|
+
cameraPosition,
|
|
6
|
+
clamp,
|
|
7
|
+
dot,
|
|
8
|
+
float,
|
|
9
|
+
mix,
|
|
10
|
+
normalMap as normalMapNode,
|
|
11
|
+
normalWorld,
|
|
12
|
+
normalize,
|
|
13
|
+
positionWorld,
|
|
14
|
+
pow,
|
|
15
|
+
smoothstep,
|
|
16
|
+
texture,
|
|
17
|
+
uniform,
|
|
18
|
+
vec2,
|
|
19
|
+
vec3,
|
|
20
|
+
} from 'three/tsl';
|
|
21
|
+
|
|
22
|
+
import { sampleEnvironmentSunShadow } from '../shaders-tsl/chunks/environment-sun-shadow.js';
|
|
23
|
+
import { sampleEnvironmentCloudShadow } from '../sky/cloudShadow.js';
|
|
24
|
+
|
|
25
|
+
const LEGACY_SURFACE_PROFILES = Object.freeze({
|
|
26
|
+
paintedMetal: Object.freeze({
|
|
27
|
+
colorControl: 'bodyColor',
|
|
28
|
+
colorLiftScale: 1,
|
|
29
|
+
decalScale: 1,
|
|
30
|
+
decalThreshold: 0.16,
|
|
31
|
+
fallbackMetalness: 0.58,
|
|
32
|
+
fresnelScale: 0.72,
|
|
33
|
+
highlightScale: 0.26,
|
|
34
|
+
lightValueCap: 1.25,
|
|
35
|
+
materialResponseScale: 0.82,
|
|
36
|
+
normalScale: 0.7,
|
|
37
|
+
paintValue: 0.7,
|
|
38
|
+
pastelScale: 1,
|
|
39
|
+
planarSheenScale: 0.18,
|
|
40
|
+
responseValueCap: 1.4,
|
|
41
|
+
roleColorMix: 0,
|
|
42
|
+
roughnessBreakupScale: 0.56,
|
|
43
|
+
sharpRustBoost: 1.25,
|
|
44
|
+
sourceAnchorAuthorityScale: 1,
|
|
45
|
+
sourceHueAuthorityScale: 1,
|
|
46
|
+
sourceValueAuthorityScale: 1,
|
|
47
|
+
viewReflectionScale: 0.45,
|
|
48
|
+
wearScale: 1,
|
|
49
|
+
}),
|
|
50
|
+
graphicPanel: Object.freeze({
|
|
51
|
+
colorControl: 'bodyColor',
|
|
52
|
+
colorLiftScale: 0.24,
|
|
53
|
+
decalScale: 0,
|
|
54
|
+
decalThreshold: 0.9,
|
|
55
|
+
fallbackMetalness: 0.08,
|
|
56
|
+
fresnelScale: 0.35,
|
|
57
|
+
graphicSafeMacro: 1,
|
|
58
|
+
highlightScale: 0.16,
|
|
59
|
+
lightValueCap: 1.08,
|
|
60
|
+
materialResponseScale: 0.34,
|
|
61
|
+
normalScale: 0.45,
|
|
62
|
+
paintExtractionScale: 0.12,
|
|
63
|
+
paintValue: 0.7,
|
|
64
|
+
pastelScale: 0.12,
|
|
65
|
+
planarSheenScale: 0.16,
|
|
66
|
+
responseValueCap: 1.15,
|
|
67
|
+
roleColorMix: 0,
|
|
68
|
+
roughnessBreakupScale: 0.34,
|
|
69
|
+
sharpRustBoost: 0.2,
|
|
70
|
+
sourceAnchorAuthorityScale: 0,
|
|
71
|
+
sourceHueAuthorityScale: 1,
|
|
72
|
+
sourceValueAuthorityScale: 1,
|
|
73
|
+
viewReflectionScale: 0.22,
|
|
74
|
+
wearScale: 0.08,
|
|
75
|
+
}),
|
|
76
|
+
technicalSurface: Object.freeze({
|
|
77
|
+
colorControl: 'bodyColor',
|
|
78
|
+
colorLiftScale: 0.08,
|
|
79
|
+
decalScale: 0,
|
|
80
|
+
decalThreshold: 0.9,
|
|
81
|
+
fallbackMetalness: 0.42,
|
|
82
|
+
fresnelScale: 0.48,
|
|
83
|
+
graphicSafeMacro: 1,
|
|
84
|
+
highlightScale: 0.3,
|
|
85
|
+
lightValueCap: 0.92,
|
|
86
|
+
materialResponseScale: 0.74,
|
|
87
|
+
normalScale: 0.62,
|
|
88
|
+
paintExtractionScale: 0,
|
|
89
|
+
paintValue: 0.42,
|
|
90
|
+
pastelScale: 0,
|
|
91
|
+
planarSheenScale: 0.42,
|
|
92
|
+
responseValueCap: 1.02,
|
|
93
|
+
roleColorMix: 0,
|
|
94
|
+
roughnessBreakupScale: 0.62,
|
|
95
|
+
sharpRustBoost: 0.15,
|
|
96
|
+
sourceAnchorAuthorityScale: 0,
|
|
97
|
+
sourceHueAuthorityScale: 1,
|
|
98
|
+
sourceValueAuthorityScale: 1,
|
|
99
|
+
viewReflectionScale: 0.56,
|
|
100
|
+
wearScale: 0.06,
|
|
101
|
+
}),
|
|
102
|
+
paintedTrim: Object.freeze({
|
|
103
|
+
colorControl: 'trimColor',
|
|
104
|
+
colorLiftScale: 1,
|
|
105
|
+
decalScale: 0,
|
|
106
|
+
decalThreshold: 0.38,
|
|
107
|
+
fallbackMetalness: 0.72,
|
|
108
|
+
fresnelScale: 0.9,
|
|
109
|
+
highlightScale: 0.48,
|
|
110
|
+
lightValueCap: 0.62,
|
|
111
|
+
materialResponseScale: 1,
|
|
112
|
+
normalScale: 0.8,
|
|
113
|
+
paintValue: 0.28,
|
|
114
|
+
pastelScale: 0.08,
|
|
115
|
+
planarSheenScale: 0.22,
|
|
116
|
+
responseValueCap: 0.92,
|
|
117
|
+
roleColorMix: 0.86,
|
|
118
|
+
roughnessBreakupScale: 0.7,
|
|
119
|
+
sharpRustBoost: 1.8,
|
|
120
|
+
sourceAnchorAuthorityScale: 0,
|
|
121
|
+
sourceHueAuthorityScale: 1,
|
|
122
|
+
sourceValueAuthorityScale: 0.2,
|
|
123
|
+
viewReflectionScale: 0.55,
|
|
124
|
+
wearScale: 0.22,
|
|
125
|
+
}),
|
|
126
|
+
rubber: Object.freeze({
|
|
127
|
+
colorControl: 'rubberColor',
|
|
128
|
+
colorLiftScale: 1,
|
|
129
|
+
decalScale: 0,
|
|
130
|
+
decalThreshold: 0.9,
|
|
131
|
+
fallbackMetalness: 0,
|
|
132
|
+
fresnelScale: 0.28,
|
|
133
|
+
highlightScale: 0.04,
|
|
134
|
+
lightValueCap: 0.42,
|
|
135
|
+
materialResponseScale: 0.16,
|
|
136
|
+
normalScale: 0.72,
|
|
137
|
+
paintValue: 0.14,
|
|
138
|
+
pastelScale: 0,
|
|
139
|
+
planarSheenScale: 0.04,
|
|
140
|
+
responseValueCap: 0.72,
|
|
141
|
+
roleColorMix: 1,
|
|
142
|
+
roughnessBreakupScale: 0.2,
|
|
143
|
+
sharpRustBoost: 0.25,
|
|
144
|
+
sourceAnchorAuthorityScale: 0,
|
|
145
|
+
sourceHueAuthorityScale: 1,
|
|
146
|
+
sourceValueAuthorityScale: 1,
|
|
147
|
+
viewReflectionScale: 0.08,
|
|
148
|
+
wearScale: 0.08,
|
|
149
|
+
}),
|
|
150
|
+
lid: Object.freeze({
|
|
151
|
+
colorControl: 'lidColor',
|
|
152
|
+
colorLiftScale: 1,
|
|
153
|
+
decalScale: 0,
|
|
154
|
+
decalThreshold: 0.28,
|
|
155
|
+
fallbackMetalness: 0.18,
|
|
156
|
+
fresnelScale: 0.82,
|
|
157
|
+
highlightScale: 0.9,
|
|
158
|
+
lightValueCap: 0.34,
|
|
159
|
+
materialResponseScale: 1.12,
|
|
160
|
+
normalScale: 0.62,
|
|
161
|
+
paintValue: 0.3,
|
|
162
|
+
pastelScale: 0.18,
|
|
163
|
+
planarSheenScale: 1,
|
|
164
|
+
responseValueCap: 0.82,
|
|
165
|
+
roleColorMix: 0.72,
|
|
166
|
+
roughnessBreakupScale: 1,
|
|
167
|
+
sharpRustBoost: 0.55,
|
|
168
|
+
sourceAnchorAuthorityScale: 0,
|
|
169
|
+
sourceHueAuthorityScale: 1,
|
|
170
|
+
sourceValueAuthorityScale: 1,
|
|
171
|
+
viewReflectionScale: 1,
|
|
172
|
+
wearScale: 0.12,
|
|
173
|
+
}),
|
|
174
|
+
bareMetal: Object.freeze({
|
|
175
|
+
colorControl: 'bareMetalColor',
|
|
176
|
+
colorLiftScale: 0,
|
|
177
|
+
decalScale: 0,
|
|
178
|
+
decalThreshold: 0.9,
|
|
179
|
+
fallbackMetalness: 0.88,
|
|
180
|
+
fresnelScale: 0.55,
|
|
181
|
+
highlightScale: 0.08,
|
|
182
|
+
lightValueCap: 0.32,
|
|
183
|
+
materialResponseScale: 1.26,
|
|
184
|
+
normalScale: 0.72,
|
|
185
|
+
paintValue: 0.16,
|
|
186
|
+
pastelScale: 0,
|
|
187
|
+
planarSheenScale: 0.34,
|
|
188
|
+
responseValueCap: 0.62,
|
|
189
|
+
roleColorMix: 1,
|
|
190
|
+
roughnessBreakupScale: 0.84,
|
|
191
|
+
sharpRustBoost: 3.2,
|
|
192
|
+
sourceAnchorAuthorityScale: 0,
|
|
193
|
+
sourceHueAuthorityScale: 0,
|
|
194
|
+
sourceValueAuthorityScale: 0,
|
|
195
|
+
viewReflectionScale: 0.78,
|
|
196
|
+
wearScale: 0.95,
|
|
197
|
+
}),
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
function surfaceProfile(base, overrides) {
|
|
201
|
+
return Object.freeze({ ...base, ...overrides });
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const SURFACE_PROFILES = Object.freeze({
|
|
205
|
+
...LEGACY_SURFACE_PROFILES,
|
|
206
|
+
coatedPanel: LEGACY_SURFACE_PROFILES.lid,
|
|
207
|
+
genericDielectric: surfaceProfile(LEGACY_SURFACE_PROFILES.paintedMetal, {
|
|
208
|
+
colorLiftScale: 0.42,
|
|
209
|
+
fallbackMetalness: 0,
|
|
210
|
+
fresnelScale: 0.34,
|
|
211
|
+
highlightScale: 0.2,
|
|
212
|
+
lightValueCap: 1.08,
|
|
213
|
+
materialResponseScale: 0.42,
|
|
214
|
+
normalScale: 0.82,
|
|
215
|
+
paintExtractionScale: 0.35,
|
|
216
|
+
pastelScale: 0.45,
|
|
217
|
+
planarSheenScale: 0.08,
|
|
218
|
+
responseValueCap: 1.15,
|
|
219
|
+
roughnessBreakupScale: 0.72,
|
|
220
|
+
sharpRustBoost: 0.2,
|
|
221
|
+
viewReflectionScale: 0.2,
|
|
222
|
+
wearScale: 0.3,
|
|
223
|
+
}),
|
|
224
|
+
masonry: surfaceProfile(LEGACY_SURFACE_PROFILES.paintedMetal, {
|
|
225
|
+
colorLiftScale: 0.2,
|
|
226
|
+
fallbackMetalness: 0,
|
|
227
|
+
fresnelScale: 0.08,
|
|
228
|
+
highlightScale: 0.08,
|
|
229
|
+
lightValueCap: 1.05,
|
|
230
|
+
materialResponseScale: 0.18,
|
|
231
|
+
normalScale: 1,
|
|
232
|
+
paintExtractionScale: 0.12,
|
|
233
|
+
pastelScale: 0.18,
|
|
234
|
+
planarSheenScale: 0.015,
|
|
235
|
+
responseValueCap: 1.08,
|
|
236
|
+
roughnessBreakupScale: 1,
|
|
237
|
+
sharpRustBoost: 0,
|
|
238
|
+
sourceAnchorAuthorityScale: 0,
|
|
239
|
+
viewReflectionScale: 0.035,
|
|
240
|
+
wearScale: 0.24,
|
|
241
|
+
}),
|
|
242
|
+
wood: surfaceProfile(LEGACY_SURFACE_PROFILES.paintedMetal, {
|
|
243
|
+
colorLiftScale: 0.28,
|
|
244
|
+
fallbackMetalness: 0,
|
|
245
|
+
fresnelScale: 0.24,
|
|
246
|
+
highlightScale: 0.15,
|
|
247
|
+
lightValueCap: 1.08,
|
|
248
|
+
materialResponseScale: 0.32,
|
|
249
|
+
normalScale: 0.88,
|
|
250
|
+
paintExtractionScale: 0.18,
|
|
251
|
+
pastelScale: 0.28,
|
|
252
|
+
planarSheenScale: 0.06,
|
|
253
|
+
responseValueCap: 1.12,
|
|
254
|
+
roughnessBreakupScale: 0.82,
|
|
255
|
+
sharpRustBoost: 0,
|
|
256
|
+
sourceAnchorAuthorityScale: 0,
|
|
257
|
+
viewReflectionScale: 0.14,
|
|
258
|
+
wearScale: 0.34,
|
|
259
|
+
}),
|
|
260
|
+
polymer: surfaceProfile(LEGACY_SURFACE_PROFILES.lid, {
|
|
261
|
+
colorControl: 'bodyColor',
|
|
262
|
+
colorLiftScale: 0.34,
|
|
263
|
+
fallbackMetalness: 0,
|
|
264
|
+
lightValueCap: 0.82,
|
|
265
|
+
paintExtractionScale: 0.18,
|
|
266
|
+
pastelScale: 0.24,
|
|
267
|
+
responseValueCap: 1.02,
|
|
268
|
+
roleColorMix: 0,
|
|
269
|
+
sharpRustBoost: 0,
|
|
270
|
+
sourceAnchorAuthorityScale: 0,
|
|
271
|
+
viewReflectionScale: 0.62,
|
|
272
|
+
wearScale: 0.14,
|
|
273
|
+
}),
|
|
274
|
+
glass: surfaceProfile(LEGACY_SURFACE_PROFILES.technicalSurface, {
|
|
275
|
+
fallbackMetalness: 0,
|
|
276
|
+
fresnelScale: 1.35,
|
|
277
|
+
highlightScale: 1,
|
|
278
|
+
lightValueCap: 1.05,
|
|
279
|
+
materialResponseScale: 1.15,
|
|
280
|
+
normalScale: 0.35,
|
|
281
|
+
pastelScale: 0,
|
|
282
|
+
planarSheenScale: 0.5,
|
|
283
|
+
responseValueCap: 1.2,
|
|
284
|
+
roughnessBreakupScale: 0.28,
|
|
285
|
+
viewReflectionScale: 1.15,
|
|
286
|
+
wearScale: 0.02,
|
|
287
|
+
}),
|
|
288
|
+
ceramic: surfaceProfile(LEGACY_SURFACE_PROFILES.paintedMetal, {
|
|
289
|
+
colorLiftScale: 0.3,
|
|
290
|
+
fallbackMetalness: 0,
|
|
291
|
+
fresnelScale: 0.46,
|
|
292
|
+
highlightScale: 0.54,
|
|
293
|
+
materialResponseScale: 0.55,
|
|
294
|
+
normalScale: 0.68,
|
|
295
|
+
paintExtractionScale: 0.12,
|
|
296
|
+
pastelScale: 0.32,
|
|
297
|
+
planarSheenScale: 0.18,
|
|
298
|
+
roughnessBreakupScale: 0.42,
|
|
299
|
+
sharpRustBoost: 0,
|
|
300
|
+
viewReflectionScale: 0.36,
|
|
301
|
+
wearScale: 0.08,
|
|
302
|
+
}),
|
|
303
|
+
textile: surfaceProfile(LEGACY_SURFACE_PROFILES.paintedMetal, {
|
|
304
|
+
colorLiftScale: 0.18,
|
|
305
|
+
fallbackMetalness: 0,
|
|
306
|
+
fresnelScale: 0.06,
|
|
307
|
+
highlightScale: 0.035,
|
|
308
|
+
lightValueCap: 1.02,
|
|
309
|
+
materialResponseScale: 0.1,
|
|
310
|
+
normalScale: 0.92,
|
|
311
|
+
paintExtractionScale: 0.08,
|
|
312
|
+
pastelScale: 0.2,
|
|
313
|
+
planarSheenScale: 0,
|
|
314
|
+
responseValueCap: 1.04,
|
|
315
|
+
roughnessBreakupScale: 0.9,
|
|
316
|
+
sharpRustBoost: 0,
|
|
317
|
+
sourceAnchorAuthorityScale: 0,
|
|
318
|
+
viewReflectionScale: 0.02,
|
|
319
|
+
wearScale: 0.1,
|
|
320
|
+
}),
|
|
321
|
+
leather: surfaceProfile(LEGACY_SURFACE_PROFILES.paintedMetal, {
|
|
322
|
+
colorLiftScale: 0.16,
|
|
323
|
+
fallbackMetalness: 0,
|
|
324
|
+
fresnelScale: 0.26,
|
|
325
|
+
highlightScale: 0.18,
|
|
326
|
+
lightValueCap: 0.9,
|
|
327
|
+
materialResponseScale: 0.28,
|
|
328
|
+
normalScale: 0.82,
|
|
329
|
+
paintExtractionScale: 0.08,
|
|
330
|
+
pastelScale: 0.08,
|
|
331
|
+
planarSheenScale: 0.05,
|
|
332
|
+
responseValueCap: 1,
|
|
333
|
+
roughnessBreakupScale: 0.7,
|
|
334
|
+
sharpRustBoost: 0,
|
|
335
|
+
sourceAnchorAuthorityScale: 0,
|
|
336
|
+
viewReflectionScale: 0.16,
|
|
337
|
+
wearScale: 0.16,
|
|
338
|
+
}),
|
|
339
|
+
paper: surfaceProfile(LEGACY_SURFACE_PROFILES.graphicPanel, {
|
|
340
|
+
fallbackMetalness: 0,
|
|
341
|
+
fresnelScale: 0.04,
|
|
342
|
+
highlightScale: 0.02,
|
|
343
|
+
materialResponseScale: 0.08,
|
|
344
|
+
normalScale: 0.3,
|
|
345
|
+
planarSheenScale: 0,
|
|
346
|
+
viewReflectionScale: 0.01,
|
|
347
|
+
}),
|
|
348
|
+
composite: surfaceProfile(LEGACY_SURFACE_PROFILES.technicalSurface, {
|
|
349
|
+
fallbackMetalness: 0.08,
|
|
350
|
+
fresnelScale: 0.58,
|
|
351
|
+
highlightScale: 0.42,
|
|
352
|
+
materialResponseScale: 0.62,
|
|
353
|
+
normalScale: 0.72,
|
|
354
|
+
pastelScale: 0.06,
|
|
355
|
+
planarSheenScale: 0.2,
|
|
356
|
+
viewReflectionScale: 0.44,
|
|
357
|
+
wearScale: 0.1,
|
|
358
|
+
}),
|
|
359
|
+
fluid: surfaceProfile(LEGACY_SURFACE_PROFILES.technicalSurface, {
|
|
360
|
+
fallbackMetalness: 0,
|
|
361
|
+
fresnelScale: 1.2,
|
|
362
|
+
highlightScale: 0.9,
|
|
363
|
+
materialResponseScale: 1.08,
|
|
364
|
+
normalScale: 0.55,
|
|
365
|
+
pastelScale: 0,
|
|
366
|
+
planarSheenScale: 0.62,
|
|
367
|
+
viewReflectionScale: 1.1,
|
|
368
|
+
wearScale: 0,
|
|
369
|
+
}),
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
export { SURFACE_PROFILES as URBAN_PROP_SURFACE_PROFILES };
|
|
373
|
+
|
|
374
|
+
export const URBAN_MATERIAL_BASES = Object.freeze([
|
|
375
|
+
'metal',
|
|
376
|
+
'mineral',
|
|
377
|
+
'wood',
|
|
378
|
+
'polymer',
|
|
379
|
+
'rubber',
|
|
380
|
+
'glass',
|
|
381
|
+
'ceramic',
|
|
382
|
+
'textile',
|
|
383
|
+
'leather',
|
|
384
|
+
'paper',
|
|
385
|
+
'composite',
|
|
386
|
+
'fluid',
|
|
387
|
+
'genericDielectric',
|
|
388
|
+
]);
|
|
389
|
+
|
|
390
|
+
export const URBAN_MATERIAL_FINISHES = Object.freeze([
|
|
391
|
+
'raw',
|
|
392
|
+
'painted',
|
|
393
|
+
'varnished',
|
|
394
|
+
'clearCoated',
|
|
395
|
+
'polished',
|
|
396
|
+
'brushed',
|
|
397
|
+
'glazed',
|
|
398
|
+
'anodized',
|
|
399
|
+
'mirror',
|
|
400
|
+
'matte',
|
|
401
|
+
]);
|
|
402
|
+
|
|
403
|
+
export const URBAN_RENDER_MODES = Object.freeze([
|
|
404
|
+
'opaque',
|
|
405
|
+
'alphaCutout',
|
|
406
|
+
'translucent',
|
|
407
|
+
'transmissive',
|
|
408
|
+
'unlit',
|
|
409
|
+
]);
|
|
410
|
+
|
|
411
|
+
export const URBAN_STRUCTURAL_ROLES = Object.freeze([
|
|
412
|
+
'primaryMass',
|
|
413
|
+
'secondaryStructure',
|
|
414
|
+
'trim',
|
|
415
|
+
'fastener',
|
|
416
|
+
'cavity',
|
|
417
|
+
'window',
|
|
418
|
+
'graphic',
|
|
419
|
+
'lightEmitter',
|
|
420
|
+
]);
|
|
421
|
+
|
|
422
|
+
export const URBAN_CONTENT_FLAGS = Object.freeze([
|
|
423
|
+
'graphic',
|
|
424
|
+
'display',
|
|
425
|
+
'emissive',
|
|
426
|
+
]);
|
|
427
|
+
|
|
428
|
+
export const URBAN_PROP_SURFACE_ROLES = Object.freeze([
|
|
429
|
+
'paintedMetal',
|
|
430
|
+
'graphicPanel',
|
|
431
|
+
'technicalSurface',
|
|
432
|
+
'paintedTrim',
|
|
433
|
+
'rubber',
|
|
434
|
+
'lid',
|
|
435
|
+
'bareMetal',
|
|
436
|
+
]);
|
|
437
|
+
|
|
438
|
+
export const URBAN_PROP_PALETTES = Object.freeze({
|
|
439
|
+
source: Object.freeze({
|
|
440
|
+
accentColor: 0xeaf4ff,
|
|
441
|
+
bodyColor: 0x16499b,
|
|
442
|
+
label: 'Source',
|
|
443
|
+
lidColor: 0x102d5d,
|
|
444
|
+
overrideStrength: 0,
|
|
445
|
+
rubberColor: 0x090c16,
|
|
446
|
+
trimColor: 0x11162b,
|
|
447
|
+
}),
|
|
448
|
+
mint: Object.freeze({
|
|
449
|
+
accentColor: 0x9a48ee,
|
|
450
|
+
bodyColor: 0x36d3a2,
|
|
451
|
+
label: 'Mint',
|
|
452
|
+
lidColor: 0x9da7ab,
|
|
453
|
+
overrideStrength: 1,
|
|
454
|
+
rubberColor: 0x202831,
|
|
455
|
+
trimColor: 0x164d5d,
|
|
456
|
+
}),
|
|
457
|
+
blue: Object.freeze({
|
|
458
|
+
accentColor: 0xee4baa,
|
|
459
|
+
bodyColor: 0x3f83df,
|
|
460
|
+
label: 'Blue',
|
|
461
|
+
lidColor: 0x9ba5af,
|
|
462
|
+
overrideStrength: 1,
|
|
463
|
+
rubberColor: 0x202831,
|
|
464
|
+
trimColor: 0x203b58,
|
|
465
|
+
}),
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
let lockedGradientMap;
|
|
469
|
+
let smoothGradientMap;
|
|
470
|
+
const textureAnchorCache = new WeakMap();
|
|
471
|
+
|
|
472
|
+
function createLockedGradientMap() {
|
|
473
|
+
if (lockedGradientMap) return lockedGradientMap;
|
|
474
|
+
// Duplicate the darkest texel to create three deliberate lighting bands.
|
|
475
|
+
// This keeps midtones broad while making the lit-to-shadow transition read
|
|
476
|
+
// like authored cel shading instead of a continuous PBR rolloff.
|
|
477
|
+
const values = [92, 92, 92, 255, 92, 92, 92, 255, 205, 205, 205, 255, 255, 255, 255, 255];
|
|
478
|
+
lockedGradientMap = new THREE.DataTexture(
|
|
479
|
+
new Uint8Array(values),
|
|
480
|
+
4,
|
|
481
|
+
1,
|
|
482
|
+
THREE.RGBAFormat,
|
|
483
|
+
THREE.UnsignedByteType,
|
|
484
|
+
);
|
|
485
|
+
lockedGradientMap.colorSpace = THREE.NoColorSpace;
|
|
486
|
+
lockedGradientMap.magFilter = THREE.NearestFilter;
|
|
487
|
+
lockedGradientMap.minFilter = THREE.NearestFilter;
|
|
488
|
+
lockedGradientMap.generateMipmaps = false;
|
|
489
|
+
lockedGradientMap.needsUpdate = true;
|
|
490
|
+
return lockedGradientMap;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function createSmoothGradientMap() {
|
|
494
|
+
if (smoothGradientMap) return smoothGradientMap;
|
|
495
|
+
const values = new Uint8Array(256 * 4);
|
|
496
|
+
for (let index = 0; index < 256; index += 1) {
|
|
497
|
+
const value = Math.round(72 + (index / 255) * 183);
|
|
498
|
+
const offset = index * 4;
|
|
499
|
+
values[offset] = value;
|
|
500
|
+
values[offset + 1] = value;
|
|
501
|
+
values[offset + 2] = value;
|
|
502
|
+
values[offset + 3] = 255;
|
|
503
|
+
}
|
|
504
|
+
smoothGradientMap = new THREE.DataTexture(
|
|
505
|
+
values,
|
|
506
|
+
256,
|
|
507
|
+
1,
|
|
508
|
+
THREE.RGBAFormat,
|
|
509
|
+
THREE.UnsignedByteType,
|
|
510
|
+
);
|
|
511
|
+
smoothGradientMap.colorSpace = THREE.NoColorSpace;
|
|
512
|
+
smoothGradientMap.magFilter = THREE.LinearFilter;
|
|
513
|
+
smoothGradientMap.minFilter = THREE.LinearFilter;
|
|
514
|
+
smoothGradientMap.generateMipmaps = false;
|
|
515
|
+
smoothGradientMap.needsUpdate = true;
|
|
516
|
+
return smoothGradientMap;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function deriveTextureAnchor(texture) {
|
|
520
|
+
if (!texture?.image || typeof document === 'undefined') {
|
|
521
|
+
return { color: new THREE.Color(0xffffff), strength: 0 };
|
|
522
|
+
}
|
|
523
|
+
if (textureAnchorCache.has(texture)) return textureAnchorCache.get(texture);
|
|
524
|
+
|
|
525
|
+
const fallback = { color: new THREE.Color(0xffffff), strength: 0 };
|
|
526
|
+
try {
|
|
527
|
+
const image = texture.image;
|
|
528
|
+
const imageWidth = image.width ?? image.videoWidth ?? 0;
|
|
529
|
+
const imageHeight = image.height ?? image.videoHeight ?? 0;
|
|
530
|
+
if (!imageWidth || !imageHeight) return fallback;
|
|
531
|
+
|
|
532
|
+
const sampleSize = 48;
|
|
533
|
+
const canvas = document.createElement('canvas');
|
|
534
|
+
canvas.width = sampleSize;
|
|
535
|
+
canvas.height = sampleSize;
|
|
536
|
+
const context = canvas.getContext('2d', { willReadFrequently: true });
|
|
537
|
+
context.drawImage(image, 0, 0, sampleSize, sampleSize);
|
|
538
|
+
const pixels = context.getImageData(0, 0, sampleSize, sampleSize).data;
|
|
539
|
+
const binCount = 24;
|
|
540
|
+
const bins = Array.from({ length: binCount }, () => ({
|
|
541
|
+
blue: 0,
|
|
542
|
+
green: 0,
|
|
543
|
+
red: 0,
|
|
544
|
+
weight: 0,
|
|
545
|
+
}));
|
|
546
|
+
let chromaticPixelCount = 0;
|
|
547
|
+
let eligiblePixelCount = 0;
|
|
548
|
+
let totalWeight = 0;
|
|
549
|
+
|
|
550
|
+
for (let index = 0; index < pixels.length; index += 4) {
|
|
551
|
+
if (pixels[index + 3] < 32) continue;
|
|
552
|
+
const red = pixels[index] / 255;
|
|
553
|
+
const green = pixels[index + 1] / 255;
|
|
554
|
+
const blue = pixels[index + 2] / 255;
|
|
555
|
+
const high = Math.max(red, green, blue);
|
|
556
|
+
const low = Math.min(red, green, blue);
|
|
557
|
+
const chroma = high - low;
|
|
558
|
+
const saturation = chroma / Math.max(high, 0.001);
|
|
559
|
+
if (high >= 0.07 && high <= 0.96) eligiblePixelCount += 1;
|
|
560
|
+
const mutedNeutral = saturation < 0.22 && chroma < 0.055;
|
|
561
|
+
if (
|
|
562
|
+
saturation < 0.12
|
|
563
|
+
|| mutedNeutral
|
|
564
|
+
|| high < 0.07
|
|
565
|
+
|| high > 0.96
|
|
566
|
+
) continue;
|
|
567
|
+
chromaticPixelCount += 1;
|
|
568
|
+
|
|
569
|
+
let hue;
|
|
570
|
+
if (high === red) hue = ((green - blue) / chroma) % 6;
|
|
571
|
+
else if (high === green) hue = (blue - red) / chroma + 2;
|
|
572
|
+
else hue = (red - green) / chroma + 4;
|
|
573
|
+
hue = ((hue / 6) + 1) % 1;
|
|
574
|
+
const weight = saturation * saturation * (0.4 + high * 0.6);
|
|
575
|
+
const bin = bins[Math.floor(hue * binCount) % binCount];
|
|
576
|
+
bin.red += red * weight;
|
|
577
|
+
bin.green += green * weight;
|
|
578
|
+
bin.blue += blue * weight;
|
|
579
|
+
bin.weight += weight;
|
|
580
|
+
totalWeight += weight;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (totalWeight <= 0.001) return fallback;
|
|
584
|
+
const clusterWeightAt = (index) => bins[index].weight
|
|
585
|
+
+ bins[(index + binCount - 1) % binCount].weight
|
|
586
|
+
+ bins[(index + 1) % binCount].weight;
|
|
587
|
+
let winner = 0;
|
|
588
|
+
let winnerWeight = 0;
|
|
589
|
+
for (let index = 0; index < binCount; index += 1) {
|
|
590
|
+
const clusterWeight = clusterWeightAt(index);
|
|
591
|
+
if (clusterWeight > winnerWeight) {
|
|
592
|
+
winner = index;
|
|
593
|
+
winnerWeight = clusterWeight;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// Dark warm-brown corrosion often covers more texels than the remaining
|
|
598
|
+
// paint. When a substantial non-warm cluster also exists, treat that
|
|
599
|
+
// second cluster as the paint identity instead of averaging paint + rust.
|
|
600
|
+
const winnerIsWarmWear = winner <= 2 || winner >= binCount - 1;
|
|
601
|
+
if (winnerIsWarmWear) {
|
|
602
|
+
let paintWinner = winner;
|
|
603
|
+
let paintWeight = 0;
|
|
604
|
+
for (let index = 3; index < binCount - 1; index += 1) {
|
|
605
|
+
const clusterWeight = clusterWeightAt(index);
|
|
606
|
+
if (clusterWeight > paintWeight) {
|
|
607
|
+
paintWinner = index;
|
|
608
|
+
paintWeight = clusterWeight;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
if (paintWeight > totalWeight * 0.24 && paintWeight > winnerWeight * 0.5) {
|
|
612
|
+
winner = paintWinner;
|
|
613
|
+
winnerWeight = paintWeight;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
const clusterBins = [
|
|
618
|
+
bins[(winner + binCount - 1) % binCount],
|
|
619
|
+
bins[winner],
|
|
620
|
+
bins[(winner + 1) % binCount],
|
|
621
|
+
];
|
|
622
|
+
const sum = clusterBins.reduce((result, bin) => ({
|
|
623
|
+
red: result.red + bin.red,
|
|
624
|
+
green: result.green + bin.green,
|
|
625
|
+
blue: result.blue + bin.blue,
|
|
626
|
+
weight: result.weight + bin.weight,
|
|
627
|
+
}), { red: 0, green: 0, blue: 0, weight: 0 });
|
|
628
|
+
const red = sum.red / Math.max(sum.weight, 0.001);
|
|
629
|
+
const green = sum.green / Math.max(sum.weight, 0.001);
|
|
630
|
+
const blue = sum.blue / Math.max(sum.weight, 0.001);
|
|
631
|
+
const high = Math.max(red, green, blue, 0.001);
|
|
632
|
+
const normalized = {
|
|
633
|
+
red: red / high,
|
|
634
|
+
green: green / high,
|
|
635
|
+
blue: blue / high,
|
|
636
|
+
};
|
|
637
|
+
const low = Math.min(normalized.red, normalized.green, normalized.blue);
|
|
638
|
+
const chromaRange = Math.max(1 - low, 0.001);
|
|
639
|
+
const pureHue = {
|
|
640
|
+
red: (normalized.red - low) / chromaRange,
|
|
641
|
+
green: (normalized.green - low) / chromaRange,
|
|
642
|
+
blue: (normalized.blue - low) / chromaRange,
|
|
643
|
+
};
|
|
644
|
+
const saturationBoost = 0.62;
|
|
645
|
+
const dominance = winnerWeight / totalWeight;
|
|
646
|
+
const chromaticCoverage = chromaticPixelCount
|
|
647
|
+
/ Math.max(eligiblePixelCount, 1);
|
|
648
|
+
const dominanceConfidence = THREE.MathUtils.clamp(
|
|
649
|
+
(dominance - 0.2) / 0.25,
|
|
650
|
+
0,
|
|
651
|
+
1,
|
|
652
|
+
);
|
|
653
|
+
const coverageConfidence = THREE.MathUtils.clamp(
|
|
654
|
+
(chromaticCoverage - 0.08) / 0.26,
|
|
655
|
+
0,
|
|
656
|
+
1,
|
|
657
|
+
);
|
|
658
|
+
const result = {
|
|
659
|
+
color: new THREE.Color().setRGB(
|
|
660
|
+
THREE.MathUtils.lerp(normalized.red, pureHue.red, saturationBoost),
|
|
661
|
+
THREE.MathUtils.lerp(normalized.green, pureHue.green, saturationBoost),
|
|
662
|
+
THREE.MathUtils.lerp(normalized.blue, pureHue.blue, saturationBoost),
|
|
663
|
+
THREE.SRGBColorSpace,
|
|
664
|
+
),
|
|
665
|
+
strength: dominanceConfidence * coverageConfidence,
|
|
666
|
+
};
|
|
667
|
+
textureAnchorCache.set(texture, result);
|
|
668
|
+
return result;
|
|
669
|
+
} catch {
|
|
670
|
+
return fallback;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function colorControl(hex) {
|
|
675
|
+
return { value: new THREE.Color(hex) };
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
function numberControl(value) {
|
|
679
|
+
return { value };
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
export function createUrbanPropShaderControls(palette = 'source') {
|
|
683
|
+
const selected = URBAN_PROP_PALETTES[palette] ?? URBAN_PROP_PALETTES.source;
|
|
684
|
+
return {
|
|
685
|
+
accentColor: colorControl(selected.accentColor),
|
|
686
|
+
bareMetalColor: colorControl(0x788087),
|
|
687
|
+
celLightingEnabled: numberControl(1),
|
|
688
|
+
colorLiftEnabled: numberControl(1),
|
|
689
|
+
colorLiftStrength: numberControl(0.58),
|
|
690
|
+
coolShadowColor: colorControl(0x173875),
|
|
691
|
+
coolShadowsEnabled: numberControl(1),
|
|
692
|
+
coolShadowStrength: numberControl(0.72),
|
|
693
|
+
bodyColor: colorControl(selected.bodyColor),
|
|
694
|
+
decalStrength: numberControl(0.95),
|
|
695
|
+
dirtColor: colorControl(0x2d1b29),
|
|
696
|
+
edgeInkEnabled: numberControl(1),
|
|
697
|
+
fresnelColor: colorControl(0xb8d7e7),
|
|
698
|
+
fresnelEnabled: numberControl(1),
|
|
699
|
+
fresnelStrength: numberControl(0.22),
|
|
700
|
+
graphicsEnabled: numberControl(1),
|
|
701
|
+
highlightBandColor: colorControl(0xc5e7ff),
|
|
702
|
+
highlightBandEnabled: numberControl(1),
|
|
703
|
+
highlightBandStrength: numberControl(0.42),
|
|
704
|
+
highlightStrength: numberControl(0.16),
|
|
705
|
+
lidColor: colorControl(selected.lidColor),
|
|
706
|
+
materialResponseColor: colorControl(0xaacbe0),
|
|
707
|
+
materialResponseEnabled: numberControl(1),
|
|
708
|
+
materialResponseStrength: numberControl(0.82),
|
|
709
|
+
normalDetailEnabled: numberControl(1),
|
|
710
|
+
normalStrength: numberControl(0.1),
|
|
711
|
+
pastelBlueColor: colorControl(0x8faabd),
|
|
712
|
+
pastelPaletteEnabled: numberControl(1),
|
|
713
|
+
pastelStrength: numberControl(0.10),
|
|
714
|
+
planarSheenEnabled: numberControl(1),
|
|
715
|
+
planarSheenStrength: numberControl(0.25),
|
|
716
|
+
paintBandsEnabled: numberControl(1),
|
|
717
|
+
paintExtractionEnabled: numberControl(1),
|
|
718
|
+
paintExtractionStrength: numberControl(1),
|
|
719
|
+
paletteOverride: numberControl(selected.overrideStrength),
|
|
720
|
+
rimLeftColor: colorControl(0xff43d1),
|
|
721
|
+
rimRightColor: colorControl(0x44e8ff),
|
|
722
|
+
rimEnabled: numberControl(0),
|
|
723
|
+
reflectionNormalEnabled: numberControl(1),
|
|
724
|
+
reflectionNormalStrength: numberControl(0.8),
|
|
725
|
+
reflectionProbeAvailable: numberControl(0),
|
|
726
|
+
reflectionProbeLayerEnabled: numberControl(1),
|
|
727
|
+
reflectionProbeMap: { value: null },
|
|
728
|
+
reflectionProbeStrength: numberControl(0.82),
|
|
729
|
+
reflectionSelectivityEnabled: numberControl(1),
|
|
730
|
+
reflectionSelectivityStrength: numberControl(0.82),
|
|
731
|
+
roughnessBreakupEnabled: numberControl(1),
|
|
732
|
+
roughnessBreakupStrength: numberControl(1.15),
|
|
733
|
+
rubberColor: colorControl(selected.rubberColor),
|
|
734
|
+
shadowPastelEnabled: numberControl(1),
|
|
735
|
+
shadowPastelStrength: numberControl(0.80),
|
|
736
|
+
silhouetteInkEnabled: numberControl(1),
|
|
737
|
+
sourceAuthorityEnabled: numberControl(1),
|
|
738
|
+
sourceAuthorityStrength: numberControl(1),
|
|
739
|
+
trimColor: colorControl(selected.trimColor),
|
|
740
|
+
viewReflectionEnabled: numberControl(1),
|
|
741
|
+
viewReflectionStrength: numberControl(0.62),
|
|
742
|
+
wearEnabled: numberControl(1),
|
|
743
|
+
wearAmount: numberControl(0.28),
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
export const URBAN_PROP_SHADER_PROFILE_DOCUMENT_TYPE = 'toonlab/manufactured-surface-profile';
|
|
748
|
+
export const URBAN_PROP_SHADER_PROFILE_SCHEMA_VERSION = 1;
|
|
749
|
+
|
|
750
|
+
const URBAN_PROP_RUNTIME_ONLY_CONTROL_KEYS = new Set([
|
|
751
|
+
'reflectionProbeAvailable',
|
|
752
|
+
'reflectionProbeMap',
|
|
753
|
+
]);
|
|
754
|
+
|
|
755
|
+
function urbanPropProfileId(value) {
|
|
756
|
+
return String(value ?? '')
|
|
757
|
+
.trim()
|
|
758
|
+
.toLowerCase()
|
|
759
|
+
.replace(/[^a-z0-9]+/g, '_')
|
|
760
|
+
.replace(/^_+|_+$/g, '') || 'manufactured_surface';
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function urbanPropControlDefaults() {
|
|
764
|
+
return createUrbanPropShaderControls('source');
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/** Portable, JSON-safe values accepted by createUrbanPropShaderControls(). */
|
|
768
|
+
export function createUrbanPropShaderProfileSettings(input = {}) {
|
|
769
|
+
const source = input && typeof input === 'object' && !Array.isArray(input) ? input : {};
|
|
770
|
+
const controls = urbanPropControlDefaults();
|
|
771
|
+
const settings = {};
|
|
772
|
+
for (const [key, control] of Object.entries(controls)) {
|
|
773
|
+
if (URBAN_PROP_RUNTIME_ONLY_CONTROL_KEYS.has(key)) continue;
|
|
774
|
+
const candidate = source[key];
|
|
775
|
+
if (control.value?.isColor) {
|
|
776
|
+
const color = control.value.clone();
|
|
777
|
+
if (candidate !== undefined) {
|
|
778
|
+
try { color.set(candidate); } catch { /* keep the runtime default */ }
|
|
779
|
+
}
|
|
780
|
+
settings[key] = `#${color.getHexString()}`;
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
const number = candidate === undefined ? Number(control.value) : Number(candidate);
|
|
784
|
+
settings[key] = Number.isFinite(number) ? number : Number(control.value);
|
|
785
|
+
}
|
|
786
|
+
return settings;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
export function snapshotUrbanPropShaderControls(controls) {
|
|
790
|
+
const values = {};
|
|
791
|
+
const defaults = urbanPropControlDefaults();
|
|
792
|
+
for (const [key, fallback] of Object.entries(defaults)) {
|
|
793
|
+
if (URBAN_PROP_RUNTIME_ONLY_CONTROL_KEYS.has(key)) continue;
|
|
794
|
+
const control = controls?.[key] ?? fallback;
|
|
795
|
+
values[key] = fallback.value?.isColor
|
|
796
|
+
? `#${(control.value?.isColor ? control.value : fallback.value).getHexString()}`
|
|
797
|
+
: Number(control.value);
|
|
798
|
+
}
|
|
799
|
+
return createUrbanPropShaderProfileSettings(values);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
export function applyUrbanPropShaderProfile(controls, input) {
|
|
803
|
+
if (!controls || typeof controls !== 'object') {
|
|
804
|
+
throw new Error('Urban prop shader controls are required.');
|
|
805
|
+
}
|
|
806
|
+
const source = input?.type === URBAN_PROP_SHADER_PROFILE_DOCUMENT_TYPE
|
|
807
|
+
? parseUrbanPropShaderProfileDocument(input)
|
|
808
|
+
: { ok: true, value: { settings: createUrbanPropShaderProfileSettings(input) } };
|
|
809
|
+
if (!source.ok) throw new Error(source.errors.join(' '));
|
|
810
|
+
for (const [key, value] of Object.entries(source.value.settings)) {
|
|
811
|
+
const control = controls[key];
|
|
812
|
+
if (!control) continue;
|
|
813
|
+
if (control.value?.isColor) control.value.set(value);
|
|
814
|
+
else control.value = value;
|
|
815
|
+
}
|
|
816
|
+
return controls;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
export function createUrbanPropShaderProfileDocument(id, {
|
|
820
|
+
description = '',
|
|
821
|
+
label = id,
|
|
822
|
+
settings = {},
|
|
823
|
+
} = {}) {
|
|
824
|
+
return {
|
|
825
|
+
description: String(description ?? ''),
|
|
826
|
+
id: urbanPropProfileId(id),
|
|
827
|
+
label: String(label ?? id).trim() || 'Manufactured surface',
|
|
828
|
+
settings: createUrbanPropShaderProfileSettings(settings),
|
|
829
|
+
type: URBAN_PROP_SHADER_PROFILE_DOCUMENT_TYPE,
|
|
830
|
+
version: URBAN_PROP_SHADER_PROFILE_SCHEMA_VERSION,
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
export function parseUrbanPropShaderProfileDocument(input) {
|
|
835
|
+
let source = input;
|
|
836
|
+
if (typeof source === 'string') {
|
|
837
|
+
try { source = JSON.parse(source); } catch (error) {
|
|
838
|
+
return { errors: [`Invalid manufactured-surface JSON: ${error.message}`], ok: false };
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
const errors = [];
|
|
842
|
+
const warnings = [];
|
|
843
|
+
if (!source || typeof source !== 'object' || Array.isArray(source)) {
|
|
844
|
+
return { errors: ['Manufactured-surface profile must be a JSON object.'], ok: false };
|
|
845
|
+
}
|
|
846
|
+
if (source.type !== URBAN_PROP_SHADER_PROFILE_DOCUMENT_TYPE) {
|
|
847
|
+
errors.push(`Profile type must be "${URBAN_PROP_SHADER_PROFILE_DOCUMENT_TYPE}".`);
|
|
848
|
+
}
|
|
849
|
+
const version = Number(source.version ?? URBAN_PROP_SHADER_PROFILE_SCHEMA_VERSION);
|
|
850
|
+
if (version > URBAN_PROP_SHADER_PROFILE_SCHEMA_VERSION || version < 1) {
|
|
851
|
+
errors.push(`Unsupported manufactured-surface profile version ${source.version}.`);
|
|
852
|
+
}
|
|
853
|
+
const id = urbanPropProfileId(source.id || source.label);
|
|
854
|
+
const label = String(source.label ?? '').trim();
|
|
855
|
+
if (!label) errors.push('Manufactured-surface profile needs a label.');
|
|
856
|
+
const known = new Set(Object.keys(createUrbanPropShaderProfileSettings()));
|
|
857
|
+
for (const key of Object.keys(source.settings ?? {})) {
|
|
858
|
+
if (!known.has(key)) warnings.push(`Unknown manufactured-surface setting "${key}" was ignored.`);
|
|
859
|
+
}
|
|
860
|
+
if (errors.length) return { errors, ok: false, warnings };
|
|
861
|
+
return {
|
|
862
|
+
errors,
|
|
863
|
+
ok: true,
|
|
864
|
+
value: createUrbanPropShaderProfileDocument(id, {
|
|
865
|
+
description: source.description,
|
|
866
|
+
label,
|
|
867
|
+
settings: source.settings,
|
|
868
|
+
}),
|
|
869
|
+
warnings,
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
export function serializeUrbanPropShaderProfile(document, { pretty = true } = {}) {
|
|
874
|
+
const result = parseUrbanPropShaderProfileDocument(document);
|
|
875
|
+
if (!result.ok) throw new Error(result.errors.join(' '));
|
|
876
|
+
return JSON.stringify(result.value, null, pretty ? 2 : 0);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
export function applyUrbanPropPalette(controls, palette) {
|
|
880
|
+
const selected = URBAN_PROP_PALETTES[palette] ?? URBAN_PROP_PALETTES.source;
|
|
881
|
+
for (const key of ['accentColor', 'bodyColor', 'lidColor', 'rubberColor', 'trimColor']) {
|
|
882
|
+
controls[key].value.setHex(selected[key]);
|
|
883
|
+
}
|
|
884
|
+
controls.paletteOverride.value = selected.overrideStrength;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
const LEGACY_SURFACE_CLASSIFICATIONS = Object.freeze({
|
|
888
|
+
paintedMetal: Object.freeze({
|
|
889
|
+
baseMaterial: 'metal',
|
|
890
|
+
finish: 'painted',
|
|
891
|
+
renderMode: 'opaque',
|
|
892
|
+
structuralRole: 'primaryMass',
|
|
893
|
+
}),
|
|
894
|
+
paintedTrim: Object.freeze({
|
|
895
|
+
baseMaterial: 'metal',
|
|
896
|
+
finish: 'painted',
|
|
897
|
+
renderMode: 'opaque',
|
|
898
|
+
structuralRole: 'trim',
|
|
899
|
+
}),
|
|
900
|
+
bareMetal: Object.freeze({
|
|
901
|
+
baseMaterial: 'metal',
|
|
902
|
+
finish: 'raw',
|
|
903
|
+
renderMode: 'opaque',
|
|
904
|
+
structuralRole: 'secondaryStructure',
|
|
905
|
+
}),
|
|
906
|
+
rubber: Object.freeze({
|
|
907
|
+
baseMaterial: 'rubber',
|
|
908
|
+
finish: 'matte',
|
|
909
|
+
renderMode: 'opaque',
|
|
910
|
+
structuralRole: 'secondaryStructure',
|
|
911
|
+
}),
|
|
912
|
+
lid: Object.freeze({
|
|
913
|
+
baseMaterial: 'metal',
|
|
914
|
+
finish: 'painted',
|
|
915
|
+
renderMode: 'opaque',
|
|
916
|
+
structuralRole: 'secondaryStructure',
|
|
917
|
+
}),
|
|
918
|
+
graphicPanel: Object.freeze({
|
|
919
|
+
baseMaterial: 'genericDielectric',
|
|
920
|
+
contentFlags: Object.freeze(['graphic']),
|
|
921
|
+
finish: 'matte',
|
|
922
|
+
renderMode: 'opaque',
|
|
923
|
+
structuralRole: 'graphic',
|
|
924
|
+
}),
|
|
925
|
+
technicalSurface: Object.freeze({
|
|
926
|
+
baseMaterial: 'genericDielectric',
|
|
927
|
+
contentFlags: Object.freeze(['display']),
|
|
928
|
+
finish: 'matte',
|
|
929
|
+
renderMode: 'opaque',
|
|
930
|
+
structuralRole: 'secondaryStructure',
|
|
931
|
+
}),
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
function includesEnum(values, value) {
|
|
935
|
+
return values.includes(value);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
function sourceRenderMode(sourceMaterial) {
|
|
939
|
+
if (
|
|
940
|
+
Number(sourceMaterial?.transmission ?? 0) > 0
|
|
941
|
+
|| Number(sourceMaterial?.transmissionNode?.value ?? 0) > 0
|
|
942
|
+
) {
|
|
943
|
+
return 'transmissive';
|
|
944
|
+
}
|
|
945
|
+
if (sourceMaterial?.transparent || Number(sourceMaterial?.opacity ?? 1) < 0.999) {
|
|
946
|
+
return 'translucent';
|
|
947
|
+
}
|
|
948
|
+
if (Number(sourceMaterial?.alphaTest ?? 0) > 0) return 'alphaCutout';
|
|
949
|
+
return 'opaque';
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
function sourceHasEmission(sourceMaterial) {
|
|
953
|
+
if (sourceMaterial?.emissiveMap || sourceMaterial?.emissiveNode) return true;
|
|
954
|
+
const emissive = sourceMaterial?.emissive;
|
|
955
|
+
return Boolean(emissive && (emissive.r > 0 || emissive.g > 0 || emissive.b > 0));
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
export function createUrbanMaterialClassification(options = {}) {
|
|
959
|
+
const baseMaterial = includesEnum(URBAN_MATERIAL_BASES, options.baseMaterial)
|
|
960
|
+
? options.baseMaterial
|
|
961
|
+
: 'genericDielectric';
|
|
962
|
+
const finish = includesEnum(URBAN_MATERIAL_FINISHES, options.finish)
|
|
963
|
+
? options.finish
|
|
964
|
+
: 'matte';
|
|
965
|
+
const renderMode = includesEnum(URBAN_RENDER_MODES, options.renderMode)
|
|
966
|
+
? options.renderMode
|
|
967
|
+
: 'opaque';
|
|
968
|
+
const structuralRole = includesEnum(URBAN_STRUCTURAL_ROLES, options.structuralRole)
|
|
969
|
+
? options.structuralRole
|
|
970
|
+
: 'primaryMass';
|
|
971
|
+
const contentFlags = Object.freeze([
|
|
972
|
+
...new Set(
|
|
973
|
+
(Array.isArray(options.contentFlags) ? options.contentFlags : [])
|
|
974
|
+
.filter((flag) => includesEnum(URBAN_CONTENT_FLAGS, flag)),
|
|
975
|
+
),
|
|
976
|
+
]);
|
|
977
|
+
return Object.freeze({
|
|
978
|
+
version: 1,
|
|
979
|
+
baseMaterial,
|
|
980
|
+
finish,
|
|
981
|
+
renderMode,
|
|
982
|
+
structuralRole,
|
|
983
|
+
contentFlags,
|
|
984
|
+
classificationSource: options.classificationSource ?? 'explicit',
|
|
985
|
+
confidence: THREE.MathUtils.clamp(Number(options.confidence ?? 1), 0, 1),
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
function classificationFromMetadata(object, sourceMaterial) {
|
|
990
|
+
const nodeData = object?.userData ?? {};
|
|
991
|
+
const materialData = sourceMaterial?.userData ?? {};
|
|
992
|
+
const nested = {
|
|
993
|
+
...(nodeData.urbanMaterial && typeof nodeData.urbanMaterial === 'object'
|
|
994
|
+
? nodeData.urbanMaterial
|
|
995
|
+
: {}),
|
|
996
|
+
...(materialData.urbanMaterial && typeof materialData.urbanMaterial === 'object'
|
|
997
|
+
? materialData.urbanMaterial
|
|
998
|
+
: {}),
|
|
999
|
+
};
|
|
1000
|
+
const explicit = {
|
|
1001
|
+
baseMaterial: materialData.urbanBaseMaterial
|
|
1002
|
+
?? nodeData.urbanBaseMaterial
|
|
1003
|
+
?? nested.baseMaterial,
|
|
1004
|
+
finish: materialData.urbanFinish
|
|
1005
|
+
?? nodeData.urbanFinish
|
|
1006
|
+
?? nested.finish,
|
|
1007
|
+
renderMode: materialData.urbanRenderMode
|
|
1008
|
+
?? nodeData.urbanRenderMode
|
|
1009
|
+
?? nested.renderMode,
|
|
1010
|
+
structuralRole: materialData.urbanStructuralRole
|
|
1011
|
+
?? nodeData.urbanStructuralRole
|
|
1012
|
+
?? nested.structuralRole,
|
|
1013
|
+
contentFlags: materialData.urbanContentFlags
|
|
1014
|
+
?? nodeData.urbanContentFlags
|
|
1015
|
+
?? nested.contentFlags,
|
|
1016
|
+
};
|
|
1017
|
+
if (!includesEnum(URBAN_MATERIAL_BASES, explicit.baseMaterial)) return null;
|
|
1018
|
+
return createUrbanMaterialClassification({
|
|
1019
|
+
...explicit,
|
|
1020
|
+
classificationSource: 'explicit',
|
|
1021
|
+
confidence: 1,
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
function classificationText(object, materialOverride) {
|
|
1026
|
+
return `${object?.name ?? ''} ${object?.parent?.name ?? ''} ${
|
|
1027
|
+
materialOverride
|
|
1028
|
+
? materialOverride?.name ?? ''
|
|
1029
|
+
: Array.isArray(object?.material)
|
|
1030
|
+
? object.material.map((material) => material?.name ?? '').join(' ')
|
|
1031
|
+
: object?.material?.name ?? ''
|
|
1032
|
+
}`.toLowerCase();
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
export function resolveUrbanMaterialProfile(classification) {
|
|
1036
|
+
const flags = classification?.contentFlags ?? [];
|
|
1037
|
+
if (flags.includes('graphic') || classification?.structuralRole === 'graphic') {
|
|
1038
|
+
return 'graphicPanel';
|
|
1039
|
+
}
|
|
1040
|
+
if (flags.includes('display') || flags.includes('emissive')) {
|
|
1041
|
+
return 'technicalSurface';
|
|
1042
|
+
}
|
|
1043
|
+
switch (classification?.baseMaterial) {
|
|
1044
|
+
case 'metal':
|
|
1045
|
+
if (['raw', 'polished', 'brushed', 'anodized', 'mirror'].includes(
|
|
1046
|
+
classification.finish,
|
|
1047
|
+
)) {
|
|
1048
|
+
return 'bareMetal';
|
|
1049
|
+
}
|
|
1050
|
+
if (classification.structuralRole === 'trim') return 'paintedTrim';
|
|
1051
|
+
if (classification.structuralRole === 'secondaryStructure') {
|
|
1052
|
+
return 'coatedPanel';
|
|
1053
|
+
}
|
|
1054
|
+
return 'paintedMetal';
|
|
1055
|
+
case 'mineral':
|
|
1056
|
+
return 'masonry';
|
|
1057
|
+
case 'wood':
|
|
1058
|
+
return 'wood';
|
|
1059
|
+
case 'polymer':
|
|
1060
|
+
return 'polymer';
|
|
1061
|
+
case 'rubber':
|
|
1062
|
+
return 'rubber';
|
|
1063
|
+
case 'glass':
|
|
1064
|
+
return 'glass';
|
|
1065
|
+
case 'ceramic':
|
|
1066
|
+
return 'ceramic';
|
|
1067
|
+
case 'textile':
|
|
1068
|
+
return 'textile';
|
|
1069
|
+
case 'leather':
|
|
1070
|
+
return 'leather';
|
|
1071
|
+
case 'paper':
|
|
1072
|
+
return 'paper';
|
|
1073
|
+
case 'composite':
|
|
1074
|
+
return 'composite';
|
|
1075
|
+
case 'fluid':
|
|
1076
|
+
return 'fluid';
|
|
1077
|
+
default:
|
|
1078
|
+
return 'genericDielectric';
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
export function classifyUrbanMaterial(object, materialOverride = null) {
|
|
1083
|
+
const sourceMaterial = materialOverride ?? (
|
|
1084
|
+
Array.isArray(object?.material)
|
|
1085
|
+
? object.material[0]
|
|
1086
|
+
: object?.material
|
|
1087
|
+
);
|
|
1088
|
+
const explicitClassification = classificationFromMetadata(object, sourceMaterial);
|
|
1089
|
+
if (explicitClassification) return explicitClassification;
|
|
1090
|
+
|
|
1091
|
+
const explicitRole = sourceMaterial?.userData?.urbanSurface
|
|
1092
|
+
?? object?.userData?.urbanSurface;
|
|
1093
|
+
if (URBAN_PROP_SURFACE_ROLES.includes(explicitRole)) {
|
|
1094
|
+
return createUrbanMaterialClassification({
|
|
1095
|
+
...LEGACY_SURFACE_CLASSIFICATIONS[explicitRole],
|
|
1096
|
+
renderMode: sourceRenderMode(sourceMaterial),
|
|
1097
|
+
contentFlags: [
|
|
1098
|
+
...(LEGACY_SURFACE_CLASSIFICATIONS[explicitRole]?.contentFlags ?? []),
|
|
1099
|
+
...(sourceHasEmission(sourceMaterial) ? ['emissive'] : []),
|
|
1100
|
+
],
|
|
1101
|
+
classificationSource: 'legacy',
|
|
1102
|
+
confidence: 1,
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
const text = classificationText(object, materialOverride);
|
|
1107
|
+
const canonicalRole = URBAN_PROP_SURFACE_ROLES.find((role) => (
|
|
1108
|
+
new RegExp(`(?:^|[^a-z0-9])${role.toLowerCase()}(?:$|[^a-z0-9])`).test(text)
|
|
1109
|
+
));
|
|
1110
|
+
if (canonicalRole) {
|
|
1111
|
+
return createUrbanMaterialClassification({
|
|
1112
|
+
...LEGACY_SURFACE_CLASSIFICATIONS[canonicalRole],
|
|
1113
|
+
renderMode: sourceRenderMode(sourceMaterial),
|
|
1114
|
+
contentFlags: [
|
|
1115
|
+
...(LEGACY_SURFACE_CLASSIFICATIONS[canonicalRole]?.contentFlags ?? []),
|
|
1116
|
+
...(sourceHasEmission(sourceMaterial) ? ['emissive'] : []),
|
|
1117
|
+
],
|
|
1118
|
+
classificationSource: 'nameToken',
|
|
1119
|
+
confidence: 0.95,
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
let baseMaterial = 'genericDielectric';
|
|
1124
|
+
let finish = 'matte';
|
|
1125
|
+
let structuralRole = 'primaryMass';
|
|
1126
|
+
const renderMode = sourceRenderMode(sourceMaterial);
|
|
1127
|
+
const contentFlags = [];
|
|
1128
|
+
let confidence = 0.46;
|
|
1129
|
+
|
|
1130
|
+
if (/(sign|poster|billboard|advert|label|decal|graphic|print)/.test(text)) {
|
|
1131
|
+
contentFlags.push('graphic');
|
|
1132
|
+
structuralRole = 'graphic';
|
|
1133
|
+
confidence = Math.max(confidence, 0.9);
|
|
1134
|
+
}
|
|
1135
|
+
if (/(electrical|electronic|solar|photovoltaic|circuit|control.?panel|screen|display)/.test(text)) {
|
|
1136
|
+
contentFlags.push('display');
|
|
1137
|
+
structuralRole = structuralRole === 'graphic' ? structuralRole : 'secondaryStructure';
|
|
1138
|
+
confidence = Math.max(confidence, 0.86);
|
|
1139
|
+
}
|
|
1140
|
+
if (sourceHasEmission(sourceMaterial) || /(emissive|lamp|light|neon|led)/.test(text)) {
|
|
1141
|
+
contentFlags.push('emissive');
|
|
1142
|
+
if (structuralRole === 'primaryMass') structuralRole = 'lightEmitter';
|
|
1143
|
+
confidence = Math.max(confidence, 0.82);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
if (/(glass|window|windshield|windscreen|mirror)/.test(text)) {
|
|
1147
|
+
baseMaterial = 'glass';
|
|
1148
|
+
finish = /mirror/.test(text) ? 'mirror' : 'polished';
|
|
1149
|
+
structuralRole = /window|windshield|windscreen/.test(text) ? 'window' : structuralRole;
|
|
1150
|
+
confidence = 0.96;
|
|
1151
|
+
} else if (/(rubber|tire|tyre)/.test(text)) {
|
|
1152
|
+
baseMaterial = 'rubber';
|
|
1153
|
+
finish = 'matte';
|
|
1154
|
+
structuralRole = 'secondaryStructure';
|
|
1155
|
+
confidence = 0.96;
|
|
1156
|
+
} else if (/(fabric|textile|cloth|upholstery|curtain|canvas|carpet|rug)/.test(text)) {
|
|
1157
|
+
baseMaterial = 'textile';
|
|
1158
|
+
finish = 'matte';
|
|
1159
|
+
confidence = 0.92;
|
|
1160
|
+
} else if (/(leather|suede)/.test(text)) {
|
|
1161
|
+
baseMaterial = 'leather';
|
|
1162
|
+
finish = 'matte';
|
|
1163
|
+
confidence = 0.96;
|
|
1164
|
+
} else if (/(paper|cardboard|carton|poster)/.test(text)) {
|
|
1165
|
+
baseMaterial = 'paper';
|
|
1166
|
+
finish = 'matte';
|
|
1167
|
+
confidence = 0.92;
|
|
1168
|
+
} else if (/(ceramic|porcelain|earthenware)/.test(text)) {
|
|
1169
|
+
baseMaterial = 'ceramic';
|
|
1170
|
+
finish = /glaz/.test(text) ? 'glazed' : 'matte';
|
|
1171
|
+
confidence = 0.94;
|
|
1172
|
+
} else if (/(wood|timber|plank|plywood|veneer)/.test(text)) {
|
|
1173
|
+
baseMaterial = 'wood';
|
|
1174
|
+
finish = /(varnish|lacquer)/.test(text) ? 'varnished' : 'raw';
|
|
1175
|
+
confidence = 0.94;
|
|
1176
|
+
} else if (/(plastic|polymer|acrylic|vinyl|resin|foam)/.test(text)) {
|
|
1177
|
+
baseMaterial = 'polymer';
|
|
1178
|
+
finish = 'matte';
|
|
1179
|
+
confidence = 0.9;
|
|
1180
|
+
} else if (/(carbon.?fiber|fiberglass|fibre.?glass|laminate|composite)/.test(text)) {
|
|
1181
|
+
baseMaterial = 'composite';
|
|
1182
|
+
finish = /clear.?coat/.test(text) ? 'clearCoated' : 'matte';
|
|
1183
|
+
confidence = 0.92;
|
|
1184
|
+
} else if (/(liquid|fluid|water|oil)/.test(text)) {
|
|
1185
|
+
baseMaterial = 'fluid';
|
|
1186
|
+
finish = 'polished';
|
|
1187
|
+
confidence = 0.88;
|
|
1188
|
+
} else if (
|
|
1189
|
+
/(brick|concrete|cement|plaster|stucco|masonry|stone|marble|granite|asphalt|pavement|drywall|wall|floor|roof|gable|building)/.test(text)
|
|
1190
|
+
) {
|
|
1191
|
+
baseMaterial = 'mineral';
|
|
1192
|
+
finish = /(marble|granite|polish)/.test(text) ? 'polished' : 'raw';
|
|
1193
|
+
confidence = 0.9;
|
|
1194
|
+
} else if (
|
|
1195
|
+
/(metal|steel|iron|alum|chrome|copper|brass|handle|hinge|rod|bar|rail|pipe)/.test(text)
|
|
1196
|
+
|| Number(sourceMaterial?.metalness ?? 0) > 0.45
|
|
1197
|
+
) {
|
|
1198
|
+
baseMaterial = 'metal';
|
|
1199
|
+
finish = /(chrome|polish|mirror)/.test(text)
|
|
1200
|
+
? 'polished'
|
|
1201
|
+
: /(brush)/.test(text)
|
|
1202
|
+
? 'brushed'
|
|
1203
|
+
: /(handle|hinge|rod|bar|rail|pipe|bare)/.test(text)
|
|
1204
|
+
? 'raw'
|
|
1205
|
+
: 'painted';
|
|
1206
|
+
confidence = /(metal|steel|iron|alum|chrome|copper|brass)/.test(text) ? 0.94 : 0.72;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
if (/(top|lid|cover|roof|gable)/.test(text) && structuralRole === 'primaryMass') {
|
|
1210
|
+
structuralRole = 'secondaryStructure';
|
|
1211
|
+
}
|
|
1212
|
+
if (/(trim|frame|grate|extra)/.test(text) && structuralRole === 'primaryMass') {
|
|
1213
|
+
structuralRole = 'trim';
|
|
1214
|
+
}
|
|
1215
|
+
if (/(handle|hinge|fastener|bolt|screw|rod|bar|rail|pipe)/.test(text)) {
|
|
1216
|
+
structuralRole = 'fastener';
|
|
1217
|
+
}
|
|
1218
|
+
if (/(cavity|interior|inside|recess|void)/.test(text)) {
|
|
1219
|
+
structuralRole = 'cavity';
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
return createUrbanMaterialClassification({
|
|
1223
|
+
baseMaterial,
|
|
1224
|
+
finish,
|
|
1225
|
+
renderMode,
|
|
1226
|
+
structuralRole,
|
|
1227
|
+
contentFlags,
|
|
1228
|
+
classificationSource: baseMaterial === 'genericDielectric' ? 'fallback' : 'inferred',
|
|
1229
|
+
confidence,
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
export function classifyUrbanPropSurface(object, materialOverride = null) {
|
|
1234
|
+
return resolveUrbanMaterialProfile(
|
|
1235
|
+
classifyUrbanMaterial(object, materialOverride),
|
|
1236
|
+
);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
function installLockedLookShader(
|
|
1240
|
+
material,
|
|
1241
|
+
source,
|
|
1242
|
+
profile,
|
|
1243
|
+
controls,
|
|
1244
|
+
{ isMirror = false } = {},
|
|
1245
|
+
) {
|
|
1246
|
+
const sourceAnchor = deriveTextureAnchor(source?.map);
|
|
1247
|
+
const sourceResponseMap = source?.roughnessMap ?? source?.metalnessMap ?? null;
|
|
1248
|
+
const sourceImage = source?.map?.image;
|
|
1249
|
+
const sourceWidth = sourceImage?.width ?? sourceImage?.videoWidth ?? 1024;
|
|
1250
|
+
const sourceHeight = sourceImage?.height ?? sourceImage?.videoHeight ?? 1024;
|
|
1251
|
+
const sourceResponseImage = sourceResponseMap?.image ?? sourceImage;
|
|
1252
|
+
const sourceResponseWidth = sourceResponseImage?.width
|
|
1253
|
+
?? sourceResponseImage?.videoWidth
|
|
1254
|
+
?? sourceWidth;
|
|
1255
|
+
const sourceResponseHeight = sourceResponseImage?.height
|
|
1256
|
+
?? sourceResponseImage?.videoHeight
|
|
1257
|
+
?? sourceHeight;
|
|
1258
|
+
const sourceTexelSize = {
|
|
1259
|
+
value: new THREE.Vector2(1 / sourceWidth, 1 / sourceHeight),
|
|
1260
|
+
};
|
|
1261
|
+
const sourceBaseColor = {
|
|
1262
|
+
value: source?.color?.clone?.() ?? new THREE.Color(0xffffff),
|
|
1263
|
+
};
|
|
1264
|
+
const sourceMetalness = {
|
|
1265
|
+
value: Number.isFinite(source?.metalness)
|
|
1266
|
+
? source.metalness
|
|
1267
|
+
: profile.fallbackMetalness,
|
|
1268
|
+
};
|
|
1269
|
+
const sourceRoughness = {
|
|
1270
|
+
value: Number.isFinite(source?.roughness) ? source.roughness : 0.72,
|
|
1271
|
+
};
|
|
1272
|
+
material.onBeforeCompile = (shader) => {
|
|
1273
|
+
shader.uniforms.urbanAccentColor = controls.accentColor;
|
|
1274
|
+
shader.uniforms.urbanCoolShadowColor = controls.coolShadowColor;
|
|
1275
|
+
shader.uniforms.urbanCoolShadowsEnabled = controls.coolShadowsEnabled;
|
|
1276
|
+
shader.uniforms.urbanCoolShadowStrength = controls.coolShadowStrength;
|
|
1277
|
+
shader.uniforms.urbanColorLiftEnabled = controls.colorLiftEnabled;
|
|
1278
|
+
shader.uniforms.urbanColorLiftStrength = controls.colorLiftStrength;
|
|
1279
|
+
shader.uniforms.urbanDecalStrength = controls.decalStrength;
|
|
1280
|
+
shader.uniforms.urbanDirtColor = controls.dirtColor;
|
|
1281
|
+
shader.uniforms.urbanFresnelColor = controls.fresnelColor;
|
|
1282
|
+
shader.uniforms.urbanFresnelEnabled = controls.fresnelEnabled;
|
|
1283
|
+
shader.uniforms.urbanFresnelStrength = controls.fresnelStrength;
|
|
1284
|
+
shader.uniforms.urbanGraphicsEnabled = controls.graphicsEnabled;
|
|
1285
|
+
shader.uniforms.urbanHighlightBandColor = controls.highlightBandColor;
|
|
1286
|
+
shader.uniforms.urbanHighlightBandEnabled = controls.highlightBandEnabled;
|
|
1287
|
+
shader.uniforms.urbanHighlightBandStrength = controls.highlightBandStrength;
|
|
1288
|
+
shader.uniforms.urbanHighlightStrength = controls.highlightStrength;
|
|
1289
|
+
shader.uniforms.urbanMapTexelSize = sourceTexelSize;
|
|
1290
|
+
shader.uniforms.urbanMaterialResponseColor = controls.materialResponseColor;
|
|
1291
|
+
shader.uniforms.urbanMaterialResponseEnabled = controls.materialResponseEnabled;
|
|
1292
|
+
shader.uniforms.urbanMaterialResponseMap = {
|
|
1293
|
+
value: sourceResponseMap ?? source?.map ?? null,
|
|
1294
|
+
};
|
|
1295
|
+
shader.uniforms.urbanMaterialResponseMapEnabled = {
|
|
1296
|
+
value: sourceResponseMap ? 1 : 0,
|
|
1297
|
+
};
|
|
1298
|
+
shader.uniforms.urbanMaterialResponseStrength = controls.materialResponseStrength;
|
|
1299
|
+
shader.uniforms.urbanMaterialResponseTexelSize = {
|
|
1300
|
+
value: new THREE.Vector2(
|
|
1301
|
+
1 / sourceResponseWidth,
|
|
1302
|
+
1 / sourceResponseHeight,
|
|
1303
|
+
),
|
|
1304
|
+
};
|
|
1305
|
+
shader.uniforms.urbanPaintBandsEnabled = controls.paintBandsEnabled;
|
|
1306
|
+
shader.uniforms.urbanPaintExtractionEnabled = controls.paintExtractionEnabled;
|
|
1307
|
+
shader.uniforms.urbanPaintExtractionStrength = controls.paintExtractionStrength;
|
|
1308
|
+
shader.uniforms.urbanPastelBlueColor = controls.pastelBlueColor;
|
|
1309
|
+
shader.uniforms.urbanPastelPaletteEnabled = controls.pastelPaletteEnabled;
|
|
1310
|
+
shader.uniforms.urbanPastelStrength = controls.pastelStrength;
|
|
1311
|
+
shader.uniforms.urbanPlanarSheenEnabled = controls.planarSheenEnabled;
|
|
1312
|
+
shader.uniforms.urbanPlanarSheenStrength = controls.planarSheenStrength;
|
|
1313
|
+
shader.uniforms.urbanPaletteOverride = controls.paletteOverride;
|
|
1314
|
+
shader.uniforms.urbanRimLeftColor = controls.rimLeftColor;
|
|
1315
|
+
shader.uniforms.urbanRimRightColor = controls.rimRightColor;
|
|
1316
|
+
shader.uniforms.urbanRimEnabled = controls.rimEnabled;
|
|
1317
|
+
shader.uniforms.urbanReflectionNormalEnabled =
|
|
1318
|
+
controls.reflectionNormalEnabled;
|
|
1319
|
+
shader.uniforms.urbanReflectionNormalStrength =
|
|
1320
|
+
controls.reflectionNormalStrength;
|
|
1321
|
+
if (isMirror) {
|
|
1322
|
+
shader.uniforms.urbanReflectionProbeAvailable =
|
|
1323
|
+
controls.reflectionProbeAvailable;
|
|
1324
|
+
shader.uniforms.urbanReflectionProbeLayerEnabled =
|
|
1325
|
+
controls.reflectionProbeLayerEnabled;
|
|
1326
|
+
shader.uniforms.urbanReflectionProbeMap = controls.reflectionProbeMap;
|
|
1327
|
+
shader.uniforms.urbanReflectionProbeStrength =
|
|
1328
|
+
controls.reflectionProbeStrength;
|
|
1329
|
+
}
|
|
1330
|
+
shader.uniforms.urbanReflectionSelectivityEnabled =
|
|
1331
|
+
controls.reflectionSelectivityEnabled;
|
|
1332
|
+
shader.uniforms.urbanReflectionSelectivityStrength =
|
|
1333
|
+
controls.reflectionSelectivityStrength;
|
|
1334
|
+
shader.uniforms.urbanRoleColor = controls[profile.colorControl];
|
|
1335
|
+
shader.uniforms.urbanRoughnessBreakupEnabled =
|
|
1336
|
+
controls.roughnessBreakupEnabled;
|
|
1337
|
+
shader.uniforms.urbanRoughnessBreakupStrength =
|
|
1338
|
+
controls.roughnessBreakupStrength;
|
|
1339
|
+
shader.uniforms.urbanShadowPastelEnabled = controls.shadowPastelEnabled;
|
|
1340
|
+
shader.uniforms.urbanShadowPastelStrength = controls.shadowPastelStrength;
|
|
1341
|
+
shader.uniforms.urbanSourceAnchorColor = { value: sourceAnchor.color };
|
|
1342
|
+
shader.uniforms.urbanSourceAnchorStrength = { value: sourceAnchor.strength };
|
|
1343
|
+
shader.uniforms.urbanSourceAuthorityEnabled = controls.sourceAuthorityEnabled;
|
|
1344
|
+
shader.uniforms.urbanSourceAuthorityStrength = controls.sourceAuthorityStrength;
|
|
1345
|
+
shader.uniforms.urbanSourceBaseColor = sourceBaseColor;
|
|
1346
|
+
shader.uniforms.urbanSourceMetalness = sourceMetalness;
|
|
1347
|
+
shader.uniforms.urbanSourceRoughness = sourceRoughness;
|
|
1348
|
+
shader.uniforms.urbanViewReflectionEnabled = controls.viewReflectionEnabled;
|
|
1349
|
+
shader.uniforms.urbanViewReflectionStrength = controls.viewReflectionStrength;
|
|
1350
|
+
shader.uniforms.urbanWearAmount = controls.wearAmount;
|
|
1351
|
+
shader.uniforms.urbanWearEnabled = controls.wearEnabled;
|
|
1352
|
+
|
|
1353
|
+
shader.fragmentShader = `
|
|
1354
|
+
uniform vec3 urbanAccentColor;
|
|
1355
|
+
uniform vec3 urbanCoolShadowColor;
|
|
1356
|
+
uniform float urbanCoolShadowsEnabled;
|
|
1357
|
+
uniform float urbanCoolShadowStrength;
|
|
1358
|
+
uniform float urbanColorLiftEnabled;
|
|
1359
|
+
uniform float urbanColorLiftStrength;
|
|
1360
|
+
uniform float urbanDecalStrength;
|
|
1361
|
+
uniform vec3 urbanDirtColor;
|
|
1362
|
+
uniform vec3 urbanFresnelColor;
|
|
1363
|
+
uniform float urbanFresnelEnabled;
|
|
1364
|
+
uniform float urbanFresnelStrength;
|
|
1365
|
+
uniform float urbanGraphicsEnabled;
|
|
1366
|
+
uniform vec3 urbanHighlightBandColor;
|
|
1367
|
+
uniform float urbanHighlightBandEnabled;
|
|
1368
|
+
uniform float urbanHighlightBandStrength;
|
|
1369
|
+
uniform float urbanHighlightStrength;
|
|
1370
|
+
uniform vec2 urbanMapTexelSize;
|
|
1371
|
+
uniform vec3 urbanMaterialResponseColor;
|
|
1372
|
+
uniform float urbanMaterialResponseEnabled;
|
|
1373
|
+
uniform sampler2D urbanMaterialResponseMap;
|
|
1374
|
+
uniform float urbanMaterialResponseMapEnabled;
|
|
1375
|
+
uniform float urbanMaterialResponseStrength;
|
|
1376
|
+
uniform vec2 urbanMaterialResponseTexelSize;
|
|
1377
|
+
uniform float urbanPaintBandsEnabled;
|
|
1378
|
+
uniform float urbanPaintExtractionEnabled;
|
|
1379
|
+
uniform float urbanPaintExtractionStrength;
|
|
1380
|
+
uniform vec3 urbanPastelBlueColor;
|
|
1381
|
+
uniform float urbanPastelPaletteEnabled;
|
|
1382
|
+
uniform float urbanPastelStrength;
|
|
1383
|
+
uniform float urbanPlanarSheenEnabled;
|
|
1384
|
+
uniform float urbanPlanarSheenStrength;
|
|
1385
|
+
uniform float urbanPaletteOverride;
|
|
1386
|
+
uniform vec3 urbanRimLeftColor;
|
|
1387
|
+
uniform vec3 urbanRimRightColor;
|
|
1388
|
+
uniform float urbanRimEnabled;
|
|
1389
|
+
uniform float urbanReflectionNormalEnabled;
|
|
1390
|
+
uniform float urbanReflectionNormalStrength;
|
|
1391
|
+
${isMirror ? `
|
|
1392
|
+
uniform float urbanReflectionProbeAvailable;
|
|
1393
|
+
uniform float urbanReflectionProbeLayerEnabled;
|
|
1394
|
+
uniform samplerCube urbanReflectionProbeMap;
|
|
1395
|
+
uniform float urbanReflectionProbeStrength;
|
|
1396
|
+
` : ''}
|
|
1397
|
+
uniform float urbanReflectionSelectivityEnabled;
|
|
1398
|
+
uniform float urbanReflectionSelectivityStrength;
|
|
1399
|
+
uniform vec3 urbanRoleColor;
|
|
1400
|
+
uniform float urbanRoughnessBreakupEnabled;
|
|
1401
|
+
uniform float urbanRoughnessBreakupStrength;
|
|
1402
|
+
uniform float urbanShadowPastelEnabled;
|
|
1403
|
+
uniform float urbanShadowPastelStrength;
|
|
1404
|
+
uniform vec3 urbanSourceAnchorColor;
|
|
1405
|
+
uniform float urbanSourceAnchorStrength;
|
|
1406
|
+
uniform float urbanSourceAuthorityEnabled;
|
|
1407
|
+
uniform float urbanSourceAuthorityStrength;
|
|
1408
|
+
uniform vec3 urbanSourceBaseColor;
|
|
1409
|
+
uniform float urbanSourceMetalness;
|
|
1410
|
+
uniform float urbanSourceRoughness;
|
|
1411
|
+
uniform float urbanViewReflectionEnabled;
|
|
1412
|
+
uniform float urbanViewReflectionStrength;
|
|
1413
|
+
uniform float urbanWearAmount;
|
|
1414
|
+
uniform float urbanWearEnabled;
|
|
1415
|
+
${shader.fragmentShader}`;
|
|
1416
|
+
|
|
1417
|
+
shader.fragmentShader = shader.fragmentShader.replace(
|
|
1418
|
+
'#include <map_fragment>',
|
|
1419
|
+
source?.map
|
|
1420
|
+
? `
|
|
1421
|
+
vec4 urbanSourceSample = texture2D(map, vMapUv);
|
|
1422
|
+
vec2 urbanMacroRadius = urbanMapTexelSize
|
|
1423
|
+
* mix(
|
|
1424
|
+
1.0,
|
|
1425
|
+
34.0,
|
|
1426
|
+
urbanPaintExtractionStrength * urbanPaintExtractionEnabled
|
|
1427
|
+
);
|
|
1428
|
+
vec4 urbanBlurredMacroSample = urbanSourceSample * 0.20;
|
|
1429
|
+
urbanBlurredMacroSample += texture2D(
|
|
1430
|
+
map,
|
|
1431
|
+
vMapUv + vec2(urbanMacroRadius.x, 0.0)
|
|
1432
|
+
) * 0.10;
|
|
1433
|
+
urbanBlurredMacroSample += texture2D(
|
|
1434
|
+
map,
|
|
1435
|
+
vMapUv - vec2(urbanMacroRadius.x, 0.0)
|
|
1436
|
+
) * 0.10;
|
|
1437
|
+
urbanBlurredMacroSample += texture2D(
|
|
1438
|
+
map,
|
|
1439
|
+
vMapUv + vec2(0.0, urbanMacroRadius.y)
|
|
1440
|
+
) * 0.10;
|
|
1441
|
+
urbanBlurredMacroSample += texture2D(
|
|
1442
|
+
map,
|
|
1443
|
+
vMapUv - vec2(0.0, urbanMacroRadius.y)
|
|
1444
|
+
) * 0.10;
|
|
1445
|
+
urbanBlurredMacroSample += texture2D(
|
|
1446
|
+
map,
|
|
1447
|
+
vMapUv + urbanMacroRadius
|
|
1448
|
+
) * 0.10;
|
|
1449
|
+
urbanBlurredMacroSample += texture2D(
|
|
1450
|
+
map,
|
|
1451
|
+
vMapUv - urbanMacroRadius
|
|
1452
|
+
) * 0.10;
|
|
1453
|
+
urbanBlurredMacroSample += texture2D(
|
|
1454
|
+
map,
|
|
1455
|
+
vMapUv + vec2(urbanMacroRadius.x, -urbanMacroRadius.y)
|
|
1456
|
+
) * 0.10;
|
|
1457
|
+
urbanBlurredMacroSample += texture2D(
|
|
1458
|
+
map,
|
|
1459
|
+
vMapUv + vec2(-urbanMacroRadius.x, urbanMacroRadius.y)
|
|
1460
|
+
) * 0.10;
|
|
1461
|
+
|
|
1462
|
+
vec2 urbanUltraRadius = urbanMapTexelSize * 96.0;
|
|
1463
|
+
vec4 urbanBlurredUltraMacroSample = texture2D(
|
|
1464
|
+
map,
|
|
1465
|
+
vMapUv + vec2(urbanUltraRadius.x, 0.0)
|
|
1466
|
+
) * 0.25;
|
|
1467
|
+
urbanBlurredUltraMacroSample += texture2D(
|
|
1468
|
+
map,
|
|
1469
|
+
vMapUv - vec2(urbanUltraRadius.x, 0.0)
|
|
1470
|
+
) * 0.25;
|
|
1471
|
+
urbanBlurredUltraMacroSample += texture2D(
|
|
1472
|
+
map,
|
|
1473
|
+
vMapUv + vec2(0.0, urbanUltraRadius.y)
|
|
1474
|
+
) * 0.25;
|
|
1475
|
+
urbanBlurredUltraMacroSample += texture2D(
|
|
1476
|
+
map,
|
|
1477
|
+
vMapUv - vec2(0.0, urbanUltraRadius.y)
|
|
1478
|
+
) * 0.25;
|
|
1479
|
+
float urbanGraphicSafeMacro =
|
|
1480
|
+
${(profile.graphicSafeMacro ?? 0).toFixed(4)};
|
|
1481
|
+
vec4 urbanMacroSample = mix(
|
|
1482
|
+
urbanBlurredMacroSample,
|
|
1483
|
+
urbanSourceSample,
|
|
1484
|
+
urbanGraphicSafeMacro
|
|
1485
|
+
);
|
|
1486
|
+
vec4 urbanUltraMacroSample = mix(
|
|
1487
|
+
urbanBlurredUltraMacroSample,
|
|
1488
|
+
urbanSourceSample,
|
|
1489
|
+
urbanGraphicSafeMacro
|
|
1490
|
+
);
|
|
1491
|
+
vec3 urbanSharpColor = urbanSourceSample.rgb * urbanSourceBaseColor;
|
|
1492
|
+
vec3 urbanMacroColor = urbanMacroSample.rgb * urbanSourceBaseColor;
|
|
1493
|
+
vec3 urbanUltraMacroColor = urbanUltraMacroSample.rgb
|
|
1494
|
+
* urbanSourceBaseColor;
|
|
1495
|
+
|
|
1496
|
+
float urbanSharpLuma = dot(
|
|
1497
|
+
urbanSharpColor,
|
|
1498
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
1499
|
+
);
|
|
1500
|
+
float urbanMacroLuma = dot(
|
|
1501
|
+
urbanMacroColor,
|
|
1502
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
1503
|
+
);
|
|
1504
|
+
float urbanSharpHigh = max(
|
|
1505
|
+
max(urbanSharpColor.r, urbanSharpColor.g),
|
|
1506
|
+
urbanSharpColor.b
|
|
1507
|
+
);
|
|
1508
|
+
float urbanSharpLow = min(
|
|
1509
|
+
min(urbanSharpColor.r, urbanSharpColor.g),
|
|
1510
|
+
urbanSharpColor.b
|
|
1511
|
+
);
|
|
1512
|
+
float urbanSharpChroma = urbanSharpHigh - urbanSharpLow;
|
|
1513
|
+
float urbanSharpRelativeChroma = urbanSharpChroma
|
|
1514
|
+
/ max(urbanSharpHigh, 0.06);
|
|
1515
|
+
float urbanLocalNeutralMask = 1.0 - smoothstep(
|
|
1516
|
+
0.055,
|
|
1517
|
+
0.18,
|
|
1518
|
+
urbanSharpRelativeChroma
|
|
1519
|
+
);
|
|
1520
|
+
// Black is a local source property, not a material-wide class. A
|
|
1521
|
+
// mixed atlas can contain rust-red paint and a neutral black bike;
|
|
1522
|
+
// the colored texels must not grant their hue to the black texels.
|
|
1523
|
+
float urbanLocalBlackMask = (
|
|
1524
|
+
1.0 - smoothstep(0.10, 0.34, urbanSharpHigh)
|
|
1525
|
+
) * (
|
|
1526
|
+
1.0 - smoothstep(0.06, 0.20, urbanSharpRelativeChroma)
|
|
1527
|
+
);
|
|
1528
|
+
float urbanMacroHigh = max(
|
|
1529
|
+
max(urbanMacroColor.r, urbanMacroColor.g),
|
|
1530
|
+
urbanMacroColor.b
|
|
1531
|
+
);
|
|
1532
|
+
float urbanMacroLow = min(
|
|
1533
|
+
min(urbanMacroColor.r, urbanMacroColor.g),
|
|
1534
|
+
urbanMacroColor.b
|
|
1535
|
+
);
|
|
1536
|
+
float urbanLocalContrast = smoothstep(
|
|
1537
|
+
0.04,
|
|
1538
|
+
0.22,
|
|
1539
|
+
length(urbanSharpColor - urbanMacroColor)
|
|
1540
|
+
);
|
|
1541
|
+
|
|
1542
|
+
vec3 urbanSharpHue = urbanSharpColor / max(urbanSharpHigh, 0.035);
|
|
1543
|
+
vec3 urbanMacroHue = urbanMacroColor / max(urbanMacroHigh, 0.035);
|
|
1544
|
+
float urbanAnchorHigh = max(
|
|
1545
|
+
max(urbanSourceAnchorColor.r, urbanSourceAnchorColor.g),
|
|
1546
|
+
urbanSourceAnchorColor.b
|
|
1547
|
+
);
|
|
1548
|
+
float urbanAnchorLow = min(
|
|
1549
|
+
min(urbanSourceAnchorColor.r, urbanSourceAnchorColor.g),
|
|
1550
|
+
urbanSourceAnchorColor.b
|
|
1551
|
+
);
|
|
1552
|
+
vec3 urbanAnchorHue = urbanSourceAnchorColor
|
|
1553
|
+
/ max(urbanAnchorHigh, 0.035);
|
|
1554
|
+
vec3 urbanPaintHue = mix(
|
|
1555
|
+
urbanMacroHue,
|
|
1556
|
+
urbanAnchorHue,
|
|
1557
|
+
urbanSourceAnchorStrength
|
|
1558
|
+
);
|
|
1559
|
+
float urbanRoleHigh = max(
|
|
1560
|
+
max(urbanRoleColor.r, urbanRoleColor.g),
|
|
1561
|
+
urbanRoleColor.b
|
|
1562
|
+
);
|
|
1563
|
+
vec3 urbanRoleHue = urbanRoleColor / max(urbanRoleHigh, 0.035);
|
|
1564
|
+
vec3 urbanWearReferenceHue = mix(
|
|
1565
|
+
urbanRoleHue,
|
|
1566
|
+
urbanAnchorHue,
|
|
1567
|
+
urbanSourceAnchorStrength
|
|
1568
|
+
);
|
|
1569
|
+
urbanPaintHue = mix(
|
|
1570
|
+
urbanPaintHue,
|
|
1571
|
+
urbanRoleHue,
|
|
1572
|
+
${profile.roleColorMix.toFixed(4)}
|
|
1573
|
+
);
|
|
1574
|
+
float urbanPaletteHigh = max(
|
|
1575
|
+
max(diffuseColor.r, diffuseColor.g),
|
|
1576
|
+
diffuseColor.b
|
|
1577
|
+
);
|
|
1578
|
+
vec3 urbanPaletteHue = diffuseColor.rgb / max(urbanPaletteHigh, 0.035);
|
|
1579
|
+
urbanPaintHue = mix(
|
|
1580
|
+
urbanPaintHue,
|
|
1581
|
+
urbanPaletteHue,
|
|
1582
|
+
urbanPaletteOverride
|
|
1583
|
+
);
|
|
1584
|
+
|
|
1585
|
+
float urbanSharpNeutral = 1.0 - smoothstep(
|
|
1586
|
+
0.08,
|
|
1587
|
+
0.34,
|
|
1588
|
+
urbanSharpChroma
|
|
1589
|
+
);
|
|
1590
|
+
float urbanGraphicMask = smoothstep(
|
|
1591
|
+
${(profile.decalThreshold * 0.45).toFixed(4)},
|
|
1592
|
+
0.46,
|
|
1593
|
+
urbanSharpLuma
|
|
1594
|
+
) * urbanSharpNeutral
|
|
1595
|
+
* smoothstep(
|
|
1596
|
+
0.06,
|
|
1597
|
+
0.24,
|
|
1598
|
+
urbanSharpLuma - urbanMacroLuma
|
|
1599
|
+
)
|
|
1600
|
+
* smoothstep(
|
|
1601
|
+
0.018,
|
|
1602
|
+
0.14,
|
|
1603
|
+
length(urbanSharpColor - urbanMacroColor)
|
|
1604
|
+
)
|
|
1605
|
+
* ${profile.decalScale.toFixed(4)};
|
|
1606
|
+
|
|
1607
|
+
float urbanMacroValue = pow(
|
|
1608
|
+
clamp(urbanMacroHigh, 0.0, 1.0),
|
|
1609
|
+
0.72
|
|
1610
|
+
);
|
|
1611
|
+
float urbanSmoothPaintValue = ${profile.paintValue.toFixed(4)}
|
|
1612
|
+
* mix(0.74, 1.18, smoothstep(0.16, 0.78, urbanMacroValue));
|
|
1613
|
+
float urbanPaintBandValue = ${profile.paintValue.toFixed(4)} * 0.72;
|
|
1614
|
+
urbanPaintBandValue = mix(
|
|
1615
|
+
urbanPaintBandValue,
|
|
1616
|
+
${profile.paintValue.toFixed(4)},
|
|
1617
|
+
step(0.31, urbanMacroValue)
|
|
1618
|
+
);
|
|
1619
|
+
urbanPaintBandValue = mix(
|
|
1620
|
+
urbanPaintBandValue,
|
|
1621
|
+
min(0.96, ${profile.paintValue.toFixed(4)} * 1.18),
|
|
1622
|
+
step(0.68, urbanMacroValue)
|
|
1623
|
+
);
|
|
1624
|
+
float urbanPaintValue = mix(
|
|
1625
|
+
urbanSmoothPaintValue,
|
|
1626
|
+
urbanPaintBandValue,
|
|
1627
|
+
urbanPaintBandsEnabled
|
|
1628
|
+
);
|
|
1629
|
+
|
|
1630
|
+
float urbanPaintLift = urbanColorLiftEnabled
|
|
1631
|
+
* urbanColorLiftStrength
|
|
1632
|
+
* ${profile.colorLiftScale.toFixed(4)};
|
|
1633
|
+
urbanPaintValue = min(
|
|
1634
|
+
0.98,
|
|
1635
|
+
urbanPaintValue + 0.24 * urbanPaintLift
|
|
1636
|
+
);
|
|
1637
|
+
float urbanPaintHueLuma = dot(
|
|
1638
|
+
urbanPaintHue,
|
|
1639
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
1640
|
+
);
|
|
1641
|
+
urbanPaintHue = clamp(
|
|
1642
|
+
mix(
|
|
1643
|
+
vec3(urbanPaintHueLuma),
|
|
1644
|
+
urbanPaintHue,
|
|
1645
|
+
1.0 + 0.88 * urbanPaintLift
|
|
1646
|
+
),
|
|
1647
|
+
0.0,
|
|
1648
|
+
1.36
|
|
1649
|
+
);
|
|
1650
|
+
float urbanLocalSourceChroma = urbanMacroHigh - urbanMacroLow;
|
|
1651
|
+
float urbanLocalRelativeChroma = urbanLocalSourceChroma
|
|
1652
|
+
/ max(urbanMacroHigh, 0.08);
|
|
1653
|
+
float urbanMacroColorPresence = max(
|
|
1654
|
+
smoothstep(
|
|
1655
|
+
0.035,
|
|
1656
|
+
0.10,
|
|
1657
|
+
urbanLocalSourceChroma
|
|
1658
|
+
),
|
|
1659
|
+
smoothstep(
|
|
1660
|
+
0.30,
|
|
1661
|
+
0.52,
|
|
1662
|
+
urbanLocalRelativeChroma
|
|
1663
|
+
) * smoothstep(
|
|
1664
|
+
0.008,
|
|
1665
|
+
0.035,
|
|
1666
|
+
urbanMacroHigh
|
|
1667
|
+
)
|
|
1668
|
+
);
|
|
1669
|
+
// Macro evidence defines a material's local color class. Sharp
|
|
1670
|
+
// scratches are detail/wear and cannot reclassify neutral structure.
|
|
1671
|
+
float urbanLocalColorPresence = urbanMacroColorPresence;
|
|
1672
|
+
vec3 urbanLocalSourceHue = urbanMacroHue;
|
|
1673
|
+
float urbanAnchorColorPresence = smoothstep(
|
|
1674
|
+
0.035,
|
|
1675
|
+
0.14,
|
|
1676
|
+
urbanAnchorHigh - urbanAnchorLow
|
|
1677
|
+
);
|
|
1678
|
+
float urbanAnchorAgreement = 1.0 - smoothstep(
|
|
1679
|
+
0.18,
|
|
1680
|
+
0.62,
|
|
1681
|
+
distance(urbanLocalSourceHue, urbanAnchorHue)
|
|
1682
|
+
);
|
|
1683
|
+
float urbanAnchorConfidence = smoothstep(
|
|
1684
|
+
0.08,
|
|
1685
|
+
0.32,
|
|
1686
|
+
urbanSourceAnchorStrength
|
|
1687
|
+
);
|
|
1688
|
+
float urbanAnchorAuthority = urbanAnchorConfidence
|
|
1689
|
+
* ${profile.sourceAnchorAuthorityScale.toFixed(4)};
|
|
1690
|
+
float urbanSourceColorPresence = max(
|
|
1691
|
+
urbanLocalColorPresence,
|
|
1692
|
+
urbanAnchorColorPresence
|
|
1693
|
+
* urbanAnchorAuthority
|
|
1694
|
+
);
|
|
1695
|
+
float urbanAnchorTrust = urbanAnchorAuthority * mix(
|
|
1696
|
+
1.0,
|
|
1697
|
+
urbanAnchorAgreement,
|
|
1698
|
+
urbanLocalColorPresence
|
|
1699
|
+
);
|
|
1700
|
+
vec3 urbanStableSourceHue = mix(
|
|
1701
|
+
vec3(1.0),
|
|
1702
|
+
mix(
|
|
1703
|
+
urbanLocalSourceHue,
|
|
1704
|
+
urbanAnchorHue,
|
|
1705
|
+
urbanAnchorTrust
|
|
1706
|
+
),
|
|
1707
|
+
urbanSourceColorPresence
|
|
1708
|
+
);
|
|
1709
|
+
float urbanSourceAuthority = urbanSourceAuthorityEnabled
|
|
1710
|
+
* urbanSourceAuthorityStrength
|
|
1711
|
+
* (1.0 - urbanPaletteOverride);
|
|
1712
|
+
urbanPaintHue = mix(
|
|
1713
|
+
urbanPaintHue,
|
|
1714
|
+
urbanStableSourceHue,
|
|
1715
|
+
urbanSourceAuthority
|
|
1716
|
+
* ${profile.sourceHueAuthorityScale.toFixed(4)}
|
|
1717
|
+
);
|
|
1718
|
+
// A credible saturated texture anchor identifies weathering inside
|
|
1719
|
+
// one painted material (the dumpster). A muted neutral atlas has no
|
|
1720
|
+
// such anchor, so its dark structure remains neutral (the station).
|
|
1721
|
+
float urbanSourceNeutralClass = 1.0 - urbanSourceColorPresence;
|
|
1722
|
+
float urbanDarkNeutralMask = urbanSourceNeutralClass * (
|
|
1723
|
+
1.0 - smoothstep(0.16, 0.48, urbanMacroHigh)
|
|
1724
|
+
);
|
|
1725
|
+
float urbanSourceBlackMask = urbanSourceNeutralClass * (
|
|
1726
|
+
1.0 - smoothstep(0.10, 0.34, urbanMacroHigh)
|
|
1727
|
+
);
|
|
1728
|
+
urbanDarkNeutralMask = max(
|
|
1729
|
+
urbanDarkNeutralMask,
|
|
1730
|
+
urbanLocalBlackMask
|
|
1731
|
+
);
|
|
1732
|
+
urbanSourceBlackMask = max(
|
|
1733
|
+
urbanSourceBlackMask,
|
|
1734
|
+
urbanLocalBlackMask
|
|
1735
|
+
);
|
|
1736
|
+
float urbanRawStableSourceValue = clamp(
|
|
1737
|
+
mix(
|
|
1738
|
+
urbanMacroHigh,
|
|
1739
|
+
urbanAnchorHigh,
|
|
1740
|
+
urbanAnchorConfidence
|
|
1741
|
+
),
|
|
1742
|
+
0.015,
|
|
1743
|
+
1.0
|
|
1744
|
+
);
|
|
1745
|
+
float urbanStableSourceValue = mix(
|
|
1746
|
+
pow(urbanRawStableSourceValue, 0.82),
|
|
1747
|
+
max(0.012, urbanRawStableSourceValue * 0.52),
|
|
1748
|
+
urbanSourceBlackMask
|
|
1749
|
+
);
|
|
1750
|
+
urbanPaintValue = mix(
|
|
1751
|
+
urbanPaintValue,
|
|
1752
|
+
urbanStableSourceValue,
|
|
1753
|
+
urbanSourceAuthority
|
|
1754
|
+
* max(urbanSourceNeutralClass, urbanLocalBlackMask)
|
|
1755
|
+
* ${Math.max(
|
|
1756
|
+
profile.sourceValueAuthorityScale,
|
|
1757
|
+
profile.sourceHueAuthorityScale,
|
|
1758
|
+
).toFixed(4)}
|
|
1759
|
+
);
|
|
1760
|
+
float urbanCoolBlueGate = smoothstep(
|
|
1761
|
+
0.025,
|
|
1762
|
+
0.14,
|
|
1763
|
+
urbanPaintHue.b - max(urbanPaintHue.r, urbanPaintHue.g)
|
|
1764
|
+
) * urbanPastelPaletteEnabled * ${profile.pastelScale.toFixed(4)};
|
|
1765
|
+
float urbanPastelMix = urbanCoolBlueGate
|
|
1766
|
+
* urbanPastelStrength;
|
|
1767
|
+
float urbanPastelHigh = max(
|
|
1768
|
+
max(urbanPastelBlueColor.r, urbanPastelBlueColor.g),
|
|
1769
|
+
urbanPastelBlueColor.b
|
|
1770
|
+
);
|
|
1771
|
+
vec3 urbanPastelHue = urbanPastelBlueColor
|
|
1772
|
+
/ max(urbanPastelHigh, 0.035);
|
|
1773
|
+
urbanPaintHue = mix(
|
|
1774
|
+
urbanPaintHue,
|
|
1775
|
+
urbanPastelHue,
|
|
1776
|
+
urbanPastelMix
|
|
1777
|
+
);
|
|
1778
|
+
urbanPaintValue = mix(
|
|
1779
|
+
urbanPaintValue,
|
|
1780
|
+
0.68,
|
|
1781
|
+
urbanPastelMix
|
|
1782
|
+
);
|
|
1783
|
+
vec3 urbanCleanPaint = clamp(
|
|
1784
|
+
urbanPaintHue * urbanPaintValue,
|
|
1785
|
+
0.0,
|
|
1786
|
+
1.0
|
|
1787
|
+
);
|
|
1788
|
+
float urbanLocalBlackValue = clamp(
|
|
1789
|
+
urbanSharpLuma * 0.72 + 0.008,
|
|
1790
|
+
0.008,
|
|
1791
|
+
0.12
|
|
1792
|
+
);
|
|
1793
|
+
urbanCleanPaint = mix(
|
|
1794
|
+
urbanCleanPaint,
|
|
1795
|
+
vec3(urbanLocalBlackValue),
|
|
1796
|
+
urbanLocalBlackMask * urbanSourceAuthority
|
|
1797
|
+
);
|
|
1798
|
+
|
|
1799
|
+
float urbanSharpWarmRust = smoothstep(
|
|
1800
|
+
0.002,
|
|
1801
|
+
0.035,
|
|
1802
|
+
urbanSharpColor.r
|
|
1803
|
+
- max(urbanSharpColor.g, urbanSharpColor.b * 0.88)
|
|
1804
|
+
) * (
|
|
1805
|
+
1.0 - smoothstep(0.72, 0.94, urbanSharpHigh)
|
|
1806
|
+
);
|
|
1807
|
+
float urbanMacroWarmWear = smoothstep(
|
|
1808
|
+
0.002,
|
|
1809
|
+
0.065,
|
|
1810
|
+
urbanMacroColor.r
|
|
1811
|
+
- max(urbanMacroColor.g, urbanMacroColor.b * 0.88)
|
|
1812
|
+
);
|
|
1813
|
+
float urbanWearStructure = smoothstep(
|
|
1814
|
+
0.035,
|
|
1815
|
+
0.22,
|
|
1816
|
+
length(urbanMacroColor - urbanUltraMacroColor)
|
|
1817
|
+
);
|
|
1818
|
+
float urbanDarkDamage = smoothstep(
|
|
1819
|
+
0.12,
|
|
1820
|
+
0.46,
|
|
1821
|
+
urbanMacroHigh - urbanSharpHigh
|
|
1822
|
+
) * urbanLocalContrast;
|
|
1823
|
+
float urbanMacroHueWear = smoothstep(
|
|
1824
|
+
0.16,
|
|
1825
|
+
0.78,
|
|
1826
|
+
distance(urbanMacroHue, urbanWearReferenceHue)
|
|
1827
|
+
) * urbanLocalColorPresence;
|
|
1828
|
+
float urbanRawWear = max(
|
|
1829
|
+
urbanMacroWarmWear * 1.4,
|
|
1830
|
+
urbanMacroHueWear * urbanWearStructure * 1.8
|
|
1831
|
+
);
|
|
1832
|
+
urbanRawWear = max(urbanRawWear, urbanDarkDamage * 0.30);
|
|
1833
|
+
urbanRawWear = max(
|
|
1834
|
+
urbanRawWear,
|
|
1835
|
+
urbanSharpWarmRust * ${profile.sharpRustBoost.toFixed(4)}
|
|
1836
|
+
);
|
|
1837
|
+
urbanRawWear = clamp(urbanRawWear, 0.0, 1.0);
|
|
1838
|
+
urbanRawWear *= 1.0 - urbanGraphicMask;
|
|
1839
|
+
float urbanWearThreshold = mix(
|
|
1840
|
+
0.90,
|
|
1841
|
+
0.40,
|
|
1842
|
+
urbanWearAmount
|
|
1843
|
+
);
|
|
1844
|
+
float urbanWearMask = smoothstep(
|
|
1845
|
+
urbanWearThreshold,
|
|
1846
|
+
min(0.98, urbanWearThreshold + 0.10),
|
|
1847
|
+
urbanRawWear
|
|
1848
|
+
) * ${profile.wearScale.toFixed(4)};
|
|
1849
|
+
float urbanWearValue = mix(
|
|
1850
|
+
0.10,
|
|
1851
|
+
0.24,
|
|
1852
|
+
step(0.46, urbanSharpHigh)
|
|
1853
|
+
);
|
|
1854
|
+
vec3 urbanWearHue = mix(
|
|
1855
|
+
urbanDirtColor,
|
|
1856
|
+
urbanSharpHue,
|
|
1857
|
+
mix(0.08, 0.82, urbanSharpWarmRust)
|
|
1858
|
+
);
|
|
1859
|
+
float urbanWearHueHigh = max(
|
|
1860
|
+
max(urbanWearHue.r, urbanWearHue.g),
|
|
1861
|
+
urbanWearHue.b
|
|
1862
|
+
);
|
|
1863
|
+
urbanWearHue /= max(urbanWearHueHigh, 0.035);
|
|
1864
|
+
vec3 urbanStylizedWear = clamp(
|
|
1865
|
+
urbanWearHue * mix(
|
|
1866
|
+
urbanWearValue,
|
|
1867
|
+
min(0.34, max(0.17, urbanSharpHigh * 0.72)),
|
|
1868
|
+
urbanSharpWarmRust
|
|
1869
|
+
),
|
|
1870
|
+
0.0,
|
|
1871
|
+
1.0
|
|
1872
|
+
);
|
|
1873
|
+
|
|
1874
|
+
float urbanExtractionMix = urbanPaintExtractionEnabled
|
|
1875
|
+
* urbanPaintExtractionStrength
|
|
1876
|
+
* ${(profile.paintExtractionScale ?? 1).toFixed(4)}
|
|
1877
|
+
* (1.0 - 0.92 * urbanGraphicMask);
|
|
1878
|
+
vec3 urbanReconstructed = mix(
|
|
1879
|
+
urbanSharpColor,
|
|
1880
|
+
urbanCleanPaint,
|
|
1881
|
+
clamp(urbanExtractionMix, 0.0, 1.0)
|
|
1882
|
+
);
|
|
1883
|
+
urbanReconstructed = mix(
|
|
1884
|
+
urbanReconstructed,
|
|
1885
|
+
urbanStylizedWear,
|
|
1886
|
+
urbanWearMask * urbanWearEnabled
|
|
1887
|
+
);
|
|
1888
|
+
|
|
1889
|
+
vec3 urbanGraphicColor = urbanAccentColor * mix(
|
|
1890
|
+
0.78,
|
|
1891
|
+
1.10,
|
|
1892
|
+
smoothstep(0.24, 0.82, urbanSharpLuma)
|
|
1893
|
+
);
|
|
1894
|
+
float urbanGraphicStrength = urbanGraphicMask
|
|
1895
|
+
* urbanGraphicsEnabled
|
|
1896
|
+
* urbanDecalStrength;
|
|
1897
|
+
diffuseColor.rgb = mix(
|
|
1898
|
+
urbanReconstructed,
|
|
1899
|
+
urbanGraphicColor,
|
|
1900
|
+
clamp(urbanGraphicStrength, 0.0, 1.0)
|
|
1901
|
+
);
|
|
1902
|
+
// Neutral metal inside a colored mixed atlas keeps its own value.
|
|
1903
|
+
// This prevents a red paint anchor from recoloring rims, spokes,
|
|
1904
|
+
// chainrings, handles, and other gray hardware.
|
|
1905
|
+
float urbanLocalNeutralValue = clamp(
|
|
1906
|
+
pow(max(urbanSharpLuma, 0.0), 0.88),
|
|
1907
|
+
0.008,
|
|
1908
|
+
0.82
|
|
1909
|
+
);
|
|
1910
|
+
diffuseColor.rgb = mix(
|
|
1911
|
+
diffuseColor.rgb,
|
|
1912
|
+
vec3(urbanLocalNeutralValue),
|
|
1913
|
+
urbanLocalNeutralMask
|
|
1914
|
+
* urbanSourceAuthority
|
|
1915
|
+
* (1.0 - urbanGraphicStrength)
|
|
1916
|
+
);
|
|
1917
|
+
// Final albedo authority for actual black texels. This must occur
|
|
1918
|
+
// after wear and graphics reconstruction because a mixed atlas can
|
|
1919
|
+
// place a red panel close enough for the macro samples to bleed into
|
|
1920
|
+
// a black bicycle frame. Light and reflection response remain later.
|
|
1921
|
+
diffuseColor.rgb = mix(
|
|
1922
|
+
diffuseColor.rgb,
|
|
1923
|
+
vec3(urbanLocalBlackValue),
|
|
1924
|
+
urbanLocalBlackMask
|
|
1925
|
+
* urbanSourceAuthority
|
|
1926
|
+
* (1.0 - urbanGraphicStrength)
|
|
1927
|
+
);
|
|
1928
|
+
diffuseColor.a *= urbanSourceSample.a;
|
|
1929
|
+
`
|
|
1930
|
+
: '',
|
|
1931
|
+
);
|
|
1932
|
+
|
|
1933
|
+
shader.fragmentShader = shader.fragmentShader.replace(
|
|
1934
|
+
'vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;',
|
|
1935
|
+
`
|
|
1936
|
+
vec3 outgoingLight = reflectedLight.directDiffuse
|
|
1937
|
+
+ reflectedLight.indirectDiffuse
|
|
1938
|
+
+ totalEmissiveRadiance;
|
|
1939
|
+
|
|
1940
|
+
float urbanAlbedoEnergy = max(
|
|
1941
|
+
dot(diffuseColor.rgb, vec3(0.2126, 0.7152, 0.0722)),
|
|
1942
|
+
0.06
|
|
1943
|
+
);
|
|
1944
|
+
float urbanDirectEnergy = dot(
|
|
1945
|
+
reflectedLight.directDiffuse,
|
|
1946
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
1947
|
+
) / urbanAlbedoEnergy;
|
|
1948
|
+
float urbanShadowMask = 1.0 - smoothstep(
|
|
1949
|
+
0.12,
|
|
1950
|
+
0.55,
|
|
1951
|
+
urbanDirectEnergy
|
|
1952
|
+
);
|
|
1953
|
+
vec3 urbanCoolShadow = outgoingLight * vec3(0.68, 0.76, 1.12)
|
|
1954
|
+
+ urbanCoolShadowColor * urbanAlbedoEnergy * 0.18;
|
|
1955
|
+
outgoingLight = mix(
|
|
1956
|
+
outgoingLight,
|
|
1957
|
+
urbanCoolShadow,
|
|
1958
|
+
urbanShadowMask
|
|
1959
|
+
* urbanCoolShadowsEnabled
|
|
1960
|
+
* urbanCoolShadowStrength
|
|
1961
|
+
);
|
|
1962
|
+
|
|
1963
|
+
float urbanShadowColorLuma = dot(
|
|
1964
|
+
outgoingLight,
|
|
1965
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
1966
|
+
);
|
|
1967
|
+
vec3 urbanShadowPastel = mix(
|
|
1968
|
+
outgoingLight,
|
|
1969
|
+
vec3(urbanShadowColorLuma),
|
|
1970
|
+
0.48
|
|
1971
|
+
) * 1.18;
|
|
1972
|
+
outgoingLight = mix(
|
|
1973
|
+
outgoingLight,
|
|
1974
|
+
urbanShadowPastel,
|
|
1975
|
+
urbanShadowMask
|
|
1976
|
+
* urbanShadowPastelEnabled
|
|
1977
|
+
* urbanShadowPastelStrength
|
|
1978
|
+
);
|
|
1979
|
+
${source?.map
|
|
1980
|
+
? `
|
|
1981
|
+
// Keep black/charcoal albedo from being lifted into a pastel body
|
|
1982
|
+
// color. Reflection layers are added later and remain fully colored.
|
|
1983
|
+
float urbanNeutralBaseLuma = dot(
|
|
1984
|
+
outgoingLight,
|
|
1985
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
1986
|
+
);
|
|
1987
|
+
vec3 urbanNeutralBase = mix(
|
|
1988
|
+
vec3(urbanNeutralBaseLuma),
|
|
1989
|
+
outgoingLight,
|
|
1990
|
+
0.16
|
|
1991
|
+
);
|
|
1992
|
+
float urbanNeutralBaseHigh = max(
|
|
1993
|
+
max(urbanNeutralBase.r, urbanNeutralBase.g),
|
|
1994
|
+
urbanNeutralBase.b
|
|
1995
|
+
);
|
|
1996
|
+
float urbanNeutralBaseCap = mix(
|
|
1997
|
+
0.15,
|
|
1998
|
+
0.065,
|
|
1999
|
+
urbanSourceBlackMask
|
|
2000
|
+
);
|
|
2001
|
+
urbanNeutralBase *= min(
|
|
2002
|
+
1.0,
|
|
2003
|
+
urbanNeutralBaseCap / max(urbanNeutralBaseHigh, 0.0001)
|
|
2004
|
+
);
|
|
2005
|
+
outgoingLight = mix(
|
|
2006
|
+
outgoingLight,
|
|
2007
|
+
urbanNeutralBase,
|
|
2008
|
+
max(urbanDarkNeutralMask, urbanSourceBlackMask)
|
|
2009
|
+
* urbanSourceAuthority
|
|
2010
|
+
);
|
|
2011
|
+
`
|
|
2012
|
+
: ''}
|
|
2013
|
+
|
|
2014
|
+
vec3 urbanViewNormal = normalize(normal);
|
|
2015
|
+
vec3 urbanReflectionNormal = urbanViewNormal;
|
|
2016
|
+
#ifdef USE_NORMALMAP_TANGENTSPACE
|
|
2017
|
+
vec3 urbanReflectionMapNormal = texture2D(
|
|
2018
|
+
normalMap,
|
|
2019
|
+
vNormalMapUv
|
|
2020
|
+
).xyz * 2.0 - 1.0;
|
|
2021
|
+
#if defined(USE_PACKED_NORMALMAP)
|
|
2022
|
+
urbanReflectionMapNormal = vec3(
|
|
2023
|
+
urbanReflectionMapNormal.xy,
|
|
2024
|
+
sqrt(
|
|
2025
|
+
saturate(
|
|
2026
|
+
1.0 - dot(
|
|
2027
|
+
urbanReflectionMapNormal.xy,
|
|
2028
|
+
urbanReflectionMapNormal.xy
|
|
2029
|
+
)
|
|
2030
|
+
)
|
|
2031
|
+
)
|
|
2032
|
+
);
|
|
2033
|
+
#endif
|
|
2034
|
+
urbanReflectionMapNormal.xy *=
|
|
2035
|
+
urbanReflectionNormalEnabled
|
|
2036
|
+
* urbanReflectionNormalStrength;
|
|
2037
|
+
urbanReflectionNormal = normalize(
|
|
2038
|
+
tbn * urbanReflectionMapNormal
|
|
2039
|
+
);
|
|
2040
|
+
#endif
|
|
2041
|
+
float urbanNeutralResponseMask =
|
|
2042
|
+
${source?.map ? 'urbanLocalNeutralMask' : '0.0'};
|
|
2043
|
+
vec3 urbanGraphicLight = normalize(vec3(-0.25, 0.78, 0.57));
|
|
2044
|
+
float urbanHighlightBand = smoothstep(
|
|
2045
|
+
0.62,
|
|
2046
|
+
0.74,
|
|
2047
|
+
dot(urbanViewNormal, urbanGraphicLight)
|
|
2048
|
+
) * (1.0 - urbanShadowMask);
|
|
2049
|
+
float urbanHighlightBandLuma = dot(
|
|
2050
|
+
urbanHighlightBandColor,
|
|
2051
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
2052
|
+
);
|
|
2053
|
+
vec3 urbanAppliedHighlightBandColor = mix(
|
|
2054
|
+
urbanHighlightBandColor,
|
|
2055
|
+
vec3(urbanHighlightBandLuma),
|
|
2056
|
+
urbanNeutralResponseMask
|
|
2057
|
+
);
|
|
2058
|
+
outgoingLight += urbanAppliedHighlightBandColor
|
|
2059
|
+
* urbanHighlightBand
|
|
2060
|
+
* urbanHighlightBandEnabled
|
|
2061
|
+
* urbanHighlightBandStrength
|
|
2062
|
+
* ${profile.highlightScale.toFixed(4)}
|
|
2063
|
+
* 0.32;
|
|
2064
|
+
|
|
2065
|
+
float urbanFacing = saturate(
|
|
2066
|
+
dot(urbanViewNormal, normalize(vViewPosition))
|
|
2067
|
+
);
|
|
2068
|
+
float urbanRim = smoothstep(0.42, 0.88, 1.0 - urbanFacing);
|
|
2069
|
+
float urbanFresnelEdge = smoothstep(
|
|
2070
|
+
0.52,
|
|
2071
|
+
0.82,
|
|
2072
|
+
1.0 - urbanFacing
|
|
2073
|
+
) * (
|
|
2074
|
+
1.0 - smoothstep(0.94, 1.0, 1.0 - urbanFacing)
|
|
2075
|
+
);
|
|
2076
|
+
float urbanFresnelColorLuma = dot(
|
|
2077
|
+
urbanFresnelColor,
|
|
2078
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
2079
|
+
);
|
|
2080
|
+
vec3 urbanAppliedFresnelColor = mix(
|
|
2081
|
+
urbanFresnelColor,
|
|
2082
|
+
vec3(urbanFresnelColorLuma),
|
|
2083
|
+
urbanNeutralResponseMask
|
|
2084
|
+
);
|
|
2085
|
+
outgoingLight += urbanAppliedFresnelColor
|
|
2086
|
+
* urbanFresnelEdge
|
|
2087
|
+
* urbanFresnelStrength
|
|
2088
|
+
* urbanFresnelEnabled
|
|
2089
|
+
* ${profile.fresnelScale.toFixed(4)}
|
|
2090
|
+
* 0.18;
|
|
2091
|
+
vec3 urbanRimColor = mix(
|
|
2092
|
+
urbanRimLeftColor,
|
|
2093
|
+
urbanRimRightColor,
|
|
2094
|
+
smoothstep(-0.42, 0.42, urbanViewNormal.x)
|
|
2095
|
+
);
|
|
2096
|
+
float urbanRimColorLuma = dot(
|
|
2097
|
+
urbanRimColor,
|
|
2098
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
2099
|
+
);
|
|
2100
|
+
urbanRimColor = mix(
|
|
2101
|
+
urbanRimColor,
|
|
2102
|
+
vec3(urbanRimColorLuma),
|
|
2103
|
+
urbanNeutralResponseMask
|
|
2104
|
+
);
|
|
2105
|
+
outgoingLight += urbanRimColor
|
|
2106
|
+
* urbanRim
|
|
2107
|
+
* urbanHighlightStrength
|
|
2108
|
+
* urbanRimEnabled
|
|
2109
|
+
* 0.20;
|
|
2110
|
+
|
|
2111
|
+
float urbanBaseOutputHigh = max(
|
|
2112
|
+
max(outgoingLight.r, outgoingLight.g),
|
|
2113
|
+
outgoingLight.b
|
|
2114
|
+
);
|
|
2115
|
+
outgoingLight *= min(
|
|
2116
|
+
1.0,
|
|
2117
|
+
${profile.lightValueCap.toFixed(4)}
|
|
2118
|
+
/ max(urbanBaseOutputHigh, 0.0001)
|
|
2119
|
+
);
|
|
2120
|
+
|
|
2121
|
+
float urbanMaterialMetalness = clamp(
|
|
2122
|
+
urbanSourceMetalness,
|
|
2123
|
+
0.0,
|
|
2124
|
+
1.0
|
|
2125
|
+
);
|
|
2126
|
+
float urbanMaterialRoughness = clamp(
|
|
2127
|
+
urbanSourceRoughness,
|
|
2128
|
+
0.04,
|
|
2129
|
+
1.0
|
|
2130
|
+
);
|
|
2131
|
+
float urbanMaterialMacroRoughness = urbanMaterialRoughness;
|
|
2132
|
+
#ifdef USE_MAP
|
|
2133
|
+
if (urbanMaterialResponseMapEnabled > 0.5) {
|
|
2134
|
+
vec4 urbanMaterialResponseSample = texture2D(
|
|
2135
|
+
urbanMaterialResponseMap,
|
|
2136
|
+
vMapUv
|
|
2137
|
+
);
|
|
2138
|
+
vec2 urbanRoughnessRadius =
|
|
2139
|
+
urbanMaterialResponseTexelSize * 18.0;
|
|
2140
|
+
float urbanMacroRoughnessSample =
|
|
2141
|
+
urbanMaterialResponseSample.g * 0.36;
|
|
2142
|
+
urbanMacroRoughnessSample += texture2D(
|
|
2143
|
+
urbanMaterialResponseMap,
|
|
2144
|
+
vMapUv + vec2(urbanRoughnessRadius.x, 0.0)
|
|
2145
|
+
).g * 0.16;
|
|
2146
|
+
urbanMacroRoughnessSample += texture2D(
|
|
2147
|
+
urbanMaterialResponseMap,
|
|
2148
|
+
vMapUv - vec2(urbanRoughnessRadius.x, 0.0)
|
|
2149
|
+
).g * 0.16;
|
|
2150
|
+
urbanMacroRoughnessSample += texture2D(
|
|
2151
|
+
urbanMaterialResponseMap,
|
|
2152
|
+
vMapUv + vec2(0.0, urbanRoughnessRadius.y)
|
|
2153
|
+
).g * 0.16;
|
|
2154
|
+
urbanMacroRoughnessSample += texture2D(
|
|
2155
|
+
urbanMaterialResponseMap,
|
|
2156
|
+
vMapUv - vec2(0.0, urbanRoughnessRadius.y)
|
|
2157
|
+
).g * 0.16;
|
|
2158
|
+
urbanMaterialRoughness = clamp(
|
|
2159
|
+
urbanMaterialRoughness * urbanMaterialResponseSample.g,
|
|
2160
|
+
0.04,
|
|
2161
|
+
1.0
|
|
2162
|
+
);
|
|
2163
|
+
urbanMaterialMacroRoughness = clamp(
|
|
2164
|
+
urbanSourceRoughness * urbanMacroRoughnessSample,
|
|
2165
|
+
0.04,
|
|
2166
|
+
1.0
|
|
2167
|
+
);
|
|
2168
|
+
urbanMaterialMetalness = clamp(
|
|
2169
|
+
urbanMaterialMetalness * urbanMaterialResponseSample.b,
|
|
2170
|
+
0.0,
|
|
2171
|
+
1.0
|
|
2172
|
+
);
|
|
2173
|
+
}
|
|
2174
|
+
#endif
|
|
2175
|
+
float urbanLocalSmoothness = 1.0 - smoothstep(
|
|
2176
|
+
0.36,
|
|
2177
|
+
0.74,
|
|
2178
|
+
urbanMaterialRoughness
|
|
2179
|
+
);
|
|
2180
|
+
float urbanMacroSmoothness = 1.0 - smoothstep(
|
|
2181
|
+
0.36,
|
|
2182
|
+
0.74,
|
|
2183
|
+
urbanMaterialMacroRoughness
|
|
2184
|
+
);
|
|
2185
|
+
float urbanLocalRoughnessBand = floor(
|
|
2186
|
+
clamp(urbanLocalSmoothness, 0.0, 0.999) * 3.0
|
|
2187
|
+
) * 0.5;
|
|
2188
|
+
float urbanMacroRoughnessBand = floor(
|
|
2189
|
+
clamp(urbanMacroSmoothness, 0.0, 0.999) * 3.0
|
|
2190
|
+
) * 0.5;
|
|
2191
|
+
float urbanStylizedSmoothness = clamp(
|
|
2192
|
+
urbanLocalRoughnessBand * 0.72
|
|
2193
|
+
+ urbanMacroRoughnessBand * 0.28,
|
|
2194
|
+
0.0,
|
|
2195
|
+
1.0
|
|
2196
|
+
);
|
|
2197
|
+
#ifdef USE_MAP
|
|
2198
|
+
vec2 urbanSourceBreakupRadius = urbanMapTexelSize * 12.0;
|
|
2199
|
+
vec3 urbanSourceBreakupSharp = texture2D(
|
|
2200
|
+
map,
|
|
2201
|
+
vMapUv
|
|
2202
|
+
).rgb;
|
|
2203
|
+
vec3 urbanSourceBreakupMacro = urbanSourceBreakupSharp * 0.36;
|
|
2204
|
+
urbanSourceBreakupMacro += texture2D(
|
|
2205
|
+
map,
|
|
2206
|
+
vMapUv + vec2(urbanSourceBreakupRadius.x, 0.0)
|
|
2207
|
+
).rgb * 0.16;
|
|
2208
|
+
urbanSourceBreakupMacro += texture2D(
|
|
2209
|
+
map,
|
|
2210
|
+
vMapUv - vec2(urbanSourceBreakupRadius.x, 0.0)
|
|
2211
|
+
).rgb * 0.16;
|
|
2212
|
+
urbanSourceBreakupMacro += texture2D(
|
|
2213
|
+
map,
|
|
2214
|
+
vMapUv + vec2(0.0, urbanSourceBreakupRadius.y)
|
|
2215
|
+
).rgb * 0.16;
|
|
2216
|
+
urbanSourceBreakupMacro += texture2D(
|
|
2217
|
+
map,
|
|
2218
|
+
vMapUv - vec2(0.0, urbanSourceBreakupRadius.y)
|
|
2219
|
+
).rgb * 0.16;
|
|
2220
|
+
float urbanSourceBreakupSharpLuma = dot(
|
|
2221
|
+
urbanSourceBreakupSharp,
|
|
2222
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
2223
|
+
);
|
|
2224
|
+
float urbanSourceBreakupMacroLuma = dot(
|
|
2225
|
+
urbanSourceBreakupMacro,
|
|
2226
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
2227
|
+
);
|
|
2228
|
+
float urbanSourceBreakupDelta =
|
|
2229
|
+
urbanSourceBreakupSharpLuma
|
|
2230
|
+
- urbanSourceBreakupMacroLuma;
|
|
2231
|
+
float urbanSourceBreakupMask = smoothstep(
|
|
2232
|
+
0.018,
|
|
2233
|
+
0.15,
|
|
2234
|
+
abs(urbanSourceBreakupDelta)
|
|
2235
|
+
);
|
|
2236
|
+
float urbanSourceWearSmoothness = smoothstep(
|
|
2237
|
+
-0.08,
|
|
2238
|
+
0.12,
|
|
2239
|
+
urbanSourceBreakupDelta
|
|
2240
|
+
);
|
|
2241
|
+
urbanStylizedSmoothness = mix(
|
|
2242
|
+
urbanStylizedSmoothness,
|
|
2243
|
+
urbanSourceWearSmoothness,
|
|
2244
|
+
urbanSourceBreakupMask * 0.72
|
|
2245
|
+
);
|
|
2246
|
+
#endif
|
|
2247
|
+
float urbanReflectionSoftClass = smoothstep(
|
|
2248
|
+
0.18,
|
|
2249
|
+
0.48,
|
|
2250
|
+
urbanStylizedSmoothness
|
|
2251
|
+
);
|
|
2252
|
+
float urbanReflectionGlossClass = smoothstep(
|
|
2253
|
+
0.58,
|
|
2254
|
+
0.82,
|
|
2255
|
+
urbanStylizedSmoothness
|
|
2256
|
+
);
|
|
2257
|
+
float urbanReflectionClass = clamp(
|
|
2258
|
+
urbanReflectionSoftClass * 0.34
|
|
2259
|
+
+ urbanReflectionGlossClass * 0.66,
|
|
2260
|
+
0.0,
|
|
2261
|
+
1.0
|
|
2262
|
+
);
|
|
2263
|
+
float urbanReflectionSelectivityAmount =
|
|
2264
|
+
urbanReflectionSelectivityEnabled
|
|
2265
|
+
* urbanReflectionSelectivityStrength;
|
|
2266
|
+
float urbanReflectionCoverage = mix(
|
|
2267
|
+
1.0,
|
|
2268
|
+
mix(0.06, 1.0, urbanReflectionClass),
|
|
2269
|
+
urbanReflectionSelectivityAmount
|
|
2270
|
+
);
|
|
2271
|
+
float urbanRoughnessBreakupAmount =
|
|
2272
|
+
urbanRoughnessBreakupEnabled
|
|
2273
|
+
* urbanRoughnessBreakupStrength
|
|
2274
|
+
* urbanMaterialResponseMapEnabled
|
|
2275
|
+
* ${profile.roughnessBreakupScale.toFixed(4)};
|
|
2276
|
+
float urbanRoughnessSheen = mix(
|
|
2277
|
+
1.0,
|
|
2278
|
+
mix(0.42, 1.48, urbanStylizedSmoothness),
|
|
2279
|
+
urbanRoughnessBreakupAmount
|
|
2280
|
+
);
|
|
2281
|
+
|
|
2282
|
+
vec3 urbanResponseView = normalize(vViewPosition);
|
|
2283
|
+
vec3 urbanReflectedView = reflect(
|
|
2284
|
+
-urbanResponseView,
|
|
2285
|
+
urbanReflectionNormal
|
|
2286
|
+
);
|
|
2287
|
+
vec3 urbanColoredLightResponse = vec3(0.0);
|
|
2288
|
+
vec3 urbanPlanarLightResponse = vec3(0.0);
|
|
2289
|
+
vec3 urbanViewLightResponse = vec3(0.0);
|
|
2290
|
+
#if NUM_DIR_LIGHTS > 0
|
|
2291
|
+
for (int urbanLightIndex = 0;
|
|
2292
|
+
urbanLightIndex < NUM_DIR_LIGHTS;
|
|
2293
|
+
urbanLightIndex++
|
|
2294
|
+
) {
|
|
2295
|
+
vec3 urbanResponseLight = normalize(
|
|
2296
|
+
directionalLights[urbanLightIndex].direction
|
|
2297
|
+
);
|
|
2298
|
+
vec3 urbanResponseHalf = normalize(
|
|
2299
|
+
urbanResponseLight + urbanResponseView
|
|
2300
|
+
);
|
|
2301
|
+
float urbanResponseNdotH = max(
|
|
2302
|
+
dot(urbanReflectionNormal, urbanResponseHalf),
|
|
2303
|
+
0.0
|
|
2304
|
+
);
|
|
2305
|
+
float urbanResponseNdotL = max(
|
|
2306
|
+
dot(urbanViewNormal, urbanResponseLight),
|
|
2307
|
+
0.0
|
|
2308
|
+
);
|
|
2309
|
+
float urbanBroadSpecular = pow(
|
|
2310
|
+
urbanResponseNdotH,
|
|
2311
|
+
mix(3.0, 18.0, 1.0 - urbanMaterialRoughness)
|
|
2312
|
+
);
|
|
2313
|
+
float urbanTightSpecular = pow(
|
|
2314
|
+
urbanResponseNdotH,
|
|
2315
|
+
mix(18.0, 88.0, 1.0 - urbanMaterialRoughness)
|
|
2316
|
+
);
|
|
2317
|
+
float urbanLightLobe = (
|
|
2318
|
+
urbanBroadSpecular * 0.18
|
|
2319
|
+
+ urbanTightSpecular * 0.34
|
|
2320
|
+
) * smoothstep(0.0, 0.34, urbanResponseNdotL);
|
|
2321
|
+
urbanColoredLightResponse +=
|
|
2322
|
+
directionalLights[urbanLightIndex].color
|
|
2323
|
+
* urbanLightLobe;
|
|
2324
|
+
vec3 urbanReflectedLight = reflect(
|
|
2325
|
+
-urbanResponseLight,
|
|
2326
|
+
urbanReflectionNormal
|
|
2327
|
+
);
|
|
2328
|
+
float urbanPlanarLightLobe = pow(
|
|
2329
|
+
max(dot(urbanReflectedLight, urbanResponseView), 0.0),
|
|
2330
|
+
mix(2.0, 7.0, 1.0 - urbanMaterialRoughness)
|
|
2331
|
+
);
|
|
2332
|
+
urbanPlanarLightResponse +=
|
|
2333
|
+
directionalLights[urbanLightIndex].color
|
|
2334
|
+
* urbanPlanarLightLobe;
|
|
2335
|
+
float urbanViewReflectionLobe =
|
|
2336
|
+
urbanBroadSpecular * 0.58
|
|
2337
|
+
+ urbanTightSpecular * 0.42;
|
|
2338
|
+
float urbanViewReflectionSoftBand = smoothstep(
|
|
2339
|
+
0.025,
|
|
2340
|
+
0.22,
|
|
2341
|
+
urbanViewReflectionLobe
|
|
2342
|
+
);
|
|
2343
|
+
float urbanViewReflectionCoreBand = smoothstep(
|
|
2344
|
+
0.28,
|
|
2345
|
+
0.68,
|
|
2346
|
+
urbanViewReflectionLobe
|
|
2347
|
+
);
|
|
2348
|
+
float urbanViewReflectionBand =
|
|
2349
|
+
urbanViewReflectionSoftBand * 0.34
|
|
2350
|
+
+ urbanViewReflectionCoreBand * 0.66;
|
|
2351
|
+
urbanViewLightResponse +=
|
|
2352
|
+
directionalLights[urbanLightIndex].color
|
|
2353
|
+
* urbanViewReflectionBand
|
|
2354
|
+
* smoothstep(0.0, 0.3, urbanResponseNdotL);
|
|
2355
|
+
}
|
|
2356
|
+
#endif
|
|
2357
|
+
float urbanSkyReflection = smoothstep(
|
|
2358
|
+
-0.22,
|
|
2359
|
+
0.68,
|
|
2360
|
+
urbanReflectedView.y
|
|
2361
|
+
);
|
|
2362
|
+
float urbanHorizonReflection = 1.0 - smoothstep(
|
|
2363
|
+
0.08,
|
|
2364
|
+
0.52,
|
|
2365
|
+
abs(urbanReflectedView.y - 0.06)
|
|
2366
|
+
);
|
|
2367
|
+
float urbanEnvironmentReflection =
|
|
2368
|
+
urbanSkyReflection * mix(0.18, 0.34, 1.0 - urbanMaterialRoughness)
|
|
2369
|
+
+ urbanHorizonReflection * 0.13;
|
|
2370
|
+
float urbanDiffuseHigh = max(
|
|
2371
|
+
max(diffuseColor.r, diffuseColor.g),
|
|
2372
|
+
diffuseColor.b
|
|
2373
|
+
);
|
|
2374
|
+
vec3 urbanDiffuseHue = diffuseColor.rgb
|
|
2375
|
+
/ max(urbanDiffuseHigh, 0.04);
|
|
2376
|
+
vec3 urbanResponseTint = mix(
|
|
2377
|
+
urbanMaterialResponseColor,
|
|
2378
|
+
mix(
|
|
2379
|
+
urbanMaterialResponseColor,
|
|
2380
|
+
urbanDiffuseHue,
|
|
2381
|
+
0.46
|
|
2382
|
+
),
|
|
2383
|
+
urbanMaterialMetalness
|
|
2384
|
+
);
|
|
2385
|
+
float urbanResponseTintLuma = dot(
|
|
2386
|
+
urbanResponseTint,
|
|
2387
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
2388
|
+
);
|
|
2389
|
+
urbanResponseTint = mix(
|
|
2390
|
+
urbanResponseTint,
|
|
2391
|
+
vec3(urbanResponseTintLuma),
|
|
2392
|
+
urbanNeutralResponseMask
|
|
2393
|
+
);
|
|
2394
|
+
float urbanResponseAmount = urbanMaterialResponseEnabled
|
|
2395
|
+
* urbanMaterialResponseStrength
|
|
2396
|
+
* ${profile.materialResponseScale.toFixed(4)}
|
|
2397
|
+
* mix(0.24, 1.0, urbanMaterialMetalness);
|
|
2398
|
+
vec3 urbanMetalLightTint = mix(
|
|
2399
|
+
vec3(1.0),
|
|
2400
|
+
urbanDiffuseHue,
|
|
2401
|
+
urbanMaterialMetalness * 0.42
|
|
2402
|
+
);
|
|
2403
|
+
outgoingLight += (
|
|
2404
|
+
urbanResponseTint
|
|
2405
|
+
* urbanEnvironmentReflection
|
|
2406
|
+
* mix(0.20, 0.44, urbanMaterialMetalness)
|
|
2407
|
+
+ urbanColoredLightResponse
|
|
2408
|
+
* urbanMetalLightTint
|
|
2409
|
+
* mix(0.18, 0.34, urbanMaterialMetalness)
|
|
2410
|
+
) * urbanResponseAmount
|
|
2411
|
+
* urbanRoughnessSheen
|
|
2412
|
+
* mix(0.34, 1.0, urbanReflectionCoverage);
|
|
2413
|
+
|
|
2414
|
+
float urbanPlanarFacing = smoothstep(
|
|
2415
|
+
0.34,
|
|
2416
|
+
0.78,
|
|
2417
|
+
urbanViewNormal.y
|
|
2418
|
+
);
|
|
2419
|
+
float urbanPlanarRoughnessGain = mix(
|
|
2420
|
+
0.72,
|
|
2421
|
+
1.18,
|
|
2422
|
+
1.0 - urbanMaterialRoughness
|
|
2423
|
+
);
|
|
2424
|
+
vec3 urbanPlanarSheenColor =
|
|
2425
|
+
urbanMaterialResponseColor
|
|
2426
|
+
* (
|
|
2427
|
+
urbanSkyReflection * 0.04
|
|
2428
|
+
+ urbanHorizonReflection * 0.03
|
|
2429
|
+
)
|
|
2430
|
+
+ urbanPlanarLightResponse * 0.85;
|
|
2431
|
+
float urbanPlanarSheenLuma = dot(
|
|
2432
|
+
urbanPlanarSheenColor,
|
|
2433
|
+
vec3(0.2126, 0.7152, 0.0722)
|
|
2434
|
+
);
|
|
2435
|
+
urbanPlanarSheenColor = mix(
|
|
2436
|
+
urbanPlanarSheenColor,
|
|
2437
|
+
vec3(urbanPlanarSheenLuma),
|
|
2438
|
+
urbanNeutralResponseMask
|
|
2439
|
+
);
|
|
2440
|
+
outgoingLight += urbanPlanarSheenColor
|
|
2441
|
+
* urbanPlanarFacing
|
|
2442
|
+
* urbanPlanarRoughnessGain
|
|
2443
|
+
* urbanPlanarSheenEnabled
|
|
2444
|
+
* urbanPlanarSheenStrength
|
|
2445
|
+
* urbanReflectionCoverage
|
|
2446
|
+
* urbanRoughnessSheen
|
|
2447
|
+
* ${profile.planarSheenScale.toFixed(4)};
|
|
2448
|
+
float urbanRoughnessSurfaceResponse = mix(
|
|
2449
|
+
0.72,
|
|
2450
|
+
1.18,
|
|
2451
|
+
urbanStylizedSmoothness
|
|
2452
|
+
);
|
|
2453
|
+
outgoingLight *= mix(
|
|
2454
|
+
1.0,
|
|
2455
|
+
urbanRoughnessSurfaceResponse,
|
|
2456
|
+
urbanRoughnessBreakupAmount
|
|
2457
|
+
* mix(0.24, 1.0, urbanPlanarFacing)
|
|
2458
|
+
);
|
|
2459
|
+
|
|
2460
|
+
float urbanOutputHigh = max(
|
|
2461
|
+
max(outgoingLight.r, outgoingLight.g),
|
|
2462
|
+
outgoingLight.b
|
|
2463
|
+
);
|
|
2464
|
+
outgoingLight *= min(
|
|
2465
|
+
1.0,
|
|
2466
|
+
${profile.responseValueCap.toFixed(4)}
|
|
2467
|
+
/ max(urbanOutputHigh, 0.0001)
|
|
2468
|
+
);
|
|
2469
|
+
float urbanViewReflectionAmount =
|
|
2470
|
+
urbanViewReflectionEnabled
|
|
2471
|
+
* urbanViewReflectionStrength
|
|
2472
|
+
* ${profile.viewReflectionScale.toFixed(4)}
|
|
2473
|
+
* mix(0.42, 1.0, urbanMaterialMetalness)
|
|
2474
|
+
* mix(0.34, 1.0, urbanPlanarFacing);
|
|
2475
|
+
vec3 urbanViewReflectionTint = mix(
|
|
2476
|
+
urbanViewLightResponse,
|
|
2477
|
+
urbanViewLightResponse * urbanDiffuseHue,
|
|
2478
|
+
urbanMaterialMetalness * 0.32
|
|
2479
|
+
);
|
|
2480
|
+
outgoingLight += urbanViewReflectionTint
|
|
2481
|
+
* urbanViewReflectionAmount
|
|
2482
|
+
* urbanReflectionCoverage
|
|
2483
|
+
* mix(0.38, 1.16, urbanStylizedSmoothness)
|
|
2484
|
+
* mix(0.72, 1.0, urbanRoughnessSheen);
|
|
2485
|
+
${isMirror ? `
|
|
2486
|
+
vec3 urbanProbeDirection = inverseTransformDirection(
|
|
2487
|
+
urbanReflectedView,
|
|
2488
|
+
viewMatrix
|
|
2489
|
+
);
|
|
2490
|
+
urbanProbeDirection.x *= -1.0;
|
|
2491
|
+
vec3 urbanProbeColor = textureCube(
|
|
2492
|
+
urbanReflectionProbeMap,
|
|
2493
|
+
urbanProbeDirection
|
|
2494
|
+
).rgb;
|
|
2495
|
+
float urbanProbeHigh = max(
|
|
2496
|
+
max(urbanProbeColor.r, urbanProbeColor.g),
|
|
2497
|
+
urbanProbeColor.b
|
|
2498
|
+
);
|
|
2499
|
+
vec3 urbanProbeHue = urbanProbeColor
|
|
2500
|
+
/ max(urbanProbeHigh, 0.025);
|
|
2501
|
+
float urbanProbeBand = floor(
|
|
2502
|
+
clamp(urbanProbeHigh, 0.0, 0.999) * 5.0
|
|
2503
|
+
) * 0.25;
|
|
2504
|
+
vec3 urbanStylizedProbe = urbanProbeHue * mix(
|
|
2505
|
+
urbanProbeHigh,
|
|
2506
|
+
urbanProbeBand,
|
|
2507
|
+
0.28
|
|
2508
|
+
);
|
|
2509
|
+
float urbanProbeFresnel = pow(
|
|
2510
|
+
clamp(1.0 - urbanFacing, 0.0, 1.0),
|
|
2511
|
+
3.0
|
|
2512
|
+
);
|
|
2513
|
+
float urbanProbeAmount =
|
|
2514
|
+
urbanReflectionProbeAvailable
|
|
2515
|
+
* urbanReflectionProbeLayerEnabled
|
|
2516
|
+
* urbanReflectionProbeStrength
|
|
2517
|
+
* mix(0.74, 0.94, urbanProbeFresnel);
|
|
2518
|
+
outgoingLight = mix(
|
|
2519
|
+
outgoingLight,
|
|
2520
|
+
urbanStylizedProbe,
|
|
2521
|
+
clamp(urbanProbeAmount, 0.0, 0.96)
|
|
2522
|
+
);
|
|
2523
|
+
` : ''}
|
|
2524
|
+
`,
|
|
2525
|
+
);
|
|
2526
|
+
};
|
|
2527
|
+
|
|
2528
|
+
material.customProgramCacheKey = () => [
|
|
2529
|
+
'locked-urban-v72-local-neutral-authority',
|
|
2530
|
+
isMirror,
|
|
2531
|
+
Boolean(source?.map),
|
|
2532
|
+
Boolean(sourceResponseMap),
|
|
2533
|
+
profile.colorControl,
|
|
2534
|
+
profile.colorLiftScale,
|
|
2535
|
+
profile.decalScale,
|
|
2536
|
+
profile.fresnelScale,
|
|
2537
|
+
profile.fallbackMetalness,
|
|
2538
|
+
profile.decalThreshold,
|
|
2539
|
+
profile.graphicSafeMacro ?? 0,
|
|
2540
|
+
profile.highlightScale,
|
|
2541
|
+
profile.lightValueCap,
|
|
2542
|
+
profile.materialResponseScale,
|
|
2543
|
+
profile.normalScale,
|
|
2544
|
+
profile.paintExtractionScale ?? 1,
|
|
2545
|
+
profile.paintValue,
|
|
2546
|
+
profile.planarSheenScale,
|
|
2547
|
+
profile.responseValueCap,
|
|
2548
|
+
profile.roleColorMix,
|
|
2549
|
+
profile.roughnessBreakupScale,
|
|
2550
|
+
profile.sharpRustBoost,
|
|
2551
|
+
profile.sourceAnchorAuthorityScale,
|
|
2552
|
+
profile.sourceHueAuthorityScale,
|
|
2553
|
+
profile.sourceValueAuthorityScale,
|
|
2554
|
+
profile.viewReflectionScale,
|
|
2555
|
+
profile.wearScale,
|
|
2556
|
+
].join(':');
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
function classificationForAdapter(source, classification, legacySurface) {
|
|
2560
|
+
if (classification && typeof classification === 'object') {
|
|
2561
|
+
return createUrbanMaterialClassification(classification);
|
|
2562
|
+
}
|
|
2563
|
+
const legacy = LEGACY_SURFACE_CLASSIFICATIONS[legacySurface]
|
|
2564
|
+
?? LEGACY_SURFACE_CLASSIFICATIONS.paintedMetal;
|
|
2565
|
+
return createUrbanMaterialClassification({
|
|
2566
|
+
...legacy,
|
|
2567
|
+
renderMode: sourceRenderMode(source),
|
|
2568
|
+
contentFlags: [
|
|
2569
|
+
...(legacy.contentFlags ?? []),
|
|
2570
|
+
...(sourceHasEmission(source) ? ['emissive'] : []),
|
|
2571
|
+
],
|
|
2572
|
+
classificationSource: legacySurface ? 'legacyAdapter' : 'defaultAdapter',
|
|
2573
|
+
confidence: legacySurface ? 1 : 0.5,
|
|
2574
|
+
});
|
|
2575
|
+
}
|
|
2576
|
+
|
|
2577
|
+
function legacySurfaceForProfile(profileId) {
|
|
2578
|
+
if (URBAN_PROP_SURFACE_ROLES.includes(profileId)) return profileId;
|
|
2579
|
+
if (profileId === 'coatedPanel' || profileId === 'polymer') return 'lid';
|
|
2580
|
+
if (profileId === 'glass' || profileId === 'composite' || profileId === 'fluid') {
|
|
2581
|
+
return 'technicalSurface';
|
|
2582
|
+
}
|
|
2583
|
+
if (profileId === 'rubber') return 'rubber';
|
|
2584
|
+
return 'paintedMetal';
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
export function createUrbanAnimePropMaterial(sourceMaterial, {
|
|
2588
|
+
classification = null,
|
|
2589
|
+
controls,
|
|
2590
|
+
surface = null,
|
|
2591
|
+
} = {}) {
|
|
2592
|
+
const source = Array.isArray(sourceMaterial) ? sourceMaterial[0] : sourceMaterial;
|
|
2593
|
+
const materialClassification = classificationForAdapter(source, classification, surface);
|
|
2594
|
+
const profileId = surface && SURFACE_PROFILES[surface]
|
|
2595
|
+
? surface
|
|
2596
|
+
: resolveUrbanMaterialProfile(materialClassification);
|
|
2597
|
+
const profile = SURFACE_PROFILES[profileId] ?? SURFACE_PROFILES.genericDielectric;
|
|
2598
|
+
const shared = controls ?? createUrbanPropShaderControls();
|
|
2599
|
+
|
|
2600
|
+
const material = new THREE.MeshToonMaterial({
|
|
2601
|
+
color: shared[profile.colorControl].value,
|
|
2602
|
+
emissive: 0x020508,
|
|
2603
|
+
gradientMap: createLockedGradientMap(),
|
|
2604
|
+
});
|
|
2605
|
+
material.name = `Locked urban · ${profileId} · ${source?.name ?? 'material'}`;
|
|
2606
|
+
material.map = source?.map ?? null;
|
|
2607
|
+
material.normalMap = source?.normalMap ?? null;
|
|
2608
|
+
material.side = source?.side ?? THREE.FrontSide;
|
|
2609
|
+
material.transparent = source?.transparent ?? false;
|
|
2610
|
+
material.opacity = source?.opacity ?? 1;
|
|
2611
|
+
material.alphaTest = source?.alphaTest ?? 0;
|
|
2612
|
+
material.fog = true;
|
|
2613
|
+
|
|
2614
|
+
const sourceScale = source?.normalScale?.clone?.() ?? new THREE.Vector2(1, 1);
|
|
2615
|
+
const sourceColor = source?.color?.clone?.() ?? new THREE.Color(0xffffff);
|
|
2616
|
+
const syncLookControls = () => {
|
|
2617
|
+
material.color
|
|
2618
|
+
.copy(sourceColor)
|
|
2619
|
+
.lerp(
|
|
2620
|
+
shared[profile.colorControl].value,
|
|
2621
|
+
THREE.MathUtils.clamp(shared.paletteOverride.value, 0, 1),
|
|
2622
|
+
);
|
|
2623
|
+
const extractedNormalScale = 1 - THREE.MathUtils.clamp(
|
|
2624
|
+
shared.paintExtractionEnabled.value
|
|
2625
|
+
* shared.paintExtractionStrength.value
|
|
2626
|
+
* 0.62,
|
|
2627
|
+
0,
|
|
2628
|
+
0.62,
|
|
2629
|
+
);
|
|
2630
|
+
const normalEnabled = shared.normalDetailEnabled.value > 0.5 ? 1 : 0;
|
|
2631
|
+
material.normalScale.set(
|
|
2632
|
+
sourceScale.x * profile.normalScale * shared.normalStrength.value
|
|
2633
|
+
* extractedNormalScale * normalEnabled,
|
|
2634
|
+
sourceScale.y * profile.normalScale * shared.normalStrength.value
|
|
2635
|
+
* extractedNormalScale * normalEnabled,
|
|
2636
|
+
);
|
|
2637
|
+
material.gradientMap = shared.celLightingEnabled.value > 0.5
|
|
2638
|
+
? createLockedGradientMap()
|
|
2639
|
+
: createSmoothGradientMap();
|
|
2640
|
+
};
|
|
2641
|
+
syncLookControls();
|
|
2642
|
+
material.onBeforeRender = syncLookControls;
|
|
2643
|
+
|
|
2644
|
+
installLockedLookShader(material, source, profile, shared, {
|
|
2645
|
+
isMirror: materialClassification.finish === 'mirror',
|
|
2646
|
+
});
|
|
2647
|
+
material.userData.environmentShaderExclude = true;
|
|
2648
|
+
material.userData.urbanMaterial = {
|
|
2649
|
+
...materialClassification,
|
|
2650
|
+
contentFlags: [...materialClassification.contentFlags],
|
|
2651
|
+
};
|
|
2652
|
+
material.userData.urbanSurfaceProfile = profileId;
|
|
2653
|
+
material.userData.urbanSurface = legacySurfaceForProfile(profileId);
|
|
2654
|
+
material.userData.urbanPropSurface = material.userData.urbanSurface;
|
|
2655
|
+
material.userData.urbanLookVersion = 5;
|
|
2656
|
+
return material;
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
/**
|
|
2660
|
+
* WebGPU/TSL presentation adapter for the locked urban look.
|
|
2661
|
+
*
|
|
2662
|
+
* The standalone benchmark uses `onBeforeCompile`, which WebGPURenderer does
|
|
2663
|
+
* not execute. This adapter consumes the same controls and role profiles while
|
|
2664
|
+
* retaining source texture/node authority, toon bands, normal detail, source
|
|
2665
|
+
* emission, roughness-selective sheen, and the canonical urbanSurface role.
|
|
2666
|
+
*/
|
|
2667
|
+
export function createUrbanAnimePropNodeMaterial(sourceMaterial, {
|
|
2668
|
+
classification = null,
|
|
2669
|
+
controls,
|
|
2670
|
+
surface = null,
|
|
2671
|
+
} = {}) {
|
|
2672
|
+
const source = Array.isArray(sourceMaterial) ? sourceMaterial[0] : sourceMaterial;
|
|
2673
|
+
const materialClassification = classificationForAdapter(source, classification, surface);
|
|
2674
|
+
const profileId = surface && SURFACE_PROFILES[surface]
|
|
2675
|
+
? surface
|
|
2676
|
+
: resolveUrbanMaterialProfile(materialClassification);
|
|
2677
|
+
const profile = SURFACE_PROFILES[profileId] ?? SURFACE_PROFILES.genericDielectric;
|
|
2678
|
+
const shared = controls ?? createUrbanPropShaderControls();
|
|
2679
|
+
const scalarBindings = [];
|
|
2680
|
+
const scalarControl = (control) => {
|
|
2681
|
+
const node = uniform(Number(control?.value ?? 0));
|
|
2682
|
+
scalarBindings.push([node, control]);
|
|
2683
|
+
return node;
|
|
2684
|
+
};
|
|
2685
|
+
const colorControlNode = (control, fallback = 0xffffff) => (
|
|
2686
|
+
uniform(control?.value ?? new THREE.Color(fallback))
|
|
2687
|
+
);
|
|
2688
|
+
|
|
2689
|
+
const sourceColor = source?.color?.clone?.() ?? new THREE.Color(0xffffff);
|
|
2690
|
+
let sourceColorNode = source?.colorNode ?? vec3(
|
|
2691
|
+
sourceColor.r,
|
|
2692
|
+
sourceColor.g,
|
|
2693
|
+
sourceColor.b,
|
|
2694
|
+
);
|
|
2695
|
+
if (!source?.colorNode && source?.map) {
|
|
2696
|
+
sourceColorNode = texture(source.map).rgb.mul(sourceColorNode);
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
const roleColor = colorControlNode(shared[profile.colorControl]);
|
|
2700
|
+
const paletteAmount = scalarControl(shared.paletteOverride)
|
|
2701
|
+
.mul(profile.roleColorMix);
|
|
2702
|
+
let urbanColor = mix(sourceColorNode, roleColor, paletteAmount);
|
|
2703
|
+
const pastelAmount = scalarControl(shared.pastelPaletteEnabled)
|
|
2704
|
+
.mul(scalarControl(shared.pastelStrength))
|
|
2705
|
+
.mul(profile.pastelScale);
|
|
2706
|
+
const pastelTarget = urbanColor
|
|
2707
|
+
.mul(0.9)
|
|
2708
|
+
.add(colorControlNode(shared.pastelBlueColor, 0x8faabd).mul(0.1));
|
|
2709
|
+
urbanColor = mix(urbanColor, pastelTarget, pastelAmount);
|
|
2710
|
+
urbanColor = urbanColor.add(
|
|
2711
|
+
scalarControl(shared.colorLiftEnabled)
|
|
2712
|
+
.mul(scalarControl(shared.colorLiftStrength))
|
|
2713
|
+
.mul(profile.colorLiftScale * 0.035),
|
|
2714
|
+
);
|
|
2715
|
+
|
|
2716
|
+
let sourceRoughnessNode = float(
|
|
2717
|
+
Number.isFinite(source?.roughness) ? source.roughness : 0.72,
|
|
2718
|
+
);
|
|
2719
|
+
if (source?.roughnessNode) {
|
|
2720
|
+
sourceRoughnessNode = source.roughnessNode;
|
|
2721
|
+
} else if (source?.roughnessMap) {
|
|
2722
|
+
sourceRoughnessNode = texture(source.roughnessMap).g.mul(
|
|
2723
|
+
Number.isFinite(source.roughness) ? source.roughness : 1,
|
|
2724
|
+
);
|
|
2725
|
+
}
|
|
2726
|
+
const roughnessNode = clamp(sourceRoughnessNode, 0, 1);
|
|
2727
|
+
|
|
2728
|
+
let sourceMetalnessNode = float(
|
|
2729
|
+
Number.isFinite(source?.metalness)
|
|
2730
|
+
? source.metalness
|
|
2731
|
+
: profile.fallbackMetalness,
|
|
2732
|
+
);
|
|
2733
|
+
if (source?.metalnessNode) {
|
|
2734
|
+
sourceMetalnessNode = source.metalnessNode;
|
|
2735
|
+
} else if (source?.metalnessMap) {
|
|
2736
|
+
sourceMetalnessNode = texture(source.metalnessMap).b.mul(
|
|
2737
|
+
Number.isFinite(source.metalness) ? source.metalness : 1,
|
|
2738
|
+
);
|
|
2739
|
+
}
|
|
2740
|
+
const metalnessNode = clamp(sourceMetalnessNode, 0, 1);
|
|
2741
|
+
|
|
2742
|
+
let sourceNormalNode = source?.normalNode ?? null;
|
|
2743
|
+
if (!sourceNormalNode && source?.normalMap) {
|
|
2744
|
+
const sourceNormalScale = source.normalScale ?? new THREE.Vector2(1, 1);
|
|
2745
|
+
const detailAmount = scalarControl(shared.normalDetailEnabled)
|
|
2746
|
+
.mul(scalarControl(shared.normalStrength))
|
|
2747
|
+
.mul(profile.normalScale);
|
|
2748
|
+
sourceNormalNode = normalMapNode(
|
|
2749
|
+
texture(source.normalMap).rgb,
|
|
2750
|
+
vec2(sourceNormalScale.x, sourceNormalScale.y).mul(detailAmount),
|
|
2751
|
+
);
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
let sourceEmissionNode = source?.emissiveNode ?? vec3(0);
|
|
2755
|
+
if (!source?.emissiveNode) {
|
|
2756
|
+
const sourceEmissive = source?.emissive?.clone?.() ?? new THREE.Color(0x000000);
|
|
2757
|
+
sourceEmissionNode = vec3(
|
|
2758
|
+
sourceEmissive.r,
|
|
2759
|
+
sourceEmissive.g,
|
|
2760
|
+
sourceEmissive.b,
|
|
2761
|
+
).mul(Number(source?.emissiveIntensity ?? 1));
|
|
2762
|
+
if (source?.emissiveMap) {
|
|
2763
|
+
sourceEmissionNode = texture(source.emissiveMap).rgb.mul(sourceEmissionNode);
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
const viewDirection = normalize(cameraPosition.sub(positionWorld));
|
|
2768
|
+
const facing = clamp(abs(dot(normalWorld, viewDirection)), 0, 1);
|
|
2769
|
+
const fresnel = pow(facing.oneMinus(), 3);
|
|
2770
|
+
const planarFacing = smoothstep(0.38, 0.94, normalWorld.y);
|
|
2771
|
+
const smoothResponse = mix(0.38, 1.18, roughnessNode.oneMinus());
|
|
2772
|
+
const metalResponse = mix(0.42, 1, metalnessNode);
|
|
2773
|
+
const materialResponseAmount = scalarControl(shared.materialResponseEnabled)
|
|
2774
|
+
.mul(scalarControl(shared.materialResponseStrength))
|
|
2775
|
+
.mul(profile.materialResponseScale);
|
|
2776
|
+
const fresnelResponse = fresnel
|
|
2777
|
+
.mul(scalarControl(shared.fresnelEnabled))
|
|
2778
|
+
.mul(scalarControl(shared.fresnelStrength))
|
|
2779
|
+
.mul(profile.fresnelScale * 0.34);
|
|
2780
|
+
const planarResponse = planarFacing
|
|
2781
|
+
.mul(scalarControl(shared.planarSheenEnabled))
|
|
2782
|
+
.mul(scalarControl(shared.planarSheenStrength))
|
|
2783
|
+
.mul(profile.planarSheenScale * 0.18);
|
|
2784
|
+
const highlightBand = smoothstep(0.28, 0.54, fresnel)
|
|
2785
|
+
.sub(smoothstep(0.62, 0.82, fresnel))
|
|
2786
|
+
.mul(scalarControl(shared.highlightBandEnabled))
|
|
2787
|
+
.mul(scalarControl(shared.highlightBandStrength))
|
|
2788
|
+
.mul(profile.highlightScale * 0.12);
|
|
2789
|
+
const stylizedResponse = colorControlNode(
|
|
2790
|
+
shared.materialResponseColor,
|
|
2791
|
+
0xaacbe0,
|
|
2792
|
+
).mul(
|
|
2793
|
+
fresnelResponse
|
|
2794
|
+
.add(planarResponse)
|
|
2795
|
+
.add(highlightBand)
|
|
2796
|
+
.mul(smoothResponse)
|
|
2797
|
+
.mul(metalResponse)
|
|
2798
|
+
.mul(materialResponseAmount),
|
|
2799
|
+
);
|
|
2800
|
+
|
|
2801
|
+
const sceneShadow = sampleEnvironmentSunShadow(positionWorld)
|
|
2802
|
+
.mul(sampleEnvironmentCloudShadow(positionWorld, 1))
|
|
2803
|
+
.toVar();
|
|
2804
|
+
const castShadowAmount = sceneShadow.oneMinus()
|
|
2805
|
+
.mul(scalarControl(shared.coolShadowsEnabled))
|
|
2806
|
+
.mul(scalarControl(shared.coolShadowStrength));
|
|
2807
|
+
const castShadowTint = mix(
|
|
2808
|
+
vec3(1),
|
|
2809
|
+
colorControlNode(shared.coolShadowColor, 0x173875),
|
|
2810
|
+
castShadowAmount.mul(0.72),
|
|
2811
|
+
);
|
|
2812
|
+
|
|
2813
|
+
const material = new MeshToonNodeMaterial();
|
|
2814
|
+
material.name = `Locked urban WebGPU · ${profileId} · ${
|
|
2815
|
+
source?.name ?? 'material'
|
|
2816
|
+
}`;
|
|
2817
|
+
material.colorNode = clamp(urbanColor, 0, profile.lightValueCap)
|
|
2818
|
+
.mul(castShadowTint);
|
|
2819
|
+
// Authored emission remains visible in shade; view-dependent manufactured
|
|
2820
|
+
// highlights are direct-light cues and must disappear with the sun.
|
|
2821
|
+
material.emissiveNode = sourceEmissionNode.add(stylizedResponse.mul(sceneShadow));
|
|
2822
|
+
material.normalNode = sourceNormalNode;
|
|
2823
|
+
material.gradientMap = createLockedGradientMap();
|
|
2824
|
+
material.side = source?.side ?? THREE.FrontSide;
|
|
2825
|
+
material.transparent = source?.transparent ?? false;
|
|
2826
|
+
material.opacity = source?.opacity ?? 1;
|
|
2827
|
+
material.alphaTest = source?.alphaTest ?? 0;
|
|
2828
|
+
if (source?.opacityNode) {
|
|
2829
|
+
material.opacityNode = source.opacityNode;
|
|
2830
|
+
} else if (source?.map && material.transparent) {
|
|
2831
|
+
material.opacityNode = texture(source.map).a.mul(material.opacity);
|
|
2832
|
+
}
|
|
2833
|
+
material.fog = true;
|
|
2834
|
+
material.onBeforeRender = () => {
|
|
2835
|
+
for (const [node, control] of scalarBindings) {
|
|
2836
|
+
node.value = Number(control?.value ?? 0);
|
|
2837
|
+
}
|
|
2838
|
+
material.gradientMap = shared.celLightingEnabled.value > 0.5
|
|
2839
|
+
? createLockedGradientMap()
|
|
2840
|
+
: createSmoothGradientMap();
|
|
2841
|
+
};
|
|
2842
|
+
material.userData.environmentShaderExclude = true;
|
|
2843
|
+
material.userData.urbanMaterial = {
|
|
2844
|
+
...materialClassification,
|
|
2845
|
+
contentFlags: [...materialClassification.contentFlags],
|
|
2846
|
+
};
|
|
2847
|
+
material.userData.urbanSurfaceProfile = profileId;
|
|
2848
|
+
material.userData.urbanSurface = legacySurfaceForProfile(profileId);
|
|
2849
|
+
material.userData.urbanPropSurface = material.userData.urbanSurface;
|
|
2850
|
+
material.userData.urbanLookVersion = 5;
|
|
2851
|
+
material.userData.urbanRendererAdapter = 'WebGPU/TSL';
|
|
2852
|
+
material.userData.urbanSourceMaterial = source?.name ?? null;
|
|
2853
|
+
material.userData.toonlabSourceTextureCount = [
|
|
2854
|
+
source?.map,
|
|
2855
|
+
source?.normalMap,
|
|
2856
|
+
source?.roughnessMap,
|
|
2857
|
+
source?.metalnessMap,
|
|
2858
|
+
source?.aoMap,
|
|
2859
|
+
source?.emissiveMap,
|
|
2860
|
+
source?.alphaMap,
|
|
2861
|
+
].filter((value) => value?.isTexture).length;
|
|
2862
|
+
material.userData.toonlabSourceTextureIds = [
|
|
2863
|
+
source?.map,
|
|
2864
|
+
source?.normalMap,
|
|
2865
|
+
source?.roughnessMap,
|
|
2866
|
+
source?.metalnessMap,
|
|
2867
|
+
source?.aoMap,
|
|
2868
|
+
source?.emissiveMap,
|
|
2869
|
+
source?.alphaMap,
|
|
2870
|
+
].filter((value) => value?.isTexture).map((value) => value.uuid);
|
|
2871
|
+
material.userData.toonlabSourceTexturesPreserved = true;
|
|
2872
|
+
material.needsUpdate = true;
|
|
2873
|
+
return material;
|
|
2874
|
+
}
|