Assignment for RMIT Mixed Reality in 2020
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.

85 lines
3.1 KiB

  1. // Adapted from The Lab Renderer's vr_quality_vis.shader, available at
  2. // https://github.com/ValveSoftware/the_lab_renderer/blob/ae64c48a8ccbe5406aba1e39b160d4f2f7156c2c/Assets/TheLabRenderer/Resources/vr_quality_vis.shader
  3. // For The Lab Renderer's license see THIRD_PARTY_NOTICES.
  4. Shader "VRTK/AdaptiveQualityDebugVisualization"
  5. {
  6. SubShader
  7. {
  8. Tags { "Queue" = "Overlay" "PreviewType" = "Plane" }
  9. Pass
  10. {
  11. Cull Off
  12. ZWrite Off
  13. ZTest Always
  14. CGPROGRAM
  15. #pragma only_renderers d3d11
  16. #pragma vertex vert
  17. #pragma fragment frag
  18. #include "UnityCG.cginc"
  19. v2f_img vert(appdata_img i)
  20. {
  21. v2f_img o = vert_img(i);
  22. o.uv.y = 1.0 - i.texcoord.y;
  23. return o;
  24. }
  25. CBUFFER_START(AdaptiveQualityDebugVisualization)
  26. uint _RenderScaleLevelsCount = 10;
  27. uint _DefaultRenderViewportScaleLevel = 6;
  28. uint _CurrentRenderViewportScaleLevel = 5;
  29. uint _CurrentRenderScaleLevel = 5;
  30. uint _LastFrameIsInBudget = 1;
  31. CBUFFER_END
  32. fixed4 frag(v2f_img i) : SV_TARGET0
  33. {
  34. fixed4 o;
  35. o.rgba = fixed4(0.0, 0.0, 0.0, 1.0);
  36. uint nLevel = i.uv.x * _RenderScaleLevelsCount;
  37. // Thin bar showing colors
  38. if (i.uv.y <= 0.1)
  39. {
  40. if (nLevel == 0)
  41. o.rgb = fixed3(0.5, 0.0, 0.0);
  42. else if (nLevel < _DefaultRenderViewportScaleLevel)
  43. o.rgb = fixed3(0.5, 0.5, 0.0);
  44. else
  45. o.rgb = fixed3(0.0, 0.5, 0.0);
  46. }
  47. // Current level
  48. else if (nLevel == _CurrentRenderViewportScaleLevel)
  49. {
  50. if (nLevel == _CurrentRenderScaleLevel && i.uv.y >= 0.9)
  51. o.rgb = fixed3(0.0, 1.0, 1.0);
  52. else if (_LastFrameIsInBudget == 0)
  53. o.rgb = fixed3(0.5, 0.0, 0.0);
  54. else if (nLevel < _DefaultRenderViewportScaleLevel)
  55. o.rgb = fixed3(0.5, 0.5, 0.0);
  56. else
  57. o.rgb = fixed3(0.0, 0.5, 0.0);
  58. }
  59. // Gray levels
  60. else
  61. {
  62. if (nLevel == _CurrentRenderScaleLevel && i.uv.y >= 0.9)
  63. o.rgb = fixed3(0.0, 1.0, 1.0);
  64. else if (nLevel & 0x1)
  65. o.rgb = fixed3(0.02, 0.02, 0.02);
  66. else
  67. o.rgb = fixed3(0.03, 0.03, 0.03);
  68. }
  69. return o;
  70. }
  71. ENDCG
  72. }
  73. }
  74. }