Point.shader 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //======= Copyright (c) Stereolabs Corporation, All rights reserved. ===============
  2. Shader "Point Cloud/Point"
  3. {
  4. Properties
  5. {
  6. _Tint("Tint", Color) = (0.5, 0.5, 0.5, 1)
  7. _PointSize("Point Size", Float) = 0.05
  8. }
  9. SubShader
  10. {
  11. Tags { "RenderType"="Opaque" }
  12. Pass
  13. {
  14. CGPROGRAM
  15. #pragma vertex Vertex
  16. #pragma fragment Fragment
  17. #pragma multi_compile_fog
  18. #pragma multi_compile _ UNITY_COLORSPACE_GAMMA
  19. #pragma multi_compile _ _DISTANCE_ON
  20. #pragma multi_compile _ _COMPUTE_BUFFER
  21. #include "UnityCG.cginc"
  22. #include "../ZED_Utils.cginc"
  23. struct Attributes
  24. {
  25. float4 position : POSITION;
  26. half3 color : COLOR;
  27. };
  28. struct Varyings
  29. {
  30. float4 position : SV_Position;
  31. half3 color : COLOR;
  32. half psize : PSIZE;
  33. UNITY_FOG_COORDS(0)
  34. };
  35. half4 _Tint;
  36. float4x4 _Transform;
  37. half _PointSize;
  38. StructuredBuffer<float4> _PointBuffer;
  39. Varyings Vertex(uint vid : SV_VertexID)
  40. {
  41. float4 pt = _PointBuffer[vid];
  42. float4 pos = mul(_Transform, float4(pt.xyz, 1));
  43. float4 col = PCDecodeColor(asuint(pt.w));
  44. Varyings o;
  45. o.position = UnityObjectToClipPos(pos);
  46. o.color = col;
  47. o.psize = _PointSize;
  48. UNITY_TRANSFER_FOG(o, o.position);
  49. return o;
  50. }
  51. half4 Fragment(Varyings input) : SV_Target
  52. {
  53. half4 c = half4(input.color, _Tint.a);
  54. UNITY_APPLY_FOG(input.fogCoord, c);
  55. return c;
  56. }
  57. ENDCG
  58. }
  59. }
  60. }