CMWaveform.shader 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. Shader "CMWaveform"
  2. {
  3. HLSLINCLUDE
  4. #pragma target 4.5
  5. #include "StdLib.hlsl"
  6. StructuredBuffer<uint4> _WaveformBuffer;
  7. float3 _Params; // x: buffer width, y: buffer height, z: exposure, w: unused
  8. float3 Tonemap(float3 x, float exposure)
  9. {
  10. const float a = 6.2;
  11. const float b = 0.5;
  12. const float c = 1.7;
  13. const float d = 0.06;
  14. x *= exposure;
  15. x = max((0.0).xxx, x - (0.004).xxx);
  16. x = (x * (a * x + b)) / (x * (a * x + c) + d);
  17. return x * x;
  18. }
  19. float4 Frag(VaryingsDefault i) : SV_Target
  20. {
  21. const float3 red = float3(1.4, 0.03, 0.02);
  22. const float3 green = float3(0.02, 1.1, 0.05);
  23. const float3 blue = float3(0.0, 0.25, 1.5);
  24. float3 color = float3(0.0, 0.0, 0.0);
  25. uint2 uvI = i.vertex.xy;
  26. float3 w = _WaveformBuffer[uvI.x * _Params.y + uvI.y].xyz;
  27. color += red * w.r;
  28. color += green * w.g;
  29. color += blue * w.b;
  30. color = Tonemap(color, _Params.z);
  31. return float4(saturate(color), 1.0);
  32. }
  33. ENDHLSL
  34. SubShader
  35. {
  36. Cull Off ZWrite Off ZTest Always
  37. Pass
  38. {
  39. HLSLPROGRAM
  40. #pragma vertex VertDefault
  41. #pragma fragment Frag
  42. ENDHLSL
  43. }
  44. }
  45. }