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.

80 lines
2.4 KiB

  1. /************************************************************************************
  2. Copyright : Copyright 2017 Oculus VR, LLC. All Rights reserved.
  3. Licensed under the Oculus VR Rift SDK License Version 3.4.1 (the "License");
  4. you may not use the Oculus VR Rift SDK except in compliance with the License,
  5. which is provided at the time of installation or download, or which
  6. otherwise accompanies this software in either electronic or hard copy form.
  7. You may obtain a copy of the License at
  8. https://developer.oculus.com/licenses/sdk-3.4.1
  9. Unless required by applicable law or agreed to in writing, the Oculus VR SDK
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ************************************************************************************/
  15. Shader "Custom/TriPlanarWorld" {
  16. Properties {
  17. _Color("Color", Color) = (1,1,1,1)
  18. _MainTex ("Albedo (RGB)", 2D) = "white" {}
  19. _Glossiness ("Smoothness", Range(0,1)) = 0.5
  20. _Metallic ("Metallic", Range(0,1)) = 0.0
  21. }
  22. SubShader {
  23. Tags { "RenderType"="Opaque" }
  24. LOD 200
  25. CGPROGRAM
  26. // Physically based Standard lighting model, and enable shadows on all light types
  27. #pragma surface surf Standard fullforwardshadows vertex:vert
  28. // Use shader model 3.0 target, to get nicer looking lighting
  29. #pragma target 3.0
  30. sampler2D _MainTex;
  31. struct Input {
  32. float2 uv_MainTex;
  33. float3 worldPos;
  34. float3 worldNormal;
  35. float4 vertColor : COLOR;
  36. };
  37. half _Glossiness;
  38. half _Metallic;
  39. fixed4 _Color;
  40. void vert(inout appdata_full v, out Input o) {
  41. UNITY_INITIALIZE_OUTPUT(Input, o);
  42. o.vertColor = v.color;
  43. o.vertColor = float4(1, 0, 1, 1);
  44. }
  45. void surf (Input IN, inout SurfaceOutputStandard o) {
  46. float3 absNormal = abs(IN.worldNormal);
  47. // exponentially scale the absNormal so that it strongly biases to a single cardinal axis.
  48. absNormal = normalize(pow(absNormal, 5));
  49. fixed4 x = tex2D(_MainTex, IN.worldPos.yz);
  50. fixed4 y = tex2D(_MainTex, IN.worldPos.xz);
  51. fixed4 z = tex2D(_MainTex, IN.worldPos.xy);
  52. fixed4 c = x * absNormal.x + y * absNormal.y + z * absNormal.z;
  53. c *= _Color * IN.vertColor;
  54. o.Albedo = c.rgb;
  55. o.Metallic = _Metallic;
  56. o.Smoothness = _Glossiness;
  57. o.Alpha = c.a;
  58. //o.Albedo = abs(IN.worldNormal);
  59. }
  60. ENDCG
  61. }
  62. FallBack "Diffuse"
  63. }