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
1.6 KiB

  1. //
  2. // OvrAvatar Simple Avatar Shader
  3. // Uses the Avatar Material Model on the Standard Surface Shader
  4. //
  5. Shader "OvrAvatar/AvatarPBRV2Simple"
  6. {
  7. Properties
  8. {
  9. [NoScaleOffset] _MainTex("Color (RGB)", 2D) = "white" {}
  10. [NoScaleOffset] _NormalMap("Normal Map", 2D) = "bump" {}
  11. [NoScaleOffset] _RoughnessMap("Roughness Map", 2D) = "black" {}
  12. }
  13. SubShader
  14. {
  15. Blend One Zero
  16. Cull Back
  17. CGPROGRAM
  18. #pragma surface surf Standard keepalpha fullforwardshadows
  19. #pragma target 3.0
  20. #pragma fragmentoption ARB_precision_hint_fastest
  21. #include "UnityCG.cginc"
  22. sampler2D _MainTex;
  23. sampler2D _NormalMap;
  24. sampler2D _RoughnessMap;
  25. struct Input
  26. {
  27. float2 uv_MainTex;
  28. float2 uv_NormalMap;
  29. float2 uv_RoughnessMap;
  30. float3 viewDir;
  31. float3 worldNormal; INTERNAL_DATA
  32. };
  33. void surf(Input IN, inout SurfaceOutputStandard o)
  34. {
  35. #if (UNITY_VERSION >= 20171)
  36. o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_MainTex));
  37. #else
  38. o.Normal = tex2D(_NormalMap, IN.uv_MainTex) * 2.0 - 1.0;
  39. #endif
  40. half4 roughnessTex = tex2D(_RoughnessMap, IN.uv_MainTex);
  41. o.Albedo = tex2D(_MainTex, IN.uv_MainTex);
  42. o.Smoothness = roughnessTex.a;
  43. o.Metallic = roughnessTex.r;
  44. #if !defined(UNITY_COLORSPACE_GAMMA)
  45. o.Albedo = GammaToLinearSpace(o.Albedo);
  46. #endif
  47. o.Albedo = saturate(o.Albedo);
  48. o.Alpha = 1.0;
  49. }
  50. ENDCG
  51. }
  52. Fallback "Diffuse"
  53. }