You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.8 KiB

  1. Shader "Hidden/Post FX/Monitors/Waveform Render"
  2. {
  3. SubShader
  4. {
  5. ZTest Always Cull Off ZWrite Off
  6. Fog { Mode off }
  7. CGINCLUDE
  8. #pragma fragmentoption ARB_precision_hint_fastest
  9. #pragma target 5.0
  10. #include "UnityCG.cginc"
  11. StructuredBuffer<uint4> _Waveform;
  12. float2 _Size;
  13. float4 _Channels;
  14. float _Exposure;
  15. float3 Tonemap(float3 x, float exposure)
  16. {
  17. const float a = 6.2;
  18. const float b = 0.5;
  19. const float c = 1.7;
  20. const float d = 0.06;
  21. x *= exposure;
  22. x = max((0.0).xxx, x - (0.004).xxx);
  23. x = (x * (a * x + b)) / (x * (a * x + c) + d);
  24. return x * x;
  25. }
  26. float4 FragWaveform(v2f_img i) : SV_Target
  27. {
  28. const float3 red = float3(1.4, 0.03, 0.02);
  29. const float3 green = float3(0.02, 1.1, 0.05);
  30. const float3 blue = float3(0.0, 0.25, 1.5);
  31. float3 color = float3(0.0, 0.0, 0.0);
  32. uint2 uvI = i.pos.xy;
  33. float4 w = _Waveform[uvI.y + uvI.x * _Size.y]; // Waveform data is stored in columns instead of rows
  34. color += red * w.r * _Channels.r;
  35. color += green * w.g * _Channels.g;
  36. color += blue * w.b * _Channels.b;
  37. color += w.aaa * _Channels.a * 1.5;
  38. color = Tonemap(color, _Exposure);
  39. color += (0.1).xxx;
  40. return float4(saturate(color), 1.0);
  41. }
  42. ENDCG
  43. // (0)
  44. Pass
  45. {
  46. CGPROGRAM
  47. #pragma vertex vert_img
  48. #pragma fragment FragWaveform
  49. ENDCG
  50. }
  51. }
  52. FallBack off
  53. }