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.

fix(postprocess): ssao and gtao take a radius down to a centimetre

yhhe1f2c3d11b79
diff --git a/sdk/src/postprocess/effects.ts b/sdk/src/postprocess/effects.ts
index 1eb63df5d..f764bf174 100644
--- a/sdk/src/postprocess/effects.ts
+++ b/sdk/src/postprocess/effects.ts
@@ -566,7 +566,7 @@ registerEffect({
uniforms: [
// A WORLD length: positions come back in world space, so this is "how far
// around a point counts as its neighbourhood", not a pixel count.
- { name: 'u_radius', label: 'Radius', min: 1, max: 400, step: 1, defaultValue: 60 },
+ { name: 'u_radius', label: 'Radius', min: 0.01, max: 400, step: 0.01, defaultValue: 60 },
{ name: 'u_intensity', label: 'Intensity', min: 0, max: 2, step: 0.01, defaultValue: 1 },
// How far above the tangent plane a sample must sit to count. This is
// what keeps a flat floor from occluding itself into grey.
@@ -614,7 +614,7 @@ registerEffect({
// The horizon-based estimator in place of the ring of samples: no bias to tune against a surface occluding itself,
// so a flat floor stays white and a crease darkens by how closed it really is. The blur and the composite are SSAO's.
uniforms: [
- { name: 'u_radius', label: 'Radius', min: 1, max: 500, step: 1, defaultValue: 80 },
+ { name: 'u_radius', label: 'Radius', min: 0.01, max: 500, step: 0.01, defaultValue: 80 },
{ name: 'u_intensity', label: 'Intensity', min: 0, max: 2, step: 0.01, defaultValue: 1 },
{ name: 'u_power', label: 'Power', min: 0.5, max: 4, step: 0.05, defaultValue: 1.4, neutralValue: 1 },
// 0 trusts every occluder to be as tall as it looks; 1 lets a thin one (a railing, a leaf) be seen past.
diff --git a/sdk/src/postprocess/gtao.ts b/sdk/src/postprocess/gtao.ts
index 510f14307..b41097973 100644
--- a/sdk/src/postprocess/gtao.ts
+++ b/sdk/src/postprocess/gtao.ts
@@ -19,7 +19,7 @@ export const gtaoPasses = {
const source = `#pragma shader "PP GTAO"
#pragma version 300 es
#pragma domain PostProcess
-#pragma param u_radius float default(80) range(1,500)
+#pragma param u_radius float default(80) range(0.01,500)
#pragma param u_intensity float default(1) range(0,2)
#pragma param u_power float default(1.4) range(0.5,4)
#pragma param u_thickness float default(0.5) range(0,1)
diff --git a/sdk/src/postprocess/sources/lighting.ts b/sdk/src/postprocess/sources/lighting.ts
index c01151fbf..980151965 100644
--- a/sdk/src/postprocess/sources/lighting.ts
+++ b/sdk/src/postprocess/sources/lighting.ts
@@ -1490,7 +1490,7 @@ ${WGSL}
const source = `#pragma shader "PP SSAO"
#pragma version 300 es
#pragma domain PostProcess
-#pragma param u_radius float default(60) range(1,400)
+#pragma param u_radius float default(60) range(0.01,400)
#pragma param u_intensity float default(1) range(0,2)
#pragma param u_bias float default(0.12) range(0,0.6)
#pragma param u_power float default(1.6) range(0.5,4)