0
\$\begingroup\$

A custom shader I made is breaking on build.

Here's what it's supposed to look like:

Water Shader

Yet, on the build it looks like this. The surface is completely flat, all details are gone, and sometimes the surface goes from nearly completely opaque to nearly transparent depending on the angle...

Broken Water Shader

Any idea what might be causing this? I tried adding it to the Always include shaders, tried generating shader includes, did a few tweaks to the shader and can't for the life of me figure out what's wrong.

There is this "Shader warning in 'Shader Graphs/Water2': 'UnityMetaVertexPosition': implicit truncation of vector type at" warning, not sure if that's causing it.

Here's the shader graph file too, if someone would be willing to have a look. Not sure if it's a setting in the shader or editor setting.

Shader graph preview

\$\endgroup\$
11
  • 2
    \$\begingroup\$ When you say "sometimes the surface disappears if I change the angle", you mean the rest of the time the water displays as normal? That would suggest that it's not a problem with the shader failing to be included/compiled correctly - otherwise it would never appear, or always show up as fuchsia/consistently wrong. Occasionally popping away suggests it might be getting frustum culled - especially if your vertex displacement is moving the visible surface outside the bounding box of the original mesh. Or it could be that a level of detail or z-sorting change is kicking in. \$\endgroup\$
    – DMGregory
    Commented Sep 20 at 17:59
  • \$\begingroup\$ @DMGregory You can see what i mean in the images, the issue isn't just that it sometimes disappears, the shader is completely broken and a flat colour, no waves, no nothing. And the issue only occurs on build, i think if the frustum was being culled it should be broken in the editor, right? Edit: Weird, the images were broke so I uploaded the images to imgur and they were fixed but for some reason they broke again? I think maybe when you editted my title my changes got lost. Here they are again, Proper shader: imgur.com/a/OMKCWpN Broken shader: imgur.com/a/3Yw7JTE \$\endgroup\$
    – Mashimaro7
    Commented Sep 21 at 10:42
  • \$\begingroup\$ @DMGregory Also i want to emphasize, the water disappearing from certain angles is not the issue. As you can see from the images, the shader is completely broken. Not pink, but it's flat, the waves are all gone, the colours aren't working. I edited it for more clarity, didn't realize I worded it wrong \$\endgroup\$
    – Mashimaro7
    Commented Sep 21 at 10:48
  • \$\begingroup\$ Sorry for so many comments in a row, but i thought i should mention, i actually realized the water shader DOES NOT disappear. IT goes almost transparent(instantly from like fully solid to nearly transparent) but it's still visible. And again, this does not happen in the editor... \$\endgroup\$
    – Mashimaro7
    Commented Sep 21 at 11:16
  • \$\begingroup\$ It sounds like it would be good to record a short video of what you're seeing in build. From a still image, it's hard to tell the difference between the water being absent and the clear colour showing through, versus the water being present but rendering in a mostly flat colour. \$\endgroup\$
    – DMGregory
    Commented Sep 21 at 15:13

1 Answer 1

0
\$\begingroup\$

Well, not exactly sure what the issue was, but upgrading from 2021 to the latest 2022 fixed it. I hope this helps someone. I know "upgrade to the newest LTS" isn't the best solution for everyone, but that's what fixed it for me.

Current version is 2022.3.49. Honestly I didn't want to upgrade - I don't like the new navmesh system. But that fixed the shader issue (if anyone has any idea as to why this would've fixed it, maybe they can post in the replies for someone who doesn't want to upgrade engines?)

\$\endgroup\$
3
  • \$\begingroup\$ What I'd do is look at the release notes of in-between versions (binary search them like git bisect) to find the exact version where they mention the relevant bug fix. Unless the navmesh stuff isn't that much of a bother for you of course. Can you say what the old version was exactly? \$\endgroup\$ Commented Oct 2 at 14:53
  • \$\begingroup\$ @FurkanKambay Sorry, didn't see this. I believe the old version was 2021.3.38f. I tried upgrading to the newest 2021 version and it was still broken, so i tried 2022 and it fixed it, so the fix must be somewhere in there(i don't really know how to search through the versions) \$\endgroup\$
    – Mashimaro7
    Commented Oct 16 at 9:58
  • \$\begingroup\$ I've had the exact same issue with a water shader provided with Gaia. What's really random is it started doing it out of the blue even though I hadn't touched it. I could luckily reimport it from another project as a package but it would still do it after every build. You can imagine my frustration when it's 8pm and I need to catch a flight the following day with this product! I think I'll try upgrading to a newer version. \$\endgroup\$
    – veddycent
    Commented Oct 31 at 20:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .