Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

HDRP Custom Skybox and Shaders

Discussion in 'Graphics Experimental Previews' started by Korindian, Sep 6, 2018.

  1. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Can anyone answer any of the following with regards to a custom HDRP skybox and HDRP shaders in general?

    I know there is this page on the wiki, but I still have the following questions:

    1. Can we create a custom HDRP skybox shader using the Shader Graph?

    2. Does the skybox shader have to have 2 passes, as shown in the shader from the wiki page? If I remove any one of the passes, I get "RenderingCommandBuffer: invalid pass index 1 in DrawProcedural".

    3. Is the second render pass needed if we're not using the skybox rendered into a reflection cubemap, but a manually updated reflection probe?

    4. If using the skybox shader from the SRP wiki, is it possible to do the skybox rotation in the vert function rather than frag? If so how?

    5. Does a page or resource exist like the Unity Shader Reference documentation where I can learn the differences between CG and HD SRP HLSL shader syntax, for example TEXTURECUBE and SAMPLER vs samplerCUBE etc., and the various other new functions?

    6. How do we create transparent shaders via code or Shader Graph that will get properly affected by HDRP volumetric fog?

    I'd appreciate any help, thanks.
     
  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    1. No, unless you make a HDRP skybox shader master node for the Shader Graph.

    2. Yes.

    3. If you're updating a reflection probe with a custom cubemap, you're basically writing in a cube render texture. So it has nothing to do with the sky.

    4. No, as the vertex shader is only drawing a full screen quad, you need to do the rotation in the pixel shader to have proper values.

    5. Those are new macros to declare and sample the textures. The main difference with what has existed before is that texture and samplers are now decoupled. You can find the macros declarations in the different API include files, like this one for DX11 : https://github.com/Unity-Technologi...r-pipelines.core/ShaderLibrary/API/D3D11.hlsl

    6. This is not possible for the moment, but is probably on the todo list of the Shader Graph team.
     
    robogamingbysam likes this.
  3. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Thanks so much for replying to every question. Really appreciated.
     
  4. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    @Remy_Unity I've successfully converted a custom skybox shader to HDRP's volume system. I posted a couple of questions on the HDRP feedback thread that didn't get answered and was hoping you'd have some insight:

    When setting Sky update mode to "On Demand", how do we make the call to update the sky lighting manually?

    Is there a way to increase the brightness/intesnity of sky lighting on objects without affecting the visual brightness of the skybox? For example, for an HDRISky cubemap, keeping it at the same exposure level, but having a slider which increases or decreases the amount (intensity) of lighting it puts out.

    Thanks.
     
  5. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    @Korindian For the "On Demand" update mode : It appears that the public api call to update the sky has been accidentally removed during a refactor of the code. I reported a bug to the developers and you can expect this to be corrected in a near future version.
    In the meantime, your can use the "On Change" mode that will trigger the update when a change is made in the sky settings.

    And what you want is to decouple the visual intensity and the lighting intensity of the sky, right ? You can do this by using the "Lighting Override Mask" feature : https://github.com/Unity-Technologies/ScriptableRenderPipeline/wiki/HDRP-Sky
    This is a layer mask setting in the HDRP Asset : https://github.com/Unity-Technologies/ScriptableRenderPipeline/wiki/HDRP-Asset

    Once set, the volume objects in those layers will override the lighting of others, so you can have one volume to set your background, and on for the lighting, with different settings.
    Also pay attention to remove the baking sky component of the volume used for the background, as it will only be necessary for the lighting override volume.
     
  6. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    @Remy_Unity Thanks.

    1. The lighting override mask feature works as intended, but I'm getting 42 additional SetPass calls just having the override lighting volume active. Something isn't right here.

    Empty scene with camera, volume component and custom skybox component: 7 SetPass calls.
    Cloned Volume component with custom skybox in override layer: 49 SetPass calls.

    Disabling the override volume brings it back down to 7. There is nothing else in the scene... no lights or objects, just the camera and the two volumes. Is this intended?

    2. Once the public api to update the sky is reintroduced, which method will we need to call to update the sky lighting?

    3. When update mode is set to "On Change", only changing the inherited variables from SkySettings causes an update. Changing any new variables in the derived class does not cause an update of the lighting in "On Change" update mode. Can you look into this please?
     
  7. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    1. Could you send a small repro project so I can have a look ? If the override sky is set to realtime those number wouldn't surprise me.

    2. We don't know know, once it is reintroduced it will be added to the documentation.

    3. The "On Change" update is called when the component hash is changed. I you want it to take in account your new variable, you must override the hash generation. See how it's done in the ProceduralSky : https://github.com/Unity-Technologi...on/Runtime/Sky/ProceduralSky/ProceduralSky.cs
     
  8. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    @Remy_Unity You are right, override sky was set to realtime. I guess this will never be a problem for me as I'll be setting the mode to OnDemand when the new API comes out.

    Also thanks, I was able to get all variables to register for "On Change" using the example you linked. You might want to update the HDRP docs (this page particularly) with the hash info for other users.

    You've been a great help in this thread. I really appreciate you taking the time to answer.
     
    Remy_Unity likes this.