wave-harmonic / crest

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

Screen Space Reflections (SSR) functionality #613

Closed olavrv closed 3 years ago

olavrv commented 3 years ago

Possibility to enable/disable SSR on Crest HDRP ocean material

huwb commented 3 years ago

We discussed this in the past actually - it is not supported as far as i can tell. from our discord chat:

i spent a bit of time scratching my head over SSR , turns out i couldnt get it to work on any transparent shader, and i dont think its supported.. https://forum.unity.com/threads/ssrr-on-a-transparent-or-translucent-object.408206/

if you are able to get it to work on any transparent material, let me know, as i should then be able to add it to the ocean. but i could imagine it is not supported, sadly

huwb commented 3 years ago

I took another quick look around now and did not find any updates to this.

olavrv commented 3 years ago

@huwb @daleeidd HDRP 9.0.0 now supports transparent SSR. It can be enabled in HDRP settings. It works on a standard HDRP Lit material (transparent), but not on Crest ocean shader (material). On standard HDRP Lit (transparent) material, "Receive SSR Transparent" have to be ticked on (enabled).

I tested using HDRP 9.0.0 - preview.58, Unity 2020.1.1f1

daleeidd commented 3 years ago

Thanks. We will wait for it to make its way out of preview before attempting anything. I'll re-open so others can see the issue.

daleeidd commented 3 years ago

I gave this a look and it mostly works with the shader graph version of our shader. But it is quite difficult parting out SSR and adding it to our generated shader. I think we should wait until 2020 LTS which is released around June 2021. We can change the minimum requirement to 2020 and generate a new shader gaining all the new features.

huwb commented 3 years ago

Is your thinking that it will be easier to maintain the generated shader with the LTS version, due to less change? Might still be hard to maintain 2020 Vs 2021 etc, but I'm not sure

Custom interpolators is next thing on the planned features of shadergraph, I'm counting the days until we can stop generating shaders..

daleeidd commented 3 years ago

Is your thinking that it will be easier to maintain the generated shader with the LTS version, due to less change? Might still be hard to maintain 2020 Vs 2021 etc, but I'm not sure

More so that 2020 (which will be HDRP 10 or 11) as a baseline shader will have SSR already part of it once we generate from the graph. I was under the assumption we would be jumping from LTS to LTS. So 2020 LTS is the next logical step.

Custom interpolators is next thing on the planned features of shadergraph, I'm counting the days until we can stop generating shaders..

Indeed. That will probably be a while way sadly. Only "planned" in their graphics roadmap.

olavrv commented 3 years ago

I understand your thinking from a developer perspective (being a developer ourselves), but from a user / customer of Crest perspective, this is hell on earth at the moment with how Unity is rolling out LTS versions...

daleeidd commented 3 years ago

I understand your thinking from a developer perspective (being a developer ourselves), but from a user / customer of Crest perspective, this is hell on earth at the moment with how Unity is rolling out LTS versions...

Understandable. There is a lot to consider so nothing is set in stone actually no decision has been made on what to do next. Is the issue the upgrade process itself, or waiting for the next LTS for these features?

olavrv commented 3 years ago

The issue is that Unity has been behind on many "basic" features one would expect from a AAA game engine, which they now have catched up with in 2020.2 / HDRP 10.2.x. So when when everything is working on 2020.2 / HDRP 10.2.x things should normalize, and we don't have to upgrade to the latest Unity version every time it comes out...

daleeidd commented 3 years ago

Understood. Thats good to see they have caught up. I do know we want newer shader graph features which will allow us to ship the shader graph rather than a generated shader. But that is a while away and we should be able to work something out when that comes around hopefully.

olavrv commented 3 years ago

Unity 2020.2 next release is officially spring 2021, so it would be really nice if it didn't take too long before a compatible version of crest with SSR.

I have requested some info from Unity regarding what version of HDRP will be used in the LTS release version. Will keep you posted

olavrv commented 3 years ago

I have been using the shadergraph for crest, and it works really well. Only issue in our use case is the LOD transition, where you can see a line in the transition. Is this something that could be "easily" fixed?

PS: I had a meeting with unity right before christmas, and showed them our simulator. They said they had never seen such high quality water in Unity before :D So keep up the good work!

daleeidd commented 3 years ago

I have been using the shadergraph for crest, and it works really well. Only issue in our use case is the LOD transition, where you can see a line in the transition. Is this something that could be "easily" fixed?

It can be patched in the generated shader. In the one we provide, if you search for "// Crest", you should see where we patch the vertex struct and function to fix that.

PS: I had a meeting with unity right before christmas, and showed them our simulator. They said they had never seen such high quality water in Unity before :D So keep up the good work!

Thank you for passing that on.

olavrv commented 3 years ago

@daleeidd I tried to implement the patch in the compiled shader graph code, but it made no difference... Any tips?

daleeidd commented 3 years ago

Sorry. I missed a thing. But I will provide all the other things that you will need to get the shaders on par. I recommend generating with the latest minor version to solve an issue with shader graph keywords.

You'll need to add the following two defines:

#define CREST_GENERATED_SHADER_ON 1
#define _ENABLE_FOG_ON_TRANSPARENT 1

And search for the following comment and patch your shader with that:

// Send ocean data through UV channels 0-2

And there are three lines that have the following where we made a minor change:

output.ObjectSpaceBiTangent =
daleeidd commented 3 years ago

This is working now with 4.12 release.