@aura3d/rendering 1.5.2 → 2.0.1

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.
Files changed (574) hide show
  1. package/README.md +8 -2
  2. package/dist/ArchitecturalLighting.d.ts +35 -0
  3. package/dist/ArchitecturalLighting.d.ts.map +1 -0
  4. package/dist/{ArchitecturalLightingFixtures.js → ArchitecturalLighting.js} +3 -12
  5. package/dist/ArchitecturalLighting.js.map +1 -0
  6. package/dist/ArchitecturalMaterialCatalog.d.ts +3 -3
  7. package/dist/ArchitecturalMaterialCatalog.d.ts.map +1 -1
  8. package/dist/ArchitecturalMaterialCatalog.js +1 -1
  9. package/dist/ArchitecturalMaterialCatalog.js.map +1 -1
  10. package/dist/{ArchitecturalMeasurementFixtures.d.ts → ArchitecturalMeasurement.d.ts} +3 -6
  11. package/dist/ArchitecturalMeasurement.d.ts.map +1 -0
  12. package/dist/{ArchitecturalMeasurementFixtures.js → ArchitecturalMeasurement.js} +3 -6
  13. package/dist/ArchitecturalMeasurement.js.map +1 -0
  14. package/dist/{CanonicalSceneFixtures.d.ts → CanonicalProductScene.d.ts} +2 -2
  15. package/dist/CanonicalProductScene.d.ts.map +1 -0
  16. package/dist/{CanonicalSceneFixtures.js → CanonicalProductScene.js} +2 -2
  17. package/dist/CanonicalProductScene.js.map +1 -0
  18. package/dist/CascadedShadowMaps.d.ts +7 -7
  19. package/dist/CascadedShadowMaps.d.ts.map +1 -1
  20. package/dist/CascadedShadowMaps.js +1 -1
  21. package/dist/CascadedShadowMaps.js.map +1 -1
  22. package/dist/ClusteredForwardLighting.d.ts +2 -2
  23. package/dist/DecalGeometry.d.ts +2 -2
  24. package/dist/DepthPass.d.ts +4 -4
  25. package/dist/DepthPass.d.ts.map +1 -1
  26. package/dist/DepthPass.js +2 -2
  27. package/dist/DepthPass.js.map +1 -1
  28. package/dist/EnvironmentBackgroundPass.d.ts +4 -4
  29. package/dist/EnvironmentBackgroundPass.d.ts.map +1 -1
  30. package/dist/EnvironmentBackgroundPass.js +2 -2
  31. package/dist/EnvironmentBackgroundPass.js.map +1 -1
  32. package/dist/EnvironmentBackgroundResources.d.ts +2 -2
  33. package/dist/EnvironmentLighting.d.ts +1 -1
  34. package/dist/EnvironmentMapResources.d.ts +2 -2
  35. package/dist/EnvironmentPipeline.d.ts +2 -2
  36. package/dist/EnvironmentPlatform.d.ts +3 -3
  37. package/dist/EnvironmentPlatform.js +2 -2
  38. package/dist/EnvironmentPlatform.js.map +1 -1
  39. package/dist/EnvironmentPreset.d.ts +1 -1
  40. package/dist/Exposure.d.ts +1 -1
  41. package/dist/ExternalParityRenderPreset.d.ts +3 -3
  42. package/dist/ForwardPass.d.ts +9 -9
  43. package/dist/ForwardPass.d.ts.map +1 -1
  44. package/dist/ForwardPass.js +24 -10
  45. package/dist/ForwardPass.js.map +1 -1
  46. package/dist/Geometry.d.ts +5 -3
  47. package/dist/Geometry.d.ts.map +1 -1
  48. package/dist/Geometry.js +15 -0
  49. package/dist/Geometry.js.map +1 -1
  50. package/dist/GeometryPrimitives.d.ts +2 -2
  51. package/dist/HDRRenderPipeline.d.ts +4 -4
  52. package/dist/IBL.d.ts +4 -4
  53. package/dist/IndexBuffer.d.ts +1 -1
  54. package/dist/InstancedPBRMaterial.d.ts +2 -2
  55. package/dist/InstancedPBRMaterial.js +1 -1
  56. package/dist/InstancedPBRMaterial.js.map +1 -1
  57. package/dist/InstancedUnlitMaterial.d.ts +1 -1
  58. package/dist/InstancedUnlitMaterial.js +1 -1
  59. package/dist/InstancedUnlitMaterial.js.map +1 -1
  60. package/dist/Instancing.d.ts +1 -1
  61. package/dist/LightUniforms.d.ts +2 -2
  62. package/dist/LightingDebug.d.ts +2 -2
  63. package/dist/LightingDefaults.d.ts +2 -2
  64. package/dist/LightingRig.d.ts +1 -1
  65. package/dist/LineGeometry.d.ts +2 -2
  66. package/dist/Material.d.ts +1 -1
  67. package/dist/Material.js +2 -2
  68. package/dist/Material.js.map +1 -1
  69. package/dist/MaterialBinding.d.ts +3 -3
  70. package/dist/MaterialBinding.js +4 -4
  71. package/dist/MaterialBinding.js.map +1 -1
  72. package/dist/MaterialInstance.d.ts +2 -2
  73. package/dist/MaterialInstance.js +2 -2
  74. package/dist/MaterialInstance.js.map +1 -1
  75. package/dist/MaterialPresets.d.ts +2 -2
  76. package/dist/MeshConsolidation.d.ts +2 -2
  77. package/dist/MorphTarget.d.ts +1 -1
  78. package/dist/MorphTargetPlan.d.ts +1 -1
  79. package/dist/MorphUnlitMaterial.d.ts +1 -1
  80. package/dist/MorphUnlitMaterial.js +1 -1
  81. package/dist/MorphUnlitMaterial.js.map +1 -1
  82. package/dist/NormalMappedPBRMaterial.d.ts +4 -4
  83. package/dist/NormalMappedPBRMaterial.js +1 -1
  84. package/dist/NormalMappedPBRMaterial.js.map +1 -1
  85. package/dist/{OceanFixtures.d.ts → OceanSurface.d.ts} +1 -1
  86. package/dist/OceanSurface.d.ts.map +1 -0
  87. package/dist/{OceanFixtures.js → OceanSurface.js} +1 -1
  88. package/dist/OceanSurface.js.map +1 -0
  89. package/dist/PBRLightingDefaults.d.ts +1 -1
  90. package/dist/PBRMaterial.d.ts +2 -2
  91. package/dist/PBRMaterial.d.ts.map +1 -1
  92. package/dist/PBRMaterial.js +3 -3
  93. package/dist/PBRMaterial.js.map +1 -1
  94. package/dist/PMREM.d.ts +2 -2
  95. package/dist/PortableShaderMaterial.d.ts +60 -0
  96. package/dist/PortableShaderMaterial.d.ts.map +1 -0
  97. package/dist/PortableShaderMaterial.js +223 -0
  98. package/dist/PortableShaderMaterial.js.map +1 -0
  99. package/dist/PostProcessPass.d.ts +2 -2
  100. package/dist/PostProcessPass.d.ts.map +1 -1
  101. package/dist/PostProcessPass.js +30 -6
  102. package/dist/PostProcessPass.js.map +1 -1
  103. package/dist/{ProceduralTextureFixtures.d.ts → ProceduralTexture.d.ts} +2 -2
  104. package/dist/ProceduralTexture.d.ts.map +1 -0
  105. package/dist/{ProceduralTextureFixtures.js → ProceduralTexture.js} +1 -1
  106. package/dist/ProceduralTexture.js.map +1 -0
  107. package/dist/{ProductTurntableFixtures.d.ts → ProductTurntable.d.ts} +4 -4
  108. package/dist/ProductTurntable.d.ts.map +1 -0
  109. package/dist/{ProductTurntableFixtures.js → ProductTurntable.js} +2 -2
  110. package/dist/ProductTurntable.js.map +1 -0
  111. package/dist/ReflectionProbe.d.ts +4 -4
  112. package/dist/ReflectionSurfaces.d.ts +2 -2
  113. package/dist/RenderBackend.d.ts +3 -3
  114. package/dist/RenderDevice.d.ts +36 -6
  115. package/dist/RenderDevice.d.ts.map +1 -1
  116. package/dist/RenderDevice.js.map +1 -1
  117. package/dist/RenderGraph.d.ts +1 -1
  118. package/dist/RenderPass.d.ts +1 -1
  119. package/dist/RenderPipeline.d.ts +3 -3
  120. package/dist/RenderQueue.d.ts +2 -2
  121. package/dist/RenderState.d.ts +2 -2
  122. package/dist/Renderer.d.ts +16 -15
  123. package/dist/Renderer.d.ts.map +1 -1
  124. package/dist/Renderer.js +23 -9
  125. package/dist/Renderer.js.map +1 -1
  126. package/dist/RendererFeatureGates.d.ts +1 -1
  127. package/dist/RendererPostprocessPlan.d.ts +1 -1
  128. package/dist/RendererPostprocessPlan.js +4 -4
  129. package/dist/RendererPostprocessPlan.js.map +1 -1
  130. package/dist/RendererVisualPipelineReport.d.ts +4 -4
  131. package/dist/ResourceLifecycle.d.ts +1 -1
  132. package/dist/SceneOptimization.d.ts +2 -2
  133. package/dist/ScreenSpaceLineMaterial.d.ts +1 -1
  134. package/dist/ScreenSpaceLineMaterial.js +1 -1
  135. package/dist/ScreenSpaceLineMaterial.js.map +1 -1
  136. package/dist/ShaderChunks.d.ts.map +1 -1
  137. package/dist/ShaderChunks.js +92 -24
  138. package/dist/ShaderChunks.js.map +1 -1
  139. package/dist/ShaderLibrary.d.ts +2 -78
  140. package/dist/ShaderLibrary.d.ts.map +1 -1
  141. package/dist/ShaderLibrary.js +103 -810
  142. package/dist/ShaderLibrary.js.map +1 -1
  143. package/dist/ShaderLibraryCore.d.ts +100 -0
  144. package/dist/ShaderLibraryCore.d.ts.map +1 -0
  145. package/dist/ShaderLibraryCore.js +792 -0
  146. package/dist/ShaderLibraryCore.js.map +1 -0
  147. package/dist/ShaderModule.d.ts +3 -3
  148. package/dist/ShaderModule.d.ts.map +1 -1
  149. package/dist/ShaderModule.js +4 -2
  150. package/dist/ShaderModule.js.map +1 -1
  151. package/dist/ShaderReflection.d.ts +1 -1
  152. package/dist/ShadowMap.d.ts +1 -1
  153. package/dist/ShadowPass.d.ts +5 -5
  154. package/dist/ShadowPass.d.ts.map +1 -1
  155. package/dist/ShadowPass.js +6 -4
  156. package/dist/ShadowPass.js.map +1 -1
  157. package/dist/ShadowProjection.d.ts +1 -1
  158. package/dist/SkinnedLitMaterial.d.ts +3 -3
  159. package/dist/SkinnedLitMaterial.js +1 -1
  160. package/dist/SkinnedLitMaterial.js.map +1 -1
  161. package/dist/SkinnedUnlitMaterial.d.ts +1 -1
  162. package/dist/SkinnedUnlitMaterial.js +1 -1
  163. package/dist/SkinnedUnlitMaterial.js.map +1 -1
  164. package/dist/SkinningBounds.d.ts +2 -2
  165. package/dist/{SpaceEnvironmentFixtures.d.ts → SpaceEnvironment.d.ts} +4 -9
  166. package/dist/SpaceEnvironment.d.ts.map +1 -0
  167. package/dist/{SpaceEnvironmentFixtures.js → SpaceEnvironment.js} +6 -22
  168. package/dist/SpaceEnvironment.js.map +1 -0
  169. package/dist/SpecularPrefilter.d.ts +1 -1
  170. package/dist/SpriteGeometry.d.ts +1 -1
  171. package/dist/StereoCameraRig.d.ts +1 -1
  172. package/dist/StereoEffects.d.ts +1 -1
  173. package/dist/{TerrainFixtures.d.ts → TerrainHeightfield.d.ts} +2 -2
  174. package/dist/TerrainHeightfield.d.ts.map +1 -0
  175. package/dist/{TerrainFixtures.js → TerrainHeightfield.js} +1 -1
  176. package/dist/TerrainHeightfield.js.map +1 -0
  177. package/dist/TextureBinding.d.ts +16 -2
  178. package/dist/TextureBinding.d.ts.map +1 -1
  179. package/dist/TextureBinding.js +17 -0
  180. package/dist/TextureBinding.js.map +1 -1
  181. package/dist/TexturedPBRMaterial.d.ts +4 -4
  182. package/dist/TexturedPBRMaterial.js +1 -1
  183. package/dist/TexturedPBRMaterial.js.map +1 -1
  184. package/dist/TexturedUnlitMaterial.d.ts +3 -3
  185. package/dist/TexturedUnlitMaterial.js +1 -1
  186. package/dist/TexturedUnlitMaterial.js.map +1 -1
  187. package/dist/ToneMapping.d.ts +1 -1
  188. package/dist/UniformBinder.d.ts +1 -1
  189. package/dist/UnlitMaterial.d.ts +1 -1
  190. package/dist/UnlitMaterial.js +1 -1
  191. package/dist/UnlitMaterial.js.map +1 -1
  192. package/dist/{VegetationFixtures.d.ts → VegetationScatter.d.ts} +2 -2
  193. package/dist/VegetationScatter.d.ts.map +1 -0
  194. package/dist/{VegetationFixtures.js → VegetationScatter.js} +2 -2
  195. package/dist/VegetationScatter.js.map +1 -0
  196. package/dist/VertexBuffer.d.ts +2 -2
  197. package/dist/{VoxelWorldFixtures.d.ts → VoxelWorld.d.ts} +12 -15
  198. package/dist/VoxelWorld.d.ts.map +1 -0
  199. package/dist/{VoxelWorldFixtures.js → VoxelWorld.js} +6 -9
  200. package/dist/VoxelWorld.js.map +1 -0
  201. package/dist/{WeatherFixtures.d.ts → Weather.d.ts} +7 -9
  202. package/dist/Weather.d.ts.map +1 -0
  203. package/dist/{WeatherFixtures.js → Weather.js} +5 -7
  204. package/dist/Weather.js.map +1 -0
  205. package/dist/WebGL2Device.d.ts +23 -1
  206. package/dist/WebGL2Device.d.ts.map +1 -1
  207. package/dist/WebGL2Device.js +134 -23
  208. package/dist/WebGL2Device.js.map +1 -1
  209. package/dist/WebGPUDevice.d.ts +20 -3
  210. package/dist/WebGPUDevice.d.ts.map +1 -1
  211. package/dist/WebGPUDevice.js +188 -9
  212. package/dist/WebGPUDevice.js.map +1 -1
  213. package/dist/WebGPURenderToTextureProof.d.ts +1 -1
  214. package/dist/advanced-runtime/AdvancedRenderer.d.ts +3 -3
  215. package/dist/advanced-runtime/index.d.ts +9 -9
  216. package/dist/cinematic/BloomPass.d.ts +1 -1
  217. package/dist/cinematic/CinematicDepthComposition.d.ts +1 -1
  218. package/dist/cinematic/CinematicLightingRig.d.ts +2 -2
  219. package/dist/cinematic/CinematicMaterialPresets.d.ts +2 -2
  220. package/dist/cinematic/CinematicPostProcess.d.ts +6 -6
  221. package/dist/cinematic/DepthHazePass.d.ts +1 -1
  222. package/dist/cinematic/EmissivePracticalLightSystem.d.ts +2 -2
  223. package/dist/cinematic/FilmGrainPass.d.ts +1 -1
  224. package/dist/cinematic/FogVolumeSystem.d.ts +1 -1
  225. package/dist/cinematic/GlowCardSystem.d.ts +2 -2
  226. package/dist/cinematic/RainParticleSystem.d.ts +2 -2
  227. package/dist/cinematic/VignettePass.d.ts +1 -1
  228. package/dist/cinematic/WetReflectionApproximation.d.ts +1 -1
  229. package/dist/cinematic/index.d.ts +14 -14
  230. package/dist/index.d.ts +230 -237
  231. package/dist/index.d.ts.map +1 -1
  232. package/dist/index.js +35 -19
  233. package/dist/index.js.map +1 -1
  234. package/dist/lean/LeanProductRenderer.d.ts +29 -0
  235. package/dist/lean/LeanProductRenderer.d.ts.map +1 -0
  236. package/dist/lean/LeanProductRenderer.js +38 -0
  237. package/dist/lean/LeanProductRenderer.js.map +1 -0
  238. package/dist/lean/LeanProductionRenderer.d.ts +38 -0
  239. package/dist/lean/LeanProductionRenderer.d.ts.map +1 -0
  240. package/dist/lean/LeanProductionRenderer.js +88 -0
  241. package/dist/lean/LeanProductionRenderer.js.map +1 -0
  242. package/dist/lean-runtime.d.ts +18 -0
  243. package/dist/lean-runtime.d.ts.map +1 -0
  244. package/dist/lean-runtime.js +13 -0
  245. package/dist/lean-runtime.js.map +1 -0
  246. package/dist/materials/PhysicalMaterial.d.ts +1 -1
  247. package/dist/performance/BVH.d.ts +2 -2
  248. package/dist/performance/Batcher.d.ts +2 -2
  249. package/dist/performance/FrustumCuller.d.ts +1 -1
  250. package/dist/performance/Octree.d.ts +1 -1
  251. package/dist/postprocess/BloomPass.d.ts +1 -1
  252. package/dist/postprocess/CinematicDiagnostics.d.ts +1 -1
  253. package/dist/postprocess/ColorGradingPass.d.ts +1 -1
  254. package/dist/postprocess/DepthOfFieldPass.d.ts +1 -1
  255. package/dist/postprocess/EffectComposer.d.ts +3 -3
  256. package/dist/postprocess/EffectComposer.d.ts.map +1 -1
  257. package/dist/postprocess/EffectComposer.js +1 -3
  258. package/dist/postprocess/EffectComposer.js.map +1 -1
  259. package/dist/postprocess/SSAOPass.d.ts +1 -1
  260. package/dist/postprocess/index.d.ts +10 -10
  261. package/dist/production-runtime/AnimationControlsPipeline.d.ts +1 -1
  262. package/dist/production-runtime/PBRHDRPipeline.d.ts +4 -4
  263. package/dist/production-runtime/PBRHDRPipeline.d.ts.map +1 -1
  264. package/dist/production-runtime/PBRHDRPipeline.js +5 -1
  265. package/dist/production-runtime/PBRHDRPipeline.js.map +1 -1
  266. package/dist/production-runtime/ProductionEffectsPipeline.d.ts +2 -2
  267. package/dist/production-runtime/ProductionRendererTypes.d.ts +11 -2
  268. package/dist/production-runtime/ProductionRendererTypes.d.ts.map +1 -1
  269. package/dist/production-runtime/ProductionRendererTypes.js.map +1 -1
  270. package/dist/production-runtime/ProductionRuntimeRenderer.d.ts +8 -3
  271. package/dist/production-runtime/ProductionRuntimeRenderer.d.ts.map +1 -1
  272. package/dist/production-runtime/ProductionRuntimeRenderer.js +53 -5
  273. package/dist/production-runtime/ProductionRuntimeRenderer.js.map +1 -1
  274. package/dist/production-runtime/ProductionWebGL2Renderer.d.ts +14 -4
  275. package/dist/production-runtime/ProductionWebGL2Renderer.d.ts.map +1 -1
  276. package/dist/production-runtime/ProductionWebGL2Renderer.js +21 -2
  277. package/dist/production-runtime/ProductionWebGL2Renderer.js.map +1 -1
  278. package/dist/production-runtime/ProductionWebGPURenderer.d.ts +4 -4
  279. package/dist/production-runtime/ProductionWebGPURenderer.d.ts.map +1 -1
  280. package/dist/production-runtime/ProductionWebGPURenderer.js +4 -1
  281. package/dist/production-runtime/ProductionWebGPURenderer.js.map +1 -1
  282. package/dist/production-runtime/TransmissionBackdropCapture.d.ts +3 -3
  283. package/dist/production-runtime/backends/RendererBackend.d.ts +1 -1
  284. package/dist/production-runtime/backends/WebGL2RendererBackend.d.ts +3 -3
  285. package/dist/production-runtime/backends/WebGPURendererBackend.d.ts +1 -1
  286. package/dist/production-runtime/backends/webgl2/WebGL2StateCache.d.ts +1 -1
  287. package/dist/production-runtime/diagnostics/FrameCapture.d.ts +1 -1
  288. package/dist/production-runtime/environment/HDRLoader.d.ts +2 -2
  289. package/dist/production-runtime/environment/PMREMGenerator.d.ts +1 -1
  290. package/dist/production-runtime/framegraph/FrameGraph.d.ts +1 -1
  291. package/dist/production-runtime/geometry/ProjectedDecalGeometry.d.ts +1 -1
  292. package/dist/production-runtime/index.d.ts +74 -74
  293. package/dist/production-runtime/lights/LightManager.d.ts +1 -1
  294. package/dist/production-runtime/lights/ShadowMapRenderer.d.ts +1 -1
  295. package/dist/production-runtime/materials/GLTFMaterialAdapter.d.ts +1 -1
  296. package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.d.ts +2 -2
  297. package/dist/production-runtime/materials/MaterialCompiler.d.ts +2 -2
  298. package/dist/production-runtime/materials/MaterialTextureBindings.d.ts +1 -1
  299. package/dist/production-runtime/passes/ContactShadowPass.d.ts +1 -1
  300. package/dist/production-runtime/passes/DepthPrepass.d.ts +1 -1
  301. package/dist/production-runtime/passes/OpaquePass.d.ts +1 -1
  302. package/dist/production-runtime/passes/ShadowPass.d.ts +1 -1
  303. package/dist/production-runtime/passes/SkyboxPass.d.ts +1 -1
  304. package/dist/production-runtime/passes/ToneMappingPass.d.ts +1 -1
  305. package/dist/production-runtime/passes/TransparentPass.d.ts +1 -1
  306. package/dist/production-runtime/postprocess/BloomPass.d.ts +2 -2
  307. package/dist/production-runtime/postprocess/ColorGradingPass.d.ts +2 -2
  308. package/dist/production-runtime/postprocess/DOFPass.d.ts +2 -2
  309. package/dist/production-runtime/postprocess/FXAAPass.d.ts +2 -2
  310. package/dist/production-runtime/postprocess/ProductionEffectComposer.d.ts +1 -1
  311. package/dist/production-runtime/postprocess/ProductionPostProcessTypes.d.ts +1 -1
  312. package/dist/production-runtime/postprocess/SSAOPass.d.ts +2 -2
  313. package/dist/production-runtime/resources/RenderTarget.d.ts +1 -1
  314. package/dist/production-runtime/scene/RenderableMesh.d.ts +1 -1
  315. package/dist/production-runtime/scene/RenderableScene.d.ts +3 -3
  316. package/dist/shadows/CascadedShadowPipeline.d.ts +1 -1
  317. package/dist/shadows/ShadowDebugViews.d.ts +2 -2
  318. package/dist/threejs-example-parity/index.d.ts +4 -4
  319. package/dist/webgpu/WebGPUBuffer.d.ts +1 -1
  320. package/dist/webgpu/WebGPUCompute.d.ts +2 -2
  321. package/dist/webgpu/WebGPUPostProcess.d.ts +2 -2
  322. package/dist/webgpu/WebGPUTexture.d.ts +2 -2
  323. package/dist/webgpu.d.ts +25 -0
  324. package/dist/webgpu.d.ts.map +1 -0
  325. package/dist/webgpu.js +24 -0
  326. package/dist/webgpu.js.map +1 -0
  327. package/package.json +11 -3
  328. package/dist/ArchitecturalLightingFixtures.d.ts +0 -40
  329. package/dist/ArchitecturalLightingFixtures.d.ts.map +0 -1
  330. package/dist/ArchitecturalLightingFixtures.js.map +0 -1
  331. package/dist/ArchitecturalMeasurementFixtures.d.ts.map +0 -1
  332. package/dist/ArchitecturalMeasurementFixtures.js.map +0 -1
  333. package/dist/CanonicalSceneFixtures.d.ts.map +0 -1
  334. package/dist/CanonicalSceneFixtures.js.map +0 -1
  335. package/dist/CullingFixtures.d.ts +0 -70
  336. package/dist/CullingFixtures.d.ts.map +0 -1
  337. package/dist/CullingFixtures.js +0 -191
  338. package/dist/CullingFixtures.js.map +0 -1
  339. package/dist/OceanFixtures.d.ts.map +0 -1
  340. package/dist/OceanFixtures.js.map +0 -1
  341. package/dist/ProceduralTextureFixtures.d.ts.map +0 -1
  342. package/dist/ProceduralTextureFixtures.js.map +0 -1
  343. package/dist/ProductTurntableFixtures.d.ts.map +0 -1
  344. package/dist/ProductTurntableFixtures.js.map +0 -1
  345. package/dist/SpaceEnvironmentFixtures.d.ts.map +0 -1
  346. package/dist/SpaceEnvironmentFixtures.js.map +0 -1
  347. package/dist/TerrainFixtures.d.ts.map +0 -1
  348. package/dist/TerrainFixtures.js.map +0 -1
  349. package/dist/VegetationFixtures.d.ts.map +0 -1
  350. package/dist/VegetationFixtures.js.map +0 -1
  351. package/dist/VoxelWorldFixtures.d.ts.map +0 -1
  352. package/dist/VoxelWorldFixtures.js.map +0 -1
  353. package/dist/WeatherFixtures.d.ts.map +0 -1
  354. package/dist/WeatherFixtures.js.map +0 -1
  355. package/dist/cartoon/CartoonMaterialStyle.d.ts +0 -19
  356. package/dist/cartoon/CartoonMaterialStyle.d.ts.map +0 -1
  357. package/dist/cartoon/CartoonMaterialStyle.js +0 -13
  358. package/dist/cartoon/CartoonMaterialStyle.js.map +0 -1
  359. package/dist/cartoon/CartoonRenderPreset.d.ts +0 -36
  360. package/dist/cartoon/CartoonRenderPreset.d.ts.map +0 -1
  361. package/dist/cartoon/CartoonRenderPreset.js +0 -23
  362. package/dist/cartoon/CartoonRenderPreset.js.map +0 -1
  363. package/dist/cartoon/CartoonToonMaterial.d.ts +0 -130
  364. package/dist/cartoon/CartoonToonMaterial.d.ts.map +0 -1
  365. package/dist/cartoon/CartoonToonMaterial.js +0 -303
  366. package/dist/cartoon/CartoonToonMaterial.js.map +0 -1
  367. package/dist/cartoon/CartoonVisualQuality.d.ts +0 -28
  368. package/dist/cartoon/CartoonVisualQuality.d.ts.map +0 -1
  369. package/dist/cartoon/CartoonVisualQuality.js +0 -39
  370. package/dist/cartoon/CartoonVisualQuality.js.map +0 -1
  371. package/dist/cartoon/applyCartoonRenderPreset.d.ts +0 -79
  372. package/dist/cartoon/applyCartoonRenderPreset.d.ts.map +0 -1
  373. package/dist/cartoon/applyCartoonRenderPreset.js +0 -88
  374. package/dist/cartoon/applyCartoonRenderPreset.js.map +0 -1
  375. package/dist/cartoon/index.d.ts +0 -6
  376. package/dist/cartoon/index.d.ts.map +0 -1
  377. package/dist/cartoon/index.js +0 -6
  378. package/dist/cartoon/index.js.map +0 -1
  379. package/dist/threejs-compatibility/InstancingSystem.d.ts +0 -10
  380. package/dist/threejs-compatibility/InstancingSystem.d.ts.map +0 -1
  381. package/dist/threejs-compatibility/InstancingSystem.js +0 -11
  382. package/dist/threejs-compatibility/InstancingSystem.js.map +0 -1
  383. package/dist/threejs-compatibility/LightingSystem.d.ts +0 -11
  384. package/dist/threejs-compatibility/LightingSystem.d.ts.map +0 -1
  385. package/dist/threejs-compatibility/LightingSystem.js +0 -14
  386. package/dist/threejs-compatibility/LightingSystem.js.map +0 -1
  387. package/dist/threejs-compatibility/MaterialSystem.d.ts +0 -6
  388. package/dist/threejs-compatibility/MaterialSystem.d.ts.map +0 -1
  389. package/dist/threejs-compatibility/MaterialSystem.js +0 -7
  390. package/dist/threejs-compatibility/MaterialSystem.js.map +0 -1
  391. package/dist/threejs-compatibility/RenderTargetSystem.d.ts +0 -16
  392. package/dist/threejs-compatibility/RenderTargetSystem.d.ts.map +0 -1
  393. package/dist/threejs-compatibility/RenderTargetSystem.js +0 -23
  394. package/dist/threejs-compatibility/RenderTargetSystem.js.map +0 -1
  395. package/dist/threejs-compatibility/RendererDiagnostics.d.ts +0 -27
  396. package/dist/threejs-compatibility/RendererDiagnostics.d.ts.map +0 -1
  397. package/dist/threejs-compatibility/RendererDiagnostics.js +0 -41
  398. package/dist/threejs-compatibility/RendererDiagnostics.js.map +0 -1
  399. package/dist/threejs-compatibility/SceneRenderer.d.ts +0 -19
  400. package/dist/threejs-compatibility/SceneRenderer.d.ts.map +0 -1
  401. package/dist/threejs-compatibility/SceneRenderer.js +0 -18
  402. package/dist/threejs-compatibility/SceneRenderer.js.map +0 -1
  403. package/dist/threejs-compatibility/ShadowSystem.d.ts +0 -11
  404. package/dist/threejs-compatibility/ShadowSystem.d.ts.map +0 -1
  405. package/dist/threejs-compatibility/ShadowSystem.js +0 -12
  406. package/dist/threejs-compatibility/ShadowSystem.js.map +0 -1
  407. package/dist/threejs-compatibility/TextureSystem.d.ts +0 -9
  408. package/dist/threejs-compatibility/TextureSystem.d.ts.map +0 -1
  409. package/dist/threejs-compatibility/TextureSystem.js +0 -14
  410. package/dist/threejs-compatibility/TextureSystem.js.map +0 -1
  411. package/dist/threejs-compatibility/ThreeCompatRenderer.d.ts +0 -37
  412. package/dist/threejs-compatibility/ThreeCompatRenderer.d.ts.map +0 -1
  413. package/dist/threejs-compatibility/ThreeCompatRenderer.js +0 -77
  414. package/dist/threejs-compatibility/ThreeCompatRenderer.js.map +0 -1
  415. package/dist/threejs-compatibility/TransparencySystem.d.ts +0 -11
  416. package/dist/threejs-compatibility/TransparencySystem.d.ts.map +0 -1
  417. package/dist/threejs-compatibility/TransparencySystem.js +0 -12
  418. package/dist/threejs-compatibility/TransparencySystem.js.map +0 -1
  419. package/dist/threejs-compatibility/index.d.ts +0 -25
  420. package/dist/threejs-compatibility/index.d.ts.map +0 -1
  421. package/dist/threejs-compatibility/index.js +0 -15
  422. package/dist/threejs-compatibility/index.js.map +0 -1
  423. package/dist/threejs-compatibility/performance/BVH.d.ts +0 -11
  424. package/dist/threejs-compatibility/performance/BVH.d.ts.map +0 -1
  425. package/dist/threejs-compatibility/performance/BVH.js +0 -10
  426. package/dist/threejs-compatibility/performance/BVH.js.map +0 -1
  427. package/dist/threejs-compatibility/performance/FrustumCulling.d.ts +0 -7
  428. package/dist/threejs-compatibility/performance/FrustumCulling.d.ts.map +0 -1
  429. package/dist/threejs-compatibility/performance/FrustumCulling.js +0 -5
  430. package/dist/threejs-compatibility/performance/FrustumCulling.js.map +0 -1
  431. package/dist/threejs-compatibility/performance/Instancing.d.ts +0 -7
  432. package/dist/threejs-compatibility/performance/Instancing.d.ts.map +0 -1
  433. package/dist/threejs-compatibility/performance/Instancing.js +0 -10
  434. package/dist/threejs-compatibility/performance/Instancing.js.map +0 -1
  435. package/dist/threejs-compatibility/performance/LODSystem.d.ts +0 -9
  436. package/dist/threejs-compatibility/performance/LODSystem.d.ts.map +0 -1
  437. package/dist/threejs-compatibility/performance/LODSystem.js +0 -11
  438. package/dist/threejs-compatibility/performance/LODSystem.js.map +0 -1
  439. package/dist/threejs-compatibility/performance/OcclusionCulling.d.ts +0 -3
  440. package/dist/threejs-compatibility/performance/OcclusionCulling.d.ts.map +0 -1
  441. package/dist/threejs-compatibility/performance/OcclusionCulling.js +0 -5
  442. package/dist/threejs-compatibility/performance/OcclusionCulling.js.map +0 -1
  443. package/dist/threejs-compatibility/performance/RaycastAcceleration.d.ts +0 -8
  444. package/dist/threejs-compatibility/performance/RaycastAcceleration.d.ts.map +0 -1
  445. package/dist/threejs-compatibility/performance/RaycastAcceleration.js +0 -11
  446. package/dist/threejs-compatibility/performance/RaycastAcceleration.js.map +0 -1
  447. package/dist/threejs-compatibility/performance/RendererProfiler.d.ts +0 -11
  448. package/dist/threejs-compatibility/performance/RendererProfiler.d.ts.map +0 -1
  449. package/dist/threejs-compatibility/performance/RendererProfiler.js +0 -10
  450. package/dist/threejs-compatibility/performance/RendererProfiler.js.map +0 -1
  451. package/dist/threejs-compatibility/performance/TextureStreaming.d.ts +0 -7
  452. package/dist/threejs-compatibility/performance/TextureStreaming.d.ts.map +0 -1
  453. package/dist/threejs-compatibility/performance/TextureStreaming.js +0 -10
  454. package/dist/threejs-compatibility/performance/TextureStreaming.js.map +0 -1
  455. package/dist/threejs-compatibility/performance/index.d.ts +0 -13
  456. package/dist/threejs-compatibility/performance/index.d.ts.map +0 -1
  457. package/dist/threejs-compatibility/performance/index.js +0 -9
  458. package/dist/threejs-compatibility/performance/index.js.map +0 -1
  459. package/dist/threejs-compatibility/postprocess/BloomPass.d.ts +0 -9
  460. package/dist/threejs-compatibility/postprocess/BloomPass.d.ts.map +0 -1
  461. package/dist/threejs-compatibility/postprocess/BloomPass.js +0 -14
  462. package/dist/threejs-compatibility/postprocess/BloomPass.js.map +0 -1
  463. package/dist/threejs-compatibility/postprocess/ColorGradingPass.d.ts +0 -10
  464. package/dist/threejs-compatibility/postprocess/ColorGradingPass.d.ts.map +0 -1
  465. package/dist/threejs-compatibility/postprocess/ColorGradingPass.js +0 -16
  466. package/dist/threejs-compatibility/postprocess/ColorGradingPass.js.map +0 -1
  467. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.d.ts +0 -9
  468. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.d.ts.map +0 -1
  469. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.js +0 -19
  470. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.js.map +0 -1
  471. package/dist/threejs-compatibility/postprocess/EffectComposer.d.ts +0 -7
  472. package/dist/threejs-compatibility/postprocess/EffectComposer.d.ts.map +0 -1
  473. package/dist/threejs-compatibility/postprocess/EffectComposer.js +0 -11
  474. package/dist/threejs-compatibility/postprocess/EffectComposer.js.map +0 -1
  475. package/dist/threejs-compatibility/postprocess/FXAAPass.d.ts +0 -7
  476. package/dist/threejs-compatibility/postprocess/FXAAPass.d.ts.map +0 -1
  477. package/dist/threejs-compatibility/postprocess/FXAAPass.js +0 -10
  478. package/dist/threejs-compatibility/postprocess/FXAAPass.js.map +0 -1
  479. package/dist/threejs-compatibility/postprocess/MotionBlurPass.d.ts +0 -9
  480. package/dist/threejs-compatibility/postprocess/MotionBlurPass.d.ts.map +0 -1
  481. package/dist/threejs-compatibility/postprocess/MotionBlurPass.js +0 -18
  482. package/dist/threejs-compatibility/postprocess/MotionBlurPass.js.map +0 -1
  483. package/dist/threejs-compatibility/postprocess/OutlinePass.d.ts +0 -9
  484. package/dist/threejs-compatibility/postprocess/OutlinePass.d.ts.map +0 -1
  485. package/dist/threejs-compatibility/postprocess/OutlinePass.js +0 -19
  486. package/dist/threejs-compatibility/postprocess/OutlinePass.js.map +0 -1
  487. package/dist/threejs-compatibility/postprocess/PostProcessTypes.d.ts +0 -42
  488. package/dist/threejs-compatibility/postprocess/PostProcessTypes.d.ts.map +0 -1
  489. package/dist/threejs-compatibility/postprocess/PostProcessTypes.js +0 -123
  490. package/dist/threejs-compatibility/postprocess/PostProcessTypes.js.map +0 -1
  491. package/dist/threejs-compatibility/postprocess/RenderPass.d.ts +0 -7
  492. package/dist/threejs-compatibility/postprocess/RenderPass.d.ts.map +0 -1
  493. package/dist/threejs-compatibility/postprocess/RenderPass.js +0 -8
  494. package/dist/threejs-compatibility/postprocess/RenderPass.js.map +0 -1
  495. package/dist/threejs-compatibility/postprocess/SMAAPass.d.ts +0 -7
  496. package/dist/threejs-compatibility/postprocess/SMAAPass.d.ts.map +0 -1
  497. package/dist/threejs-compatibility/postprocess/SMAAPass.js +0 -10
  498. package/dist/threejs-compatibility/postprocess/SMAAPass.js.map +0 -1
  499. package/dist/threejs-compatibility/postprocess/SSAOPass.d.ts +0 -9
  500. package/dist/threejs-compatibility/postprocess/SSAOPass.d.ts.map +0 -1
  501. package/dist/threejs-compatibility/postprocess/SSAOPass.js +0 -19
  502. package/dist/threejs-compatibility/postprocess/SSAOPass.js.map +0 -1
  503. package/dist/threejs-compatibility/postprocess/ShaderPass.d.ts +0 -9
  504. package/dist/threejs-compatibility/postprocess/ShaderPass.d.ts.map +0 -1
  505. package/dist/threejs-compatibility/postprocess/ShaderPass.js +0 -11
  506. package/dist/threejs-compatibility/postprocess/ShaderPass.js.map +0 -1
  507. package/dist/threejs-compatibility/postprocess/TAAPass.d.ts +0 -7
  508. package/dist/threejs-compatibility/postprocess/TAAPass.d.ts.map +0 -1
  509. package/dist/threejs-compatibility/postprocess/TAAPass.js +0 -10
  510. package/dist/threejs-compatibility/postprocess/TAAPass.js.map +0 -1
  511. package/dist/threejs-compatibility/postprocess/VignettePass.d.ts +0 -9
  512. package/dist/threejs-compatibility/postprocess/VignettePass.d.ts.map +0 -1
  513. package/dist/threejs-compatibility/postprocess/VignettePass.js +0 -14
  514. package/dist/threejs-compatibility/postprocess/VignettePass.js.map +0 -1
  515. package/dist/threejs-compatibility/postprocess/index.d.ts +0 -16
  516. package/dist/threejs-compatibility/postprocess/index.d.ts.map +0 -1
  517. package/dist/threejs-compatibility/postprocess/index.js +0 -15
  518. package/dist/threejs-compatibility/postprocess/index.js.map +0 -1
  519. package/dist/threejs-compatibility/shaders/NodeMaterial.d.ts +0 -14
  520. package/dist/threejs-compatibility/shaders/NodeMaterial.d.ts.map +0 -1
  521. package/dist/threejs-compatibility/shaders/NodeMaterial.js +0 -15
  522. package/dist/threejs-compatibility/shaders/NodeMaterial.js.map +0 -1
  523. package/dist/threejs-compatibility/shaders/RawShaderMaterial.d.ts +0 -6
  524. package/dist/threejs-compatibility/shaders/RawShaderMaterial.d.ts.map +0 -1
  525. package/dist/threejs-compatibility/shaders/RawShaderMaterial.js +0 -6
  526. package/dist/threejs-compatibility/shaders/RawShaderMaterial.js.map +0 -1
  527. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.d.ts +0 -7
  528. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.d.ts.map +0 -1
  529. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.js +0 -12
  530. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.js.map +0 -1
  531. package/dist/threejs-compatibility/shaders/ShaderMaterial.d.ts +0 -12
  532. package/dist/threejs-compatibility/shaders/ShaderMaterial.d.ts.map +0 -1
  533. package/dist/threejs-compatibility/shaders/ShaderMaterial.js +0 -20
  534. package/dist/threejs-compatibility/shaders/ShaderMaterial.js.map +0 -1
  535. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.d.ts +0 -7
  536. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.d.ts.map +0 -1
  537. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.js +0 -7
  538. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.js.map +0 -1
  539. package/dist/threejs-compatibility/shaders/Uniforms.d.ts +0 -8
  540. package/dist/threejs-compatibility/shaders/Uniforms.d.ts.map +0 -1
  541. package/dist/threejs-compatibility/shaders/Uniforms.js +0 -14
  542. package/dist/threejs-compatibility/shaders/Uniforms.js.map +0 -1
  543. package/dist/threejs-compatibility/shaders/index.d.ts +0 -10
  544. package/dist/threejs-compatibility/shaders/index.d.ts.map +0 -1
  545. package/dist/threejs-compatibility/shaders/index.js +0 -7
  546. package/dist/threejs-compatibility/shaders/index.js.map +0 -1
  547. package/dist/threejs-compatibility/vfx/GPUPointCloud.d.ts +0 -7
  548. package/dist/threejs-compatibility/vfx/GPUPointCloud.d.ts.map +0 -1
  549. package/dist/threejs-compatibility/vfx/GPUPointCloud.js +0 -12
  550. package/dist/threejs-compatibility/vfx/GPUPointCloud.js.map +0 -1
  551. package/dist/threejs-compatibility/vfx/LineRenderer.d.ts +0 -10
  552. package/dist/threejs-compatibility/vfx/LineRenderer.d.ts.map +0 -1
  553. package/dist/threejs-compatibility/vfx/LineRenderer.js +0 -7
  554. package/dist/threejs-compatibility/vfx/LineRenderer.js.map +0 -1
  555. package/dist/threejs-compatibility/vfx/ParticleSystem.d.ts +0 -12
  556. package/dist/threejs-compatibility/vfx/ParticleSystem.d.ts.map +0 -1
  557. package/dist/threejs-compatibility/vfx/ParticleSystem.js +0 -15
  558. package/dist/threejs-compatibility/vfx/ParticleSystem.js.map +0 -1
  559. package/dist/threejs-compatibility/vfx/SpriteSystem.d.ts +0 -11
  560. package/dist/threejs-compatibility/vfx/SpriteSystem.d.ts.map +0 -1
  561. package/dist/threejs-compatibility/vfx/SpriteSystem.js +0 -7
  562. package/dist/threejs-compatibility/vfx/SpriteSystem.js.map +0 -1
  563. package/dist/threejs-compatibility/vfx/TrailRenderer.d.ts +0 -5
  564. package/dist/threejs-compatibility/vfx/TrailRenderer.d.ts.map +0 -1
  565. package/dist/threejs-compatibility/vfx/TrailRenderer.js +0 -9
  566. package/dist/threejs-compatibility/vfx/TrailRenderer.js.map +0 -1
  567. package/dist/threejs-compatibility/vfx/VFXDiagnostics.d.ts +0 -21
  568. package/dist/threejs-compatibility/vfx/VFXDiagnostics.d.ts.map +0 -1
  569. package/dist/threejs-compatibility/vfx/VFXDiagnostics.js +0 -12
  570. package/dist/threejs-compatibility/vfx/VFXDiagnostics.js.map +0 -1
  571. package/dist/threejs-compatibility/vfx/index.d.ts +0 -10
  572. package/dist/threejs-compatibility/vfx/index.d.ts.map +0 -1
  573. package/dist/threejs-compatibility/vfx/index.js +0 -7
  574. package/dist/threejs-compatibility/vfx/index.js.map +0 -1
