Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Rendering Meshes to the Skybox in a SkyboxRenderer (to affect both GI and Env Reflections)

Discussion in 'High Definition Render Pipeline' started by MoruganKodi, Dec 4, 2023.

  1. MoruganKodi

    MoruganKodi

    Joined:
    Feb 11, 2015
    Posts:
    77
    Okay, so I have created a custom skybox VolumeComponent (and renderer) for HDRP after we converted our project from URP to HDRP.

    However - I am having issues finding resources covering also rendering meshes directly to the skybox while both supporting GI and including them in the environment reflections.

    I already have a mechanism which builds a spherical set of (about 20K) quads to render as stars, which currently render BeforeRefraction (Material setting).

    I am new to working woth CommandBuffers/VolumeComponents still - and I am wondering if anyone has seen any examples which demonstrate rendering meshes as part of the skybox.

    And in certain states of the game, I also need to render a custom Sun disk (on top of layered HDRI) in this component.

    I imagine since the HDRP Physically Based Skybox does this when rendering a planet - It would be possible with any custom mesh.

    My google foo seems to be failing me on this specific use case.
     
  2. Misaki_eKU

    Misaki_eKU

    Joined:
    May 3, 2018
    Posts:
    85
    From what I have learned, you cannot render a mesh in skybox. To render stars, you can use a cubemap which contain stars only and blend it with the regular sky; for sun disk, you can use the dot product of sun direction and absolute world space view direction to get the sun halo.
     
  3. SebLazyWizard

    SebLazyWizard

    Joined:
    Jun 15, 2018
    Posts:
    230
    There's no mesh involved at all, it's just a sphere projection inside the shader.
     
  4. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    I didn't try but if you create a custom sky renderer as you did, you can put anything inside the RenderSky function, so you should be able to draw a mesh
    However that will be very custom cause you can't access the light lists, and you would have to provide the projection matrix yourself, as well as other stuff probably. You might be able to use the HDRP/Unlit shader but it's probably not that straightforward

    If you just want to draw a sphere it might be easier to do it analytically as in the PBR sky shader