doodlum / skyrim-community-shaders

Community-driven advanced graphics modifications for AE, SE and VR. Also fixes bugs and improves performance.
GNU General Public License v3.0
202 stars 49 forks source link

VR underwater mask is incorrect #620

Open alandtse opened 1 month ago

alandtse commented 1 month ago

This is a vanilla bug. As demonstrated by this picture, there is a mask that is being rendered that is incorrect in two ways. image

  1. The angle of the mask does not match the water surface.
  2. It isn't stereo aware and applied across the entire image so there is an eye mismatch.

This is the mask generated by ISUnderwaterMask via water.hlsl. image

I have confirmed that this is only generated with partial submersion. Full submersion uses a different effect without a mask.

Here are the vertex meshes for the mask in Flat: image

and in VR image

alandtse commented 1 month ago

The issue seems to be the underwater mesh is not a flat plane but two triangles that are not perfectly flat. The issue is that because of the fact there are only 6 vertexes, the triangle gets culled and results in a the break in the mask.

One alternative may be to build the mask with the depth buffer. During partially submerged scenes, the water line looks to be where the depth goes near 0 (but not 0). The air and water below and above quickly increase in depth. It may be possible to use that depth stencil to decide the water line. We could then put a mask below that water line (of course their is a question of determining up vs down but we can probably assume down is underwater). image

In one example, the gradient waterline pixel is depth 0.00258, and immediately below it in the water, the depth goes to .994262.