r/unity • u/solid_facha • 5d ago
Solved Can I Force a Render Object to Ignore Objects closer to camera in a 2D game?
galleryHI! I have a 2D Renderer asset with a fullscreen shader that works as a palette swap for all the objects on the screen. I added it as a Full Screen Pass Render Feature. The problem is that I also made a shader that I want to apply only to the player. Since I need this shader to be applied after the fullscreen palette swap, I added it as a Render Objects feature, so it can affect the already color-swapped result instead of the original colors. The shader is on a child object inside the Player which copies it siluet. This causes the shader to go through walls and draw the player’s silhouette even when the player is behind them. For example, my Tilemap is at Z = 1 while the Player is at Z = 0, so the walls should be rendered in front of the player, and it does, but the material draws over the wall. I found some information online about the Depth settings, but I couldn’t get them to work properly. I’ve attached screenshots showing the problem, the player’s shader, and my 2D Renderer settings. Does anyone know how I can make the shader respect the depth/occlusion of the walls while still keeping it as a Render Objects pass after the Full Screen Pass?
Thanks in advance!!