Search Unity

Feedback Please expose more parameters in ScriptableRenderContext.DrawSkyBox

Discussion in 'General Graphics' started by equalsequals, Apr 8, 2021.

  1. equalsequals

    equalsequals

    Joined:
    Sep 27, 2010
    Posts:
    154
    It would be very helpful to be able to subvert behaviour of the black-box DrawSkyBox method, which currently only takes the Camera as a parameter for setting up view matrices.

    A couple suggestions here would be to allow for setting RenderStateBlock, and the Mesh itself.

    Currently in our custom SRP I can do the later:

    Code (CSharp):
    1. public bool OverrideSkyboxPass(ScriptableRenderContext context, Camera camera)
    2. {
    3.     if (camera.clearFlags != CameraClearFlags.Skybox
    4.         || _skyboxMode == SkyboxMode.Default
    5.         || camera.cameraType==CameraType.Preview)
    6.         return false;
    7.  
    8.     CommandBuffer cmd = CommandBufferPool.Get("Draw Skybox");
    9.     {
    10.         cmd.Clear();
    11.         context.ExecuteCommandBuffer(cmd);
    12.        
    13.         cmd.DrawMesh(
    14.             skyboxMesh,
    15.             Matrix4x4.TRS(
    16.                 camera.transform.position,
    17.                 Quaternion.identity,
    18.                 Vector3.one*SKYBOX_SCALE),
    19.             RenderSettings.skybox);
    20.         context.ExecuteCommandBuffer(cmd);
    21.     }
    22.     CommandBufferPool.Release(cmd);
    23.    
    24.     return true;
    25. }
    But here I cannot subvert the RenderStateBlock and must resolve things like Stencil in the Shader directly, which is inconvenient and error-prone as it requires our Content Creators to set data in several locations.

    Thanks,
    ==
     
    sabojako and GuardHei like this.