Jump to content

How I can exclude skybox from SSAO


BlackMojito
 Share

Recommended Posts

Hello, as the SSAO is a postprocess you can rely on a 2 cameras approach:

https://github.com/BabylonJS/Website/blob/master/Demos/DefaultRenderingPipeline/default.js

(you can see that the first camera is used to render the scene with postprocess and the second one is used for the GUI)

In your case the first camera could be just for the skybox and the second one for the actual scene

Link to comment
Share on other sites

11 hours ago, Deltakosh said:

Hello, as the SSAO is a postprocess you can rely on a 2 cameras approach:

https://github.com/BabylonJS/Website/blob/master/Demos/DefaultRenderingPipeline/default.js

(you can see that the first camera is used to render the scene with postprocess and the second one is used for the GUI)

In your case the first camera could be just for the skybox and the second one for the actual scene

Thanks, Deltakosh. Hum...but how I can sync those two cameras though? BTW, I am thinking that maybe I can just use an environment sphere which can avoid the AO problem.

Link to comment
Share on other sites

HI @BlackMojito

Here's an example of a two camera approach,
Imagine camera_A is your main camera with postprocess, 
camera_A has layerMask 2, so should any mesh you want it to render, e.g. the building in your screenshot, or the sphere in this example.

camera_B is your secondary camera with no postprocess,
camera_B has layermask 1, so does the ground mesh in this example.

So camera_A is rendering the sphere.
and camera_B is rendering the ground.

Using ArcRotateCamera's,
In a registerBeforeRender, we are updating camera_B's alpha, beta, radius and target values to match camera_A's values. (user input modifies camera_A).

Take good note on the activeCameras.push, the first camera to be pushed will render behind the second camera.

scene.activeCameras.push(camera_B, camera_A);


http://playground.babylonjs.com/#QGW698

Link to comment
Share on other sites

  • 2 weeks later...
On 11/23/2017 at 3:25 PM, aWeirdo said:

HI @BlackMojito

Here's an example of a two camera approach,
Imagine camera_A is your main camera with postprocess, 
camera_A has layerMask 2, so should any mesh you want it to render, e.g. the building in your screenshot, or the sphere in this example.

camera_B is your secondary camera with no postprocess,
camera_B has layermask 1, so does the ground mesh in this example.

So camera_A is rendering the sphere.
and camera_B is rendering the ground.

Using ArcRotateCamera's,
In a registerBeforeRender, we are updating camera_B's alpha, beta, radius and target values to match camera_A's values. (user input modifies camera_A).

Take good note on the activeCameras.push, the first camera to be pushed will render behind the second camera.

scene.activeCameras.push(camera_B, camera_A);


http://playground.babylonjs.com/#QGW698

How can I keep the depth buffer between those cameras? It seems that secondary camera clears the depth buffer rendered with the first camera though...

Link to comment
Share on other sites

Hi again @BlackMojito & @Deltakosh

I believe this and these topics;

have the same goal;
I think, what he means is that camera_A is always rendered behind camera_B, depth is "ignored" between cameras.

Example;
Only half the sphere in this PG should be visible; 
http://playground.babylonjs.com/#QGW698#4

Now, if you swap the cameras around and render camera_B before camera_A,
rotating the cameras up or down will hide the sphere behind the box, again "ignoring" depth.
http://playground.babylonjs.com/#QGW698#5 

Link to comment
Share on other sites

5 hours ago, aWeirdo said:

Hi again @BlackMojito & @Deltakosh

I believe this and these topics;

have the same goal;
I think, what he means is that camera_A is always rendered behind camera_B, depth is "ignored" between cameras.

Example;
Only half the sphere in this PG should be visible; 
http://playground.babylonjs.com/#QGW698#4

Now, if you swap the cameras around and render camera_B before camera_A,
rotating the cameras up or down will hide the sphere behind the box, again "ignoring" depth.
http://playground.babylonjs.com/#QGW698#5 

yeah right,  scene.autoClearDepthAndStencil = false cannot work for this.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...