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
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Will the HDPipeline completely change the way shaders work?

Discussion in 'Graphics Experimental Previews' started by PhilSA, Oct 11, 2017.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I was looking at Amplify Shader Editor and ShaderForge, and I was wondering.... will these become completely unusable once the HDPipeline arrives? (unless they get converted by the authors... which is highly likely to happen)

    How much does the HDPipeline change the way shaders are written? I thought I heard somewhere in these forums that the whole ShaderLab thing was going away, but I can't remember where
     
    Last edited: Oct 11, 2017
    konsic, scvnathan and Cleverlie like this.
  2. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    219
    I wonder the same, I hope all my current made shaders don't render useless (pun intended :p)
     
  3. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    "I was looking at Amplify Shader Editor and ShaderForge, and I was wondering.... will these become completely unusable once the HDPipeline arrives"

    No and Yes.

    No:
    When you import all of your models that use current standard shader... they are just pink, You need to convert them to their new default HD shader:


    Yes:
    In SRP you can convert all of your old shaders to the new one automatically by just clicking 1 button:
     
    BrUnO-XaVIeR likes this.
  4. boxhallowed

    boxhallowed

    Joined:
    Mar 31, 2015
    Posts:
    513
    Can someone shoot me a link to the "how why and whens" of this? Not a huge fan of Shader Lab myself. So this could be a nice development.
     
  5. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    We don't have any real info on this.

    However, looking at the HDPipeline/Lit shader in the SRP project, it definitely seems like C# will be fulfilling the role shaderlab once had.

    Code (CSharp):
    1. using UnityEngine.Rendering;
    2.  
    3. namespace UnityEngine.Experimental.Rendering.HDPipeline
    4. {
    5.     public partial class Lit : RenderPipelineMaterial
    6.     {
    7.         [GenerateHLSL(PackingRules.Exact)]
    8.         public enum MaterialId
    9.         {
    10.             LitSSS          = 0,
    11.             LitStandard     = 1,
    12.             LitAniso        = 2,
    13.             LitClearCoat    = 3,
    14.             // LitSpecular (DiffuseColor/SpecularColor) is an alternate parametrization for LitStandard (BaseColor/Metal/Specular), but it is the same shading model
    15.             // We don't want any specific materialId for it, instead we use LitStandard as materialId. However for UI purpose we still define this value here.
    16.             // For material classification we will use LitStandard too
    17.             LitSpecular     = 4,
    18.         };
    19.  
    20.         // If change, be sure it match what is done in Lit.hlsl: MaterialFeatureFlagsFromGBuffer
    21.         // Material bit mask must match LightDefinitions.s_MaterialFeatureMaskFlags value
    22.         [GenerateHLSL]
    23.         public enum MaterialFeatureFlags
    24.         {
    25.             LitSSS          = 1 << MaterialId.LitSSS,
    26.             LitStandard     = 1 << MaterialId.LitStandard,
    27.             LitAniso        = 1 << MaterialId.LitAniso,
    28.             LitClearCoat    = 1 << MaterialId.LitClearCoat,
    29.         };
    30.  
    31.         [GenerateHLSL]
    32.         public class StandardDefinitions
    33.         {
    34.             public static int s_GBufferLitStandardRegularId = 0;
    35.             public static int s_GBufferLitStandardSpecularColorId = 1;
    36.  
    37.             public static float s_DefaultSpecularValue = 0.04f;
    38.             public static float s_SkinSpecularValue = 0.028f;
    39.         }
    40.  
    41.         //-----------------------------------------------------------------------------
    42.         // SurfaceData
    43.         //-----------------------------------------------------------------------------
    44.  
    45.         // Main structure that store the user data (i.e user input of master node in material graph)
    46.         [GenerateHLSL(PackingRules.Exact, false, true, 1000)]
    47.         public struct SurfaceData
    48.         {
    49.             [SurfaceDataAttributes("Base Color", false, true)]
    50.             public Vector3 baseColor;
    51.             [SurfaceDataAttributes("Specular Occlusion")]
    52.             public float specularOcclusion;
    53.  
    54.             [SurfaceDataAttributes("Normal", true)]
    55.             public Vector3 normalWS;
    56.             [SurfaceDataAttributes("Smoothness")]
    57.             public float perceptualSmoothness;
    58.             [SurfaceDataAttributes("Material ID")]
    59.             public MaterialId materialId; // matId above 3 are store in standard material gbuffer (2bit reserved)
    60.  
    61.             [SurfaceDataAttributes("Ambient Occlusion")]
    62.             public float ambientOcclusion;
    63.  
    64.             // MaterialId dependent attribute
    65.  
    66.             // standard
    67.             [SurfaceDataAttributes("Tangent", true)]
    68.             public Vector3 tangentWS;
    69.             [SurfaceDataAttributes("Anisotropy")]
    70.             public float anisotropy; // anisotropic ratio(0->no isotropic; 1->full anisotropy in tangent direction)
    71.             [SurfaceDataAttributes("Metallic")]
    72.             public float metallic;
    73.  
    74.             // SSS
    75.             [SurfaceDataAttributes("Subsurface Radius")]
    76.             public float subsurfaceRadius;
    77.             [SurfaceDataAttributes("Thickness")]
    78.             public float thickness;
    79.             [SurfaceDataAttributes("Subsurface Profile")]
    80.             public int subsurfaceProfile;
    81.  
    82.             // SpecColor
    83.             [SurfaceDataAttributes("Specular Color", false, true)]
    84.             public Vector3 specularColor;
    85.  
    86.             // ClearCoat
    87.             [SurfaceDataAttributes("Coat Normal", true)]
    88.             public Vector3 coatNormalWS;
    89.             [SurfaceDataAttributes("Coat coverage")]
    90.             public float coatCoverage;
    91.             [SurfaceDataAttributes("Coat IOR")]
    92.             public float coatIOR; // Value is [0..1] for artists but the UI will display the value between [1..2]
    93.         };
    94.  
    95.         //-----------------------------------------------------------------------------
    96.         // BSDFData
    97.         //-----------------------------------------------------------------------------
    98.  
    99.         [GenerateHLSL(PackingRules.Exact)]
    100.         public enum TransmissionType
    101.         {
    102.             None = 0,
    103.             Regular = 1,
    104.             ThinObject = 2,
    105.         };
    106.  
    107.         [GenerateHLSL(PackingRules.Exact, false, true, 1030)]
    108.         public struct BSDFData
    109.         {
    110.             [SurfaceDataAttributes("", false, true)]
    111.             public Vector3 diffuseColor;
    112.  
    113.             public Vector3 fresnel0;
    114.  
    115.             public float specularOcclusion;
    116.  
    117.             [SurfaceDataAttributes("", true)]
    118.             public Vector3 normalWS;
    119.             public float perceptualRoughness;
    120.             public float roughness;
    121.             public int materialId;
    122.  
    123.             // MaterialId dependent attribute
    124.  
    125.             // standard
    126.             [SurfaceDataAttributes("", true)]
    127.             public Vector3 tangentWS;
    128.             [SurfaceDataAttributes("", true)]
    129.             public Vector3 bitangentWS;
    130.             public float roughnessT;
    131.             public float roughnessB;
    132.             public float anisotropy;
    133.  
    134.             // fold into fresnel0
    135.  
    136.             // SSS
    137.             public float   subsurfaceRadius;
    138.             public float   thickness;
    139.             public int     subsurfaceProfile;
    140.             public bool    enableTransmission; // Read from the SSS profile
    141.             public bool    useThinObjectMode;  // Read from the SSS profile
    142.             public Vector3 transmittance;
    143.  
    144.             // SpecColor
    145.             // fold into fresnel0
    146.  
    147.             // ClearCoat
    148.             public Vector3 coatNormalWS;
    149.             public float coatCoverage;
    150.             public float coatIOR; // CoatIOR is in range[1..2] it is surfaceData + 1
    151.         };
    152.  
    153.         //-----------------------------------------------------------------------------
    154.         // RenderLoop management
    155.         //-----------------------------------------------------------------------------
    156.  
    157.         [GenerateHLSL(PackingRules.Exact)]
    158.         public enum GBufferMaterial
    159.         {
    160.             // Note: This count doesn't include the velocity buffer. On shader and csharp side the velocity buffer will be added by the framework
    161.             Count = (ShaderConfig.k_PackgbufferInU16 == 1) ? 2 : 4
    162.         };
    163.  
    164.         //-----------------------------------------------------------------------------
    165.         // GBuffer management
    166.         //-----------------------------------------------------------------------------
    167.  
    168.         public override int GetMaterialGBufferCount() { return (int)GBufferMaterial.Count; }
    169.  
    170.         public override void GetMaterialGBufferDescription(out RenderTextureFormat[] RTFormat, out RenderTextureReadWrite[] RTReadWrite)
    171.         {
    172.             RTFormat = new RenderTextureFormat[(int)GBufferMaterial.Count];
    173.             RTReadWrite = new RenderTextureReadWrite[(int)GBufferMaterial.Count];
    174.  
    175.             if (ShaderConfig.s_PackgbufferInU16 == 1)
    176.             {
    177.                 // TODO: Just discovered that Unity doesn't support unsigned 16 RT format.
    178.                 RTFormat[0] = RenderTextureFormat.ARGBInt; RTReadWrite[0] = RenderTextureReadWrite.Linear;
    179.                 RTFormat[1] = RenderTextureFormat.ARGBInt; RTReadWrite[1] = RenderTextureReadWrite.Linear;
    180.             }
    181.             else
    182.             {
    183.                 RTFormat[0] = RenderTextureFormat.ARGB32; RTReadWrite[0] = RenderTextureReadWrite.sRGB;
    184.                 RTFormat[1] = RenderTextureFormat.ARGB2101010; RTReadWrite[1] = RenderTextureReadWrite.Linear;
    185.                 RTFormat[2] = RenderTextureFormat.ARGB32; RTReadWrite[2] = RenderTextureReadWrite.Linear;
    186.                 RTFormat[3] = RenderTextureFormat.RGB111110Float; RTReadWrite[3] = RenderTextureReadWrite.Linear;
    187.             }
    188.         }
    189.  
    190.         //-----------------------------------------------------------------------------
    191.         // Init precomputed texture
    192.         //-----------------------------------------------------------------------------
    193.  
    194.         bool m_isInit;
    195.  
    196.         // For image based lighting
    197.         Material      m_InitPreFGD;
    198.         RenderTexture m_PreIntegratedFGD;
    199.  
    200.         // For area lighting - We pack all texture inside a texture array to reduce the number of resource required
    201.         Texture2DArray m_LtcData; // 0: m_LtcGGXMatrix - RGBA, 2: m_LtcDisneyDiffuseMatrix - RGBA, 3: m_LtcMultiGGXFresnelDisneyDiffuse - RGB, A unused
    202.  
    203.         const int k_LtcLUTMatrixDim  =  3; // size of the matrix (3x3)
    204.         const int k_LtcLUTResolution = 64;
    205.  
    206.  
    207.         // Load LUT with one scalar in alpha of a tex2D
    208.         void LoadLUT(Texture2DArray tex, int arrayElement, TextureFormat format, float[] LUTScalar)
    209.         {
    210.             const int count = k_LtcLUTResolution * k_LtcLUTResolution;
    211.             Color[] pixels = new Color[count];
    212.  
    213.             for (int i = 0; i < count; i++)
    214.             {
    215.                 pixels[i] = new Color(0, 0, 0, LUTScalar[i]);
    216.             }
    217.  
    218.             tex.SetPixels(pixels, arrayElement);
    219.         }
    220.  
    221.         // Load LUT with 3x3 matrix in RGBA of a tex2D (some part are zero)
    222.         void LoadLUT(Texture2DArray tex, int arrayElement, TextureFormat format, double[,] LUTTransformInv)
    223.         {
    224.             const int count = k_LtcLUTResolution * k_LtcLUTResolution;
    225.             Color[] pixels = new Color[count];
    226.  
    227.             for (int i = 0; i < count; i++)
    228.             {
    229.                 // Both GGX and Disney Diffuse BRDFs have zero values in columns 1, 3, 5, 7.
    230.                 // Column 8 contains only ones.
    231.                 pixels[i] = new Color((float)LUTTransformInv[i, 0],
    232.                         (float)LUTTransformInv[i, 2],
    233.                         (float)LUTTransformInv[i, 4],
    234.                         (float)LUTTransformInv[i, 6]);
    235.             }
    236.  
    237.             tex.SetPixels(pixels, arrayElement);
    238.         }
    239.  
    240.         // Special-case function for 'm_LtcMultiGGXFresnelDisneyDiffuse'.
    241.         void LoadLUT(Texture2DArray tex, int arrayElement, TextureFormat format,   float[] LtcGGXMagnitudeData,
    242.             float[] LtcGGXFresnelData,
    243.             float[] LtcDisneyDiffuseMagnitudeData)
    244.         {
    245.             const int count = k_LtcLUTResolution * k_LtcLUTResolution;
    246.             Color[] pixels = new Color[count];
    247.  
    248.             for (int i = 0; i < count; i++)
    249.             {
    250.                 // We store the result of the subtraction as a run-time optimization.
    251.                 // See the footnote 2 of "LTC Fresnel Approximation" by Stephen Hill.
    252.                 pixels[i] = new Color(LtcGGXMagnitudeData[i] - LtcGGXFresnelData[i],
    253.                         LtcGGXFresnelData[i], LtcDisneyDiffuseMagnitudeData[i], 1);
    254.             }
    255.  
    256.             tex.SetPixels(pixels, arrayElement);
    257.         }
    258.  
    259.         public Lit() {}
    260.  
    261.         public override void Build(RenderPipelineResources renderPipelineResources)
    262.         {
    263.             m_InitPreFGD = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/PreIntegratedFGD");
    264.  
    265.             // For DisneyDiffuse integration values goes from (0.5 to 1.53125). GGX need 0 to 1. Use float format.
    266.             m_PreIntegratedFGD = new RenderTexture(128, 128, 0, RenderTextureFormat.RGB111110Float, RenderTextureReadWrite.Linear);
    267.             m_PreIntegratedFGD.filterMode = FilterMode.Bilinear;
    268.             m_PreIntegratedFGD.wrapMode = TextureWrapMode.Clamp;
    269.             m_PreIntegratedFGD.hideFlags = HideFlags.DontSave;
    270.             m_PreIntegratedFGD.Create();
    271.  
    272.             m_LtcData = new Texture2DArray(k_LtcLUTResolution, k_LtcLUTResolution, 3, TextureFormat.RGBAHalf, false /*mipmap*/, true /* linear */)
    273.             {
    274.                 hideFlags = HideFlags.HideAndDontSave,
    275.                 wrapMode = TextureWrapMode.Clamp,
    276.                 filterMode = FilterMode.Bilinear
    277.             };
    278.  
    279.             LoadLUT(m_LtcData, 0, TextureFormat.RGBAHalf,   s_LtcGGXMatrixData);
    280.             LoadLUT(m_LtcData, 1, TextureFormat.RGBAHalf,   s_LtcDisneyDiffuseMatrixData);
    281.             // TODO: switch to RGBA64 when it becomes available.
    282.             LoadLUT(m_LtcData, 2, TextureFormat.RGBAHalf,   s_LtcGGXMagnitudeData, s_LtcGGXFresnelData, s_LtcDisneyDiffuseMagnitudeData);
    283.  
    284.             m_LtcData.Apply();
    285.  
    286.             m_isInit = false;
    287.         }
    288.  
    289.         public override void Cleanup()
    290.         {
    291.             Utilities.Destroy(m_InitPreFGD);
    292.  
    293.             // TODO: how to delete RenderTexture ? or do we need to do it ?
    294.             m_isInit = false;
    295.         }
    296.  
    297.         public override void RenderInit(CommandBuffer cmd)
    298.         {
    299.             if (m_isInit)
    300.                 return;
    301.  
    302.             using (new Utilities.ProfilingSample("Init PreFGD", cmd))
    303.             {
    304.                 Utilities.DrawFullScreen(cmd, m_InitPreFGD, new RenderTargetIdentifier(m_PreIntegratedFGD));
    305.             }
    306.             m_isInit = true;
    307.         }
    308.  
    309.         public override void Bind()
    310.         {
    311.             Shader.SetGlobalTexture("_PreIntegratedFGD", m_PreIntegratedFGD);
    312.             Shader.SetGlobalTexture("_LtcData", m_LtcData);
    313.         }
    314.     }
    315. }
    316.  

    ...and this generates an hlsl file:

    Code (CSharp):
    1.  
    2. //
    3. // This file was automatically generated from Assets/ScriptableRenderLoop/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.  Please don't edit by hand.
    4. //
    5.  
    6. #ifndef LIT_CS_HLSL
    7. #define LIT_CS_HLSL
    8. //
    9. // UnityEngine.Experimental.Rendering.HDPipeline.Lit+MaterialId:  static fields
    10. //
    11. #define MATERIALID_LIT_SSS (0)
    12. #define MATERIALID_LIT_STANDARD (1)
    13. #define MATERIALID_LIT_ANISO (2)
    14. #define MATERIALID_LIT_CLEAR_COAT (3)
    15. #define MATERIALID_LIT_SPECULAR (4)
    16.  
    17. //
    18. // UnityEngine.Experimental.Rendering.HDPipeline.Lit+MaterialFeatureFlags:  static fields
    19. //
    20. #define MATERIALFEATUREFLAGS_LIT_SSS (1)
    21. #define MATERIALFEATUREFLAGS_LIT_STANDARD (2)
    22. #define MATERIALFEATUREFLAGS_LIT_ANISO (4)
    23. #define MATERIALFEATUREFLAGS_LIT_CLEAR_COAT (8)
    24.  
    25. //
    26. // UnityEngine.Experimental.Rendering.HDPipeline.Lit+StandardDefinitions:  static fields
    27. //
    28. #define GBUFFER_LIT_STANDARD_REGULAR_ID (0)
    29. #define GBUFFER_LIT_STANDARD_SPECULAR_COLOR_ID (1)
    30. #define DEFAULT_SPECULAR_VALUE (0.04)
    31. #define SKIN_SPECULAR_VALUE (0.028)
    32.  
    33. //
    34. // UnityEngine.Experimental.Rendering.HDPipeline.Lit+SurfaceData:  static fields
    35. //
    36. #define DEBUGVIEW_LIT_SURFACEDATA_BASE_COLOR (1000)
    37. #define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_OCCLUSION (1001)
    38. #define DEBUGVIEW_LIT_SURFACEDATA_NORMAL_WS (1002)
    39. #define DEBUGVIEW_LIT_SURFACEDATA_PERCEPTUAL_SMOOTHNESS (1003)
    40. #define DEBUGVIEW_LIT_SURFACEDATA_MATERIAL_ID (1004)
    41. #define DEBUGVIEW_LIT_SURFACEDATA_AMBIENT_OCCLUSION (1005)
    42. #define DEBUGVIEW_LIT_SURFACEDATA_TANGENT_WS (1006)
    43. #define DEBUGVIEW_LIT_SURFACEDATA_ANISOTROPY (1007)
    44. #define DEBUGVIEW_LIT_SURFACEDATA_METALLIC (1008)
    45. #define DEBUGVIEW_LIT_SURFACEDATA_SUBSURFACE_RADIUS (1009)
    46. #define DEBUGVIEW_LIT_SURFACEDATA_THICKNESS (1010)
    47. #define DEBUGVIEW_LIT_SURFACEDATA_SUBSURFACE_PROFILE (1011)
    48. #define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_COLOR (1012)
    49. #define DEBUGVIEW_LIT_SURFACEDATA_COAT_NORMAL_WS (1013)
    50. #define DEBUGVIEW_LIT_SURFACEDATA_COAT_COVERAGE (1014)
    51. #define DEBUGVIEW_LIT_SURFACEDATA_COAT_IOR (1015)
    52.  
    53. //
    54. // UnityEngine.Experimental.Rendering.HDPipeline.Lit+TransmissionType:  static fields
    55. //
    56. #define TRANSMISSIONTYPE_NONE (0)
    57. #define TRANSMISSIONTYPE_REGULAR (1)
    58. #define TRANSMISSIONTYPE_THIN_OBJECT (2)
    59.  
    60. //
    61. // UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData:  static fields
    62. //
    63. #define DEBUGVIEW_LIT_BSDFDATA_DIFFUSE_COLOR (1030)
    64. #define DEBUGVIEW_LIT_BSDFDATA_FRESNEL0 (1031)
    65. #define DEBUGVIEW_LIT_BSDFDATA_SPECULAR_OCCLUSION (1032)
    66. #define DEBUGVIEW_LIT_BSDFDATA_NORMAL_WS (1033)
    67. #define DEBUGVIEW_LIT_BSDFDATA_PERCEPTUAL_ROUGHNESS (1034)
    68. #define DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS (1035)
    69. #define DEBUGVIEW_LIT_BSDFDATA_MATERIAL_ID (1036)
    70. #define DEBUGVIEW_LIT_BSDFDATA_TANGENT_WS (1037)
    71. #define DEBUGVIEW_LIT_BSDFDATA_BITANGENT_WS (1038)
    72. #define DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS_T (1039)
    73. #define DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS_B (1040)
    74. #define DEBUGVIEW_LIT_BSDFDATA_ANISOTROPY (1041)
    75. #define DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_RADIUS (1042)
    76. #define DEBUGVIEW_LIT_BSDFDATA_THICKNESS (1043)
    77. #define DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_PROFILE (1044)
    78. #define DEBUGVIEW_LIT_BSDFDATA_ENABLE_TRANSMISSION (1045)
    79. #define DEBUGVIEW_LIT_BSDFDATA_USE_THIN_OBJECT_MODE (1046)
    80. #define DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE (1047)
    81. #define DEBUGVIEW_LIT_BSDFDATA_COAT_NORMAL_WS (1048)
    82. #define DEBUGVIEW_LIT_BSDFDATA_COAT_COVERAGE (1049)
    83. #define DEBUGVIEW_LIT_BSDFDATA_COAT_IOR (1050)
    84.  
    85. //
    86. // UnityEngine.Experimental.Rendering.HDPipeline.Lit+GBufferMaterial:  static fields
    87. //
    88. #define GBUFFERMATERIAL_COUNT (4)
    89.  
    90. // Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit+SurfaceData
    91. // PackingRules = Exact
    92. struct SurfaceData
    93. {
    94.     float3 baseColor;
    95.     float specularOcclusion;
    96.     float3 normalWS;
    97.     float perceptualSmoothness;
    98.     int materialId;
    99.     float ambientOcclusion;
    100.     float3 tangentWS;
    101.     float anisotropy;
    102.     float metallic;
    103.     float subsurfaceRadius;
    104.     float thickness;
    105.     int subsurfaceProfile;
    106.     float3 specularColor;
    107.     float3 coatNormalWS;
    108.     float coatCoverage;
    109.     float coatIOR;
    110. };
    111.  
    112. // Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData
    113. // PackingRules = Exact
    114. struct BSDFData
    115. {
    116.     float3 diffuseColor;
    117.     float3 fresnel0;
    118.     float specularOcclusion;
    119.     float3 normalWS;
    120.     float perceptualRoughness;
    121.     float roughness;
    122.     int materialId;
    123.     float3 tangentWS;
    124.     float3 bitangentWS;
    125.     float roughnessT;
    126.     float roughnessB;
    127.     float anisotropy;
    128.     float subsurfaceRadius;
    129.     float thickness;
    130.     int subsurfaceProfile;
    131.     bool enableTransmission;
    132.     bool useThinObjectMode;
    133.     float3 transmittance;
    134.     float3 coatNormalWS;
    135.     float coatCoverage;
    136.     float coatIOR;
    137. };
    138.  
    139. //
    140. // Debug functions
    141. //
    142. void GetGeneratedSurfaceDataDebug(uint paramId, SurfaceData surfacedata, inout float3 result, inout bool needLinearToSRGB)
    143. {
    144.     switch (paramId)
    145.     {
    146.         case DEBUGVIEW_LIT_SURFACEDATA_BASE_COLOR:
    147.             result = surfacedata.baseColor;
    148.             needLinearToSRGB = true;
    149.             break;
    150.         case DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_OCCLUSION:
    151.             result = surfacedata.specularOcclusion.xxx;
    152.             break;
    153.         case DEBUGVIEW_LIT_SURFACEDATA_NORMAL_WS:
    154.             result = surfacedata.normalWS * 0.5 + 0.5;
    155.             break;
    156.         case DEBUGVIEW_LIT_SURFACEDATA_PERCEPTUAL_SMOOTHNESS:
    157.             result = surfacedata.perceptualSmoothness.xxx;
    158.             break;
    159.         case DEBUGVIEW_LIT_SURFACEDATA_MATERIAL_ID:
    160.             result = GetIndexColor(surfacedata.materialId);
    161.             break;
    162.         case DEBUGVIEW_LIT_SURFACEDATA_AMBIENT_OCCLUSION:
    163.             result = surfacedata.ambientOcclusion.xxx;
    164.             break;
    165.         case DEBUGVIEW_LIT_SURFACEDATA_TANGENT_WS:
    166.             result = surfacedata.tangentWS * 0.5 + 0.5;
    167.             break;
    168.         case DEBUGVIEW_LIT_SURFACEDATA_ANISOTROPY:
    169.             result = surfacedata.anisotropy.xxx;
    170.             break;
    171.         case DEBUGVIEW_LIT_SURFACEDATA_METALLIC:
    172.             result = surfacedata.metallic.xxx;
    173.             break;
    174.         case DEBUGVIEW_LIT_SURFACEDATA_SUBSURFACE_RADIUS:
    175.             result = surfacedata.subsurfaceRadius.xxx;
    176.             break;
    177.         case DEBUGVIEW_LIT_SURFACEDATA_THICKNESS:
    178.             result = surfacedata.thickness.xxx;
    179.             break;
    180.         case DEBUGVIEW_LIT_SURFACEDATA_SUBSURFACE_PROFILE:
    181.             result = GetIndexColor(surfacedata.subsurfaceProfile);
    182.             break;
    183.         case DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_COLOR:
    184.             result = surfacedata.specularColor;
    185.             needLinearToSRGB = true;
    186.             break;
    187.         case DEBUGVIEW_LIT_SURFACEDATA_COAT_NORMAL_WS:
    188.             result = surfacedata.coatNormalWS * 0.5 + 0.5;
    189.             break;
    190.         case DEBUGVIEW_LIT_SURFACEDATA_COAT_COVERAGE:
    191.             result = surfacedata.coatCoverage.xxx;
    192.             break;
    193.         case DEBUGVIEW_LIT_SURFACEDATA_COAT_IOR:
    194.             result = surfacedata.coatIOR.xxx;
    195.             break;
    196.     }
    197. }
    198.  
    199. //
    200. // Debug functions
    201. //
    202. void GetGeneratedBSDFDataDebug(uint paramId, BSDFData bsdfdata, inout float3 result, inout bool needLinearToSRGB)
    203. {
    204.     switch (paramId)
    205.     {
    206.         case DEBUGVIEW_LIT_BSDFDATA_DIFFUSE_COLOR:
    207.             result = bsdfdata.diffuseColor;
    208.             needLinearToSRGB = true;
    209.             break;
    210.         case DEBUGVIEW_LIT_BSDFDATA_FRESNEL0:
    211.             result = bsdfdata.fresnel0;
    212.             break;
    213.         case DEBUGVIEW_LIT_BSDFDATA_SPECULAR_OCCLUSION:
    214.             result = bsdfdata.specularOcclusion.xxx;
    215.             break;
    216.         case DEBUGVIEW_LIT_BSDFDATA_NORMAL_WS:
    217.             result = bsdfdata.normalWS * 0.5 + 0.5;
    218.             break;
    219.         case DEBUGVIEW_LIT_BSDFDATA_PERCEPTUAL_ROUGHNESS:
    220.             result = bsdfdata.perceptualRoughness.xxx;
    221.             break;
    222.         case DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS:
    223.             result = bsdfdata.roughness.xxx;
    224.             break;
    225.         case DEBUGVIEW_LIT_BSDFDATA_MATERIAL_ID:
    226.             result = GetIndexColor(bsdfdata.materialId);
    227.             break;
    228.         case DEBUGVIEW_LIT_BSDFDATA_TANGENT_WS:
    229.             result = bsdfdata.tangentWS * 0.5 + 0.5;
    230.             break;
    231.         case DEBUGVIEW_LIT_BSDFDATA_BITANGENT_WS:
    232.             result = bsdfdata.bitangentWS * 0.5 + 0.5;
    233.             break;
    234.         case DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS_T:
    235.             result = bsdfdata.roughnessT.xxx;
    236.             break;
    237.         case DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS_B:
    238.             result = bsdfdata.roughnessB.xxx;
    239.             break;
    240.         case DEBUGVIEW_LIT_BSDFDATA_ANISOTROPY:
    241.             result = bsdfdata.anisotropy.xxx;
    242.             break;
    243.         case DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_RADIUS:
    244.             result = bsdfdata.subsurfaceRadius.xxx;
    245.             break;
    246.         case DEBUGVIEW_LIT_BSDFDATA_THICKNESS:
    247.             result = bsdfdata.thickness.xxx;
    248.             break;
    249.         case DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_PROFILE:
    250.             result = GetIndexColor(bsdfdata.subsurfaceProfile);
    251.             break;
    252.         case DEBUGVIEW_LIT_BSDFDATA_ENABLE_TRANSMISSION:
    253.             result = (bsdfdata.enableTransmission) ? float3(1.0, 1.0, 1.0) : float3(0.0, 0.0, 0.0);
    254.             break;
    255.         case DEBUGVIEW_LIT_BSDFDATA_USE_THIN_OBJECT_MODE:
    256.             result = (bsdfdata.useThinObjectMode) ? float3(1.0, 1.0, 1.0) : float3(0.0, 0.0, 0.0);
    257.             break;
    258.         case DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE:
    259.             result = bsdfdata.transmittance;
    260.             break;
    261.         case DEBUGVIEW_LIT_BSDFDATA_COAT_NORMAL_WS:
    262.             result = bsdfdata.coatNormalWS;
    263.             break;
    264.         case DEBUGVIEW_LIT_BSDFDATA_COAT_COVERAGE:
    265.             result = bsdfdata.coatCoverage.xxx;
    266.             break;
    267.         case DEBUGVIEW_LIT_BSDFDATA_COAT_IOR:
    268.             result = bsdfdata.coatIOR.xxx;
    269.             break;
    270.     }
    271. }
    272.  
    273.  
    274. #endif
    275.  
    276.  

    ...and I cannot wait to play around with this!

    Other things I've noticed is that there is also a Lit.shader file that still seems to have some shaderlab in it. And hlsl seems to be replacing CG entirely (CGPROGRAM is now HLSLPROGRAM). In total, there are 4 files for the Lit shader:
    • Lit.cs
    • Lit.cs.hlsl
    • Lit.hlsl
    • Lit.shader
    It'd be great if a dev could explain all this, It looks really interesting
     
    Last edited: Oct 12, 2017
    scvnathan likes this.
  6. boxhallowed

    boxhallowed

    Joined:
    Mar 31, 2015
    Posts:
    513
    Ugh, about damned time. Down with shader lab, up with bubbles.
     
  7. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    they planning to add a built in shader node editor for SRP so we don't have to deal with all of that
     
  8. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    869
    Where did you get this info from?
     
  9. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
  10. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    869
    OCASM likes this.
  11. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    there's a branch for shader graph since months ago actually, but i doubt it would work with the public unity release
     
  12. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995

    What is HDPipeline ?
     
  13. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Last edited: Nov 23, 2017
    konsic likes this.
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It'll be generally faster than a dx9-era engine at doing the same workloads as well, and Unity is still a dx9-era engine, that is, it's authored for around that tech. There's work been done to drag it screaming and kicking up to date but smart people realised it couldn't be done and would only get worse long term so

    Scriptable Render Pipeline
    solves that by allowing a kind of "pluggable graphics engine" - this is a simple way to describe it but it's really a better way to organise how Unity renders and add features of your own. It will ship with two plugin renderers to start with, these are called "Scriptable Render Pipeline Assets" and the two you get are the

    HDRenderPipeline and LDRenderPipeline, with the latter being good for webgl, mobile, even VR in some cases and the former being good for the same, but obviously heavier performance and higher quality.

    This way people can much better choose the engine that fits their game. In the end we'll see asset authors supplying Scriptable Render Pipeline "bricks" so we can pull different features together to better tailor Unity to our games.

    I used a lot of laymans terms as I don't know the technical ability of who reads this, but I hope I got the point across.
     
    BrUnO-XaVIeR and konsic like this.
  15. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    WIll Scriptable Render Pipeline still use Monodevelop ?
     
  16. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    konsic likes this.
  17. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Is it possible to get realtime lighting like in Cryengine ?
     
  18. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Depends on what you mean.
    Will it come with the same tech as cryengine? Most likely no.
    Will you be able to create similar (read: conceptually the same) render methods? Yeah, definitely.
     
    konsic likes this.
  19. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The HD path is all I could ask for from an engine setup. It looks great. But I have concerns about the performance, and the performance that worries me is Unity side more than the shaders. Unity is still hauling around a lot of monolithic baggage but I hope one day they can cut all that out and we only have SRP.
     
    Flurgle and konsic like this.