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