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.

67 lines
1.3 KiB

  1. Shader "Oculus/OVRVignette"
  2. {
  3. Properties
  4. {
  5. _Color("Color", Color) = (0,0,0,0)
  6. [Enum(UnityEngine.Rendering.BlendMode)]_BlendSrc ("Blend Source", Float) = 1
  7. [Enum(UnityEngine.Rendering.BlendMode)]_BlendDst ("Blend Destination", Float) = 0
  8. _ZWrite ("Z Write", Float) = 0
  9. }
  10. SubShader
  11. {
  12. Tags { "IgnoreProjector" = "True" }
  13. Pass
  14. {
  15. Blend [_BlendSrc] [_BlendDst]
  16. ZTest Always
  17. ZWrite [_ZWrite]
  18. Cull Off
  19. CGPROGRAM
  20. #pragma vertex vert
  21. #pragma fragment frag
  22. #pragma multi_compile _ QUADRATIC_FALLOFF
  23. #include "UnityCG.cginc"
  24. struct appdata
  25. {
  26. float4 vertex : POSITION;
  27. float2 uv : TEXCOORD0;
  28. };
  29. struct v2f
  30. {
  31. float4 vertex : SV_POSITION;
  32. half4 color : COLOR;
  33. };
  34. float4 _ScaleAndOffset0[2];
  35. float4 _ScaleAndOffset1[2];
  36. float4 _Color;
  37. v2f vert (appdata v)
  38. {
  39. v2f o;
  40. float4 scaleAndOffset = lerp(_ScaleAndOffset0[unity_StereoEyeIndex], _ScaleAndOffset1[unity_StereoEyeIndex], v.uv.x);
  41. o.vertex = float4(scaleAndOffset.zw + v.vertex.xy * scaleAndOffset.xy, _ProjectionParams.y, 1);
  42. o.color.rgb = _Color.rgb;
  43. o.color.a = v.uv.y;
  44. return o;
  45. }
  46. fixed4 frag (v2f i) : SV_Target
  47. {
  48. #if QUADRATIC_FALLOFF
  49. i.color.a *= i.color.a;
  50. #endif
  51. return i.color;
  52. }
  53. ENDCG
  54. }
  55. }
  56. }