@zephyr3d/editor 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/assets/{index-ySiLtSxz.js → index-BZ1L8ggE.js} +43 -3
  2. package/dist/assistant/zephyr-types-index.json +13230 -9488
  3. package/dist/images/icon1024.png +0 -0
  4. package/dist/index.html +1 -1
  5. package/dist/modules/zephyr3d_backend-webgl.js +2 -0
  6. package/dist/modules/zephyr3d_backend-webgl.js.map +1 -1
  7. package/dist/modules/zephyr3d_backend-webgpu.js +457 -16
  8. package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
  9. package/dist/modules/zephyr3d_device.js +27 -0
  10. package/dist/modules/zephyr3d_device.js.map +1 -1
  11. package/dist/modules/zephyr3d_loaders.js +208 -1
  12. package/dist/modules/zephyr3d_loaders.js.map +1 -1
  13. package/dist/modules/zephyr3d_scene.js +774 -80
  14. package/dist/modules/zephyr3d_scene.js.map +1 -1
  15. package/dist/vendor/zephyr3d/backend-webgl/dist/capabilities_webgl.js +2 -0
  16. package/dist/vendor/zephyr3d/backend-webgl/dist/capabilities_webgl.js.map +1 -1
  17. package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js +2 -0
  18. package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js.map +1 -1
  19. package/dist/vendor/zephyr3d/backend-webgpu/dist/commandqueue.js +55 -10
  20. package/dist/vendor/zephyr3d/backend-webgpu/dist/commandqueue.js.map +1 -1
  21. package/dist/vendor/zephyr3d/backend-webgpu/dist/computepass_webgpu.js +4 -0
  22. package/dist/vendor/zephyr3d/backend-webgpu/dist/computepass_webgpu.js.map +1 -1
  23. package/dist/vendor/zephyr3d/backend-webgpu/dist/device.js +44 -1
  24. package/dist/vendor/zephyr3d/backend-webgpu/dist/device.js.map +1 -1
  25. package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js +58 -5
  26. package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js.map +1 -1
  27. package/dist/vendor/zephyr3d/backend-webgpu/dist/timestamp_query.js +297 -0
  28. package/dist/vendor/zephyr3d/backend-webgpu/dist/timestamp_query.js.map +1 -0
  29. package/dist/vendor/zephyr3d/device/dist/base_types.js.map +1 -1
  30. package/dist/vendor/zephyr3d/device/dist/device.js +27 -0
  31. package/dist/vendor/zephyr3d/device/dist/device.js.map +1 -1
  32. package/dist/vendor/zephyr3d/device/dist/index.d.ts +81 -1
  33. package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js +208 -1
  34. package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js.map +1 -1
  35. package/dist/vendor/zephyr3d/loaders/dist/index.d.ts +8 -0
  36. package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js +334 -63
  37. package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js.map +1 -1
  38. package/dist/vendor/zephyr3d/scene/dist/animation/morphtargetgrouptrack.js +66 -0
  39. package/dist/vendor/zephyr3d/scene/dist/animation/morphtargetgrouptrack.js.map +1 -0
  40. package/dist/vendor/zephyr3d/scene/dist/asset/model.js +9 -0
  41. package/dist/vendor/zephyr3d/scene/dist/asset/model.js.map +1 -1
  42. package/dist/vendor/zephyr3d/scene/dist/index.d.ts +260 -4
  43. package/dist/vendor/zephyr3d/scene/dist/index.js +7 -0
  44. package/dist/vendor/zephyr3d/scene/dist/index.js.map +1 -1
  45. package/dist/vendor/zephyr3d/scene/dist/posteffect/sao.js +1 -1
  46. package/dist/vendor/zephyr3d/scene/dist/posteffect/sao.js.map +1 -1
  47. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/executor.js +270 -1
  48. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/executor.js.map +1 -1
  49. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/forward_plus_builder.js +19 -1
  50. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  51. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/types.js.map +1 -1
  52. package/dist/vendor/zephyr3d/scene/dist/scene/scene.js +1 -0
  53. package/dist/vendor/zephyr3d/scene/dist/scene/scene.js.map +1 -1
  54. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js +2 -1
  55. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js.map +1 -1
  56. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js +70 -1
  57. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js.map +1 -1
  58. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
  59. package/package.json +6 -6
  60. package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js +0 -320
  61. package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"forward_plus_builder.js","sources":["../../../src/render/rendergraph/forward_plus_builder.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { Vector4 } from '@zephyr3d/base';\r\nimport type {\r\n BindGroup,\r\n ColorState,\r\n FrameBuffer,\r\n GPUProgram,\r\n Texture2D,\r\n TextureFormat\r\n} from '@zephyr3d/device';\r\nimport type { DrawContext } from '../drawable';\r\nimport {\r\n RenderQueue,\r\n type RenderItemList,\r\n type RenderItemListInfo,\r\n type RenderQueueItem\r\n} from '../render_queue';\r\nimport type { PunctualLight, Scene } from '../../scene';\r\nimport type { Camera } from '../../camera';\r\nimport { LightPass } from '../lightpass';\r\nimport { ShadowMapPass } from '../shadowmap_pass';\r\nimport { DepthPass } from '../depthpass';\r\nimport { ClusteredLight } from '../cluster_light';\r\nimport { buildHiZ } from '../hzb';\r\nimport { CopyBlitter } from '../../blitter';\r\nimport { fetchSampler } from '../../utility/misc';\r\nimport { MaterialVaryingFlags } from '../../values';\r\nimport { AbstractPostEffect, PostEffectLayer } from '../../posteffect/posteffect';\r\nimport { RenderGraph } from './rendergraph';\r\nimport { RenderGraphExecutor } from './executor';\r\nimport { DevicePoolAllocator } from './device_pool_allocator';\r\nimport { HistoryResourceManager } from './history_resource_manager';\r\nimport { RGHistoryResources } from './history_resources';\r\nimport type { RGExecuteContext, RGHandle } from './types';\r\nimport { renderObjectColors } from '../gpu_picking';\r\nimport type { Primitive } from '../primitive';\r\nimport { BoxShape } from '../../shapes';\r\n\r\n// ─── Shared Pass Instances ──────────────────────────────────────────\r\n\r\nconst _scenePass = new LightPass();\r\nconst _depthPass = new DepthPass();\r\nconst _shadowMapPass = new ShadowMapPass();\r\nconst _clusters: ClusteredLight[] = [];\r\nconst _devicePoolAllocator = new DevicePoolAllocator();\r\nlet _backDepthColorState: Nullable<ColorState> = null;\r\nlet _frontDepthColorState: Nullable<ColorState> = null;\r\nconst SURFACE_MRT_FLAGS =\r\n MaterialVaryingFlags.SSR_STORE_ROUGHNESS |\r\n MaterialVaryingFlags.SSS_STORE_PROFILE |\r\n MaterialVaryingFlags.SSS_STORE_DIFFUSE |\r\n MaterialVaryingFlags.SSS_STORE_NORMAL |\r\n MaterialVaryingFlags.SSS_STORE_TRANSMISSION;\r\n\r\nfunction getClusteredLight(): ClusteredLight {\r\n return _clusters.length > 0 ? _clusters.pop()! : new ClusteredLight();\r\n}\r\nfunction freeClusteredLight(cl: ClusteredLight): void {\r\n _clusters.push(cl);\r\n}\r\n\r\nfunction getCoreMaterial(material: unknown): unknown {\r\n return (material as { coreMaterial?: unknown } | null | undefined)?.coreMaterial ?? material ?? null;\r\n}\r\n\r\nfunction hasSSSMaterialCore(material: unknown): boolean {\r\n return !!(getCoreMaterial(material) as { subsurfaceProfile?: unknown } | null)?.subsurfaceProfile;\r\n}\r\n\r\nfunction renderQueueHasActiveSSS(renderQueue: RenderQueue): boolean {\r\n const itemList = renderQueue.itemList;\r\n if (!itemList) {\r\n return false;\r\n }\r\n const lists = [...itemList.opaque.lit, ...itemList.opaque.unlit];\r\n for (const list of lists) {\r\n for (const material of list.materialList) {\r\n if (hasSSSMaterialCore(material)) {\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\nfunction filterActualSSSItemList(items: RenderQueueItem[]): RenderQueueItem[] {\r\n return items.filter((item) => hasSSSMaterialCore(item.drawable.getMaterial?.()));\r\n}\r\n\r\nfunction filterActualSSSMaterialList(materialList: Set<any>): Set<any> {\r\n const filtered = new Set<any>();\r\n materialList.forEach((mat) => {\r\n if (hasSSSMaterialCore(mat)) {\r\n filtered.add(mat);\r\n }\r\n });\r\n return filtered;\r\n}\r\n\r\nfunction cloneActualSSSListInfo(source: RenderItemListInfo, _targetQueue: RenderQueue): RenderItemListInfo {\r\n return {\r\n itemList: filterActualSSSItemList(source.itemList),\r\n skinItemList: filterActualSSSItemList(source.skinItemList),\r\n morphItemList: filterActualSSSItemList(source.morphItemList),\r\n skinAndMorphItemList: filterActualSSSItemList(source.skinAndMorphItemList),\r\n instanceItemList: filterActualSSSItemList(source.instanceItemList),\r\n materialList: filterActualSSSMaterialList(source.materialList),\r\n instanceList: {},\r\n renderQueue: source.renderQueue\r\n };\r\n}\r\n\r\nfunction cloneActualSSSBundle(\r\n source: RenderItemList['opaque'],\r\n targetQueue: RenderQueue\r\n): RenderItemList['opaque'] {\r\n return {\r\n lit: source.lit.map((info) => cloneActualSSSListInfo(info, targetQueue)),\r\n unlit: source.unlit.map((info) => cloneActualSSSListInfo(info, targetQueue))\r\n };\r\n}\r\n\r\nfunction hasAnyActualSSSItems(renderItems: RenderItemListInfo[]): boolean {\r\n return renderItems.some(\r\n (info) =>\r\n info.itemList.length > 0 ||\r\n info.skinItemList.length > 0 ||\r\n info.morphItemList.length > 0 ||\r\n info.skinAndMorphItemList.length > 0 ||\r\n info.instanceItemList.length > 0\r\n );\r\n}\r\n\r\nfunction createActualSSSRenderQueue(renderQueue: RenderQueue): RenderQueue | null {\r\n const itemList = renderQueue.itemList;\r\n if (!itemList) {\r\n return null;\r\n }\r\n const queue = new RenderQueue(_scenePass);\r\n const sssOpaque = cloneActualSSSBundle(itemList.opaque, queue);\r\n if (!hasAnyActualSSSItems([...sssOpaque.lit, ...sssOpaque.unlit])) {\r\n queue.dispose();\r\n return null;\r\n }\r\n const emptyBundle = { lit: [], unlit: [] };\r\n const target = queue as unknown as {\r\n _itemList: RenderItemList;\r\n _shadowedLightList: PunctualLight[];\r\n _unshadowedLightList: PunctualLight[];\r\n _sunLight: typeof renderQueue.sunLight;\r\n _primaryDirectionalLight: typeof renderQueue.primaryDirectionalLight;\r\n _primaryTransmissionLight: typeof renderQueue.primaryTransmissionLight;\r\n _needSceneColor: boolean;\r\n _needSceneDepth: boolean;\r\n _needSceneColorWithDepth: boolean;\r\n _drawTransparent: boolean;\r\n };\r\n target._itemList = {\r\n opaque: sssOpaque,\r\n transmission: emptyBundle,\r\n transparent: emptyBundle,\r\n transmission_trans: emptyBundle\r\n };\r\n target._shadowedLightList = renderQueue.shadowedLights;\r\n target._unshadowedLightList = renderQueue.unshadowedLights;\r\n target._sunLight = renderQueue.sunLight;\r\n target._primaryDirectionalLight = renderQueue.primaryDirectionalLight;\r\n target._primaryTransmissionLight = renderQueue.primaryTransmissionLight;\r\n target._needSceneColor = false;\r\n target._needSceneDepth = false;\r\n target._needSceneColorWithDepth = false;\r\n target._drawTransparent = false;\r\n return queue;\r\n}\r\n\r\nfunction getSurfaceTextureFormat(ctx: DrawContext): TextureFormat {\r\n const caps = ctx.device.getDeviceCaps?.();\r\n return caps?.textureCaps.supportHalfFloatColorBuffer ? 'rgba16f' : 'rgba8unorm';\r\n}\r\n\r\nfunction getTextureFormatBytes(ctx: DrawContext, format: TextureFormat): number {\r\n return ctx.device.getDeviceCaps().textureCaps.getTextureFormatInfo(format).size;\r\n}\r\n\r\nfunction shouldStoreSSSDiffuse(ctx: DrawContext): boolean {\r\n return ctx.camera.sssStrength > 0 && ctx.camera.sssBlurScale > 0;\r\n}\r\n\r\nfunction shouldStoreSSSTransmission(ctx: DrawContext): boolean {\r\n return ctx.camera.sssStrength > 0 && ctx.camera.sssTransmissionStrength > 0;\r\n}\r\n\r\nfunction getSSSLightingTextureFormat(\r\n ctx: DrawContext,\r\n attachmentCount: number,\r\n includeSSRSurfaceMRT: boolean\r\n): TextureFormat {\r\n const colorFormat = ctx.colorFormat!;\r\n if (!includeSSRSurfaceMRT || attachmentCount === 0) {\r\n return colorFormat;\r\n }\r\n const caps = ctx.device.getDeviceCaps();\r\n const roughnessFormat = ctx.SSRRoughnessTexture?.format ?? colorFormat;\r\n const normalFormat = ctx.SSRNormalTexture?.format ?? colorFormat;\r\n const colorBytes =\r\n getTextureFormatBytes(ctx, colorFormat) +\r\n getTextureFormatBytes(ctx, roughnessFormat) +\r\n getTextureFormatBytes(ctx, normalFormat);\r\n const fullPrecisionBytes = colorBytes + getTextureFormatBytes(ctx, colorFormat) * attachmentCount;\r\n if (fullPrecisionBytes <= caps.framebufferCaps.maxColorAttachmentBytesPerSample) {\r\n return colorFormat;\r\n }\r\n return 'rgba8unorm';\r\n}\r\n\r\nfunction getFullMipLevelCount(width: number, height: number): number {\r\n return Math.max(1, Math.floor(Math.log2(Math.max(1, width, height))) + 1);\r\n}\r\n\r\nfunction hasSurfaceMRT(ctx: DrawContext): boolean {\r\n return !!(ctx.materialFlags & SURFACE_MRT_FLAGS);\r\n}\r\n\r\nfunction getLightPassColorAttachments(\r\n ctx: DrawContext,\r\n colorAttachment: TextureFormat | Texture2D\r\n): TextureFormat | Texture2D | Array<TextureFormat | Texture2D> {\r\n const attachments: Array<TextureFormat | Texture2D> = [colorAttachment];\r\n if (ctx.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {\r\n attachments.push(ctx.SSRRoughnessTexture!, ctx.SSRNormalTexture!);\r\n } else if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_NORMAL) {\r\n attachments.push(ctx.SSRNormalTexture!);\r\n }\r\n if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_PROFILE) {\r\n attachments.push(ctx.SSSProfileTexture!, ctx.SSSParamTexture!);\r\n }\r\n if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_DIFFUSE) {\r\n attachments.push(ctx.SSSDiffuseTexture!);\r\n }\r\n if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_TRANSMISSION) {\r\n attachments.push(ctx.SSSTransmissionTexture!);\r\n }\r\n return attachments.length === 1 ? attachments[0] : attachments;\r\n}\r\n\r\n// ─── Pipeline Options ───────────────────────────────────────────────\r\n\r\n/**\r\n * Options controlling which features are enabled in the forward+ pipeline.\r\n *\r\n * Derived from camera settings and device capabilities each frame.\r\n *\r\n * @public\r\n */\r\nexport interface ForwardPlusOptions {\r\n /** Enable depth prepass (always true for now). */\r\n depthPrepass: boolean;\r\n /** Enable motion vectors (requires TAA or motionBlur). */\r\n motionVectors: boolean;\r\n /** Enable Hi-Z pyramid (for SSR ray tracing). */\r\n hiZ: boolean;\r\n /** Enable screen-space reflections. */\r\n ssr: boolean;\r\n /** Whether to compute SSR thickness. */\r\n ssrCalcThickness: boolean;\r\n /** Whether GPU picking is requested this frame. */\r\n gpuPicking: boolean;\r\n /** Whether transmission/refraction materials are present. */\r\n needSceneColor: boolean;\r\n /** Whether scene-color-dependent materials also require scene depth. */\r\n needSceneColorWithDepth: boolean;\r\n /** Whether SSR needs transmission depth before the main light pass. */\r\n needsTransmissionDepthForSSR: boolean;\r\n /** Enable screen-space subsurface scattering. */\r\n sss: boolean;\r\n}\r\n\r\n/**\r\n * Derive pipeline options from the current scene/camera state.\r\n * @internal\r\n */\r\nexport function deriveForwardPlusOptions(\r\n scene: Scene,\r\n camera: Camera,\r\n deviceType: string,\r\n renderQueue: RenderQueue\r\n): ForwardPlusOptions {\r\n const ssr = camera.SSR && scene.env.light.envLight && scene.env.light.envLight.hasRadiance();\r\n const sss = camera.SSS && renderQueueHasActiveSSS(renderQueue);\r\n const needSceneColor = renderQueue.needSceneColor();\r\n const needSceneColorWithDepth = renderQueue.needSceneColorWithDepth();\r\n return {\r\n depthPrepass: true,\r\n motionVectors:\r\n deviceType !== 'webgl' && (camera.TAA || camera.motionBlur || (!!ssr && camera.ssrTemporal)),\r\n hiZ: camera.HiZ && deviceType !== 'webgl',\r\n ssr: !!ssr,\r\n ssrCalcThickness: !!ssr && camera.ssrCalcThickness,\r\n gpuPicking: !!camera.getPickResultResolveFunc(),\r\n needSceneColor,\r\n needSceneColorWithDepth,\r\n needsTransmissionDepthForSSR: !!ssr && needSceneColor && !needSceneColorWithDepth,\r\n sss: !!sss\r\n };\r\n}\r\n\r\n// ─── Shared Frame State ─────────────────────────────────────────────\r\n\r\n/**\r\n * Mutable state shared between pass execute callbacks within a single frame.\r\n *\r\n * This replaces the monolithic DrawContext mutation pattern with an explicit\r\n * object that graph passes can read from and write to.\r\n *\r\n * @internal\r\n */\r\nexport interface FrameState {\r\n ctx: DrawContext;\r\n renderQueue: RenderQueue;\r\n depthFramebuffer: Nullable<FrameBuffer>;\r\n sunLightColor: Nullable<any>;\r\n options: ForwardPlusOptions;\r\n intermediateDeviceStatePushed: boolean;\r\n renderQueueDisposed: boolean;\r\n clusteredLightReleased: boolean;\r\n sunLightRestored: boolean;\r\n}\r\n\r\ninterface ForwardPlusGraphBuildResult {\r\n backbuffer: RGHandle;\r\n frame: FrameState;\r\n}\r\n\r\ninterface HistoryReadBinding {\r\n name: string;\r\n handle: RGHandle;\r\n}\r\n\r\ninterface SSSProfilePassResult {\r\n profileHandle: RGHandle;\r\n paramHandle: RGHandle;\r\n normalHandle?: RGHandle;\r\n framebufferHandle: RGHandle;\r\n}\r\n\r\n// ─── Forward+ Graph Builder ─────────────────────────────────────────\r\n\r\n/**\r\n * Constructs a render graph representing the forward+ pipeline.\r\n *\r\n * Each step in the existing `SceneRenderer._renderScene` becomes a graph pass.\r\n * Execute callbacks delegate to the existing rendering code, sharing a mutable\r\n * `FrameState`.\r\n *\r\n * @param graph - The render graph to populate.\r\n * @param ctx - The draw context for this frame.\r\n * @param renderQueue - The culled render queue.\r\n * @param options - Pipeline feature toggles.\r\n * @returns The backbuffer handle (graph output).\r\n *\r\n * @public\r\n */\r\nexport function buildForwardPlusGraph(\r\n graph: RenderGraph,\r\n ctx: DrawContext,\r\n renderQueue: RenderQueue,\r\n options: ForwardPlusOptions\r\n): RGHandle {\r\n return buildForwardPlusGraphInternal(graph, ctx, renderQueue, options).backbuffer;\r\n}\r\n\r\nfunction buildForwardPlusGraphInternal(\r\n graph: RenderGraph,\r\n ctx: DrawContext,\r\n renderQueue: RenderQueue,\r\n options: ForwardPlusOptions\r\n): ForwardPlusGraphBuildResult {\r\n const backbuffer = graph.importTexture('backbuffer');\r\n ctx.SSS = !!options.sss;\r\n\r\n // Shared mutable frame state\r\n const frame: FrameState = {\r\n ctx,\r\n renderQueue,\r\n depthFramebuffer: null,\r\n sunLightColor: null,\r\n options,\r\n intermediateDeviceStatePushed: false,\r\n renderQueueDisposed: false,\r\n clusteredLightReleased: false,\r\n sunLightRestored: false\r\n };\r\n\r\n // ── 1. Sky Update ─────────────────────────────────────────────────\r\n let orderToken = graph.addPass('SkyUpdate', (builder) => {\r\n const done = builder.createToken('SkyUpdateDone');\r\n builder.sideEffect();\r\n builder.setExecute(() => {\r\n frame.sunLightColor = ctx.scene.env.sky.update(ctx);\r\n });\r\n return done;\r\n });\r\n\r\n // ── 2. Clustered Light Setup ──────────────────────────────────────\r\n orderToken = graph.addPass('ClusterLights', (builder) => {\r\n builder.read(orderToken);\r\n const done = builder.createToken('ClusterLightsDone');\r\n builder.sideEffect();\r\n builder.setExecute(() => {\r\n ctx.clusteredLight = getClusteredLight();\r\n ctx.clusteredLight.calculateLightIndex(ctx.camera, renderQueue);\r\n });\r\n return done;\r\n });\r\n\r\n // ── 3. GPU Picking (optional, sideEffect) ─────────────────────────\r\n if (options.gpuPicking) {\r\n orderToken = graph.addPass('GPUPicking', (builder) => {\r\n builder.read(orderToken);\r\n const done = builder.createToken('GPUPickingDone');\r\n builder.sideEffect();\r\n builder.setExecute(() => {\r\n const pickResolveFunc = ctx.camera.getPickResultResolveFunc();\r\n if (pickResolveFunc) {\r\n renderObjectColors(ctx, pickResolveFunc, renderQueue);\r\n }\r\n });\r\n return done;\r\n });\r\n }\r\n\r\n // ── 4. Shadow Maps ────────────────────────────────────────────────\r\n // Shadow maps are managed internally by lights, mark as side effect\r\n if (renderQueue.shadowedLights.length > 0) {\r\n orderToken = graph.addPass('ShadowMaps', (builder) => {\r\n builder.read(orderToken);\r\n const done = builder.createToken('ShadowMapsDone');\r\n builder.sideEffect();\r\n builder.setExecute(() => {\r\n renderShadowMaps(ctx, renderQueue.shadowedLights);\r\n });\r\n return done;\r\n });\r\n }\r\n\r\n // ── 5. Depth Prepass ──────────────────────────────────────────────\r\n // Declare transient depth and motion vector textures\r\n const depthPassResult = graph.addPass('DepthPrepass', (builder) => {\r\n builder.read(orderToken);\r\n const format: TextureFormat =\r\n ctx.device.type === 'webgl'\r\n ? ctx.SSRCalcThickness\r\n ? 'rgba16f'\r\n : 'rgba8unorm'\r\n : ctx.SSRCalcThickness\r\n ? 'rg32f'\r\n : 'r32f';\r\n const mvFormat: TextureFormat = 'rgba16f';\r\n\r\n const depthHandle = builder.createTexture({ format, label: 'linearDepth' });\r\n const motionVectorHandle = options.motionVectors\r\n ? builder.createTexture({ format: mvFormat, label: 'motionVector' })\r\n : undefined;\r\n const finalDepthAttachment = ctx.finalFramebuffer?.getDepthAttachment();\r\n const externalDepthAttachment = finalDepthAttachment?.isTexture2D()\r\n ? (finalDepthAttachment as Texture2D)\r\n : null;\r\n const graphDepthAttachmentHandle = externalDepthAttachment\r\n ? undefined\r\n : builder.createTexture({ format: ctx.depthFormat, label: 'sceneDepth' });\r\n const depthAttachmentOrFormat = externalDepthAttachment ?? graphDepthAttachmentHandle ?? ctx.depthFormat;\r\n const depthFramebufferHandle = builder.createFramebuffer({\r\n label: 'DepthPrepassFramebuffer',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: motionVectorHandle ? [depthHandle, motionVectorHandle] : depthHandle,\r\n depthAttachment: depthAttachmentOrFormat,\r\n ignoreDepthStencil: false\r\n });\r\n const skyMotionVectorFramebufferHandle = motionVectorHandle\r\n ? builder.createFramebuffer({\r\n label: 'SkyMotionVectorFramebuffer',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: motionVectorHandle,\r\n depthAttachment: depthAttachmentOrFormat\r\n })\r\n : undefined;\r\n\r\n builder.addSubpass('SceneDepth', (rgCtx) => {\r\n const depthFramebuffer = rgCtx.getFramebuffer<FrameBuffer>(depthFramebufferHandle);\r\n frame.depthFramebuffer = renderSceneDepth(frame, depthFramebuffer, rgCtx, undefined, undefined, false);\r\n });\r\n if (skyMotionVectorFramebufferHandle) {\r\n builder.addSubpass('SkyMotionVectors', (rgCtx) => {\r\n renderSkyMotionVectors(ctx, rgCtx, skyMotionVectorFramebufferHandle);\r\n });\r\n }\r\n\r\n return {\r\n depthHandle,\r\n motionVectorHandle,\r\n graphDepthAttachmentHandle,\r\n externalDepthAttachment,\r\n depthFramebufferHandle\r\n };\r\n });\r\n\r\n const depthHandle = depthPassResult.depthHandle;\r\n const motionVectorHandle = depthPassResult.motionVectorHandle;\r\n const renderDepthAttachment =\r\n depthPassResult.graphDepthAttachmentHandle ?? depthPassResult.externalDepthAttachment ?? null;\r\n\r\n let preLightTransmissionDepthToken: RGHandle | undefined;\r\n if (options.needsTransmissionDepthForSSR) {\r\n preLightTransmissionDepthToken = graph.addPass('TransmissionDepthForSSR', (builder) => {\r\n builder.read(depthPassResult.depthFramebufferHandle);\r\n const done = builder.createToken('TransmissionDepthForSSRDone');\r\n builder.sideEffect();\r\n builder.setExecute((rgCtx) => {\r\n renderTransmissionDepthPass(frame, rgCtx);\r\n });\r\n return done;\r\n });\r\n }\r\n\r\n // ── 6. Hi-Z (optional) ───────────────────────────────────────────\r\n let hiZHandle: RGHandle | undefined;\r\n if (options.hiZ) {\r\n graph.addPass('HiZ', (builder) => {\r\n builder.read(depthHandle!);\r\n builder.read(depthPassResult.depthFramebufferHandle);\r\n if (preLightTransmissionDepthToken) {\r\n builder.read(preLightTransmissionDepthToken);\r\n }\r\n hiZHandle = builder.createTexture({\r\n format: 'r32f',\r\n label: 'hiZ',\r\n mipLevels: getFullMipLevelCount(ctx.renderWidth, ctx.renderHeight)\r\n });\r\n const hiZFramebufferHandle = builder.createFramebuffer({\r\n label: 'HiZFramebuffer',\r\n colorAttachments: hiZHandle,\r\n depthAttachment: null\r\n });\r\n builder.setExecute((rgCtx) => {\r\n const ctx = frame.ctx;\r\n // Use the depth texture from the framebuffer (which contains the RenderGraph texture)\r\n const depthTex = frame.depthFramebuffer?.getDepthAttachment() as Texture2D;\r\n if (depthTex) {\r\n // Get the HiZ texture allocated by the executor\r\n const hiZTex = rgCtx.getTexture<Texture2D>(hiZHandle!);\r\n const HiZFrameBuffer = rgCtx.getFramebuffer<FrameBuffer>(hiZFramebufferHandle);\r\n buildHiZ(depthTex, HiZFrameBuffer);\r\n ctx.HiZTexture = hiZTex;\r\n }\r\n });\r\n });\r\n }\r\n\r\n // ── 7. Main Light Pass ────────────────────────────────────────────\r\n const historyManager = ctx.camera?.getHistoryResourceManager?.() ?? null;\r\n const lightHistoryReadBindings: HistoryReadBinding[] = [];\r\n const compositeHistoryReadBindings: HistoryReadBinding[] = [];\r\n const historySize = { width: ctx.renderWidth, height: ctx.renderHeight };\r\n if (historyManager && options.ssr && ctx.camera?.ssrTemporal && options.motionVectors) {\r\n const reflectHistoryHandle = historyManager.importPreviousIfCompatible(\r\n graph,\r\n RGHistoryResources.SSR_REFLECT,\r\n {\r\n format: 'rgba16f',\r\n sizeMode: 'absolute',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight\r\n },\r\n historySize\r\n );\r\n const motionVectorHistoryHandle = historyManager.importPreviousIfCompatible(\r\n graph,\r\n RGHistoryResources.SSR_MOTION_VECTOR,\r\n {\r\n format: 'rgba16f',\r\n sizeMode: 'absolute',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight\r\n },\r\n historySize\r\n );\r\n if (reflectHistoryHandle && motionVectorHistoryHandle) {\r\n lightHistoryReadBindings.push(\r\n { name: RGHistoryResources.SSR_REFLECT, handle: reflectHistoryHandle },\r\n { name: RGHistoryResources.SSR_MOTION_VECTOR, handle: motionVectorHistoryHandle }\r\n );\r\n }\r\n }\r\n if (historyManager && ctx.camera?.TAA && options.motionVectors) {\r\n const colorHistoryHandle = historyManager.importPreviousIfCompatible(\r\n graph,\r\n RGHistoryResources.TAA_COLOR,\r\n {\r\n format: ctx.colorFormat!,\r\n sizeMode: 'absolute',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight\r\n },\r\n historySize\r\n );\r\n const motionVectorHistoryHandle = historyManager.importPreviousIfCompatible(\r\n graph,\r\n RGHistoryResources.TAA_MOTION_VECTOR,\r\n {\r\n format: 'rgba16f',\r\n sizeMode: 'absolute',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight\r\n },\r\n historySize\r\n );\r\n if (colorHistoryHandle && motionVectorHistoryHandle) {\r\n compositeHistoryReadBindings.push(\r\n { name: RGHistoryResources.TAA_COLOR, handle: colorHistoryHandle },\r\n { name: RGHistoryResources.TAA_MOTION_VECTOR, handle: motionVectorHistoryHandle }\r\n );\r\n }\r\n }\r\n\r\n let sssProfileResult: SSSProfilePassResult | undefined;\r\n if (options.sss) {\r\n sssProfileResult = graph.addPass('SSSProfile', (builder) => {\r\n builder.read(depthHandle);\r\n builder.read(depthPassResult.depthFramebufferHandle);\r\n if (preLightTransmissionDepthToken) {\r\n builder.read(preLightTransmissionDepthToken);\r\n }\r\n const profileHandle = builder.createTexture({ format: 'rgba16f', label: 'sssProfile' });\r\n const paramHandle = builder.createTexture({ format: 'rgba8unorm', label: 'sssParam' });\r\n const normalHandle = options.ssr\r\n ? undefined\r\n : builder.createTexture({ format: getSurfaceTextureFormat(ctx), label: 'sssNormal' });\r\n const colorAttachments = normalHandle\r\n ? [ctx.colorFormat!, normalHandle, profileHandle, paramHandle]\r\n : [ctx.colorFormat!, profileHandle, paramHandle];\r\n const framebufferHandle = builder.createFramebuffer({\r\n label: 'SSSProfileFramebuffer',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments,\r\n depthAttachment: renderDepthAttachment,\r\n ignoreDepthStencil: false\r\n });\r\n\r\n builder.setExecute((rgCtx) => {\r\n renderForwardSSSProfile(\r\n frame,\r\n rgCtx.getFramebuffer<FrameBuffer>(framebufferHandle),\r\n rgCtx.getTexture<Texture2D>(profileHandle),\r\n rgCtx.getTexture<Texture2D>(paramHandle),\r\n normalHandle ? rgCtx.getTexture<Texture2D>(normalHandle) : null\r\n );\r\n });\r\n\r\n return {\r\n profileHandle,\r\n paramHandle,\r\n normalHandle,\r\n framebufferHandle\r\n };\r\n });\r\n }\r\n\r\n const lightPassResult = graph.addPass('LightPass', (builder) => {\r\n builder.read(depthHandle);\r\n builder.read(depthPassResult.depthFramebufferHandle);\r\n if (preLightTransmissionDepthToken) {\r\n builder.read(preLightTransmissionDepthToken);\r\n }\r\n if (hiZHandle) {\r\n builder.read(hiZHandle);\r\n }\r\n for (const binding of lightHistoryReadBindings) {\r\n builder.read(binding.handle);\r\n }\r\n\r\n // Create scene color texture (intermediate render target)\r\n const sceneColorHandle = builder.createTexture({\r\n format: ctx.colorFormat!,\r\n label: 'sceneColor'\r\n });\r\n\r\n // Create optional sceneColorCopy for transmission/refraction materials\r\n let sceneColorCopyHandle: RGHandle | undefined;\r\n if (options.needSceneColor) {\r\n sceneColorCopyHandle = builder.createTexture({\r\n format: ctx.colorFormat!,\r\n label: 'sceneColorCopy'\r\n });\r\n }\r\n if (sssProfileResult) {\r\n builder.read(sssProfileResult.profileHandle);\r\n builder.read(sssProfileResult.paramHandle);\r\n if (sssProfileResult.normalHandle) {\r\n builder.read(sssProfileResult.normalHandle);\r\n }\r\n }\r\n const includeSSRSurfaceMRT = !!options.ssr;\r\n const writeSSSDiffuse = options.sss && shouldStoreSSSDiffuse(ctx);\r\n let writeSSSTransmission = options.sss && shouldStoreSSSTransmission(ctx);\r\n if (\r\n writeSSSDiffuse &&\r\n writeSSSTransmission &&\r\n includeSSRSurfaceMRT &&\r\n getSSSLightingTextureFormat(ctx, 2, includeSSRSurfaceMRT) !== ctx.colorFormat\r\n ) {\r\n writeSSSTransmission = false;\r\n }\r\n const sssLightingAttachmentCount = (writeSSSDiffuse ? 1 : 0) + (writeSSSTransmission ? 1 : 0);\r\n const sssLightingFormat = getSSSLightingTextureFormat(\r\n ctx,\r\n sssLightingAttachmentCount,\r\n includeSSRSurfaceMRT\r\n );\r\n const sssDiffuseHandle = writeSSSDiffuse\r\n ? builder.createTexture({ format: sssLightingFormat, label: 'sssDiffuse' })\r\n : undefined;\r\n const sssTransmissionHandle = writeSSSTransmission\r\n ? builder.createTexture({ format: sssLightingFormat, label: 'sssTransmission' })\r\n : undefined;\r\n const useFinalFramebufferAsIntermediate =\r\n !!depthPassResult.externalDepthAttachment &&\r\n depthPassResult.externalDepthAttachment === ctx.finalFramebuffer?.getDepthAttachment();\r\n const sceneColorFramebufferHandle = useFinalFramebufferAsIntermediate\r\n ? undefined\r\n : builder.createFramebuffer({\r\n label: 'SceneColorFramebuffer',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: sceneColorHandle,\r\n depthAttachment: renderDepthAttachment\r\n });\r\n // SSR may pre-insert transmission depth before LightPass for Hi-Z. In that case the\r\n // refraction scene-color copy needs an isolated depth buffer so transmission surfaces\r\n // do not occlude the background color they are about to sample.\r\n const sceneColorCopyFramebufferHandle =\r\n sceneColorCopyHandle && !options.needsTransmissionDepthForSSR\r\n ? builder.createFramebuffer({\r\n label: 'SceneColorCopyFramebuffer',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: sceneColorCopyHandle,\r\n depthAttachment: renderDepthAttachment,\r\n ignoreDepthStencil: false\r\n })\r\n : undefined;\r\n\r\n builder.setExecute((rgCtx) => {\r\n const sceneColorTex = rgCtx.getTexture<Texture2D>(sceneColorHandle);\r\n const sceneColorCopyTex = sceneColorCopyHandle\r\n ? rgCtx.getTexture<Texture2D>(sceneColorCopyHandle)\r\n : null;\r\n if (sssProfileResult) {\r\n ctx.SSSProfileTexture = rgCtx.getTexture<Texture2D>(sssProfileResult.profileHandle);\r\n ctx.SSSParamTexture = rgCtx.getTexture<Texture2D>(sssProfileResult.paramHandle);\r\n if (sssProfileResult.normalHandle) {\r\n ctx.SSRNormalTexture = rgCtx.getTexture<Texture2D>(sssProfileResult.normalHandle);\r\n }\r\n }\r\n ctx.SSSDiffuseTexture = sssDiffuseHandle ? rgCtx.getTexture<Texture2D>(sssDiffuseHandle) : null;\r\n ctx.SSSTransmissionTexture = sssTransmissionHandle\r\n ? rgCtx.getTexture<Texture2D>(sssTransmissionHandle)\r\n : null;\r\n const renderLightPass = () =>\r\n renderMainLightPass(\r\n frame,\r\n sceneColorTex,\r\n sceneColorCopyTex,\r\n rgCtx,\r\n sceneColorFramebufferHandle,\r\n sceneColorCopyFramebufferHandle\r\n );\r\n if (historyManager && lightHistoryReadBindings.length > 0) {\r\n historyManager.beginReadScope(\r\n lightHistoryReadBindings.map((binding) => ({\r\n name: binding.name,\r\n texture: rgCtx.getTexture<Texture2D>(binding.handle)\r\n }))\r\n );\r\n try {\r\n renderLightPass();\r\n } finally {\r\n historyManager.endReadScope();\r\n }\r\n } else {\r\n renderLightPass();\r\n }\r\n });\r\n\r\n return { sceneColorHandle, sceneColorCopyHandle, sceneColorFramebufferHandle };\r\n });\r\n\r\n const sceneColorHandle = lightPassResult.sceneColorHandle;\r\n\r\n // 8. Transmission depth pass (optional)\r\n let transmissionDepthToken: RGHandle | undefined;\r\n if (options.needSceneColor && !options.needsTransmissionDepthForSSR) {\r\n transmissionDepthToken = graph.addPass('TransmissionDepth', (builder) => {\r\n builder.read(sceneColorHandle);\r\n builder.read(depthPassResult.depthFramebufferHandle);\r\n const done = builder.createToken('TransmissionDepthDone');\r\n builder.sideEffect();\r\n builder.setExecute((rgCtx) => {\r\n renderTransmissionDepthPass(frame, rgCtx);\r\n });\r\n return done;\r\n });\r\n }\r\n\r\n // 9. Post effects + final composite\r\n const presentedBackbuffer = graph.addPass('Composite', (builder) => {\r\n builder.read(sceneColorHandle);\r\n builder.read(depthHandle);\r\n if (hiZHandle) {\r\n builder.read(hiZHandle);\r\n }\r\n if (motionVectorHandle) {\r\n builder.read(motionVectorHandle);\r\n }\r\n if (lightPassResult.sceneColorFramebufferHandle) {\r\n builder.read(lightPassResult.sceneColorFramebufferHandle);\r\n }\r\n if (transmissionDepthToken) {\r\n builder.read(transmissionDepthToken);\r\n }\r\n for (const binding of compositeHistoryReadBindings) {\r\n builder.read(binding.handle);\r\n }\r\n const outputBackbuffer = builder.write(backbuffer);\r\n builder.setExecute((rgCtx) => {\r\n if (historyManager && compositeHistoryReadBindings.length > 0) {\r\n historyManager.beginReadScope(\r\n compositeHistoryReadBindings.map((binding) => ({\r\n name: binding.name,\r\n texture: rgCtx.getTexture<Texture2D>(binding.handle)\r\n }))\r\n );\r\n try {\r\n renderComposite(frame);\r\n } finally {\r\n historyManager.endReadScope();\r\n }\r\n } else {\r\n renderComposite(frame);\r\n }\r\n });\r\n return outputBackbuffer;\r\n });\r\n\r\n return { backbuffer: presentedBackbuffer, frame };\r\n}\r\n\r\n// ─── Pass Implementation Helpers ────────────────────────────────────\r\n// These wrap the existing SceneRenderer static methods, adapted to work\r\n// with the FrameState pattern. They contain the same logic as the\r\n// original methods but read/write through FrameState.\r\n\r\n/** @internal */\r\nfunction renderShadowMaps(ctx: DrawContext, lights: PunctualLight[]): void {\r\n ctx.renderPass = _shadowMapPass;\r\n ctx.device.pushDeviceStates();\r\n try {\r\n for (const light of lights) {\r\n light.shadow.render(ctx, _shadowMapPass);\r\n }\r\n } finally {\r\n ctx.device.popDeviceStates();\r\n }\r\n}\r\n\r\nfunction renderForwardSSSProfile(\r\n frame: FrameState,\r\n profileFramebuffer: FrameBuffer,\r\n profileTexture: Texture2D,\r\n paramTexture: Texture2D,\r\n normalTexture: Nullable<Texture2D>\r\n): void {\r\n const { ctx, renderQueue } = frame;\r\n if (!ctx.SSS || !ctx.depthTexture) {\r\n return;\r\n }\r\n const sssRenderQueue = createActualSSSRenderQueue(renderQueue);\r\n if (!sssRenderQueue) {\r\n return;\r\n }\r\n\r\n const device = ctx.device;\r\n const savedMaterialFlags = ctx.materialFlags;\r\n const savedCompositor = ctx.compositor;\r\n const savedTransmission = _scenePass.transmission;\r\n const savedRenderOpaque = _scenePass.renderOpaque;\r\n const savedRenderTransparent = _scenePass.renderTransparent;\r\n const savedClearColor = _scenePass.clearColor;\r\n const savedClearDepth = _scenePass.clearDepth;\r\n const savedClearStencil = _scenePass.clearStencil;\r\n const savedCommandBufferReuse = ctx.camera.commandBufferReuse;\r\n const savedProfileTexture = ctx.SSSProfileTexture;\r\n const savedParamTexture = ctx.SSSParamTexture;\r\n const savedNormalTexture = ctx.SSRNormalTexture;\r\n\r\n let profileFlags = MaterialVaryingFlags.SSS_STORE_PROFILE;\r\n if (normalTexture) {\r\n profileFlags |= MaterialVaryingFlags.SSS_STORE_NORMAL;\r\n }\r\n\r\n device.pushDeviceStates();\r\n try {\r\n device.setFramebuffer(profileFramebuffer);\r\n ctx.SSSProfileTexture = profileTexture;\r\n ctx.SSSParamTexture = paramTexture;\r\n ctx.SSRNormalTexture = normalTexture;\r\n ctx.compositor = null;\r\n ctx.camera.commandBufferReuse = false;\r\n ctx.materialFlags =\r\n (ctx.materialFlags &\r\n ~(\r\n MaterialVaryingFlags.SSR_STORE_ROUGHNESS |\r\n MaterialVaryingFlags.SSS_STORE_PROFILE |\r\n MaterialVaryingFlags.SSS_STORE_NORMAL |\r\n MaterialVaryingFlags.SSS_STORE_DIFFUSE |\r\n MaterialVaryingFlags.SSS_STORE_TRANSMISSION\r\n )) |\r\n profileFlags;\r\n _scenePass.transmission = false;\r\n _scenePass.renderOpaque = true;\r\n _scenePass.renderTransparent = false;\r\n _scenePass.clearColor = Vector4.zero();\r\n _scenePass.clearDepth = null;\r\n _scenePass.clearStencil = null;\r\n _scenePass.render(ctx, null, null, sssRenderQueue);\r\n } finally {\r\n _scenePass.clearColor = savedClearColor;\r\n _scenePass.clearDepth = savedClearDepth;\r\n _scenePass.clearStencil = savedClearStencil;\r\n _scenePass.renderTransparent = savedRenderTransparent;\r\n _scenePass.renderOpaque = savedRenderOpaque;\r\n _scenePass.transmission = savedTransmission;\r\n ctx.camera.commandBufferReuse = savedCommandBufferReuse;\r\n ctx.materialFlags = savedMaterialFlags;\r\n ctx.compositor = savedCompositor;\r\n ctx.SSSProfileTexture = savedProfileTexture;\r\n ctx.SSSParamTexture = savedParamTexture;\r\n ctx.SSRNormalTexture = savedNormalTexture;\r\n device.popDeviceStates();\r\n sssRenderQueue.dispose();\r\n }\r\n}\r\n\r\nfunction releaseIntermediateFramebuffer(frame: FrameState): void {\r\n const { ctx } = frame;\r\n if (frame.intermediateDeviceStatePushed) {\r\n ctx.device.popDeviceStates();\r\n frame.intermediateDeviceStatePushed = false;\r\n }\r\n ctx.intermediateFramebuffer = null;\r\n}\r\n\r\nfunction releaseDepthFramebuffer(frame: FrameState): void {\r\n frame.depthFramebuffer = null;\r\n}\r\n\r\nfunction disposeRenderQueue(frame: FrameState): void {\r\n if (!frame.renderQueueDisposed) {\r\n frame.renderQueue.dispose();\r\n frame.renderQueueDisposed = true;\r\n }\r\n}\r\n\r\nfunction releaseClusteredLight(frame: FrameState): void {\r\n if (!frame.clusteredLightReleased && frame.ctx.clusteredLight) {\r\n freeClusteredLight(frame.ctx.clusteredLight);\r\n frame.ctx.clusteredLight = undefined;\r\n frame.clusteredLightReleased = true;\r\n }\r\n}\r\n\r\nfunction restoreSunLight(frame: FrameState): void {\r\n if (!frame.sunLightRestored && frame.sunLightColor && frame.ctx.sunLight) {\r\n frame.ctx.sunLight.color = frame.sunLightColor;\r\n frame.sunLightRestored = true;\r\n }\r\n}\r\n\r\nfunction cleanupFrame(frame: FrameState): void {\r\n releaseIntermediateFramebuffer(frame);\r\n releaseDepthFramebuffer(frame);\r\n releaseClusteredLight(frame);\r\n disposeRenderQueue(frame);\r\n restoreSunLight(frame);\r\n}\r\n\r\n/** @internal */\r\nfunction renderSceneDepth(\r\n frame: FrameState,\r\n existingDepthFb: Nullable<FrameBuffer>,\r\n rgCtx: RGExecuteContext,\r\n depthTex?: Texture2D,\r\n motionVectorTex?: Nullable<Texture2D>,\r\n transmissionOverride?: boolean\r\n): FrameBuffer {\r\n const ctx = frame.ctx;\r\n const renderQueue = frame.renderQueue;\r\n const transmission = transmissionOverride ?? !!existingDepthFb;\r\n let depthFramebuffer = existingDepthFb;\r\n\r\n if (!depthFramebuffer) {\r\n // Use RenderGraph-allocated textures if provided\r\n if (depthTex) {\r\n const colorAttachments = motionVectorTex ? [depthTex, motionVectorTex] : depthTex;\r\n const depthAttachment = ctx.finalFramebuffer?.getDepthAttachment();\r\n const depthTexOrFormat = depthAttachment?.isTexture2D() ? depthAttachment : ctx.depthFormat;\r\n\r\n depthFramebuffer = rgCtx.createFramebuffer<FrameBuffer>({\r\n width: depthTex.width,\r\n height: depthTex.height,\r\n colorAttachments,\r\n depthAttachment: depthTexOrFormat,\r\n ignoreDepthStencil: false\r\n });\r\n } else {\r\n // Allocate through RenderGraph so framebuffer lifetime is owned by the executor.\r\n const format: TextureFormat =\r\n ctx.device.type === 'webgl'\r\n ? ctx.SSRCalcThickness\r\n ? 'rgba16f'\r\n : 'rgba8unorm'\r\n : ctx.SSRCalcThickness\r\n ? 'rg32f'\r\n : 'r32f';\r\n const mvFormat: TextureFormat = 'rgba16f';\r\n if (!ctx.finalFramebuffer) {\r\n depthFramebuffer = rgCtx.createFramebuffer<FrameBuffer>({\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: ctx.motionVectors ? [format, mvFormat] : format,\r\n depthAttachment: ctx.depthFormat,\r\n ignoreDepthStencil: false\r\n });\r\n } else {\r\n const originDepth = ctx.finalFramebuffer?.getDepthAttachment();\r\n if (originDepth?.isTexture2D()) {\r\n depthFramebuffer = rgCtx.createFramebuffer<FrameBuffer>({\r\n width: originDepth.width,\r\n height: originDepth.height,\r\n colorAttachments: ctx.motionVectors ? [format, mvFormat] : format,\r\n depthAttachment: originDepth,\r\n ignoreDepthStencil: false\r\n });\r\n } else {\r\n depthFramebuffer = rgCtx.createFramebuffer<FrameBuffer>({\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: ctx.motionVectors ? [format, mvFormat] : format,\r\n depthAttachment: ctx.depthFormat,\r\n ignoreDepthStencil: false\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (!transmission) {\r\n frame.depthFramebuffer = depthFramebuffer!;\r\n }\r\n\r\n ctx.device.pushDeviceStates();\r\n try {\r\n ctx.device.setFramebuffer(depthFramebuffer!);\r\n _depthPass.encodeDepth = depthFramebuffer!.getColorAttachments()[0].format === 'rgba8unorm';\r\n _depthPass.clearColor = transmission\r\n ? null\r\n : _depthPass.encodeDepth\r\n ? new Vector4(0, 0, 0, 1)\r\n : new Vector4(1, 1, 1, 1);\r\n _depthPass.clearDepth = transmission ? null : 1;\r\n _depthPass.clearStencil = null;\r\n _depthPass.transmission = transmission;\r\n\r\n if (ctx.SSRCalcThickness && !transmission) {\r\n if (!_backDepthColorState) {\r\n _backDepthColorState = ctx.device.createColorState().setColorMask(false, true, false, false);\r\n }\r\n if (!_frontDepthColorState) {\r\n _frontDepthColorState = ctx.device.createColorState().setColorMask(true, false, false, false);\r\n }\r\n ctx.forceColorState = _backDepthColorState;\r\n ctx.forceCullMode = 'front';\r\n _depthPass.renderBackface = true;\r\n _depthPass.transmission = false;\r\n _depthPass.render(ctx, null, null, renderQueue);\r\n _depthPass.clearColor = null;\r\n _depthPass.renderBackface = false;\r\n ctx.forceColorState = _frontDepthColorState;\r\n ctx.forceCullMode = null;\r\n }\r\n _depthPass.render(ctx, null, null, renderQueue);\r\n } finally {\r\n ctx.forceColorState = null;\r\n ctx.forceCullMode = null;\r\n _depthPass.renderBackface = false;\r\n ctx.device.popDeviceStates();\r\n }\r\n\r\n if (!transmission) {\r\n ctx.motionVectorTexture = ctx.motionVectors\r\n ? (depthFramebuffer!.getColorAttachments()[1] as Texture2D)\r\n : null;\r\n ctx.linearDepthTexture = depthFramebuffer!.getColorAttachments()[0] as Texture2D;\r\n ctx.depthTexture = depthFramebuffer!.getDepthAttachment() as Texture2D;\r\n ctx.depthPrepassAttachment = ctx.depthTexture;\r\n // HiZ is now built in the dedicated HiZ pass\r\n }\r\n return depthFramebuffer!;\r\n}\r\n\r\n// ─── Sky Motion Vector State ────────────────────────────────────────\r\n\r\nlet _skyMVProgram: Nullable<GPUProgram> = null;\r\nlet _skyMVBindGroup: Nullable<BindGroup> = null;\r\nlet _skyMVBox: Nullable<Primitive> = null;\r\n\r\n/** @internal */\r\nfunction renderSkyMotionVectors(\r\n ctx: DrawContext,\r\n rgCtx: RGExecuteContext,\r\n framebufferHandle?: RGHandle\r\n): void {\r\n if (!ctx.motionVectorTexture) {\r\n return;\r\n }\r\n\r\n const device = ctx.device;\r\n const fb = framebufferHandle\r\n ? rgCtx.getFramebuffer<FrameBuffer>(framebufferHandle)\r\n : rgCtx.createFramebuffer<FrameBuffer>({\r\n colorAttachments: ctx.motionVectorTexture,\r\n depthAttachment: ctx.depthTexture\r\n });\r\n\r\n if (!_skyMVProgram) {\r\n _skyMVProgram = device.buildRenderProgram({\r\n vertex(pb) {\r\n this.$inputs.pos = pb.vec3().attrib('position');\r\n this.VPMatrix = pb.mat4().uniform(0);\r\n this.prevVPMatrix = pb.mat4().uniform(0);\r\n this.cameraPos = pb.vec3().uniform(0);\r\n this.prevCameraPos = pb.vec3().uniform(0);\r\n pb.main(function () {\r\n this.$l.worldPos = pb.add(this.$inputs.pos, this.cameraPos);\r\n this.$l.prevWorldPos = pb.add(this.$inputs.pos, this.prevCameraPos);\r\n this.$l.clipPos = pb.mul(this.VPMatrix, pb.vec4(this.worldPos, 1));\r\n this.$l.prevClipPos = pb.mul(this.prevVPMatrix, pb.vec4(this.prevWorldPos, 1));\r\n this.clipPos.z = this.clipPos.w;\r\n this.$builtins.position = this.clipPos;\r\n this.$outputs.currentPos = this.clipPos;\r\n this.$outputs.prevPos = this.prevClipPos;\r\n });\r\n },\r\n fragment(pb) {\r\n this.$outputs.color = pb.vec4();\r\n pb.main(function () {\r\n this.$l.motionVector = pb.mul(\r\n pb.sub(\r\n pb.div(this.$inputs.currentPos.xy, this.$inputs.currentPos.w),\r\n pb.div(this.$inputs.prevPos.xy, this.$inputs.prevPos.w)\r\n ),\r\n 0.5\r\n );\r\n this.$outputs.color = pb.vec4(this.motionVector, 0, 1);\r\n });\r\n }\r\n })!;\r\n _skyMVProgram.name = '@TAA_SkyMotionVector';\r\n }\r\n\r\n if (!_skyMVBindGroup) {\r\n _skyMVBindGroup = device.createBindGroup(_skyMVProgram.bindGroupLayouts[0]);\r\n }\r\n\r\n if (!_skyMVBox) {\r\n _skyMVBox = new BoxShape({ size: 2, needNormal: false, needUV: false });\r\n }\r\n\r\n _skyMVBindGroup.setValue('VPMatrix', ctx.camera.viewProjectionMatrix);\r\n _skyMVBindGroup.setValue('prevVPMatrix', ctx.camera.prevVPMatrix!);\r\n _skyMVBindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());\r\n _skyMVBindGroup.setValue('prevCameraPos', ctx.camera.prevPosition!);\r\n\r\n device.pushDeviceStates();\r\n device.setProgram(_skyMVProgram);\r\n device.setBindGroup(0, _skyMVBindGroup);\r\n device.setRenderStates(AbstractPostEffect.getDefaultRenderState(ctx, 'le'));\r\n device.setFramebuffer(fb);\r\n _skyMVBox.draw();\r\n device.popDeviceStates();\r\n}\r\n\r\nfunction blitToCurrentColorAttachment(ctx: DrawContext, source: Texture2D): void {\r\n const framebuffer = ctx.device.getFramebuffer();\r\n const destination = framebuffer?.getColorAttachment<Texture2D>(0) ?? null;\r\n new CopyBlitter().blit(source, destination, fetchSampler('clamp_nearest_nomip'));\r\n}\r\n\r\n/** @internal */\r\nfunction renderMainLightPass(\r\n frame: FrameState,\r\n sceneColorTex: Texture2D,\r\n sceneColorCopyTex: Nullable<Texture2D>,\r\n rgCtx: RGExecuteContext,\r\n sceneColorFramebufferHandle?: RGHandle,\r\n sceneColorCopyFramebufferHandle?: RGHandle\r\n): void {\r\n const { ctx, renderQueue } = frame;\r\n const device = ctx.device;\r\n\r\n // Use RenderGraph-allocated scene color texture\r\n const depthTex = frame.depthFramebuffer?.getDepthAttachment() as Texture2D;\r\n\r\n ctx.materialFlags &= ~(\r\n MaterialVaryingFlags.SSR_STORE_ROUGHNESS |\r\n MaterialVaryingFlags.SSS_STORE_PROFILE |\r\n MaterialVaryingFlags.SSS_STORE_DIFFUSE |\r\n MaterialVaryingFlags.SSS_STORE_NORMAL |\r\n MaterialVaryingFlags.SSS_STORE_TRANSMISSION\r\n );\r\n\r\n if (ctx.SSR) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SSR_STORE_ROUGHNESS;\r\n }\r\n if (ctx.SSS) {\r\n if (ctx.SSSDiffuseTexture) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SSS_STORE_DIFFUSE;\r\n }\r\n if (ctx.SSSTransmissionTexture) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SSS_STORE_TRANSMISSION;\r\n }\r\n }\r\n\r\n if (depthTex === ctx.finalFramebuffer?.getDepthAttachment()) {\r\n ctx.intermediateFramebuffer = ctx.finalFramebuffer;\r\n } else if (sceneColorFramebufferHandle && !hasSurfaceMRT(ctx)) {\r\n ctx.intermediateFramebuffer = rgCtx.getFramebuffer<FrameBuffer>(sceneColorFramebufferHandle);\r\n } else {\r\n ctx.intermediateFramebuffer = rgCtx.createFramebuffer<FrameBuffer>({\r\n width: sceneColorTex.width,\r\n height: sceneColorTex.height,\r\n colorAttachments: getLightPassColorAttachments(ctx, sceneColorTex),\r\n depthAttachment: depthTex\r\n });\r\n }\r\n\r\n if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {\r\n device.pushDeviceStates();\r\n frame.intermediateDeviceStatePushed = true;\r\n device.setFramebuffer(ctx.intermediateFramebuffer);\r\n } else {\r\n device.setViewport(null);\r\n device.setScissor(null);\r\n }\r\n\r\n _scenePass.transmission = false;\r\n _scenePass.clearDepth = depthTex ? null : 1;\r\n _scenePass.clearStencil = depthTex ? null : 0;\r\n\r\n ctx.compositor?.begin(ctx);\r\n\r\n if (renderQueue.needSceneColor() && sceneColorCopyTex) {\r\n const compositor = ctx.compositor;\r\n ctx.compositor = null;\r\n const isolateSceneColorDepth = frame.options.needsTransmissionDepthForSSR;\r\n const savedDepthPrepassAttachment = ctx.depthPrepassAttachment;\r\n const savedClearDepth = _scenePass.clearDepth;\r\n const savedClearStencil = _scenePass.clearStencil;\r\n const savedMaterialFlags = ctx.materialFlags;\r\n\r\n // Use RenderGraph-allocated sceneColorCopy texture\r\n const sceneColorMaterialFlags = ctx.materialFlags & ~SURFACE_MRT_FLAGS;\r\n const sceneColorFramebuffer = sceneColorCopyFramebufferHandle\r\n ? rgCtx.getFramebuffer<FrameBuffer>(sceneColorCopyFramebufferHandle)\r\n : rgCtx.createFramebuffer<FrameBuffer>({\r\n width: sceneColorCopyTex.width,\r\n height: sceneColorCopyTex.height,\r\n colorAttachments: sceneColorCopyTex,\r\n depthAttachment: isolateSceneColorDepth ? ctx.depthFormat : depthTex,\r\n ignoreDepthStencil: false\r\n });\r\n let sceneColorStatePushed = false;\r\n try {\r\n device.pushDeviceStates();\r\n sceneColorStatePushed = true;\r\n device.setFramebuffer(sceneColorFramebuffer);\r\n _scenePass.transmission = false;\r\n if (isolateSceneColorDepth) {\r\n ctx.depthPrepassAttachment = undefined;\r\n _scenePass.clearDepth = 1;\r\n _scenePass.clearStencil = 0;\r\n }\r\n ctx.materialFlags = sceneColorMaterialFlags;\r\n _scenePass.render(ctx, null, null, renderQueue);\r\n } finally {\r\n ctx.materialFlags = savedMaterialFlags;\r\n if (isolateSceneColorDepth) {\r\n ctx.depthPrepassAttachment = savedDepthPrepassAttachment;\r\n _scenePass.clearDepth = savedClearDepth;\r\n _scenePass.clearStencil = savedClearStencil;\r\n }\r\n if (sceneColorStatePushed) {\r\n device.popDeviceStates();\r\n }\r\n ctx.compositor = compositor;\r\n }\r\n ctx.sceneColorTexture = sceneColorCopyTex;\r\n blitToCurrentColorAttachment(ctx, ctx.sceneColorTexture);\r\n _scenePass.transmission = true;\r\n _scenePass.clearColor = null;\r\n _scenePass.clearDepth = null;\r\n _scenePass.clearStencil = null;\r\n }\r\n _scenePass.render(ctx, null, null, renderQueue);\r\n}\r\n\r\n/** @internal */\r\nfunction renderTransmissionDepthPass(frame: FrameState, rgCtx: RGExecuteContext): void {\r\n renderSceneDepth(frame, frame.depthFramebuffer, rgCtx);\r\n}\r\n\r\n/** @internal */\r\nfunction renderComposite(frame: FrameState): void {\r\n const { ctx } = frame;\r\n\r\n ctx.compositor?.drawPostEffects(ctx, PostEffectLayer.end, ctx.linearDepthTexture!);\r\n ctx.compositor?.end(ctx);\r\n disposeRenderQueue(frame);\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSR_STORE_ROUGHNESS;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_PROFILE;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_DIFFUSE;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_NORMAL;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_TRANSMISSION;\r\n\r\n if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {\r\n const blitter = new CopyBlitter();\r\n blitter.srgbOut = !ctx.finalFramebuffer;\r\n const srcTex = ctx.intermediateFramebuffer.getColorAttachments()[0] as Texture2D;\r\n blitter.blit(srcTex, ctx.finalFramebuffer ?? null, fetchSampler('clamp_nearest_nomip'));\r\n }\r\n\r\n releaseIntermediateFramebuffer(frame);\r\n releaseDepthFramebuffer(frame);\r\n releaseClusteredLight(frame);\r\n restoreSunLight(frame);\r\n}\r\n\r\n// ─── Convenience: Execute Full Pipeline ─────────────────────────────\r\n\r\n/**\r\n * Build, compile, and execute the forward+ pipeline as a render graph.\r\n *\r\n * This is the drop-in replacement for `SceneRenderer._renderScene`.\r\n *\r\n * @param ctx - The draw context for this frame.\r\n * @public\r\n */\r\nexport function executeForwardPlusGraph(ctx: DrawContext): void {\r\n const device = ctx.device;\r\n const graph = new RenderGraph();\r\n let renderQueue: RenderQueue | null = null;\r\n let frame: FrameState | null = null;\r\n let executor: RenderGraphExecutor<Texture2D, FrameBuffer> | null = null;\r\n let historyManager: HistoryResourceManager<Texture2D> | null = null;\r\n let historyFrameStarted = false;\r\n\r\n try {\r\n // Cull scene first (needed to derive options)\r\n renderQueue = _scenePass.cullScene(ctx, ctx.camera);\r\n\r\n const options = deriveForwardPlusOptions(ctx.scene, ctx.camera, device.type, renderQueue);\r\n ctx.SSS = options.sss;\r\n\r\n // Ensure the camera has a history resource manager for temporal effects (TAA, motion blur)\r\n historyManager = ctx.camera.getHistoryResourceManager();\r\n if (!historyManager) {\r\n historyManager = new HistoryResourceManager<Texture2D>(_devicePoolAllocator);\r\n ctx.camera.setHistoryResourceManager(historyManager);\r\n }\r\n historyManager.beginFrame();\r\n historyFrameStarted = true;\r\n\r\n const buildResult = buildForwardPlusGraphInternal(graph, ctx, renderQueue, options);\r\n frame = buildResult.frame;\r\n\r\n const compiled = graph.compile([buildResult.backbuffer]);\r\n\r\n // Use RenderGraphExecutor for automatic resource management\r\n executor = new RenderGraphExecutor(_devicePoolAllocator, ctx.renderWidth, ctx.renderHeight);\r\n\r\n // Register imported backbuffer (if using finalFramebuffer)\r\n if (ctx.finalFramebuffer) {\r\n const backbufferTex = ctx.finalFramebuffer.getColorAttachments()[0] as Texture2D;\r\n executor.setImportedTexture(buildResult.backbuffer, backbufferTex);\r\n }\r\n historyManager.bindImportedTextures(executor);\r\n\r\n executor.execute(compiled);\r\n historyManager.commitFrame();\r\n } finally {\r\n if (historyFrameStarted) {\r\n historyManager?.discardFrame();\r\n }\r\n if (frame) {\r\n cleanupFrame(frame);\r\n } else {\r\n renderQueue?.dispose();\r\n }\r\n executor?.reset();\r\n }\r\n}\r\n"],"names":["_scenePass","LightPass","_depthPass","DepthPass","_shadowMapPass","ShadowMapPass","_clusters","_devicePoolAllocator","DevicePoolAllocator","_backDepthColorState","_frontDepthColorState","SURFACE_MRT_FLAGS","MaterialVaryingFlags","SSR_STORE_ROUGHNESS","SSS_STORE_PROFILE","SSS_STORE_DIFFUSE","SSS_STORE_NORMAL","SSS_STORE_TRANSMISSION","getClusteredLight","length","pop","ClusteredLight","freeClusteredLight","cl","push","getCoreMaterial","material","coreMaterial","hasSSSMaterialCore","subsurfaceProfile","renderQueueHasActiveSSS","renderQueue","itemList","lists","opaque","lit","unlit","list","materialList","filterActualSSSItemList","items","filter","item","drawable","getMaterial","filterActualSSSMaterialList","filtered","Set","forEach","mat","add","cloneActualSSSListInfo","source","_targetQueue","skinItemList","morphItemList","skinAndMorphItemList","instanceItemList","instanceList","cloneActualSSSBundle","targetQueue","map","info","hasAnyActualSSSItems","renderItems","some","createActualSSSRenderQueue","queue","RenderQueue","sssOpaque","dispose","emptyBundle","target","_itemList","transmission","transparent","transmission_trans","_shadowedLightList","shadowedLights","_unshadowedLightList","unshadowedLights","_sunLight","sunLight","_primaryDirectionalLight","primaryDirectionalLight","_primaryTransmissionLight","primaryTransmissionLight","_needSceneColor","_needSceneDepth","_needSceneColorWithDepth","_drawTransparent","getSurfaceTextureFormat","ctx","caps","device","getDeviceCaps","textureCaps","supportHalfFloatColorBuffer","getTextureFormatBytes","format","getTextureFormatInfo","size","shouldStoreSSSDiffuse","camera","sssStrength","sssBlurScale","shouldStoreSSSTransmission","sssTransmissionStrength","getSSSLightingTextureFormat","attachmentCount","includeSSRSurfaceMRT","colorFormat","roughnessFormat","SSRRoughnessTexture","normalFormat","SSRNormalTexture","colorBytes","fullPrecisionBytes","framebufferCaps","maxColorAttachmentBytesPerSample","getFullMipLevelCount","width","height","Math","max","floor","log2","hasSurfaceMRT","materialFlags","getLightPassColorAttachments","colorAttachment","attachments","SSSProfileTexture","SSSParamTexture","SSSDiffuseTexture","SSSTransmissionTexture","deriveForwardPlusOptions","scene","deviceType","ssr","SSR","env","light","envLight","hasRadiance","sss","SSS","needSceneColor","needSceneColorWithDepth","depthPrepass","motionVectors","TAA","motionBlur","ssrTemporal","hiZ","HiZ","ssrCalcThickness","gpuPicking","getPickResultResolveFunc","needsTransmissionDepthForSSR","buildForwardPlusGraphInternal","graph","options","backbuffer","importTexture","frame","depthFramebuffer","sunLightColor","intermediateDeviceStatePushed","renderQueueDisposed","clusteredLightReleased","sunLightRestored","orderToken","addPass","builder","done","createToken","sideEffect","setExecute","sky","update","read","clusteredLight","calculateLightIndex","pickResolveFunc","renderObjectColors","renderShadowMaps","depthPassResult","type","SSRCalcThickness","mvFormat","depthHandle","createTexture","label","motionVectorHandle","undefined","finalDepthAttachment","finalFramebuffer","getDepthAttachment","externalDepthAttachment","isTexture2D","graphDepthAttachmentHandle","depthFormat","depthAttachmentOrFormat","depthFramebufferHandle","createFramebuffer","renderWidth","renderHeight","colorAttachments","depthAttachment","ignoreDepthStencil","skyMotionVectorFramebufferHandle","addSubpass","rgCtx","getFramebuffer","renderSceneDepth","renderSkyMotionVectors","renderDepthAttachment","preLightTransmissionDepthToken","renderTransmissionDepthPass","hiZHandle","mipLevels","hiZFramebufferHandle","depthTex","hiZTex","getTexture","HiZFrameBuffer","buildHiZ","HiZTexture","historyManager","getHistoryResourceManager","lightHistoryReadBindings","compositeHistoryReadBindings","historySize","reflectHistoryHandle","importPreviousIfCompatible","RGHistoryResources","SSR_REFLECT","sizeMode","motionVectorHistoryHandle","SSR_MOTION_VECTOR","name","handle","colorHistoryHandle","TAA_COLOR","TAA_MOTION_VECTOR","sssProfileResult","profileHandle","paramHandle","normalHandle","framebufferHandle","renderForwardSSSProfile","lightPassResult","binding","sceneColorHandle","sceneColorCopyHandle","writeSSSDiffuse","writeSSSTransmission","sssLightingAttachmentCount","sssLightingFormat","sssDiffuseHandle","sssTransmissionHandle","useFinalFramebufferAsIntermediate","sceneColorFramebufferHandle","sceneColorCopyFramebufferHandle","sceneColorTex","sceneColorCopyTex","renderLightPass","renderMainLightPass","beginReadScope","texture","endReadScope","transmissionDepthToken","presentedBackbuffer","outputBackbuffer","write","renderComposite","lights","renderPass","pushDeviceStates","shadow","render","popDeviceStates","profileFramebuffer","profileTexture","paramTexture","normalTexture","depthTexture","sssRenderQueue","savedMaterialFlags","savedCompositor","compositor","savedTransmission","savedRenderOpaque","renderOpaque","savedRenderTransparent","renderTransparent","savedClearColor","clearColor","savedClearDepth","clearDepth","savedClearStencil","clearStencil","savedCommandBufferReuse","commandBufferReuse","savedProfileTexture","savedParamTexture","savedNormalTexture","profileFlags","setFramebuffer","Vector4","zero","releaseIntermediateFramebuffer","intermediateFramebuffer","releaseDepthFramebuffer","disposeRenderQueue","releaseClusteredLight","restoreSunLight","color","cleanupFrame","existingDepthFb","motionVectorTex","transmissionOverride","originDepth","encodeDepth","getColorAttachments","createColorState","setColorMask","forceColorState","forceCullMode","renderBackface","motionVectorTexture","linearDepthTexture","depthPrepassAttachment","_skyMVProgram","_skyMVBindGroup","_skyMVBox","fb","buildRenderProgram","vertex","pb","$inputs","pos","vec3","attrib","VPMatrix","mat4","uniform","prevVPMatrix","cameraPos","prevCameraPos","main","$l","worldPos","prevWorldPos","clipPos","mul","vec4","prevClipPos","z","w","$builtins","position","$outputs","currentPos","prevPos","fragment","motionVector","sub","div","xy","createBindGroup","bindGroupLayouts","BoxShape","needNormal","needUV","setValue","viewProjectionMatrix","getWorldPosition","prevPosition","setProgram","setBindGroup","setRenderStates","AbstractPostEffect","getDefaultRenderState","draw","blitToCurrentColorAttachment","framebuffer","destination","getColorAttachment","CopyBlitter","blit","fetchSampler","setViewport","setScissor","begin","isolateSceneColorDepth","savedDepthPrepassAttachment","sceneColorMaterialFlags","sceneColorFramebuffer","sceneColorStatePushed","sceneColorTexture","drawPostEffects","PostEffectLayer","end","blitter","srgbOut","srcTex","executeForwardPlusGraph","RenderGraph","executor","historyFrameStarted","cullScene","HistoryResourceManager","setHistoryResourceManager","beginFrame","buildResult","compiled","compile","RenderGraphExecutor","backbufferTex","setImportedTexture","bindImportedTextures","execute","commitFrame","discardFrame","reset"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;AAEA,MAAMA,aAAa,IAAIC,SAAAA,EAAAA;AACvB,MAAMC,aAAa,IAAIC,SAAAA,EAAAA;AACvB,MAAMC,iBAAiB,IAAIC,aAAAA,EAAAA;AAC3B,MAAMC,YAA8B,EAAE;AACtC,MAAMC,uBAAuB,IAAIC,mBAAAA,EAAAA;AACjC,IAAIC,oBAA6C,GAAA,IAAA;AACjD,IAAIC,qBAA8C,GAAA,IAAA;AAClD,MAAMC,iBACJC,GAAAA,oBAAAA,CAAqBC,mBAAmB,GACxCD,qBAAqBE,iBAAiB,GACtCF,oBAAqBG,CAAAA,iBAAiB,GACtCH,oBAAAA,CAAqBI,gBAAgB,GACrCJ,qBAAqBK,sBAAsB;AAE7C,SAASC,iBAAAA,GAAAA;AACP,IAAA,OAAOZ,UAAUa,MAAM,GAAG,IAAIb,SAAUc,CAAAA,GAAG,KAAM,IAAIC,cAAAA,EAAAA;AACvD;AACA,SAASC,mBAAmBC,EAAkB,EAAA;AAC5CjB,IAAAA,SAAAA,CAAUkB,IAAI,CAACD,EAAAA,CAAAA;AACjB;AAEA,SAASE,gBAAgBC,QAAiB,EAAA;IACxC,OAAQA,QAA4DC,EAAAA,YAAAA,IAAgBD,QAAY,IAAA,IAAA;AAClG;AAEA,SAASE,mBAAmBF,QAAiB,EAAA;IAC3C,OAAO,CAAC,CAAED,eAAAA,CAAgBC,QAAsDG,CAAAA,EAAAA,iBAAAA;AAClF;AAEA,SAASC,wBAAwBC,WAAwB,EAAA;IACvD,MAAM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MAAMK,WAAchQ,GAAAA,6BAAAA,CAA8BC,KAAOrE,EAAAA,GAAAA,EAAK7D,WAAamI,EAAAA,OAAAA,CAAAA;AAC3EG,QAAAA,KAAAA,GAAQ2P,YAAY3P,KAAK;QAEzB,MAAM4P,QAAAA,GAAWhQ,KAAMiQ,CAAAA,OAAO,CAAC;AAACF,YAAAA,WAAAA,CAAY7P;AAAW,SAAA,CAAA;;AAGvDuP,QAAAA,QAAAA,GAAW,IAAIS,mBAAoB5Z,CAAAA,oBAAAA,EAAsBqF,IAAIkH,WAAW,EAAElH,IAAImH,YAAY,CAAA;;QAG1F,IAAInH,GAAAA,CAAIyG,gBAAgB,EAAE;AACxB,YAAA,MAAM+N,gBAAgBxU,GAAIyG,CAAAA,gBAAgB,CAACgI,mBAAmB,EAAE,CAAC,CAAE,CAAA;AACnEqF,YAAAA,QAAAA,CAASW,kBAAkB,CAACL,WAAY7P,CAAAA,UAAU,EAAEiQ,aAAAA,CAAAA;AACtD;AACA/L,QAAAA,cAAAA,CAAeiM,oBAAoB,CAACZ,QAAAA,CAAAA;AAEpCA,QAAAA,QAAAA,CAASa,OAAO,CAACN,QAAAA,CAAAA;AACjB5L,QAAAA,cAAAA,CAAemM,WAAW,EAAA;KAClB,QAAA;AACR,QAAA,IAAIb,mBAAqB,EAAA;YACvBtL,cAAgBoM,EAAAA,YAAAA,EAAAA;AAClB;AACA,QAAA,IAAIpQ,KAAO,EAAA;YACT0J,YAAa1J,CAAAA,KAAAA,CAAAA;SACR,MAAA;YACLtI,WAAauC,EAAAA,OAAAA,EAAAA;AACf;QACAoV,QAAUgB,EAAAA,KAAAA,EAAAA;AACZ;AACF;;;;"}
1
+ {"version":3,"file":"forward_plus_builder.js","sources":["../../../src/render/rendergraph/forward_plus_builder.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { Vector4 } from '@zephyr3d/base';\r\nimport type {\r\n BindGroup,\r\n ColorState,\r\n FrameBuffer,\r\n GPUProgram,\r\n Texture2D,\r\n TextureFormat\r\n} from '@zephyr3d/device';\r\nimport type { DrawContext } from '../drawable';\r\nimport {\r\n RenderQueue,\r\n type RenderItemList,\r\n type RenderItemListInfo,\r\n type RenderQueueItem\r\n} from '../render_queue';\r\nimport type { PunctualLight, Scene } from '../../scene';\r\nimport type { Camera } from '../../camera';\r\nimport { LightPass } from '../lightpass';\r\nimport { ShadowMapPass } from '../shadowmap_pass';\r\nimport { DepthPass } from '../depthpass';\r\nimport { ClusteredLight } from '../cluster_light';\r\nimport { buildHiZ } from '../hzb';\r\nimport { CopyBlitter } from '../../blitter';\r\nimport { fetchSampler } from '../../utility/misc';\r\nimport { MaterialVaryingFlags } from '../../values';\r\nimport { AbstractPostEffect, PostEffectLayer } from '../../posteffect/posteffect';\r\nimport { RenderGraph } from './rendergraph';\r\nimport { RenderGraphExecutor } from './executor';\r\nimport { DevicePoolAllocator } from './device_pool_allocator';\r\nimport { HistoryResourceManager } from './history_resource_manager';\r\nimport { RGHistoryResources } from './history_resources';\r\nimport type { RGExecuteContext, RGHandle } from './types';\r\nimport { renderObjectColors } from '../gpu_picking';\r\nimport type { Primitive } from '../primitive';\r\nimport { BoxShape } from '../../shapes';\r\n\r\n// ─── Shared Pass Instances ──────────────────────────────────────────\r\n\r\nconst _scenePass = new LightPass();\r\nconst _depthPass = new DepthPass();\r\nconst _shadowMapPass = new ShadowMapPass();\r\nconst _clusters: ClusteredLight[] = [];\r\nconst _devicePoolAllocator = new DevicePoolAllocator();\r\nlet _backDepthColorState: Nullable<ColorState> = null;\r\nlet _frontDepthColorState: Nullable<ColorState> = null;\r\nconst SURFACE_MRT_FLAGS =\r\n MaterialVaryingFlags.SSR_STORE_ROUGHNESS |\r\n MaterialVaryingFlags.SSS_STORE_PROFILE |\r\n MaterialVaryingFlags.SSS_STORE_DIFFUSE |\r\n MaterialVaryingFlags.SSS_STORE_NORMAL |\r\n MaterialVaryingFlags.SSS_STORE_TRANSMISSION;\r\n\r\nfunction getClusteredLight(): ClusteredLight {\r\n return _clusters.length > 0 ? _clusters.pop()! : new ClusteredLight();\r\n}\r\nfunction freeClusteredLight(cl: ClusteredLight): void {\r\n _clusters.push(cl);\r\n}\r\n\r\nfunction getCoreMaterial(material: unknown): unknown {\r\n return (material as { coreMaterial?: unknown } | null | undefined)?.coreMaterial ?? material ?? null;\r\n}\r\n\r\nfunction hasSSSMaterialCore(material: unknown): boolean {\r\n return !!(getCoreMaterial(material) as { subsurfaceProfile?: unknown } | null)?.subsurfaceProfile;\r\n}\r\n\r\nfunction renderQueueHasActiveSSS(renderQueue: RenderQueue): boolean {\r\n const itemList = renderQueue.itemList;\r\n if (!itemList) {\r\n return false;\r\n }\r\n const lists = [...itemList.opaque.lit, ...itemList.opaque.unlit];\r\n for (const list of lists) {\r\n for (const material of list.materialList) {\r\n if (hasSSSMaterialCore(material)) {\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\nfunction filterActualSSSItemList(items: RenderQueueItem[]): RenderQueueItem[] {\r\n return items.filter((item) => hasSSSMaterialCore(item.drawable.getMaterial?.()));\r\n}\r\n\r\nfunction filterActualSSSMaterialList(materialList: Set<any>): Set<any> {\r\n const filtered = new Set<any>();\r\n materialList.forEach((mat) => {\r\n if (hasSSSMaterialCore(mat)) {\r\n filtered.add(mat);\r\n }\r\n });\r\n return filtered;\r\n}\r\n\r\nfunction cloneActualSSSListInfo(source: RenderItemListInfo, _targetQueue: RenderQueue): RenderItemListInfo {\r\n return {\r\n itemList: filterActualSSSItemList(source.itemList),\r\n skinItemList: filterActualSSSItemList(source.skinItemList),\r\n morphItemList: filterActualSSSItemList(source.morphItemList),\r\n skinAndMorphItemList: filterActualSSSItemList(source.skinAndMorphItemList),\r\n instanceItemList: filterActualSSSItemList(source.instanceItemList),\r\n materialList: filterActualSSSMaterialList(source.materialList),\r\n instanceList: {},\r\n renderQueue: source.renderQueue\r\n };\r\n}\r\n\r\nfunction cloneActualSSSBundle(\r\n source: RenderItemList['opaque'],\r\n targetQueue: RenderQueue\r\n): RenderItemList['opaque'] {\r\n return {\r\n lit: source.lit.map((info) => cloneActualSSSListInfo(info, targetQueue)),\r\n unlit: source.unlit.map((info) => cloneActualSSSListInfo(info, targetQueue))\r\n };\r\n}\r\n\r\nfunction hasAnyActualSSSItems(renderItems: RenderItemListInfo[]): boolean {\r\n return renderItems.some(\r\n (info) =>\r\n info.itemList.length > 0 ||\r\n info.skinItemList.length > 0 ||\r\n info.morphItemList.length > 0 ||\r\n info.skinAndMorphItemList.length > 0 ||\r\n info.instanceItemList.length > 0\r\n );\r\n}\r\n\r\nfunction createActualSSSRenderQueue(renderQueue: RenderQueue): RenderQueue | null {\r\n const itemList = renderQueue.itemList;\r\n if (!itemList) {\r\n return null;\r\n }\r\n const queue = new RenderQueue(_scenePass);\r\n const sssOpaque = cloneActualSSSBundle(itemList.opaque, queue);\r\n if (!hasAnyActualSSSItems([...sssOpaque.lit, ...sssOpaque.unlit])) {\r\n queue.dispose();\r\n return null;\r\n }\r\n const emptyBundle = { lit: [], unlit: [] };\r\n const target = queue as unknown as {\r\n _itemList: RenderItemList;\r\n _shadowedLightList: PunctualLight[];\r\n _unshadowedLightList: PunctualLight[];\r\n _sunLight: typeof renderQueue.sunLight;\r\n _primaryDirectionalLight: typeof renderQueue.primaryDirectionalLight;\r\n _primaryTransmissionLight: typeof renderQueue.primaryTransmissionLight;\r\n _needSceneColor: boolean;\r\n _needSceneDepth: boolean;\r\n _needSceneColorWithDepth: boolean;\r\n _drawTransparent: boolean;\r\n };\r\n target._itemList = {\r\n opaque: sssOpaque,\r\n transmission: emptyBundle,\r\n transparent: emptyBundle,\r\n transmission_trans: emptyBundle\r\n };\r\n target._shadowedLightList = renderQueue.shadowedLights;\r\n target._unshadowedLightList = renderQueue.unshadowedLights;\r\n target._sunLight = renderQueue.sunLight;\r\n target._primaryDirectionalLight = renderQueue.primaryDirectionalLight;\r\n target._primaryTransmissionLight = renderQueue.primaryTransmissionLight;\r\n target._needSceneColor = false;\r\n target._needSceneDepth = false;\r\n target._needSceneColorWithDepth = false;\r\n target._drawTransparent = false;\r\n return queue;\r\n}\r\n\r\nfunction getSurfaceTextureFormat(ctx: DrawContext): TextureFormat {\r\n const caps = ctx.device.getDeviceCaps?.();\r\n return caps?.textureCaps.supportHalfFloatColorBuffer ? 'rgba16f' : 'rgba8unorm';\r\n}\r\n\r\nfunction getTextureFormatBytes(ctx: DrawContext, format: TextureFormat): number {\r\n return ctx.device.getDeviceCaps().textureCaps.getTextureFormatInfo(format).size;\r\n}\r\n\r\nfunction shouldStoreSSSDiffuse(ctx: DrawContext): boolean {\r\n return ctx.camera.sssStrength > 0 && ctx.camera.sssBlurScale > 0;\r\n}\r\n\r\nfunction shouldStoreSSSTransmission(ctx: DrawContext): boolean {\r\n return ctx.camera.sssStrength > 0 && ctx.camera.sssTransmissionStrength > 0;\r\n}\r\n\r\nfunction getSSSLightingTextureFormat(\r\n ctx: DrawContext,\r\n attachmentCount: number,\r\n includeSSRSurfaceMRT: boolean\r\n): TextureFormat {\r\n const colorFormat = ctx.colorFormat!;\r\n if (!includeSSRSurfaceMRT || attachmentCount === 0) {\r\n return colorFormat;\r\n }\r\n const caps = ctx.device.getDeviceCaps();\r\n const roughnessFormat = ctx.SSRRoughnessTexture?.format ?? colorFormat;\r\n const normalFormat = ctx.SSRNormalTexture?.format ?? colorFormat;\r\n const colorBytes =\r\n getTextureFormatBytes(ctx, colorFormat) +\r\n getTextureFormatBytes(ctx, roughnessFormat) +\r\n getTextureFormatBytes(ctx, normalFormat);\r\n const fullPrecisionBytes = colorBytes + getTextureFormatBytes(ctx, colorFormat) * attachmentCount;\r\n if (fullPrecisionBytes <= caps.framebufferCaps.maxColorAttachmentBytesPerSample) {\r\n return colorFormat;\r\n }\r\n return 'rgba8unorm';\r\n}\r\n\r\nfunction getFullMipLevelCount(width: number, height: number): number {\r\n return Math.max(1, Math.floor(Math.log2(Math.max(1, width, height))) + 1);\r\n}\r\n\r\nfunction hasSurfaceMRT(ctx: DrawContext): boolean {\r\n return !!(ctx.materialFlags & SURFACE_MRT_FLAGS);\r\n}\r\n\r\nfunction getLightPassColorAttachments(\r\n ctx: DrawContext,\r\n colorAttachment: TextureFormat | Texture2D\r\n): TextureFormat | Texture2D | Array<TextureFormat | Texture2D> {\r\n const attachments: Array<TextureFormat | Texture2D> = [colorAttachment];\r\n if (ctx.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {\r\n attachments.push(ctx.SSRRoughnessTexture!, ctx.SSRNormalTexture!);\r\n } else if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_NORMAL) {\r\n attachments.push(ctx.SSRNormalTexture!);\r\n }\r\n if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_PROFILE) {\r\n attachments.push(ctx.SSSProfileTexture!, ctx.SSSParamTexture!);\r\n }\r\n if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_DIFFUSE) {\r\n attachments.push(ctx.SSSDiffuseTexture!);\r\n }\r\n if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_TRANSMISSION) {\r\n attachments.push(ctx.SSSTransmissionTexture!);\r\n }\r\n return attachments.length === 1 ? attachments[0] : attachments;\r\n}\r\n\r\n// ─── Pipeline Options ───────────────────────────────────────────────\r\n\r\n/**\r\n * Options controlling which features are enabled in the forward+ pipeline.\r\n *\r\n * Derived from camera settings and device capabilities each frame.\r\n *\r\n * @public\r\n */\r\nexport interface ForwardPlusOptions {\r\n /** Enable depth prepass (always true for now). */\r\n depthPrepass: boolean;\r\n /** Enable motion vectors (requires TAA or motionBlur). */\r\n motionVectors: boolean;\r\n /** Enable Hi-Z pyramid (for SSR ray tracing). */\r\n hiZ: boolean;\r\n /** Enable screen-space reflections. */\r\n ssr: boolean;\r\n /** Whether to compute SSR thickness. */\r\n ssrCalcThickness: boolean;\r\n /** Whether GPU picking is requested this frame. */\r\n gpuPicking: boolean;\r\n /** Whether transmission/refraction materials are present. */\r\n needSceneColor: boolean;\r\n /** Whether scene-color-dependent materials also require scene depth. */\r\n needSceneColorWithDepth: boolean;\r\n /** Whether SSR needs transmission depth before the main light pass. */\r\n needsTransmissionDepthForSSR: boolean;\r\n /** Enable screen-space subsurface scattering. */\r\n sss: boolean;\r\n}\r\n\r\n/**\r\n * Derive pipeline options from the current scene/camera state.\r\n * @internal\r\n */\r\nexport function deriveForwardPlusOptions(\r\n scene: Scene,\r\n camera: Camera,\r\n deviceType: string,\r\n renderQueue: RenderQueue\r\n): ForwardPlusOptions {\r\n const ssr = camera.SSR && scene.env.light.envLight && scene.env.light.envLight.hasRadiance();\r\n const sss = camera.SSS && renderQueueHasActiveSSS(renderQueue);\r\n const needSceneColor = renderQueue.needSceneColor();\r\n const needSceneColorWithDepth = renderQueue.needSceneColorWithDepth();\r\n return {\r\n depthPrepass: true,\r\n motionVectors:\r\n deviceType !== 'webgl' && (camera.TAA || camera.motionBlur || (!!ssr && camera.ssrTemporal)),\r\n hiZ: camera.HiZ && deviceType !== 'webgl',\r\n ssr: !!ssr,\r\n ssrCalcThickness: !!ssr && camera.ssrCalcThickness,\r\n gpuPicking: !!camera.getPickResultResolveFunc(),\r\n needSceneColor,\r\n needSceneColorWithDepth,\r\n needsTransmissionDepthForSSR: !!ssr && needSceneColor && !needSceneColorWithDepth,\r\n sss: !!sss\r\n };\r\n}\r\n\r\n// ─── Shared Frame State ─────────────────────────────────────────────\r\n\r\n/**\r\n * Mutable state shared between pass execute callbacks within a single frame.\r\n *\r\n * This replaces the monolithic DrawContext mutation pattern with an explicit\r\n * object that graph passes can read from and write to.\r\n *\r\n * @internal\r\n */\r\nexport interface FrameState {\r\n ctx: DrawContext;\r\n renderQueue: RenderQueue;\r\n depthFramebuffer: Nullable<FrameBuffer>;\r\n sunLightColor: Nullable<any>;\r\n options: ForwardPlusOptions;\r\n intermediateDeviceStatePushed: boolean;\r\n renderQueueDisposed: boolean;\r\n clusteredLightReleased: boolean;\r\n sunLightRestored: boolean;\r\n}\r\n\r\ninterface ForwardPlusGraphBuildResult {\r\n backbuffer: RGHandle;\r\n frame: FrameState;\r\n}\r\n\r\ninterface HistoryReadBinding {\r\n name: string;\r\n handle: RGHandle;\r\n}\r\n\r\ninterface SSSProfilePassResult {\r\n profileHandle: RGHandle;\r\n paramHandle: RGHandle;\r\n normalHandle?: RGHandle;\r\n framebufferHandle: RGHandle;\r\n}\r\n\r\n// ─── Forward+ Graph Builder ─────────────────────────────────────────\r\n\r\n/**\r\n * Constructs a render graph representing the forward+ pipeline.\r\n *\r\n * Each step in the existing `SceneRenderer._renderScene` becomes a graph pass.\r\n * Execute callbacks delegate to the existing rendering code, sharing a mutable\r\n * `FrameState`.\r\n *\r\n * @param graph - The render graph to populate.\r\n * @param ctx - The draw context for this frame.\r\n * @param renderQueue - The culled render queue.\r\n * @param options - Pipeline feature toggles.\r\n * @returns The backbuffer handle (graph output).\r\n *\r\n * @public\r\n */\r\nexport function buildForwardPlusGraph(\r\n graph: RenderGraph,\r\n ctx: DrawContext,\r\n renderQueue: RenderQueue,\r\n options: ForwardPlusOptions\r\n): RGHandle {\r\n return buildForwardPlusGraphInternal(graph, ctx, renderQueue, options).backbuffer;\r\n}\r\n\r\nfunction buildForwardPlusGraphInternal(\r\n graph: RenderGraph,\r\n ctx: DrawContext,\r\n renderQueue: RenderQueue,\r\n options: ForwardPlusOptions\r\n): ForwardPlusGraphBuildResult {\r\n const backbuffer = graph.importTexture('backbuffer');\r\n ctx.SSS = !!options.sss;\r\n\r\n // Shared mutable frame state\r\n const frame: FrameState = {\r\n ctx,\r\n renderQueue,\r\n depthFramebuffer: null,\r\n sunLightColor: null,\r\n options,\r\n intermediateDeviceStatePushed: false,\r\n renderQueueDisposed: false,\r\n clusteredLightReleased: false,\r\n sunLightRestored: false\r\n };\r\n\r\n // ── 1. Sky Update ─────────────────────────────────────────────────\r\n let orderToken = graph.addPass('SkyUpdate', (builder) => {\r\n const done = builder.createToken('SkyUpdateDone');\r\n builder.sideEffect();\r\n builder.setExecute(() => {\r\n frame.sunLightColor = ctx.scene.env.sky.update(ctx);\r\n });\r\n return done;\r\n });\r\n\r\n // ── 2. Clustered Light Setup ──────────────────────────────────────\r\n orderToken = graph.addPass('ClusterLights', (builder) => {\r\n builder.read(orderToken);\r\n const done = builder.createToken('ClusterLightsDone');\r\n builder.sideEffect();\r\n builder.setExecute(() => {\r\n ctx.clusteredLight = getClusteredLight();\r\n ctx.clusteredLight.calculateLightIndex(ctx.camera, renderQueue);\r\n });\r\n return done;\r\n });\r\n\r\n // ── 3. GPU Picking (optional, sideEffect) ─────────────────────────\r\n if (options.gpuPicking) {\r\n orderToken = graph.addPass('GPUPicking', (builder) => {\r\n builder.read(orderToken);\r\n const done = builder.createToken('GPUPickingDone');\r\n builder.sideEffect();\r\n builder.setExecute(() => {\r\n const pickResolveFunc = ctx.camera.getPickResultResolveFunc();\r\n if (pickResolveFunc) {\r\n renderObjectColors(ctx, pickResolveFunc, renderQueue);\r\n }\r\n });\r\n return done;\r\n });\r\n }\r\n\r\n // ── 4. Shadow Maps ────────────────────────────────────────────────\r\n // Shadow maps are managed internally by lights, mark as side effect\r\n if (renderQueue.shadowedLights.length > 0) {\r\n orderToken = graph.addPass('ShadowMaps', (builder) => {\r\n builder.read(orderToken);\r\n const done = builder.createToken('ShadowMapsDone');\r\n builder.sideEffect();\r\n builder.setExecute(() => {\r\n renderShadowMaps(ctx, renderQueue.shadowedLights);\r\n });\r\n return done;\r\n });\r\n }\r\n\r\n // ── 5. Depth Prepass ──────────────────────────────────────────────\r\n // Declare transient depth and motion vector textures\r\n const depthPassResult = graph.addPass('DepthPrepass', (builder) => {\r\n builder.read(orderToken);\r\n const format: TextureFormat =\r\n ctx.device.type === 'webgl'\r\n ? ctx.SSRCalcThickness\r\n ? 'rgba16f'\r\n : 'rgba8unorm'\r\n : ctx.SSRCalcThickness\r\n ? 'rg32f'\r\n : 'r32f';\r\n const mvFormat: TextureFormat = 'rgba16f';\r\n\r\n const depthHandle = builder.createTexture({ format, label: 'linearDepth' });\r\n const motionVectorHandle = options.motionVectors\r\n ? builder.createTexture({ format: mvFormat, label: 'motionVector' })\r\n : undefined;\r\n const finalDepthAttachment = ctx.finalFramebuffer?.getDepthAttachment();\r\n const externalDepthAttachment = finalDepthAttachment?.isTexture2D()\r\n ? (finalDepthAttachment as Texture2D)\r\n : null;\r\n const graphDepthAttachmentHandle = externalDepthAttachment\r\n ? undefined\r\n : builder.createTexture({ format: ctx.depthFormat, label: 'sceneDepth' });\r\n const depthAttachmentOrFormat = externalDepthAttachment ?? graphDepthAttachmentHandle ?? ctx.depthFormat;\r\n const depthFramebufferHandle = builder.createFramebuffer({\r\n label: 'DepthPrepassFramebuffer',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: motionVectorHandle ? [depthHandle, motionVectorHandle] : depthHandle,\r\n depthAttachment: depthAttachmentOrFormat,\r\n ignoreDepthStencil: false\r\n });\r\n const skyMotionVectorFramebufferHandle = motionVectorHandle\r\n ? builder.createFramebuffer({\r\n label: 'SkyMotionVectorFramebuffer',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: motionVectorHandle,\r\n depthAttachment: depthAttachmentOrFormat\r\n })\r\n : undefined;\r\n\r\n builder.addSubpass('SceneDepth', (rgCtx) => {\r\n const depthFramebuffer = rgCtx.getFramebuffer<FrameBuffer>(depthFramebufferHandle);\r\n frame.depthFramebuffer = renderSceneDepth(frame, depthFramebuffer, rgCtx, undefined, undefined, false);\r\n });\r\n if (skyMotionVectorFramebufferHandle) {\r\n builder.addSubpass('SkyMotionVectors', (rgCtx) => {\r\n renderSkyMotionVectors(ctx, rgCtx, skyMotionVectorFramebufferHandle);\r\n });\r\n }\r\n\r\n return {\r\n depthHandle,\r\n motionVectorHandle,\r\n graphDepthAttachmentHandle,\r\n externalDepthAttachment,\r\n depthFramebufferHandle\r\n };\r\n });\r\n\r\n const depthHandle = depthPassResult.depthHandle;\r\n const motionVectorHandle = depthPassResult.motionVectorHandle;\r\n const renderDepthAttachment =\r\n depthPassResult.graphDepthAttachmentHandle ?? depthPassResult.externalDepthAttachment ?? null;\r\n\r\n let preLightTransmissionDepthToken: RGHandle | undefined;\r\n if (options.needsTransmissionDepthForSSR) {\r\n preLightTransmissionDepthToken = graph.addPass('TransmissionDepthForSSR', (builder) => {\r\n builder.read(depthPassResult.depthFramebufferHandle);\r\n const done = builder.createToken('TransmissionDepthForSSRDone');\r\n builder.sideEffect();\r\n builder.setExecute((rgCtx) => {\r\n renderTransmissionDepthPass(frame, rgCtx);\r\n });\r\n return done;\r\n });\r\n }\r\n\r\n // ── 6. Hi-Z (optional) ───────────────────────────────────────────\r\n let hiZHandle: RGHandle | undefined;\r\n if (options.hiZ) {\r\n graph.addPass('HiZ', (builder) => {\r\n builder.read(depthHandle!);\r\n builder.read(depthPassResult.depthFramebufferHandle);\r\n if (preLightTransmissionDepthToken) {\r\n builder.read(preLightTransmissionDepthToken);\r\n }\r\n hiZHandle = builder.createTexture({\r\n format: 'r32f',\r\n label: 'hiZ',\r\n mipLevels: getFullMipLevelCount(ctx.renderWidth, ctx.renderHeight)\r\n });\r\n const hiZFramebufferHandle = builder.createFramebuffer({\r\n label: 'HiZFramebuffer',\r\n colorAttachments: hiZHandle,\r\n depthAttachment: null\r\n });\r\n builder.setExecute((rgCtx) => {\r\n const ctx = frame.ctx;\r\n // Use the depth texture from the framebuffer (which contains the RenderGraph texture)\r\n const depthTex = frame.depthFramebuffer?.getDepthAttachment() as Texture2D;\r\n if (depthTex) {\r\n // Get the HiZ texture allocated by the executor\r\n const hiZTex = rgCtx.getTexture<Texture2D>(hiZHandle!);\r\n const HiZFrameBuffer = rgCtx.getFramebuffer<FrameBuffer>(hiZFramebufferHandle);\r\n buildHiZ(depthTex, HiZFrameBuffer);\r\n ctx.HiZTexture = hiZTex;\r\n }\r\n });\r\n });\r\n }\r\n\r\n // ── 7. Main Light Pass ────────────────────────────────────────────\r\n const historyManager = ctx.camera?.getHistoryResourceManager?.() ?? null;\r\n const lightHistoryReadBindings: HistoryReadBinding[] = [];\r\n const compositeHistoryReadBindings: HistoryReadBinding[] = [];\r\n const historySize = { width: ctx.renderWidth, height: ctx.renderHeight };\r\n if (historyManager && options.ssr && ctx.camera?.ssrTemporal && options.motionVectors) {\r\n const reflectHistoryHandle = historyManager.importPreviousIfCompatible(\r\n graph,\r\n RGHistoryResources.SSR_REFLECT,\r\n {\r\n format: 'rgba16f',\r\n sizeMode: 'absolute',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight\r\n },\r\n historySize\r\n );\r\n const motionVectorHistoryHandle = historyManager.importPreviousIfCompatible(\r\n graph,\r\n RGHistoryResources.SSR_MOTION_VECTOR,\r\n {\r\n format: 'rgba16f',\r\n sizeMode: 'absolute',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight\r\n },\r\n historySize\r\n );\r\n if (reflectHistoryHandle && motionVectorHistoryHandle) {\r\n lightHistoryReadBindings.push(\r\n { name: RGHistoryResources.SSR_REFLECT, handle: reflectHistoryHandle },\r\n { name: RGHistoryResources.SSR_MOTION_VECTOR, handle: motionVectorHistoryHandle }\r\n );\r\n }\r\n }\r\n if (historyManager && ctx.camera?.TAA && options.motionVectors) {\r\n const colorHistoryHandle = historyManager.importPreviousIfCompatible(\r\n graph,\r\n RGHistoryResources.TAA_COLOR,\r\n {\r\n format: ctx.colorFormat!,\r\n sizeMode: 'absolute',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight\r\n },\r\n historySize\r\n );\r\n const motionVectorHistoryHandle = historyManager.importPreviousIfCompatible(\r\n graph,\r\n RGHistoryResources.TAA_MOTION_VECTOR,\r\n {\r\n format: 'rgba16f',\r\n sizeMode: 'absolute',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight\r\n },\r\n historySize\r\n );\r\n if (colorHistoryHandle && motionVectorHistoryHandle) {\r\n compositeHistoryReadBindings.push(\r\n { name: RGHistoryResources.TAA_COLOR, handle: colorHistoryHandle },\r\n { name: RGHistoryResources.TAA_MOTION_VECTOR, handle: motionVectorHistoryHandle }\r\n );\r\n }\r\n }\r\n\r\n let sssProfileResult: SSSProfilePassResult | undefined;\r\n if (options.sss) {\r\n sssProfileResult = graph.addPass('SSSProfile', (builder) => {\r\n builder.read(depthHandle);\r\n builder.read(depthPassResult.depthFramebufferHandle);\r\n if (preLightTransmissionDepthToken) {\r\n builder.read(preLightTransmissionDepthToken);\r\n }\r\n const profileHandle = builder.createTexture({ format: 'rgba16f', label: 'sssProfile' });\r\n const paramHandle = builder.createTexture({ format: 'rgba8unorm', label: 'sssParam' });\r\n const normalHandle = options.ssr\r\n ? undefined\r\n : builder.createTexture({ format: getSurfaceTextureFormat(ctx), label: 'sssNormal' });\r\n const colorAttachments = normalHandle\r\n ? [ctx.colorFormat!, normalHandle, profileHandle, paramHandle]\r\n : [ctx.colorFormat!, profileHandle, paramHandle];\r\n const framebufferHandle = builder.createFramebuffer({\r\n label: 'SSSProfileFramebuffer',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments,\r\n depthAttachment: renderDepthAttachment,\r\n ignoreDepthStencil: false\r\n });\r\n\r\n builder.setExecute((rgCtx) => {\r\n renderForwardSSSProfile(\r\n frame,\r\n rgCtx.getFramebuffer<FrameBuffer>(framebufferHandle),\r\n rgCtx.getTexture<Texture2D>(profileHandle),\r\n rgCtx.getTexture<Texture2D>(paramHandle),\r\n normalHandle ? rgCtx.getTexture<Texture2D>(normalHandle) : null\r\n );\r\n });\r\n\r\n return {\r\n profileHandle,\r\n paramHandle,\r\n normalHandle,\r\n framebufferHandle\r\n };\r\n });\r\n }\r\n\r\n const lightPassResult = graph.addPass('LightPass', (builder) => {\r\n builder.read(depthHandle);\r\n builder.read(depthPassResult.depthFramebufferHandle);\r\n if (preLightTransmissionDepthToken) {\r\n builder.read(preLightTransmissionDepthToken);\r\n }\r\n if (hiZHandle) {\r\n builder.read(hiZHandle);\r\n }\r\n for (const binding of lightHistoryReadBindings) {\r\n builder.read(binding.handle);\r\n }\r\n\r\n // Create scene color texture (intermediate render target)\r\n const sceneColorHandle = builder.createTexture({\r\n format: ctx.colorFormat!,\r\n label: 'sceneColor'\r\n });\r\n\r\n // Create optional sceneColorCopy for transmission/refraction materials\r\n let sceneColorCopyHandle: RGHandle | undefined;\r\n if (options.needSceneColor) {\r\n sceneColorCopyHandle = builder.createTexture({\r\n format: ctx.colorFormat!,\r\n label: 'sceneColorCopy'\r\n });\r\n }\r\n if (sssProfileResult) {\r\n builder.read(sssProfileResult.profileHandle);\r\n builder.read(sssProfileResult.paramHandle);\r\n if (sssProfileResult.normalHandle) {\r\n builder.read(sssProfileResult.normalHandle);\r\n }\r\n }\r\n const includeSSRSurfaceMRT = !!options.ssr;\r\n const writeSSSDiffuse = options.sss && shouldStoreSSSDiffuse(ctx);\r\n let writeSSSTransmission = options.sss && shouldStoreSSSTransmission(ctx);\r\n if (\r\n writeSSSDiffuse &&\r\n writeSSSTransmission &&\r\n includeSSRSurfaceMRT &&\r\n getSSSLightingTextureFormat(ctx, 2, includeSSRSurfaceMRT) !== ctx.colorFormat\r\n ) {\r\n writeSSSTransmission = false;\r\n }\r\n const sssLightingAttachmentCount = (writeSSSDiffuse ? 1 : 0) + (writeSSSTransmission ? 1 : 0);\r\n const sssLightingFormat = getSSSLightingTextureFormat(\r\n ctx,\r\n sssLightingAttachmentCount,\r\n includeSSRSurfaceMRT\r\n );\r\n const sssDiffuseHandle = writeSSSDiffuse\r\n ? builder.createTexture({ format: sssLightingFormat, label: 'sssDiffuse' })\r\n : undefined;\r\n const sssTransmissionHandle = writeSSSTransmission\r\n ? builder.createTexture({ format: sssLightingFormat, label: 'sssTransmission' })\r\n : undefined;\r\n const useFinalFramebufferAsIntermediate =\r\n !!depthPassResult.externalDepthAttachment &&\r\n depthPassResult.externalDepthAttachment === ctx.finalFramebuffer?.getDepthAttachment();\r\n const sceneColorFramebufferHandle = useFinalFramebufferAsIntermediate\r\n ? undefined\r\n : builder.createFramebuffer({\r\n label: 'SceneColorFramebuffer',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: sceneColorHandle,\r\n depthAttachment: renderDepthAttachment\r\n });\r\n // SSR may pre-insert transmission depth before LightPass for Hi-Z. In that case the\r\n // refraction scene-color copy needs an isolated depth buffer so transmission surfaces\r\n // do not occlude the background color they are about to sample.\r\n const sceneColorCopyFramebufferHandle =\r\n sceneColorCopyHandle && !options.needsTransmissionDepthForSSR\r\n ? builder.createFramebuffer({\r\n label: 'SceneColorCopyFramebuffer',\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: sceneColorCopyHandle,\r\n depthAttachment: renderDepthAttachment,\r\n ignoreDepthStencil: false\r\n })\r\n : undefined;\r\n\r\n builder.setExecute((rgCtx) => {\r\n const sceneColorTex = rgCtx.getTexture<Texture2D>(sceneColorHandle);\r\n const sceneColorCopyTex = sceneColorCopyHandle\r\n ? rgCtx.getTexture<Texture2D>(sceneColorCopyHandle)\r\n : null;\r\n if (sssProfileResult) {\r\n ctx.SSSProfileTexture = rgCtx.getTexture<Texture2D>(sssProfileResult.profileHandle);\r\n ctx.SSSParamTexture = rgCtx.getTexture<Texture2D>(sssProfileResult.paramHandle);\r\n if (sssProfileResult.normalHandle) {\r\n ctx.SSRNormalTexture = rgCtx.getTexture<Texture2D>(sssProfileResult.normalHandle);\r\n }\r\n }\r\n ctx.SSSDiffuseTexture = sssDiffuseHandle ? rgCtx.getTexture<Texture2D>(sssDiffuseHandle) : null;\r\n ctx.SSSTransmissionTexture = sssTransmissionHandle\r\n ? rgCtx.getTexture<Texture2D>(sssTransmissionHandle)\r\n : null;\r\n const renderLightPass = () =>\r\n renderMainLightPass(\r\n frame,\r\n sceneColorTex,\r\n sceneColorCopyTex,\r\n rgCtx,\r\n sceneColorFramebufferHandle,\r\n sceneColorCopyFramebufferHandle\r\n );\r\n if (historyManager && lightHistoryReadBindings.length > 0) {\r\n historyManager.beginReadScope(\r\n lightHistoryReadBindings.map((binding) => ({\r\n name: binding.name,\r\n texture: rgCtx.getTexture<Texture2D>(binding.handle)\r\n }))\r\n );\r\n try {\r\n renderLightPass();\r\n } finally {\r\n historyManager.endReadScope();\r\n }\r\n } else {\r\n renderLightPass();\r\n }\r\n });\r\n\r\n return { sceneColorHandle, sceneColorCopyHandle, sceneColorFramebufferHandle };\r\n });\r\n\r\n const sceneColorHandle = lightPassResult.sceneColorHandle;\r\n\r\n // 8. Transmission depth pass (optional)\r\n let transmissionDepthToken: RGHandle | undefined;\r\n if (options.needSceneColor && !options.needsTransmissionDepthForSSR) {\r\n transmissionDepthToken = graph.addPass('TransmissionDepth', (builder) => {\r\n builder.read(sceneColorHandle);\r\n builder.read(depthPassResult.depthFramebufferHandle);\r\n const done = builder.createToken('TransmissionDepthDone');\r\n builder.sideEffect();\r\n builder.setExecute((rgCtx) => {\r\n renderTransmissionDepthPass(frame, rgCtx);\r\n });\r\n return done;\r\n });\r\n }\r\n\r\n // 9. Post effects + final composite\r\n const presentedBackbuffer = graph.addPass('Composite', (builder) => {\r\n builder.read(sceneColorHandle);\r\n builder.read(depthHandle);\r\n if (hiZHandle) {\r\n builder.read(hiZHandle);\r\n }\r\n if (motionVectorHandle) {\r\n builder.read(motionVectorHandle);\r\n }\r\n if (lightPassResult.sceneColorFramebufferHandle) {\r\n builder.read(lightPassResult.sceneColorFramebufferHandle);\r\n }\r\n if (transmissionDepthToken) {\r\n builder.read(transmissionDepthToken);\r\n }\r\n for (const binding of compositeHistoryReadBindings) {\r\n builder.read(binding.handle);\r\n }\r\n const outputBackbuffer = builder.write(backbuffer);\r\n builder.setExecute((rgCtx) => {\r\n if (historyManager && compositeHistoryReadBindings.length > 0) {\r\n historyManager.beginReadScope(\r\n compositeHistoryReadBindings.map((binding) => ({\r\n name: binding.name,\r\n texture: rgCtx.getTexture<Texture2D>(binding.handle)\r\n }))\r\n );\r\n try {\r\n renderComposite(frame);\r\n } finally {\r\n historyManager.endReadScope();\r\n }\r\n } else {\r\n renderComposite(frame);\r\n }\r\n });\r\n return outputBackbuffer;\r\n });\r\n\r\n return { backbuffer: presentedBackbuffer, frame };\r\n}\r\n\r\n// ─── Pass Implementation Helpers ────────────────────────────────────\r\n// These wrap the existing SceneRenderer static methods, adapted to work\r\n// with the FrameState pattern. They contain the same logic as the\r\n// original methods but read/write through FrameState.\r\n\r\n/** @internal */\r\nfunction renderShadowMaps(ctx: DrawContext, lights: PunctualLight[]): void {\r\n ctx.renderPass = _shadowMapPass;\r\n ctx.device.pushDeviceStates();\r\n try {\r\n for (const light of lights) {\r\n light.shadow.render(ctx, _shadowMapPass);\r\n }\r\n } finally {\r\n ctx.device.popDeviceStates();\r\n }\r\n}\r\n\r\nfunction renderForwardSSSProfile(\r\n frame: FrameState,\r\n profileFramebuffer: FrameBuffer,\r\n profileTexture: Texture2D,\r\n paramTexture: Texture2D,\r\n normalTexture: Nullable<Texture2D>\r\n): void {\r\n const { ctx, renderQueue } = frame;\r\n if (!ctx.SSS || !ctx.depthTexture) {\r\n return;\r\n }\r\n const sssRenderQueue = createActualSSSRenderQueue(renderQueue);\r\n if (!sssRenderQueue) {\r\n return;\r\n }\r\n\r\n const device = ctx.device;\r\n const savedMaterialFlags = ctx.materialFlags;\r\n const savedCompositor = ctx.compositor;\r\n const savedTransmission = _scenePass.transmission;\r\n const savedRenderOpaque = _scenePass.renderOpaque;\r\n const savedRenderTransparent = _scenePass.renderTransparent;\r\n const savedClearColor = _scenePass.clearColor;\r\n const savedClearDepth = _scenePass.clearDepth;\r\n const savedClearStencil = _scenePass.clearStencil;\r\n const savedCommandBufferReuse = ctx.camera.commandBufferReuse;\r\n const savedProfileTexture = ctx.SSSProfileTexture;\r\n const savedParamTexture = ctx.SSSParamTexture;\r\n const savedNormalTexture = ctx.SSRNormalTexture;\r\n\r\n let profileFlags = MaterialVaryingFlags.SSS_STORE_PROFILE;\r\n if (normalTexture) {\r\n profileFlags |= MaterialVaryingFlags.SSS_STORE_NORMAL;\r\n }\r\n\r\n device.pushDeviceStates();\r\n try {\r\n device.setFramebuffer(profileFramebuffer);\r\n ctx.SSSProfileTexture = profileTexture;\r\n ctx.SSSParamTexture = paramTexture;\r\n ctx.SSRNormalTexture = normalTexture;\r\n ctx.compositor = null;\r\n ctx.camera.commandBufferReuse = false;\r\n ctx.materialFlags =\r\n (ctx.materialFlags &\r\n ~(\r\n MaterialVaryingFlags.SSR_STORE_ROUGHNESS |\r\n MaterialVaryingFlags.SSS_STORE_PROFILE |\r\n MaterialVaryingFlags.SSS_STORE_NORMAL |\r\n MaterialVaryingFlags.SSS_STORE_DIFFUSE |\r\n MaterialVaryingFlags.SSS_STORE_TRANSMISSION\r\n )) |\r\n profileFlags;\r\n _scenePass.transmission = false;\r\n _scenePass.renderOpaque = true;\r\n _scenePass.renderTransparent = false;\r\n _scenePass.clearColor = Vector4.zero();\r\n _scenePass.clearDepth = null;\r\n _scenePass.clearStencil = null;\r\n _scenePass.render(ctx, null, null, sssRenderQueue);\r\n } finally {\r\n _scenePass.clearColor = savedClearColor;\r\n _scenePass.clearDepth = savedClearDepth;\r\n _scenePass.clearStencil = savedClearStencil;\r\n _scenePass.renderTransparent = savedRenderTransparent;\r\n _scenePass.renderOpaque = savedRenderOpaque;\r\n _scenePass.transmission = savedTransmission;\r\n ctx.camera.commandBufferReuse = savedCommandBufferReuse;\r\n ctx.materialFlags = savedMaterialFlags;\r\n ctx.compositor = savedCompositor;\r\n ctx.SSSProfileTexture = savedProfileTexture;\r\n ctx.SSSParamTexture = savedParamTexture;\r\n ctx.SSRNormalTexture = savedNormalTexture;\r\n device.popDeviceStates();\r\n sssRenderQueue.dispose();\r\n }\r\n}\r\n\r\nfunction releaseIntermediateFramebuffer(frame: FrameState): void {\r\n const { ctx } = frame;\r\n if (frame.intermediateDeviceStatePushed) {\r\n ctx.device.popDeviceStates();\r\n frame.intermediateDeviceStatePushed = false;\r\n }\r\n ctx.intermediateFramebuffer = null;\r\n}\r\n\r\nfunction releaseDepthFramebuffer(frame: FrameState): void {\r\n frame.depthFramebuffer = null;\r\n}\r\n\r\nfunction disposeRenderQueue(frame: FrameState): void {\r\n if (!frame.renderQueueDisposed) {\r\n frame.renderQueue.dispose();\r\n frame.renderQueueDisposed = true;\r\n }\r\n}\r\n\r\nfunction releaseClusteredLight(frame: FrameState): void {\r\n if (!frame.clusteredLightReleased && frame.ctx.clusteredLight) {\r\n freeClusteredLight(frame.ctx.clusteredLight);\r\n frame.ctx.clusteredLight = undefined;\r\n frame.clusteredLightReleased = true;\r\n }\r\n}\r\n\r\nfunction restoreSunLight(frame: FrameState): void {\r\n if (!frame.sunLightRestored && frame.sunLightColor && frame.ctx.sunLight) {\r\n frame.ctx.sunLight.color = frame.sunLightColor;\r\n frame.sunLightRestored = true;\r\n }\r\n}\r\n\r\nfunction cleanupFrame(frame: FrameState): void {\r\n releaseIntermediateFramebuffer(frame);\r\n releaseDepthFramebuffer(frame);\r\n releaseClusteredLight(frame);\r\n disposeRenderQueue(frame);\r\n restoreSunLight(frame);\r\n}\r\n\r\n/** @internal */\r\nfunction renderSceneDepth(\r\n frame: FrameState,\r\n existingDepthFb: Nullable<FrameBuffer>,\r\n rgCtx: RGExecuteContext,\r\n depthTex?: Texture2D,\r\n motionVectorTex?: Nullable<Texture2D>,\r\n transmissionOverride?: boolean\r\n): FrameBuffer {\r\n const ctx = frame.ctx;\r\n const renderQueue = frame.renderQueue;\r\n const transmission = transmissionOverride ?? !!existingDepthFb;\r\n let depthFramebuffer = existingDepthFb;\r\n\r\n if (!depthFramebuffer) {\r\n // Use RenderGraph-allocated textures if provided\r\n if (depthTex) {\r\n const colorAttachments = motionVectorTex ? [depthTex, motionVectorTex] : depthTex;\r\n const depthAttachment = ctx.finalFramebuffer?.getDepthAttachment();\r\n const depthTexOrFormat = depthAttachment?.isTexture2D() ? depthAttachment : ctx.depthFormat;\r\n\r\n depthFramebuffer = rgCtx.createFramebuffer<FrameBuffer>({\r\n width: depthTex.width,\r\n height: depthTex.height,\r\n colorAttachments,\r\n depthAttachment: depthTexOrFormat,\r\n ignoreDepthStencil: false\r\n });\r\n } else {\r\n // Allocate through RenderGraph so framebuffer lifetime is owned by the executor.\r\n const format: TextureFormat =\r\n ctx.device.type === 'webgl'\r\n ? ctx.SSRCalcThickness\r\n ? 'rgba16f'\r\n : 'rgba8unorm'\r\n : ctx.SSRCalcThickness\r\n ? 'rg32f'\r\n : 'r32f';\r\n const mvFormat: TextureFormat = 'rgba16f';\r\n if (!ctx.finalFramebuffer) {\r\n depthFramebuffer = rgCtx.createFramebuffer<FrameBuffer>({\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: ctx.motionVectors ? [format, mvFormat] : format,\r\n depthAttachment: ctx.depthFormat,\r\n ignoreDepthStencil: false\r\n });\r\n } else {\r\n const originDepth = ctx.finalFramebuffer?.getDepthAttachment();\r\n if (originDepth?.isTexture2D()) {\r\n depthFramebuffer = rgCtx.createFramebuffer<FrameBuffer>({\r\n width: originDepth.width,\r\n height: originDepth.height,\r\n colorAttachments: ctx.motionVectors ? [format, mvFormat] : format,\r\n depthAttachment: originDepth,\r\n ignoreDepthStencil: false\r\n });\r\n } else {\r\n depthFramebuffer = rgCtx.createFramebuffer<FrameBuffer>({\r\n width: ctx.renderWidth,\r\n height: ctx.renderHeight,\r\n colorAttachments: ctx.motionVectors ? [format, mvFormat] : format,\r\n depthAttachment: ctx.depthFormat,\r\n ignoreDepthStencil: false\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (!transmission) {\r\n frame.depthFramebuffer = depthFramebuffer!;\r\n }\r\n\r\n ctx.device.pushDeviceStates();\r\n try {\r\n ctx.device.setFramebuffer(depthFramebuffer!);\r\n _depthPass.encodeDepth = depthFramebuffer!.getColorAttachments()[0].format === 'rgba8unorm';\r\n _depthPass.clearColor = transmission\r\n ? null\r\n : _depthPass.encodeDepth\r\n ? new Vector4(0, 0, 0, 1)\r\n : new Vector4(1, 1, 1, 1);\r\n _depthPass.clearDepth = transmission ? null : 1;\r\n _depthPass.clearStencil = null;\r\n _depthPass.transmission = transmission;\r\n\r\n if (ctx.SSRCalcThickness && !transmission) {\r\n if (!_backDepthColorState) {\r\n _backDepthColorState = ctx.device.createColorState().setColorMask(false, true, false, false);\r\n }\r\n if (!_frontDepthColorState) {\r\n _frontDepthColorState = ctx.device.createColorState().setColorMask(true, false, false, false);\r\n }\r\n ctx.forceColorState = _backDepthColorState;\r\n ctx.forceCullMode = 'front';\r\n _depthPass.renderBackface = true;\r\n _depthPass.transmission = false;\r\n _depthPass.render(ctx, null, null, renderQueue);\r\n _depthPass.clearColor = null;\r\n _depthPass.renderBackface = false;\r\n ctx.forceColorState = _frontDepthColorState;\r\n ctx.forceCullMode = null;\r\n }\r\n _depthPass.render(ctx, null, null, renderQueue);\r\n } finally {\r\n ctx.forceColorState = null;\r\n ctx.forceCullMode = null;\r\n _depthPass.renderBackface = false;\r\n ctx.device.popDeviceStates();\r\n }\r\n\r\n if (!transmission) {\r\n ctx.motionVectorTexture = ctx.motionVectors\r\n ? (depthFramebuffer!.getColorAttachments()[1] as Texture2D)\r\n : null;\r\n ctx.linearDepthTexture = depthFramebuffer!.getColorAttachments()[0] as Texture2D;\r\n ctx.depthTexture = depthFramebuffer!.getDepthAttachment() as Texture2D;\r\n ctx.depthPrepassAttachment = ctx.depthTexture;\r\n // HiZ is now built in the dedicated HiZ pass\r\n }\r\n return depthFramebuffer!;\r\n}\r\n\r\n// ─── Sky Motion Vector State ────────────────────────────────────────\r\n\r\nlet _skyMVProgram: Nullable<GPUProgram> = null;\r\nlet _skyMVBindGroup: Nullable<BindGroup> = null;\r\nlet _skyMVBox: Nullable<Primitive> = null;\r\n\r\n/** @internal */\r\nfunction renderSkyMotionVectors(\r\n ctx: DrawContext,\r\n rgCtx: RGExecuteContext,\r\n framebufferHandle?: RGHandle\r\n): void {\r\n if (!ctx.motionVectorTexture) {\r\n return;\r\n }\r\n\r\n const device = ctx.device;\r\n const fb = framebufferHandle\r\n ? rgCtx.getFramebuffer<FrameBuffer>(framebufferHandle)\r\n : rgCtx.createFramebuffer<FrameBuffer>({\r\n colorAttachments: ctx.motionVectorTexture,\r\n depthAttachment: ctx.depthTexture\r\n });\r\n\r\n if (!_skyMVProgram) {\r\n _skyMVProgram = device.buildRenderProgram({\r\n vertex(pb) {\r\n this.$inputs.pos = pb.vec3().attrib('position');\r\n this.VPMatrix = pb.mat4().uniform(0);\r\n this.prevVPMatrix = pb.mat4().uniform(0);\r\n this.cameraPos = pb.vec3().uniform(0);\r\n this.prevCameraPos = pb.vec3().uniform(0);\r\n pb.main(function () {\r\n this.$l.worldPos = pb.add(this.$inputs.pos, this.cameraPos);\r\n this.$l.prevWorldPos = pb.add(this.$inputs.pos, this.prevCameraPos);\r\n this.$l.clipPos = pb.mul(this.VPMatrix, pb.vec4(this.worldPos, 1));\r\n this.$l.prevClipPos = pb.mul(this.prevVPMatrix, pb.vec4(this.prevWorldPos, 1));\r\n this.clipPos.z = this.clipPos.w;\r\n this.$builtins.position = this.clipPos;\r\n this.$outputs.currentPos = this.clipPos;\r\n this.$outputs.prevPos = this.prevClipPos;\r\n });\r\n },\r\n fragment(pb) {\r\n this.$outputs.color = pb.vec4();\r\n pb.main(function () {\r\n this.$l.motionVector = pb.mul(\r\n pb.sub(\r\n pb.div(this.$inputs.currentPos.xy, this.$inputs.currentPos.w),\r\n pb.div(this.$inputs.prevPos.xy, this.$inputs.prevPos.w)\r\n ),\r\n 0.5\r\n );\r\n this.$outputs.color = pb.vec4(this.motionVector, 0, 1);\r\n });\r\n }\r\n })!;\r\n _skyMVProgram.name = '@TAA_SkyMotionVector';\r\n }\r\n\r\n if (!_skyMVBindGroup) {\r\n _skyMVBindGroup = device.createBindGroup(_skyMVProgram.bindGroupLayouts[0]);\r\n }\r\n\r\n if (!_skyMVBox) {\r\n _skyMVBox = new BoxShape({ size: 2, needNormal: false, needUV: false });\r\n }\r\n\r\n _skyMVBindGroup.setValue('VPMatrix', ctx.camera.viewProjectionMatrix);\r\n _skyMVBindGroup.setValue('prevVPMatrix', ctx.camera.prevVPMatrix!);\r\n _skyMVBindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());\r\n _skyMVBindGroup.setValue('prevCameraPos', ctx.camera.prevPosition!);\r\n\r\n device.pushDeviceStates();\r\n device.setProgram(_skyMVProgram);\r\n device.setBindGroup(0, _skyMVBindGroup);\r\n device.setRenderStates(AbstractPostEffect.getDefaultRenderState(ctx, 'le'));\r\n device.setFramebuffer(fb);\r\n _skyMVBox.draw();\r\n device.popDeviceStates();\r\n}\r\n\r\nfunction blitToCurrentColorAttachment(ctx: DrawContext, source: Texture2D): void {\r\n const framebuffer = ctx.device.getFramebuffer();\r\n const destination = framebuffer?.getColorAttachment<Texture2D>(0) ?? null;\r\n new CopyBlitter().blit(source, destination, fetchSampler('clamp_nearest_nomip'));\r\n}\r\n\r\n/** @internal */\r\nfunction renderMainLightPass(\r\n frame: FrameState,\r\n sceneColorTex: Texture2D,\r\n sceneColorCopyTex: Nullable<Texture2D>,\r\n rgCtx: RGExecuteContext,\r\n sceneColorFramebufferHandle?: RGHandle,\r\n sceneColorCopyFramebufferHandle?: RGHandle\r\n): void {\r\n const { ctx, renderQueue } = frame;\r\n const device = ctx.device;\r\n\r\n // Use RenderGraph-allocated scene color texture\r\n const depthTex = frame.depthFramebuffer?.getDepthAttachment() as Texture2D;\r\n\r\n ctx.materialFlags &= ~(\r\n MaterialVaryingFlags.SSR_STORE_ROUGHNESS |\r\n MaterialVaryingFlags.SSS_STORE_PROFILE |\r\n MaterialVaryingFlags.SSS_STORE_DIFFUSE |\r\n MaterialVaryingFlags.SSS_STORE_NORMAL |\r\n MaterialVaryingFlags.SSS_STORE_TRANSMISSION\r\n );\r\n\r\n if (ctx.SSR) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SSR_STORE_ROUGHNESS;\r\n }\r\n if (ctx.SSS) {\r\n if (ctx.SSSDiffuseTexture) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SSS_STORE_DIFFUSE;\r\n }\r\n if (ctx.SSSTransmissionTexture) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SSS_STORE_TRANSMISSION;\r\n }\r\n }\r\n\r\n if (depthTex === ctx.finalFramebuffer?.getDepthAttachment()) {\r\n ctx.intermediateFramebuffer = ctx.finalFramebuffer;\r\n } else if (sceneColorFramebufferHandle && !hasSurfaceMRT(ctx)) {\r\n ctx.intermediateFramebuffer = rgCtx.getFramebuffer<FrameBuffer>(sceneColorFramebufferHandle);\r\n } else {\r\n ctx.intermediateFramebuffer = rgCtx.createFramebuffer<FrameBuffer>({\r\n width: sceneColorTex.width,\r\n height: sceneColorTex.height,\r\n colorAttachments: getLightPassColorAttachments(ctx, sceneColorTex),\r\n depthAttachment: depthTex\r\n });\r\n }\r\n\r\n if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {\r\n device.pushDeviceStates();\r\n frame.intermediateDeviceStatePushed = true;\r\n device.setFramebuffer(ctx.intermediateFramebuffer);\r\n } else {\r\n device.setViewport(null);\r\n device.setScissor(null);\r\n }\r\n\r\n _scenePass.transmission = false;\r\n _scenePass.clearDepth = depthTex ? null : 1;\r\n _scenePass.clearStencil = depthTex ? null : 0;\r\n\r\n ctx.compositor?.begin(ctx);\r\n\r\n if (renderQueue.needSceneColor() && sceneColorCopyTex) {\r\n const compositor = ctx.compositor;\r\n ctx.compositor = null;\r\n const isolateSceneColorDepth = frame.options.needsTransmissionDepthForSSR;\r\n const savedDepthPrepassAttachment = ctx.depthPrepassAttachment;\r\n const savedClearDepth = _scenePass.clearDepth;\r\n const savedClearStencil = _scenePass.clearStencil;\r\n const savedMaterialFlags = ctx.materialFlags;\r\n\r\n // Use RenderGraph-allocated sceneColorCopy texture\r\n const sceneColorMaterialFlags = ctx.materialFlags & ~SURFACE_MRT_FLAGS;\r\n const sceneColorFramebuffer = sceneColorCopyFramebufferHandle\r\n ? rgCtx.getFramebuffer<FrameBuffer>(sceneColorCopyFramebufferHandle)\r\n : rgCtx.createFramebuffer<FrameBuffer>({\r\n width: sceneColorCopyTex.width,\r\n height: sceneColorCopyTex.height,\r\n colorAttachments: sceneColorCopyTex,\r\n depthAttachment: isolateSceneColorDepth ? ctx.depthFormat : depthTex,\r\n ignoreDepthStencil: false\r\n });\r\n let sceneColorStatePushed = false;\r\n try {\r\n device.pushDeviceStates();\r\n sceneColorStatePushed = true;\r\n device.setFramebuffer(sceneColorFramebuffer);\r\n _scenePass.transmission = false;\r\n if (isolateSceneColorDepth) {\r\n ctx.depthPrepassAttachment = undefined;\r\n _scenePass.clearDepth = 1;\r\n _scenePass.clearStencil = 0;\r\n }\r\n ctx.materialFlags = sceneColorMaterialFlags;\r\n _scenePass.render(ctx, null, null, renderQueue);\r\n } finally {\r\n ctx.materialFlags = savedMaterialFlags;\r\n if (isolateSceneColorDepth) {\r\n ctx.depthPrepassAttachment = savedDepthPrepassAttachment;\r\n _scenePass.clearDepth = savedClearDepth;\r\n _scenePass.clearStencil = savedClearStencil;\r\n }\r\n if (sceneColorStatePushed) {\r\n device.popDeviceStates();\r\n }\r\n ctx.compositor = compositor;\r\n }\r\n ctx.sceneColorTexture = sceneColorCopyTex;\r\n blitToCurrentColorAttachment(ctx, ctx.sceneColorTexture);\r\n _scenePass.transmission = true;\r\n _scenePass.clearColor = null;\r\n _scenePass.clearDepth = null;\r\n _scenePass.clearStencil = null;\r\n }\r\n _scenePass.render(ctx, null, null, renderQueue);\r\n}\r\n\r\n/** @internal */\r\nfunction renderTransmissionDepthPass(frame: FrameState, rgCtx: RGExecuteContext): void {\r\n renderSceneDepth(frame, frame.depthFramebuffer, rgCtx);\r\n}\r\n\r\n/** @internal */\r\nfunction renderComposite(frame: FrameState): void {\r\n const { ctx } = frame;\r\n\r\n ctx.compositor?.drawPostEffects(ctx, PostEffectLayer.end, ctx.linearDepthTexture!);\r\n ctx.compositor?.end(ctx);\r\n disposeRenderQueue(frame);\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSR_STORE_ROUGHNESS;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_PROFILE;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_DIFFUSE;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_NORMAL;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_TRANSMISSION;\r\n\r\n if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {\r\n const blitter = new CopyBlitter();\r\n blitter.srgbOut = !ctx.finalFramebuffer;\r\n const srcTex = ctx.intermediateFramebuffer.getColorAttachments()[0] as Texture2D;\r\n blitter.blit(srcTex, ctx.finalFramebuffer ?? null, fetchSampler('clamp_nearest_nomip'));\r\n }\r\n\r\n releaseIntermediateFramebuffer(frame);\r\n releaseDepthFramebuffer(frame);\r\n releaseClusteredLight(frame);\r\n restoreSunLight(frame);\r\n}\r\n\r\n// ─── Convenience: Execute Full Pipeline ─────────────────────────────\r\n\r\n/**\r\n * Build, compile, and execute the forward+ pipeline as a render graph.\r\n *\r\n * This is the drop-in replacement for `SceneRenderer._renderScene`.\r\n *\r\n * @param ctx - The draw context for this frame.\r\n * @public\r\n */\r\nexport function executeForwardPlusGraph(ctx: DrawContext): void {\r\n const device = ctx.device;\r\n const graph = new RenderGraph();\r\n let renderQueue: RenderQueue | null = null;\r\n let frame: FrameState | null = null;\r\n let executor: RenderGraphExecutor<Texture2D, FrameBuffer> | null = null;\r\n let historyManager: HistoryResourceManager<Texture2D> | null = null;\r\n let historyFrameStarted = false;\r\n\r\n try {\r\n // Cull scene first (needed to derive options)\r\n renderQueue = _scenePass.cullScene(ctx, ctx.camera);\r\n\r\n const options = deriveForwardPlusOptions(ctx.scene, ctx.camera, device.type, renderQueue);\r\n ctx.SSS = options.sss;\r\n\r\n // Ensure the camera has a history resource manager for temporal effects (TAA, motion blur)\r\n historyManager = ctx.camera.getHistoryResourceManager();\r\n if (!historyManager) {\r\n historyManager = new HistoryResourceManager<Texture2D>(_devicePoolAllocator);\r\n ctx.camera.setHistoryResourceManager(historyManager);\r\n }\r\n historyManager.beginFrame();\r\n historyFrameStarted = true;\r\n\r\n const buildResult = buildForwardPlusGraphInternal(graph, ctx, renderQueue, options);\r\n frame = buildResult.frame;\r\n\r\n const compiled = graph.compile([buildResult.backbuffer]);\r\n\r\n // Use RenderGraphExecutor for automatic resource management\r\n executor = new RenderGraphExecutor(_devicePoolAllocator, ctx.renderWidth, ctx.renderHeight);\r\n\r\n // Register imported backbuffer (if using finalFramebuffer)\r\n if (ctx.finalFramebuffer) {\r\n const backbufferTex = ctx.finalFramebuffer.getColorAttachments()[0] as Texture2D;\r\n executor.setImportedTexture(buildResult.backbuffer, backbufferTex);\r\n }\r\n historyManager.bindImportedTextures(executor);\r\n\r\n executor.execute(compiled);\r\n historyManager.commitFrame();\r\n } finally {\r\n if (historyFrameStarted) {\r\n historyManager?.discardFrame();\r\n }\r\n if (frame) {\r\n cleanupFrame(frame);\r\n } else {\r\n renderQueue?.dispose();\r\n }\r\n executor?.reset();\r\n }\r\n}\r\n"],"names":["_scenePass","LightPass","_depthPass","DepthPass","_shadowMapPass","ShadowMapPass","_clusters","_devicePoolAllocator","DevicePoolAllocator","_backDepthColorState","_frontDepthColorState","SURFACE_MRT_FLAGS","MaterialVaryingFlags","SSR_STORE_ROUGHNESS","SSS_STORE_PROFILE","SSS_STORE_DIFFUSE","SSS_STORE_NORMAL","SSS_STORE_TRANSMISSION","getClusteredLight","length","pop","ClusteredLight","freeClusteredLight","cl","push","getCoreMaterial","material","coreMaterial","hasSSSMaterialCore","subsurfaceProfile","renderQueueHasActiveSSS","renderQueue","itemList","lists","opaque","lit","unlit","list","materialList","filterActualSSSItemList","items","filter","item","drawable","getMaterial","filterActualSSSMaterialList","filtered","Set","forEach","mat","add","cloneActualSSSListInfo","source","_targetQueue","skinItemList","morphItemList","skinAndMorphItemList","instanceItemList","instanceList","cloneActualSSSBundle","targetQueue","map","info","hasAnyActualSSSItems","renderItems","some","createActualSSSRenderQueue","queue","RenderQueue","sssOpaque","dispose","emptyBundle","target","_itemList","transmission","transparent","transmission_trans","_shadowedLightList","shadowedLights","_unshadowedLightList","unshadowedLights","_sunLight","sunLight","_primaryDirectionalLight","primaryDirectionalLight","_primaryTransmissionLight","primaryTransmissionLight","_needSceneColor","_needSceneDepth","_needSceneColorWithDepth","_drawTransparent","getSurfaceTextureFormat","ctx","caps","device","getDeviceCaps","textureCaps","supportHalfFloatColorBuffer","getTextureFormatBytes","format","getTextureFormatInfo","size","shouldStoreSSSDiffuse","camera","sssStrength","sssBlurScale","shouldStoreSSSTransmission","sssTransmissionStrength","getSSSLightingTextureFormat","attachmentCount","includeSSRSurfaceMRT","colorFormat","roughnessFormat","SSRRoughnessTexture","normalFormat","SSRNormalTexture","colorBytes","fullPrecisionBytes","framebufferCaps","maxColorAttachmentBytesPerSample","getFullMipLevelCount","width","height","Math","max","floor","log2","hasSurfaceMRT","materialFlags","getLightPassColorAttachments","colorAttachment","attachments","SSSProfileTexture","SSSParamTexture","SSSDiffuseTexture","SSSTransmissionTexture","deriveForwardPlusOptions","scene","deviceType","ssr","SSR","env","light","envLight","hasRadiance","sss","SSS","needSceneColor","needSceneColorWithDepth","depthPrepass","motionVectors","TAA","motionBlur","ssrTemporal","hiZ","HiZ","ssrCalcThickness","gpuPicking","getPickResultResolveFunc","needsTransmissionDepthForSSR","buildForwardPlusGraph","graph","options","buildForwardPlusGraphInternal","backbuffer","importTexture","frame","depthFramebuffer","sunLightColor","intermediateDeviceStatePushed","renderQueueDisposed","clusteredLightReleased","sunLightRestored","orderToken","addPass","builder","done","createToken","sideEffect","setExecute","sky","update","read","clusteredLight","calculateLightIndex","pickResolveFunc","renderObjectColors","renderShadowMaps","depthPassResult","type","SSRCalcThickness","mvFormat","depthHandle","createTexture","label","motionVectorHandle","undefined","finalDepthAttachment","finalFramebuffer","getDepthAttachment","externalDepthAttachment","isTexture2D","graphDepthAttachmentHandle","depthFormat","depthAttachmentOrFormat","depthFramebufferHandle","createFramebuffer","renderWidth","renderHeight","colorAttachments","depthAttachment","ignoreDepthStencil","skyMotionVectorFramebufferHandle","addSubpass","rgCtx","getFramebuffer","renderSceneDepth","renderSkyMotionVectors","renderDepthAttachment","preLightTransmissionDepthToken","renderTransmissionDepthPass","hiZHandle","mipLevels","hiZFramebufferHandle","depthTex","hiZTex","getTexture","HiZFrameBuffer","buildHiZ","HiZTexture","historyManager","getHistoryResourceManager","lightHistoryReadBindings","compositeHistoryReadBindings","historySize","reflectHistoryHandle","importPreviousIfCompatible","RGHistoryResources","SSR_REFLECT","sizeMode","motionVectorHistoryHandle","SSR_MOTION_VECTOR","name","handle","colorHistoryHandle","TAA_COLOR","TAA_MOTION_VECTOR","sssProfileResult","profileHandle","paramHandle","normalHandle","framebufferHandle","renderForwardSSSProfile","lightPassResult","binding","sceneColorHandle","sceneColorCopyHandle","writeSSSDiffuse","writeSSSTransmission","sssLightingAttachmentCount","sssLightingFormat","sssDiffuseHandle","sssTransmissionHandle","useFinalFramebufferAsIntermediate","sceneColorFramebufferHandle","sceneColorCopyFramebufferHandle","sceneColorTex","sceneColorCopyTex","renderLightPass","renderMainLightPass","beginReadScope","texture","endReadScope","transmissionDepthToken","presentedBackbuffer","outputBackbuffer","write","renderComposite","lights","renderPass","pushDeviceStates","shadow","render","popDeviceStates","profileFramebuffer","profileTexture","paramTexture","normalTexture","depthTexture","sssRenderQueue","savedMaterialFlags","savedCompositor","compositor","savedTransmission","savedRenderOpaque","renderOpaque","savedRenderTransparent","renderTransparent","savedClearColor","clearColor","savedClearDepth","clearDepth","savedClearStencil","clearStencil","savedCommandBufferReuse","commandBufferReuse","savedProfileTexture","savedParamTexture","savedNormalTexture","profileFlags","setFramebuffer","Vector4","zero","releaseIntermediateFramebuffer","intermediateFramebuffer","releaseDepthFramebuffer","disposeRenderQueue","releaseClusteredLight","restoreSunLight","color","cleanupFrame","existingDepthFb","motionVectorTex","transmissionOverride","originDepth","encodeDepth","getColorAttachments","createColorState","setColorMask","forceColorState","forceCullMode","renderBackface","motionVectorTexture","linearDepthTexture","depthPrepassAttachment","_skyMVProgram","_skyMVBindGroup","_skyMVBox","fb","buildRenderProgram","vertex","pb","$inputs","pos","vec3","attrib","VPMatrix","mat4","uniform","prevVPMatrix","cameraPos","prevCameraPos","main","$l","worldPos","prevWorldPos","clipPos","mul","vec4","prevClipPos","z","w","$builtins","position","$outputs","currentPos","prevPos","fragment","motionVector","sub","div","xy","createBindGroup","bindGroupLayouts","BoxShape","needNormal","needUV","setValue","viewProjectionMatrix","getWorldPosition","prevPosition","setProgram","setBindGroup","setRenderStates","AbstractPostEffect","getDefaultRenderState","draw","blitToCurrentColorAttachment","framebuffer","destination","getColorAttachment","CopyBlitter","blit","fetchSampler","setViewport","setScissor","begin","isolateSceneColorDepth","savedDepthPrepassAttachment","sceneColorMaterialFlags","sceneColorFramebuffer","sceneColorStatePushed","sceneColorTexture","drawPostEffects","PostEffectLayer","end","blitter","srgbOut","srcTex","executeForwardPlusGraph","RenderGraph","executor","historyFrameStarted","cullScene","HistoryResourceManager","setHistoryResourceManager","beginFrame","buildResult","compiled","compile","RenderGraphExecutor","backbufferTex","setImportedTexture","bindImportedTextures","execute","commitFrame","discardFrame","reset"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;AAEA,MAAMA,aAAa,IAAIC,SAAAA,EAAAA;AACvB,MAAMC,aAAa,IAAIC,SAAAA,EAAAA;AACvB,MAAMC,iBAAiB,IAAIC,aAAAA,EAAAA;AAC3B,MAAMC,YAA8B,EAAE;AACtC,MAAMC,uBAAuB,IAAIC,mBAAAA,EAAAA;AACjC,IAAIC,oBAA6C,GAAA,IAAA;AACjD,IAAIC,qBAA8C,GAAA,IAAA;AAClD,MAAMC,iBACJC,GAAAA,oBAAAA,CAAqBC,mBAAmB,GACxCD,qBAAqBE,iBAAiB,GACtCF,oBAAqBG,CAAAA,iBAAiB,GACtCH,oBAAAA,CAAqBI,gBAAgB,GACrCJ,qBAAqBK,sBAAsB;AAE7C,SAASC,iBAAAA,GAAA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