Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen Space Ambient Occlusion post effect #3266

Merged
merged 7 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions examples/src/examples/graphics/post-effects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PostEffectsExample extends Example {
<AssetLoader name='bokeh' type='script' url='static/scripts/posteffects/posteffect-bokeh.js' />
<AssetLoader name='sepia' type='script' url='static/scripts/posteffects/posteffect-sepia.js' />
<AssetLoader name='vignette' type='script' url='static/scripts/posteffects/posteffect-vignette.js' />
<AssetLoader name='ssao' type='script' url='static/scripts/posteffects/posteffect-ssao.js' />
<AssetLoader name='font' type='font' url='static/assets/fonts/arial.json' />
<AssetLoader name='helipad.dds' type='cubemap' url='static/assets/cubemaps/helipad.dds' data={{ type: pc.TEXTURETYPE_RGBM }}/>
</>;
Expand Down Expand Up @@ -74,13 +75,14 @@ class PostEffectsExample extends Example {

// create the towers from the boxes
let scale = 16;
for (let y = 0; y <= 6; y++) {
for (let y = 0; y <= 7; y++) {
for (let x = -1; x <= 1; x += 2) {
for (let z = 0; z <= 10; z += 2) {
createPrimitive("box", new pc.Vec3(x * 40, 2 + y * 10, z * 40), new pc.Vec3(scale, scale, scale), Math.random());
const prim = createPrimitive("box", new pc.Vec3(x * 40, 2 + y * 10, z * 40), new pc.Vec3(scale, scale, scale), Math.random());
prim.setLocalEulerAngles(Math.random() * 360, Math.random() * 360, Math.random() * 360);
}
}
scale -= 2;
scale -= 1.5;
}

// create a sphere which represents the point of focus for the bokeh filter
Expand All @@ -104,6 +106,13 @@ class PostEffectsExample extends Example {
farClip: 500
});
camera.addComponent("script");
camera.script.create("ssao", {
attributes: {
radius: 5,
samples: 16,
brightness: 0
}
});
camera.script.create("bloom", {
attributes: {
bloomIntensity: 0.8,
Expand Down Expand Up @@ -154,6 +163,10 @@ class PostEffectsExample extends Example {
camera.script.bokeh.enabled = !camera.script.bokeh.enabled;
break;
case pc.KEY_5:
// @ts-ignore engine-tsd
camera.script.ssao.enabled = !camera.script.ssao.enabled;
break;
case pc.KEY_6:
camera.camera.disablePostEffectsLayer = camera.camera.disablePostEffectsLayer === pc.LAYERID_UI ? undefined : pc.LAYERID_UI;
break;
}
Expand Down Expand Up @@ -203,7 +216,8 @@ class PostEffectsExample extends Example {
`[Key 2] Sepia: ${camera.script.sepia.enabled}\n` +
`[Key 3] Vignette: ${camera.script.vignette.enabled}\n` +
`[Key 4] Bokeh: ${camera.script.bokeh.enabled}\n` +
`[Key 5] Post-process UI: ${camera.camera.disablePostEffectsLayer !== pc.LAYERID_UI}\n`;
`[Key 5] SSAO: ${camera.script.ssao.enabled}\n` +
`[Key 6] Post-process UI: ${camera.camera.disablePostEffectsLayer !== pc.LAYERID_UI}\n`;

// display the depth textur if bokeh is enabled
if (camera.script.bokeh.enabled) {
Expand Down
Loading