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

About the new AO color implementation #4

Closed ButzYung closed 1 year ago

ButzYung commented 1 year ago

My understanding is that AO is about darkening, but this isn't always the case in your new AO color implementation.

gl_FragColor = vec4( mix(sceneTexel.rgb, color, 1.0 - finalAo), sceneTexel.a);

If color is black (default), everything is fine. However, imagine the scenario when color is brighter than the sceneTexel. The AO color would actually lighten up the pixel. Shouldn't the AO color be a "multiply" operation, something like this?

gl_FragColor = vec4( sceneTexel.rgb * mix(color, vec3(1.0), finalAo), sceneTexel.a);

N8python commented 1 year ago

I was torn about how to implement this - as a simple "multiply" operation would make the AO color look weird, if not wrong, on colored surfaces. For instance - a blue tinted AO would not appear on a red surface. There's probably a better algorithm out there for this...

N8python commented 1 year ago

Switched to multiply blending for now, as you are right that it looks better.