Search Unity

Creat Occlusion Culling Behind UI (Scissor Rect?)

Discussion in 'General Graphics' started by Treasureman, Nov 2, 2020.

  1. Treasureman

    Treasureman

    Joined:
    Jul 5, 2014
    Posts:
    563
    Hi! I'm going to do my best to describe what I'm trying to achieve in my game. The game has a letterbox option (cinematic black bars like in the game Virginia). I figured I'd try to optimize a bit, and I figured a good way to do that would be to not render anything that's hidden by the black bars (they're just UI Images). My first thought was to use Scissor Rect. This seemed to work, but it caused issues with the image effects on my camera because it was like the image effects were being squished down to fit the new camera rect. Thank you if anyone can help!
    Summerland Screenshot 1-ex.png
     
  2. zaxonjiajiami

    zaxonjiajiami

    Joined:
    Dec 19, 2020
    Posts:
    2
    Hi, I have a similar question with you, but I don't need to worry about image effects. My problem is the scissor rect doesn't work, here is my code:


    void OnPreRender()
    {
    CommandBuffer cb = new CommandBuffer();
    cb.EnableScissorRect(new Rect(0, 0, 100, 200)); // NOT WORKING !
    //cb.ClearRenderTarget(true, true, Color.green); // WORKING
    Graphics.ExecuteCommandBuffer(cb);
    }

    The script is attached to the MainCamera, however, the screen is still full rendered.

    Could you tell me what went wrong?