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
Screen Space Ambient Occlusion (abbreviated to SSAO) is meant here as a general notion of a post processing algorithm obscuring pixels on screen. If I talk about the classic SSAO algorithm, I'll use the following syntax: SSAO
Is your feature request related to a problem? Please describe.
The SSAO approach used in three.js (like SSAOPass or SAOPass) is only suitable for applying on indirectly lit surfaces. Start using direct lights in the scene, and the render is incorrect, as the AO texture will thoughtlessly obscure lit and unlit surfaces alike. This is not the expected result. This is why SSAO is generally used in deferred shading, but from what I've been able to gather, deferred shading is a very complex feature and as such is not supported by three.js
Describe the solution you'd like
The idea is to use the SSAO computed texture directly as an AO map in the three.js pipeline, and a first approach is to use projected vertex coordinates on screen as uv2. This does not work (see below), so a new parameter is required.
The SSAO map would be passed to the material. It would look like something like this:
object.material=newTHREE.MeshStandardMaterial()// Similarly to what we can do right now with an AO map... object.material.aoMap=aoTexture;object.material.needsUpdate=true;// .. we could have the same feature for that SSAO map object.material.ssaoMap=ssaoRenderTarget.texture;object.material.needsUpdate=true;
To do that, we need to extend the material lib and the AO shaders a bit, and pass the current renderer/renderTarget size to the fragment shader, with that we'll be able to retrieve the AO from the SSAO map like this:
We'll then be able to use the ao value for the rest of the pipeline calculations without a problem, accounting for direct lights as expected.
I have already forked the library and made a dedicated branch: link
Changes required are small but occur in several files. However, it could be used for any per-pixel ambient occlusion algorithm. So I wonder what are your thought about this ?
Describe alternatives you've considered
I tried to project vertices positions on screen to get uv2 coordinates in screen space and pass the SSAO map in standard aoMap parameter. It has some interesting results, but shows big artefacts due to perspective projection and uv2 interpolation.
Using an SSAO Pass (notice how the yellow areas are darkened instead of going back to orange) (demo):
Using my forked three.js, passing the ao map to the material (demo):
I work at Dioxygen Software, we are mainly making 3D configurators (www.dualbox.com), but also develop custom online 3D modelers and specialized viewers for businesses. All based on Three.js
The text was updated successfully, but these errors were encountered:
Important note
Screen Space Ambient Occlusion (abbreviated to SSAO) is meant here as a general notion of a post processing algorithm obscuring pixels on screen. If I talk about the classic SSAO algorithm, I'll use the following syntax:
SSAO
Is your feature request related to a problem? Please describe.
The SSAO approach used in three.js (like
SSAOPass
orSAOPass
) is only suitable for applying on indirectly lit surfaces. Start using direct lights in the scene, and the render is incorrect, as the AO texture will thoughtlessly obscure lit and unlit surfaces alike. This is not the expected result. This is why SSAO is generally used in deferred shading, but from what I've been able to gather, deferred shading is a very complex feature and as such is not supported by three.jsDescribe the solution you'd like
The idea is to use the SSAO computed texture directly as an AO map in the three.js pipeline, and a first approach is to use projected vertex coordinates on screen as uv2. This does not work (see below), so a new parameter is required.
The SSAO map would be passed to the material. It would look like something like this:
To do that, we need to extend the material lib and the AO shaders a bit, and pass the current renderer/renderTarget size to the fragment shader, with that we'll be able to retrieve the AO from the SSAO map like this:
We'll then be able to use the ao value for the rest of the pipeline calculations without a problem, accounting for direct lights as expected.
I have already forked the library and made a dedicated branch: link
Changes required are small but occur in several files. However, it could be used for any per-pixel ambient occlusion algorithm. So I wonder what are your thought about this ?
Describe alternatives you've considered
I tried to project vertices positions on screen to get uv2 coordinates in screen space and pass the SSAO map in standard aoMap parameter. It has some interesting results, but shows big artefacts due to perspective projection and uv2 interpolation.
I made a dedicated repo for this approach : link
Additional context
Using an
SSAO
Pass (notice how the yellow areas are darkened instead of going back to orange) (demo):Using my forked three.js, passing the ao map to the material (demo):
I work at Dioxygen Software, we are mainly making 3D configurators (www.dualbox.com), but also develop custom online 3D modelers and specialized viewers for businesses. All based on Three.js
The text was updated successfully, but these errors were encountered: