I am creating a 2D game and want to implement a funcitonality that apply custom post processing material only to a bounded area in the scene, speficied by the sprite.
What I am thinking is that use another sprite renderer, and sample current scene color using screen position as the UV in the shader, and apply something. However, the SceneColor node not seems to be working in 2D and I found a solution by enabling CameraSortingLayerTexture and sampling from that texture. Looks like this.
When I tried in the shader graph, the CameraSortingLayerTexture is set, and I can sample from it, which is cool!
But when I tried changing the UV corrdinate to the ScreenPosition, it can only sample some strange color.
If I output the ScreenPosition directly, it works fine.
Where am I wrong? Or any alternative solution?