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.

86 lines
2.2 KiB

  1. Shader "Custom/DoubleSided" {
  2. Properties{
  3. _Color("Color", Color) = (1,1,1,1)
  4. _MainTex("Albedo (RGB)", 2D) = "white" {}
  5. _Glossiness("Smoothness", Range(0,1)) = 0.5
  6. _Metallic("Metallic", Range(0,1)) = 0.0
  7. _BumpMap("NormalMap", 2D) = "Bump" {}
  8. _BumpScale("Normal Power", Float) = 1.0
  9. _NormalDefault("Normal Default", Color) = (128, 128, 255)
  10. }
  11. SubShader{
  12. Tags { "RenderType" = "Opaque" }
  13. LOD 200
  14. // Render back faces first
  15. Cull Front
  16. CGPROGRAM
  17. // Physically based Standard lighting model, and enable shadows on all light types
  18. #pragma surface surf Standard fullforwardshadows
  19. // Use shader model 3.0 target, to get nicer looking lighting
  20. #pragma target 3.0
  21. sampler2D _MainTex;
  22. sampler2D _BumpMap;
  23. struct Input {
  24. float2 uv_MainTex;
  25. };
  26. half _Glossiness;
  27. half _BumpScale;
  28. half _Metallic;
  29. fixed4 _Color;
  30. half3 _NormalDefault;
  31. void surf(Input IN, inout SurfaceOutputStandard o) {
  32. // Albedo comes from a texture tinted by color
  33. fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  34. o.Albedo = c.rgb;
  35. // Metallic and smoothness come from slider variables
  36. o.Metallic = _Metallic;
  37. o.Smoothness = _Glossiness;
  38. o.Normal = -UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
  39. //o.Normal = -_NormalDefault;
  40. o.Alpha = c.a;
  41. }
  42. ENDCG
  43. // Now render front faces
  44. Cull Back
  45. CGPROGRAM
  46. // Physically based Standard lighting model, and enable shadows on all light types
  47. #pragma surface surf Standard fullforwardshadows
  48. // Use shader model 3.0 target, to get nicer looking lighting
  49. #pragma target 3.0
  50. sampler2D _MainTex;
  51. sampler2D _BumpMap;
  52. struct Input {
  53. float2 uv_MainTex;
  54. };
  55. half _Glossiness;
  56. half _BumpScale;
  57. half _Metallic;
  58. fixed4 _Color;
  59. half3 _NormalDefault;
  60. void surf(Input IN, inout SurfaceOutputStandard o) {
  61. // Albedo comes from a texture tinted by color
  62. fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  63. o.Albedo = c.rgb;
  64. // Metallic and smoothness come from slider variables
  65. o.Metallic = _Metallic;
  66. o.Smoothness = _Glossiness;
  67. o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
  68. //o.Normal = _NormalDefault;
  69. o.Alpha = c.a;
  70. }
  71. ENDCG
  72. }
  73. FallBack "Diffuse"
  74. }