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.

63 lines
2.1 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. // does baked lighting + one directional light + reflection probe
  9. Shader "Oculus Sample/Train Props Shader" {
  10. Properties {
  11. [PowerSlider(6.0)] _Shininess("Shininess", Range(0.02, 1)) = 0.03
  12. _MainTex("Base (RGB) Gloss (A)", 2D) = "white" {}
  13. _Color("Color", Color) = (0.5, 0.5, 0.5, 0.5)
  14. _BumpMap("Normal map", 2D) = "bump" {}
  15. _ReflectionMap("Reflection map", CUBE) = "" {}
  16. [MaterialToggle] _ReflectionMapEnabled("Enable Reflection map", Float) = 0
  17. }
  18. SubShader {
  19. Tags{"RenderType" = "Opaque"}
  20. LOD 300
  21. CGPROGRAM
  22. #include "UnityCG.cginc"
  23. // no deferred. support lightmaps and one light. use half vector instead of
  24. // view vector (less accurate but faster)
  25. #pragma surface surf BlinnPhong exclude_path:prepass noforwardadd halfasview
  26. sampler2D _MainTex;
  27. struct Input {
  28. float2 uv_MainTex;
  29. float3 worldRefl;
  30. float3 viewDir;
  31. INTERNAL_DATA
  32. };
  33. half _Shininess;
  34. fixed4 _Color;
  35. sampler2D _BumpMap;
  36. samplerCUBE _ReflectionMap;
  37. fixed _ReflectionMapEnabled;
  38. void surf(Input IN, inout SurfaceOutput o) {
  39. fixed4 albedo = tex2D(_MainTex, IN.uv_MainTex)*_Color;
  40. fixed gloss = albedo.a*_Shininess;
  41. fixed4 fakeReflec = texCUBE(_ReflectionMap, WorldReflectionVector(IN, o.Normal));
  42. o.Albedo = albedo.rgb;
  43. o.Gloss = gloss;
  44. o.Alpha = gloss;
  45. o.Specular = gloss;
  46. o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
  47. o.Emission = _ReflectionMapEnabled * gloss * fakeReflec.rgb;
  48. }
  49. ENDCG
  50. }
  51. FallBack "Mobile/VertexLit"
  52. }