Try / OpenGothic

Reimplementation of Gothic 2 Notr
MIT License
1.07k stars 78 forks source link

Screen space reflections look bad on swamp water #588

Closed hwnde closed 1 month ago

hwnde commented 2 months ago

Swamp water seem to use the same SSR shader as regular water which doesn't look good with Jarkendar swamp. First, there are lots of trees there which means severe pop-in and pop-out when you turn the camera. Second, the shader assumes that there is a clear sky above which is not true for swamp since thick vegetation obstructs the sky.

I think SSR should be disabled for swamp. Realistically swamp water shouldn't be able to reflect much because of dirt. Screenshot 2024-03-01 213735

Try commented 2 months ago

Hi, @hwnde !

I think SSR should be disabled for swamp.

Sure, but how? Only useful information engine has is the Material::group - so we know that it's a water. From semi-useful data there is a texture (green'ish on swamp, blue on ocean) - this is not in use as not applicable for ocean and rivers.

hwnde commented 2 months ago

So texture is something that we could potentially use to branch the logic, correct? Another approach is to implement ray traced reflections.

Try commented 2 months ago

He are examples of textures: ocean: 0x000002047f7699b0 swamp: 0x000001ce22f71610

Naturally there are problems. This is a single texture, that does not represent any of material properties. Using them as specular - works for swamp, probably, but not for ocean. Using them for transmittance - OK, but doesn't solve anything for SSR

Another approach is to implement ray traced reflections

Ray-tracing, in current gen of api's, is very awkward to use. It give us a 'hit', but then engine would have to evaluate(expensive) color at the hit-point. Animation is also something what doesn't just works. And even if we solve RT - this is only small subsets of GPU's.

hwnde commented 2 months ago

Did some experiments - I tried overriding alphaFunc for specific materials. The best results seem to be produced with Multiply - looks very close / identical to the original.

Screenshot 2024-03-04 214811

Try commented 1 month ago

The best results seem to be produced with Multiply - looks very close / identical to the original.

Multiply, while maybe works for swamp case, but completely ruins effect in open areas, such as harbor
изображение

Main issue is still stands - engine need to be aware, if sky is reachable, similar to sky-occlusion maps in modern engines