You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SSAO2RenderingPipeline from @babylonjs/core — constructor (name, scene, ratio | { ssaoRatio, blurRatio }, cameras?, forceGeometryBuffer?), the tuning properties (radius, totalStrength, base, samples, maxZ, minZAspect, epsilon, expensiveBlur), dispose(), and the scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline / detachCamerasFromRenderPipeline pair that apps use to switch it on and off.
Current behavior
It exists but throws LiteCompatError ("SSAO is not implemented in Babylon Lite"). scene.postProcessRenderPipelineManager is undefined.
Use case
Interior / furniture scenes lean on SSAO for contact shading: the gaps between cabinet fronts, inner corners of carcasses, the floor line under plinths. I am moving a kitchen configurator from Babylon.js 9 to Babylon Lite through lite-compat; without SSAO flat-lit furniture loses most of its depth cues, and this was the last rendering feature missing for us (after GlowLayer, #751).
An AO pass at ssaoRatio of the canvas: view position rebuilt from the linear depth and the projection matrix (perspective and orthographic), the normal derived from neighbouring positions, then the SSAO2 loop as in Babylon.js — Hammersley hemisphere directions with cosθ = 1 − 0.85u, the 16-entry scales table, the radius/minZAspect correction, the epsilon step and range check, the maxZ fade, and clamp(1 − totalStrength·occlusion/N + base).
The expensiveBlur bilateral box filter, horizontal then vertical: 16 taps over ±16 texels, weight 1 / (0.003 + |Δdepth|). This is what turns the thin raw AO lines into the soft wide gradients; with a narrow Gaussian the result looked nothing like Babylon.js.
Composite onto engine.scRT as black with alpha 1 − ao (alphaMode: 2, clear: false), which multiplies the resolved frame by the AO term without touching the default render task.
Measured against Babylon.js 9 on the same scenes, the raw AO maps (strength 1, base 0) match in shape and strength (mean AO 0.9916 vs 0.9935), and the darkening in a 20 mm gap between two cabinet fronts is 0.950 vs 0.959. Cost at 1920×1080 with an uncapped frame rate: 0.67 ms → 1.73 ms per frame on a desktop GPU.
Missing API
SSAO2RenderingPipelinefrom@babylonjs/core— constructor(name, scene, ratio | { ssaoRatio, blurRatio }, cameras?, forceGeometryBuffer?), the tuning properties (radius,totalStrength,base,samples,maxZ,minZAspect,epsilon,expensiveBlur),dispose(), and thescene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline / detachCamerasFromRenderPipelinepair that apps use to switch it on and off.Current behavior
It exists but throws LiteCompatError ("SSAO is not implemented in Babylon Lite").
scene.postProcessRenderPipelineManagerisundefined.Use case
Interior / furniture scenes lean on SSAO for contact shading: the gaps between cabinet fronts, inner corners of carcasses, the floor line under plinths. I am moving a kitchen configurator from Babylon.js 9 to Babylon Lite through
lite-compat; without SSAO flat-lit furniture loses most of its depth cues, and this was the last rendering feature missing for us (afterGlowLayer, #751).Minimal example
Additional context
I have a working implementation in my app-side shim on 1.30.0, again made only of native frame-graph tasks appended after the default
scenetask:createGeometryRendererTaskwith a singleVIEW_DEPTHattachment (shared with the glow layer from [compat] GlowLayer (selective glow for emissive meshes) #751).ssaoRatioof the canvas: view position rebuilt from the linear depth and the projection matrix (perspective and orthographic), the normal derived from neighbouring positions, then the SSAO2 loop as in Babylon.js — Hammersley hemisphere directions withcosθ = 1 − 0.85u, the 16-entryscalestable, theradius/minZAspectcorrection, theepsilonstep and range check, themaxZfade, andclamp(1 − totalStrength·occlusion/N + base).expensiveBlurbilateral box filter, horizontal then vertical: 16 taps over ±16 texels, weight1 / (0.003 + |Δdepth|). This is what turns the thin raw AO lines into the soft wide gradients; with a narrow Gaussian the result looked nothing like Babylon.js.engine.scRTas black with alpha1 − ao(alphaMode: 2,clear: false), which multiplies the resolved frame by the AO term without touching the default render task.Measured against Babylon.js 9 on the same scenes, the raw AO maps (strength 1, base 0) match in shape and strength (mean AO 0.9916 vs 0.9935), and the darkening in a 20 mm gap between two cabinet fronts is 0.950 vs 0.959. Cost at 1920×1080 with an uncapped frame rate: 0.67 ms → 1.73 ms per frame on a desktop GPU.
Notes that may be useful whichever way you go:
VIEW_NORMAL, because a normal attachment currently breaks on unlit Standard materials (fix(geometry): emit valid normal outputs for unlit Standard materials #747). With that fixed, the geometry normals would be the better input.VIEW_DEPTHdefaults tor32float, which a post-process can only bind on devices withfloat32-filterable; I fall back toformat: "r16float"otherwise.RenderTarget" with no public entry point (same gap as described in [compat] GlowLayer (selective glow for emissive meshes) #751).Happy to contribute this as a PR against
babylon-lite-compat(or as a nativecreateSsaoPostProcessTask) if you want it.