N8python / n8ao

An efficient and visually pleasing implementation of SSAO with an emphasis on temporal stability and artist control.
Creative Commons Zero v1.0 Universal
371 stars 13 forks source link

Dramatically boost performance by lowering AO resolution #7

Closed fanjules closed 1 year ago

fanjules commented 1 year ago

I love the look of N8AO! However, the render performance for low end machines isn't really good enough even on very low settings, I want to hit 60fps ideally across all devices which is critical for my usage case. At the moment I would have to turn off N8AO if the FPS dropped below this level.

Now, if the render window is much smaller, the render performance improves dramatically. This is as you would expect - half the resolution reduces the pixel count by a factor of 4, quarter resolution reduces it by a factor of 16, etc.

So, I would love an option where you can change the resolution of the AO, but the regular render pass images stays at the normal resolution. Ideally, the AO shading would then be applied with bilinear filtering so it doesn't look pixelated on top of the regular image. The performance would ROCKET and any drop in image quality would be acceptable for these low end devices.

Not only that, but being able to adjust the quality modes AND the AO resolution would allow for more flexibility. In some use cases, a combination of using a lower AO resolution with higher quality mode (less noise) may look aesthetically more pleasing.

N8python commented 1 year ago

This shall be implemented. Probably w/ halfRes and quarterRes settings

fanjules commented 1 year ago

This will be amazing, can't wait!

N8python commented 1 year ago

Progress is being made. Expect for a 2-3x perf speedup.

fanjules commented 1 year ago

For fun can we have an eighthRes option too? 😁

By the way, I love the effect of N8AO! You have really added something truly wonderful for the Three.js community to include in their projects.

fanjules commented 1 year ago

I've tried the updated version and it works well on low end devices!

I found if you have low quality settings there is quite a noticeable flicker because of the noise. But if you have halfRes + mid level settings then this is much less noticeable and now I am suddenly able to bring the mid-level settings to the slower machines. 😎

Well done and thank you for implementing this so fast!

N8python commented 1 year ago

Awesome, glad it worked! Yes, low-level settings + half-res are brutal for noise. But higher settings don't cost much more and work well. That's what I was going for - glad it worked!

fanjules commented 1 year ago

A couple of problems on mobile devices when using halfRes...

On Android banding appears (the banding also appears to be in the wrong place away from the geometry). This happens on Moto G4, Moto G5, Moto G8 which are fairly close to base Android.

Image1

Then on iOS on an iPad, I get a black screen. No errors are ported in the console and the animation loop runs as normal.

Hopefully the two problems are related and an easy fix - I hate to be the bearer of bad news!

N8python commented 1 year ago

I'm so sorry I didn't see this! Pushed a possible fix.