See-Through effect for top-down game (Performance issues)
Hi everyone,
We are developing a top-down game and decided to implement a see-through effect for the player ... as expected. Our first choice was to use some sort of ghost/x-ray effect by assigning a shader to the Player's material for this:
The problem with this is that our testers complained saying that it would be a better experience if they could see other objects around the player. Based on this we decided to seek a new solution which was an image effect on the Camera using depth texture:
The second solution looks good but it cuts performance by almost half, so I'm wondering whether there is a way to achieve something like this while keeping performance up. Currently, the moment enemies show up we start having serious lags and the Profiler tells that most of the performance goes into this effect for both CPU and GPU.
The other option we found was to add custom shaders on each environment object but this is far from ideal for us since it will affect the general visuals and will be too much of a chore as our maps undergo changes a lot.
The first option (using a shader on the player) had very good performance so I would appreciate any direction on how to achieve something like the second feature, but in a very simple fashion to keep performance at a very good level.
The biggest performance hit for the GPU comes from DepthTexture.Update, for the depth texture being used in the second effect and for the CPU the biggest hit lies in OnRenderImage() as expected. OnRenderImage for this effect uses up over 15% of CPU according to Unity's Profiler and DepthTexture uses about 1.7% of GPU. It seems small but every other thing in the game has much lower stats than this and we have our frame rate cut in half.
Any ideas would be appreciated.
Thank you.
Your answer
Follow this Question
Related Questions
URP Camera.RenderWithShader(..) doesn't seem to work? 0 Answers
Material.SetFloat not working 0 Answers
Custom Urp shader weird problem 0 Answers
Shadows on Custom Lit Surface Shader 1 Answer
Posterize-time/stutter frame post-processing shader for camera? 0 Answers