@babylonjs/lite 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +735 -0
- package/README.md +26 -1
- package/THIRD_PARTY_NOTICES.txt +139 -0
- package/dist/index.js +292 -277
- package/dist/index.js.map +1 -1
- package/index.d.ts +277 -11
- package/lib/_chunks/vendor/{manifold-Sh8xE2da.js → manifold-DtI3BJoR.js} +2 -2
- package/lib/_chunks/vendor/{manifold-Sh8xE2da.js.map → manifold-DtI3BJoR.js.map} +1 -1
- package/lib/animation/animation-group-task.js +1 -1
- package/lib/animation/animation-group-task.js.map +1 -1
- package/lib/animation/animation-group.js +20 -15
- package/lib/animation/animation-group.js.map +1 -1
- package/lib/animation/animation-tick.js +10 -0
- package/lib/animation/animation-tick.js.map +1 -0
- package/lib/animation/property-animation.js +2 -1
- package/lib/animation/property-animation.js.map +1 -1
- package/lib/animation/weighted-gltf-mixer.js +1 -1
- package/lib/animation/weighted-gltf-mixer.js.map +1 -1
- package/lib/animation/weighted-pointer-mixer.js +1 -1
- package/lib/animation/weighted-pointer-mixer.js.map +1 -1
- package/lib/engine/device-lost-recovery.js +1 -0
- package/lib/engine/device-lost-recovery.js.map +1 -1
- package/lib/engine/engine.js +1 -1
- package/lib/engine/null-engine.js +29 -0
- package/lib/engine/null-engine.js.map +1 -0
- package/lib/frame-graph/depth-pyramid.js +158 -0
- package/lib/frame-graph/depth-pyramid.js.map +1 -0
- package/lib/frame-graph/frame-graph-actions.js +10 -1
- package/lib/frame-graph/frame-graph-actions.js.map +1 -1
- package/lib/frame-graph/render-task.js +7 -0
- package/lib/frame-graph/render-task.js.map +1 -1
- package/lib/frame-graph/transmission-depth-grab.js +88 -0
- package/lib/frame-graph/transmission-depth-grab.js.map +1 -0
- package/lib/frame-graph/transmission.js +30 -1
- package/lib/frame-graph/transmission.js.map +1 -1
- package/lib/gizmo/bounding-box-gizmo.js +1 -1
- package/lib/index.js +8 -6
- package/lib/index.js.map +1 -1
- package/lib/loader-gltf/gltf-feature-gpu-instancing.js +1 -1
- package/lib/loader-gltf/gltf-interleave.js +1 -1
- package/lib/loader-gltf/load-gltf.js +1 -1
- package/lib/material/shader/shader-pipeline.js +1 -1
- package/lib/material/shader/shader-pipeline.js.map +1 -1
- package/lib/material/shader/shader-renderable.js +23 -8
- package/lib/material/shader/shader-renderable.js.map +1 -1
- package/lib/math/aabb.js +1 -1
- package/lib/math/compute-aabb.js +63 -1
- package/lib/math/compute-aabb.js.map +1 -1
- package/lib/math/index.js +1 -1
- package/lib/mesh/csg2.js +3 -2
- package/lib/mesh/csg2.js.map +1 -1
- package/lib/mesh/mesh-factories.js +1 -1
- package/lib/mesh/thin-instance-gpu-culling.js +4 -2
- package/lib/mesh/thin-instance-gpu-culling.js.map +1 -1
- package/lib/mesh/thin-instance.js +8 -1
- package/lib/mesh/thin-instance.js.map +1 -1
- package/lib/navigation/index.js +1 -1
- package/lib/navigation/navigation.js +9 -1
- package/lib/navigation/navigation.js.map +1 -1
- package/lib/physics/character-controller.js +2 -2
- package/lib/physics/character-controller.js.map +1 -1
- package/lib/physics/havok-floating-origin.js +2 -2
- package/lib/physics/havok-floating-origin.js.map +1 -1
- package/lib/physics/havok.js +40 -13
- package/lib/physics/havok.js.map +1 -1
- package/lib/picking/gpu-picker.js +16 -2
- package/lib/picking/gpu-picker.js.map +1 -1
- package/lib/scene/scene-core.js +9 -3
- package/lib/scene/scene-core.js.map +1 -1
- package/lib/scene/scene-remove.js +8 -0
- package/lib/scene/scene-remove.js.map +1 -1
- package/lib/texture/pixels-texture.js +31 -1
- package/lib/texture/pixels-texture.js.map +1 -1
- package/lib/vat/vat-baker.js +41 -2
- package/lib/vat/vat-baker.js.map +1 -1
- package/package.json +15 -3
- package/lib/_chunks/__vite-browser-external-BFTKbDcV.js +0 -68
- package/lib/_chunks/__vite-browser-external-BFTKbDcV.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transmission.js","sources":["../../../src/frame-graph/transmission.ts"],"sourcesContent":["import { TU, SS } from \"../engine/gpu-flags.js\";\nimport type { EngineContext } from \"../engine/engine.js\";\nimport { _vis } from \"../engine/engine.js\";\nimport { createRenderTarget } from \"../engine/render-target.js\";\nimport { getBilinearSampler } from \"../resource/samplers.js\";\nimport { getTrilinearAnisotropicSampler } from \"../resource/trilinear-anisotropic-sampler.js\";\nimport type { Texture2D } from \"../texture/texture-2d.js\";\nimport { recordMipmaps } from \"../texture/generate-mipmaps.js\";\nimport { biasedMipLevelCount } from \"../texture/mip-count.js\";\nimport type { DrawBinding } from \"../render/renderable.js\";\nimport type { RenderTask } from \"./render-task.js\";\nimport type { SceneContext } from \"../scene/scene-core.js\";\nimport { createImageProcessingTask } from \"./image-processing-task.js\";\n\nexport interface RenderTaskTransmissionState {\n readonly texture: Texture2D;\n /** @internal */\n readonly _baseView: GPUTextureView;\n /** @internal */\n _sourceWidth: number;\n /** @internal */\n _sourceHeight: number;\n /** @internal */\n _sourceTexture: GPUTexture | null;\n /** @internal */\n _blit: TransmissionBlitState | null;\n /** @internal */\n readonly _copyCount: number;\n /** @internal */\n readonly _generateMipmaps: boolean;\n /** @internal */\n _copies: number;\n}\n\ninterface TransmissionBlitState {\n readonly _pipeline: GPURenderPipeline;\n readonly _bindGroup: GPUBindGroup;\n}\n\nconst BLIT_SHADER = `@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}`;\nconst BLIT_MSAA_SHADER = `@group(0)@binding(0)var t:texture_multisampled_2d<f32>;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}fn l(p:vec2i)->vec4f{let n=textureNumSamples(t);var c=vec4f(0);for(var i=0u;i<n;i++){c+=textureLoad(t,p,i);}return c/f32(n);}@fragment fn fs(v:V)->@location(0)vec4f{let d=vec2i(textureDimensions(t));let q=clamp(v.u*vec2f(d)-.5,vec2f(0),vec2f(d-vec2i(1)));let p=vec2i(floor(q));let f=fract(q);let p1=min(p+vec2i(1),d-vec2i(1));return mix(mix(l(p),l(vec2i(p1.x,p.y)),f.x),mix(l(vec2i(p.x,p1.y)),l(p1),f.x),f.y);}`;\nconst REFRACTION_LOD_BIAS = 4;\nlet blitPipelines: Map<string, GPURenderPipeline> | null = null;\nlet blitShader: GPUShaderModule | null = null;\nlet blitMsaaShader: GPUShaderModule | null = null;\nlet blitBgl: GPUBindGroupLayout | null = null;\nlet blitMsaaBgl: GPUBindGroupLayout | null = null;\nlet blitDevice: GPUDevice | null = null;\n\n/** Enable scene-color transmission for every render task currently registered in a scene. PBR materials are marked for linear transmission, and a trailing image-processing task is appended when needed. */\nexport function enableSceneTransmission(scene: SceneContext, engine: EngineContext): void {\n markPbrMaterialsLinear(scene);\n let lastRenderTask: RenderTask | null = null;\n for (const task of scene._frameGraph._tasks) {\n if (\"_renderables\" in task) {\n const renderTask = task as RenderTask;\n enableRenderTaskTransmission(renderTask, engine);\n lastRenderTask = renderTask;\n }\n }\n if (lastRenderTask && !scene._frameGraph._tasks.some((task) => task.name === \"transmission-image-processing\")) {\n scene._frameGraph._tasks.push(createImageProcessingTask({ name: \"transmission-image-processing\", source: lastRenderTask._config.rt }, engine, scene));\n }\n}\n\n/** Options controlling how a render task exposes opaque scene color to transmissive materials. Use these to opt out of the linear offscreen path, control refresh frequency, and limit mipmap generation cost. */\nexport interface TransmissionOptions {\n /** When true (the default), retarget the task's color buffer to a linear `rgba16float`\n * offscreen and tone-map it in a trailing image-processing pass — the model PBR\n * transmission uses so refractive materials read scene color in *linear* space.\n *\n * Set false to perform ONLY the mid-pass scene-color grab: the task's render target\n * format / sample count / clear are left untouched and no tone-map pass is added. Use\n * this for consumers that own their tone mapping / post (e.g. a custom depth-of-field\n * stack) and just need the opaque scene color exposed to a custom transmissive\n * `ShaderMaterial`. */\n linear?: boolean;\n /** Override how many times the scene-colour grab is refreshed per frame. `0` means before every\n * transmissive draw; the default is once before the first transmissive draw. */\n copyCount?: number;\n /** Set false when the transmissive material never samples the scene-colour grab above mip 0. */\n generateMipmaps?: boolean;\n /** Cap the scene-colour grab mip chain. Use this when the material samples explicit low LODs only, so\n * unused tiny mips are not regenerated every frame. Ignored when `generateMipmaps` is false. */\n mipLevelCount?: number;\n}\n\n/** Handle to a render task's scene-color grab, returned by `enableRenderTaskTransmission`. */\nexport interface SceneColorGrab {\n /** The live opaque-scene-color texture sampled by transmissive surfaces, or null before the\n * frame graph has built the task at least once. Its identity changes when the task rebuilds\n * (e.g. on resize), so consumers that bind it to a custom material should re-bind when it\n * changes. */\n readonly texture: Texture2D | null;\n}\n\n/** Enable mid-pass scene-color grabs for a single render task and return the live texture handle. The task is wrapped so transmissive draw calls can sample the opaque color rendered earlier in the same pass. */\nexport function enableRenderTaskTransmission(task: RenderTask, engine: EngineContext, options?: TransmissionOptions): SceneColorGrab {\n const linear = options?.linear !== false;\n applyTransmissionOptions(task, options);\n const grab: SceneColorGrab = {\n get texture(): Texture2D | null {\n return (task._targetSignature as { _transmissionTexture?: Texture2D })._transmissionTexture ?? null;\n },\n };\n if (task._executeWithTransmission) {\n return grab;\n }\n if (linear) {\n retargetRenderTaskToLinearOffscreen(task);\n }\n let state: RenderTaskTransmissionState | null = null;\n const record = task.record.bind(task);\n const execute = task.execute?.bind(task);\n const dispose = task.dispose?.bind(task);\n task.record = () => {\n disposeRenderTaskTransmission(state);\n state = createRenderTaskTransmission(task, engine);\n (task._targetSignature as { _transmissionTexture?: Texture2D })._transmissionTexture = state.texture;\n record();\n configureTransmissionSource(state, task, engine);\n };\n if (linear && execute) {\n task.execute = () => executeRenderTaskLinear(task.scene, execute);\n }\n task.dispose = () => {\n disposeRenderTaskTransmission(state);\n state = null;\n dispose?.();\n };\n task._executeWithTransmission = (sampleCount) => executePassWithTransmission(task, engine, state!, sampleCount);\n return grab;\n}\n\nfunction retargetRenderTaskToLinearOffscreen(task: RenderTask): void {\n const cfg = task._config;\n const oldDesc = cfg.rt._descriptor;\n const surface = task.scene.surface;\n const sampleCount = surface.msaaSamples;\n // The scene render task may target the shared engine scRT (single-sample,\n // colour-only — single-sample default path) or an MSAA colour RT that resolves into it\n // via `rst` (MSAA default path). Never mutate the shared scRT descriptor —\n // instead point the task at a fresh offscreen HDR target and stop resolving to swap.\n // Transmission samples this linear HDR result in its own final image-processing pass\n // that writes the tonemapped result to the swapchain.\n //\n // Depth ownership: when the task already carries an external depth (`cfg.depth`, the\n // single-sample default path), keep it; otherwise the new target owns depth (matching\n // the MSAA colour RT it replaces).\n const ownsDepth = !cfg.depth;\n const newRt = createRenderTarget({\n lbl: \"transmission-linear\",\n format: \"rgba16float\",\n dFormat: ownsDepth ? (oldDesc.dFormat ?? \"depth24plus-stencil8\") : undefined,\n _depthClearValue: oldDesc._depthClearValue,\n _depthCompare: oldDesc._depthCompare,\n samples: sampleCount,\n size: surface,\n });\n cfg.rt = newRt;\n cfg.rst = undefined;\n const sig = task._targetSignature as {\n _colorFormat?: GPUTextureFormat;\n _depthStencilFormat?: GPUTextureFormat;\n _depthCompare?: GPUCompareFunction;\n _sampleCount: number;\n };\n sig._colorFormat = \"rgba16float\";\n sig._depthStencilFormat = cfg.depth?._descriptor.dFormat ?? newRt._descriptor.dFormat;\n sig._depthCompare = newRt._descriptor._depthCompare;\n sig._sampleCount = sampleCount;\n task._opaqueBundles.length = 0;\n task._lastVersion = -1;\n}\n\nfunction executeRenderTaskLinear(scene: SceneContext, execute: () => number): number {\n const imageProcessing = scene.imageProcessing as { exposure: number; contrast: number; toneMappingEnabled: boolean | number };\n const toneMappingEnabled = imageProcessing.toneMappingEnabled;\n const clearColor = scene.clearColor;\n const linearClearColor = inverseImageProcessedColor(clearColor, imageProcessing.exposure, imageProcessing.contrast, toneMappingEnabled === true);\n imageProcessing.toneMappingEnabled = -1;\n scene.clearColor = linearClearColor;\n try {\n return execute();\n } finally {\n scene.clearColor = clearColor;\n imageProcessing.toneMappingEnabled = toneMappingEnabled;\n }\n}\n\nfunction inverseImageProcessedColor(color: GPUColorDict, exposure: number, contrast: number, toneMapping: boolean): GPUColorDict {\n return {\n r: inverseImageProcessedChannel(color.r, exposure, contrast, toneMapping),\n g: inverseImageProcessedChannel(color.g, exposure, contrast, toneMapping),\n b: inverseImageProcessedChannel(color.b, exposure, contrast, toneMapping),\n a: color.a,\n };\n}\n\nfunction inverseImageProcessedChannel(value: number, exposure: number, contrast: number, toneMapping: boolean): number {\n let c = clamp01(value);\n if (contrast < 1) {\n c = contrast > 0 ? clamp01((c - 0.5 * (1 - contrast)) / contrast) : 0.5;\n } else if (contrast > 1) {\n const mixAmount = contrast - 1;\n let lo = 0;\n let hi = 1;\n for (let i = 0; i < 16; i++) {\n const mid = (lo + hi) * 0.5;\n const high = mid * mid * (3 - 2 * mid);\n const out = mid + (high - mid) * mixAmount;\n if (out < c) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n c = (lo + hi) * 0.5;\n }\n c = c ** 2.2;\n if (toneMapping) {\n c = -Math.log2(Math.max(1 - c, 1e-6)) / 1.5905790328979492;\n }\n return exposure > 0 ? c / exposure : c;\n}\n\nfunction clamp01(v: number): number {\n return Math.min(Math.max(v, 0), 1);\n}\n\nfunction markPbrMaterialsLinear(scene: SceneContext): void {\n for (const mesh of scene.meshes) {\n const mat = mesh.material as { _linearImageProcessing?: boolean; _renderFeatures?: unknown } | undefined;\n if (mat) {\n mat._linearImageProcessing = true;\n mat._renderFeatures = undefined;\n }\n }\n}\n\nfunction createRenderTaskTransmission(task: RenderTask, engine: EngineContext): RenderTaskTransmissionState {\n const rt = task._config.rt;\n const width = 1024;\n const height = 1024;\n const format: GPUTextureFormat = \"rgba16float\";\n const mipLevelCount = transmissionMipLevelCount(task._config.transmission, width, height);\n const generateMipmaps = mipLevelCount > 1;\n const texture = engine._device.createTexture({\n label: task.name,\n size: { width, height },\n format,\n mipLevelCount,\n usage: TU.RENDER_ATTACHMENT | TU.TEXTURE_BINDING | TU.COPY_DST,\n });\n const tex: Texture2D = {\n texture,\n view: texture.createView(),\n sampler: getTrilinearAnisotropicSampler(engine),\n width,\n height,\n invertY: false,\n };\n return {\n texture: tex,\n _baseView: texture.createView({ baseMipLevel: 0, mipLevelCount: 1 }),\n _sourceWidth: rt._width,\n _sourceHeight: rt._height,\n _sourceTexture: null,\n _blit: null,\n _copyCount: normalizeCopyCount(task._config.transmission),\n _generateMipmaps: generateMipmaps,\n _copies: 0,\n };\n}\n\nfunction configureTransmissionSource(state: RenderTaskTransmissionState, task: RenderTask, engine: EngineContext): void {\n const rt = task._config.rt;\n state._sourceWidth = rt._width;\n state._sourceHeight = rt._height;\n state._sourceTexture = rt._colorTexture;\n const sampleCount = task._targetSignature._sampleCount;\n if (!state._sourceTexture) {\n return;\n }\n state._blit = shouldBlitTransmission(state, sampleCount) ? createTransmissionBlit(state, engine, state._sourceTexture, sampleCount > 1) : null;\n}\n\nfunction disposeRenderTaskTransmission(state: RenderTaskTransmissionState | null | undefined): void {\n state?.texture.texture.destroy();\n}\n\nexport function executePassWithTransmission(task: RenderTask, engine: EngineContext, state: RenderTaskTransmissionState, sampleCount: number): number {\n state._copies = 0;\n const transparent = task._transparentBindings;\n // MSAA: resolve the FINAL scene colour into the task's single-sample resolve target (`rst`) so downstream\n // passes that SAMPLE the scene RTT (e.g. a custom DoF/present stack) get a resolved image. The multisampled\n // colour is preserved across the split segments (store/load), so resolving on every segment leaves the LAST\n // (complete) resolve in `rst`. No-op when single-sample (resolveView stays null) — existing scenes unchanged.\n const resolveView = sampleCount > 1 ? (task._config.rst?._colorView ?? null) : null;\n let pass = beginTaskPass(task, resolveView, sampleCount, false);\n let draws = drawBaseTask(task, pass);\n let lastPipeline: GPURenderPipeline | null = null;\n let overlay: DrawBinding[] | null = null;\n for (let i = 0; i < transparent.length; i++) {\n const binding = transparent[i]!;\n // `Mesh.renderOnTop` surfaces draw last — after the scene-colour grab — so they sit on top of the\n // transmissive surface and are excluded from what it refracts (e.g. lily pads on water).\n if (binding.renderable.mesh?.renderOnTop === true) {\n (overlay ??= []).push(binding);\n continue;\n }\n const transmissive = binding.renderable._transmissive === true;\n if (transmissive && canUpdateTransmission(state)) {\n pass.end();\n updateTransmissionTexture(state, engine);\n pass = beginTaskPass(task, resolveView, sampleCount, true);\n setPassState(task, pass);\n lastPipeline = null;\n }\n const mesh = binding.renderable.mesh;\n if (mesh && mesh.visible === false) {\n continue;\n }\n if (binding.pipeline !== lastPipeline) {\n pass.setPipeline(binding.pipeline);\n lastPipeline = binding.pipeline;\n }\n draws += binding.draw(pass, engine);\n }\n if (overlay) {\n draws += drawList(pass, overlay, engine);\n }\n pass.end();\n return draws;\n}\n\nfunction updateTransmissionTexture(state: RenderTaskTransmissionState, engine: EngineContext): void {\n if (!state._sourceTexture) {\n throw new Error(\"No transmission source\");\n }\n if (state._blit) {\n blitToTransmission(state, engine);\n } else {\n engine._currentEncoder.copyTextureToTexture(\n { texture: state._sourceTexture },\n { texture: state.texture.texture },\n { width: state.texture.width, height: state.texture.height }\n );\n }\n if (state._generateMipmaps) {\n recordMipmaps(engine, state.texture.texture, engine._currentEncoder);\n }\n state._copies++;\n}\n\nfunction getBlitPipeline(engine: EngineContext, format: GPUTextureFormat, multisampled: boolean): GPURenderPipeline {\n const device = engine._device;\n if (device !== blitDevice) {\n blitPipelines?.clear();\n blitPipelines = null;\n blitShader = null;\n blitMsaaShader = null;\n blitBgl = null;\n blitMsaaBgl = null;\n blitDevice = device;\n }\n if (multisampled) {\n blitMsaaShader ??= device.createShaderModule({ code: BLIT_MSAA_SHADER });\n blitMsaaBgl ??= device.createBindGroupLayout({\n entries: [{ binding: 0, visibility: SS.FRAGMENT, texture: { sampleType: \"unfilterable-float\", multisampled: true } }],\n });\n } else {\n blitShader ??= device.createShaderModule({ code: BLIT_SHADER });\n blitBgl ??= device.createBindGroupLayout({\n entries: [\n { binding: 0, visibility: SS.FRAGMENT, texture: { sampleType: \"float\" } },\n { binding: 1, visibility: SS.FRAGMENT, sampler: {} },\n ],\n });\n }\n blitPipelines ??= new Map();\n const key = `${format}:${multisampled ? \"msaa\" : \"\"}`;\n let pipeline = blitPipelines.get(key);\n if (!pipeline) {\n const bgl = multisampled ? blitMsaaBgl! : blitBgl!;\n pipeline = device.createRenderPipeline({\n label: \"transmission-copy\",\n layout: device.createPipelineLayout({ bindGroupLayouts: [bgl] }),\n vertex: { module: multisampled ? blitMsaaShader! : blitShader!, entryPoint: \"vs\" },\n fragment: { module: multisampled ? blitMsaaShader! : blitShader!, entryPoint: \"fs\", targets: [{ format }] },\n primitive: { topology: \"triangle-list\" },\n });\n blitPipelines.set(key, pipeline);\n }\n return pipeline;\n}\n\nfunction shouldBlitTransmission(state: RenderTaskTransmissionState, sampleCount: number): boolean {\n return sampleCount > 1 || state._sourceWidth !== state.texture.width || state._sourceHeight !== state.texture.height;\n}\n\nfunction createTransmissionBlit(state: RenderTaskTransmissionState, engine: EngineContext, source: GPUTexture, multisampled: boolean): TransmissionBlitState {\n const device = engine._device;\n const pipeline = getBlitPipeline(engine, state.texture.texture.format, multisampled);\n const bindGroup = device.createBindGroup({\n layout: multisampled ? blitMsaaBgl! : blitBgl!,\n entries: multisampled\n ? [{ binding: 0, resource: source.createView() }]\n : [\n { binding: 0, resource: source.createView() },\n { binding: 1, resource: getBilinearSampler(engine) },\n ],\n });\n return { _pipeline: pipeline, _bindGroup: bindGroup };\n}\n\nfunction blitToTransmission(state: RenderTaskTransmissionState, engine: EngineContext): void {\n const blit = state._blit!;\n const pass = engine._currentEncoder.beginRenderPass({\n colorAttachments: [{ view: state._baseView, loadOp: \"clear\", storeOp: \"store\", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],\n });\n pass.setPipeline(blit._pipeline);\n pass.setBindGroup(0, blit._bindGroup);\n pass.draw(3);\n pass.end();\n}\n\nfunction canUpdateTransmission(state: RenderTaskTransmissionState): boolean {\n return state._copyCount === 0 || state._copies < state._copyCount;\n}\n\nfunction beginTaskPass(task: RenderTask, resolveTarget: GPUTextureView | null, sampleCount: number, load: boolean): GPURenderPassEncoder {\n const att = task._colorAttachment;\n const depthLoadOp = load || !task._config.clr ? \"load\" : \"clear\";\n if (load) {\n att.loadOp = \"load\";\n }\n const depthAttachment = task._renderPassDescriptor.depthStencilAttachment;\n if (depthAttachment) {\n depthAttachment.depthLoadOp = depthLoadOp;\n if (depthAttachment.stencilLoadOp) {\n depthAttachment.stencilLoadOp = depthLoadOp;\n }\n }\n if (sampleCount > 1) {\n att.resolveTarget = resolveTarget ?? undefined;\n } else {\n att.resolveTarget = undefined;\n }\n return task.engine._currentEncoder.beginRenderPass(task._renderPassDescriptor);\n}\n\nfunction setPassState(task: RenderTask, pass: GPURenderPassEncoder): void {\n const cfg = task._config;\n const rt = cfg.rt;\n const scene = task.scene;\n const camera = cfg.cam ?? scene.camera;\n const v = camera?.viewport;\n if (v) {\n const rw = rt._width;\n const rh = rt._height;\n const x = Math.floor(v.x * rw);\n const y = Math.floor((1 - v.y - v.height) * rh);\n const w = Math.ceil((v.x + v.width) * rw) - x;\n const h = Math.ceil((1 - v.y) * rh) - y;\n pass.setViewport(x, y, w, h, 0, 1);\n pass.setScissorRect(x, y, w, h);\n }\n pass.setBindGroup(0, task._sceneBG);\n}\n\nfunction drawBaseTask(task: RenderTask, pass: GPURenderPassEncoder): number {\n const eng = task.engine;\n const rt = task._config.rt;\n const scene = task.scene;\n const opaqueBindings = task._opaqueBindings;\n const opaqueBundles = task._opaqueBundles;\n\n setPassState(task, pass);\n\n if (task._lastVersion !== scene._renderableVersion || task._lastVis !== _vis || opaqueBundles.length === 0) {\n const desc = rt._descriptor;\n const be = eng._device.createRenderBundleEncoder({\n colorFormats: desc.format ? [desc.format] : [],\n depthStencilFormat: desc.dFormat,\n sampleCount: desc.samples ?? 1,\n });\n be.setBindGroup(0, task._sceneBG);\n drawList(be, opaqueBindings, eng);\n opaqueBundles[0] = be.finish();\n task._lastVersion = scene._renderableVersion;\n task._lastVis = _vis;\n }\n let draws = opaqueBindings.length;\n pass.executeBundles(opaqueBundles);\n pass.setBindGroup(0, task._sceneBG);\n draws += drawList(pass, task._directBindings, eng);\n return draws;\n}\n\nfunction drawList(enc: GPURenderPassEncoder | GPURenderBundleEncoder, list: readonly DrawBinding[], engine: EngineContext): number {\n let lp: GPURenderPipeline | null = null;\n let draws = 0;\n for (const b of list) {\n const mesh = b.renderable.mesh;\n if (mesh && mesh.visible === false) {\n continue;\n }\n if (b.pipeline !== lp) {\n enc.setPipeline(b.pipeline);\n lp = b.pipeline;\n }\n draws += b.draw(enc, engine);\n }\n return draws;\n}\n\nfunction normalizeCopyCount(cfg: RenderTask[\"_config\"][\"transmission\"]): number {\n const count = cfg?.copyCount ?? 1;\n return count === Infinity ? 0 : Math.max(0, count | 0);\n}\n\nfunction applyTransmissionOptions(task: RenderTask, options: TransmissionOptions | undefined): void {\n if (!options) {\n return;\n }\n let next = task._config.transmission;\n let changed = false;\n const set = <K extends keyof NonNullable<RenderTask[\"_config\"][\"transmission\"]>>(key: K, value: NonNullable<RenderTask[\"_config\"][\"transmission\"]>[K] | undefined): void => {\n if (value === undefined) {\n return;\n }\n next = { ...next, [key]: value };\n changed = true;\n };\n set(\"copyCount\", options.copyCount);\n set(\"generateMipmaps\", options.generateMipmaps);\n set(\"mipLevelCount\", options.mipLevelCount);\n if (changed) {\n task._config.transmission = next;\n }\n}\n\nfunction transmissionMipLevelCount(cfg: RenderTask[\"_config\"][\"transmission\"], width: number, height: number): number {\n if (cfg?.generateMipmaps === false) {\n return 1;\n }\n const full = Math.floor(Math.log2(Math.max(width, height))) + 1;\n const defaultCount = biasedMipLevelCount(width, height, REFRACTION_LOD_BIAS);\n const requested = cfg?.mipLevelCount;\n if (requested === undefined) {\n return Math.min(full, defaultCount);\n }\n return Math.min(full, Math.max(1, requested | 0));\n}\n"],"names":[],"mappings":";;;;;;;;;AAuCA,MAAM,WAAA,GAAc,CAAA,4YAAA,CAAA;AACpB,MAAM,gBAAA,GAAmB,CAAA,0sBAAA,CAAA;AACzB,MAAM,mBAAA,GAAsB,CAAA;AAC5B,IAAI,aAAA,GAAuD,IAAA;AAC3D,IAAI,UAAA,GAAqC,IAAA;AACzC,IAAI,cAAA,GAAyC,IAAA;AAC7C,IAAI,OAAA,GAAqC,IAAA;AACzC,IAAI,WAAA,GAAyC,IAAA;AAC7C,IAAI,UAAA,GAA+B,IAAA;AAG5B,SAAS,uBAAA,CAAwB,OAAqB,MAAA,EAA6B;AACtF,EAAA,sBAAA,CAAuB,KAAK,CAAA;AAC5B,EAAA,IAAI,cAAA,GAAoC,IAAA;AACxC,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,CAAM,WAAA,CAAY,MAAA,EAAQ;AACzC,IAAA,IAAI,kBAAkB,IAAA,EAAM;AACxB,MAAA,MAAM,UAAA,GAAa,IAAA;AACnB,MAAA,4BAAA,CAA6B,YAAY,MAAM,CAAA;AAC/C,MAAA,cAAA,GAAiB,UAAA;AAAA,IACrB;AAAA,EACJ;AACA,EAAA,IAAI,cAAA,IAAkB,CAAC,KAAA,CAAM,WAAA,CAAY,MAAA,CAAO,IAAA,CAAK,CAAC,IAAA,KAAS,IAAA,CAAK,IAAA,KAAS,+BAA+B,CAAA,EAAG;AAC3G,IAAA,KAAA,CAAM,WAAA,CAAY,MAAA,CAAO,IAAA,CAAK,yBAAA,CAA0B,EAAE,IAAA,EAAM,+BAAA,EAAiC,MAAA,EAAQ,cAAA,CAAe,OAAA,CAAQ,EAAA,EA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AAA,EAAW;AACzB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,EAAM,YAAY,CAAA;AAAA,EACtC;AACA,EAAA,OAAO,IAAA,CAAK,IAAI,IAAA,EAAM,IAAA,CAAK,IAAI,CAAA,EAAG,SAAA,GAAY,CAAC,CAAC,CAAA;AACpD;;;;"}
|
|
1
|
+
{"version":3,"file":"transmission.js","sources":["../../../src/frame-graph/transmission.ts"],"sourcesContent":["import { TU, SS } from \"../engine/gpu-flags.js\";\nimport type { EngineContext } from \"../engine/engine.js\";\nimport { _vis } from \"../engine/engine.js\";\nimport { createRenderTarget } from \"../engine/render-target.js\";\nimport { getBilinearSampler } from \"../resource/samplers.js\";\nimport { getTrilinearAnisotropicSampler } from \"../resource/trilinear-anisotropic-sampler.js\";\nimport type { Texture2D } from \"../texture/texture-2d.js\";\nimport { recordMipmaps } from \"../texture/generate-mipmaps.js\";\nimport { biasedMipLevelCount } from \"../texture/mip-count.js\";\nimport type { DrawBinding } from \"../render/renderable.js\";\nimport type { RenderTask } from \"./render-task.js\";\nimport type { SceneContext } from \"../scene/scene-core.js\";\nimport { createImageProcessingTask } from \"./image-processing-task.js\";\n\nexport interface RenderTaskTransmissionState {\n readonly texture: Texture2D;\n /** @internal */\n readonly _baseView: GPUTextureView;\n /** @internal */\n _sourceWidth: number;\n /** @internal */\n _sourceHeight: number;\n /** @internal */\n _sourceTexture: GPUTexture | null;\n /** @internal */\n _blit: TransmissionBlitState | null;\n /** @internal Depth grab (the `grabDepth` option): the task's depth attachment snapshotted at the same\n * mid-pass break as the scene-colour copy, resolved into a single-sample `r32float`. Null when the\n * option is off, the task has no depth attachment, or the target hasn't built yet. */\n _depth: TransmissionDepthGrabState | null;\n /** @internal */\n readonly _copyCount: number;\n /** @internal */\n readonly _generateMipmaps: boolean;\n /** @internal */\n _copies: number;\n}\n\n/** @internal Depth-grab state built by the lazy `transmission-depth-grab` module and consumed by the per-frame\n * grab in `updateTransmissionTexture`. Exported so the lazy module can construct it. */\nexport interface TransmissionDepthGrabState {\n readonly texture: Texture2D;\n /** @internal */\n readonly _view: GPUTextureView;\n /** @internal */\n readonly _blit: TransmissionBlitState;\n}\n\n/** @internal */\nexport interface TransmissionBlitState {\n /** @internal */\n readonly _pipeline: GPURenderPipeline;\n /** @internal */\n readonly _bindGroup: GPUBindGroup;\n}\n\n/** @internal Builds the depth-grab target + resolve blit, and records the per-frame resolve pass. Lives in the\n * lazily-imported `transmission-depth-grab` module so its shaders/pipelines/pass-descriptor cost zero bytes for\n * transmission scenes that never set `grabDepth`. */\nexport interface DepthGrabImpl {\n create: (engine: EngineContext, source: GPUTexture, width: number, height: number, multisampled: boolean) => TransmissionDepthGrabState;\n record: (engine: EngineContext, depth: TransmissionDepthGrabState) => void;\n}\n\nlet _depthGrab: DepthGrabImpl | null = null;\n\n/** @internal Called at the top level of `transmission-depth-grab.ts` (module side-effect) to wire the builder into\n * this shared module. The dynamic `import(\"./transmission-depth-grab.js\")` in a grabDepth task's `_preload` runs\n * before the frame graph builds, so `_depthGrab` is installed by the time `configureTransmissionSource` runs. */\nexport function _installDepthGrab(impl: DepthGrabImpl): void {\n _depthGrab = impl;\n}\n\nconst BLIT_SHADER = `@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}`;\nconst BLIT_MSAA_SHADER = `@group(0)@binding(0)var t:texture_multisampled_2d<f32>;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}fn l(p:vec2i)->vec4f{let n=textureNumSamples(t);var c=vec4f(0);for(var i=0u;i<n;i++){c+=textureLoad(t,p,i);}return c/f32(n);}@fragment fn fs(v:V)->@location(0)vec4f{let d=vec2i(textureDimensions(t));let q=clamp(v.u*vec2f(d)-.5,vec2f(0),vec2f(d-vec2i(1)));let p=vec2i(floor(q));let f=fract(q);let p1=min(p+vec2i(1),d-vec2i(1));return mix(mix(l(p),l(vec2i(p1.x,p.y)),f.x),mix(l(vec2i(p.x,p1.y)),l(p1),f.x),f.y);}`;\nconst REFRACTION_LOD_BIAS = 4;\nlet blitPipelines: Map<string, GPURenderPipeline> | null = null;\nlet blitShader: GPUShaderModule | null = null;\nlet blitMsaaShader: GPUShaderModule | null = null;\nlet blitBgl: GPUBindGroupLayout | null = null;\nlet blitMsaaBgl: GPUBindGroupLayout | null = null;\nlet blitDevice: GPUDevice | null = null;\n\n/** Enable scene-color transmission for every render task currently registered in a scene. PBR materials are marked for linear transmission, and a trailing image-processing task is appended when needed. */\nexport function enableSceneTransmission(scene: SceneContext, engine: EngineContext): void {\n markPbrMaterialsLinear(scene);\n let lastRenderTask: RenderTask | null = null;\n for (const task of scene._frameGraph._tasks) {\n if (\"_renderables\" in task) {\n const renderTask = task as RenderTask;\n enableRenderTaskTransmission(renderTask, engine);\n lastRenderTask = renderTask;\n }\n }\n if (lastRenderTask && !scene._frameGraph._tasks.some((task) => task.name === \"transmission-image-processing\")) {\n scene._frameGraph._tasks.push(createImageProcessingTask({ name: \"transmission-image-processing\", source: lastRenderTask._config.rt }, engine, scene));\n }\n}\n\n/** Options controlling how a render task exposes opaque scene color to transmissive materials. Use these to opt out of the linear offscreen path, control refresh frequency, and limit mipmap generation cost. */\nexport interface TransmissionOptions {\n /** When true (the default), retarget the task's color buffer to a linear `rgba16float`\n * offscreen and tone-map it in a trailing image-processing pass — the model PBR\n * transmission uses so refractive materials read scene color in *linear* space.\n *\n * Set false to perform ONLY the mid-pass scene-color grab: the task's render target\n * format / sample count / clear are left untouched and no tone-map pass is added. Use\n * this for consumers that own their tone mapping / post (e.g. a custom depth-of-field\n * stack) and just need the opaque scene color exposed to a custom transmissive\n * `ShaderMaterial`. */\n linear?: boolean;\n /** Override how many times the scene-colour grab is refreshed per frame. `0` means before every\n * transmissive draw; the default is once before the first transmissive draw. */\n copyCount?: number;\n /** Set false when the transmissive material never samples the scene-colour grab above mip 0. */\n generateMipmaps?: boolean;\n /** Cap the scene-colour grab mip chain. Use this when the material samples explicit low LODs only, so\n * unused tiny mips are not regenerated every frame. Ignored when `generateMipmaps` is false. */\n mipLevelCount?: number;\n /** When true, ALSO snapshot the task's DEPTH attachment at the same mid-pass grab, into a single-sample\n * `r32float` texture exposed as `SceneColorGrab.depthTexture` — the opaque scene depth as of the moment\n * the first transmissive surface draws. Lets a transmissive material depth-ray-march the opaque scene\n * (screen-space reflection / refraction) without re-rendering a separate depth prepass: the depth\n * attachment itself cannot be sampled while the transmissive draw has it bound (a WebGPU feedback loop),\n * which is exactly why the snapshot is taken at the pass break. MSAA sources resolve sample 0 (matching\n * `createDepthResolveTask`). No-op when the task's render target carries no depth attachment. */\n grabDepth?: boolean;\n}\n\n/** Handle to a render task's scene-color grab, returned by `enableRenderTaskTransmission`. */\nexport interface SceneColorGrab {\n /** The live opaque-scene-color texture sampled by transmissive surfaces, or null before the\n * frame graph has built the task at least once. Its identity changes when the task rebuilds\n * (e.g. on resize), so consumers that bind it to a custom material should re-bind when it\n * changes. */\n readonly texture: Texture2D | null;\n /** The live opaque-scene DEPTH grab (`grabDepth: true`): the task's depth attachment as of the moment\n * the first transmissive surface draws, resolved to a single-sample `r32float` (raw NDC depth as\n * stored; a cleared texel means no geometry). Null before the target builds or when `grabDepth` is\n * off. Identity changes when the task rebuilds (e.g. on resize) — re-bind on change. */\n readonly depthTexture: Texture2D | null;\n}\n\n/** Enable mid-pass scene-color grabs for a single render task and return the live texture handle. The task is wrapped so transmissive draw calls can sample the opaque color rendered earlier in the same pass. */\nexport function enableRenderTaskTransmission(task: RenderTask, engine: EngineContext, options?: TransmissionOptions): SceneColorGrab {\n const linear = options?.linear !== false;\n applyTransmissionOptions(task, options);\n // grabDepth is opt-in: only when set do we dynamic-import the depth-grab shaders/pipelines (installed via the\n // module side-effect). `_preload` is awaited before the frame graph builds, so `_createDepthGrab` is ready by\n // the time `configureTransmissionSource` runs in record(). Transmission scenes without grabDepth never fetch it.\n if (task._config.transmission?.grabDepth) {\n const priorPreload = task._preload?.bind(task);\n task._preload = async (): Promise<void> => {\n if (priorPreload) {\n await priorPreload();\n }\n await import(\"./transmission-depth-grab.js\");\n };\n }\n const grab: SceneColorGrab = {\n get texture(): Texture2D | null {\n return (task._targetSignature as { _transmissionTexture?: Texture2D })._transmissionTexture ?? null;\n },\n get depthTexture(): Texture2D | null {\n return (task._targetSignature as { _transmissionDepthTexture?: Texture2D | null })._transmissionDepthTexture ?? null;\n },\n };\n if (task._executeWithTransmission) {\n return grab;\n }\n if (linear) {\n retargetRenderTaskToLinearOffscreen(task);\n }\n let state: RenderTaskTransmissionState | null = null;\n const record = task.record.bind(task);\n const execute = task.execute?.bind(task);\n const dispose = task.dispose?.bind(task);\n task.record = () => {\n disposeRenderTaskTransmission(state);\n state = createRenderTaskTransmission(task, engine);\n (task._targetSignature as { _transmissionTexture?: Texture2D })._transmissionTexture = state.texture;\n record();\n configureTransmissionSource(state, task, engine);\n };\n if (linear && execute) {\n task.execute = () => executeRenderTaskLinear(task.scene, execute);\n }\n task.dispose = () => {\n disposeRenderTaskTransmission(state);\n state = null;\n dispose?.();\n };\n task._executeWithTransmission = (sampleCount) => executePassWithTransmission(task, engine, state!, sampleCount);\n return grab;\n}\n\nfunction retargetRenderTaskToLinearOffscreen(task: RenderTask): void {\n const cfg = task._config;\n const oldDesc = cfg.rt._descriptor;\n const surface = task.scene.surface;\n const sampleCount = surface.msaaSamples;\n // The scene render task may target the shared engine scRT (single-sample,\n // colour-only — single-sample default path) or an MSAA colour RT that resolves into it\n // via `rst` (MSAA default path). Never mutate the shared scRT descriptor —\n // instead point the task at a fresh offscreen HDR target and stop resolving to swap.\n // Transmission samples this linear HDR result in its own final image-processing pass\n // that writes the tonemapped result to the swapchain.\n //\n // Depth ownership: when the task already carries an external depth (`cfg.depth`, the\n // single-sample default path), keep it; otherwise the new target owns depth (matching\n // the MSAA colour RT it replaces).\n const ownsDepth = !cfg.depth;\n const newRt = createRenderTarget({\n lbl: \"transmission-linear\",\n format: \"rgba16float\",\n dFormat: ownsDepth ? (oldDesc.dFormat ?? \"depth24plus-stencil8\") : undefined,\n _depthClearValue: oldDesc._depthClearValue,\n _depthCompare: oldDesc._depthCompare,\n samples: sampleCount,\n size: surface,\n });\n cfg.rt = newRt;\n cfg.rst = undefined;\n const sig = task._targetSignature as {\n _colorFormat?: GPUTextureFormat;\n _depthStencilFormat?: GPUTextureFormat;\n _depthCompare?: GPUCompareFunction;\n _sampleCount: number;\n };\n sig._colorFormat = \"rgba16float\";\n sig._depthStencilFormat = cfg.depth?._descriptor.dFormat ?? newRt._descriptor.dFormat;\n sig._depthCompare = newRt._descriptor._depthCompare;\n sig._sampleCount = sampleCount;\n task._opaqueBundles.length = 0;\n task._lastVersion = -1;\n}\n\nfunction executeRenderTaskLinear(scene: SceneContext, execute: () => number): number {\n const imageProcessing = scene.imageProcessing as { exposure: number; contrast: number; toneMappingEnabled: boolean | number };\n const toneMappingEnabled = imageProcessing.toneMappingEnabled;\n const clearColor = scene.clearColor;\n const linearClearColor = inverseImageProcessedColor(clearColor, imageProcessing.exposure, imageProcessing.contrast, toneMappingEnabled === true);\n imageProcessing.toneMappingEnabled = -1;\n scene.clearColor = linearClearColor;\n try {\n return execute();\n } finally {\n scene.clearColor = clearColor;\n imageProcessing.toneMappingEnabled = toneMappingEnabled;\n }\n}\n\nfunction inverseImageProcessedColor(color: GPUColorDict, exposure: number, contrast: number, toneMapping: boolean): GPUColorDict {\n return {\n r: inverseImageProcessedChannel(color.r, exposure, contrast, toneMapping),\n g: inverseImageProcessedChannel(color.g, exposure, contrast, toneMapping),\n b: inverseImageProcessedChannel(color.b, exposure, contrast, toneMapping),\n a: color.a,\n };\n}\n\nfunction inverseImageProcessedChannel(value: number, exposure: number, contrast: number, toneMapping: boolean): number {\n let c = clamp01(value);\n if (contrast < 1) {\n c = contrast > 0 ? clamp01((c - 0.5 * (1 - contrast)) / contrast) : 0.5;\n } else if (contrast > 1) {\n const mixAmount = contrast - 1;\n let lo = 0;\n let hi = 1;\n for (let i = 0; i < 16; i++) {\n const mid = (lo + hi) * 0.5;\n const high = mid * mid * (3 - 2 * mid);\n const out = mid + (high - mid) * mixAmount;\n if (out < c) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n c = (lo + hi) * 0.5;\n }\n c = c ** 2.2;\n if (toneMapping) {\n c = -Math.log2(Math.max(1 - c, 1e-6)) / 1.5905790328979492;\n }\n return exposure > 0 ? c / exposure : c;\n}\n\nfunction clamp01(v: number): number {\n return Math.min(Math.max(v, 0), 1);\n}\n\nfunction markPbrMaterialsLinear(scene: SceneContext): void {\n for (const mesh of scene.meshes) {\n const mat = mesh.material as { _linearImageProcessing?: boolean; _renderFeatures?: unknown } | undefined;\n if (mat) {\n mat._linearImageProcessing = true;\n mat._renderFeatures = undefined;\n }\n }\n}\n\nfunction createRenderTaskTransmission(task: RenderTask, engine: EngineContext): RenderTaskTransmissionState {\n const rt = task._config.rt;\n const width = 1024;\n const height = 1024;\n const format: GPUTextureFormat = \"rgba16float\";\n const mipLevelCount = transmissionMipLevelCount(task._config.transmission, width, height);\n const generateMipmaps = mipLevelCount > 1;\n const texture = engine._device.createTexture({\n label: task.name,\n size: { width, height },\n format,\n mipLevelCount,\n usage: TU.RENDER_ATTACHMENT | TU.TEXTURE_BINDING | TU.COPY_DST,\n });\n const tex: Texture2D = {\n texture,\n view: texture.createView(),\n sampler: getTrilinearAnisotropicSampler(engine),\n width,\n height,\n invertY: false,\n };\n return {\n texture: tex,\n _baseView: texture.createView({ baseMipLevel: 0, mipLevelCount: 1 }),\n _sourceWidth: rt._width,\n _sourceHeight: rt._height,\n _sourceTexture: null,\n _blit: null,\n _depth: null,\n _copyCount: normalizeCopyCount(task._config.transmission),\n _generateMipmaps: generateMipmaps,\n _copies: 0,\n };\n}\n\nfunction configureTransmissionSource(state: RenderTaskTransmissionState, task: RenderTask, engine: EngineContext): void {\n const rt = task._config.rt;\n state._sourceWidth = rt._width;\n state._sourceHeight = rt._height;\n state._sourceTexture = rt._colorTexture;\n const sampleCount = task._targetSignature._sampleCount;\n // Depth grab (grabDepth): (re)build the r32float snapshot + its resolve blit against the task's CURRENT\n // depth attachment, and publish it on the target signature so `SceneColorGrab.depthTexture` stays live.\n const sig = task._targetSignature as { _transmissionDepthTexture?: Texture2D | null };\n sig._transmissionDepthTexture = null;\n const depthSource = rt._depthTexture;\n if (task._config.transmission?.grabDepth && _depthGrab && depthSource && rt._width > 0 && rt._height > 0) {\n state._depth = _depthGrab.create(engine, depthSource, rt._width, rt._height, sampleCount > 1);\n sig._transmissionDepthTexture = state._depth.texture;\n }\n if (!state._sourceTexture) {\n return;\n }\n state._blit = shouldBlitTransmission(state, sampleCount) ? createTransmissionBlit(state, engine, state._sourceTexture, sampleCount > 1) : null;\n}\n\nfunction disposeRenderTaskTransmission(state: RenderTaskTransmissionState | null | undefined): void {\n state?.texture.texture.destroy();\n state?._depth?.texture.texture.destroy();\n}\n\nexport function executePassWithTransmission(task: RenderTask, engine: EngineContext, state: RenderTaskTransmissionState, sampleCount: number): number {\n state._copies = 0;\n const transparent = task._transparentBindings;\n // MSAA: resolve the FINAL scene colour into the task's single-sample resolve target (`rst`) so downstream\n // passes that SAMPLE the scene RTT (e.g. a custom DoF/present stack) get a resolved image. The multisampled\n // colour is preserved across the split segments (store/load), so resolving on every segment leaves the LAST\n // (complete) resolve in `rst`. No-op when single-sample (resolveView stays null) — existing scenes unchanged.\n const resolveView = sampleCount > 1 ? (task._config.rst?._colorView ?? null) : null;\n let pass = beginTaskPass(task, resolveView, sampleCount, false);\n let draws = drawBaseTask(task, pass);\n let lastPipeline: GPURenderPipeline | null = null;\n let overlay: DrawBinding[] | null = null;\n for (let i = 0; i < transparent.length; i++) {\n const binding = transparent[i]!;\n // `Mesh.renderOnTop` surfaces draw last — after the scene-colour grab — so they sit on top of the\n // transmissive surface and are excluded from what it refracts (e.g. lily pads on water).\n if (binding.renderable.mesh?.renderOnTop === true) {\n (overlay ??= []).push(binding);\n continue;\n }\n const transmissive = binding.renderable._transmissive === true;\n if (transmissive && canUpdateTransmission(state)) {\n pass.end();\n updateTransmissionTexture(state, engine);\n pass = beginTaskPass(task, resolveView, sampleCount, true);\n setPassState(task, pass);\n lastPipeline = null;\n }\n const mesh = binding.renderable.mesh;\n if (mesh && mesh.visible === false) {\n continue;\n }\n if (binding.pipeline !== lastPipeline) {\n pass.setPipeline(binding.pipeline);\n lastPipeline = binding.pipeline;\n }\n draws += binding.draw(pass, engine);\n }\n if (overlay) {\n draws += drawList(pass, overlay, engine);\n }\n pass.end();\n return draws;\n}\n\nfunction updateTransmissionTexture(state: RenderTaskTransmissionState, engine: EngineContext): void {\n if (!state._sourceTexture) {\n throw new Error(\"No transmission source\");\n }\n if (state._blit) {\n blitToTransmission(state, engine);\n } else {\n engine._currentEncoder.copyTextureToTexture(\n { texture: state._sourceTexture },\n { texture: state.texture.texture },\n { width: state.texture.width, height: state.texture.height }\n );\n }\n if (state._generateMipmaps) {\n recordMipmaps(engine, state.texture.texture, engine._currentEncoder);\n }\n // Depth grab rides the same mid-pass break: the depth attachment is unbound here (the pass just ended),\n // so it is legal to sample; the resumed segment re-attaches it with loadOp \"load\". The record body lives in\n // the lazy depth-grab module (installed only when grabDepth is enabled), so it costs zero bytes otherwise.\n if (state._depth) {\n _depthGrab?.record(engine, state._depth);\n }\n state._copies++;\n}\n\nfunction getBlitPipeline(engine: EngineContext, format: GPUTextureFormat, multisampled: boolean): GPURenderPipeline {\n const device = engine._device;\n if (device !== blitDevice) {\n blitPipelines?.clear();\n blitPipelines = null;\n blitShader = null;\n blitMsaaShader = null;\n blitBgl = null;\n blitMsaaBgl = null;\n blitDevice = device;\n }\n if (multisampled) {\n blitMsaaShader ??= device.createShaderModule({ code: BLIT_MSAA_SHADER });\n blitMsaaBgl ??= device.createBindGroupLayout({\n entries: [{ binding: 0, visibility: SS.FRAGMENT, texture: { sampleType: \"unfilterable-float\", multisampled: true } }],\n });\n } else {\n blitShader ??= device.createShaderModule({ code: BLIT_SHADER });\n blitBgl ??= device.createBindGroupLayout({\n entries: [\n { binding: 0, visibility: SS.FRAGMENT, texture: { sampleType: \"float\" } },\n { binding: 1, visibility: SS.FRAGMENT, sampler: {} },\n ],\n });\n }\n blitPipelines ??= new Map();\n const key = `${format}:${multisampled ? \"msaa\" : \"\"}`;\n let pipeline = blitPipelines.get(key);\n if (!pipeline) {\n const bgl = multisampled ? blitMsaaBgl! : blitBgl!;\n pipeline = device.createRenderPipeline({\n label: \"transmission-copy\",\n layout: device.createPipelineLayout({ bindGroupLayouts: [bgl] }),\n vertex: { module: multisampled ? blitMsaaShader! : blitShader!, entryPoint: \"vs\" },\n fragment: { module: multisampled ? blitMsaaShader! : blitShader!, entryPoint: \"fs\", targets: [{ format }] },\n primitive: { topology: \"triangle-list\" },\n });\n blitPipelines.set(key, pipeline);\n }\n return pipeline;\n}\n\nfunction shouldBlitTransmission(state: RenderTaskTransmissionState, sampleCount: number): boolean {\n return sampleCount > 1 || state._sourceWidth !== state.texture.width || state._sourceHeight !== state.texture.height;\n}\n\nfunction createTransmissionBlit(state: RenderTaskTransmissionState, engine: EngineContext, source: GPUTexture, multisampled: boolean): TransmissionBlitState {\n const device = engine._device;\n const pipeline = getBlitPipeline(engine, state.texture.texture.format, multisampled);\n const bindGroup = device.createBindGroup({\n layout: multisampled ? blitMsaaBgl! : blitBgl!,\n entries: multisampled\n ? [{ binding: 0, resource: source.createView() }]\n : [\n { binding: 0, resource: source.createView() },\n { binding: 1, resource: getBilinearSampler(engine) },\n ],\n });\n return { _pipeline: pipeline, _bindGroup: bindGroup };\n}\n\nfunction blitToTransmission(state: RenderTaskTransmissionState, engine: EngineContext): void {\n const blit = state._blit!;\n const pass = engine._currentEncoder.beginRenderPass({\n colorAttachments: [{ view: state._baseView, loadOp: \"clear\", storeOp: \"store\", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],\n });\n pass.setPipeline(blit._pipeline);\n pass.setBindGroup(0, blit._bindGroup);\n pass.draw(3);\n pass.end();\n}\n\nfunction canUpdateTransmission(state: RenderTaskTransmissionState): boolean {\n return state._copyCount === 0 || state._copies < state._copyCount;\n}\n\nfunction beginTaskPass(task: RenderTask, resolveTarget: GPUTextureView | null, sampleCount: number, load: boolean): GPURenderPassEncoder {\n const att = task._colorAttachment;\n const depthLoadOp = load || !task._config.clr ? \"load\" : \"clear\";\n if (load) {\n att.loadOp = \"load\";\n }\n const depthAttachment = task._renderPassDescriptor.depthStencilAttachment;\n if (depthAttachment) {\n depthAttachment.depthLoadOp = depthLoadOp;\n if (depthAttachment.stencilLoadOp) {\n depthAttachment.stencilLoadOp = depthLoadOp;\n }\n }\n if (sampleCount > 1) {\n att.resolveTarget = resolveTarget ?? undefined;\n } else {\n att.resolveTarget = undefined;\n }\n return task.engine._currentEncoder.beginRenderPass(task._renderPassDescriptor);\n}\n\nfunction setPassState(task: RenderTask, pass: GPURenderPassEncoder): void {\n const cfg = task._config;\n const rt = cfg.rt;\n const scene = task.scene;\n const camera = cfg.cam ?? scene.camera;\n const v = camera?.viewport;\n if (v) {\n const rw = rt._width;\n const rh = rt._height;\n const x = Math.floor(v.x * rw);\n const y = Math.floor((1 - v.y - v.height) * rh);\n const w = Math.ceil((v.x + v.width) * rw) - x;\n const h = Math.ceil((1 - v.y) * rh) - y;\n pass.setViewport(x, y, w, h, 0, 1);\n pass.setScissorRect(x, y, w, h);\n }\n pass.setBindGroup(0, task._sceneBG);\n}\n\nfunction drawBaseTask(task: RenderTask, pass: GPURenderPassEncoder): number {\n const eng = task.engine;\n const rt = task._config.rt;\n const scene = task.scene;\n const opaqueBindings = task._opaqueBindings;\n const opaqueBundles = task._opaqueBundles;\n\n setPassState(task, pass);\n\n if (task._lastVersion !== scene._renderableVersion || task._lastVis !== _vis || opaqueBundles.length === 0) {\n const desc = rt._descriptor;\n const be = eng._device.createRenderBundleEncoder({\n colorFormats: desc.format ? [desc.format] : [],\n depthStencilFormat: desc.dFormat,\n sampleCount: desc.samples ?? 1,\n });\n be.setBindGroup(0, task._sceneBG);\n drawList(be, opaqueBindings, eng);\n opaqueBundles[0] = be.finish();\n task._lastVersion = scene._renderableVersion;\n task._lastVis = _vis;\n }\n let draws = opaqueBindings.length;\n pass.executeBundles(opaqueBundles);\n pass.setBindGroup(0, task._sceneBG);\n draws += drawList(pass, task._directBindings, eng);\n return draws;\n}\n\nfunction drawList(enc: GPURenderPassEncoder | GPURenderBundleEncoder, list: readonly DrawBinding[], engine: EngineContext): number {\n let lp: GPURenderPipeline | null = null;\n let draws = 0;\n for (const b of list) {\n const mesh = b.renderable.mesh;\n if (mesh && mesh.visible === false) {\n continue;\n }\n if (b.pipeline !== lp) {\n enc.setPipeline(b.pipeline);\n lp = b.pipeline;\n }\n draws += b.draw(enc, engine);\n }\n return draws;\n}\n\nfunction normalizeCopyCount(cfg: RenderTask[\"_config\"][\"transmission\"]): number {\n const count = cfg?.copyCount ?? 1;\n return count === Infinity ? 0 : Math.max(0, count | 0);\n}\n\nfunction applyTransmissionOptions(task: RenderTask, options: TransmissionOptions | undefined): void {\n if (!options) {\n return;\n }\n let next = task._config.transmission;\n let changed = false;\n const set = <K extends keyof NonNullable<RenderTask[\"_config\"][\"transmission\"]>>(key: K, value: NonNullable<RenderTask[\"_config\"][\"transmission\"]>[K] | undefined): void => {\n if (value === undefined) {\n return;\n }\n next = { ...next, [key]: value };\n changed = true;\n };\n set(\"copyCount\", options.copyCount);\n set(\"generateMipmaps\", options.generateMipmaps);\n set(\"mipLevelCount\", options.mipLevelCount);\n set(\"grabDepth\", options.grabDepth);\n if (changed) {\n task._config.transmission = next;\n }\n}\n\nfunction transmissionMipLevelCount(cfg: RenderTask[\"_config\"][\"transmission\"], width: number, height: number): number {\n if (cfg?.generateMipmaps === false) {\n return 1;\n }\n const full = Math.floor(Math.log2(Math.max(width, height))) + 1;\n const defaultCount = biasedMipLevelCount(width, height, REFRACTION_LOD_BIAS);\n const requested = cfg?.mipLevelCount;\n if (requested === undefined) {\n return Math.min(full, defaultCount);\n }\n return Math.min(full, Math.max(1, requested | 0));\n}\n"],"names":[],"mappings":";;;;;;;;;AAgEA,IAAI,UAAA,GAAmC,IAAA;AAKhC,SAAS,kBAAkB,IAAA,EAA2B;AACzD,EAAA,UAAA,GAAa,IAAA;AACjB;AAEA,MAAM,WAAA,GAAc,CAAA,4YAAA,CAAA;AACpB,MAAM,gBAAA,GAAmB,CAAA,0sBAAA,CAAA;AACzB,MAAM,mBAAA,GAAsB,CAAA;AAC5B,IAAI,aAAA,GAAuD,IAAA;AAC3D,IAAI,UAAA,GAAqC,IAAA;AACzC,IAAI,cAAA,GAAyC,IAAA;AAC7C,IAAI,OAAA,GAAqC,IAAA;AACzC,IAAI,WAAA,GAAyC,IAAA;AAC7C,IAAI,UAAA,GAA+B,IAAA;AAG5B,SAAS,uBAAA,CAAwB,OAAqB,MAAA,EAA6B;AACtF,EAAA,sBAAA,CAAuB,KAAK,CAAA;AAC5B,EAAA,IAAI,cAAA,GAAoC,IAAA;AACxC,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,CAAM,WAAA,CAAY,MAAA,EAAQ;AACzC,IAAA,IAAI,kBAAkB,IAAA,EAAM;AACxB,MAAA,MAAM,UAAA,GAAa,IAAA;AACnB,MAAA,4BAAA,CAA6B,YAAY,MAAM,CAAA;AAC/C,MAAA,cAAA,GAAiB,UAAA;AAAA,IACrB;AAAA,EACJ;AACA,EAAA,IAAI,cAAA,IAAkB,CAAC,KAAA,CAAM,WAAA,CAAY,MAAA,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AAK,IAAA,CAAK,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,MAAM,CAAC,CAAC,CAAA,GAAI,CAAA;AAC9D,EAAA,MAAM,YAAA,GAAe,mBAAA,CAAoB,KAAA,EAAO,MAAA,EAAQ,mBAAmB,CAAA;AAC3E,EAAA,MAAM,YAAY,GAAA,EAAK,aAAA;AACvB,EAAA,IAAI,cAAc,MAAA,EAAW;AACzB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,EAAM,YAAY,CAAA;AAAA,EACtC;AACA,EAAA,OAAO,IAAA,CAAK,IAAI,IAAA,EAAM,IAAA,CAAK,IAAI,CAAA,EAAG,SAAA,GAAY,CAAC,CAAC,CAAA;AACpD;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addToScene, onBeforeRender } from '../scene/scene-core.js';
|
|
2
2
|
import { removeFromScene } from '../scene/scene-remove.js';
|
|
3
3
|
import { createCylinder, createBox } from '../mesh/mesh-factories.js';
|
|
4
|
-
import {
|
|
4
|
+
import { computeAabb } from '../math/compute-aabb.js';
|
|
5
5
|
import { mat4FromQuat } from '../math/mat4-from-quat.js';
|
|
6
6
|
import { mat4Multiply } from '../math/mat4-multiply.js';
|
|
7
7
|
import { createStandardMaterial } from '../material/standard/create-standard-material.js';
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { VERSION, createEngine, disposeEngine, isGpuTimingSupported, renderFrame, resizeEngine, setEngineSize, setGpuTimingEnabled, startEngine, stopEngine } from './engine/engine.js';
|
|
2
|
+
export { createNullEngine, runHeadlessSteps, stepScene } from './engine/null-engine.js';
|
|
2
3
|
export { getRenderTaskGpuTimings, isRenderTaskGpuTimingSupported, setRenderTaskGpuTimingEnabled } from './engine/gpu-task-timing.js';
|
|
3
4
|
export { createSurface, disposeSurface, resizeSurface, setSurfaceSize } from './engine/surface.js';
|
|
4
5
|
export { captureScreenshot } from './engine/screenshot.js';
|
|
@@ -8,10 +9,11 @@ export { removeFromScene } from './scene/scene-remove.js';
|
|
|
8
9
|
export { setSubtreeVisible as setMeshVisible, setSubtreeVisible } from './scene/visibility.js';
|
|
9
10
|
export { setClipPlane, setFog } from './scene/scene-ubo-extras.js';
|
|
10
11
|
export { getFloatingOriginOffset } from './large-world/floating-origin.js';
|
|
11
|
-
export { addRenderPass, addTask, addTaskAtStart, addTaskBefore } from './frame-graph/frame-graph-actions.js';
|
|
12
|
+
export { addRenderPass, addTask, addTaskAfter, addTaskAtStart, addTaskBefore } from './frame-graph/frame-graph-actions.js';
|
|
12
13
|
export { createFrameGraphContext, disposeFrameGraphContext, registerFrameGraphContext, unregisterFrameGraphContext } from './frame-graph/frame-graph-context.js';
|
|
13
14
|
export { addPassDependencies } from './frame-graph/pass.js';
|
|
14
15
|
export { createRenderTask, removeMeshFromTask } from './frame-graph/render-task.js';
|
|
16
|
+
export { createDepthPyramid, createDepthPyramidTask } from './frame-graph/depth-pyramid.js';
|
|
15
17
|
export { createImageProcessingTask } from './frame-graph/image-processing-task.js';
|
|
16
18
|
export { createCopyToTextureTask } from './frame-graph/copy-to-texture-task.js';
|
|
17
19
|
export { createDepthResolveTask } from './frame-graph/depth-resolve-task.js';
|
|
@@ -54,7 +56,7 @@ export { createTorusKnotData } from './mesh/create-torus-knot.js';
|
|
|
54
56
|
export { createCsgFromMesh, createMeshFromCsg, csgIntersect, csgSubtract, csgUnion } from './mesh/csg.js';
|
|
55
57
|
export { createCsg2FromMesh, createMeshFromCsg2, createMeshesFromCsg2, csg2Add, csg2Intersect, csg2Subtract, disposeCsg2, initializeCsg2Async, isCsg2Ready } from './mesh/csg2.js';
|
|
56
58
|
export { createSolidTexture2D } from './texture/solid-texture.js';
|
|
57
|
-
export { createRenderTexture2D, createTexture2DFromPixels, updateTexture2DFromPixels } from './texture/pixels-texture.js';
|
|
59
|
+
export { createRenderTexture2D, createTexture2DFromPixels, createTexture3DFromPixels, updateTexture2DFromPixels } from './texture/pixels-texture.js';
|
|
58
60
|
export { loadKtxTexture2D } from './texture/ktx-loader.js';
|
|
59
61
|
export { loadBasisTexture2D } from './texture/basis-loader.js';
|
|
60
62
|
export { loadKtx2Texture2D, setKtx2DecoderUrl } from './texture/ktx2-loader.js';
|
|
@@ -139,9 +141,9 @@ export { mat4FromQuat } from './math/mat4-from-quat.js';
|
|
|
139
141
|
export { quatFromRotationMatrix } from './math/quat-from-rotation-matrix.js';
|
|
140
142
|
export { quatFromLookDirectionRH } from './math/quat-from-look-direction-rh.js';
|
|
141
143
|
export { mat4Decompose } from './math/mat4-decompose.js';
|
|
142
|
-
export {
|
|
144
|
+
export { computeAabb } from './math/compute-aabb.js';
|
|
143
145
|
export { linearToSrgbByte, packedSrgbToLinearRgba, srgbByteToLinear } from './math/color.js';
|
|
144
|
-
export { addThinInstance, enableThinInstanceGpuCulling, flushThinInstances, removeThinInstance, setThinInstanceColor, setThinInstanceColors, setThinInstanceCount, setThinInstanceMatrix, setThinInstances } from './mesh/thin-instance.js';
|
|
146
|
+
export { addThinInstance, enableThinInstanceGpuCulling, flushThinInstances, removeThinInstance, setThinInstanceColor, setThinInstanceColors, setThinInstanceCount, setThinInstanceCullBoundsPad, setThinInstanceMatrix, setThinInstances } from './mesh/thin-instance.js';
|
|
145
147
|
export { addHierarchyInstance, createHierarchyInstancePool, removeHierarchyInstance, setHierarchyInstanceCount, setHierarchyInstanceMatrix } from './mesh/hierarchy-instance-pool.js';
|
|
146
148
|
export { getCameraPosition, getEffectiveAspectRatio, getProjectionMatrix, getViewMatrix, getViewProjectionMatrix } from './camera/camera.js';
|
|
147
149
|
export { resolveCameraViewport } from './camera/viewport.js';
|
|
@@ -190,14 +192,14 @@ export { createTextData, disposeTextData, updateTextData } from './text/text-dat
|
|
|
190
192
|
export { createDefaultTextData, disposeDefaultTextData, updateDefaultTextData } from './text/default-text-data.js';
|
|
191
193
|
export { addTextRenderable, createTextRenderable, disposeTextRenderable } from './text/text-renderable.js';
|
|
192
194
|
export { addTextRendererLayer, createTextLayer, createTextRenderer, disposeTextRenderer, registerTextRenderer, removeTextRendererLayer, setTextLayerPosition, unregisterTextRenderer } from './text/text-renderer.js';
|
|
193
|
-
export { PhysicsConstraintAxis, PhysicsConstraintType, PhysicsMotionType, PhysicsPrestepType, PhysicsShapeType, addPhysicsShapeChild, addPhysicsShapeChildFromParent, applyPhysicsBodyForce, applyPhysicsBodyImpulse, applyPhysicsImpulse, createHavokWorld, createPhysicsAggregate, createPhysicsBody, createPhysicsConstraint, createPhysicsShape, disposePhysics, enableHavokFloatingOrigin, getPhysicsBodyLinearVelocity, getPhysicsGravity, getPhysicsTimestep, getPhysicsVelocityLimits, onPhysicsAfterStep, releasePhysicsShape, removePhysicsBody, setPhysicsBodyAngularVelocity, setPhysicsBodyLinearVelocity, setPhysicsBodyMass, setPhysicsBodyMassProperties, setPhysicsBodyMotionType, setPhysicsBodyPreStep, setPhysicsBodyPrestepType, setPhysicsBodyShape, setPhysicsBodyTransform, setPhysicsGravity, setPhysicsShapeFilterCollideMask, setPhysicsShapeFilterMembershipMask, setPhysicsShapeMaterial, setPhysicsTimestep, setPhysicsVelocityLimits } from './physics/havok.js';
|
|
195
|
+
export { PhysicsConstraintAxis, PhysicsConstraintType, PhysicsMotionType, PhysicsPrestepType, PhysicsShapeType, addPhysicsShapeChild, addPhysicsShapeChildFromParent, applyPhysicsBodyForce, applyPhysicsBodyImpulse, applyPhysicsImpulse, createHavokWorld, createPhysicsAggregate, createPhysicsBody, createPhysicsConstraint, createPhysicsShape, disposePhysics, enableHavokFloatingOrigin, getPhysicsBodyLinearVelocity, getPhysicsGravity, getPhysicsTimestep, getPhysicsTimestepMs, getPhysicsVelocityLimits, onPhysicsAfterStep, releasePhysicsShape, removePhysicsBody, setPhysicsBodyAngularVelocity, setPhysicsBodyLinearVelocity, setPhysicsBodyMass, setPhysicsBodyMassProperties, setPhysicsBodyMotionType, setPhysicsBodyPreStep, setPhysicsBodyPrestepType, setPhysicsBodyShape, setPhysicsBodyTransform, setPhysicsGravity, setPhysicsShapeFilterCollideMask, setPhysicsShapeFilterMembershipMask, setPhysicsShapeMaterial, setPhysicsTimestep, setPhysicsTimestepMs, setPhysicsVelocityLimits } from './physics/havok.js';
|
|
194
196
|
export { createHeightFieldShape } from './physics/havok-heightfield.js';
|
|
195
197
|
export { physicsRaycast, shapeCast, shapeProximity } from './physics/havok-queries.js';
|
|
196
198
|
export { onPhysicsCollision, setPhysicsBodyCollisionEventsEnabled } from './physics/havok-collision.js';
|
|
197
199
|
export { onPhysicsTrigger, setPhysicsShapeIsTrigger } from './physics/havok-trigger.js';
|
|
198
200
|
export { createPhysicsViewer, disposePhysicsViewer, hidePhysicsBody, showPhysicsBody, showPhysicsConstraint } from './physics/physics-viewer.js';
|
|
199
201
|
export { CharacterCollisionObservable, CharacterSupportedState, PhysicsCharacterController, createPhysicsCharacterController } from './physics/character-controller.js';
|
|
200
|
-
export { addAgent, addBoxObstacle, addCylinderObstacle, agentGoto, computePath, createDebugNavMeshGeometry, createNavCrowd, createNavMesh, createNavMeshFromSources, createNavigationPluginAsync, disposeNavigationPlugin, findRandomPoint, findRandomPointAroundCircle, getAgentPosition, getAgentVelocity, getClosestPoint, getNavigationRandomSeed, raycast, removeObstacle, setNavigationRandomSeed, updateNavCrowd, updateNavMeshObstacles } from './navigation/navigation.js';
|
|
202
|
+
export { addAgent, addBoxObstacle, addCylinderObstacle, agentGoto, computePath, createDebugNavMeshGeometry, createNavCrowd, createNavMesh, createNavMeshFromSources, createNavigationPluginAsync, disposeNavigationPlugin, findClosestPointWithin, findRandomPoint, findRandomPointAroundCircle, getAgentPosition, getAgentVelocity, getClosestPoint, getNavigationRandomSeed, raycast, removeObstacle, setNavigationRandomSeed, updateNavCrowd, updateNavMeshObstacles } from './navigation/navigation.js';
|
|
201
203
|
export { createAudioEngineAsync, disposeAudioEngine, getMasterVolume, setMasterVolume, unlockAudioEngineAsync } from './audio/audio-engine.js';
|
|
202
204
|
export { SoundState, createSoundAsync, disposeSound, pauseSound, playSound, resumeSound, setSoundVolume, stopSound } from './audio/static-sound.js';
|
|
203
205
|
export { createStreamingSoundAsync, disposeStreamingSound, pauseStreamingSound, playStreamingSound, preloadStreamingInstanceAsync, preloadStreamingInstancesAsync, resumeStreamingSound, setStreamingSoundVolume, stopStreamingSound } from './audio/streaming-sound.js';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { F32 } from '../engine/typed-arrays.js';
|
|
2
2
|
import { resolveAccessor } from './gltf-parser.js';
|
|
3
|
-
import {
|
|
3
|
+
import { computeAabb } from '../math/compute-aabb.js';
|
|
4
4
|
import { mat4ComposeInto } from '../math/mat4-compose-into.js';
|
|
5
5
|
import { mat4Multiply } from '../math/mat4-multiply.js';
|
|
6
6
|
import { setThinInstances } from '../mesh/thin-instance.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { U32, U8, U16, F32, DV } from '../engine/typed-arrays.js';
|
|
2
2
|
import { BU } from '../engine/gpu-flags.js';
|
|
3
|
-
import {
|
|
3
|
+
import { computeAabb } from '../math/compute-aabb.js';
|
|
4
4
|
import { initMeshTransform } from '../mesh/mesh.js';
|
|
5
5
|
import { createMappedBuffer } from '../resource/gpu-buffers.js';
|
|
6
6
|
import { TYPE_SIZES, resolveAccessor } from './gltf-parser.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DV, F32, U32, U8, U16 } from '../engine/typed-arrays.js';
|
|
2
2
|
import { BU } from '../engine/gpu-flags.js';
|
|
3
|
-
import {
|
|
3
|
+
import { computeAabb } from '../math/compute-aabb.js';
|
|
4
4
|
import { createTransformNode } from '../scene/transform-node.js';
|
|
5
5
|
import { createSceneNodeFromMatrix } from '../scene/scene-node.js';
|
|
6
6
|
import { initMeshTransform } from '../mesh/mesh.js';
|
|
@@ -9,7 +9,6 @@ let _stencilResolver = null;
|
|
|
9
9
|
function _installShaderStencilResolver(resolve) {
|
|
10
10
|
_stencilResolver = resolve;
|
|
11
11
|
}
|
|
12
|
-
const SHADER_STAGE_ALL = SS.VERTEX | SS.FRAGMENT;
|
|
13
12
|
function getOrCreateShaderPipelineBindings(engine, material) {
|
|
14
13
|
const state = material;
|
|
15
14
|
if (state._shaderBindings && state._shaderDevice === engine._device) {
|
|
@@ -97,6 +96,7 @@ function toUboField(decl) {
|
|
|
97
96
|
return { _name: decl.name, _type: decl.type };
|
|
98
97
|
}
|
|
99
98
|
function buildBindGroupLayoutEntries(samplers, storageBuffers, hasCustomUbo) {
|
|
99
|
+
const SHADER_STAGE_ALL = SS.VERTEX | SS.FRAGMENT;
|
|
100
100
|
const entries = [{ binding: 0, visibility: SHADER_STAGE_ALL, buffer: { type: "uniform" } }];
|
|
101
101
|
let nextBinding = 1;
|
|
102
102
|
if (hasCustomUbo) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-pipeline.js","sources":["../../../../src/material/shader/shader-pipeline.ts"],"sourcesContent":["import { SS } from \"../../engine/gpu-flags.js\";\nimport type { EngineContext } from \"../../engine/engine.js\";\nimport type { RenderTargetSignature } from \"../../engine/render-target.js\";\nimport { targetSignatureKey } from \"../../engine/render-target.js\";\nimport { getSceneBindGroupLayout } from \"../../render/scene-helpers.js\";\nimport { SCENE_UBO_WGSL } from \"../../shader/scene-uniforms.js\";\nimport { computeUboLayout } from \"../../shader/ubo-layout.js\";\nimport type { UboField, UboSpec } from \"../../shader/fragment-types.js\";\nimport type { ShaderAttributeName, ShaderMaterial, ShaderSamplerDecl, ShaderUniformDecl } from \"./shader-material.js\";\nimport { _isShaderSystemUniform } from \"./shader-material.js\";\nimport type { ResolvedStencil } from \"../stencil-state.js\";\nimport type { StencilState } from \"../material.js\";\n\n/** Stencil resolver, installed only by `enableMaterialStencil`. Module-local with a single exported setter:\n * when `enableMaterialStencil` is absent from the bundle the setter tree-shakes, the bundler proves this is\n * always null, and every stencil branch below folds away — stencil-free Shader scenes stay byte-identical. */\nlet _stencilResolver: ((stencil: StencilState) => ResolvedStencil) | null = null;\n/** @internal Install the stencil resolver into the Shader pipeline (called by `enableMaterialStencil`). */\nexport function _installShaderStencilResolver(resolve: (stencil: StencilState) => ResolvedStencil): void {\n _stencilResolver = resolve;\n}\n\nexport interface ShaderPipelineBindings {\n readonly group1BGL: GPUBindGroupLayout;\n readonly systemSpec: UboSpec;\n readonly customSpec: UboSpec | null;\n readonly vertexBuffers: readonly GPUVertexBufferLayout[];\n readonly pipelines: Map<string, GPURenderPipeline>;\n}\n\ninterface ShaderMaterialPipelineState extends ShaderMaterial {\n _shaderDevice?: GPUDevice;\n _shaderBindings?: ShaderPipelineBindings;\n _shaderCustomUbo?: GPUBuffer | null;\n _shaderCustomSpec?: UboSpec | null;\n _shaderCustomData?: ArrayBuffer | null;\n _shaderCustomVersion?: number;\n}\n\nconst SHADER_STAGE_ALL = SS.VERTEX | SS.FRAGMENT;\n\nexport function getOrCreateShaderPipelineBindings(engine: EngineContext, material: ShaderMaterial): ShaderPipelineBindings {\n const state = material as ShaderMaterialPipelineState;\n if (state._shaderBindings && state._shaderDevice === engine._device) {\n return state._shaderBindings;\n }\n\n state._shaderDevice = engine._device;\n const systemFields = material.uniformDecls.filter((u) => _isShaderSystemUniform(u.name)).map(toUboField);\n const customFields = material.uniformDecls.filter((u) => !_isShaderSystemUniform(u.name)).map(toUboField);\n const systemSpec = computeUboLayout(systemFields.length > 0 ? systemFields : [{ _name: \"_pad\", _type: \"vec4<f32>\" }]);\n const customSpec = customFields.length > 0 ? computeUboLayout(customFields) : null;\n const group1BGL = engine._device.createBindGroupLayout({\n label: \"shader-material-group1\",\n entries: buildBindGroupLayoutEntries(material.samplerDecls, material.storageBufferDecls, customSpec !== null),\n });\n const bindings: ShaderPipelineBindings = {\n group1BGL,\n systemSpec,\n customSpec,\n vertexBuffers: material.attributes.map(attributeLayout),\n pipelines: new Map(),\n };\n state._shaderBindings = bindings;\n state._shaderCustomSpec = customSpec;\n state._shaderCustomUbo = null;\n state._shaderCustomData = null;\n state._shaderCustomVersion = -1;\n return bindings;\n}\n\nexport function getOrCreateShaderPipeline(\n engine: EngineContext,\n sig: RenderTargetSignature,\n material: ShaderMaterial,\n bindings: ShaderPipelineBindings,\n variantKey = \"\",\n vertexBuffers: readonly GPUVertexBufferLayout[] = bindings.vertexBuffers,\n instanceAttrs = \"\"\n): GPURenderPipeline {\n // `variantKey`, `vertexBuffers` and `instanceAttrs` default to the\n // non-instanced pipeline — byte-for-byte identical behaviour to before\n // instancing existed. The dynamically-imported thin-instance module is the\n // only caller that passes non-default values, so no instancing logic runs\n // for non-instanced scenes.\n const key = `${targetSignatureKey(sig)}${variantKey}`;\n const cached = bindings.pipelines.get(key);\n if (cached) {\n return cached;\n }\n const stencil = material.stencil && _stencilResolver ? _stencilResolver(material.stencil) : null;\n const device = engine._device;\n const prelude = buildShaderPrelude(material, bindings.systemSpec, bindings.customSpec, instanceAttrs);\n const vertModule = device.createShaderModule({ label: `${material.name ?? \"shader\"}-vertex`, code: `${prelude}\\n${material.vertexSource}` });\n const wantsFragment = !!sig._colorFormat || material.depthOnlyFragment;\n const fragModule = wantsFragment ? device.createShaderModule({ label: `${material.name ?? \"shader\"}-fragment`, code: `${prelude}\\n${material.fragmentSource}` }) : null;\n const colorTarget: GPUColorTargetState | null = sig._colorFormat\n ? {\n format: sig._colorFormat,\n ...(material.needAlphaBlending\n ? {\n blend:\n material.blendMode === \"additive\"\n ? ({\n color: { srcFactor: \"src-alpha\", dstFactor: \"one\", operation: \"add\" },\n alpha: { srcFactor: \"one\", dstFactor: \"one\", operation: \"add\" },\n } satisfies GPUBlendState)\n : ({\n color: { srcFactor: \"src-alpha\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" },\n alpha: { srcFactor: \"one\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" },\n } satisfies GPUBlendState),\n }\n : {}),\n }\n : null;\n\n const pipeline = device.createRenderPipeline({\n label: `${material.name ?? \"shader\"}-pipeline`,\n layout: device.createPipelineLayout({ bindGroupLayouts: [getSceneBindGroupLayout(engine), bindings.group1BGL] }),\n vertex: { module: vertModule, entryPoint: \"mainVertex\", buffers: vertexBuffers as GPUVertexBufferLayout[] },\n ...(fragModule ? { fragment: { module: fragModule, entryPoint: \"mainFragment\", targets: colorTarget ? [colorTarget] : [] } } : {}),\n ...(sig._depthStencilFormat\n ? {\n depthStencil: {\n format: sig._depthStencilFormat,\n // The target's declared depth convention wins over the material default: a depth-only\n // caster authored for the forward-Z shadow map (\"less-equal\") must still depth-test\n // correctly when drawn into a reverse-Z camera depth prepass that declares\n // \"greater-equal\" — otherwise every fragment fails against the 0-cleared buffer.\n depthCompare: sig._depthCompare ?? material.depthCompare,\n depthWriteEnabled: material.needAlphaBlending ? false : material.depthWrite,\n ...(material.depthBias ? { depthBias: material.depthBias } : {}),\n ...(material.depthBiasSlopeScale ? { depthBiasSlopeScale: material.depthBiasSlopeScale } : {}),\n // Pre-baked stencil sub-fields, resolved through the opt-in `_stencilResolver` hook above;\n // applied only on a stencil-capable target — a material reused in the depth32float\n // shadow/depth pass keeps plain depth state (no stencil → no format mismatch). `stencil`\n // is a local const that folds to null in stencil-free bundles, so this branch disappears.\n ...(stencil && sig._depthStencilFormat.includes(\"stencil\") ? stencil._desc : {}),\n },\n }\n : {}),\n multisample: { count: sig._sampleCount },\n primitive: { topology: \"triangle-list\", cullMode: material.backFaceCulling ? \"back\" : \"none\", frontFace: \"ccw\" },\n });\n bindings.pipelines.set(key, pipeline);\n return pipeline;\n}\n\nfunction toUboField(decl: ShaderUniformDecl): UboField {\n return { _name: decl.name, _type: decl.type };\n}\n\nfunction buildBindGroupLayoutEntries(\n samplers: readonly ShaderSamplerDecl[],\n storageBuffers: readonly { name: string; type: string }[],\n hasCustomUbo: boolean\n): GPUBindGroupLayoutEntry[] {\n const entries: GPUBindGroupLayoutEntry[] = [{ binding: 0, visibility: SHADER_STAGE_ALL, buffer: { type: \"uniform\" } }];\n let nextBinding = 1;\n if (hasCustomUbo) {\n entries.push({ binding: nextBinding++, visibility: SHADER_STAGE_ALL, buffer: { type: \"uniform\" } });\n }\n for (const sampler of samplers) {\n const isArray = sampler.viewDimension === \"2d-array\";\n const sampleType = sampler.comparison === true ? \"depth\" : (sampler.sampleType ?? \"float\");\n entries.push({\n binding: nextBinding++,\n visibility: SHADER_STAGE_ALL,\n texture: {\n sampleType,\n viewDimension: isArray ? \"2d-array\" : \"2d\",\n },\n });\n entries.push({\n binding: nextBinding++,\n visibility: SHADER_STAGE_ALL,\n sampler: { type: sampler.comparison === true ? \"comparison\" : sampleType === \"float\" ? \"filtering\" : \"non-filtering\" },\n });\n }\n for (const _storage of storageBuffers) {\n entries.push({\n binding: nextBinding++,\n visibility: SHADER_STAGE_ALL,\n buffer: { type: \"read-only-storage\" },\n });\n }\n return entries;\n}\n\nfunction attributeLayout(name: ShaderAttributeName, shaderLocation: number): GPUVertexBufferLayout {\n switch (name) {\n case \"position\":\n case \"normal\":\n return { arrayStride: 12, attributes: [{ shaderLocation, offset: 0, format: \"float32x3\" }] };\n case \"uv\":\n case \"uv2\":\n return { arrayStride: 8, attributes: [{ shaderLocation, offset: 0, format: \"float32x2\" }] };\n case \"tangent\":\n case \"color\":\n case \"weights\":\n case \"weights1\":\n return { arrayStride: 16, attributes: [{ shaderLocation, offset: 0, format: \"float32x4\" }] };\n case \"joints\":\n case \"joints1\":\n return { arrayStride: 16, attributes: [{ shaderLocation, offset: 0, format: \"uint32x4\" }] };\n }\n}\n\nfunction buildShaderPrelude(material: ShaderMaterial, systemSpec: UboSpec, customSpec: UboSpec | null, instanceAttrs = \"\"): string {\n let wgsl = `${SCENE_UBO_WGSL}\nstruct ShaderSystemUniforms {\n${systemSpec._structBody}\n}\n@group(1) @binding(0) var<uniform> shaderSystem: ShaderSystemUniforms;\n`;\n if (customSpec) {\n wgsl += `struct ShaderUniforms {\n${customSpec._structBody}\n}\n@group(1) @binding(1) var<uniform> shaderUniforms: ShaderUniforms;\n`;\n }\n let nextBinding = customSpec ? 2 : 1;\n for (const sampler of material.samplerDecls) {\n const isArray = sampler.viewDimension === \"2d-array\";\n const isDepth = sampler.comparison === true || sampler.sampleType === \"depth\";\n const texType = isDepth ? (isArray ? \"texture_depth_2d_array\" : \"texture_depth_2d\") : isArray ? \"texture_2d_array<f32>\" : \"texture_2d<f32>\";\n const samplerType = sampler.comparison === true ? \"sampler_comparison\" : \"sampler\";\n wgsl += `@group(1) @binding(${nextBinding++}) var ${sampler.name}: ${texType};\n@group(1) @binding(${nextBinding++}) var ${sampler.name}Sampler: ${samplerType};\n`;\n }\n for (const storage of material.storageBufferDecls) {\n wgsl += `@group(1) @binding(${nextBinding++}) var<storage, read> ${storage.name}: ${storage.type};\n`;\n }\n for (const define of material.defines) {\n wgsl += `const ${define.name}: ${typeof define.value === \"boolean\" ? \"bool\" : \"f32\"} = ${formatDefineValue(define.value)};\n`;\n }\n wgsl += `struct VertexInput {\n`;\n for (let i = 0; i < material.attributes.length; i++) {\n const attr = material.attributes[i]!;\n wgsl += `@location(${i}) ${attr}: ${attributeWgslType(attr)},\n`;\n }\n wgsl += instanceAttrs;\n wgsl += `};\n`;\n return wgsl;\n}\n\nfunction formatDefineValue(value: boolean | number): string {\n if (typeof value === \"boolean\") {\n return value ? \"true\" : \"false\";\n }\n if (Number.isInteger(value)) {\n return `${value}.0`;\n }\n return String(value);\n}\n\nfunction attributeWgslType(name: ShaderAttributeName): string {\n switch (name) {\n case \"position\":\n case \"normal\":\n return \"vec3<f32>\";\n case \"uv\":\n case \"uv2\":\n return \"vec2<f32>\";\n case \"tangent\":\n case \"color\":\n case \"weights\":\n case \"weights1\":\n return \"vec4<f32>\";\n case \"joints\":\n case \"joints1\":\n return \"vec4<u32>\";\n }\n}\n"],"names":[],"mappings":";;;;;;;AAgBA,IAAI,gBAAA,GAAwE,IAAA;AAErE,SAAS,8BAA8B,OAAA,EAA2D;AACrG,EAAA,gBAAA,GAAmB,OAAA;AACvB;AAmBA,MAAM,gBAAA,GAAmB,EAAA,CAAG,MAAA,GAAS,EAAA,CAAG,QAAA;AAEjC,SAAS,iCAAA,CAAkC,QAAuB,QAAA,EAAkD;AACvH,EAAA,MAAM,KAAA,GAAQ,QAAA;AACd,EAAA,IAAI,KAAA,CAAM,eAAA,IAAmB,KAAA,CAAM,aAAA,KAAkB,OAAO,OAAA,EAAS;AACjE,IAAA,OAAO,KAAA,CAAM,eAAA;AAAA,EACjB;AAEA,EAAA,KAAA,CAAM,gBAAgB,MAAA,CAAO,OAAA;AAC7B,EAAA,MAAM,YAAA,GAAe,QAAA,CAAS,YAAA,CAAa,MAAA,CAAO,CAAC,CAAA,KAAM,sBAAA,CAAuB,CAAA,CAAE,IAAI,CAAC,CAAA,CAAE,GAAA,CAAI,UAAU,CAAA;AACvG,EAAA,MAAM,YAAA,GAAe,QAAA,CAAS,YAAA,CAAa,MAAA,CAAO,CAAC,CAAA,KAAM,CAAC,sBAAA,CAAuB,CAAA,CAAE,IAAI,CAAC,CAAA,CAAE,IAAI,UAAU,CAAA;AACxG,EAAA,MAAM,UAAA,GAAa,gBAAA,CAAiB,YAAA,CAAa,MAAA,GAAS,CAAA,GAAI,YAAA,GAAe,CAAC,EAAE,KAAA,EAAO,MAAA,EAAQ,KAAA,EAAO,WAAA,EAAa,CAAC,CAAA;AACpH,EAAA,MAAM,aAAa,YAAA,CAAa,MAAA,GAAS,CAAA,GAAI,gBAAA,CAAiB,YAAY,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,KAAK,KAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACX,KAAK,SAAA;AAAA,IACL,KAAK,OAAA;AAAA,IACL,KAAK,SAAA;AAAA,IACL,KAAK,UAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACX,KAAK,QAAA;AAAA,IACL,KAAK,SAAA;AACD,MAAA,OAAO,WAAA;AAAA;AAEnB;;;;"}
|
|
1
|
+
{"version":3,"file":"shader-pipeline.js","sources":["../../../../src/material/shader/shader-pipeline.ts"],"sourcesContent":["import { SS } from \"../../engine/gpu-flags.js\";\nimport type { EngineContext } from \"../../engine/engine.js\";\nimport type { RenderTargetSignature } from \"../../engine/render-target.js\";\nimport { targetSignatureKey } from \"../../engine/render-target.js\";\nimport { getSceneBindGroupLayout } from \"../../render/scene-helpers.js\";\nimport { SCENE_UBO_WGSL } from \"../../shader/scene-uniforms.js\";\nimport { computeUboLayout } from \"../../shader/ubo-layout.js\";\nimport type { UboField, UboSpec } from \"../../shader/fragment-types.js\";\nimport type { ShaderAttributeName, ShaderMaterial, ShaderSamplerDecl, ShaderUniformDecl } from \"./shader-material.js\";\nimport { _isShaderSystemUniform } from \"./shader-material.js\";\nimport type { ResolvedStencil } from \"../stencil-state.js\";\nimport type { StencilState } from \"../material.js\";\n\n/** Stencil resolver, installed only by `enableMaterialStencil`. Module-local with a single exported setter:\n * when `enableMaterialStencil` is absent from the bundle the setter tree-shakes, the bundler proves this is\n * always null, and every stencil branch below folds away — stencil-free Shader scenes stay byte-identical. */\nlet _stencilResolver: ((stencil: StencilState) => ResolvedStencil) | null = null;\n/** @internal Install the stencil resolver into the Shader pipeline (called by `enableMaterialStencil`). */\nexport function _installShaderStencilResolver(resolve: (stencil: StencilState) => ResolvedStencil): void {\n _stencilResolver = resolve;\n}\n\nexport interface ShaderPipelineBindings {\n readonly group1BGL: GPUBindGroupLayout;\n readonly systemSpec: UboSpec;\n readonly customSpec: UboSpec | null;\n readonly vertexBuffers: readonly GPUVertexBufferLayout[];\n readonly pipelines: Map<string, GPURenderPipeline>;\n}\n\ninterface ShaderMaterialPipelineState extends ShaderMaterial {\n _shaderDevice?: GPUDevice;\n _shaderBindings?: ShaderPipelineBindings;\n _shaderCustomUbo?: GPUBuffer | null;\n _shaderCustomSpec?: UboSpec | null;\n _shaderCustomData?: ArrayBuffer | null;\n _shaderCustomVersion?: number;\n}\n\nexport function getOrCreateShaderPipelineBindings(engine: EngineContext, material: ShaderMaterial): ShaderPipelineBindings {\n const state = material as ShaderMaterialPipelineState;\n if (state._shaderBindings && state._shaderDevice === engine._device) {\n return state._shaderBindings;\n }\n\n state._shaderDevice = engine._device;\n const systemFields = material.uniformDecls.filter((u) => _isShaderSystemUniform(u.name)).map(toUboField);\n const customFields = material.uniformDecls.filter((u) => !_isShaderSystemUniform(u.name)).map(toUboField);\n const systemSpec = computeUboLayout(systemFields.length > 0 ? systemFields : [{ _name: \"_pad\", _type: \"vec4<f32>\" }]);\n const customSpec = customFields.length > 0 ? computeUboLayout(customFields) : null;\n const group1BGL = engine._device.createBindGroupLayout({\n label: \"shader-material-group1\",\n entries: buildBindGroupLayoutEntries(material.samplerDecls, material.storageBufferDecls, customSpec !== null),\n });\n const bindings: ShaderPipelineBindings = {\n group1BGL,\n systemSpec,\n customSpec,\n vertexBuffers: material.attributes.map(attributeLayout),\n pipelines: new Map(),\n };\n state._shaderBindings = bindings;\n state._shaderCustomSpec = customSpec;\n state._shaderCustomUbo = null;\n state._shaderCustomData = null;\n state._shaderCustomVersion = -1;\n return bindings;\n}\n\nexport function getOrCreateShaderPipeline(\n engine: EngineContext,\n sig: RenderTargetSignature,\n material: ShaderMaterial,\n bindings: ShaderPipelineBindings,\n variantKey = \"\",\n vertexBuffers: readonly GPUVertexBufferLayout[] = bindings.vertexBuffers,\n instanceAttrs = \"\"\n): GPURenderPipeline {\n // `variantKey`, `vertexBuffers` and `instanceAttrs` default to the\n // non-instanced pipeline — byte-for-byte identical behaviour to before\n // instancing existed. The dynamically-imported thin-instance module is the\n // only caller that passes non-default values, so no instancing logic runs\n // for non-instanced scenes.\n const key = `${targetSignatureKey(sig)}${variantKey}`;\n const cached = bindings.pipelines.get(key);\n if (cached) {\n return cached;\n }\n const stencil = material.stencil && _stencilResolver ? _stencilResolver(material.stencil) : null;\n const device = engine._device;\n const prelude = buildShaderPrelude(material, bindings.systemSpec, bindings.customSpec, instanceAttrs);\n const vertModule = device.createShaderModule({ label: `${material.name ?? \"shader\"}-vertex`, code: `${prelude}\\n${material.vertexSource}` });\n const wantsFragment = !!sig._colorFormat || material.depthOnlyFragment;\n const fragModule = wantsFragment ? device.createShaderModule({ label: `${material.name ?? \"shader\"}-fragment`, code: `${prelude}\\n${material.fragmentSource}` }) : null;\n const colorTarget: GPUColorTargetState | null = sig._colorFormat\n ? {\n format: sig._colorFormat,\n ...(material.needAlphaBlending\n ? {\n blend:\n material.blendMode === \"additive\"\n ? ({\n color: { srcFactor: \"src-alpha\", dstFactor: \"one\", operation: \"add\" },\n alpha: { srcFactor: \"one\", dstFactor: \"one\", operation: \"add\" },\n } satisfies GPUBlendState)\n : ({\n color: { srcFactor: \"src-alpha\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" },\n alpha: { srcFactor: \"one\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" },\n } satisfies GPUBlendState),\n }\n : {}),\n }\n : null;\n\n const pipeline = device.createRenderPipeline({\n label: `${material.name ?? \"shader\"}-pipeline`,\n layout: device.createPipelineLayout({ bindGroupLayouts: [getSceneBindGroupLayout(engine), bindings.group1BGL] }),\n vertex: { module: vertModule, entryPoint: \"mainVertex\", buffers: vertexBuffers as GPUVertexBufferLayout[] },\n ...(fragModule ? { fragment: { module: fragModule, entryPoint: \"mainFragment\", targets: colorTarget ? [colorTarget] : [] } } : {}),\n ...(sig._depthStencilFormat\n ? {\n depthStencil: {\n format: sig._depthStencilFormat,\n // The target's declared depth convention wins over the material default: a depth-only\n // caster authored for the forward-Z shadow map (\"less-equal\") must still depth-test\n // correctly when drawn into a reverse-Z camera depth prepass that declares\n // \"greater-equal\" — otherwise every fragment fails against the 0-cleared buffer.\n depthCompare: sig._depthCompare ?? material.depthCompare,\n depthWriteEnabled: material.needAlphaBlending ? false : material.depthWrite,\n ...(material.depthBias ? { depthBias: material.depthBias } : {}),\n ...(material.depthBiasSlopeScale ? { depthBiasSlopeScale: material.depthBiasSlopeScale } : {}),\n // Pre-baked stencil sub-fields, resolved through the opt-in `_stencilResolver` hook above;\n // applied only on a stencil-capable target — a material reused in the depth32float\n // shadow/depth pass keeps plain depth state (no stencil → no format mismatch). `stencil`\n // is a local const that folds to null in stencil-free bundles, so this branch disappears.\n ...(stencil && sig._depthStencilFormat.includes(\"stencil\") ? stencil._desc : {}),\n },\n }\n : {}),\n multisample: { count: sig._sampleCount },\n primitive: { topology: \"triangle-list\", cullMode: material.backFaceCulling ? \"back\" : \"none\", frontFace: \"ccw\" },\n });\n bindings.pipelines.set(key, pipeline);\n return pipeline;\n}\n\nfunction toUboField(decl: ShaderUniformDecl): UboField {\n return { _name: decl.name, _type: decl.type };\n}\n\nfunction buildBindGroupLayoutEntries(\n samplers: readonly ShaderSamplerDecl[],\n storageBuffers: readonly { name: string; type: string }[],\n hasCustomUbo: boolean\n): GPUBindGroupLayoutEntry[] {\n // Local (not module-level): reading the WebGPU flag globals must be deferred until\n // first device/pipeline use so importing the engine never requires them to exist.\n const SHADER_STAGE_ALL = SS.VERTEX | SS.FRAGMENT;\n const entries: GPUBindGroupLayoutEntry[] = [{ binding: 0, visibility: SHADER_STAGE_ALL, buffer: { type: \"uniform\" } }];\n let nextBinding = 1;\n if (hasCustomUbo) {\n entries.push({ binding: nextBinding++, visibility: SHADER_STAGE_ALL, buffer: { type: \"uniform\" } });\n }\n for (const sampler of samplers) {\n const isArray = sampler.viewDimension === \"2d-array\";\n const sampleType = sampler.comparison === true ? \"depth\" : (sampler.sampleType ?? \"float\");\n entries.push({\n binding: nextBinding++,\n visibility: SHADER_STAGE_ALL,\n texture: {\n sampleType,\n viewDimension: isArray ? \"2d-array\" : \"2d\",\n },\n });\n entries.push({\n binding: nextBinding++,\n visibility: SHADER_STAGE_ALL,\n sampler: { type: sampler.comparison === true ? \"comparison\" : sampleType === \"float\" ? \"filtering\" : \"non-filtering\" },\n });\n }\n for (const _storage of storageBuffers) {\n entries.push({\n binding: nextBinding++,\n visibility: SHADER_STAGE_ALL,\n buffer: { type: \"read-only-storage\" },\n });\n }\n return entries;\n}\n\nfunction attributeLayout(name: ShaderAttributeName, shaderLocation: number): GPUVertexBufferLayout {\n switch (name) {\n case \"position\":\n case \"normal\":\n return { arrayStride: 12, attributes: [{ shaderLocation, offset: 0, format: \"float32x3\" }] };\n case \"uv\":\n case \"uv2\":\n return { arrayStride: 8, attributes: [{ shaderLocation, offset: 0, format: \"float32x2\" }] };\n case \"tangent\":\n case \"color\":\n case \"weights\":\n case \"weights1\":\n return { arrayStride: 16, attributes: [{ shaderLocation, offset: 0, format: \"float32x4\" }] };\n case \"joints\":\n case \"joints1\":\n return { arrayStride: 16, attributes: [{ shaderLocation, offset: 0, format: \"uint32x4\" }] };\n }\n}\n\nfunction buildShaderPrelude(material: ShaderMaterial, systemSpec: UboSpec, customSpec: UboSpec | null, instanceAttrs = \"\"): string {\n let wgsl = `${SCENE_UBO_WGSL}\nstruct ShaderSystemUniforms {\n${systemSpec._structBody}\n}\n@group(1) @binding(0) var<uniform> shaderSystem: ShaderSystemUniforms;\n`;\n if (customSpec) {\n wgsl += `struct ShaderUniforms {\n${customSpec._structBody}\n}\n@group(1) @binding(1) var<uniform> shaderUniforms: ShaderUniforms;\n`;\n }\n let nextBinding = customSpec ? 2 : 1;\n for (const sampler of material.samplerDecls) {\n const isArray = sampler.viewDimension === \"2d-array\";\n const isDepth = sampler.comparison === true || sampler.sampleType === \"depth\";\n const texType = isDepth ? (isArray ? \"texture_depth_2d_array\" : \"texture_depth_2d\") : isArray ? \"texture_2d_array<f32>\" : \"texture_2d<f32>\";\n const samplerType = sampler.comparison === true ? \"sampler_comparison\" : \"sampler\";\n wgsl += `@group(1) @binding(${nextBinding++}) var ${sampler.name}: ${texType};\n@group(1) @binding(${nextBinding++}) var ${sampler.name}Sampler: ${samplerType};\n`;\n }\n for (const storage of material.storageBufferDecls) {\n wgsl += `@group(1) @binding(${nextBinding++}) var<storage, read> ${storage.name}: ${storage.type};\n`;\n }\n for (const define of material.defines) {\n wgsl += `const ${define.name}: ${typeof define.value === \"boolean\" ? \"bool\" : \"f32\"} = ${formatDefineValue(define.value)};\n`;\n }\n wgsl += `struct VertexInput {\n`;\n for (let i = 0; i < material.attributes.length; i++) {\n const attr = material.attributes[i]!;\n wgsl += `@location(${i}) ${attr}: ${attributeWgslType(attr)},\n`;\n }\n wgsl += instanceAttrs;\n wgsl += `};\n`;\n return wgsl;\n}\n\nfunction formatDefineValue(value: boolean | number): string {\n if (typeof value === \"boolean\") {\n return value ? \"true\" : \"false\";\n }\n if (Number.isInteger(value)) {\n return `${value}.0`;\n }\n return String(value);\n}\n\nfunction attributeWgslType(name: ShaderAttributeName): string {\n switch (name) {\n case \"position\":\n case \"normal\":\n return \"vec3<f32>\";\n case \"uv\":\n case \"uv2\":\n return \"vec2<f32>\";\n case \"tangent\":\n case \"color\":\n case \"weights\":\n case \"weights1\":\n return \"vec4<f32>\";\n case \"joints\":\n case \"joints1\":\n return \"vec4<u32>\";\n }\n}\n"],"names":[],"mappings":";;;;;;;AAgBA,IAAI,gBAAA,GAAwE,IAAA;AAErE,SAAS,8BAA8B,OAAA,EAA2D;AACrG,EAAA,gBAAA,GAAmB,OAAA;AACvB;AAmBO,SAAS,iCAAA,CAAkC,QAAuB,QAAA,EAAkD;AACvH,EAAA,MAAM,KAAA,GAAQ,QAAA;AACd,EAAA,IAAI,KAAA,CAAM,eAAA,IAAmB,KAAA,CAAM,aAAA,KAAkB,OAAO,OAAA,EAAS;AACjE,IAAA,OAAO,KAAA,CAAM,eAAA;AAAA,EACjB;AAEA,EAAA,KAAA,CAAM,gBAAgB,MAAA,CAAO,OAAA;AAC7B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AAI,CAAA,EAAA,EAAK,iBAAA,CAAkB,IAAI,CAAC,CAAA;AAAA,CAAA;AAAA,EAE/D;AACA,EAAA,IAAA,IAAQ,aAAA;AACR,EAAA,IAAA,IAAQ,CAAA;AAAA,CAAA;AAER,EAAA,OAAO,IAAA;AACX;AAEA,SAAS,kBAAkB,KAAA,EAAiC;AACxD,EAAA,IAAI,OAAO,UAAU,SAAA,EAAW;AAC5B,IAAA,OAAO,QAAQ,MAAA,GAAS,OAAA;AAAA,EAC5B;AACA,EAAA,IAAI,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,EAAG;AACzB,IAAA,OAAO,GAAG,KAAK,CAAA,EAAA,CAAA;AAAA,EACnB;AACA,EAAA,OAAO,OAAO,KAAK,CAAA;AACvB;AAEA,SAAS,kBAAkB,IAAA,EAAmC;AAC1D,EAAA,QAAQ,IAAA;AAAM,IACV,KAAK,UAAA;AAAA,IACL,KAAK,QAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACX,KAAK,IAAA;AAAA,IACL,KAAK,KAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACX,KAAK,SAAA;AAAA,IACL,KAAK,OAAA;AAAA,IACL,KAAK,SAAA;AAAA,IACL,KAAK,UAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACX,KAAK,QAAA;AAAA,IACL,KAAK,SAAA;AACD,MAAA,OAAO,WAAA;AAAA;AAEnB;;;;"}
|
|
@@ -52,14 +52,14 @@ function buildMaterialRenderables(scene, material, meshes, isOverride = false) {
|
|
|
52
52
|
const engine = scene.surface.engine;
|
|
53
53
|
const bindings = getOrCreateShaderPipelineBindings(engine, material);
|
|
54
54
|
ensureCustomUbo(engine, material, bindings.customSpec);
|
|
55
|
-
const packets = meshes.map((mesh) => createPacket(scene, material, bindings.systemSpec, mesh));
|
|
55
|
+
const packets = meshes.map((mesh) => createPacket(scene, material, bindings.systemSpec, mesh, isOverride));
|
|
56
56
|
const isTransparent = material.needAlphaBlending;
|
|
57
57
|
if (isTransparent) {
|
|
58
58
|
return packets.map((packet) => createTransparentRenderable(scene, material, packet, isOverride));
|
|
59
59
|
}
|
|
60
60
|
return [createOpaqueRenderable(scene, material, packets, isOverride)];
|
|
61
61
|
}
|
|
62
|
-
function createPacket(scene, material, systemSpec, mesh) {
|
|
62
|
+
function createPacket(scene, material, systemSpec, mesh, aux = false) {
|
|
63
63
|
const engine = scene.surface.engine;
|
|
64
64
|
const systemUBO = createEmptyUniformBuffer(engine, systemSpec._totalBytes, "shader-system-ubo");
|
|
65
65
|
const systemData = new F32(systemSpec._totalBytes / 4);
|
|
@@ -77,7 +77,7 @@ function createPacket(scene, material, systemSpec, mesh) {
|
|
|
77
77
|
for (const tex of packet._boundTextures) {
|
|
78
78
|
acquireTexture(tex);
|
|
79
79
|
}
|
|
80
|
-
registerMeshTextureDisposer(scene, mesh, packet);
|
|
80
|
+
registerMeshTextureDisposer(scene, mesh, packet, aux);
|
|
81
81
|
return packet;
|
|
82
82
|
}
|
|
83
83
|
function createOpaqueRenderable(scene, material, packets, isOverride) {
|
|
@@ -166,8 +166,22 @@ function createTransparentRenderable(scene, material, packet, isOverride) {
|
|
|
166
166
|
function updatePacket(scene, material, packet, context) {
|
|
167
167
|
const engine = scene.surface.engine;
|
|
168
168
|
const state = material;
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
const camera = context._camera ?? scene.camera;
|
|
170
|
+
const cameraVersion = camera ? camera.worldMatrixVersion : -1;
|
|
171
|
+
const meshWmVersion = packet.mesh.worldMatrixVersion;
|
|
172
|
+
const alphaCutoff = material._uniformValues.get("alphaCutoff")?.value[0] ?? 0.4;
|
|
173
|
+
const aspect = camera ? getEffectiveAspectRatio(camera, context.targetWidth, context.targetHeight) : 1;
|
|
174
|
+
if (packet._lastCamera !== camera || packet._lastCameraVersion !== cameraVersion || packet._lastMeshWmVersion !== meshWmVersion || packet._lastTargetWidth !== context.targetWidth || packet._lastTargetHeight !== context.targetHeight || packet._lastAspect !== aspect || packet._lastAlphaCutoff !== alphaCutoff) {
|
|
175
|
+
writeSystemUniforms(packet.systemData, state._shaderBindings.systemSpec, material, packet.mesh, camera, context.targetWidth, context.targetHeight);
|
|
176
|
+
engine._device.queue.writeBuffer(packet.systemUBO, 0, packet.systemData);
|
|
177
|
+
packet._lastCamera = camera;
|
|
178
|
+
packet._lastCameraVersion = cameraVersion;
|
|
179
|
+
packet._lastMeshWmVersion = meshWmVersion;
|
|
180
|
+
packet._lastTargetWidth = context.targetWidth;
|
|
181
|
+
packet._lastTargetHeight = context.targetHeight;
|
|
182
|
+
packet._lastAspect = aspect;
|
|
183
|
+
packet._lastAlphaCutoff = alphaCutoff;
|
|
184
|
+
}
|
|
171
185
|
if (packet._lastResourceVersion !== material._resourceVersion) {
|
|
172
186
|
const newTextures = collectShaderTextures(material);
|
|
173
187
|
for (const tex of newTextures) {
|
|
@@ -285,8 +299,9 @@ function collectShaderStorageBuffers(material) {
|
|
|
285
299
|
}
|
|
286
300
|
return buffers;
|
|
287
301
|
}
|
|
288
|
-
function registerMeshTextureDisposer(scene, mesh, packet) {
|
|
289
|
-
const
|
|
302
|
+
function registerMeshTextureDisposer(scene, mesh, packet, aux = false) {
|
|
303
|
+
const map = aux ? scene._meshAuxDisposables : scene._meshDisposables;
|
|
304
|
+
const list = map.get(mesh) ?? [];
|
|
290
305
|
list.push(() => {
|
|
291
306
|
packet._disposed = true;
|
|
292
307
|
if (packet._owner) {
|
|
@@ -303,7 +318,7 @@ function registerMeshTextureDisposer(scene, mesh, packet) {
|
|
|
303
318
|
packet._boundTextures = [];
|
|
304
319
|
packet._boundStorageBuffers = [];
|
|
305
320
|
});
|
|
306
|
-
|
|
321
|
+
map.set(mesh, list);
|
|
307
322
|
}
|
|
308
323
|
function writeSystemUniforms(data, spec, material, mesh, camera, targetWidth, targetHeight) {
|
|
309
324
|
data.fill(0);
|