Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. 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

Question Special shader for HDRP

Discussion in 'High Definition Render Pipeline' started by konsic, Dec 15, 2019.

  1. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    I need to get this shader with HDRP v7 working.

    How can I translate it ?

    Code (CSharp):
    1. Shader "SimplestInstancedShader"
    2. {
    3.     Properties
    4.     {
    5.         _Color ("Color", Color) = (1, 1, 1, 1)
    6.     }
    7.  
    8.     SubShader
    9.     {
    10.         Tags { "RenderType"="Opaque" }
    11.         LOD 100
    12.  
    13.         Pass
    14.         {
    15.             CGPROGRAM
    16.             #pragma vertex vert
    17.             #pragma fragment frag
    18.             #pragma multi_compile_instancing
    19.             #include "UnityCG.cginc"
    20.  
    21.             struct appdata
    22.             {
    23.                 float4 vertex : POSITION;
    24.                 UNITY_VERTEX_INPUT_INSTANCE_ID
    25.             };
    26.  
    27.             struct v2f
    28.             {
    29.                 float4 vertex : SV_POSITION;
    30.                 UNITY_VERTEX_INPUT_INSTANCE_ID // necessary only if you want to access instanced properties in __fragment Shader__.
    31.             };
    32.  
    33.             UNITY_INSTANCING_BUFFER_START(Props)
    34.                 UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
    35.             UNITY_INSTANCING_BUFFER_END(Props)
    36.          
    37.             v2f vert(appdata v)
    38.             {
    39.                 v2f o;
    40.  
    41.                 UNITY_SETUP_INSTANCE_ID(v);
    42.                 UNITY_TRANSFER_INSTANCE_ID(v, o); // necessary only if you want to access instanced properties in the fragment Shader.
    43.  
    44.                 o.vertex = UnityObjectToClipPos(v.vertex);
    45.                 return o;
    46.             }
    47.          
    48.             fixed4 frag(v2f i) : SV_Target
    49.             {
    50.                 UNITY_SETUP_INSTANCE_ID(i); // necessary only if any instanced properties are going to be accessed in the fragment Shader.
    51.                 return UNITY_ACCESS_INSTANCED_PROP(Props, _Color);
    52.             }
    53.             ENDCG
    54.         }
    55.     }
    56. }
     
  2. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    So you basically just want a Lit shader with just a custom color and instancing?
    Did you tried Shadergraph?
     
  3. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    No, I don't know how to use instancing in SG and if that will be the same as custom shader.