BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / Avatar / Resources / Materials / AvatarPBRV2Simple.shader

AvatarPBRV2Simple.shader

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