@carbonenginejs/runtime 0.1.0-alpha.6 → 0.1.0-alpha.7
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.
Potentially problematic release.
This version of @carbonenginejs/runtime might be problematic. Click here for more details.
- package/dist/global/consts/effectPaths.js +4 -1
- package/dist/global/consts/effectPaths.js.map +1 -1
- package/dist/global/consts/index.js +1 -1
- package/dist/global/index.js +1 -1
- package/dist/index.js +3 -3
- package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js +19 -2
- package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/resource/format/index.js +1 -1
- package/dist/resource/formats/hlsl/core/carbonTypedViews.js +121 -65
- package/dist/resource/formats/hlsl/core/carbonTypedViews.js.map +1 -1
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js +10 -7
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/resource/formats/webgpu/core/effectBackendBodySet.js +3 -1
- package/dist/resource/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/resource/formats/webgpu/core/packageEffect.js +5 -0
- package/dist/resource/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/emitWgsl.js +20 -0
- package/dist/resource/formats/webgpu/core/wgsl/emitWgsl.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/emulatedAddressing.js +93 -4
- package/dist/resource/formats/webgpu/core/wgsl/emulatedAddressing.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js +74 -64
- package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/lowerFragmentProgram.js +16 -7
- package/dist/resource/formats/webgpu/core/wgsl/lowerFragmentProgram.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/wgslTypedViews.js +69 -27
- package/dist/resource/formats/webgpu/core/wgsl/wgslTypedViews.js.map +1 -1
- package/dist/resource/geometry/registerGeometryResources.js +10 -1
- package/dist/resource/geometry/registerGeometryResources.js.map +1 -1
- package/dist/sof/EveSOFDNA.js +4 -2
- package/dist/sof/EveSOFDNA.js.map +1 -1
- package/dist/sof/EveSOFDataMgr.js +83 -69
- package/dist/sof/EveSOFDataMgr.js.map +1 -1
- package/dist/trinity/core/Tr2Denoiser.js +6 -1
- package/dist/trinity/core/Tr2Denoiser.js.map +1 -1
- package/dist/trinity/core/Tr2ShadowMap.js +7 -2
- package/dist/trinity/core/Tr2ShadowMap.js.map +1 -1
- package/dist/trinity/core/context/Tr2RenderContext.js +43 -0
- package/dist/trinity/core/context/Tr2RenderContext.js.map +1 -1
- package/dist/trinity/core/device/Tr2GpuStructuredBuffer.js +134 -0
- package/dist/trinity/core/device/Tr2GpuStructuredBuffer.js.map +1 -0
- package/dist/trinity/core/index.js +1 -0
- package/dist/trinity/core/index.js.map +1 -1
- package/dist/trinity/core/lighting/Tr2LightManager.js +410 -124
- package/dist/trinity/core/lighting/Tr2LightManager.js.map +1 -1
- package/dist/trinity/eve/effect/lensflare/EveLensflare.js +303 -312
- package/dist/trinity/eve/effect/lensflare/EveLensflare.js.map +1 -1
- package/dist/trinity/eve/effect/lensflare/EveOccluder.js +117 -0
- package/dist/trinity/eve/effect/lensflare/EveOccluder.js.map +1 -0
- package/dist/trinity/eve/index.js +1 -0
- package/dist/trinity/eve/index.js.map +1 -1
- package/dist/trinity/eve/scene/EveSpaceScene.js +286 -6
- package/dist/trinity/eve/scene/EveSpaceScene.js.map +1 -1
- package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js +212 -32
- package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js.map +1 -1
- package/dist/trinity/generated/eve/effect/index.js +0 -1
- package/dist/trinity/generated/eve/effect/index.js.map +1 -1
- package/dist/trinity/generated/eve/index.js +0 -1
- package/dist/trinity/generated/eve/index.js.map +1 -1
- package/dist/trinity/generated/index.js +0 -2
- package/dist/trinity/generated/index.js.map +1 -1
- package/dist/trinity/generated/trinityCore/index.js +0 -1
- package/dist/trinity/generated/trinityCore/index.js.map +1 -1
- package/dist/trinity/index.js +2 -2
- package/dist/trinity/postProcess/Tr2PostProcessRenderer.js +4 -1
- package/dist/trinity/postProcess/Tr2PostProcessRenderer.js.map +1 -1
- package/dist/trinity/postProcess/Tr2SSAO.js +282 -21
- package/dist/trinity/postProcess/Tr2SSAO.js.map +1 -1
- package/dist/trinity/shader/parameter/Tr2RuntimeTextureParameter.js +71 -53
- package/dist/trinity/shader/parameter/Tr2RuntimeTextureParameter.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js +81 -18
- package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuResourceSetAL.js +46 -4
- package/dist/trinityal/webgpu/CjsWebgpuResourceSetAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderAL.js +32 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderProgramAL.js +27 -0
- package/dist/trinityal/webgpu/CjsWebgpuShaderProgramAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js +29 -4
- package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuPsoDescription.js +32 -2
- package/dist/trinityal/webgpu/core/CjsWebgpuPsoDescription.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js +57 -5
- package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuWorkQueue.js +111 -5
- package/dist/trinityal/webgpu/core/CjsWebgpuWorkQueue.js.map +1 -1
- package/docs/trinity/reference/classes/generated.md +20 -20
- package/docs/trinity/reference/classes/post-process.md +1 -1
- package/package.json +1 -1
- package/dist/trinity/generated/eve/effect/EveOccluder.js +0 -38
- package/dist/trinity/generated/eve/effect/EveOccluder.js.map +0 -1
- package/dist/trinity/generated/trinityCore/Tr2GpuStructuredBuffer.js +0 -48
- package/dist/trinity/generated/trinityCore/Tr2GpuStructuredBuffer.js.map +0 -1
|
@@ -1,16 +1,52 @@
|
|
|
1
1
|
import { identity as _identity, applyDecs2311 as _applyDecs2311 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { edit, type, carbon, impl } from '#schema';
|
|
3
3
|
import { CjsModel } from '#model';
|
|
4
|
+
import { mat4 } from '#math/mat4';
|
|
5
|
+
import { Tr2GpuUsage, PixelFormat, ShaderType, TextureType } from '#consts/render-context';
|
|
6
|
+
import { Failed, Tr2ConstantUsageAL } from '#trinityal';
|
|
7
|
+
import { ResourceRequirement } from '#resource';
|
|
4
8
|
import { SSAOQuality } from '../generated/trinityCore/enums.js';
|
|
9
|
+
import { Tr2Effect as _Tr2Effect } from '../shader/Tr2Effect.js';
|
|
10
|
+
import { PER_OBJECT_VS, Tr2Renderer as _Tr2Renderer } from '../core/Tr2Renderer.js';
|
|
11
|
+
import { GpuResourceHandle } from '../core/Tr2GpuResourcePool/GpuResourceHandle.js';
|
|
5
12
|
import { blue, EnumRegistrationType } from '#blue';
|
|
6
13
|
|
|
7
14
|
let _initProto, _initClass, _init_quality, _init_extra_quality, _init_cortaoBentNormal, _init_extra_cortaoBentNormal, _init_zoomLevel, _init_extra_zoomLevel, _init_shadowClamp, _init_extra_shadowClamp, _init_shadowPower, _init_extra_shadowPower, _init_shadowMultiplier, _init_extra_shadowMultiplier, _init_cortaoBlur, _init_extra_cortaoBlur, _init_cortaoEnabled, _init_extra_cortaoEnabled, _init_sharpness, _init_extra_sharpness, _init_enabled, _init_extra_enabled, _init_cortaoMipBias, _init_extra_cortaoMipBias, _init_cortaoMaxBlockerSearchRadius, _init_extra_cortaoMaxBlockerSearchRadius, _init_cortaoRadius, _init_extra_cortaoRadius, _init_cortaoStrength, _init_extra_cortaoStrength, _init_downsampled, _init_extra_downsampled, _init_radius, _init_extra_radius;
|
|
8
15
|
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
/** CORTAO's effects and lookup table (`Tr2SSAO.cpp:99, 102, 108`). */
|
|
17
|
+
const CORTAO_EFFECT_PATH = "res:/Graphics/Effect/Managed/Space/System/CORTAO/CORTAO.fx";
|
|
18
|
+
const CORTAO_BLUR_EFFECT_PATH = "res:/Graphics/Effect/Managed/Space/System/CORTAO/Blur.fx";
|
|
19
|
+
const CORTAO_LOOKUP_TABLE_PATH = "res:/texture/ssao/24x24x16x16.dds";
|
|
20
|
+
|
|
21
|
+
/** The SAMPLE_COUNT option per `SSAOQuality`, highest first (`Tr2SSAO.cpp:647-653`). */
|
|
22
|
+
const SAMPLE_COUNTS = Object.freeze(["SAMPLE_COUNT_16", "SAMPLE_COUNT_12", "SAMPLE_COUNT_8", "SAMPLE_COUNT_6", "SAMPLE_COUNT_4"]);
|
|
23
|
+
|
|
24
|
+
/** sizeof( CortaoPerObjectData ) (`Tr2SSAO.h:59-86`). */
|
|
25
|
+
const CORTAO_PER_OBJECT_DATA_SIZE = 176;
|
|
26
|
+
|
|
27
|
+
/** The kernels' thread-group edges (`Tr2SSAO.cpp:675, 680, 689`). */
|
|
28
|
+
const PACK_WORK_GROUP_SIZE = 8;
|
|
29
|
+
const MAIN_PASS_WORK_GROUP_SIZE = 16;
|
|
30
|
+
const BLUR_WORK_GROUP_SIZE = 8;
|
|
31
|
+
|
|
32
|
+
/** Carbon's float literal for 2π (`Tr2SSAO.cpp:617`). */
|
|
33
|
+
const TWO_PI = 6.283185307179586476925286766559;
|
|
34
|
+
|
|
35
|
+
/** Every CORTAO target is computed into and then sampled. */
|
|
36
|
+
const CORTAO_USAGE = Tr2GpuUsage.UNORDERED_ACCESS | Tr2GpuUsage.SHADER_RESOURCE;
|
|
37
|
+
|
|
38
|
+
/** Carbon's file-local DispatchSize (`Tr2SSAO.cpp:42-45`): groups covering a size. */
|
|
39
|
+
function DispatchSize(tileSize, totalSize) {
|
|
40
|
+
return Math.floor((totalSize + tileSize - 1) / tileSize);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Carbon's SSAO: its authored settings and quality controls, and the CORTAO
|
|
45
|
+
* filter that turns the depth and normal maps into the SSAOMap.
|
|
46
|
+
*
|
|
47
|
+
* Carbon has two filters. CORTAO is the one it runs (`m_cortaoEnabled` is set
|
|
48
|
+
* in the constructor, `Tr2SSAO.cpp:20`) and the one ported here; CACAO
|
|
49
|
+
* (`PerformPass`, AMD's FidelityFX CACAO) is not.
|
|
14
50
|
*/
|
|
15
51
|
let _Tr2SSAO;
|
|
16
52
|
new class extends _identity {
|
|
@@ -22,11 +58,7 @@ new class extends _identity {
|
|
|
22
58
|
} = _applyDecs2311(this, [type.define({
|
|
23
59
|
className: "Tr2SSAO",
|
|
24
60
|
family: "trinityCore"
|
|
25
|
-
})], [[[edit, edit.notify, edit, edit.readwrite, type, type.int32, void 0, type.enum("trinity.SSAOQuality")], 16, "quality"], [[edit, edit.notify, edit, edit.readwrite, edit, edit.persist, type, type.boolean], 16, "cortaoBentNormal"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "zoomLevel"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "shadowClamp"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "shadowPower"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "shadowMultiplier"], [[edit, edit.notify, edit, edit.readwrite, type, type.boolean], 16, "cortaoBlur"], [[edit, edit.notify, edit, edit.readwrite, edit, edit.persist, type, type.boolean], 16, "cortaoEnabled"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "sharpness"], [[edit, edit.readwrite, type, type.boolean], 16, "enabled"], [[edit, edit.notify, edit, edit.readwrite, type, type.float32], 16, "cortaoMipBias"], [[edit, edit.notify, edit, edit.readwrite, type, type.float32], 16, "cortaoMaxBlockerSearchRadius"], [[edit, edit.notify, edit, edit.readwrite, type, type.float32], 16, "cortaoRadius"], [[edit, edit.notify, edit, edit.readwrite, type, type.float32], 16, "cortaoStrength"], [[edit, edit.notify, edit, edit.readwrite, type, type.boolean], 16, "downsampled"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "radius"], [[carbon, carbon.method, impl, impl.implemented], 18, "Enable"], [[carbon, carbon.method, impl, impl.implemented], 18, "SetQuality"], [[carbon, carbon.method, impl, impl.
|
|
26
|
-
}
|
|
27
|
-
constructor(...args) {
|
|
28
|
-
super(...args);
|
|
29
|
-
_init_extra_radius(this);
|
|
61
|
+
})], [[[edit, edit.notify, edit, edit.readwrite, type, type.int32, void 0, type.enum("trinity.SSAOQuality")], 16, "quality"], [[edit, edit.notify, edit, edit.readwrite, edit, edit.persist, type, type.boolean], 16, "cortaoBentNormal"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "zoomLevel"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "shadowClamp"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "shadowPower"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "shadowMultiplier"], [[edit, edit.notify, edit, edit.readwrite, type, type.boolean], 16, "cortaoBlur"], [[edit, edit.notify, edit, edit.readwrite, edit, edit.persist, type, type.boolean], 16, "cortaoEnabled"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "sharpness"], [[edit, edit.readwrite, type, type.boolean], 16, "enabled"], [[edit, edit.notify, edit, edit.readwrite, type, type.float32], 16, "cortaoMipBias"], [[edit, edit.notify, edit, edit.readwrite, type, type.float32], 16, "cortaoMaxBlockerSearchRadius"], [[edit, edit.notify, edit, edit.readwrite, type, type.float32], 16, "cortaoRadius"], [[edit, edit.notify, edit, edit.readwrite, type, type.float32], 16, "cortaoStrength"], [[edit, edit.notify, edit, edit.readwrite, type, type.boolean], 16, "downsampled"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "radius"], [[carbon, carbon.method, impl, impl.implemented], 18, "Enable"], [[carbon, carbon.method, impl, impl.implemented], 18, "SetQuality"], [[carbon, carbon.method, impl, impl.adapted], 18, "Filter"], [[carbon, carbon.method, impl, impl.adapted], 18, "ComputeCORTAO"]], 0, void 0, CjsModel));
|
|
30
62
|
}
|
|
31
63
|
quality = (_initProto(this), _init_quality(this, SSAOQuality.HIGHEST));
|
|
32
64
|
cortaoBentNormal = (_init_extra_quality(this), _init_cortaoBentNormal(this, true));
|
|
@@ -56,20 +88,249 @@ new class extends _identity {
|
|
|
56
88
|
this.downsampled = Boolean(downsampled);
|
|
57
89
|
}
|
|
58
90
|
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
91
|
+
/** m_cortaoInitialized: CORTAO's effects and table are made on first use. */
|
|
92
|
+
_cortaoInitialized = (_init_extra_radius(this), false);
|
|
93
|
+
|
|
94
|
+
/** m_cortaoEffect: the Pack and MainPass kernels. */
|
|
95
|
+
_cortaoEffect = null;
|
|
96
|
+
|
|
97
|
+
/** m_cortaoBlurEffect: the two-pass (or temporal) blur. */
|
|
98
|
+
_cortaoBlurEffect = null;
|
|
99
|
+
|
|
100
|
+
/** m_cortaoLookupTable: the occlusion lookup, a 3D R16_UNORM texture. */
|
|
101
|
+
_cortaoLookupTable = null;
|
|
102
|
+
|
|
103
|
+
/** m_cortaoConstantBuffer: CortaoPerObjectData. */
|
|
104
|
+
_cortaoConstantBuffer = null;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* m_cortaoRandSeeds. Carbon never initialises them (`Tr2SSAO.h:113`), so
|
|
108
|
+
* a non-temporal frame reads whatever the allocation held; zero here.
|
|
109
|
+
*/
|
|
110
|
+
_cortaoRandSeeds = new Uint32Array(4);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Filters the depth and normal maps into the SSAO texture, or answers an
|
|
114
|
+
* empty handle when the detail layer is disabled (`Tr2SSAO.cpp:84-123`).
|
|
115
|
+
*
|
|
116
|
+
* CORTAO's effects and lookup table are made on the first call, as Carbon's
|
|
117
|
+
* are. Carbon's GPU regions are not ported.
|
|
118
|
+
*
|
|
119
|
+
* @param {object} depthBuffer The scene depth, a `Tr2TextureAL`.
|
|
120
|
+
* @param {object} normalBuffer The depth pass's normal map, a `Tr2TextureAL`.
|
|
121
|
+
* @param {object} gpuResourcePool The driver's `Tr2GpuResourcePool`.
|
|
122
|
+
* @param {object} renderContext The render context.
|
|
123
|
+
* @param {boolean} temporal Whether a temporal pass (TAA or a temporal
|
|
124
|
+
* upscaler) follows, which reseeds the sampling every frame.
|
|
125
|
+
* @returns {GpuResourceHandle} The SSAO texture, or an empty handle.
|
|
126
|
+
* @throws {Error} When CORTAO is off: the CACAO path is not ported.
|
|
127
|
+
*/
|
|
128
|
+
Filter(depthBuffer, normalBuffer, gpuResourcePool, renderContext, temporal) {
|
|
129
|
+
if (!this.enabled) return new GpuResourceHandle();
|
|
130
|
+
if (!this.cortaoEnabled) {
|
|
131
|
+
throw new Error("Tr2SSAO.Filter: the CACAO path (PerformPass) is not ported; CORTAO is.");
|
|
132
|
+
}
|
|
133
|
+
if (!this._cortaoInitialized) {
|
|
134
|
+
this._cortaoEffect = new _Tr2Effect();
|
|
135
|
+
this._cortaoEffect.SetEffectPathName(CORTAO_EFFECT_PATH);
|
|
136
|
+
this._cortaoBlurEffect = new _Tr2Effect();
|
|
137
|
+
this._cortaoBlurEffect.SetEffectPathName(CORTAO_BLUR_EFFECT_PATH);
|
|
138
|
+
this._cortaoLookupTable = blue.resMan.GetResource(CORTAO_LOOKUP_TABLE_PATH, {
|
|
139
|
+
requirement: ResourceRequirement.TEXTURE
|
|
140
|
+
});
|
|
141
|
+
this._cortaoInitialized = true;
|
|
142
|
+
}
|
|
143
|
+
return this.ComputeCORTAO(depthBuffer, normalBuffer, gpuResourcePool, renderContext, temporal);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Carbon's private ComputeCORTAO (`Tr2SSAO.cpp:540-714`): packs depth and
|
|
148
|
+
* normals into a mipped R32_FLOAT texture, runs the main pass into the
|
|
149
|
+
* output, and blurs it twice through a second target.
|
|
150
|
+
*
|
|
151
|
+
* The pool textures Carbon holds as locals (the packed buffer, the blur
|
|
152
|
+
* buffer) are freed before returning; the output is the caller's.
|
|
153
|
+
*
|
|
154
|
+
* Adapted in three places. The constants bind at `PER_OBJECT_VS`, the value
|
|
155
|
+
* of Carbon's static `Tr2Renderer::GetPerObjectVSStartRegister()`, which is
|
|
156
|
+
* an instance method here. The view, projection and clip planes come from
|
|
157
|
+
* the render context, which holds Tr2Renderer's camera state in this
|
|
158
|
+
* runtime. Carbon's GPU regions are not ported.
|
|
159
|
+
*
|
|
160
|
+
* @param {object} depthBuffer The scene depth.
|
|
161
|
+
* @param {object} normalBuffer The normal map.
|
|
162
|
+
* @param {object} gpuResourcePool The driver's pool.
|
|
163
|
+
* @param {object} renderContext The render context.
|
|
164
|
+
* @param {boolean} temporal Whether to reseed and blur temporally.
|
|
165
|
+
* @returns {GpuResourceHandle} The SSAO texture, or an empty handle.
|
|
63
166
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
167
|
+
ComputeCORTAO(depthBuffer, normalBuffer, gpuResourcePool, renderContext, temporal) {
|
|
168
|
+
const width = depthBuffer.GetWidth();
|
|
169
|
+
const height = depthBuffer.GetHeight();
|
|
170
|
+
|
|
171
|
+
// One mip per halving while the larger side stays at least 32, up to 8.
|
|
172
|
+
let mipLevels = 1;
|
|
173
|
+
let res = Math.max(width, height);
|
|
174
|
+
for (; mipLevels < 8; mipLevels++) {
|
|
175
|
+
res = Math.floor(res / 2);
|
|
176
|
+
if (res < 32) break;
|
|
177
|
+
}
|
|
178
|
+
const packedBuffer = gpuResourcePool.GetTempTexture("cortao_packed", this._Target(width, height, mipLevels, PixelFormat.PIXEL_FORMAT_R32_FLOAT));
|
|
179
|
+
const packed = packedBuffer.Get();
|
|
180
|
+
try {
|
|
181
|
+
if (!this._cortaoConstantBuffer?.IsValid()) {
|
|
182
|
+
this._cortaoConstantBuffer = renderContext.CreateConstantBuffer();
|
|
183
|
+
if (Failed(this._cortaoConstantBuffer.Create(CORTAO_PER_OBJECT_DATA_SIZE, Tr2ConstantUsageAL.REUSABLE, null, renderContext))) {
|
|
184
|
+
return new GpuResourceHandle();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const {
|
|
188
|
+
result,
|
|
189
|
+
data
|
|
190
|
+
} = this._cortaoConstantBuffer.Lock(renderContext);
|
|
191
|
+
if (Failed(result) || !data) return new GpuResourceHandle();
|
|
192
|
+
this._FillCortaoPerObjectData(new DataView(data.buffer, data.byteOffset, CORTAO_PER_OBJECT_DATA_SIZE), width, height, packed.GetMipCount(), temporal, renderContext);
|
|
193
|
+
if (Failed(this._cortaoConstantBuffer.Unlock(renderContext))) return new GpuResourceHandle();
|
|
194
|
+
if (!renderContext.SetConstants(this._cortaoConstantBuffer, ShaderType.COMPUTE_SHADER, PER_OBJECT_VS)) return new GpuResourceHandle();
|
|
195
|
+
const outputFormat = this.cortaoBentNormal ? PixelFormat.PIXEL_FORMAT_R8G8B8A8_SNORM : PixelFormat.PIXEL_FORMAT_R8_UNORM;
|
|
196
|
+
const outputTarget = gpuResourcePool.GetTempTexture("cortao_output", this._Target(width, height, 1, outputFormat));
|
|
197
|
+
const output = outputTarget.Get();
|
|
198
|
+
const bentNormal = this.cortaoBentNormal ? "BENT_NORMAL_ENABLED" : "BENT_NORMAL_DISABLED";
|
|
199
|
+
const cortao = this._cortaoEffect;
|
|
200
|
+
cortao.SetOption("SAMPLE_COUNT", SAMPLE_COUNTS[this.quality]);
|
|
201
|
+
cortao.SetOption("BENT_NORMAL", bentNormal);
|
|
202
|
+
cortao.SetParameter("NormalBuffer", normalBuffer);
|
|
203
|
+
cortao.SetParameter("DepthBuffer", depthBuffer);
|
|
204
|
+
|
|
205
|
+
// Every mip slot is set, "to ensure no warnings produced by unset
|
|
206
|
+
// resources" (Tr2SSAO.cpp:659-665); past the last mip they repeat it.
|
|
207
|
+
for (let i = 0; i < 8; i++) {
|
|
208
|
+
cortao.SetParameter(`PackedOutputBuffer${i}`, packed, Math.min(i, packed.GetMipCount() - 1));
|
|
209
|
+
}
|
|
210
|
+
cortao.SetParameter("PackedBuffer", packed);
|
|
211
|
+
cortao.SetParameter("LookupTable", this._cortaoLookupTable);
|
|
212
|
+
cortao.SetParameter("OutputBuffer", output);
|
|
213
|
+
_Tr2Renderer.runComputeShader(cortao, "Pack", DispatchSize(PACK_WORK_GROUP_SIZE, width), DispatchSize(PACK_WORK_GROUP_SIZE, height), 1, renderContext);
|
|
214
|
+
_Tr2Renderer.runComputeShader(cortao, "MainPass", DispatchSize(MAIN_PASS_WORK_GROUP_SIZE, width), DispatchSize(MAIN_PASS_WORK_GROUP_SIZE, height), 1, renderContext);
|
|
215
|
+
if (this.cortaoBlur) {
|
|
216
|
+
const blurBuffer = gpuResourcePool.GetTempTexture("cortao_blur", this._Target(width, height, 1, outputFormat));
|
|
217
|
+
const blur = this._cortaoBlurEffect;
|
|
218
|
+
const groupsX = DispatchSize(BLUR_WORK_GROUP_SIZE, width);
|
|
219
|
+
const groupsY = DispatchSize(BLUR_WORK_GROUP_SIZE, height);
|
|
220
|
+
try {
|
|
221
|
+
blur.SetParameter("PackedDataBuffer", packed);
|
|
222
|
+
blur.SetOption("BENT_NORMAL", bentNormal);
|
|
223
|
+
blur.SetOption("MODE", temporal ? "MODE_TEMPORAL" : "MODE_PASS1");
|
|
224
|
+
blur.SetParameter("SSAOInputBuffer", output);
|
|
225
|
+
blur.SetParameter("SSAOOutputBuffer", blurBuffer.Get());
|
|
226
|
+
_Tr2Renderer.runComputeShader(blur, "Blur", groupsX, groupsY, 1, renderContext);
|
|
227
|
+
blur.SetOption("MODE", temporal ? "MODE_TEMPORAL" : "MODE_PASS2");
|
|
228
|
+
blur.SetParameter("SSAOInputBuffer", blurBuffer.Get());
|
|
229
|
+
blur.SetParameter("SSAOOutputBuffer", output);
|
|
230
|
+
_Tr2Renderer.runComputeShader(blur, "Blur", groupsX, groupsY, 1, renderContext);
|
|
231
|
+
} finally {
|
|
232
|
+
gpuResourcePool.Free(blurBuffer);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return outputTarget;
|
|
236
|
+
} finally {
|
|
237
|
+
gpuResourcePool.Free(packedBuffer);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Fills CortaoPerObjectData (`Tr2SSAO.h:59-86`) as Carbon's lock block does
|
|
243
|
+
* (`Tr2SSAO.cpp:569-636`).
|
|
244
|
+
*
|
|
245
|
+
* Carbon's `_rc` is element `(r - 1) * 4 + (c - 1)` here: the row-major and
|
|
246
|
+
* column-major byte layouts coincide. Near and far are read from the back
|
|
247
|
+
* and front clip, as Carbon reads them (`Tr2SSAO.cpp:575-576`); with
|
|
248
|
+
* Tr2Renderer's clip derivation (`Tr2Renderer.cpp:81-82`) that hands the
|
|
249
|
+
* shader far as "near" and near as "far", which is what linearises a
|
|
250
|
+
* reversed depth buffer.
|
|
251
|
+
*
|
|
252
|
+
* @param {DataView} view The locked buffer.
|
|
253
|
+
* @param {number} width Render width.
|
|
254
|
+
* @param {number} height Render height.
|
|
255
|
+
* @param {number} mipCount The packed buffer's mip count.
|
|
256
|
+
* @param {boolean} temporal Whether to reseed.
|
|
257
|
+
* @param {object} renderContext The context holding the view and projection.
|
|
258
|
+
*/
|
|
259
|
+
_FillCortaoPerObjectData(view, width, height, mipCount, temporal, renderContext) {
|
|
260
|
+
const viewMatrix = renderContext.GetViewTransform();
|
|
261
|
+
const projection = renderContext.GetProjection();
|
|
262
|
+
const inverseProjection = mat4.invert(mat4.create(), projection);
|
|
263
|
+
|
|
264
|
+
// Tr2Renderer's UpdateProjectionParameters (Tr2Renderer.cpp:81-82).
|
|
265
|
+
const frontClip = projection[10] ? projection[14] / projection[10] : 0;
|
|
266
|
+
const backClip = projection[14] / (1 + projection[10]);
|
|
267
|
+
const nearPlane = Math.fround(backClip);
|
|
268
|
+
const farPlane = Math.fround(frontClip);
|
|
269
|
+
const floats = (offset, ...values) => values.forEach((value, index) => view.setFloat32(offset + index * 4, value, true));
|
|
270
|
+
const uints = (offset, ...values) => values.forEach((value, index) => view.setUint32(offset + index * 4, value >>> 0, true));
|
|
271
|
+
|
|
272
|
+
// resolution
|
|
273
|
+
floats(0, width, height, 1 / width, 1 / height);
|
|
274
|
+
|
|
275
|
+
// projectionParams
|
|
276
|
+
floats(16, 0.5 * projection[0], -0.5 * projection[5], -0.5 + projection[8] * 0.5, -0.5 + projection[9] * -0.5);
|
|
277
|
+
|
|
278
|
+
// unprojectParams
|
|
279
|
+
floats(32, 2 * inverseProjection[0], -2 * inverseProjection[5], -inverseProjection[0] + inverseProjection[12], inverseProjection[5] - inverseProjection[13]);
|
|
280
|
+
|
|
281
|
+
// depthParams, radius, normalBias
|
|
282
|
+
floats(48, (nearPlane - farPlane) / (nearPlane * farPlane), 1 / nearPlane, this.cortaoRadius, inverseProjection[0] * Math.SQRT2 / width);
|
|
283
|
+
const maxApparentCircleRadius = this.cortaoMaxBlockerSearchRadius * 2 * Math.min(inverseProjection[0], inverseProjection[5]);
|
|
284
|
+
const circleBias = Math.log2(projection[0] * width * 0.5);
|
|
285
|
+
|
|
286
|
+
// maxApparentCircleRadiusCoefficient, mipBias, radiusMultiplier, lookupOccluderRadiusScale
|
|
287
|
+
floats(64, maxApparentCircleRadius / Math.sqrt(maxApparentCircleRadius * maxApparentCircleRadius + 1), this.cortaoMipBias + circleBias, this.cortaoStrength, 1);
|
|
288
|
+
|
|
289
|
+
// Carbon adds the C runtime's rand(), 0..RAND_MAX (32767 on MSVC).
|
|
290
|
+
if (temporal) {
|
|
291
|
+
for (let i = 0; i < 4; i++) {
|
|
292
|
+
this._cortaoRandSeeds[i] = _Tr2SSAO.hash(this._cortaoRandSeeds[i] + Math.floor(Math.random() * 32768));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// randomVectorSeedX, randomVectorSeedY, randomAngleOffset, inverseMaxSlopeWeight
|
|
297
|
+
uints(80, this._cortaoRandSeeds[0], this._cortaoRandSeeds[1]);
|
|
298
|
+
floats(88, Math.fround(TWO_PI / Math.fround(0xFFFFFFFF)) * Math.fround(this._cortaoRandSeeds[2]), 1 / 5);
|
|
299
|
+
|
|
300
|
+
// The view without its translation, after a bias taking [0, 1] to
|
|
301
|
+
// [-1, +1]. Carbon's row-vector `biasMatrix * normalMatrix`, with
|
|
302
|
+
// biasMatrix = ScalingMatrix( 2 ) * TranslationMatrix( -1 ), is gl-matrix's
|
|
303
|
+
// `normalMatrix * biasMatrix`; the same bytes, then transposed.
|
|
304
|
+
const normalMatrix = mat4.copy(mat4.create(), viewMatrix);
|
|
305
|
+
normalMatrix[12] = 0;
|
|
306
|
+
normalMatrix[13] = 0;
|
|
307
|
+
normalMatrix[14] = 0;
|
|
308
|
+
const biasMatrix = mat4.fromValues(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, -1, -1, -1, 1);
|
|
309
|
+
const biased = mat4.multiply(mat4.create(), normalMatrix, biasMatrix);
|
|
310
|
+
floats(96, ...mat4.transpose(biased, biased));
|
|
311
|
+
|
|
312
|
+
// mipCount and the three padding words
|
|
313
|
+
uints(160, mipCount, 0, 0, 0);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** A CORTAO pool target: a 2D texture computed into and sampled. */
|
|
317
|
+
_Target(width, height, mipCount, format) {
|
|
318
|
+
return {
|
|
319
|
+
type: TextureType.TEX_TYPE_2D,
|
|
320
|
+
width,
|
|
321
|
+
height,
|
|
322
|
+
depth: 1,
|
|
323
|
+
mipCount,
|
|
324
|
+
format,
|
|
325
|
+
gpuUsage: CORTAO_USAGE
|
|
326
|
+
};
|
|
66
327
|
}
|
|
67
328
|
|
|
68
|
-
/**
|
|
69
|
-
* Carbon Hash (Tr2SSAO.cpp:535): `n * (n ^ (n >> 15))` - the integer
|
|
70
|
-
* bit-mix that decorrelates per-frame/per-pixel sampling. Static in
|
|
71
|
-
* Carbon (a file-local-style helper on the class), uint32 wrap preserved
|
|
72
|
-
* with imul.
|
|
329
|
+
/**
|
|
330
|
+
* Carbon Hash (Tr2SSAO.cpp:535): `n * (n ^ (n >> 15))` - the integer
|
|
331
|
+
* bit-mix that decorrelates per-frame/per-pixel sampling. Static in
|
|
332
|
+
* Carbon (a file-local-style helper on the class), uint32 wrap preserved
|
|
333
|
+
* with imul.
|
|
73
334
|
*/
|
|
74
335
|
static hash(n) {
|
|
75
336
|
const value = n >>> 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tr2SSAO.js","sources":["../../../../src/trinity/postProcess/Tr2SSAO.js"],"sourcesContent":["// Carbon source: trinity/trinity/Tr2SSAO.h\r\n// Carbon source: trinity/trinity/Tr2SSAO.cpp\r\n// Carbon source: trinity/trinity/Tr2SSAO_Blue.cpp\r\nimport { carbon, impl, edit, type } from \"#schema\";\r\nimport { CjsModel } from \"#model\";\r\nimport { SSAOQuality } from \"../generated/trinityCore/enums.js\";\r\nimport { blue, EnumRegistrationType } from \"#blue\";\r\n\r\n\r\n/**\r\n * Carbon's authored SSAO settings and quality controls.\r\n *\r\n * Physical CACAO/CORTAO allocation, compute dispatch, and filtering remain an\r\n * explicit engine obligation.\r\n */\r\n@type.define({ className: \"Tr2SSAO\", family: \"trinityCore\" })\r\nexport class Tr2SSAO extends CjsModel\r\n{\r\n @edit.notify\r\n @edit.readwrite\r\n @type.int32\r\n @type.enum(\"trinity.SSAOQuality\")\r\n quality = SSAOQuality.HIGHEST;\r\n\r\n @edit.notify\r\n @edit.readwrite\r\n @edit.persist\r\n @type.boolean\r\n cortaoBentNormal = true;\r\n\r\n @edit.readwrite\r\n @edit.persist\r\n @type.float32\r\n zoomLevel = 5;\r\n\r\n @edit.readwrite\r\n @edit.persist\r\n @type.float32\r\n shadowClamp = 0.98;\r\n\r\n @edit.readwrite\r\n @edit.persist\r\n @type.float32\r\n shadowPower = 2.6;\r\n\r\n @edit.readwrite\r\n @edit.persist\r\n @type.float32\r\n shadowMultiplier = 1;\r\n\r\n @edit.notify\r\n @edit.readwrite\r\n @type.boolean\r\n cortaoBlur = true;\r\n\r\n @edit.notify\r\n @edit.readwrite\r\n @edit.persist\r\n @type.boolean\r\n cortaoEnabled = true;\r\n\r\n @edit.readwrite\r\n @edit.persist\r\n @type.float32\r\n sharpness = 0.5;\r\n\r\n @edit.readwrite\r\n @type.boolean\r\n enabled = true;\r\n\r\n @edit.notify\r\n @edit.readwrite\r\n @type.float32\r\n cortaoMipBias = -4;\r\n\r\n @edit.notify\r\n @edit.readwrite\r\n @type.float32\r\n cortaoMaxBlockerSearchRadius = 0.25;\r\n\r\n @edit.notify\r\n @edit.readwrite\r\n @type.float32\r\n cortaoRadius = 1e10;\r\n\r\n @edit.notify\r\n @edit.readwrite\r\n @type.float32\r\n cortaoStrength = 1;\r\n\r\n @edit.notify\r\n @edit.readwrite\r\n @type.boolean\r\n downsampled = false;\r\n\r\n @edit.readwrite\r\n @edit.persist\r\n @type.float32\r\n radius = 6;\r\n\r\n /** Enables or disables Carbon's detail SSAO layer. */\r\n @carbon.method\r\n @impl.implemented\r\n Enable(enable)\r\n {\r\n this.enabled = Boolean(enable);\r\n }\r\n\r\n /** Selects the detail-layer quality and resolution policy. */\r\n @carbon.method\r\n @impl.implemented\r\n SetQuality(quality, downsampled)\r\n {\r\n this.quality = quality;\r\n this.downsampled = Boolean(downsampled);\r\n }\r\n\r\n /**\r\n * Filters the supplied depth/normal inputs into a physical SSAO texture.\r\n *\r\n * @throws {Error} Not ported yet; Carbon implements this on the class itself.\r\n */\r\n @carbon.method\r\n @impl.notImplemented\r\n Filter(_depthBuffer, _normalBuffer, _gpuResourcePool, _renderContext, _temporal)\r\n {\r\n throw new Error(\"Tr2SSAO.Filter is not ported yet.\");\r\n }\r\n\r\n /**\r\n * Carbon Hash (Tr2SSAO.cpp:535): `n * (n ^ (n >> 15))` - the integer\r\n * bit-mix that decorrelates per-frame/per-pixel sampling. Static in\r\n * Carbon (a file-local-style helper on the class), uint32 wrap preserved\r\n * with imul.\r\n */\r\n static hash(n)\r\n {\r\n const value = n >>> 0;\r\n return Math.imul(value, value ^ (value >>> 15)) >>> 0;\r\n }\r\n\r\n static SSAOQuality = SSAOQuality;\r\n\r\n}\r\n\r\n// Carbon's chooser lists the qualities lowest first.\r\nblue.enums.RegisterEnum(\"trinity.SSAOQuality\", SSAOQuality, {\r\n source: \"trinity/trinity/Tr2SSAO.h\", family: \"postProcess\", line: 9,\r\n exposedName: \"SSAOQuality\", exposure: EnumRegistrationType.ENUM_REG_ENUM_OBJECT_ON_MODULE,\r\n chooserSource: \"trinity/trinity/Tr2SSAO_Blue.cpp:8\",\r\n chooser: [\r\n { name: \"Lowest\", value: SSAOQuality.LOWEST, description: \"Lowest quality\" },\r\n { name: \"Low\", value: SSAOQuality.LOW, description: \"Low quality\" },\r\n { name: \"Medium\", value: SSAOQuality.MEDIUM, description: \"Medium quality\" },\r\n { name: \"High\", value: SSAOQuality.HIGH, description: \"High quality\" },\r\n { name: \"Highest\", value: SSAOQuality.HIGHEST, description: \"Highest (adaptive) quality\" }\r\n ]\r\n});\r\n"],"names":["_Tr2SSAO","_identity","Tr2SSAO","CjsModel","e","_init_quality","_init_extra_quality","_init_cortaoBentNormal","_init_extra_cortaoBentNormal","_init_zoomLevel","_init_extra_zoomLevel","_init_shadowClamp","_init_extra_shadowClamp","_init_shadowPower","_init_extra_shadowPower","_init_shadowMultiplier","_init_extra_shadowMultiplier","_init_cortaoBlur","_init_extra_cortaoBlur","_init_cortaoEnabled","_init_extra_cortaoEnabled","_init_sharpness","_init_extra_sharpness","_init_enabled","_init_extra_enabled","_init_cortaoMipBias","_init_extra_cortaoMipBias","_init_cortaoMaxBlockerSearchRadius","_init_extra_cortaoMaxBlockerSearchRadius","_init_cortaoRadius","_init_extra_cortaoRadius","_init_cortaoStrength","_init_extra_cortaoStrength","_init_downsampled","_init_extra_downsampled","_init_radius","_init_extra_radius","_initProto","c","_initClass","_applyDecs","type","define","className","family","edit","notify","readwrite","int32","enum","persist","boolean","float32","carbon","method","impl","implemented","notImplemented","constructor","args","quality","SSAOQuality","HIGHEST","cortaoBentNormal","zoomLevel","shadowClamp","shadowPower","shadowMultiplier","cortaoBlur","cortaoEnabled","sharpness","enabled","cortaoMipBias","cortaoMaxBlockerSearchRadius","cortaoRadius","cortaoStrength","downsampled","radius","Enable","enable","Boolean","SetQuality","Filter","_depthBuffer","_normalBuffer","_gpuResourcePool","_renderContext","_temporal","Error","hash","n","value","Math","imul","blue","enums","RegisterEnum","source","line","exposedName","exposure","EnumRegistrationType","ENUM_REG_ENUM_OBJECT_ON_MODULE","chooserSource","chooser","name","LOWEST","description","LOW","MEDIUM","HIGH"],"mappings":";;;;;;;;AASA;AACA;AACA;AACA;AACA;AACA;AALA,IAAAA;AAAA,IAAA,cAAAC,SAAA,CAAA;AAAA,EAAA,QAMA,MAAAC,OAAA,SAC6BC,QAAQ,CACrC;AAAA,IAAA;AAAA,MAAA,CAAA;AAAAC,QAAAA,CAAA,EAAA,CAAAC,aAAA,EAAAC,mBAAA,EAAAC,sBAAA,EAAAC,4BAAA,EAAAC,eAAA,EAAAC,qBAAA,EAAAC,iBAAA,EAAAC,uBAAA,EAAAC,iBAAA,EAAAC,uBAAA,EAAAC,sBAAA,EAAAC,4BAAA,EAAAC,gBAAA,EAAAC,sBAAA,EAAAC,mBAAA,EAAAC,yBAAA,EAAAC,eAAA,EAAAC,qBAAA,EAAAC,aAAA,EAAAC,mBAAA,EAAAC,mBAAA,EAAAC,yBAAA,EAAAC,kCAAA,EAAAC,wCAAA,EAAAC,kBAAA,EAAAC,wBAAA,EAAAC,oBAAA,EAAAC,0BAAA,EAAAC,iBAAA,EAAAC,uBAAA,EAAAC,YAAA,EAAAC,k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I,EAAE,QAAQ;IAAEd,KAAK,EAAE9B,WAAW,CAACgD,MAAM;AAAEF,IAAAA,WAAW,EAAE;AAAiB,GAAC,EAC5E;AAAEF,IAAAA,IAAI,EAAE,MAAM;IAAEd,KAAK,EAAE9B,WAAW,CAACiD,IAAI;AAAEH,IAAAA,WAAW,EAAE;AAAe,GAAC,EACtE;AAAEF,IAAAA,IAAI,EAAE,SAAS;IAAEd,KAAK,EAAE9B,WAAW,CAACC,OAAO;AAAE6C,IAAAA,WAAW,EAAE;GAA8B;AAE9F,CAAC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Tr2SSAO.js","sources":["../../../../src/trinity/postProcess/Tr2SSAO.js"],"sourcesContent":["// Carbon source: trinity/trinity/Tr2SSAO.h\n// Carbon source: trinity/trinity/Tr2SSAO.cpp\n// Carbon source: trinity/trinity/Tr2SSAO_Blue.cpp\nimport { carbon, impl, edit, type } from \"#schema\";\nimport { CjsModel } from \"#model\";\nimport { mat4 } from \"#math/mat4\";\nimport { PixelFormat, ShaderType, TextureType, Tr2GpuUsage } from \"#consts/render-context\";\nimport { Failed, Tr2ConstantUsageAL } from \"#trinityal\";\nimport { ResourceRequirement } from \"#resource\";\nimport { SSAOQuality } from \"../generated/trinityCore/enums.js\";\nimport { Tr2Effect } from \"../shader/Tr2Effect.js\";\nimport { PER_OBJECT_VS, Tr2Renderer } from \"../core/Tr2Renderer.js\";\nimport { GpuResourceHandle } from \"../core/Tr2GpuResourcePool/GpuResourceHandle.js\";\nimport { blue, EnumRegistrationType } from \"#blue\";\n\n/** CORTAO's effects and lookup table (`Tr2SSAO.cpp:99, 102, 108`). */\nconst CORTAO_EFFECT_PATH = \"res:/Graphics/Effect/Managed/Space/System/CORTAO/CORTAO.fx\";\nconst CORTAO_BLUR_EFFECT_PATH = \"res:/Graphics/Effect/Managed/Space/System/CORTAO/Blur.fx\";\nconst CORTAO_LOOKUP_TABLE_PATH = \"res:/texture/ssao/24x24x16x16.dds\";\n\n/** The SAMPLE_COUNT option per `SSAOQuality`, highest first (`Tr2SSAO.cpp:647-653`). */\nconst SAMPLE_COUNTS = Object.freeze([\n \"SAMPLE_COUNT_16\",\n \"SAMPLE_COUNT_12\",\n \"SAMPLE_COUNT_8\",\n \"SAMPLE_COUNT_6\",\n \"SAMPLE_COUNT_4\"\n]);\n\n/** sizeof( CortaoPerObjectData ) (`Tr2SSAO.h:59-86`). */\nconst CORTAO_PER_OBJECT_DATA_SIZE = 176;\n\n/** The kernels' thread-group edges (`Tr2SSAO.cpp:675, 680, 689`). */\nconst PACK_WORK_GROUP_SIZE = 8;\nconst MAIN_PASS_WORK_GROUP_SIZE = 16;\nconst BLUR_WORK_GROUP_SIZE = 8;\n\n/** Carbon's float literal for 2π (`Tr2SSAO.cpp:617`). */\nconst TWO_PI = 6.283185307179586476925286766559;\n\n/** Every CORTAO target is computed into and then sampled. */\nconst CORTAO_USAGE = Tr2GpuUsage.UNORDERED_ACCESS | Tr2GpuUsage.SHADER_RESOURCE;\n\n/** Carbon's file-local DispatchSize (`Tr2SSAO.cpp:42-45`): groups covering a size. */\nfunction DispatchSize(tileSize, totalSize)\n{\n return Math.floor((totalSize + tileSize - 1) / tileSize);\n}\n\n/**\n * Carbon's SSAO: its authored settings and quality controls, and the CORTAO\n * filter that turns the depth and normal maps into the SSAOMap.\n *\n * Carbon has two filters. CORTAO is the one it runs (`m_cortaoEnabled` is set\n * in the constructor, `Tr2SSAO.cpp:20`) and the one ported here; CACAO\n * (`PerformPass`, AMD's FidelityFX CACAO) is not.\n */\n@type.define({ className: \"Tr2SSAO\", family: \"trinityCore\" })\nexport class Tr2SSAO extends CjsModel\n{\n @edit.notify\n @edit.readwrite\n @type.int32\n @type.enum(\"trinity.SSAOQuality\")\n quality = SSAOQuality.HIGHEST;\n\n @edit.notify\n @edit.readwrite\n @edit.persist\n @type.boolean\n cortaoBentNormal = true;\n\n @edit.readwrite\n @edit.persist\n @type.float32\n zoomLevel = 5;\n\n @edit.readwrite\n @edit.persist\n @type.float32\n shadowClamp = 0.98;\n\n @edit.readwrite\n @edit.persist\n @type.float32\n shadowPower = 2.6;\n\n @edit.readwrite\n @edit.persist\n @type.float32\n shadowMultiplier = 1;\n\n @edit.notify\n @edit.readwrite\n @type.boolean\n cortaoBlur = true;\n\n @edit.notify\n @edit.readwrite\n @edit.persist\n @type.boolean\n cortaoEnabled = true;\n\n @edit.readwrite\n @edit.persist\n @type.float32\n sharpness = 0.5;\n\n @edit.readwrite\n @type.boolean\n enabled = true;\n\n @edit.notify\n @edit.readwrite\n @type.float32\n cortaoMipBias = -4;\n\n @edit.notify\n @edit.readwrite\n @type.float32\n cortaoMaxBlockerSearchRadius = 0.25;\n\n @edit.notify\n @edit.readwrite\n @type.float32\n cortaoRadius = 1e10;\n\n @edit.notify\n @edit.readwrite\n @type.float32\n cortaoStrength = 1;\n\n @edit.notify\n @edit.readwrite\n @type.boolean\n downsampled = false;\n\n @edit.readwrite\n @edit.persist\n @type.float32\n radius = 6;\n\n /** Enables or disables Carbon's detail SSAO layer. */\n @carbon.method\n @impl.implemented\n Enable(enable)\n {\n this.enabled = Boolean(enable);\n }\n\n /** Selects the detail-layer quality and resolution policy. */\n @carbon.method\n @impl.implemented\n SetQuality(quality, downsampled)\n {\n this.quality = quality;\n this.downsampled = Boolean(downsampled);\n }\n\n /** m_cortaoInitialized: CORTAO's effects and table are made on first use. */\n _cortaoInitialized = false;\n\n /** m_cortaoEffect: the Pack and MainPass kernels. */\n _cortaoEffect = null;\n\n /** m_cortaoBlurEffect: the two-pass (or temporal) blur. */\n _cortaoBlurEffect = null;\n\n /** m_cortaoLookupTable: the occlusion lookup, a 3D R16_UNORM texture. */\n _cortaoLookupTable = null;\n\n /** m_cortaoConstantBuffer: CortaoPerObjectData. */\n _cortaoConstantBuffer = null;\n\n /**\n * m_cortaoRandSeeds. Carbon never initialises them (`Tr2SSAO.h:113`), so\n * a non-temporal frame reads whatever the allocation held; zero here.\n */\n _cortaoRandSeeds = new Uint32Array(4);\n\n /**\n * Filters the depth and normal maps into the SSAO texture, or answers an\n * empty handle when the detail layer is disabled (`Tr2SSAO.cpp:84-123`).\n *\n * CORTAO's effects and lookup table are made on the first call, as Carbon's\n * are. Carbon's GPU regions are not ported.\n *\n * @param {object} depthBuffer The scene depth, a `Tr2TextureAL`.\n * @param {object} normalBuffer The depth pass's normal map, a `Tr2TextureAL`.\n * @param {object} gpuResourcePool The driver's `Tr2GpuResourcePool`.\n * @param {object} renderContext The render context.\n * @param {boolean} temporal Whether a temporal pass (TAA or a temporal\n * upscaler) follows, which reseeds the sampling every frame.\n * @returns {GpuResourceHandle} The SSAO texture, or an empty handle.\n * @throws {Error} When CORTAO is off: the CACAO path is not ported.\n */\n @carbon.method\n @impl.adapted\n Filter(depthBuffer, normalBuffer, gpuResourcePool, renderContext, temporal)\n {\n if (!this.enabled) return new GpuResourceHandle();\n\n if (!this.cortaoEnabled)\n {\n throw new Error(\"Tr2SSAO.Filter: the CACAO path (PerformPass) is not ported; CORTAO is.\");\n }\n\n if (!this._cortaoInitialized)\n {\n this._cortaoEffect = new Tr2Effect();\n this._cortaoEffect.SetEffectPathName(CORTAO_EFFECT_PATH);\n\n this._cortaoBlurEffect = new Tr2Effect();\n this._cortaoBlurEffect.SetEffectPathName(CORTAO_BLUR_EFFECT_PATH);\n\n this._cortaoLookupTable = blue.resMan.GetResource(CORTAO_LOOKUP_TABLE_PATH, { requirement: ResourceRequirement.TEXTURE });\n\n this._cortaoInitialized = true;\n }\n\n return this.ComputeCORTAO(depthBuffer, normalBuffer, gpuResourcePool, renderContext, temporal);\n }\n\n /**\n * Carbon's private ComputeCORTAO (`Tr2SSAO.cpp:540-714`): packs depth and\n * normals into a mipped R32_FLOAT texture, runs the main pass into the\n * output, and blurs it twice through a second target.\n *\n * The pool textures Carbon holds as locals (the packed buffer, the blur\n * buffer) are freed before returning; the output is the caller's.\n *\n * Adapted in three places. The constants bind at `PER_OBJECT_VS`, the value\n * of Carbon's static `Tr2Renderer::GetPerObjectVSStartRegister()`, which is\n * an instance method here. The view, projection and clip planes come from\n * the render context, which holds Tr2Renderer's camera state in this\n * runtime. Carbon's GPU regions are not ported.\n *\n * @param {object} depthBuffer The scene depth.\n * @param {object} normalBuffer The normal map.\n * @param {object} gpuResourcePool The driver's pool.\n * @param {object} renderContext The render context.\n * @param {boolean} temporal Whether to reseed and blur temporally.\n * @returns {GpuResourceHandle} The SSAO texture, or an empty handle.\n */\n @carbon.method\n @impl.adapted\n ComputeCORTAO(depthBuffer, normalBuffer, gpuResourcePool, renderContext, temporal)\n {\n const width = depthBuffer.GetWidth();\n const height = depthBuffer.GetHeight();\n\n // One mip per halving while the larger side stays at least 32, up to 8.\n let mipLevels = 1;\n let res = Math.max(width, height);\n\n for (; mipLevels < 8; mipLevels++)\n {\n res = Math.floor(res / 2);\n if (res < 32) break;\n }\n\n const packedBuffer = gpuResourcePool.GetTempTexture(\"cortao_packed\", this._Target(width, height, mipLevels, PixelFormat.PIXEL_FORMAT_R32_FLOAT));\n const packed = packedBuffer.Get();\n\n try\n {\n if (!this._cortaoConstantBuffer?.IsValid())\n {\n this._cortaoConstantBuffer = renderContext.CreateConstantBuffer();\n if (Failed(this._cortaoConstantBuffer.Create(CORTAO_PER_OBJECT_DATA_SIZE, Tr2ConstantUsageAL.REUSABLE, null, renderContext)))\n {\n return new GpuResourceHandle();\n }\n }\n\n const { result, data } = this._cortaoConstantBuffer.Lock(renderContext);\n\n if (Failed(result) || !data) return new GpuResourceHandle();\n\n this._FillCortaoPerObjectData(new DataView(data.buffer, data.byteOffset, CORTAO_PER_OBJECT_DATA_SIZE), width, height, packed.GetMipCount(), temporal, renderContext);\n\n if (Failed(this._cortaoConstantBuffer.Unlock(renderContext))) return new GpuResourceHandle();\n if (!renderContext.SetConstants(this._cortaoConstantBuffer, ShaderType.COMPUTE_SHADER, PER_OBJECT_VS)) return new GpuResourceHandle();\n\n const outputFormat = this.cortaoBentNormal ? PixelFormat.PIXEL_FORMAT_R8G8B8A8_SNORM : PixelFormat.PIXEL_FORMAT_R8_UNORM;\n const outputTarget = gpuResourcePool.GetTempTexture(\"cortao_output\", this._Target(width, height, 1, outputFormat));\n const output = outputTarget.Get();\n const bentNormal = this.cortaoBentNormal ? \"BENT_NORMAL_ENABLED\" : \"BENT_NORMAL_DISABLED\";\n const cortao = this._cortaoEffect;\n\n cortao.SetOption(\"SAMPLE_COUNT\", SAMPLE_COUNTS[this.quality]);\n cortao.SetOption(\"BENT_NORMAL\", bentNormal);\n\n cortao.SetParameter(\"NormalBuffer\", normalBuffer);\n cortao.SetParameter(\"DepthBuffer\", depthBuffer);\n\n // Every mip slot is set, \"to ensure no warnings produced by unset\n // resources\" (Tr2SSAO.cpp:659-665); past the last mip they repeat it.\n for (let i = 0; i < 8; i++)\n {\n cortao.SetParameter(`PackedOutputBuffer${i}`, packed, Math.min(i, packed.GetMipCount() - 1));\n }\n\n cortao.SetParameter(\"PackedBuffer\", packed);\n cortao.SetParameter(\"LookupTable\", this._cortaoLookupTable);\n cortao.SetParameter(\"OutputBuffer\", output);\n\n Tr2Renderer.runComputeShader(cortao, \"Pack\", DispatchSize(PACK_WORK_GROUP_SIZE, width), DispatchSize(PACK_WORK_GROUP_SIZE, height), 1, renderContext);\n Tr2Renderer.runComputeShader(cortao, \"MainPass\", DispatchSize(MAIN_PASS_WORK_GROUP_SIZE, width), DispatchSize(MAIN_PASS_WORK_GROUP_SIZE, height), 1, renderContext);\n\n if (this.cortaoBlur)\n {\n const blurBuffer = gpuResourcePool.GetTempTexture(\"cortao_blur\", this._Target(width, height, 1, outputFormat));\n const blur = this._cortaoBlurEffect;\n const groupsX = DispatchSize(BLUR_WORK_GROUP_SIZE, width);\n const groupsY = DispatchSize(BLUR_WORK_GROUP_SIZE, height);\n\n try\n {\n blur.SetParameter(\"PackedDataBuffer\", packed);\n blur.SetOption(\"BENT_NORMAL\", bentNormal);\n\n blur.SetOption(\"MODE\", temporal ? \"MODE_TEMPORAL\" : \"MODE_PASS1\");\n blur.SetParameter(\"SSAOInputBuffer\", output);\n blur.SetParameter(\"SSAOOutputBuffer\", blurBuffer.Get());\n Tr2Renderer.runComputeShader(blur, \"Blur\", groupsX, groupsY, 1, renderContext);\n\n blur.SetOption(\"MODE\", temporal ? \"MODE_TEMPORAL\" : \"MODE_PASS2\");\n blur.SetParameter(\"SSAOInputBuffer\", blurBuffer.Get());\n blur.SetParameter(\"SSAOOutputBuffer\", output);\n Tr2Renderer.runComputeShader(blur, \"Blur\", groupsX, groupsY, 1, renderContext);\n }\n finally\n {\n gpuResourcePool.Free(blurBuffer);\n }\n }\n\n return outputTarget;\n }\n finally\n {\n gpuResourcePool.Free(packedBuffer);\n }\n }\n\n /**\n * Fills CortaoPerObjectData (`Tr2SSAO.h:59-86`) as Carbon's lock block does\n * (`Tr2SSAO.cpp:569-636`).\n *\n * Carbon's `_rc` is element `(r - 1) * 4 + (c - 1)` here: the row-major and\n * column-major byte layouts coincide. Near and far are read from the back\n * and front clip, as Carbon reads them (`Tr2SSAO.cpp:575-576`); with\n * Tr2Renderer's clip derivation (`Tr2Renderer.cpp:81-82`) that hands the\n * shader far as \"near\" and near as \"far\", which is what linearises a\n * reversed depth buffer.\n *\n * @param {DataView} view The locked buffer.\n * @param {number} width Render width.\n * @param {number} height Render height.\n * @param {number} mipCount The packed buffer's mip count.\n * @param {boolean} temporal Whether to reseed.\n * @param {object} renderContext The context holding the view and projection.\n */\n _FillCortaoPerObjectData(view, width, height, mipCount, temporal, renderContext)\n {\n const viewMatrix = renderContext.GetViewTransform();\n const projection = renderContext.GetProjection();\n const inverseProjection = mat4.invert(mat4.create(), projection);\n\n // Tr2Renderer's UpdateProjectionParameters (Tr2Renderer.cpp:81-82).\n const frontClip = projection[10] ? projection[14] / projection[10] : 0;\n const backClip = projection[14] / (1 + projection[10]);\n const nearPlane = Math.fround(backClip);\n const farPlane = Math.fround(frontClip);\n\n const floats = (offset, ...values) => values.forEach((value, index) => view.setFloat32(offset + index * 4, value, true));\n const uints = (offset, ...values) => values.forEach((value, index) => view.setUint32(offset + index * 4, value >>> 0, true));\n\n // resolution\n floats(0, width, height, 1 / width, 1 / height);\n\n // projectionParams\n floats(16,\n 0.5 * projection[0],\n -0.5 * projection[5],\n -0.5 + projection[8] * 0.5,\n -0.5 + projection[9] * -0.5);\n\n // unprojectParams\n floats(32,\n 2 * inverseProjection[0],\n -2 * inverseProjection[5],\n -inverseProjection[0] + inverseProjection[12],\n inverseProjection[5] - inverseProjection[13]);\n\n // depthParams, radius, normalBias\n floats(48,\n (nearPlane - farPlane) / (nearPlane * farPlane),\n 1 / nearPlane,\n this.cortaoRadius,\n inverseProjection[0] * Math.SQRT2 / width);\n\n const maxApparentCircleRadius = this.cortaoMaxBlockerSearchRadius * 2 * Math.min(inverseProjection[0], inverseProjection[5]);\n const circleBias = Math.log2(projection[0] * width * 0.5);\n\n // maxApparentCircleRadiusCoefficient, mipBias, radiusMultiplier, lookupOccluderRadiusScale\n floats(64,\n maxApparentCircleRadius / Math.sqrt(maxApparentCircleRadius * maxApparentCircleRadius + 1),\n this.cortaoMipBias + circleBias,\n this.cortaoStrength,\n 1);\n\n // Carbon adds the C runtime's rand(), 0..RAND_MAX (32767 on MSVC).\n if (temporal)\n {\n for (let i = 0; i < 4; i++)\n {\n this._cortaoRandSeeds[i] = Tr2SSAO.hash(this._cortaoRandSeeds[i] + Math.floor(Math.random() * 32768));\n }\n }\n\n // randomVectorSeedX, randomVectorSeedY, randomAngleOffset, inverseMaxSlopeWeight\n uints(80, this._cortaoRandSeeds[0], this._cortaoRandSeeds[1]);\n floats(88,\n Math.fround(TWO_PI / Math.fround(0xFFFFFFFF)) * Math.fround(this._cortaoRandSeeds[2]),\n 1 / 5);\n\n // The view without its translation, after a bias taking [0, 1] to\n // [-1, +1]. Carbon's row-vector `biasMatrix * normalMatrix`, with\n // biasMatrix = ScalingMatrix( 2 ) * TranslationMatrix( -1 ), is gl-matrix's\n // `normalMatrix * biasMatrix`; the same bytes, then transposed.\n const normalMatrix = mat4.copy(mat4.create(), viewMatrix);\n\n normalMatrix[12] = 0;\n normalMatrix[13] = 0;\n normalMatrix[14] = 0;\n\n const biasMatrix = mat4.fromValues(\n 2, 0, 0, 0,\n 0, 2, 0, 0,\n 0, 0, 2, 0,\n -1, -1, -1, 1);\n const biased = mat4.multiply(mat4.create(), normalMatrix, biasMatrix);\n\n floats(96, ...mat4.transpose(biased, biased));\n\n // mipCount and the three padding words\n uints(160, mipCount, 0, 0, 0);\n }\n\n /** A CORTAO pool target: a 2D texture computed into and sampled. */\n _Target(width, height, mipCount, format)\n {\n return {\n type: TextureType.TEX_TYPE_2D,\n width,\n height,\n depth: 1,\n mipCount,\n format,\n gpuUsage: CORTAO_USAGE\n };\n }\n\n /**\n * Carbon Hash (Tr2SSAO.cpp:535): `n * (n ^ (n >> 15))` - the integer\n * bit-mix that decorrelates per-frame/per-pixel sampling. Static in\n * Carbon (a file-local-style helper on the class), uint32 wrap preserved\n * with imul.\n */\n static hash(n)\n {\n const value = n >>> 0;\n return Math.imul(value, value ^ (value >>> 15)) >>> 0;\n }\n\n static SSAOQuality = SSAOQuality;\n\n}\n\n// Carbon's chooser lists the qualities lowest first.\nblue.enums.RegisterEnum(\"trinity.SSAOQuality\", SSAOQuality, {\n source: \"trinity/trinity/Tr2SSAO.h\", family: \"postProcess\", line: 9,\n exposedName: \"SSAOQuality\", exposure: EnumRegistrationType.ENUM_REG_ENUM_OBJECT_ON_MODULE,\n chooserSource: \"trinity/trinity/Tr2SSAO_Blue.cpp:8\",\n chooser: [\n { name: \"Lowest\", value: SSAOQuality.LOWEST, description: \"Lowest quality\" },\n { name: \"Low\", value: SSAOQuality.LOW, description: \"Low quality\" },\n { name: \"Medium\", value: SSAOQuality.MEDIUM, description: \"Medium quality\" },\n { name: \"High\", value: SSAOQuality.HIGH, description: \"High quality\" },\n { name: \"Highest\", value: SSAOQuality.HIGHEST, description: \"Highest (adaptive) quality\" }\n ]\n});\n"],"names":["CORTAO_EFFECT_PATH","CORTAO_BLUR_EFFECT_PATH","CORTAO_LOOKUP_TABLE_PATH","SAMPLE_COUNTS","Object","freeze","CORTAO_PER_OBJECT_DATA_SIZE","PACK_WORK_GROUP_SIZE","MAIN_PASS_WORK_GROUP_SIZE","BLUR_WORK_GROUP_SIZE","TWO_PI","CORTAO_USAGE","Tr2GpuUsage","UNORDERED_ACCESS","SHADER_RESOURCE","DispatchSize","tileSize","totalSize","Math","floor","_Tr2SSAO","_identity","Tr2SSAO","CjsModel","e","_init_quality","_init_extra_quality","_init_cortaoBentNormal","_init_extra_cortaoBentNormal","_init_zoomLevel","_init_extra_zoomLevel","_init_shadowClamp","_init_extra_shadowClamp","_init_shadowPower","_init_extra_shadowPower","_init_shadowMultiplier","_init_extra_shadowMultiplier","_init_cortaoBlur","_init_extra_cortaoBlur","_init_cortaoEnabled","_init_extra_cortaoEnabled","_init_sharpness","_init_extra_sharpness","_init_enabled","_init_extra_enabled","_init_cortaoMipBias","_init_extra_cortaoMipBias","_init_cortaoMaxBlockerSearchRadius","_init_extra_cortaoMaxBlockerSearchRadius","_init_cortaoRadius","_init_extra_cortaoRadius","_init_cortaoStrength","_init_extra_cortaoStrength","_init_downsampled","_init_extra_downsampled","_init_radius","_init_extra_radius","_initProto","c","_initClass","_applyDecs","type","define","className","family","edit","notify","readwrite","int32","enum","persist","boolean","float32","carbon","method","impl","implemented","adapted","quality","SSAOQuality","HIGHEST","cortaoBentNormal","zoomLevel","shadowClamp","shadowPower","shadowMultiplier","cortaoBlur","cortaoEnabled","sharpness","enabled","cortaoMipBias","cortaoMaxBlockerSearchRadius","cortaoRadius","cortaoStrength","downsampled","radius","Enable","enable","Boolean","SetQuality","_cortaoInitialized","_cortaoEffect","_cortaoBlurEffect","_cortaoLookupTable","_cortaoConstantBuffer","_cortaoRandSeeds","Uint32Array","Filter","depthBuffer","normalBuffer","gpuResourcePool","renderContext","temporal","GpuResourceHandle","Error","Tr2Effect","SetEffectPathName","blue","resMan","GetResource","requirement","ResourceRequirement","TEXTURE","ComputeCORTAO","width","GetWidth","height","GetHeight","mipLevels","res","max","packedBuffer","GetTempTexture","_Target","PixelFormat","PIXEL_FORMAT_R32_FLOAT","packed","Get","IsValid","CreateConstantBuffer","Failed","Create","Tr2ConstantUsageAL","REUSABLE","result","data","Lock","_FillCortaoPerObjectData","DataView","buffer","byteOffset","GetMipCount","Unlock","SetConstants","ShaderType","COMPUTE_SHADER","PER_OBJECT_VS","outputFormat","PIXEL_FORMAT_R8G8B8A8_SNORM","PIXEL_FORMAT_R8_UNORM","outputTarget","output","bentNormal","cortao","SetOption","SetParameter","i","min","Tr2Renderer","runComputeShader","blurBuffer","blur","groupsX","groupsY","Free","view","mipCount","viewMatrix","GetViewTransform","projection","GetProjection","inverseProjection","mat4","invert","create","frontClip","backClip","nearPlane","fround","farPlane","floats","offset","values","forEach","value","index","setFloat32","uints","setUint32","SQRT2","maxApparentCircleRadius","circleBias","log2","sqrt","hash","random","normalMatrix","copy","biasMatrix","fromValues","biased","multiply","transpose","format","TextureType","TEX_TYPE_2D","depth","gpuUsage","n","imul","constructor","enums","RegisterEnum","source","line","exposedName","exposure","EnumRegistrationType","ENUM_REG_ENUM_OBJECT_ON_MODULE","chooserSource","chooser","name","LOWEST","description","LOW","MEDIUM","HIGH"],"mappings":";;;;;;;;;;;;;;;AAeA;AACA,MAAMA,kBAAkB,GAAG,4DAA4D;AACvF,MAAMC,uBAAuB,GAAG,0DAA0D;AAC1F,MAAMC,wBAAwB,GAAG,mCAAmC;;AAEpE;AACA,MAAMC,aAAa,GAAGC,MAAM,CAACC,MAAM,CAAC,CAClC,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,CACjB,CAAC;;AAEF;AACA,MAAMC,2BAA2B,GAAG,GAAG;;AAEvC;AACA,MAAMC,oBAAoB,GAAG,CAAC;AAC9B,MAAMC,yBAAyB,GAAG,EAAE;AACpC,MAAMC,oBAAoB,GAAG,CAAC;;AAE9B;AACA,MAAMC,MAAM,GAAG,gCAAg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