wave-harmonic / crest

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

MSAA maxes depth cache value where geometry ends #473

Open daleeidd opened 4 years ago

daleeidd commented 4 years ago

Describe the bug I have noticed intermittent lines with the same colour as the shallow subsurface scattering appear in the main scene with MSAA enabled. It appears where the depth cache camera bounds intersects with the island geometry or where the geometry ends.

Screenshots / video

SSSS Game It is hard to notice in the thumbnail (see large version), but there is a cyan line

SSSS Scene Scene view with the camera depth bounds and camera transform

Screenshot (150) Screenshot (151)

The line doesn't appear if either shallow subsurface scattering or MSAA is disabled.

Versions Appears on both BIRP and URP. Not sure about HDRP

To Reproduce Turn MSAA on in the main scene.

Platform

Additional context Changing the ocean depth camera scale will move the line around. Having the bounds cover the geometry seems to fix the problem for the main scene, but this might not be an option where a continuous terrain is required. I tested on another terrain and this trick didn't work.

I tried baking the depth cache with MSAA disabled and using it with MSAA enabled, but it didn't have an effect. So it must have something to do with sampling.

daleeidd commented 4 years ago

Edited the post since I was able to reproduce with a case where the geometry were within the camera bounds.

huwb commented 4 years ago

Thanks for this!

Does it happen with the SG shader in URP?

Some depths within a pixel subsamples may be set to zfar and funny things can happen if the depth is not sampled carefully. It might be that this is handled better when using the Scene Depth node in SG.

daleeidd commented 4 years ago

It happens with both SG and non SG.

huwb commented 4 years ago

On reread I think I misunderstood before, this is related to the depth cache?

I can't see the issue on the above screenshots - is it at the horizon?

Not sure how depth caches would affect the ocean in the distance!

World it be possible to maybe get a temporary branch checked in with the camera showing the issue?

daleeidd commented 4 years ago

this is related to the depth cache?

Yes. Sorry. I wasn't very clear.

78986010-99c99c80-7b6d-11ea-9999-750dd1282aac 78986218-1b212f00-7b6e-11ea-927f-c2a9165d298d

It can be difficult to see in pictures. You'll have to open the larger image to see it.

World it be possible to maybe get a temporary branch checked in with the camera showing the issue?

Sure.

daleeidd commented 4 years ago

Here is the branch: test/msaa-shallow-sss

andrew-sidereal commented 3 years ago

Eagerly awaiting a resolution to this.

daleeidd commented 3 years ago

@andrew-sidereal The shallow SSS feature will removed once we added better controls for tweaking SSS values which will give much nicer results. Then this will no longer be an issue. #722 works towards than end.