zesterer / openmw-volumetric-clouds

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

Clouds Appear Overtop of Foliage (at moderate to long distances) #7

Open Professor-CDawg opened 2 years ago

Professor-CDawg commented 2 years ago

Hello! Firstly, I wanted to say this mod is incredible! It truly is the best of both worlds between the game's original atmosphere and the power of distant land/long render distances.

However, while I was testing, I noticed that sometimes the clouds appeared overtop of trees that were clearly too close to the ground for this to make sense visually. Here's an example: screenshot000 I noticed this seems to happen with all the trees until I get pretty close to them (and then the leaves sort of "pop" overtop of the clouds): screenshot001

Am I doing something wrong, or is this a bug?

I am on the latest development build of OpenMW, downloaded from the website this morning.

Thanks again for your incredible work!

zesterer commented 2 years ago

This is a duplicate of #4.

Sadly, it's not particularly easy to fix in general, but enabling A2C should significantly improve it for close objects.

OpenMW doesn't write to the depth buffer for distant translucent LoD objects, so there's no way for the post-processing cloud shader to "know" that it's part of the foreground and not the background. Fixing this properly would require support for forward pass shaders in OpenMW, or writing to depth for LoD objects.

Professor-CDawg commented 2 years ago

Ah, that makes sense.

I wonder how difficult/reasonable it would be for OpenMW to implement the necessary changes, or if this has been brought to the attention of any of the developers.

zesterer commented 2 years ago

I wonder how difficult/reasonable it would be for OpenMW to implement the necessary changes, or if this has been brought to the attention of any of the developers.

It has been brought to their attention, but the changes necessary to have this working properly are not a high priority, from what I'm told. Hopefully this changes in time!

kqr commented 4 months ago

I'm experiencing a similar problem where mist disappears entirely behind nearby foliage. In other words, if I stand in a bushy tree and look through one of its branches, I have perfect visibility even on a foggy day:

anb1o0yjgewc1

I tried setting antialias alpha test = true, and turned on MSAA (since the antialias alpha test setting is active only when antialiasing is a number greater than zero, from what I understand.) But:

  1. When I did so, the bottom half of the screen became pure white. Did I do something else wrong in the process?
  2. But also, isn't this counter to the recommendation of turning off MSAA?
zesterer commented 4 months ago

You need to both enable A2C and turn off MSAA, as mentioned above.

The wider problem is still blocked on OpenMW making changes to how and when post-processing shaders are applied.

kqr commented 4 months ago

Ah, I see, so A2C doesn't have a visible effect when MSAA is off – but it produces data that the shaders can use? Unfortunately it doesn't seem to help my case either, but I do understand the real problem is one in OpenMW and not something the shader can fix.

zesterer commented 4 months ago

What you see is not what the shader sees.

The cloud shader is determining how far away objects on the screen are (and hence how much cloud should be applied over the top) based on the depth buffer.

With A2C disabled, the entire tree branch polygon is writing to the depth buffer, so the the cloud shader sees it as just one big object on the screen (hence the weird polygonal outline you see in your screenshot: if you go in and inspect the depth buffer in a debug tool, you'll see that the tree leaves are just being represented by many large, flat planes).

With A2C enabled, the code that renders the tree branch polygon will instead only write to the depth buffer for parts of the polygon that have are not transparent (i.e: actual leaves).

Hence, "Alpha to Coverage", meaning 'the value of the alpha channel (the opacity) is used to determine what parts of the polygon should cover existing depth buffer values'.

kqr commented 4 months ago

Thanks for the explanation, that makes sense. I don't know why A2C causes strange behaviour for me, but someone else proposed a workaround that is perfect for me: installing Morrowind Optimisation Patch, which switches trees to use alpha clipping instead of alpha blending.

image

zesterer commented 4 months ago

Alpha clipping should have the same effect, yes. I'm glad you've found a solution! It's unfortunate that this issue exists, but sadly there's no way around it at the level of this mod, and only a few questionable solutions at the level of OpenMW itself. There's a reason you don't see transparency combined with volumetrics in many games!