Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

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.