wave-harmonic / crest

A class-leading water system implemented in Unity
MIT License
3.39k stars 473 forks source link

[HDRP] sometimes underwater postprocess is enabled above water #655

Closed banan5555 closed 3 years ago

banan5555 commented 3 years ago

Describe the bug Sometimes underwater postprocess is enabled above water

Screenshots / video

Screenshot

https://www.youtube.com/watch?v=AcR_2XzU-qk

Log No crest related warnings / errors.

Versions Crest 4.5, Unity 2019.4.10f1, HDRP 7.4.3

To Reproduce This is very rare case it shows up once a few days. When it happen once,(until restart) it is easy to reproduce like in video. But after game restart it works fine another 20 times.

Platform Windows 10 x64

Hardware GPU GTX 1070

daleeidd commented 3 years ago

Thank you for reporting. What is the value of the Horizontal Safety Margin Multiplier? Are you using dynamic resolution?

banan5555 commented 3 years ago

Horizontal Safety Margin Multiplier: 0.3 (we have to use it to avoid horizontal line issue) We don't use dynamic resolution

daleeidd commented 3 years ago

When the issue happens, could you check the following in the Frame Debugger? In the command list, navigate to the following: HDRenderPipeline::Render / PostProcessing / CustomPostProcessBefore / \ / Draw Procedural. Then see if __FULL_SCREENEFFECT is in Keywords.

banan5555 commented 3 years ago

Ok, i reproduce it on editor it is related to Time provider. I run game 10 times and 9 times it work properly and last time I joined server and time was synchronize with server issue appears. I compere logs from those 10 logins and first 9 tries I join 'young' servers so time send to me was ~200-500 seconds and it works without issues, but then I join to really old one and: 'Time from server received [ms]: 84851,98' When I stop synchronization and just provide this time to Custom time provider issue is reproduced :) image

banan5555 commented 3 years ago

screen with answer for your question here: image

daleeidd commented 3 years ago

Thanks. That should be perfect for testing.

In the UnderwaterPostProcessUtils file, after the following line:

bool forceFullShader = (cameraYPosition + nearPlaneFrustumWorldHeight + maxOceanVerticalDisplacement) <= seaLevel;

Can you add:

forceFullShader = forceFullShader && waterHeightLevelDifference < 0f;

And after the following line:

float seaLevel = OceanRenderer.Instance.SeaLevel;

Can you add:

float waterHeightLevelDifference = 0f;

And then remove the float for the following line:

float waterHeightLevelDifference = seaLevelHeightDifference;
banan5555 commented 3 years ago

image image I looks like it is harder to reproduce and in first impression i thought that it is fixed. But when most of camera is underwater it shows again.

daleeidd commented 3 years ago

On the following line:

forceFullShader = forceFullShader && waterHeightLevelDifference < 0f;

If you change the 0 to something like -2 then it should go away. I don't know if it will solve it for every case as I recall there being edge cases which are difficult to solve. The more you decrease that number the further down the full screen effect takes over. -2 seems like a safe and reliable value. I'll have to look into something better if I can reproduce the issue myself.

banan5555 commented 3 years ago

Great! Thanks! No issue with '-2' :)

huwb commented 3 years ago

Closing as it sounds fixed(ish?), and is hopefully fixed even more with 4.10's improvement which should make the effect more stable.

daleeidd commented 3 years ago

The fix described here will be out for everyone in 4.12.