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

Feedback Wanted: High Definition Render Pipeline

Discussion in 'Graphics Experimental Previews' started by Tim-C, Sep 25, 2018.

  1. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Please place all HDRP feedback in this thread. The other SRP thread should be used for core api feedback.

    High Definition Render Pipeline overview




    The High Definition Render Pipeline (HDRP) is a high-fidelity Scriptable Render Pipeline built by Unity to target modern (Compute Shader compatible) platforms.

    The HDRP utilizes Physically-Based Lighting techniques, linear lighting, HDR lighting and a configurable hybrid Tile/Cluster deferred/Forward lighting architecture and gives you the tools you need to create games, technical demos, animations and more to a high graphical standard.

    NOTE: Projects made using HDRP are not compatible with the Lightweight Render Pipeline. You must decide which render pipeline your project will use before starting development as HDRP features are not cross-compatible between HDRP and Lightweight.

    This section contains the information you need to begin creating applications using HDRP; including information on Lighting, Materials and Shaders, Cameras, debugging and information for advanced users.

    HRDP is only supported on the following platforms:

    Note: HDRP will only work on the following platforms if the device used supports Compute Shaders. I.e: HDRP will only work on iOS if the iPhone model used supports Compute Shaders.

    • Windows and Windows Store, with DirectX 11 or DirectX 12 and Shader Model 5.0
    • macOS and iOS using Metal graphics
    • Android, Linux and Windows platforms with Vulkan
    • Modern consoles (Sony PS4 and Microsoft Xbox One)
    HDRP does not support OpenGL or OpenGL ES devices.
     
    Deleted User and Lars-Steenhoff like this.
  2. Arnklit

    Arnklit

    Joined:
    May 18, 2015
    Posts:
    48
    Hi Tim, is Vulkan support supposed to be working currently? I had some issues when I tried it on 2018.2. Basically Unity crashed.
    Also is there any info available on what performance difference can be expected between DX11, DX12 and Vulkan?
     
  3. poa123

    poa123

    Joined:
    Jul 13, 2018
    Posts:
    22
    I have a question regarding Normal Map format on HD pipeline...
    Is it still true that Unity works with "OpenGL" normal map format? Or now on HD RP the normal map format was changed to "DirectX", like in UE4?
     
  4. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    is there any particle shader in HDRP? or is it possible to recreate it with HD ShaderGraph?
     
  5. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    The 'proper', 'futuristic' particle solution for HDRP is the new VFX system. But this system is still rather new, so perhaps there are intermediate solutions available that enable the old particle system to work with HDRP, but I'm afraid I lack knowledge about that side of things. I would certainly encourage people to take a look at the VFX system for HDRP, but depending on your skills etc this advice is probably more sensible once VFX is available in preview form via the package manager, rather than its current state of public development on github. And since the VFX is a brand new, graph and compute shader based system, there is no upgrade path for existing particle systems.

    Provisional VFX documentation: https://github.com/Unity-Technologies/ScriptableRenderPipeline/wiki/Visual-Effects-Editor
     
  6. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    I can't get fog to work in the HD SRP for a custom unlit emissive shader. In LW it works fine.

    In RenderDoc, both GetPositionInput() and EvaluateAtmosphericScattering() are jumped over when singe stepping through the code. I am not sure if this is because that code is ignored or that RenderDoc is unable to step into 3rd party functions. Looking at the assembly, it looks like those functions are indeed missing. Strange because the compiler doesn't throw an error.

    I am not sure where to check in RenderDoc that _AtmosphericScatteringType is correctly initialized.

    The blend mode is present as a shader feature.

    Below is the full shader I am using. Here is also a small repo:
    https://drive.google.com/file/d/1Sn6gIIK6li6fXM05Jo_JOlnHZl2yltXp/view?usp=sharing

    The GameObject containing the OmniSimple shader is called CityLightsAmber0 and CityLightsWhite0. Note that the shader needs custom vertex data and cannot be applied to a regular mesh. So the repo is indeed required.

    The camera controls in game mode are the same as with the Editor.
    You can see a spherical shadow effect and incorrect blending with the cube.

    View attachment 299137
    View attachment 299140
    Code (CSharp):
    1.  
    2. //This shader contains a failed attempt to get fog (atmospheric scattering) to work.
    3. Shader "Lights/OmniSimple"{
    4.  
    5.     Properties{
    6.  
    7.         _MainTex ("Light Texture", 2D) = "white" {}
    8.        [HDR]_FrontColor ("Front Color", Color) = (0.5,0.5,0.5,0.5)
    9.         _MinPixelSize ("Minimum screen size", FLOAT) = 5.0
    10.         _Attenuation ("Attenuation", Range(0.01, 1)) = 0.37
    11.         _BrightnessOffset ("Brightness offset", Range(-1, 1)) = 0
    12.     }
    13.  
    14.    HLSLINCLUDE
    15.    #pragma target 4.5
    16.    #pragma glsl_no_auto_normalization
    17.    #pragma enable_d3d11_debug_symbols
    18.  
    19.    #pragma shader_feature _SURFACE_TYPE_TRANSPARENT
    20.    #pragma shader_feature _BLENDMODE_ALPHA
    21.    //#pragma shader_feature _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
    22.    #pragma shader_feature _ENABLE_FOG_ON_TRANSPARENT
    23.  
    24.    #define UNITY_MATERIAL_UNLIT // Need to be define before including Material.hlsl
    25.  
    26.    #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
    27.    #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"  
    28.    #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"   //for Fog
    29.    #include "lightFunctions.cginc"
    30.  
    31.    uniform sampler2D _MainTex;      
    32.    float _MinPixelSize;
    33.    half _BrightnessOffset;
    34.    float _Attenuation;
    35.    half4 _FrontColor;
    36.  
    37.    //These global variables are set from a Unity script.
    38.    float _ScaleFactor;
    39.  
    40.    struct vertexInput {
    41.  
    42.        float4 center : POSITION; //Mesh center position is stored in the position channel (vertices in Unity).
    43.        float4 corner : TANGENT; //Mesh corner is stored in the tangent channel (tangent in Unity). The scale is stored in the w component.
    44.        float2 uvs : TEXCOORD0; //Texture coordinates (uv in Unity).      
    45.    };
    46.  
    47.    struct vertexOutput{
    48.  
    49.        float4 pos : SV_POSITION;
    50.        float2 uvs : TEXCOORD0;
    51.        half4 color : COLOR;
    52.  
    53.        //This is not a UV coordinate but it is just used to pass some variables
    54.        //from the vertex shader to the fragment shader: xyz = world space pos. w = gain
    55.        float4 container : TEXCOORD1;
    56.    };          
    57.  
    58.    vertexOutput vert(vertexInput input){
    59.  
    60.        vertexOutput output;
    61.        half gain;
    62.        half distanceGain;
    63.        float scale;
    64.        float3 positionWS;
    65.  
    66.        //Get a vector from the vertex to the camera and cache the result.
    67.        float3 objSpaceViewDir = ObjSpaceViewDir2(input.center);
    68.  
    69.        //Get the distance between the camera and the light.
    70.        float distance = length(objSpaceViewDir);  
    71.  
    72.        output.color = _FrontColor;
    73.  
    74.        //Calculate the scale. If the light size is smaller than one pixel, scale it up
    75.        //so it remains at least one pixel in size.
    76.        scale = ScaleUp(distance, _ScaleFactor, input.corner.w, 1.0f, _MinPixelSize);
    77.  
    78.        //Get the vertex offset to shift and scale the light.
    79.        float4 offset = GetOffset(scale, input.corner);
    80.  
    81.        //Place the vertex by moving it away from the center.
    82.        //Rotate the billboard towards the camera.
    83.        positionWS = TransformObjectToWorld(input.center.xyz);
    84.        output.pos.xyz = TransformWorldToView(positionWS) + offset.xyz;
    85.        output.pos = mul(UNITY_MATRIX_P, float4(output.pos.xyz, 1.0f));
    86.  
    87.        //Far away lights should be less bright. Attenuate with the inverse square law.
    88.        distanceGain = Attenuate(distance, _Attenuation);
    89.  
    90.        //Merge the distance gain (attenuation), and light brightness into a single gain value.
    91.        gain = (_BrightnessOffset - (1.0h - distanceGain));
    92.  
    93.        //Send the gain and positionWS to the fragment shader.
    94.        output.container = float4(positionWS, gain);
    95.  
    96.        //UV mapping.
    97.        output.uvs = input.uvs;
    98.  
    99.        return output;
    100.    }
    101.  
    102.    half4 frag(vertexOutput input) : SV_Target{
    103.  
    104.        //Compute the final color.
    105.        //Note: input.container.x fetches the gain from the vertex shader. No need to calculate this for each fragment.
    106.        half4 col = 2.0h * input.color * tex2D(_MainTex, input.uvs) * (exp(input.container.w * 5.0h));    
    107.  
    108.        //input.positionSS is SV_Position   (float2 positionSS, float2 invScreenSize, float deviceDepth, float linearDepth, float3 positionWS)
    109.        //PositionInputs posInput = GetPositionInput(input.pos.xy, _ScreenSize.zw, input.pos.z, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
    110.        PositionInputs posInput = GetPositionInput(input.pos.xy, _ScreenSize.zw, input.pos.z, input.pos.w, input.container.xyz);
    111.  
    112.        //This does not have any effect.
    113.        col = EvaluateAtmosphericScattering(posInput, col);
    114.  
    115.        return col;
    116.    }
    117.    ENDHLSL
    118.  
    119.    SubShader{
    120.  
    121.        Tags {"RenderType"="Transparent"}
    122.  
    123.         Pass
    124.         {
    125.             Name ""
    126.             Tags{ "LightMode" = "ForwardOnly" }
    127.            Blend SrcAlpha One
    128.            AlphaTest Greater .01
    129.            ColorMask RGB
    130.            Lighting Off
    131.            ZWrite Off  
    132.             HLSLPROGRAM
    133.                 #pragma vertex vert
    134.                 #pragma fragment frag
    135.             ENDHLSL
    136.         }
    137.    }    
    138. }
    139.  
    140.  
    141.  
     
    Last edited: Oct 1, 2018
  7. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    First I want to say I like HDRP, it faster than legacy render, and look better. But volumertic light just destroy performance. Is there any chance that it will be optimized?
     
    hippocoder likes this.
  8. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    HDRP v3.3.0
    Unity 2018.3b

    I have two cameras:

    Near camera
    Near: 0.1
    Far: 1000
    Clear Mode: None
    Clear Depth :true
    Depth: 2

    Far camera
    Near: 1000
    Far: 10000
    Clear Mode: Sky
    Clear Depth: true
    Depth: 1

    On both cameras I have posprocessing layer with simple postprocessing effect, which only outputs the linear01 depth from depth buffer of the current camera.

    On the preview of each camera I see the correct results.

    Near camera:


    Far camera


    But final composed result is this:


    Why did this happened? Did both cameras share one depth buffer on postprocessing stage? Is this bug or known limitation? How I can overcame this issue?
     
    tetto_green and Desoxi like this.
  9. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    What is the UV the used by Distortion Vector Map? it seems that the base UV mapping setting doesn't affect it
     
  10. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    That seems rather correct to me : the near camera renders after the far one, and clears the depth before rendering, so you're not keeping the depth of the far one.
     
  11. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    So, I can not have depth-based posteffects on far camera?
     
  12. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
  13. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Found the solution via DepthPyramid, thank god.
    I also see, that now PostProcessEvent.BeforeTransparent custom effects are not executed by hdrp. Are there any plans to fix this?
     
    Last edited: Sep 29, 2018
  14. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    579
    hdrp 4 questions

    1. What is micro shadowing?
    2. What is indirect lighting controller?
    3. I enabled SSR everywhere, it's still not present, what should i do?
     
  15. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    1. directional shadow based on AO and Normal texture, based from Naughty dogs tech used in UC4 Link
    2. additional control for lightmaps and reflection probe data. You can increase/decrease the intensity of the baked data globally
    3. not sure about this one, ssr work fine for me. Edit : Oh try to change the minimum smoothness value in the Volume settings
     
    Last edited: Sep 30, 2018
    pointcache likes this.
  16. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Any way to get GPU Instancing on the HDRP Unlit Shader Graph shaders? Only seeing it for HD Lit but not for Unlit in 4.0.0.
     
  17. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    MSVO has severe problems with large view distances, so we will need a range value for it. We tested with a 3km view distance with short 0.05f near clip. Geometry was a huge unity sphere of 200x200x200

    MSVO gave us harsh banding and low resolution artefacts which would be entirely avoidable by being able to fade out the effect over distance. Has Unity not tested HDRP fully with open world rendering?

    Please consider the addition of a falloff/range parameter or advise, thank you, since MSVO for us is fine otherwise.

    upload_2018-9-30_19-14-19.png

    Or perhaps it's just a bug.
     
  18. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    HDRP has an issue with materials set to gpu instancing in Editor mode. It seems to flicker horribly between some kind of baked atlas and it's actual texture and applies to static stuff. This has been going on forever so I am assuming it's just WIP.

    The problem goes away in play mode but does prevent proper level editing, therefore I have rolled a script to set the sharedMaterial properties for static stuff to not be instanced.

    So why not do that all the time? Well, some things will share materials :p
     
  19. discofhc

    discofhc

    Joined:
    Dec 18, 2017
    Posts:
    47
    I need that answer as well...
     
  20. poa123

    poa123

    Joined:
    Jul 13, 2018
    Posts:
    22
    A question about Volumetric Fog...
    I am struggling to achieve a good resolution using a SpotLight, as you can see in the image. Even with "increase resolution of volumetrics" enabled. Anyone can help me?
     

    Attached Files:

  21. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Activate "Increase volumetric fog resolution" in HDRP settings
     
  22. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You should read the hdrp docs on wiki a bit closer. You can add a controller to the volume that will adjust the volumetric near/far distribution.

    Hint: you will need to make the range as small as possible for near/far. The effect does not have endless resolution. Some gains could be had once HDRP team improve shadow filtering.
     
  23. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Still no reply on this issue - AO causing artefacts - do I need to log a bug? Seems obvious in any scene of large depth.
     
  24. James9270_

    James9270_

    Joined:
    Sep 3, 2015
    Posts:
    1
    Is there a way to toggle reprojection of volumetric lighting on a per-light basis?
    I'd like to keep reprojection enabled for static lights, but disable it for a couple of dynamic lights in my scene: The reprojection really improves the quality of non-moving lights, but it produces terrible artifacts with moving lights.
     
  25. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    So, any chance we get Opaque Texture in HDRP? or at least direct access to the Refraction buffer in shadergraph?
    Oh and What is LightLayers?
     
    Last edited: Oct 2, 2018
  26. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, Vulkan is not in a good state currently.
     
  27. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, nope, it still use OpenGL convention
     
  28. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, there is no particles shaders currently. Solution are in development
     
  29. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, really sorry but we haven't the time to investigate your issue :(
     
  30. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, you need to provide more information here:
    - how many lights? Shadow or not? light type? Which platform ? What are your resolution? what option are you using (high quality?) ? etc...

    We still have optimization to do on volumetric, but "destroy performance" is not really a measurable metric :)
     
  31. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, IIRC it use TexCoord0
     
  32. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    > I also see, that now PostProcessEvent.BeforeTransparent c

    No plan to fix it. HDRP use a totally different render pipeline and architecture than builtin
     
  33. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Korindian likes this.
  34. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    > Unity not tested HDRP fully with open world rendering?
    Indeed, we have no open world demo currently :)

    @Keijiro-UTJ any thought?
     
  35. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, which version of HDRP? Which version of Binaries?

    (cc @Remy_Unity )
     
  36. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, you will be require to tweak the size of the froxels in volumetric settings I suppose.
     
  37. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, reprojection can now be disabled but only globally, there is no "per light reprojection" possible.
     
  38. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Currently Color buffer is not expose in shader graph, should come in the future.
    Lightlayers, is light linking. I.e one light affect only a subset of object.
     
  39. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    it's the same uv that used by other texture input right? i think i found a bug then. Because when i increase the tilling value of uv1 the distortion vector tilling not affected.
     
  40. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Is there any way to apply some effects/shaders before transparent geometry, without modifying the render pipeline itself?
     
  41. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Distortion is indeed not affect by tiling (currently it use UV1 but is independent of tiling or mapping option of inputs). This was on purpose, so not a bug but rather a feature request :). We will add the request to our list
     
  42. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    I think the Readme file on github might need updating, since unless I am mistaken the postprocessing is handled via package manager dependencies stuff rather than via github submodule these days?

    But the readme still says in several places 'git submodule update --init (This command fetches the Postprocessing module, which is needed to use SRP)'
     
  43. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Ah okay, now that's make sense then
     
  44. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Thanks, this will be done soon.
     
    elbows likes this.
  45. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi. Without code modification this is not possible. Currently HDRP is not extensible, we will work on this topic in near future.
     
  46. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Thanks. And one more question: do you plan to give the ability to users to write custom fog (like precomputed multiple scattering), as you did it for sky with sky framework?
     
  47. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    The Volume Component's profile reference is not getting saved on scene save and then when restarting Unity. Instead, an instance is created and used. This is on 2018.3b4

    - Create a Scene Settings GameObject.
    - Assign a newly created Scene Settings Profile to the Volume Component.
    - Save the scene, and restart Unity.
    - Notice how in the Volume Component, there is an "(Instance)" next to Profile, with the reference being (VolumeProfile). Changing the Scene Settings GameObject doesn't affect the Scene Settings Profile ScriptableObject, and vice versa, as the assigned reference is an instance.

    Is this intended?
     
  48. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Also, 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 of HDRISky lighting on objects without affecting the brightness of the HDRISky? 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.
     
    Last edited: Oct 4, 2018
  49. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, Fog is a more complex beast than Sky. With sky we only have a single pass to display it, so easy to customize. Fog require to apply to both opaque and transparent object.
    Transparent object apply fog during forward pass. Mean it can't be easily customize, it is required to modify the source code, it can't just be a plugin.

    Then there is the choice of how to add it. Dynamic branching (this is what we do for volumetric lighting for example), or multicompile. Multicompile generate a lot of extra variant for forward path, so isn't really affordable from production point of view. So no silver bullet here and thus why we can't extent fog like we extent sky.

    hope this help.
     
  50. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Thanks for the report and repro, will check with the team