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.

81 lines
2.4 KiB

  1. /************************************************************************************
  2. Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
  3. See SampleFramework license.txt for license terms. Unless required by applicable law
  4. or agreed to in writing, the sample code is provided “AS IS” WITHOUT WARRANTIES OR
  5. CONDITIONS OF ANY KIND, either express or implied. See the license for specific
  6. language governing permissions and limitations under the license.
  7. ************************************************************************************/
  8. Shader "Oculus Sample/Procedural Gradient Skybox"
  9. {
  10. Properties
  11. {
  12. _TopColor ("Top Color", Color) = (1, 1, 1, 0)
  13. _HorizonColor ("Horizon Color", Color) = (1, 1, 1, 0)
  14. _BottomColor ("Bottom Color", Color) = (1, 1, 1, 0)
  15. _TopExponent ("Top Exponent", Float) = 0.5
  16. _BottomExponent ("Bottom Exponent", Float) = 0.5
  17. _AmplFactor ("Amplification", Float) = 1.0
  18. }
  19. SubShader
  20. {
  21. Tags{"RenderType" ="Background" "Queue" = "Background"}
  22. ZWrite Off Cull Off
  23. Fog { Mode Off }
  24. LOD 100
  25. Pass
  26. {
  27. CGPROGRAM
  28. #pragma vertex vert
  29. #pragma fragment frag
  30. #include "UnityCG.cginc"
  31. struct vertIn
  32. {
  33. float4 vertex : POSITION;
  34. float3 uv : TEXCOORD0;
  35. };
  36. struct vertOut
  37. {
  38. float4 vertex : SV_POSITION;
  39. float3 uv: TEXCOORD0;
  40. };
  41. vertOut vert (vertIn v)
  42. {
  43. vertOut o;
  44. o.vertex = UnityObjectToClipPos(v.vertex);
  45. o.uv = v.uv;
  46. return o;
  47. }
  48. half _TopExponent;
  49. half _BottomExponent;
  50. fixed4 _TopColor;
  51. fixed4 _HorizonColor;
  52. fixed4 _BottomColor;
  53. half _AmplFactor;
  54. fixed4 frag (vertOut i) : SV_Target
  55. {
  56. float interpUv = normalize (i.uv).y;
  57. // top goes from 0->1 going down toward horizon
  58. float topLerp = 1.0f - pow (min (1.0f, 1.0f - interpUv), _TopExponent);
  59. // bottom goes from 0->1 going up toward horizon
  60. float bottomLerp = 1.0f - pow (min (1.0f, 1.0f + interpUv), _BottomExponent);
  61. // last lerp param is horizon. all must add up to 1.0
  62. float horizonLerp = 1.0f - topLerp - bottomLerp;
  63. return (_TopColor * topLerp + _HorizonColor * horizonLerp + _BottomColor * bottomLerp) *
  64. _AmplFactor;
  65. }
  66. ENDCG
  67. }
  68. }
  69. }