@runevision@mastodon.gamedev.place
Post #3169278
2026-06-07 08:30 UTC
I tried adding a discard to the terrain shader based on distance to the camera, to achieve a clipping sphere around the camera instead of a clipping plane. The point being to avoid the mountain silhouettes wobbling when merely rotating the camera.
It works fine in the editor in Play Mode, but fails making a build, with an error of
"internal error: argument pulled into unrelated predicate"
No idea what to make of that.
Replies (2)
-
@dougbinks@mastodon.gamedev.place 2026-06-07 08:37
@runevision@mastodon.gamedev.place I think this is related to HLSL optimizer having issues with code after a discard. I think you can get around this by using if() { discard; } else {rest of code} or by discarding at the end based on a bool set where you discarded.
-
@aras@mastodon.gamedev.place 2026-06-07 09:19
@runevision@mastodon.gamedev.place no idea why that would happen, but FYI mere presence of discard in a pixel shader makes it run quite a bit slower than a always-known-to-be-opaque shader. Maybe doing it at vertex level would be just enough? Setting vertex position to NaN effectively “discards” the whole triangle that the vertex is on