@@ -1,190 +1,14 @@
1
- import { ShaderPreprocessor } from "./ShaderPreprocessor.js";
2
- import { DEFAULT_PBR_SHADER_MARKER, DEFAULT_PBR_SHADER_NAME } from "./PBRMaterial.js";
3
1
  import { SHADER_CHUNKS, validateShaderChunks } from "./ShaderChunks.js";
4
2
  import { registerAnimationToonShader } from "./animation/AnimationToonMaterial.js";
5
- export class ShaderLibrary {
6
- shaders = new Map();
7
- chunks = new Map();
8
- preprocessor = new ShaderPreprocessor();
9
- variantCache = new Map();
10
- register(shader) {
11
- if (this.shaders.has(shader.name)) {
12
- throw new Error(`Shader is already registered: ${shader.name}`);
13
- }
14
- this.assertMarker(shader);
15
- this.assertVariants(shader);
16
- this.shaders.set(shader.name, shader);
17
- this.variantCache.clear();
18
- }
19
- registerChunk(name, source) {
20
- if (this.chunks.has(name)) {
21
- throw new Error(`Shader chunk is already registered: ${name}`);
22
- }
23
- this.chunks.set(name, source);
24
- this.variantCache.clear();
25
- }
26
- get(name) {
27
- const shader = this.shaders.get(name);
28
- if (!shader) {
29
- throw new Error(`Shader is not registered: ${name}`);
30
- }
31
- return shader;
32
- }
33
- compileSource(name, options = {}) {
34
- const shader = this.get(name);
35
- const includes = new Map([...this.chunks, ...(options.includes ?? new Map())]);
36
- const preprocessOptions = { ...options, includes };
37
- const vertex = this.preprocessor.preprocess(shader.vertex, preprocessOptions).source;
38
- const fragment = this.preprocessor.preprocess(shader.fragment, preprocessOptions).source;
39
- if (!vertex.includes(shader.marker) || !fragment.includes(shader.marker)) {
40
- throw new Error(`Shader marker ${shader.marker} was not preserved for ${name}`);
41
- }
42
- return { label: name, marker: shader.marker, vertex, fragment };
43
- }
44
- compileVariant(name, variantName, options = {}) {
45
- const shader = this.get(name);
46
- const variant = shader.variants?.find((candidate) => candidate.name === variantName);
47
- if (!variant) {
48
- throw new Error(`Shader variant is not registered: ${name}:${variantName}`);
49
- }
50
- const compileOptions = {
51
- ...options,
52
- defines: {
53
- ...(variant.defines ?? {}),
54
- ...(options.defines ?? {})
55
- }
56
- };
57
- const cacheKey = variantCacheKey(name, variantName, compileOptions);
58
- const cached = this.variantCache.get(cacheKey);
59
- if (cached) {
60
- return cached;
61
- }
62
- const compiled = this.compileSource(name, compileOptions);
63
- const labeled = { ...compiled, label: `${name}:${variantName}` };
64
- this.variantCache.set(cacheKey, labeled);
65
- return labeled;
66
- }
67
- names() {
68
- return [...this.shaders.keys()];
69
- }
70
- assertMarker(shader) {
71
- if (!shader.marker.trim()) {
72
- throw new Error(`Shader ${shader.name} must declare a non-empty source marker`);
73
- }
74
- if (!shader.vertex.includes(shader.marker) || !shader.fragment.includes(shader.marker)) {
75
- throw new Error(`Shader ${shader.name} must include marker ${shader.marker} in both stages`);
76
- }
77
- }
78
- assertVariants(shader) {
79
- const seen = new Set();
80
- for (const variant of shader.variants ?? []) {
81
- if (!variant.name.trim()) {
82
- throw new Error(`Shader ${shader.name} has a variant with an empty name`);
83
- }
84
- if (seen.has(variant.name)) {
85
- throw new Error(`Shader variant is already registered: ${shader.name}:${variant.name}`);
86
- }
87
- seen.add(variant.name);
88
- }
89
- }
90
- }
91
- function variantCacheKey(name, variantName, options) {
92
- return JSON.stringify({
93
- name,
94
- variantName,
95
- defines: Object.entries(options.defines ?? {}).sort(([left], [right]) => left.localeCompare(right)),
96
- includes: [...(options.includes ?? new Map()).entries()].sort(([left], [right]) => left.localeCompare(right))
97
- });
98
- }
99
- export const DEFAULT_UNLIT_SHADER_NAME = "aura3d/unlit";
100
- export const DEFAULT_UNLIT_SHADER_MARKER = "@aura3d-shader:unlit";
101
- export const DEFAULT_INSTANCED_UNLIT_SHADER_NAME = "aura3d/instanced-unlit";
102
- export const DEFAULT_INSTANCED_UNLIT_SHADER_MARKER = "@aura3d-shader:instanced-unlit";
103
- export const DEFAULT_INSTANCED_PBR_SHADER_NAME = "aura3d/instanced-pbr";
104
- export const DEFAULT_INSTANCED_PBR_SHADER_MARKER = "@aura3d-shader:instanced-pbr";
105
- export const DEFAULT_TEXTURED_UNLIT_SHADER_NAME = "aura3d/textured-unlit";
106
- export const DEFAULT_TEXTURED_UNLIT_SHADER_MARKER = "@aura3d-shader:textured-unlit";
107
- export const DEFAULT_SKINNED_UNLIT_SHADER_NAME = "aura3d/skinned-unlit";
108
- export const DEFAULT_SKINNED_UNLIT_SHADER_MARKER = "@aura3d-shader:skinned-unlit";
109
- export const DEFAULT_SKINNED_LIT_SHADER_NAME = "aura3d/skinned-lit";
110
- export const DEFAULT_SKINNED_LIT_SHADER_MARKER = "@aura3d-shader:skinned-lit";
111
- /**
112
- * Eight-influence skinned shaders. These read a second `JOINTS_1`/`WEIGHTS_1`
113
- * attribute set and select between uniform-array and data-texture joint palettes at
114
- * runtime through `u_jointPaletteMode`, so a single program serves both small rigs
115
- * and rigs above the uniform-array joint limit.
116
- */
117
- export const DEFAULT_SKINNED_UNLIT_EIGHT_INFLUENCE_SHADER_NAME = "aura3d/skinned-unlit-8";
118
- export const DEFAULT_SKINNED_UNLIT_EIGHT_INFLUENCE_SHADER_MARKER = "@aura3d-shader:skinned-unlit-8";
119
- export const DEFAULT_SKINNED_LIT_EIGHT_INFLUENCE_SHADER_NAME = "aura3d/skinned-lit-8";
120
- export const DEFAULT_SKINNED_LIT_EIGHT_INFLUENCE_SHADER_MARKER = "@aura3d-shader:skinned-lit-8";
121
- export const DEFAULT_MORPH_UNLIT_SHADER_NAME = "aura3d/morph-unlit";
122
- export const DEFAULT_MORPH_UNLIT_SHADER_MARKER = "@aura3d-shader:morph-unlit";
123
- export const DEFAULT_NORMAL_MAPPED_PBR_SHADER_NAME = "aura3d/pbr-normal-map";
124
- export const DEFAULT_NORMAL_MAPPED_PBR_SHADER_MARKER = "@aura3d-shader:pbr-normal-map";
125
- export const DEFAULT_TEXTURED_PBR_SHADER_NAME = "aura3d/pbr-textured";
126
- export const DEFAULT_TEXTURED_PBR_SHADER_MARKER = "@aura3d-shader:pbr-textured";
127
- export const DEFAULT_TEXTURED_PBR_CLEARCOAT_TEXTURES_VARIANT = "clearcoat-textures";
128
- export const DEFAULT_TEXTURED_PBR_TRANSMISSION_VOLUME_TEXTURES_VARIANT = "transmission-volume-textures";
129
- export const DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_TEXTURES_VARIANT = "specular-sheen-anisotropy-textures";
130
- export const DEFAULT_TEXTURED_PBR_IRIDESCENCE_TEXTURES_VARIANT = "iridescence-textures";
131
- export const DEFAULT_TEXTURED_PBR_CLEARCOAT_TRANSMISSION_VOLUME_TEXTURES_VARIANT = "clearcoat-transmission-volume-textures";
132
- export const DEFAULT_TEXTURED_PBR_CLEARCOAT_SPECULAR_TEXTURES_VARIANT = "clearcoat-specular-textures";
133
- export const DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_IRIDESCENCE_TEXTURES_VARIANT = "specular-sheen-anisotropy-iridescence-textures";
134
- /**
135
- * True screen-space fat lines, equivalent in intent to Three.js `Line2`/`LineMaterial`.
136
- * Width is specified in pixels and stays constant across distance, FOV, viewport size,
137
- * and device pixel ratio.
138
- */
139
- export const DEFAULT_SCREEN_SPACE_LINE_SHADER_NAME = "aura3d/screen-space-line";
140
- export const DEFAULT_SCREEN_SPACE_LINE_SHADER_MARKER = "@aura3d-shader:screen-space-line";
141
- export const DEFAULT_DEPTH_SHADER_NAME = "aura3d/depth";
142
- export const DEFAULT_DEPTH_SHADER_MARKER = "@aura3d-shader:depth";
143
- export const DEFAULT_ENVIRONMENT_BACKGROUND_SHADER_NAME = "aura3d/environment-background";
144
- export const DEFAULT_ENVIRONMENT_BACKGROUND_SHADER_MARKER = "@aura3d-shader:environment-background";
3
+ import { ShaderLibrary, registerLeanUnlitShader, registerLeanPbrShader, registerLeanDepthShader, registerLeanEnvironmentBackgroundShader, DEFAULT_DEPTH_SHADER_MARKER, DEFAULT_DEPTH_SHADER_NAME, DEFAULT_ENVIRONMENT_BACKGROUND_SHADER_MARKER, DEFAULT_ENVIRONMENT_BACKGROUND_SHADER_NAME, DEFAULT_INSTANCED_PBR_SHADER_MARKER, DEFAULT_INSTANCED_PBR_SHADER_NAME, DEFAULT_INSTANCED_UNLIT_SHADER_MARKER, DEFAULT_INSTANCED_UNLIT_SHADER_NAME, DEFAULT_MORPH_UNLIT_SHADER_MARKER, DEFAULT_MORPH_UNLIT_SHADER_NAME, DEFAULT_NORMAL_MAPPED_PBR_SHADER_MARKER, DEFAULT_NORMAL_MAPPED_PBR_SHADER_NAME, DEFAULT_PBR_SHADER_MARKER, DEFAULT_PBR_SHADER_NAME, DEFAULT_SCREEN_SPACE_LINE_SHADER_MARKER, DEFAULT_SCREEN_SPACE_LINE_SHADER_NAME, DEFAULT_SKINNED_LIT_EIGHT_INFLUENCE_SHADER_MARKER, DEFAULT_SKINNED_LIT_EIGHT_INFLUENCE_SHADER_NAME, DEFAULT_SKINNED_LIT_SHADER_MARKER, DEFAULT_SKINNED_LIT_SHADER_NAME, DEFAULT_SKINNED_UNLIT_EIGHT_INFLUENCE_SHADER_MARKER, DEFAULT_SKINNED_UNLIT_EIGHT_INFLUENCE_SHADER_NAME, DEFAULT_SKINNED_UNLIT_SHADER_MARKER, DEFAULT_SKINNED_UNLIT_SHADER_NAME, DEFAULT_TEXTURED_PBR_CLEARCOAT_SPECULAR_TEXTURES_VARIANT, DEFAULT_TEXTURED_PBR_CLEARCOAT_TEXTURES_VARIANT, DEFAULT_TEXTURED_PBR_CLEARCOAT_TRANSMISSION_VOLUME_TEXTURES_VARIANT, DEFAULT_TEXTURED_PBR_IRIDESCENCE_TEXTURES_VARIANT, DEFAULT_TEXTURED_PBR_SHADER_MARKER, DEFAULT_TEXTURED_PBR_SHADER_NAME, DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_IRIDESCENCE_TEXTURES_VARIANT, DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_TEXTURES_VARIANT, DEFAULT_TEXTURED_PBR_TRANSMISSION_VOLUME_TEXTURES_VARIANT, DEFAULT_TEXTURED_UNLIT_SHADER_MARKER, DEFAULT_TEXTURED_UNLIT_SHADER_NAME, DEFAULT_UNLIT_SHADER_MARKER, DEFAULT_UNLIT_SHADER_NAME, } from "./ShaderLibraryCore.js";
4
+ export * from "./ShaderLibraryCore.js";
145
5
  export function createDefaultShaderLibrary() {
146
6
  const library = new ShaderLibrary();
147
7
  validateShaderChunks();
148
8
  for (const chunk of SHADER_CHUNKS) {
149
9
  library.registerChunk(chunk.name, chunk.source);
150
10
  }
151
- library.register({
152
- name: DEFAULT_UNLIT_SHADER_NAME,
153
- marker: DEFAULT_UNLIT_SHADER_MARKER,
154
- vertex: `#version 300 es
155
- // ${DEFAULT_UNLIT_SHADER_MARKER}
156
- precision highp float;
157
- layout(location = 0) in vec3 a_position;
158
- layout(location = 4) in vec4 a_color;
159
- uniform mat4 u_modelViewProjection;
160
- uniform float u_pointSize;
161
- out vec4 v_vertexColor;
162
- void main() {
163
- v_vertexColor = a_color;
164
- gl_PointSize = max(u_pointSize, 1.0);
165
- gl_Position = u_modelViewProjection * vec4(a_position, 1.0);
166
- }
167
- `,
168
- fragment: `#version 300 es
169
- // ${DEFAULT_UNLIT_SHADER_MARKER}
170
- precision highp float;
171
- uniform vec4 u_baseColor;
172
- uniform float u_alphaCutoff;
173
- uniform float u_roundPoints;
174
- in vec4 v_vertexColor;
175
- out vec4 outColor;
176
- void main() {
177
- if (u_roundPoints > 0.5) {
178
- vec2 pointUv = gl_PointCoord * 2.0 - 1.0;
179
- float radius = dot(pointUv, pointUv);
180
- if (radius > 1.0) discard;
181
- }
182
- vec4 base = u_baseColor * v_vertexColor;
183
- if (base.a < u_alphaCutoff) discard;
184
- outColor = base;
185
- }
186
- `
187
- });
11
+ registerLeanUnlitShader(library);
188
12
  library.register({
189
13
  name: DEFAULT_INSTANCED_UNLIT_SHADER_NAME,
190
14
  marker: DEFAULT_INSTANCED_UNLIT_SHADER_MARKER,
@@ -225,467 +49,7 @@ void main() {
225
49
  }
226
50
  `
227
51
  });
228
- library.register({
229
- name: DEFAULT_PBR_SHADER_NAME,
230
- marker: DEFAULT_PBR_SHADER_MARKER,
231
- vertex: `#version 300 es
232
- // ${DEFAULT_PBR_SHADER_MARKER}
233
- precision highp float;
234
- layout(location = 0) in vec3 a_position;
235
- layout(location = 1) in vec3 a_normal;
236
- layout(location = 4) in vec4 a_color;
237
- uniform mat4 u_modelViewProjection;
238
- uniform mat4 u_modelMatrix;
239
- uniform mat4 u_normalMatrix;
240
- out vec3 v_normal;
241
- out vec3 v_worldPosition;
242
- out vec4 v_vertexColor;
243
- void main() {
244
- v_normal = mat3(u_normalMatrix) * a_normal;
245
- v_worldPosition = (u_modelMatrix * vec4(a_position, 1.0)).xyz;
246
- v_vertexColor = a_color;
247
- gl_Position = u_modelViewProjection * vec4(a_position, 1.0);
248
- }
249
- `,
250
- fragment: `#version 300 es
251
- // ${DEFAULT_PBR_SHADER_MARKER}
252
- precision highp float;
253
- #include <lighting_common>
254
- #include <pbr_common>
255
- uniform vec4 u_baseColor;
256
- uniform float u_alphaCutoff;
257
- uniform float u_metallic;
258
- uniform float u_roughness;
259
- uniform vec3 u_environmentColor;
260
- uniform float u_environmentIntensity;
261
- uniform vec3 u_environmentSkyColor;
262
- uniform vec3 u_environmentHorizonColor;
263
- uniform vec3 u_environmentGroundColor;
264
- uniform vec3 u_environmentSpecularColor;
265
- uniform float u_environmentMapIntensity;
266
- uniform float u_environmentSpecularIntensity;
267
- uniform sampler2D u_environmentMapTexture;
268
- uniform samplerCube u_environmentCubeMapTexture;
269
- uniform float u_environmentCubeMapTextureEnabled;
270
- uniform float u_environmentMapTextureEnabled;
271
- uniform float u_environmentMapTextureIntensity;
272
- uniform float u_environmentMapTextureSpecularIntensity;
273
- uniform float u_environmentMapTextureRotation;
274
- uniform float u_environmentMapTextureMipCount;
275
- uniform float u_environmentMapTextureEncoding;
276
- uniform sampler2D u_environmentBrdfLutTexture;
277
- uniform float u_environmentBrdfLutEnabled;
278
- uniform vec3 u_emissiveColor;
279
- uniform float u_emissiveStrength;
280
- uniform float u_clearcoatFactor;
281
- uniform float u_clearcoatRoughnessFactor;
282
- uniform float u_transmissionFactor;
283
- uniform float u_diffuseTransmissionFactor;
284
- uniform vec3 u_diffuseTransmissionColorFactor;
285
- uniform float u_transmissionFallbackEnergy;
286
- uniform float u_volumeThicknessFactor;
287
- uniform float u_volumeAttenuationDistance;
288
- uniform vec3 u_volumeAttenuationColor;
289
- uniform float u_transmissionParallaxStrength;
290
- uniform vec3 u_transmissionParallaxBoxMin;
291
- uniform vec3 u_transmissionParallaxBoxMax;
292
- uniform float u_transmissionBounceCount;
293
- uniform float u_transmissionCausticStrength;
294
- uniform float u_ior;
295
- uniform float u_specularFactor;
296
- uniform vec3 u_specularColorFactor;
297
- uniform vec3 u_sheenColorFactor;
298
- uniform float u_sheenRoughnessFactor;
299
- uniform float u_anisotropyStrength;
300
- uniform float u_anisotropyRotation;
301
- uniform float u_iridescenceFactor;
302
- uniform float u_iridescenceIor;
303
- uniform float u_iridescenceThicknessMinimum;
304
- uniform float u_iridescenceThicknessMaximum;
305
- uniform float u_dispersion;
306
- uniform float u_lightCount;
307
- uniform vec4 u_lightData[96];
308
- uniform float u_clusteredLightEnabled;
309
- uniform vec2 u_clusterGridSize;
310
- uniform vec2 u_clusterViewportSize;
311
- uniform sampler2D u_clusterLightData;
312
- uniform sampler2D u_clusterLightIndices;
313
- uniform sampler2D u_shadowMapTexture;
314
- uniform float u_shadowMapEnabled;
315
- uniform mat4 u_shadowMapMatrix;
316
- uniform float u_shadowMapStrength;
317
- uniform float u_shadowMapBias;
318
- uniform float u_shadowMapSlopeBias;
319
- uniform vec2 u_shadowMapTexelSize;
320
- uniform float u_shadowPcfSampleCount;
321
- uniform vec4 u_shadowPcfSamples[32];
322
- uniform sampler2D u_pointShadowMapTexture;
323
- uniform float u_pointShadowMapEnabled;
324
- uniform vec3 u_pointShadowLightPosition;
325
- uniform float u_pointShadowRange;
326
- uniform mat4 u_pointShadowFaceMatrices[6];
327
- uniform vec4 u_pointShadowFaceRects[6];
328
- uniform float u_pointShadowStrength;
329
- uniform float u_pointShadowBias;
330
- uniform float u_pointShadowSlopeBias;
331
- uniform vec2 u_pointShadowTexelSize;
332
- uniform float u_pointShadowPcfSampleCount;
333
- uniform vec4 u_pointShadowPcfSamples[32];
334
- uniform float u_outputColorSpace;
335
- uniform vec3 u_cameraPosition;
336
- uniform float u_environmentFogEnabled;
337
- uniform float u_environmentFogMode;
338
- uniform vec3 u_environmentFogColor;
339
- uniform float u_environmentFogNear;
340
- uniform float u_environmentFogFar;
341
- uniform float u_environmentFogDensity;
342
- uniform float u_environmentFogHeightFalloff;
343
- uniform float u_environmentFogHeightReference;
344
- uniform float u_environmentFogMaxOpacity;
345
- in vec3 v_normal;
346
- in vec3 v_worldPosition;
347
- in vec4 v_vertexColor;
348
- out vec4 outColor;
349
- #include <environment_fog_common>
350
- vec2 a3dEnvironmentEquirectUv(vec3 direction, float rotation) {
351
- vec3 d = normalize(direction);
352
- float u = atan(d.z, d.x) / 6.28318530718 + 0.5 + rotation;
353
- float v = acos(clamp(d.y, -1.0, 1.0)) / 3.14159265359;
354
- return vec2(fract(u), clamp(v, 0.0, 1.0));
355
- }
356
- vec3 a3dEnvironmentCubeDirection(vec3 direction, float rotation) {
357
- float angle = rotation * 6.28318530718;
358
- float c = cos(angle);
359
- float s = sin(angle);
360
- vec3 d = normalize(direction);
361
- return normalize(vec3(c * d.x - s * d.z, d.y, s * d.x + c * d.z));
362
- }
363
- vec3 a3dPbrDecodeEnvironmentSrgb(vec3 encodedColor) {
364
- return max(encodedColor, vec3(0.0));
365
- }
366
- vec3 a3dPbrDecodeEnvironmentRgbe(vec4 encodedSample) {
367
- float exponent = encodedSample.a * 255.0;
368
- float scale = exponent <= 0.0 ? 0.0 : exp2(exponent - 128.0) * (255.0 / 256.0);
369
- return max(encodedSample.rgb * scale, vec3(0.0));
370
- }
371
- vec3 a3dPbrDecodeEnvironmentSample(vec4 encodedSample) {
372
- if (u_environmentMapTextureEncoding > 1.5) return max(encodedSample.rgb, vec3(0.0));
373
- if (u_environmentMapTextureEncoding > 0.5) return a3dPbrDecodeEnvironmentRgbe(encodedSample);
374
- return a3dPbrDecodeEnvironmentSrgb(encodedSample.rgb);
375
- }
376
- vec3 a3dPbrBoundHdrTransmissionRadiance(vec3 radiance) {
377
- vec3 nonNegative = max(radiance, vec3(0.0));
378
- return nonNegative / (vec3(1.0) + max(nonNegative - vec3(1.0), vec3(0.0)));
379
- }
380
- vec3 a3dPbrBoundHdrSpecularRadiance(vec3 radiance) {
381
- vec3 nonNegative = max(radiance, vec3(0.0));
382
- vec3 softKnee = nonNegative / (vec3(1.0) + max(nonNegative - vec3(1.0), vec3(0.0)) * 0.58);
383
- float maxChannel = max(max(softKnee.r, softKnee.g), softKnee.b);
384
- return maxChannel > 1.65 ? softKnee * (1.65 / maxChannel) : softKnee;
385
- }
386
- vec3 a3dPbrClampSampledSpecularEdgeEnergy(vec3 radiance, float nDotV, float roughness) {
387
- float faceOn = smoothstep(0.12, 0.55, clamp(nDotV, 0.0, 1.0));
388
- float roughEnergy = mix(0.6, 1.0, clamp(roughness, 0.0, 1.0));
389
- float edgeCap = mix(0.12, 1.2, faceOn) * roughEnergy;
390
- float edgeScale = mix(0.14, 0.92, faceOn);
391
- vec3 bounded = min(radiance * edgeScale, vec3(edgeCap));
392
- return max(bounded, vec3(0.0));
393
- }
394
- vec4 a3dPbrEnvironmentSampleRaw(vec3 direction, float lod) {
395
- vec4 equirectSample = textureLod(u_environmentMapTexture, a3dEnvironmentEquirectUv(direction, u_environmentMapTextureRotation), lod);
396
- vec4 cubeSample = textureLod(u_environmentCubeMapTexture, a3dEnvironmentCubeDirection(direction, u_environmentMapTextureRotation), lod);
397
- return mix(equirectSample, cubeSample, step(0.5, u_environmentCubeMapTextureEnabled));
398
- }
399
- vec3 a3dPbrBoxProjectedDirection(vec3 worldPosition, vec3 direction, vec3 boxMin, vec3 boxMax) {
400
- vec3 safeDirection = normalize(direction);
401
- vec3 invDirection = 1.0 / max(abs(safeDirection), vec3(0.0001)) * sign(safeDirection);
402
- vec3 firstPlane = mix(boxMin, boxMax, step(vec3(0.0), safeDirection));
403
- vec3 distances = (firstPlane - worldPosition) * invDirection;
404
- float travel = min(min(
405
- distances.x > 0.0 ? distances.x : 100000.0,
406
- distances.y > 0.0 ? distances.y : 100000.0
407
- ), distances.z > 0.0 ? distances.z : 100000.0);
408
- vec3 hitPosition = worldPosition + safeDirection * travel;
409
- vec3 boxCenter = (boxMin + boxMax) * 0.5;
410
- return normalize(hitPosition - boxCenter);
411
- }
412
- float a3dForwardShadowFactor(vec3 worldPosition, vec3 normal, vec3 lightDirection) {
413
- if (u_shadowMapEnabled < 0.5) return 1.0;
414
- vec4 lightPosition = u_shadowMapMatrix * vec4(worldPosition, 1.0);
415
- vec3 projected = lightPosition.xyz / max(lightPosition.w, 0.0001);
416
- vec2 uv = projected.xy * 0.5 + 0.5;
417
- if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) return 1.0;
418
- vec3 receiverNormal = normalize(normal);
419
- vec3 receiverLightDirection = lightDirection / max(length(lightDirection), 0.0001);
420
- float normalDotLight = clamp(abs(dot(receiverNormal, receiverLightDirection)), 0.0, 1.0);
421
- // Slope-scaled depth bias must be evaluated per PCF sample, not once for the kernel
422
- // centre. A sample offset N texels away on a receiver sloped relative to the light sees a
423
- // depth difference proportional to N, so a centre-only bias under-compensates every outer
424
- // tap and the receiver shadows itself. Scaling by each sample's own texel distance keeps
425
- // wide kernels acne-free without inflating the constant bias into peter-panning.
426
- // The depth gradient across one shadow texel is tan(angle between receiver normal and
427
- // light), not (1 - N.L). The linear form collapses toward zero far faster than the real
428
- // gradient grows, so it under-biases exactly the grazing angles that need the most
429
- // compensation. Clamped so a near-perpendicular receiver cannot demand unbounded bias.
430
- float slopeTangent = min(sqrt(max(1.0 - normalDotLight * normalDotLight, 0.0)) / max(normalDotLight, 0.05), 8.0);
431
- float slopeTexelBias = slopeTangent * u_shadowMapSlopeBias * max(u_shadowMapTexelSize.x, u_shadowMapTexelSize.y);
432
- float projectedDepth = projected.z * 0.5 + 0.5;
433
- float shadowed = 0.0;
434
- float totalWeight = 0.0;
435
- int sampleCount = clamp(int(u_shadowPcfSampleCount), 1, 32);
436
- for (int i = 0; i < 32; ++i) {
437
- if (i >= sampleCount) break;
438
- vec4 sampleData = u_shadowPcfSamples[i];
439
- float weight = max(sampleData.z, 0.0);
440
- vec2 offset = sampleData.xy * u_shadowMapTexelSize;
441
- float storedDepth = texture(u_shadowMapTexture, uv + offset).r;
442
- float sampleTexelDistance = max(1.0, length(sampleData.xy));
443
- float receiverDepth = projectedDepth - u_shadowMapBias - slopeTexelBias * sampleTexelDistance;
444
- shadowed += (receiverDepth > storedDepth ? 1.0 : 0.0) * weight;
445
- totalWeight += weight;
446
- }
447
- float occlusion = totalWeight > 0.0 ? shadowed / totalWeight : 0.0;
448
- return mix(1.0, 1.0 - occlusion, clamp(u_shadowMapStrength, 0.0, 1.0));
449
- }
450
- float a3dPointShadowFaceIndex(vec3 direction) {
451
- vec3 absoluteDirection = abs(direction);
452
- if (absoluteDirection.x >= absoluteDirection.y && absoluteDirection.x >= absoluteDirection.z) return direction.x >= 0.0 ? 0.0 : 1.0;
453
- if (absoluteDirection.y >= absoluteDirection.x && absoluteDirection.y >= absoluteDirection.z) return direction.y >= 0.0 ? 2.0 : 3.0;
454
- return direction.z >= 0.0 ? 4.0 : 5.0;
455
- }
456
- float a3dPointShadowFactor(vec3 worldPosition, vec3 normal, vec3 lightDirection) {
457
- if (u_pointShadowMapEnabled < 0.5) return 1.0;
458
- vec3 lightToFragment = worldPosition - u_pointShadowLightPosition;
459
- float distanceToLight = length(lightToFragment);
460
- if (distanceToLight > u_pointShadowRange) return 1.0;
461
- int faceIndex = int(a3dPointShadowFaceIndex(lightToFragment));
462
- vec4 lightPosition = u_pointShadowFaceMatrices[faceIndex] * vec4(worldPosition, 1.0);
463
- vec3 projected = lightPosition.xyz / max(lightPosition.w, 0.0001);
464
- vec2 localUv = projected.xy * 0.5 + 0.5;
465
- if (localUv.x < 0.0 || localUv.x > 1.0 || localUv.y < 0.0 || localUv.y > 1.0) return 1.0;
466
- vec4 rect = u_pointShadowFaceRects[faceIndex];
467
- vec2 uv = rect.xy + localUv * rect.zw;
468
- vec3 receiverNormal = normalize(normal);
469
- vec3 receiverLightDirection = lightDirection / max(length(lightDirection), 0.0001);
470
- float normalDotLight = clamp(abs(dot(receiverNormal, receiverLightDirection)), 0.0, 1.0);
471
- // Slope-scaled depth bias must be evaluated per PCF sample, not once for the kernel
472
- // centre. A sample offset N texels away on a receiver sloped relative to the light sees a
473
- // depth difference proportional to N, so a centre-only bias under-compensates every outer
474
- // tap and the receiver shadows itself. Scaling by each sample's own texel distance keeps
475
- // wide kernels acne-free without inflating the constant bias into peter-panning.
476
- // The depth gradient across one shadow texel is tan(angle between receiver normal and
477
- // light), not (1 - N.L). The linear form collapses toward zero far faster than the real
478
- // gradient grows, so it under-biases exactly the grazing angles that need the most
479
- // compensation. Clamped so a near-perpendicular receiver cannot demand unbounded bias.
480
- float slopeTangent = min(sqrt(max(1.0 - normalDotLight * normalDotLight, 0.0)) / max(normalDotLight, 0.05), 8.0);
481
- float slopeTexelBias = slopeTangent * u_pointShadowSlopeBias * max(u_pointShadowTexelSize.x, u_pointShadowTexelSize.y);
482
- float projectedDepth = projected.z * 0.5 + 0.5;
483
- float shadowed = 0.0;
484
- float totalWeight = 0.0;
485
- int sampleCount = clamp(int(u_pointShadowPcfSampleCount), 1, 32);
486
- for (int i = 0; i < 32; ++i) {
487
- if (i >= sampleCount) break;
488
- vec4 sampleData = u_pointShadowPcfSamples[i];
489
- float weight = max(sampleData.z, 0.0);
490
- vec2 offset = sampleData.xy * u_pointShadowTexelSize;
491
- float storedDepth = texture(u_pointShadowMapTexture, uv + offset).r;
492
- float sampleTexelDistance = max(1.0, length(sampleData.xy));
493
- float receiverDepth = projectedDepth - u_pointShadowBias - slopeTexelBias * sampleTexelDistance;
494
- shadowed += (receiverDepth > storedDepth ? 1.0 : 0.0) * weight;
495
- totalWeight += weight;
496
- }
497
- float occlusion = totalWeight > 0.0 ? shadowed / totalWeight : 0.0;
498
- return mix(1.0, 1.0 - occlusion, clamp(u_pointShadowStrength, 0.0, 1.0));
499
- }
500
- vec3 a3dPbrEncodeOutput(vec3 linearColor) {
501
- vec3 color = max(linearColor, vec3(0.0));
502
- vec3 filmic = clamp((color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14), vec3(0.0), vec3(1.0));
503
- vec3 srgb = pow(filmic, vec3(1.0 / 2.2));
504
- return mix(color, srgb, step(0.5, u_outputColorSpace));
505
- }
506
- void main() {
507
- vec3 normal = normalize(v_normal);
508
- if (!gl_FrontFacing) normal = -normal;
509
- vec3 viewDirection = normalize(u_cameraPosition - v_worldPosition);
510
- vec3 materialBase = a3dApplyAdvancedPbrLobes(
511
- u_baseColor.rgb * v_vertexColor.rgb,
512
- u_clearcoatFactor,
513
- u_clearcoatRoughnessFactor,
514
- u_transmissionFactor,
515
- u_diffuseTransmissionFactor,
516
- u_diffuseTransmissionColorFactor,
517
- u_transmissionFallbackEnergy,
518
- u_volumeThicknessFactor,
519
- u_volumeAttenuationDistance,
520
- u_volumeAttenuationColor,
521
- u_ior,
522
- u_specularFactor,
523
- u_specularColorFactor,
524
- u_sheenColorFactor,
525
- u_sheenRoughnessFactor,
526
- u_anisotropyStrength,
527
- u_anisotropyRotation,
528
- u_iridescenceFactor,
529
- u_iridescenceIor,
530
- u_iridescenceThicknessMinimum,
531
- u_iridescenceThicknessMaximum,
532
- u_dispersion
533
- );
534
- float environmentHemi = mix(0.35, 1.0, clamp(normal.y * 0.5 + 0.5, 0.0, 1.0));
535
- vec3 ambientEnvironment = u_environmentColor * u_environmentIntensity * environmentHemi;
536
- float proceduralEnvironmentWeight = step(0.0001, u_environmentMapIntensity);
537
- float skyBlend = clamp(normal.y * 0.5 + 0.5, 0.0, 1.0);
538
- float horizonBlend = 1.0 - abs(normal.y);
539
- vec3 proceduralDiffuse = mix(u_environmentGroundColor, u_environmentSkyColor, skyBlend);
540
- proceduralDiffuse = mix(proceduralDiffuse, u_environmentHorizonColor, clamp(horizonBlend, 0.0, 1.0) * 0.55);
541
- // The ambient term must be added to the procedural contribution, not replaced by it. A mix
542
- // here discarded u_environmentColor * u_environmentIntensity entirely whenever a procedural
543
- // map was present, which is the normal case: raising ambient intensity from 0.18 to 3.0 on
544
- // the product-turntable kit produced a byte-identical frame. Ambient and a sky gradient are
545
- // separate physical contributions, so they sum.
546
- vec3 environmentDiffuse = ambientEnvironment + proceduralDiffuse * u_environmentMapIntensity * proceduralEnvironmentWeight;
547
- float sampledEnvironmentWeight = step(0.0001, u_environmentMapTextureEnabled * u_environmentMapTextureIntensity);
548
- float diffuseEnvironmentLod = max(u_environmentMapTextureMipCount - 1.0, 0.0);
549
- vec3 sampledDiffuse = a3dPbrDecodeEnvironmentSample(a3dPbrEnvironmentSampleRaw(normal, diffuseEnvironmentLod));
550
- environmentDiffuse = mix(environmentDiffuse, ambientEnvironment + sampledDiffuse * u_environmentMapTextureIntensity, sampledEnvironmentWeight);
551
- vec3 reflectionDirection = reflect(-viewDirection, normal);
552
- float roughness = clamp(u_roughness, 0.0, 1.0);
553
- float reflectionBand = pow(clamp(reflectionDirection.y * 0.5 + 0.5, 0.0, 1.0), mix(18.0, 2.0, roughness));
554
- float roughEnvironmentFloor = mix(0.04, 0.38, roughness);
555
- float proceduralSpecularResponse = max(reflectionBand, roughEnvironmentFloor);
556
- vec3 proceduralSpecular = u_environmentSpecularColor * u_environmentSpecularIntensity * proceduralSpecularResponse * proceduralEnvironmentWeight;
557
- float environmentLod = roughness * max(u_environmentMapTextureMipCount - 1.0, 0.0);
558
- vec3 sampledSpecular = a3dPbrBoundHdrSpecularRadiance(a3dPbrDecodeEnvironmentSample(a3dPbrEnvironmentSampleRaw(reflectionDirection, environmentLod)));
559
- float nDotV = clamp(dot(normal, viewDirection), 0.0, 1.0);
560
- vec2 brdfLut = texture(u_environmentBrdfLutTexture, vec2(nDotV, roughness)).rg;
561
- sampledSpecular = a3dPbrClampSampledSpecularEdgeEnergy(sampledSpecular, nDotV, roughness);
562
- sampledSpecular *= u_environmentMapTextureSpecularIntensity * sampledEnvironmentWeight * mix(1.1, 0.85, roughness);
563
- vec3 shaded = a3dPbrEnvironmentLightSplitSum(
564
- normal,
565
- viewDirection,
566
- environmentDiffuse,
567
- proceduralSpecular + sampledSpecular,
568
- mix(vec2(1.0, 0.0), brdfLut, step(0.0001, u_environmentBrdfLutEnabled)),
569
- materialBase,
570
- u_metallic,
571
- u_roughness,
572
- u_specularFactor,
573
- u_specularColorFactor
574
- ) + u_emissiveColor * u_emissiveStrength;
575
- shaded += a3dPbrExtensionEnvironmentLight(
576
- normal,
577
- viewDirection,
578
- proceduralSpecular + sampledSpecular,
579
- u_clearcoatFactor,
580
- u_clearcoatRoughnessFactor,
581
- u_sheenColorFactor,
582
- u_sheenRoughnessFactor,
583
- u_anisotropyStrength,
584
- u_anisotropyRotation,
585
- u_iridescenceFactor,
586
- u_iridescenceIor,
587
- u_iridescenceThicknessMinimum,
588
- u_iridescenceThicknessMaximum
589
- );
590
- float transmissionAmount = clamp(max(u_transmissionFactor, u_diffuseTransmissionFactor), 0.0, 1.0);
591
- if (transmissionAmount > 0.0001 && sampledEnvironmentWeight > 0.0001) {
592
- vec3 refractionDirection = refract(-viewDirection, normal, 1.0 / max(u_ior, 1.0));
593
- refractionDirection = length(refractionDirection) > 0.0001 ? normalize(refractionDirection) : -reflectionDirection;
594
- float parallaxStrength = clamp(u_transmissionParallaxStrength, 0.0, 1.0);
595
- if (parallaxStrength > 0.0001) {
596
- vec3 parallaxDirection = a3dPbrBoxProjectedDirection(v_worldPosition, refractionDirection, u_transmissionParallaxBoxMin, u_transmissionParallaxBoxMax);
597
- refractionDirection = normalize(mix(refractionDirection, parallaxDirection, parallaxStrength));
598
- }
599
- float bounceCount = clamp(u_transmissionBounceCount, 0.0, 4.0);
600
- float refractionLod = clamp(roughness + u_volumeThicknessFactor * 0.12 + bounceCount * 0.04 * parallaxStrength, 0.0, 1.0) * max(u_environmentMapTextureMipCount - 1.0, 0.0);
601
- vec3 refractedEnvironment = a3dPbrBoundHdrTransmissionRadiance(a3dPbrDecodeEnvironmentSample(a3dPbrEnvironmentSampleRaw(refractionDirection, refractionLod)));
602
- float volumeTravel = clamp((max(u_volumeThicknessFactor, 0.0) * (1.0 + bounceCount * 0.18 * parallaxStrength)) / max(u_volumeAttenuationDistance, 0.0001), 0.0, 16.0);
603
- vec3 volumeTint = pow(clamp(u_volumeAttenuationColor, vec3(0.0001), vec3(1.0)), vec3(volumeTravel));
604
- float causticEnergy = u_transmissionCausticStrength * parallaxStrength * transmissionAmount * pow(1.0 - roughness, 2.0) / (1.0 + bounceCount * 0.35);
605
- float roughVolumeIorLift = mix(1.0, 1.45, clamp((u_ior - 1.0) / 1.5, 0.0, 1.0) * smoothstep(0.35, 0.95, roughness + u_volumeThicknessFactor * 0.2));
606
- float fallbackEnvironmentTransmissionEnergy = mix(1.0, clamp(u_transmissionFallbackEnergy, 0.0, 1.0), transmissionAmount);
607
- vec3 refractionRadiance = (refractedEnvironment + vec3(causticEnergy)) * volumeTint * u_environmentMapTextureIntensity * transmissionAmount * fallbackEnvironmentTransmissionEnergy * mix(0.9, 0.55, roughness) * roughVolumeIorLift;
608
- shaded = mix(shaded, shaded * 0.72 + refractionRadiance, transmissionAmount * mix(0.08, 0.58, fallbackEnvironmentTransmissionEnergy));
609
- }
610
- ivec2 clusterTile = clamp(ivec2(floor(gl_FragCoord.xy / max(u_clusterViewportSize / u_clusterGridSize, vec2(1.0)))), ivec2(0), ivec2(u_clusterGridSize) - ivec2(1));
611
- int clusterIndex = clusterTile.y * int(u_clusterGridSize.x) + clusterTile.x;
612
- int count = u_clusteredLightEnabled > 0.5 ? min(int(texelFetch(u_clusterLightIndices, ivec2(0, clusterIndex), 0).g), 64) : min(int(u_lightCount), 16);
613
- for (int i = 0; i < 64; ++i) {
614
- if (i >= count) break;
615
- int lightIndex = u_clusteredLightEnabled > 0.5 ? int(texelFetch(u_clusterLightIndices, ivec2(i, clusterIndex), 0).r) : i;
616
- int baseIndex = lightIndex * 6;
617
- vec4 colorIntensity = u_clusteredLightEnabled > 0.5 ? texelFetch(u_clusterLightData, ivec2(0, lightIndex), 0) : u_lightData[baseIndex];
618
- vec4 positionRange = u_clusteredLightEnabled > 0.5 ? texelFetch(u_clusterLightData, ivec2(1, lightIndex), 0) : u_lightData[baseIndex + 1];
619
- vec4 directionKind = u_clusteredLightEnabled > 0.5 ? texelFetch(u_clusterLightData, ivec2(2, lightIndex), 0) : u_lightData[baseIndex + 2];
620
- vec4 spotShadowLayer = u_clusteredLightEnabled > 0.5 ? texelFetch(u_clusterLightData, ivec2(3, lightIndex), 0) : u_lightData[baseIndex + 3];
621
- vec4 areaRight = u_clusteredLightEnabled > 0.5 ? texelFetch(u_clusterLightData, ivec2(4, lightIndex), 0) : u_lightData[baseIndex + 4];
622
- vec4 areaUp = u_clusteredLightEnabled > 0.5 ? texelFetch(u_clusterLightData, ivec2(5, lightIndex), 0) : u_lightData[baseIndex + 5];
623
- float kind = directionKind.w;
624
- if (kind > 2.5) {
625
- shaded += a3dPbrRectAreaLight(
626
- v_worldPosition, positionRange.xyz, directionKind.xyz, areaRight.xyz, areaUp.xyz,
627
- spotShadowLayer.x, spotShadowLayer.y, positionRange.w,
628
- normal, viewDirection, colorIntensity.rgb, colorIntensity.a,
629
- materialBase, u_metallic, u_roughness, u_specularFactor, u_specularColorFactor
630
- );
631
- continue;
632
- }
633
- vec3 lightDirection = -directionKind.xyz;
634
- float attenuation = 1.0;
635
- if (kind > 0.5) {
636
- vec3 toLight = positionRange.xyz - v_worldPosition;
637
- float distanceToLight = length(toLight);
638
- lightDirection = distanceToLight > 0.0001 ? toLight / distanceToLight : -directionKind.xyz;
639
- float range = max(positionRange.w, 0.0001);
640
- float rangeFalloff = clamp(1.0 - pow(distanceToLight / range, 4.0), 0.0, 1.0);
641
- rangeFalloff *= rangeFalloff;
642
- attenuation = rangeFalloff / max(distanceToLight * distanceToLight, 1.0);
643
- }
644
- if (kind > 1.5) {
645
- vec3 lightToFragment = normalize(v_worldPosition - positionRange.xyz);
646
- float cone = dot(normalize(directionKind.xyz), lightToFragment);
647
- float outer = cos(spotShadowLayer.x);
648
- float inner = cos(spotShadowLayer.x * max(1.0 - spotShadowLayer.y, 0.001));
649
- attenuation *= smoothstep(outer, inner, cone);
650
- }
651
- float directLightIntensity = colorIntensity.a * attenuation * mix(1.0, kind > 0.5 && kind < 1.5 ? a3dPointShadowFactor(v_worldPosition, normal, lightDirection) : a3dForwardShadowFactor(v_worldPosition, normal, lightDirection), step(0.5, spotShadowLayer.z));
652
- shaded += a3dPbrDirectLight(
653
- normal,
654
- viewDirection,
655
- lightDirection,
656
- colorIntensity.rgb,
657
- directLightIntensity,
658
- materialBase,
659
- u_metallic,
660
- u_roughness,
661
- u_specularFactor,
662
- u_specularColorFactor
663
- );
664
- shaded += a3dPbrExtensionDirectLight(
665
- normal,
666
- viewDirection,
667
- lightDirection,
668
- colorIntensity.rgb,
669
- directLightIntensity,
670
- u_clearcoatFactor,
671
- u_clearcoatRoughnessFactor,
672
- u_sheenColorFactor,
673
- u_sheenRoughnessFactor,
674
- u_anisotropyStrength,
675
- u_anisotropyRotation,
676
- u_iridescenceFactor,
677
- u_iridescenceIor,
678
- u_iridescenceThicknessMinimum,
679
- u_iridescenceThicknessMaximum
680
- );
681
- }
682
- float alpha = u_baseColor.a * v_vertexColor.a;
683
- if (alpha < u_alphaCutoff) discard;
684
- vec3 fogged = a3dApplyEnvironmentFog(max(shaded, vec3(0.0)), v_worldPosition);
685
- outColor = vec4(a3dPbrEncodeOutput(fogged), alpha);
686
- }
687
- `
688
- });
52
+ registerLeanPbrShader(library);
689
53
  library.register({
690
54
  name: DEFAULT_INSTANCED_PBR_SHADER_NAME,
691
55
  marker: DEFAULT_INSTANCED_PBR_SHADER_MARKER,
@@ -891,18 +255,10 @@ vec3 a3dPbrDecodeEnvironmentSample(vec4 encodedSample) {
891
255
  return a3dPbrDecodeEnvironmentSrgb(encodedSample.rgb);
892
256
  }
893
257
  vec3 a3dPbrBoundHdrSpecularRadiance(vec3 radiance) {
894
- vec3 nonNegative = max(radiance, vec3(0.0));
895
- vec3 softKnee = nonNegative / (vec3(1.0) + max(nonNegative - vec3(1.0), vec3(0.0)) * 0.58);
896
- float maxChannel = max(max(softKnee.r, softKnee.g), softKnee.b);
897
- return maxChannel > 1.65 ? softKnee * (1.65 / maxChannel) : softKnee;
258
+ return clamp(radiance, vec3(0.0), vec3(65504.0));
898
259
  }
899
260
  vec3 a3dPbrClampSampledSpecularEdgeEnergy(vec3 radiance, float nDotV, float roughness) {
900
- float faceOn = smoothstep(0.12, 0.55, clamp(nDotV, 0.0, 1.0));
901
- float roughEnergy = mix(0.6, 1.0, clamp(roughness, 0.0, 1.0));
902
- float edgeCap = mix(0.12, 1.2, faceOn) * roughEnergy;
903
- float edgeScale = mix(0.14, 0.92, faceOn);
904
- vec3 bounded = min(radiance * edgeScale, vec3(edgeCap));
905
- return max(bounded, vec3(0.0));
261
+ return max(radiance, vec3(0.0));
906
262
  }
907
263
  vec4 a3dPbrEnvironmentSampleRaw(vec3 direction, float lod) {
908
264
  vec4 equirectSample = textureLod(u_environmentMapTexture, a3dEnvironmentEquirectUv(direction, u_environmentMapTextureRotation), lod);
@@ -1283,18 +639,10 @@ vec3 a3dPbrDecodeEnvironmentSample(vec4 encodedSample) {
1283
639
  return a3dPbrDecodeEnvironmentSrgb(encodedSample.rgb);
1284
640
  }
1285
641
  vec3 a3dPbrBoundHdrSpecularRadiance(vec3 radiance) {
1286
- vec3 nonNegative = max(radiance, vec3(0.0));
1287
- vec3 softKnee = nonNegative / (vec3(1.0) + max(nonNegative - vec3(1.0), vec3(0.0)) * 0.58);
1288
- float maxChannel = max(max(softKnee.r, softKnee.g), softKnee.b);
1289
- return maxChannel > 1.65 ? softKnee * (1.65 / maxChannel) : softKnee;
642
+ return clamp(radiance, vec3(0.0), vec3(65504.0));
1290
643
  }
1291
644
  vec3 a3dPbrClampSampledSpecularEdgeEnergy(vec3 radiance, float nDotV, float roughness) {
1292
- float faceOn = smoothstep(0.12, 0.55, clamp(nDotV, 0.0, 1.0));
1293
- float roughEnergy = mix(0.6, 1.0, clamp(roughness, 0.0, 1.0));
1294
- float edgeCap = mix(0.12, 1.2, faceOn) * roughEnergy;
1295
- float edgeScale = mix(0.14, 0.92, faceOn);
1296
- vec3 bounded = min(radiance * edgeScale, vec3(edgeCap));
1297
- return max(bounded, vec3(0.0));
645
+ return max(radiance, vec3(0.0));
1298
646
  }
1299
647
  vec4 a3dPbrEnvironmentSampleRaw(vec3 direction, float lod) {
1300
648
  vec4 equirectSample = textureLod(u_environmentMapTexture, a3dEnvironmentEquirectUv(direction, u_environmentMapTextureRotation), lod);
@@ -1474,7 +822,7 @@ void main() {
1474
822
  float nDotV = clamp(dot(normal, viewDirection), 0.0, 1.0);
1475
823
  vec2 brdfLut = texture(u_environmentBrdfLutTexture, vec2(nDotV, clampedRoughness)).rg;
1476
824
  sampledSpecular = a3dPbrClampSampledSpecularEdgeEnergy(sampledSpecular, nDotV, clampedRoughness);
1477
- sampledSpecular *= u_environmentMapTextureSpecularIntensity * sampledEnvironmentWeight * mix(1.1, 0.85, roughness);
825
+ sampledSpecular *= u_environmentMapTextureSpecularIntensity * sampledEnvironmentWeight * mix(1.1, 0.65, roughness);
1478
826
  vec3 shaded = a3dPbrEnvironmentLightSplitSum(
1479
827
  normal,
1480
828
  viewDirection,
@@ -1770,18 +1118,10 @@ vec3 a3dPbrDecodeEnvironmentSample(vec4 encodedSample) {
1770
1118
  return a3dPbrDecodeEnvironmentSrgb(encodedSample.rgb);
1771
1119
  }
1772
1120
  vec3 a3dPbrBoundHdrSpecularRadiance(vec3 radiance) {
1773
- vec3 nonNegative = max(radiance, vec3(0.0));
1774
- vec3 softKnee = nonNegative / (vec3(1.0) + max(nonNegative - vec3(1.0), vec3(0.0)) * 0.58);
1775
- float maxChannel = max(max(softKnee.r, softKnee.g), softKnee.b);
1776
- return maxChannel > 1.65 ? softKnee * (1.65 / maxChannel) : softKnee;
1121
+ return clamp(radiance, vec3(0.0), vec3(65504.0));
1777
1122
  }
1778
1123
  vec3 a3dPbrClampSampledSpecularEdgeEnergy(vec3 radiance, float nDotV, float roughness) {
1779
- float faceOn = smoothstep(0.12, 0.55, clamp(nDotV, 0.0, 1.0));
1780
- float roughEnergy = mix(0.6, 1.0, clamp(roughness, 0.0, 1.0));
1781
- float edgeCap = mix(0.12, 1.2, faceOn) * roughEnergy;
1782
- float edgeScale = mix(0.14, 0.92, faceOn);
1783
- vec3 bounded = min(radiance * edgeScale, vec3(edgeCap));
1784
- return max(bounded, vec3(0.0));
1124
+ return max(radiance, vec3(0.0));
1785
1125
  }
1786
1126
  vec4 a3dPbrEnvironmentSampleRaw(vec3 direction, float lod) {
1787
1127
  vec4 equirectSample = textureLod(u_environmentMapTexture, a3dEnvironmentEquirectUv(direction, u_environmentMapTextureRotation), lod);
@@ -1961,7 +1301,7 @@ void main() {
1961
1301
  float nDotV = clamp(dot(normal, viewDirection), 0.0, 1.0);
1962
1302
  vec2 brdfLut = texture(u_environmentBrdfLutTexture, vec2(nDotV, clampedRoughness)).rg;
1963
1303
  sampledSpecular = a3dPbrClampSampledSpecularEdgeEnergy(sampledSpecular, nDotV, clampedRoughness);
1964
- sampledSpecular *= u_environmentMapTextureSpecularIntensity * sampledEnvironmentWeight * mix(1.1, 0.85, roughness);
1304
+ sampledSpecular *= u_environmentMapTextureSpecularIntensity * sampledEnvironmentWeight * mix(1.1, 0.65, roughness);
1965
1305
  vec3 shaded = a3dPbrEnvironmentLightSplitSum(
1966
1306
  normal,
1967
1307
  viewDirection,
@@ -2322,18 +1662,10 @@ vec3 a3dPbrDecodeEnvironmentSample(vec4 encodedSample) {
2322
1662
  return a3dPbrDecodeEnvironmentSrgb(encodedSample.rgb);
2323
1663
  }
2324
1664
  vec3 a3dPbrBoundHdrSpecularRadiance(vec3 radiance) {
2325
- vec3 nonNegative = max(radiance, vec3(0.0));
2326
- vec3 softKnee = nonNegative / (vec3(1.0) + max(nonNegative - vec3(1.0), vec3(0.0)) * 0.58);
2327
- float maxChannel = max(max(softKnee.r, softKnee.g), softKnee.b);
2328
- return maxChannel > 1.65 ? softKnee * (1.65 / maxChannel) : softKnee;
1665
+ return clamp(radiance, vec3(0.0), vec3(65504.0));
2329
1666
  }
2330
1667
  vec3 a3dPbrClampSampledSpecularEdgeEnergy(vec3 radiance, float nDotV, float roughness) {
2331
- float faceOn = smoothstep(0.12, 0.55, clamp(nDotV, 0.0, 1.0));
2332
- float roughEnergy = mix(0.6, 1.0, clamp(roughness, 0.0, 1.0));
2333
- float edgeCap = mix(0.12, 1.2, faceOn) * roughEnergy;
2334
- float edgeScale = mix(0.14, 0.92, faceOn);
2335
- vec3 bounded = min(radiance * edgeScale, vec3(edgeCap));
2336
- return max(bounded, vec3(0.0));
1668
+ return max(radiance, vec3(0.0));
2337
1669
  }
2338
1670
  vec4 a3dPbrEnvironmentSampleRaw(vec3 direction, float lod) {
2339
1671
  vec4 equirectSample = textureLod(u_environmentMapTexture, a3dEnvironmentEquirectUv(direction, u_environmentMapTextureRotation), lod);
@@ -2802,18 +2134,10 @@ vec3 a3dTexturedPbrBoundHdrTransmissionRadiance(vec3 radiance) {
2802
2134
  return nonNegative / (vec3(1.0) + max(nonNegative - vec3(1.0), vec3(0.0)));
2803
2135
  }
2804
2136
  vec3 a3dTexturedPbrBoundHdrSpecularRadiance(vec3 radiance) {
2805
- vec3 nonNegative = max(radiance, vec3(0.0));
2806
- vec3 softKnee = nonNegative / (vec3(1.0) + max(nonNegative - vec3(1.0), vec3(0.0)) * 0.62);
2807
- float maxChannel = max(max(softKnee.r, softKnee.g), softKnee.b);
2808
- return maxChannel > 1.35 ? softKnee * (1.35 / maxChannel) : softKnee;
2137
+ return clamp(radiance, vec3(0.0), vec3(65504.0));
2809
2138
  }
2810
2139
  vec3 a3dTexturedPbrClampSampledSpecularEdgeEnergy(vec3 radiance, float nDotV, float roughness) {
2811
- float faceOn = smoothstep(0.2, 0.72, clamp(nDotV, 0.0, 1.0));
2812
- float roughEnergy = mix(0.35, 0.88, clamp(roughness, 0.0, 1.0));
2813
- float edgeCap = mix(0.035, 0.86, faceOn) * roughEnergy;
2814
- float edgeScale = mix(0.045, 0.78, faceOn);
2815
- vec3 bounded = min(radiance * edgeScale, vec3(edgeCap));
2816
- return max(bounded, vec3(0.0));
2140
+ return max(radiance, vec3(0.0));
2817
2141
  }
2818
2142
  vec3 a3dTexturedPbrApplyNormalSample(vec3 baseNormal, vec4 tangentFrame, vec3 sampled, float scale) {
2819
2143
  vec3 n = normalize(baseNormal);
@@ -2953,9 +2277,13 @@ vec3 a3dTexturedPbrEnvironmentSpecularInput(vec3 normal, vec3 viewDirection, flo
2953
2277
  vec3 reflectionDirection = reflect(-viewDirection, normal);
2954
2278
  float clampedRoughness = clamp(roughness, 0.0, 1.0);
2955
2279
  float nDotV = clamp(dot(normal, viewDirection), 0.0, 1.0);
2956
- float faceOnSpecularGate = smoothstep(0.1, 0.42, nDotV);
2957
2280
  float reflectionBand = pow(clamp(reflectionDirection.y * 0.5 + 0.5, 0.0, 1.0), mix(18.0, 2.0, clampedRoughness));
2958
- float roughEnvironmentFloor = mix(0.04, 0.38, clampedRoughness);
2281
+ // Keep the procedural environment from becoming a uniform white veil on
2282
+ // saturated textured base colors. A high roughness floor spread neutral
2283
+ // specular over every fragment, while image-based lighting and Three.js keep
2284
+ // the strongest neutral energy in reflection bands and glancing highlights.
2285
+ // The lower floor preserves ambient readability without erasing texture chroma.
2286
+ float roughEnvironmentFloor = mix(0.012, 0.16, clampedRoughness);
2959
2287
  float proceduralSpecularResponse = max(reflectionBand, roughEnvironmentFloor);
2960
2288
  float horizonStripe = pow(clamp(1.0 - abs(reflectionDirection.y), 0.0, 1.0), mix(14.0, 3.0, clampedRoughness));
2961
2289
  float sideStripe = pow(clamp(abs(reflectionDirection.x), 0.0, 1.0), mix(10.0, 3.0, clampedRoughness)) * smoothstep(0.0, 0.72, 1.0 - abs(reflectionDirection.y));
@@ -2969,19 +2297,55 @@ vec3 a3dTexturedPbrEnvironmentSpecularInput(vec3 normal, vec3 viewDirection, flo
2969
2297
  float environmentLod = clampedRoughness * max(u_environmentMapTextureMipCount - 1.0, 0.0);
2970
2298
  vec3 sampledSpecular = a3dTexturedPbrBoundHdrSpecularRadiance(a3dTexturedPbrDecodeEnvironmentSample(a3dTexturedPbrEnvironmentSampleRaw(reflectionDirection, environmentLod)));
2971
2299
  sampledSpecular = a3dTexturedPbrClampSampledSpecularEdgeEnergy(sampledSpecular, nDotV, clampedRoughness);
2972
- sampledSpecular *= u_environmentMapTextureSpecularIntensity * sampledEnvironmentWeight * mix(0.84, 0.58, clampedRoughness);
2973
- float proceduralSpecularScale = materialFiniteSpecularScale * mix(0.34, 1.0, faceOnSpecularGate);
2974
- float sampledSpecularScale = materialEnvironmentSpecularScale * mix(0.18, 1.0, faceOnSpecularGate);
2300
+ sampledSpecular *= u_environmentMapTextureSpecularIntensity * sampledEnvironmentWeight * mix(1.1, 0.65, clampedRoughness);
2301
+ float proceduralSpecularScale = materialFiniteSpecularScale;
2302
+ float sampledSpecularScale = materialEnvironmentSpecularScale;
2975
2303
  return proceduralSpecular * proceduralSpecularScale + sampledSpecular * sampledSpecularScale;
2976
2304
  }
2977
- vec3 a3dTexturedPbrIridescenceColor(float minimumThickness, float maximumThickness, float iridescenceIor) {
2305
+ vec3 a3dTexturedPbrIridescenceColor(float minimumThickness, float maximumThickness, float iridescenceIor, float nDotV) {
2978
2306
  float thickness = clamp((minimumThickness + maximumThickness) * 0.5, 0.0, 1200.0);
2979
- float phase = clamp((thickness - 100.0) / 1100.0, 0.0, 1.0) * 6.2831853;
2307
+ float opticalThicknessPhase = clamp((thickness - 100.0) / 1100.0, 0.0, 1.0) * 6.2831853;
2980
2308
  float iorShift = clamp((iridescenceIor - 1.0) / 2.0, 0.0, 1.0) * 0.65;
2981
- return clamp(0.5 + 0.5 * cos(phase + iorShift + vec3(0.0, 2.0943951, 4.1887902)), vec3(0.0), vec3(1.0));
2309
+ float viewPhase = pow(1.0 - clamp(nDotV, 0.0, 1.0), 1.25) * (3.2 + iridescenceIor * 1.4);
2310
+ float phase = opticalThicknessPhase + iorShift + viewPhase;
2311
+ return clamp(0.5 + 0.5 * cos(phase + vec3(0.0, 2.0943951, 4.1887902)), vec3(0.0), vec3(1.0));
2312
+ }
2313
+ float a3dTexturedPbrCharlieSheen(float nDotH, float sheenRoughness) {
2314
+ float alpha = max(0.07, sheenRoughness * sheenRoughness);
2315
+ float inverseAlpha = 1.0 / alpha;
2316
+ float sin2h = max(1.0 - nDotH * nDotH, 0.0078125);
2317
+ return (2.0 + inverseAlpha) * pow(sin2h, inverseAlpha * 0.5) / (2.0 * A3D_PI);
2318
+ }
2319
+ float a3dTexturedPbrAnisotropicDistribution(
2320
+ vec3 normal,
2321
+ vec3 halfVector,
2322
+ vec4 tangentFrame,
2323
+ float roughness,
2324
+ float anisotropy,
2325
+ float rotation
2326
+ ) {
2327
+ vec3 N = normalize(normal);
2328
+ vec3 authoredTangent = normalize(tangentFrame.xyz);
2329
+ vec3 authoredBitangent = normalize(cross(N, authoredTangent)) * (tangentFrame.w < 0.0 ? -1.0 : 1.0);
2330
+ float c = cos(rotation);
2331
+ float s = sin(rotation);
2332
+ vec3 T = normalize(authoredTangent * c + authoredBitangent * s);
2333
+ vec3 B = normalize(authoredBitangent * c - authoredTangent * s);
2334
+ float alpha = max(0.035, roughness * roughness);
2335
+ float aspect = sqrt(max(0.08, 1.0 - clamp(anisotropy, 0.0, 0.98) * 0.92));
2336
+ float alphaT = max(0.012, alpha / aspect);
2337
+ float alphaB = max(0.012, alpha * aspect);
2338
+ float tDotH = dot(T, halfVector);
2339
+ float bDotH = dot(B, halfVector);
2340
+ float nDotH = max(dot(N, halfVector), 0.0);
2341
+ float denominator = tDotH * tDotH / (alphaT * alphaT)
2342
+ + bDotH * bDotH / (alphaB * alphaB)
2343
+ + nDotH * nDotH;
2344
+ return 1.0 / max(A3D_PI * alphaT * alphaB * denominator * denominator, A3D_EPSILON);
2982
2345
  }
2983
2346
  vec3 a3dTexturedPbrExtensionDirectLight(
2984
2347
  vec3 normal,
2348
+ vec4 tangentFrame,
2985
2349
  vec3 viewDirection,
2986
2350
  vec3 lightDirection,
2987
2351
  vec3 lightColor,
@@ -3009,18 +2373,22 @@ vec3 a3dTexturedPbrExtensionDirectLight(
3009
2373
  vec3 clearcoatF = a3dFresnelSchlick(vec3(0.04), vDotH);
3010
2374
  float clearcoatD = a3dDistributionGGX(nDotH, clearcoatRough);
3011
2375
  float clearcoatG = a3dGeometrySmithGGXCorrelated(nDotV, nDotL, clearcoatRough);
3012
- vec3 clearcoatLobe = clearcoatF * clearcoatD * clearcoatG * clamp(clearcoat, 0.0, 1.0) * 0.12;
3013
- float sheenStrength = (1.0 - clamp(sheenRoughness, 0.0, 1.0)) * pow(a3dSaturate(1.0 - vDotH), 5.0);
3014
- vec3 sheenLobe = clamp(sheenColor, vec3(0.0), vec3(1.0)) * sheenStrength * 0.18;
3015
- vec3 anisotropyAxis = normalize(vec3(cos(anisotropyRotation), 0.0, sin(anisotropyRotation)));
3016
- float anisotropyBand = pow(abs(dot(H, anisotropyAxis)), mix(28.0, 6.0, clearcoatRough));
3017
- vec3 anisotropyLobe = vec3(clamp(anisotropy, 0.0, 1.0) * anisotropyBand * 0.055);
3018
- vec3 iridescenceColor = a3dTexturedPbrIridescenceColor(iridescenceThicknessMinimum, iridescenceThicknessMaximum, iridescenceIor);
2376
+ vec3 clearcoatLobe = clearcoatF * clearcoatD * clearcoatG * clamp(clearcoat, 0.0, 1.0);
2377
+ float sheenDistribution = a3dTexturedPbrCharlieSheen(nDotH, sheenRoughness);
2378
+ float sheenVisibility = 1.0 / max(4.0 * (nDotV + nDotL - nDotV * nDotL), A3D_EPSILON);
2379
+ float sheenGrazing = pow(1.0 - nDotV, 12.0);
2380
+ vec3 sheenLobe = clamp(sheenColor, vec3(0.0), vec3(1.0))
2381
+ * (sheenDistribution * sheenVisibility * 0.012 + sheenGrazing * 0.18);
2382
+ float anisotropicDistribution = a3dTexturedPbrAnisotropicDistribution(N, H, tangentFrame, clearcoatRough, anisotropy, anisotropyRotation);
2383
+ float anisotropyShape = anisotropicDistribution / (anisotropicDistribution + 3.0);
2384
+ vec3 anisotropyLobe = vec3(clamp(anisotropy, 0.0, 1.0) * anisotropyShape * 0.72);
2385
+ vec3 iridescenceColor = a3dTexturedPbrIridescenceColor(iridescenceThicknessMinimum, iridescenceThicknessMaximum, iridescenceIor, nDotV);
3019
2386
  vec3 iridescenceLobe = iridescenceColor * clamp(iridescence, 0.0, 1.0) * clearcoatF * pow(a3dSaturate(1.0 - nDotV), 2.0) * 0.12;
3020
2387
  return (clearcoatLobe + sheenLobe + anisotropyLobe + iridescenceLobe) * lightColor * lightIntensity * nDotL;
3021
2388
  }
3022
2389
  vec3 a3dTexturedPbrExtensionEnvironmentLight(
3023
2390
  vec3 normal,
2391
+ vec4 tangentFrame,
3024
2392
  vec3 viewDirection,
3025
2393
  vec3 specularRadiance,
3026
2394
  float clearcoat,
@@ -3038,11 +2406,18 @@ vec3 a3dTexturedPbrExtensionEnvironmentLight(
3038
2406
  vec3 clearcoatF = a3dFresnelSchlickRoughness(vec3(0.04), nDotV, clamp(clearcoatRoughness, 0.18, 1.0));
3039
2407
  float faceOn = smoothstep(0.18, 0.68, nDotV);
3040
2408
  vec3 boundedSpecularRadiance = min(specularRadiance * mix(0.1, 0.82, faceOn), vec3(mix(0.08, 0.95, faceOn)));
3041
- vec3 clearcoatLobe = boundedSpecularRadiance * clearcoatF * clamp(clearcoat, 0.0, 1.0) * 0.045;
3042
- vec3 sheenLobe = clamp(sheenColor, vec3(0.0), vec3(1.0)) * (1.0 - clamp(sheenRoughness, 0.0, 1.0)) * pow(a3dSaturate(1.0 - nDotV), 5.0) * 0.12;
3043
- float anisotropyBand = 0.5 + 0.5 * cos(anisotropyRotation * 2.0);
3044
- vec3 anisotropyLobe = boundedSpecularRadiance * clamp(anisotropy, 0.0, 1.0) * mix(0.025, 0.07, anisotropyBand);
3045
- vec3 iridescenceColor = a3dTexturedPbrIridescenceColor(iridescenceThicknessMinimum, iridescenceThicknessMaximum, iridescenceIor);
2409
+ vec3 clearcoatLobe = specularRadiance * clearcoatF * clamp(clearcoat, 0.0, 1.0);
2410
+ vec3 sheenLobe = clamp(sheenColor, vec3(0.0), vec3(1.0))
2411
+ * pow(a3dSaturate(1.0 - nDotV), 8.0)
2412
+ * mix(1.4, 0.75, clamp(sheenRoughness, 0.0, 1.0));
2413
+ vec3 N = normalize(normal);
2414
+ vec3 V = normalize(viewDirection);
2415
+ vec3 environmentDirection = normalize(vec3(0.42, 0.78, 0.46));
2416
+ vec3 environmentHalf = normalize(V + environmentDirection);
2417
+ float anisotropicDistribution = a3dTexturedPbrAnisotropicDistribution(N, environmentHalf, tangentFrame, clearcoatRoughness, anisotropy, anisotropyRotation);
2418
+ float anisotropyShape = anisotropicDistribution / (anisotropicDistribution + 3.0);
2419
+ vec3 anisotropyLobe = boundedSpecularRadiance * clamp(anisotropy, 0.0, 1.0) * anisotropyShape * 0.72;
2420
+ vec3 iridescenceColor = a3dTexturedPbrIridescenceColor(iridescenceThicknessMinimum, iridescenceThicknessMaximum, iridescenceIor, nDotV);
3046
2421
  vec3 iridescenceLobe = boundedSpecularRadiance * iridescenceColor * clamp(iridescence, 0.0, 1.0) * pow(a3dSaturate(1.0 - nDotV), 2.0) * 0.09;
3047
2422
  return clearcoatLobe + sheenLobe + anisotropyLobe + iridescenceLobe;
3048
2423
  }
@@ -3229,8 +2604,9 @@ void main() {
3229
2604
  roughness,
3230
2605
  specular,
3231
2606
  specularColor
3232
- ) + a3dTexturedPbrExtensionEnvironmentLight(
2607
+ ) * mix(1.0, 0.18, anisotropy) + a3dTexturedPbrExtensionEnvironmentLight(
3233
2608
  clearcoatNormalDirection,
2609
+ v_tangent,
3234
2610
  viewDirection,
3235
2611
  extensionEnvironmentSpecular,
3236
2612
  clearcoat,
@@ -3275,7 +2651,15 @@ void main() {
3275
2651
  vec2 backdropOffset = normalize(texturedRefractionDirection.xy + vec2(0.0001)) * u_transmissionBackdropRefractionScale * mix(1.25, 0.55, roughness) * clamp(u_ior - 1.0, 0.0, 2.5);
3276
2652
  float backdropLod = clamp((roughness + volumeThickness * 0.08) * max(u_transmissionBackdropMipCount - 1.0, 0.0), 0.0, max(u_transmissionBackdropMipCount - 1.0, 0.0));
3277
2653
  vec3 backdropRadiance = a3dTexturedPbrDecodeSrgb(textureLod(u_transmissionBackdropTexture, clamp(backdropUv + backdropOffset, vec2(0.001), vec2(0.999)), backdropLod).rgb);
3278
- texturedRefractionRadiance = mix(texturedRefractionRadiance, backdropRadiance * texturedTransmissionAmount * mix(1.0, 1.22, texturedBackdropWeight), texturedBackdropWeight);
2654
+ // Scene-color refraction travels through the same participating volume as
2655
+ // environment refraction. Omitting texturedVolumeTint here made thickness,
2656
+ // attenuationDistance, and attenuationColor byte-identical whenever the
2657
+ // renderer-owned backdrop path was active.
2658
+ texturedRefractionRadiance = mix(
2659
+ texturedRefractionRadiance,
2660
+ backdropRadiance * texturedVolumeTint * texturedTransmissionAmount * mix(1.0, 1.22, texturedBackdropWeight),
2661
+ texturedBackdropWeight
2662
+ );
3279
2663
  }
3280
2664
  #endif
3281
2665
  shaded = mix(shaded, shaded * 0.72 + texturedRefractionRadiance, texturedTransmissionAmount * mix(0.08, 0.58, texturedFallbackEnvironmentTransmissionEnergy));
@@ -3344,9 +2728,11 @@ void main() {
3344
2728
  float directExtensionNdotV = clamp(dot(clearcoatNormalDirection, viewDirection), 0.0, 1.0);
3345
2729
  float directExtensionGrazingGate = mix(0.18, 1.0, smoothstep(0.12, 0.58, directExtensionNdotV));
3346
2730
  float directExtensionSpecularScale = sqrt(clamp(u_materialEnvironmentSpecularScale, 0.0, 1.0)) * directExtensionGrazingGate;
3347
- shaded += a3dPbrDirectLight(mappedNormal, viewDirection, lightDirection, colorIntensity.rgb, directLightIntensity, base, metallic, roughness, specular, specularColor);
2731
+ shaded += a3dPbrDirectLight(mappedNormal, viewDirection, lightDirection, colorIntensity.rgb, directLightIntensity, base, metallic, roughness, specular, specularColor)
2732
+ * mix(1.0, 0.18, anisotropy);
3348
2733
  shaded += a3dTexturedPbrExtensionDirectLight(
3349
2734
  clearcoatNormalDirection,
2735
+ v_tangent,
3350
2736
  viewDirection,
3351
2737
  lightDirection,
3352
2738
  colorIntensity.rgb,
@@ -3370,80 +2756,7 @@ void main() {
3370
2756
  }
3371
2757
  `
3372
2758
  });
3373
- library.register({
3374
- name: DEFAULT_ENVIRONMENT_BACKGROUND_SHADER_NAME,
3375
- marker: DEFAULT_ENVIRONMENT_BACKGROUND_SHADER_MARKER,
3376
- vertex: `#version 300 es
3377
- // ${DEFAULT_ENVIRONMENT_BACKGROUND_SHADER_MARKER}
3378
- precision highp float;
3379
- layout(location = 0) in vec3 a_position;
3380
- out vec2 v_backgroundNdc;
3381
- void main() {
3382
- v_backgroundNdc = a_position.xy;
3383
- gl_Position = vec4(a_position.xy, 1.0, 1.0);
3384
- }
3385
- `,
3386
- fragment: `#version 300 es
3387
- // ${DEFAULT_ENVIRONMENT_BACKGROUND_SHADER_MARKER}
3388
- precision highp float;
3389
- uniform sampler2D u_environmentBackgroundTexture;
3390
- uniform samplerCube u_environmentBackgroundCubeTexture;
3391
- uniform float u_environmentBackgroundProjection;
3392
- uniform float u_environmentBackgroundRotation;
3393
- uniform float u_environmentBackgroundIntensity;
3394
- uniform float u_environmentBackgroundEncoding;
3395
- uniform float u_outputColorSpace;
3396
- uniform mat4 u_environmentBackgroundInverseViewProjection;
3397
- in vec2 v_backgroundNdc;
3398
- out vec4 outColor;
3399
- vec2 a3dBackgroundEquirectUv(vec3 direction) {
3400
- vec3 d = normalize(direction);
3401
- float u = atan(d.z, d.x) / 6.28318530718 + 0.5;
3402
- float v = acos(clamp(d.y, -1.0, 1.0)) / 3.14159265359;
3403
- return vec2(fract(u), clamp(v, 0.0, 1.0));
3404
- }
3405
- vec3 a3dRotateBackgroundDirection(vec3 direction, float rotation) {
3406
- float angle = rotation * 6.28318530718;
3407
- float c = cos(angle);
3408
- float s = sin(angle);
3409
- vec3 d = normalize(direction);
3410
- return normalize(vec3(c * d.x - s * d.z, d.y, s * d.x + c * d.z));
3411
- }
3412
- vec3 a3dBackgroundDirectionFromNdc(vec2 ndc) {
3413
- vec4 nearPoint = u_environmentBackgroundInverseViewProjection * vec4(ndc, -1.0, 1.0);
3414
- vec4 farPoint = u_environmentBackgroundInverseViewProjection * vec4(ndc, 1.0, 1.0);
3415
- vec3 nearWorld = nearPoint.xyz / max(nearPoint.w, 0.00001);
3416
- vec3 farWorld = farPoint.xyz / max(farPoint.w, 0.00001);
3417
- return normalize(farWorld - nearWorld);
3418
- }
3419
- vec3 a3dBackgroundDecodeRgbe(vec4 encodedSample) {
3420
- float exponent = encodedSample.a * 255.0;
3421
- float scale = exponent <= 0.0 ? 0.0 : exp2(exponent - 128.0) * (255.0 / 256.0);
3422
- return max(encodedSample.rgb * scale, vec3(0.0));
3423
- }
3424
- vec3 a3dBackgroundDecode(vec4 encodedSample) {
3425
- if (u_environmentBackgroundEncoding > 1.5) return a3dBackgroundDecodeRgbe(encodedSample);
3426
- return max(encodedSample.rgb, vec3(0.0));
3427
- }
3428
- vec3 a3dBackgroundEncodeOutput(vec3 linearColor) {
3429
- vec3 color = max(linearColor, vec3(0.0));
3430
- vec3 filmic = clamp((color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14), vec3(0.0), vec3(1.0));
3431
- vec3 srgb = pow(filmic, vec3(1.0 / 2.2));
3432
- return mix(color, srgb, step(0.5, u_outputColorSpace));
3433
- }
3434
- void main() {
3435
- vec3 direction = a3dRotateBackgroundDirection(a3dBackgroundDirectionFromNdc(v_backgroundNdc), u_environmentBackgroundRotation);
3436
- vec4 encodedSample = vec4(0.0, 0.0, 0.0, 1.0);
3437
- if (u_environmentBackgroundProjection > 1.5) {
3438
- encodedSample = texture(u_environmentBackgroundCubeTexture, direction);
3439
- } else {
3440
- encodedSample = texture(u_environmentBackgroundTexture, a3dBackgroundEquirectUv(direction));
3441
- }
3442
- vec3 color = a3dBackgroundDecode(encodedSample) * max(u_environmentBackgroundIntensity, 0.0);
3443
- outColor = vec4(a3dBackgroundEncodeOutput(color), 1.0);
3444
- }
3445
- `
3446
- });
2759
+ registerLeanEnvironmentBackgroundShader(library);
3447
2760
  library.register({
3448
2761
  name: DEFAULT_SCREEN_SPACE_LINE_SHADER_NAME,
3449
2762
  marker: DEFAULT_SCREEN_SPACE_LINE_SHADER_MARKER,
@@ -3547,27 +2860,7 @@ void main() {
3547
2860
  }
3548
2861
  `
3549
2862
  });
3550
- library.register({
3551
- name: DEFAULT_DEPTH_SHADER_NAME,
3552
- marker: DEFAULT_DEPTH_SHADER_MARKER,
3553
- vertex: `#version 300 es
3554
- // ${DEFAULT_DEPTH_SHADER_MARKER}
3555
- precision highp float;
3556
- layout(location = 0) in vec3 a_position;
3557
- uniform mat4 u_modelViewProjection;
3558
- void main() {
3559
- gl_Position = u_modelViewProjection * vec4(a_position, 1.0);
3560
- }
3561
- `,
3562
- fragment: `#version 300 es
3563
- // ${DEFAULT_DEPTH_SHADER_MARKER}
3564
- precision highp float;
3565
- out vec4 outColor;
3566
- void main() {
3567
- outColor = vec4(vec3(gl_FragCoord.z), 1.0);
3568
- }
3569
- `
3570
- });
2863
+ registerLeanDepthShader(library);
3571
2864
  // Register the animation/cel toon program (banded N·L ramp + Fresnel rim).
3572
2865
  // This is a real GLSL program compiled through the same library path as the
3573
2866
  // built-in shaders; AnimationToonMaterial targets it via ANIMATION_TOON_SHADER_NAME.