Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(gi): a half-resolution way to add the light - one pixel in four asks the probes and every pixel takes it from the four round it; the medium level runs it, and the apply costs 0.14 ms where it cost 0.25 at 1080p

yhhb76aea1a4056
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 4728b78fd..927a91a71 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -8113,6 +8113,7 @@ antialiasing: "msaa" | "temporal"
begin: () => void
bind: (camera: Entity, stack: PostProcessStack) => void
createStack: () => PostProcessStack
+dynamicGIHalfRes: boolean
effectAllowed: (type: string) => boolean
end: () => void
getStack: (camera: Entity) => PostProcessStack | null
@@ -8590,6 +8591,7 @@ antialiasing: "msaa" | "temporal"
depthPrepass: boolean
detailScale: number
drawCallBudget: number
+dynamicGIHalfRes: boolean
lighting: "full" | "direct"
minRenderScale: number
msaaSamples: 2 | 1 | 4 | 8
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 00a30dd10..a2eb93f0e 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -8320,6 +8320,7 @@ antialiasing: "msaa" | "temporal"
begin: () => void
bind: (camera: Entity, stack: PostProcessStack) => void
createStack: () => PostProcessStack
+dynamicGIHalfRes: boolean
effectAllowed: (type: string) => boolean
end: () => void
getStack: (camera: Entity) => PostProcessStack | null
@@ -8797,6 +8798,7 @@ antialiasing: "msaa" | "temporal"
depthPrepass: boolean
detailScale: number
drawCallBudget: number
+dynamicGIHalfRes: boolean
lighting: "full" | "direct"
minRenderScale: number
msaaSamples: 2 | 1 | 4 | 8
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index 28ddea59d..13199dc5b 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -8108,6 +8108,7 @@ antialiasing: "msaa" | "temporal"
begin: () => void
bind: (camera: Entity, stack: PostProcessStack) => void
createStack: () => PostProcessStack
+dynamicGIHalfRes: boolean
effectAllowed: (type: string) => boolean
end: () => void
getStack: (camera: Entity) => PostProcessStack | null
@@ -8585,6 +8586,7 @@ antialiasing: "msaa" | "temporal"
depthPrepass: boolean
detailScale: number
drawCallBudget: number
+dynamicGIHalfRes: boolean
lighting: "full" | "direct"
minRenderScale: number
msaaSamples: 2 | 1 | 4 | 8
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 39b268c3a..2f9f00e69 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -8405,6 +8405,7 @@ antialiasing: "msaa" | "temporal"
begin: () => void
bind: (camera: Entity, stack: PostProcessStack) => void
createStack: () => PostProcessStack
+dynamicGIHalfRes: boolean
effectAllowed: (type: string) => boolean
end: () => void
getStack: (camera: Entity) => PostProcessStack | null
@@ -8882,6 +8883,7 @@ antialiasing: "msaa" | "temporal"
depthPrepass: boolean
detailScale: number
drawCallBudget: number
+dynamicGIHalfRes: boolean
lighting: "full" | "direct"
minRenderScale: number
msaaSamples: 2 | 1 | 4 | 8
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 762a3c442..9703ea283 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -8115,6 +8115,7 @@ antialiasing: "msaa" | "temporal"
begin: () => void
bind: (camera: Entity, stack: PostProcessStack) => void
createStack: () => PostProcessStack
+dynamicGIHalfRes: boolean
effectAllowed: (type: string) => boolean
end: () => void
getStack: (camera: Entity) => PostProcessStack | null
@@ -8592,6 +8593,7 @@ antialiasing: "msaa" | "temporal"
depthPrepass: boolean
detailScale: number
drawCallBudget: number
+dynamicGIHalfRes: boolean
lighting: "full" | "direct"
minRenderScale: number
msaaSamples: 2 | 1 | 4 | 8
diff --git a/sdk/src/postprocess/PostProcessAPI.ts b/sdk/src/postprocess/PostProcessAPI.ts
index c2b40be01..cdab10c19 100644
--- a/sdk/src/postprocess/PostProcessAPI.ts
+++ b/sdk/src/postprocess/PostProcessAPI.ts
@@ -263,6 +263,11 @@ export class PostProcessAPI {
return this.qualityFilter_?.antialiasing ?? 'msaa';
}
+ /** Whether the quality level in force has the dynamic GI gather at half resolution: the volume system sets the effect's switch from it. */
+ get dynamicGIHalfRes(): boolean {
+ return this.qualityFilter_?.dynamicGIHalfRes ?? false;
+ }
+
/**
* Whether the quality level in force runs an effect, by its type. For a system that prepares something for an effect off the GPU (the dynamic GI
* builds a distance field, a second of a phone's CPU): it asks before it does.
diff --git a/sdk/src/postprocess/effects.ts b/sdk/src/postprocess/effects.ts
index d477ca0d6..9d0c6140b 100644
--- a/sdk/src/postprocess/effects.ts
+++ b/sdk/src/postprocess/effects.ts
@@ -587,6 +587,8 @@ registerEffect({
// Pixels between probes; 0 keeps about 160 x 90 of them whatever the size of the picture.
{ name: 'u_probeSpacing', label: 'Probe Spacing', min: 0, max: 64, step: 1, defaultValue: 0 },
{ name: 'u_skip', label: 'Skip Passes (profiling)', min: 0, max: 63, step: 1, defaultValue: 0 },
+ // 1: one pixel in four asks the probes and the rest take the light of the four round them. A quality level below the highest turns it on.
+ { name: 'u_halfRes', label: 'Half Resolution', min: 0, max: 1, step: 1, defaultValue: 0 },
{ name: 'u_cellSize', label: 'Field Cell Size', min: 0, max: 1000, step: 0.1, defaultValue: 0, worldUnits: 1 },
],
});
diff --git a/sdk/src/postprocess/volumeSystem.ts b/sdk/src/postprocess/volumeSystem.ts
index cac8803e5..565b9848f 100644
--- a/sdk/src/postprocess/volumeSystem.ts
+++ b/sdk/src/postprocess/volumeSystem.ts
@@ -275,6 +275,8 @@ function applyBlendedEffects(
} else if (def.native) {
stack.addNativePass(effectType, def.native);
for (const u of def.uniforms) stack.setUniform(effectType, u.name, effectData.uniforms.get(u.name) ?? uniformInUnits(u).defaultValue);
+ // The quality level's say over how the dynamic GI gathers: on where the level asks, whatever the volume holds.
+ if (effectType === 'dynamicGI' && api.dynamicGIHalfRes) stack.setUniform(effectType, 'u_halfRes', 1);
} else if (def.compute) {
// The params block is the effect's uniforms in their listed order, each at the volume's value or the effect's own default.
stack.addComputePass(effectType, {
diff --git a/sdk/src/render/quality.ts b/sdk/src/render/quality.ts
index 60152e933..8dc475d00 100644
--- a/sdk/src/render/quality.ts
+++ b/sdk/src/render/quality.ts
@@ -82,6 +82,11 @@ export interface QualityProfile {
*/
shadowSoftSamples: number;
lighting: 'full' | 'direct';
+ /**
+ * Whether the dynamic GI asks its probes for one pixel in four and spreads the light to the rest: about half of what a pixel reads, for
+ * light that runs a pixel or two across an edge two surfaces share. It acts on a volume that lists `dynamicGI`, at a level that runs it.
+ */
+ dynamicGIHalfRes: boolean;
/**
* The most draws a frame at this level should ask of the GPU, every pass counted (shadows, prepass, reflections and post-processing with the
* scene). Nothing is held back to meet it: the profiler and the stats overlay show a frame over it, and the frame debugger says where the draws
@@ -149,7 +154,7 @@ const PROFILES: Record<QualityLevel, QualityProfile> = {
shadowDistance: 0, detailScale: 0.5, particleLimit: 1000, postProcess: true, ssao: false,
waterWaves: 2, waterRippleCells: 32, waterDisplacement: false, waterMirror: false, waterCaustics: false,
skipEffects: ['ssr', 'taa', 'depthOfField', 'lightShafts', 'motionBlur', 'lensFlare', 'gtao', 'subsurface', 'voxelGI', 'dynamicGI'],
- shelterMaskSize: 256, shadowSoftSamples: 8, lighting: 'direct', drawCallBudget: 150, textureStreaming: true, textureStreamingBudget: 128,
+ shelterMaskSize: 256, shadowSoftSamples: 8, lighting: 'direct', dynamicGIHalfRes: true, drawCallBudget: 150, textureStreaming: true, textureStreamingBudget: 128,
},
medium: {
renderScale: 1, minRenderScale: 0.65, msaaSamples: 2, antialiasing: 'temporal',
@@ -158,7 +163,7 @@ const PROFILES: Record<QualityLevel, QualityProfile> = {
shadowDistance: 0, detailScale: 0.8, particleLimit: 5000, postProcess: true, ssao: true,
waterWaves: 3, waterRippleCells: 64, waterDisplacement: true, waterMirror: true, waterCaustics: true,
skipEffects: ['ssr', 'depthOfField'],
- shelterMaskSize: 512, shadowSoftSamples: 12, lighting: 'direct', drawCallBudget: 400, textureStreaming: true, textureStreamingBudget: 256,
+ shelterMaskSize: 512, shadowSoftSamples: 12, lighting: 'direct', dynamicGIHalfRes: true, drawCallBudget: 400, textureStreaming: true, textureStreamingBudget: 256,
},
high: {
renderScale: 1, minRenderScale: 0.75, msaaSamples: 4, antialiasing: 'msaa',
@@ -169,7 +174,7 @@ const PROFILES: Record<QualityLevel, QualityProfile> = {
shadowDistance: 0, detailScale: 1, particleLimit: 20000, postProcess: true, ssao: true,
waterWaves: 4, waterRippleCells: 128, waterDisplacement: true, waterMirror: true, waterCaustics: true,
skipEffects: [],
- shelterMaskSize: 1024, shadowSoftSamples: 16, lighting: 'full', drawCallBudget: 1500, textureStreaming: false, textureStreamingBudget: 0,
+ shelterMaskSize: 1024, shadowSoftSamples: 16, lighting: 'full', dynamicGIHalfRes: false, drawCallBudget: 1500, textureStreaming: false, textureStreamingBudget: 0,
},
};
@@ -272,6 +277,7 @@ function resolveProfile(level: QualityLevel, value: unknown): QualityProfile {
depthPrepass: typeof r.depthPrepass === 'boolean' ? r.depthPrepass : base.depthPrepass,
postProcess: typeof r.postProcess === 'boolean' ? r.postProcess : base.postProcess,
ssao: typeof r.ssao === 'boolean' ? r.ssao : base.ssao,
+ dynamicGIHalfRes: typeof r.dynamicGIHalfRes === 'boolean' ? r.dynamicGIHalfRes : base.dynamicGIHalfRes,
waterWaves: Math.round(finite(r.waterWaves, base.waterWaves, 1, 4)),
waterRippleCells: Math.round(finite(r.waterRippleCells, base.waterRippleCells, 0, 256)),
waterDisplacement: typeof r.waterDisplacement === 'boolean' ? r.waterDisplacement : base.waterDisplacement,
diff --git a/src/esengine/renderer/frame/DynamicGI.cpp b/src/esengine/renderer/frame/DynamicGI.cpp
index 899abed34..5552041c9 100644
--- a/src/esengine/renderer/frame/DynamicGI.cpp
+++ b/src/esengine/renderer/frame/DynamicGI.cpp
@@ -572,16 +572,8 @@ fn probeTerm(tile : vec2i, q : vec2f, radius : f32, pos : vec3f, n : vec3f, eye
return true;
}
-@compute @workgroup_size(8, 8)
-fn main(@builtin(global_invocation_id) id : vec3u) {
- let size = vec2i(textureDimensions(depthTex));
- let p = vec2i(id.xy);
- if (p.x >= size.x || p.y >= size.y) { return; }
- let scene = textureLoad(sceneTex, p, 0);
- let depth = textureLoad(depthTex, p, 0);
- let g = textureLoad(gbuffer, p, 0);
- let albedo = textureLoad(albedoTex, p, 0);
- if (depth >= 1.0 || g.a <= 0.7 || albedo.a <= 0.5) { textureStore(outTex, p, scene); return; }
+// The light the probes round pixel p give it (rgb), and how far the pixel is from the eye (a).
+fn irradiance(p : vec2i, size : vec2i, depth : f32, g : vec4f) -> vec4f {
var n = decodeNormal(g);
let pos = worldFromDepth((vec2f(p) + 0.5) / vec2f(size), depth);
if (dot(n, viewDirection(pos)) < 0.0) { n = -n; }
@@ -631,6 +623,81 @@ fn main(@builtin(global_invocation_id) id : vec3u) {
}
}
if (total > 0.05) { E = E / total; } else if (totalRelaxed > 1e-5) { E = Erelaxed / totalRelaxed; } else { E = vec3f(0.0); }
+ return vec4f(E, eye);
+}
+)WGSL";
+
+// The light added to every pixel, each asking the probes itself.
+const char* kApplyFull = R"WGSL(
+@compute @workgroup_size(8, 8)
+fn main(@builtin(global_invocation_id) id : vec3u) {
+ let size = vec2i(textureDimensions(depthTex));
+ let p = vec2i(id.xy);
+ if (p.x >= size.x || p.y >= size.y) { return; }
+ let scene = textureLoad(sceneTex, p, 0);
+ let depth = textureLoad(depthTex, p, 0);
+ let g = textureLoad(gbuffer, p, 0);
+ let albedo = textureLoad(albedoTex, p, 0);
+ if (depth >= 1.0 || g.a <= 0.7 || albedo.a <= 0.5) { textureStore(outTex, p, scene); return; }
+ let E = irradiance(p, size, depth, g).rgb;
+ textureStore(outTex, p, vec4f(scene.rgb + albedo.rgb * E * gi.sdf.w, scene.a));
+}
+)WGSL";
+
+// The cheaper way, in two: one pixel in four asks the probes (this), and every pixel takes its light from the four of those round it (kComposite).
+// outTex is half the picture a side; a is the distance from the eye, or -1 where there is no surface.
+const char* kGather = R"WGSL(
+@compute @workgroup_size(8, 8)
+fn main(@builtin(global_invocation_id) id : vec3u) {
+ let size = vec2i(textureDimensions(depthTex));
+ let h = vec2i(id.xy);
+ if (h.x * 2 >= size.x + 1 || h.y * 2 >= size.y + 1) { return; }
+ let p = min(h * 2, size - vec2i(1));
+ let depth = textureLoad(depthTex, p, 0);
+ let g = textureLoad(gbuffer, p, 0);
+ if (depth >= 1.0 || g.a <= 0.7) { textureStore(outTex, h, vec4f(0.0, 0.0, 0.0, -1.0)); return; }
+ textureStore(outTex, h, irradiance(p, size, depth, g));
+}
+)WGSL";
+
+// Every pixel: the light of the four gathered pixels round it, each counting by how near it is on the screen and how nearly as far from the eye
+// (so the light of a wall does not run onto what stands in front of it). Normals are not asked: across the edge two walls share, where both are
+// as far from the eye, the light of one runs a pixel or two onto the other.
+const char* kComposite = R"WGSL(
+@group(0) @binding(6) var depthTex : texture_depth_2d;
+@group(0) @binding(8) var albedoTex : texture_2d<f32>;
+@group(0) @binding(10) var sceneTex : texture_2d<f32>;
+@group(0) @binding(11) var outTex : texture_storage_2d<rgba16float, write>;
+@group(0) @binding(13) var gathered : texture_2d<f32>;
+
+@compute @workgroup_size(8, 8)
+fn main(@builtin(global_invocation_id) id : vec3u) {
+ let size = vec2i(textureDimensions(depthTex));
+ let p = vec2i(id.xy);
+ if (p.x >= size.x || p.y >= size.y) { return; }
+ let scene = textureLoad(sceneTex, p, 0);
+ let depth = textureLoad(depthTex, p, 0);
+ let albedo = textureLoad(albedoTex, p, 0);
+ if (depth >= 1.0 || albedo.a <= 0.5) { textureStore(outTex, p, scene); return; }
+ let pos = worldFromDepth((vec2f(p) + 0.5) / vec2f(size), depth);
+ let eye = max(length(pos - frame.camera.xyz), 1.0);
+ let hs = vec2i(textureDimensions(gathered));
+ let q = vec2f(p) * 0.5;
+ let q0 = vec2i(floor(q));
+ let f = q - vec2f(q0);
+ var E = vec3f(0.0); var total = 0.0;
+ var plain = vec3f(0.0); var count = 0.0;
+ for (var k = 0; k < 4; k = k + 1) {
+ let o = vec2i(k & 1, k >> 1);
+ let v = textureLoad(gathered, clamp(q0 + o, vec2i(0), hs - vec2i(1)), 0);
+ if (v.a < 0.0) { continue; }
+ let wb = select(1.0 - f.x, f.x, o.x == 1) * select(1.0 - f.y, f.y, o.y == 1) + 0.01;
+ let off = (v.a - eye) / (0.03 * eye);
+ let w = wb / (1.0 + off * off * off * off);
+ E = E + v.rgb * w; total = total + w;
+ plain = plain + v.rgb; count = count + 1.0;
+ }
+ if (total > 0.02) { E = E / total; } else if (count > 0.0) { E = plain / count; } else { E = vec3f(0.0); }
textureStore(outTex, p, vec4f(scene.rgb + albedo.rgb * E * gi.sdf.w, scene.a));
}
)WGSL";
@@ -640,6 +707,9 @@ const char* kCardLight = "";
const char* kSurface = "";
const char* kProbe = "";
const char* kApply = "";
+const char* kApplyFull = "";
+const char* kGather = "";
+const char* kComposite = "";
#endif
/// The card relight writes the cards it reads (one buffer, updated in place): the common block declares them read-only.
@@ -671,7 +741,7 @@ void DynamicGI::release() {
if (t != TextureHandle::Invalid) device_.deleteTexture(t);
t = TextureHandle::Invalid;
}
- for (ComputeHandle* c : {&cardLight_, &probe_, &apply_}) {
+ for (ComputeHandle* c : {&cardLight_, &probe_, &apply_, &gather_, &composite_}) {
if (*c != ComputeHandle::Invalid) device_.deleteCompute(*c);
*c = ComputeHandle::Invalid;
}
@@ -702,7 +772,8 @@ bool DynamicGI::ensure() {
return true;
};
return make(cardLight_, readWriteCards(join(kCommon, kCardLight)), "card light") && make(probe_, join(kCommon, kSurface, kProbe), "probe")
- && make(apply_, join(kCommon, kSurface, kApply), "apply");
+ && make(apply_, join(kCommon, kSurface, (std::string(kApply) + kApplyFull).c_str()), "apply")
+ && make(gather_, join(kCommon, kSurface, (std::string(kApply) + kGather).c_str()), "gather") && make(composite_, join(kCommon, kSurface, kComposite), "composite");
}
bool DynamicGI::upload() {
@@ -915,6 +986,42 @@ rg::ResourceId DynamicGI::declare(rg::RenderGraph& graph, rg::ResourceId input,
}
if (params.skip & 16u) return input; // measuring: the cards and the probes, and no apply pass nor the target it writes
+ // Half resolution: the probes are asked by one pixel in four, into a target half the picture a side, and the pass below spreads it.
+ rg::ResourceId gathered = rg::kNoResource;
+ if (params.halfRes) {
+ rg::TargetDesc half;
+ half.scale = 0.5f;
+ half.format = GfxPixelFormat::RGBA16F;
+ half.storage = true;
+ half.linearFilter = false;
+ gathered = graph.createTarget(half);
+ rg::PassDesc pass;
+ pass.name = "dgi_gather";
+ pass.compute = true;
+ pass.dependencies = {scene, probed};
+ pass.write = gathered;
+ pass.execute = [this, &graph, scene, p](const rg::PassContext& ctx) {
+ if (p.skip & 4u) return;
+ const TextureHandle depth = graph.depthTextureOf(scene);
+ const TextureHandle gbuffer = graph.gbufferTextureOf(scene);
+ if (depth == TextureHandle::Invalid || gbuffer == TextureHandle::Invalid || ctx.output == TextureHandle::Invalid) return;
+ const GfxComputeBinding bindings[11] = {
+ GfxComputeBinding::uniform(0, context_.frameUbo()),
+ GfxComputeBinding::uniform(1, params_),
+ GfxComputeBinding::storageRead(2, sdf_),
+ GfxComputeBinding::storageRead(3, instances_),
+ GfxComputeBinding::storageRead(4, pixels_),
+ GfxComputeBinding::storageRead(5, radiance_[0]),
+ GfxComputeBinding::depth(6, depth),
+ GfxComputeBinding::sampled(7, gbuffer),
+ GfxComputeBinding::sampled(9, probes_[frame_ & 1u]),
+ GfxComputeBinding::storageTexture(11, ctx.output),
+ GfxComputeBinding::sampled(12, probeGeo_),
+ };
+ device_.dispatchCompute(gather_, bindings, 11, (ctx.width + 7) / 8, (ctx.height + 7) / 8);
+ };
+ graph.addPass(std::move(pass));
+ }
rg::TargetDesc full;
full.format = GfxPixelFormat::RGBA16F;
full.storage = true;
@@ -924,13 +1031,15 @@ rg::ResourceId DynamicGI::declare(rg::RenderGraph& graph, rg::ResourceId input,
rg::PassDesc pass;
pass.name = "dgi_apply";
pass.compute = true;
- pass.reads = {input};
+ pass.reads = gathered != rg::kNoResource ? std::vector<rg::ResourceId>{input, gathered} : std::vector<rg::ResourceId>{input};
pass.dependencies = {scene, probed};
pass.write = result;
pass.execute = [this, &graph, scene, p](const rg::PassContext& ctx) {
// A pixel reads the scene, the depth, the G-buffer and the albedo, and from each of the four nearest probes two geometry texels and three of light.
g_stats.applyPixels = (p.skip & 4u) ? 0.0f : static_cast<f32>(ctx.width) * static_cast<f32>(ctx.height);
- g_stats.applyLoadsPerPixel = 4.0f + 4.0f * 5.0f;
+ // Half resolution: a pixel reads the scene, the depth, the albedo and four gathered pixels, and a quarter of what a gathering pixel reads
+ // (the depth, the G-buffer, and the probes as above).
+ g_stats.applyLoadsPerPixel = p.halfRes ? 3.0f + 4.0f + (2.0f + 4.0f * 5.0f) / 4.0f : 4.0f + 4.0f * 5.0f;
g_stats.width = static_cast<f32>(ctx.width);
g_stats.height = static_cast<f32>(ctx.height);
g_stats.forcedAttachmentBytes = static_cast<f32>(ctx.width) * static_cast<f32>(ctx.height) * 12.0f;
@@ -947,6 +1056,26 @@ rg::ResourceId DynamicGI::declare(rg::RenderGraph& graph, rg::ResourceId input,
const TextureHandle albedo = graph.albedoTextureOf(scene);
if (depth == TextureHandle::Invalid || gbuffer == TextureHandle::Invalid || albedo == TextureHandle::Invalid
|| ctx.output == TextureHandle::Invalid) return;
+ if (p.halfRes) {
+ const TextureHandle half = ctx.input(1);
+ if (depth == TextureHandle::Invalid || albedo == TextureHandle::Invalid || half == TextureHandle::Invalid || ctx.output == TextureHandle::Invalid) return;
+ const GfxComputeBinding composite[11] = {
+ GfxComputeBinding::uniform(0, context_.frameUbo()),
+ GfxComputeBinding::uniform(1, params_),
+ GfxComputeBinding::storageRead(2, sdf_),
+ GfxComputeBinding::storageRead(3, instances_),
+ GfxComputeBinding::storageRead(4, pixels_),
+ GfxComputeBinding::storageRead(5, radiance_[0]),
+ GfxComputeBinding::depth(6, depth),
+ GfxComputeBinding::sampled(8, albedo),
+ GfxComputeBinding::sampled(10, ctx.input(0)),
+ GfxComputeBinding::storageTexture(11, ctx.output),
+ GfxComputeBinding::sampled(13, half),
+ };
+ device_.dispatchCompute(composite_, composite, 11, (ctx.width + 7) / 8, (ctx.height + 7) / 8);
+ ++frame_;
+ return;
+ }
const u32 cur = frame_ & 1u;
const GfxComputeBinding bindings[13] = {
GfxComputeBinding::uniform(0, context_.frameUbo()),
diff --git a/src/esengine/renderer/frame/DynamicGI.hpp b/src/esengine/renderer/frame/DynamicGI.hpp
index 52e2ad78b..60c410de7 100644
--- a/src/esengine/renderer/frame/DynamicGI.hpp
+++ b/src/esengine/renderer/frame/DynamicGI.hpp
@@ -45,6 +45,9 @@ struct DynamicGIParams {
u32 skip = 0;
/// Pixels between probes: 0 picks about 160 x 90 probes whatever the picture size.
u32 probeSpacing = 0;
+ /// The probes are asked by one pixel in four and the rest take the light of the four round them: about half the reads of a pixel, for
+ /// light that runs a pixel or two across an edge two surfaces share. What a quality level below the highest runs.
+ bool halfRes = false;
};
/**
@@ -126,6 +129,8 @@ private:
ComputeHandle cardLight_ = ComputeHandle::Invalid;
ComputeHandle probe_ = ComputeHandle::Invalid;
ComputeHandle apply_ = ComputeHandle::Invalid;
+ ComputeHandle gather_ = ComputeHandle::Invalid;
+ ComputeHandle composite_ = ComputeHandle::Invalid;
u32 uploadedVersion_ = 0;
bool failed_ = false;
u32 frame_ = 0;
diff --git a/src/esengine/renderer/frame/PostProcessPipeline.cpp b/src/esengine/renderer/frame/PostProcessPipeline.cpp
index 89487f79b..a3fd2e827 100644
--- a/src/esengine/renderer/frame/PostProcessPipeline.cpp
+++ b/src/esengine/renderer/frame/PostProcessPipeline.cpp
@@ -1340,6 +1340,7 @@ void PostProcessPipeline::runChain(std::vector<PostProcessPass>& passes, rg::Res
gi.probeStride = static_cast<u32>(std::max(get("u_probeStride", static_cast<f32>(gi.probeStride)), 1.0f));
gi.skip = static_cast<u32>(std::max(get("u_skip", 0.0f), 0.0f));
gi.probeSpacing = static_cast<u32>(std::max(get("u_probeSpacing", 0.0f), 0.0f));
+ gi.halfRes = get("u_halfRes", 0.0f) > 0.5f;
auto& cache = dynamic_gis_[temporalKey_];
if (!cache) {
if (dynamic_gis_.size() > 4) {
diff --git a/tools/gi/check-gi-cost.mjs b/tools/gi/check-gi-cost.mjs
index e615647a5..4f9ee0641 100644
--- a/tools/gi/check-gi-cost.mjs
+++ b/tools/gi/check-gi-cost.mjs
@@ -58,7 +58,8 @@ function skip(why) {
const source = readFileSync(path.join(root, 'src/esengine/renderer/frame/DynamicGI.cpp'), 'utf8');
const applySource = source.slice(source.indexOf('const char* kApply'), source.indexOf('#else', source.indexOf('const char* kApply')));
const probeTerm = applySource.slice(applySource.indexOf('fn probeTerm'), applySource.indexOf('@compute', applySource.indexOf('fn probeTerm')));
-const main = applySource.slice(applySource.indexOf('@compute'));
+// The kernel every pixel runs by default (the half-resolution pair, kGather and kComposite, is a quality level's and is not what is budgeted here).
+const main = applySource.slice(applySource.indexOf('const char* kApplyFull'), applySource.indexOf('const char* kGather'));
const loads = (text) => (text.match(/textureLoad\(/g) ?? []).length;
const mainLoads = loads(main), perProbe = loads(probeTerm);
// The geometry of a probe is read before the early-out on a probe with nothing in it; five loads a probe is what a probe that counts costs.