How to Preserve Sprite Color When Overlapped by a Semi-Transparent Overlay

Hello everyone,

I’m working on a night-time effect in my game, where a shadow overlay darkens the scene to simulate nightfall. This overlay is implemented using a Sprite Renderer with a semi-transparent custom material. Everything works as intended, except for one issue: I want the moon in my game’s background to remain unaffected by this shadow overlay, retaining its original color and brightness.

I attempted to solve this by adjusting the sorting order, but this solution is not ideal. When I bring the moon to the front, it unrealistically appears in front of mountains and trees.

Is there a way to keep the moon in the background while ensuring it is not affected by the shadow overlay? Any suggestions or shader techniques that could achieve this effect would be greatly appreciated.

无论你是使用 UI 覆盖屏幕并使场景看起来更暗,还是你的月亮是 3D 世界对象、天空盒还是 2D 对象,由于 UI 是最后绘制的,你可以通过后期处理来实现这个夜间模式,如果你了解图形的绘制顺序, 你可以在画月亮的前一天晚上画。这应该是最简单的解决方案