| 1 | /* |
| 2 | This shader is used to render the impostor while clearing out the alpha of the eye buffer |
| 3 | The important details here are: |
| 4 | - the use of the Geometry+1 queue to make sure the impostor is drawn after all other opaque objects but before alpha |
| 5 | - the keepalpha parameter that allow unity to actually write the alpha we return at the end of the shader. |
| 6 | */ |
| 7 | |
| 8 | Shader "Oculus/Underlay Impostor" { |
| 9 | Properties{ |
| 10 | _Color("Color", Color) = (1,1,1,1) |
| 11 | _MainTex("Albedo (RGB)", 2D) = "white" {} |
| 12 | _Glossiness("Smoothness", Range(0,1)) = 0.5 |
| 13 | _Metallic("Metallic", Range(0,1)) = 0.0 |
| 14 | } |
| 15 | SubShader{ |
| 16 | Tags { "Queue" = "Geometry+1" "RenderType" = "Opaque" } |
| 17 | LOD 200 |
| 18 | |
| 19 | CGPROGRAM |
| 20 | // Physically based Standard lighting model, and enable shadows on all light types |
| 21 | #pragma surface surf Standard fullforwardshadows keepalpha |
| 22 | |
| 23 | // Use shader model 3.0 target, to get nicer looking lighting |
| 24 | #pragma target 3.0 |
| 25 | |
| 26 | sampler2D _MainTex; |
| 27 | |
| 28 | struct Input { |
| 29 | float2 uv_MainTex; |
| 30 | }; |
| 31 | |
| 32 | half _Glossiness; |
| 33 | half _Metallic; |
| 34 | fixed4 _Color; |
| 35 | |
| 36 | void surf(Input IN, inout SurfaceOutputStandard o) { |
| 37 | // Albedo comes from a texture tinted by color |
| 38 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; |
| 39 | o.Albedo = c.rgb; |
| 40 | // Metallic and smoothness come from slider variables |
| 41 | o.Metallic = _Metallic; |
| 42 | o.Smoothness = _Glossiness; |
| 43 | o.Alpha = 0.f; |
| 44 | } |
| 45 | ENDCG |
| 46 | } |
| 47 | FallBack "Diffuse" |
| 48 | } |