Shader SetGlobalTexture Question

Hello.

This is the RenderTexture Setting code.

private void Awake()
    {
        var rt = new RenderTexture(Screen.width, Screen.height, 24);
        Shader.SetGlobalTexture("_TimeCrackTexture", rt);       
        _hiddenCamera.targetTexture = rt;
       
        _depthHackBuffer = new CommandBuffer();
        _depthHackBuffer.ClearRenderTarget(true, true, Color.black, 0);
        _depthHackBuffer.name = "Fancy Depth Magic" + Random.Range(0,3000);       
        _depthHackBuffer.DrawRenderer(_depthHackQuad, new Material(Shader.Find("Hidden/DepthHack")));
   
        DoDepthHack();
    }

These screens are being configured.
Here
There’s nothing wrong with SinglePlay.

Setting the RenderTexture is problematic when performing MultiPlay.

Because
This is because when two people connect, the 2p User takes the RenderTexture of the 1p User.

Therefore, I think that SetGlobalTexture is set to be applied to the last user, not to each user, at the first RenderTexture setting.

How do I fix this part and draw a RenderTexture for each user?

I’ll wait for your solution. please.
Thank you!


3598557–291995–TimePiece.shader (2.32 KB)
3598557–291996–TwinCameraController.cs (1.76 KB)

The solution is to not use a global texture and assign the texture to the mirror material directly.