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.

64 lines
1.3 KiB

  1. Shader "Oculus/Texture2D Blit" {
  2. Properties{
  3. _MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
  4. _linearToSrgb("Perform linear-to-gamma conversion", Int) = 0
  5. _premultiply("Pre-multiply alpha", Int) = 0
  6. }
  7. SubShader{
  8. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
  9. Pass{
  10. ZWrite Off
  11. ColorMask RGBA
  12. CGPROGRAM
  13. #pragma vertex vert
  14. #pragma fragment frag
  15. #include "UnityCG.cginc"
  16. struct appdata_t
  17. {
  18. float4 vertex : POSITION;
  19. float2 texcoord : TEXCOORD0;
  20. };
  21. struct v2f
  22. {
  23. float4 vertex : SV_POSITION;
  24. half2 texcoord : TEXCOORD0;
  25. };
  26. sampler2D _MainTex;
  27. float4 _MainTex_ST;
  28. int _linearToSrgb;
  29. int _premultiply;
  30. v2f vert (appdata_t v)
  31. {
  32. v2f o;
  33. o.vertex = UnityObjectToClipPos(v.vertex);
  34. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  35. return o;
  36. }
  37. fixed4 frag (v2f i) : COLOR
  38. {
  39. fixed4 col = tex2D(_MainTex, i.texcoord);
  40. if (_linearToSrgb)
  41. {
  42. float3 S1 = sqrt(col.rgb);
  43. float3 S2 = sqrt(S1);
  44. float3 S3 = sqrt(S2);
  45. col.rgb = 0.662002687 * S1 + 0.684122060 * S2 - 0.323583601 * S3 - 0.0225411470 * col.rgb;
  46. }
  47. if (_premultiply)
  48. col.rgb *= col.a;
  49. return col;
  50. }
  51. ENDCG
  52. }
  53. }
  54. }