Search Unity

Convert custom shader to HDRP shader

Discussion in 'High Definition Render Pipeline' started by lcaExtende, Dec 17, 2019.

  1. lcaExtende

    lcaExtende

    Joined:
    Sep 2, 2019
    Posts:
    25
    Hi everyone,

    I use for a project a shader with custom parameters.
    I am really stuck to convert it to HDRP shader.
    Can someone help me I would be very very happy...

    Code (CSharp):
    1.  
    2. Shader "Custom/SourceConeClipping" {
    3.     Properties
    4.     {
    5.        
    6.     }
    7.         SubShader
    8.     {
    9.         Tags{ "RenderPipeline" = "HDRenderPipeline" "RenderType" = "Opaque" }
    10.         LOD 100
    11.  
    12.         /*Cull off*/
    13.         //Zwrite off
    14.  
    15.         CGPROGRAM
    16. #pragma surface surf Lambert
    17.  
    18. #include "ObjetcProjection.cginc"
    19.  
    20.         uniform float3 _SourcePosition = half3(0.0, 0.0, 0.0);
    21.         uniform float3 _SourceDirection = half3(0.0, 0.0, 0.0);
    22.         uniform float _SourceConeAngle = half3(0.0, 0.0, 0.0);
    23.  
    24.     struct Input {
    25.         float2 uv_MainTex;
    26.         float3 worldPos;
    27.     };
    28.  
    29.     // There is no need to define a special vertex shader
    30.     // we use the standard vertex shader that transforms all vertices
    31.  
    32.     // we do the clipping in the Fragment shader
    33.     void surf(Input IN, inout SurfaceOutput o)
    34.     {
    35.         bool isInsideCone = ClipCone(IN.worldPos, _SourcePosition, _SourceDirection, _SourceConeAngle);
    36.         if (isInsideCone)
    37.         {
    38.             o.Albedo = half3(0.0, 0.0, 0.0);
    39.             o.Alpha = 1.0;
    40.         }
    41.         else
    42.         {
    43.             o.Albedo = half3(1.0, 1.0, 1.0);
    44.             o.Alpha = 1.0;
    45.         }
    46.        
    47.     }
    48.     ENDCG
    49.     }
    50.         FallBack "Diffuse"
    51. }
    52.  
    53.  
     
  2. customphase

    customphase

    Joined:
    Aug 19, 2012
    Posts:
    246
    Surface shaders dont exist in HDRP any more. This requires a total rewrite of the shader. Just use shader graph to emulate it.
     
  3. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Is tessellation supported in shadergraph
     
  4. JasonBooth

    JasonBooth

    Joined:
    Jan 27, 2014
    Posts:
    651
    Nope