wave-harmonic / crest

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

Underwater not rendering. Materials are pink #533

Closed 13E12K closed 4 years ago

13E12K commented 4 years ago

Describe the bug After first initialization, underwater effects both curtain and meniscus work, however, after runtime unterwater seizes to render. Happens both in demo scenes as well as custom ones.

Screenshots / video I might upload SS if needed, but the shader icon in inspector becomes weird colors like purple. If I manually switch shaders and reassign back original underwear Shader, than it works again properly. And Versions Unity 2018.4

To Reproduce Reoccurring runtimes needed

daleeidd commented 4 years ago

Thanks.

A screenshot of the weird colours will be very helpful. Is the colour ever pink (as in broken shader pink)?

Also, how recent is your version of Crest? And what platform and graphics API are you using?

Snigros commented 4 years ago

Not sure if same issue - but underwater effects also stopped working for me when I updated to Unity 2019.4.0f1 and URP 7.4.1. Using Crest URP 4.2.0....

daleeidd commented 4 years ago

@Snigros yours might be related to #531

13E12K commented 4 years ago

Thanks.

A screenshot of the weird colours will be very helpful. Is the colour ever pink (as in broken shader pink)?

Also, how recent is your version of Crest? And what platform and graphics API are you using?

Indeed it is pink and looks like broken shader.

I tried having the underwater shader “always included shader” under settings->graphics but no success.

Is there anything else to solve this issue?

daleeidd commented 4 years ago

@13E12K reimporting the material should solve it. Let me know how you go. We have seen this happen for a while now, but we haven't been able to determine the cause. I have noticed this has become more frequent lately.

daleeidd commented 4 years ago

There will be a fix for this in 4.4. Will close this once it is released. I am hoping this is indeed the issue the user is experiencing. See the commit for the fix for those that need it now ^

daleeidd commented 4 years ago

4.4 is out which should solve this issue. It may still happen as we have had this before. Crest working in edit mode made it more frequent. Please reopen if this is still an issue.

daleeidd commented 4 years ago

Adding the following here for reference. There might be issues with that call that are unresolved.

https://forum.unity.com/threads/copypropertiesfrommaterial-corrupts-material-in-play-mode.519519/

huwb commented 4 years ago

From that thread - maybe we should back up the shader property from the material and reapply after doing the copy?

daleeidd commented 4 years ago

I should have mentioned I did try that. But it undoes the copy procedure or something to that effect as the underwater curtain appears black :\

huwb commented 4 years ago

ok great (not great) :)

daleeidd commented 4 years ago

I'll re-open this so others can see it since this does still happen (just less frequently).

I think ditching syncing materials might be the way to go. Either the user can provide the material and we use that or we completely control it by creating a material at run-time.

I would like to solve this properly though but it appears impenetrable. I am pretty sure I even checked the Library folder for leads to no avail, but I might have to check again.

huwb commented 4 years ago

Creating at runtime would be great. Would the shader variant be available - I guess we'd just include all variants using local shader features? That sounds good to me, as long as we can detect which features are enabled on the surface material, and reliably copy across all shader params .. which sounds a bit like syncing materials.. or is the idea that we sync params like colours, but not shader features/toggles?

One alternative idea.. shaders support having multiple passes. It might be we can create a second pass in the ocean shader which is only used for underwater. Both would then take params and keywords from the material.

daleeidd commented 4 years ago

I didn't go all the way with creating it at runtime. We could but it should be okay the way I have done it in #652. I will ditch the material for the underwater post processing branch though. We still sync the material but the distinction is that we don't sync to a material asset anymore.

huwb commented 4 years ago

Sure thanks

daleeidd commented 4 years ago

Another fix will be out for 4.6.

daleeidd commented 4 years ago

4.6 is out and it has reported to be fixed by others.

talqadi7 commented 3 years ago

Hello! Our team is running into a similar issue as mentioned above. It happens randomly. When using underwater meniscus and curtain, the material is sometimes pink, and underwater does not render. This happens when we open up the scene. Most of the times we can fix it by re-importing the shader. Sometimes this doesn't fix the issue, and we have to just restart unity a couple of times, and do a variety of things to get it back to normal.

Since re-importing the shader fixes the issue most of the times, we've written a script to re-import the shader during runtime. However, importing in runtime does not fix the issue, as it would when importing the shaders manually. We've also added the 2 shaders to the "always included shaders" unity setting to no avail.

I'm wondering if there is a more permanent fix rather than reimporting the shader every time.

Below is an image of what I'm talking about: image

We've switched around between different unity version and URP versions. The below seems to be most consistent for us; however, a lot of the times some of our machines won't be able to render it. Is there a specific URP and Unity version recommended by the crest team?

Unity version: 2020.2.0a19 URP version: 8.1

daleeidd commented 3 years ago

@talqadi7 this was fixed in Crest 4.6. We have reports that it has indeed fixed it properly. Are you using that version?