zesterer / openmw-volumetric-clouds

A volumetric clouds mod for OpenMW
80 stars 12 forks source link

Improper transparency sorting on some foliage #4

Open Ophiolith opened 2 years ago

Ophiolith commented 2 years ago

I'm pretty sure this could actually be a limitation of OpenMW's postprocessing implementation, and frankly I'm not even sure if it's fixable, but nevertheless thought it worth drawing attention to - this is probably less noticeable with custom foliage, but at least on the default set there are notable transparency artifacts: transparency

transparency3

If it's unclear what is going on, fog and clouds do not render behind the foliage 'stencil' and so the regular sky and geometry before the fog pass renders through instead. It's fairly distracting.

zesterer commented 2 years ago

Unfortunately, there's not a huge amount I can do about this. The cloud shader uses the value in the depth buffer at each pixel to determine the distance light travels through the air, but it can't differentiate between an opaque surface and a translucent surface that has been blended with the background, because this information no longer exist. I'll keep the issue open because it would be nice to at least somewhat mitigate this somehow.

You can enable A2C (Alpha To Coverage) in OpenMW which should at least mitigate this: https://openmw.readthedocs.io/en/latest/reference/modding/settings/shaders.html#antialias-alpha-test

glassmancody commented 2 years ago

Yeah, blended trees (and other transparents) are re-drawn with alpha testing enabled to populate depth buffer.

If we didn't do this the entire leaf structure would be sky.

I'm not entirely sure how to get postprocess fog working with OpenMWs forward renderer. If anyone has ideas I'm all ears. Zesteter suggested fog is drawn before transparents, but we need transparents to be fogged, can't get away with bypassing that step with Morrowind content.

zesterer commented 2 years ago

I think it should be possible to do it in the forward pass, but we'll need to have the transparency of the fragment be altered by the fog too. I'm also not sure whether this will have sampling-based artifacts similar to those discussed by CMAugust in the past. Something to look into, I guess. The other alternative is to use the alpha-as-cloud-blend trick I mentioned before, although it doesn't generalise well.