#Hi, I want to draw thousands of lidar

1 messages · Page 1 of 1 (latest)

cobalt quartz
#
Shader "Unlit/LiDAR Shader"
{
  Properties
  {   
  }
  SubShader
  {
    Tags { "RenderType"="Transparent" "RenderPipeline" = "UniversalPipeline" }
    LOD 100

    Pass
    {
      CGPROGRAM
      #pragma vertex vert
      #pragma fragment frag
      #pragma multi_compile_instancing
      #include "UnityCG.cginc"

      struct appdata
      {
        float4 vertex : POSITION;
        UNITY_VERTEX_INPUT_INSTANCE_ID
      };

      struct v2f
      {
        float4 vertex : SV_POSITION;
        UNITY_VERTEX_INPUT_INSTANCE_ID
        UNITY_VERTEX_OUTPUT_STEREO
      };

      UNITY_INSTANCING_BUFFER_START(Props)
        UNITY_DEFINE_INSTANCED_PROP(float4, _Colors)
      UNITY_INSTANCING_BUFFER_END(Props)

      v2f vert(appdata v)
      {
        v2f o;

        UNITY_SETUP_INSTANCE_ID(v);
        UNITY_TRANSFER_INSTANCE_ID(v, o);
        UNITY_INITIALIZE_OUTPUT(v2f, o);
        UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

        o.vertex = UnityObjectToClipPos(v.vertex);
        return o;
      }

      float4 frag(v2f i) : SV_Target
      {
        UNITY_SETUP_INSTANCE_ID(i);
        float4 col = UNITY_ACCESS_INSTANCED_PROP(Props, _Colors);

        return col;
      }
      ENDCG
    }
  }
}
#
MaterialPropertyBlock block = new();
block.SetVectorArray("_Colors", colors);

Graphics.DrawMeshInstanced(pointMesh, 0, pointMaterial, matrices, elementCount, block, ShadowCastingMode.Off, false);
high horizon