Vectorscope.shader 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. Shader "Hidden/PostProcessing/Debug/Vectorscope"
  2. {
  3. HLSLINCLUDE
  4. #pragma exclude_renderers gles gles3 d3d11_9x
  5. #pragma target 4.5
  6. #include "../StdLib.hlsl"
  7. #include "../Colors.hlsl"
  8. StructuredBuffer<uint> _VectorscopeBuffer;
  9. float3 _Params; // x: width, y: height, z: exposure, w: unused
  10. float Tonemap(float x, float exposure)
  11. {
  12. const float a = 6.2;
  13. const float b = 0.5;
  14. const float c = 1.7;
  15. const float d = 0.06;
  16. x *= exposure;
  17. x = max(0.0, x - 0.004);
  18. x = (x * (a * x + b)) / (x * (a * x + c) + d);
  19. return x * x;
  20. }
  21. float4 Frag(VaryingsDefault i) : SV_Target
  22. {
  23. i.texcoord.x = 1.0 - i.texcoord.x;
  24. float2 uv = i.texcoord - (0.5).xx;
  25. float3 c = YCbCrToRgb(float3(0.5, uv.x, uv.y));
  26. float dist = sqrt(dot(uv, uv));
  27. float delta = fwidth(dist) * 0.5;
  28. float alphaOut = 1.0 - smoothstep(0.5 - delta, 0.5 + delta, dist);
  29. uint2 uvI = i.texcoord.xy * _Params.xy;
  30. uint v = _VectorscopeBuffer[uvI.x + uvI.y * _Params.x];
  31. float vt = saturate(Tonemap(v, _Params.z));
  32. float4 color = float4(lerp(c, (0.0).xxx, vt), 1.0);
  33. return color;
  34. }
  35. ENDHLSL
  36. SubShader
  37. {
  38. Cull Off ZWrite Off ZTest Always
  39. Pass
  40. {
  41. HLSLPROGRAM
  42. #pragma vertex VertDefault
  43. #pragma fragment Frag
  44. ENDHLSL
  45. }
  46. }
  47. }