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
378 stars 14 forks source link

AO receiver but not casting #30

Closed Ben-Mack closed 3 months ago

Ben-Mack commented 3 months ago

Thank you for creating this powerful lib!

For example in your official example, I want to enable AO for the torus only, not the building, but torus should be able to cast AO to the building, not just on itself. (It is like the building only receive AO, but not casting)

image

Please give me some guidance if you have any idea, I'd much appreciate your response!

N8python commented 3 months ago

I can make it so an object can't receive AO but can cast it - I can't, however, stop an object from casting AO (without dramatically hurting performance) - so what you could do here is have the torus not receive AO - but I can't help you w/ the floor - as if you want it to receive AO from the torus it can also receive AO from the walls. Your best bet would be making the walls transparent w/out depthwrite so they don't cast AO. Anything that touches the depth buffer, however, casts AO.

Next release of N8AO will have a way to disable AO receiving.

N8python commented 3 months ago

This has been added in release 1.8.4:

You can also simply have an object not receive AO at all (this requires rendering it twice, so it is not recommended for performance-critical applications) by setting cannotReceiveAO to true in the object's userData:

mesh.userData.cannotReceiveAO = false;

Ben-Mack commented 3 months ago

Wow! Did not expect you would add it this quick. And thank you for these suggestions, it really helps a lot!