summaryrefslogtreecommitdiff
path: root/VRCSDK3AvatarsLegacy/Assets/Avatars/Auri/materials/OptimizedShaders/body/Includes/CGI_Poicludes.cginc
blob: 0cf468e1d403549ed6327ad9223bb3aafd2ca12b (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#ifndef POICLUDES
#define POICLUDES

UNITY_DECLARE_TEX2D(_MainTex); float4 _MainTex_ST; float4 _MainTex_TexelSize;
float _SpecularLMOcclusion;
float _SpecLMOcclusionAdjust;
sampler2D _PoiGrab;
sampler2D _CameraDepthTexture;
float _Cutoff;
float _AlphaMod;

//Structs
struct appdata
{
    float4 vertex: POSITION;
    float3 normal: NORMAL;
    float4 tangent: TANGENT;
    float4 color: COLOR;
    float2 uv0: TEXCOORD0;
    float2 uv1: TEXCOORD1;
    float2 uv2: TEXCOORD2;
    float2 uv3: TEXCOORD3;
    uint vertexId: SV_VertexID;
    UNITY_VERTEX_INPUT_INSTANCE_ID
};

#ifdef OUTLINE
    float _LineWidth;
    float _OutlineEmission;
    float4 _LineColor;
    sampler2D _OutlineTexture; float4 _OutlineTexture_ST; float2 _OutlineTexturePan; float _OutlineTextureUV;
    float4 _OutlineFadeDistance;
    float4 _OutlineGlobalPan;
#endif

struct PoiLighting
{
    half3 direction;
    half3 color;
    fixed attenuation;
    #ifdef FORWARD_ADD_PASS
        fixed additiveShadow;
    #endif
    half3 directLighting;
    half3 indirectLighting;
    half lightMap;
    float3 rampedLightMap;
    half3 finalLighting;
    half3 halfDir;
    half nDotL;
    half nDotH;
    half lDotv;
    half lDotH;
    half nDotV;
    half N0DotV;
    half diffuseTerm;
    half occlusion;
    // World normal dot half direction
    #ifdef POI_VAR_DOTNH
        half dotNH;
    #endif
    
    // Light direction dot half direction
    #ifdef POI_VAR_DOTLH
        half dotLH;
    #endif
    
    #ifdef VERTEXLIGHT_ON
        // Non Important Lights
        float4 vDotNL;
        float3 vColor[4];
        float4 vCorrectedDotNL;
        float4 vAttenuation;
        float4 vAttenuationDotNL;
        float3 vPosition[4];
        float3 vDirection[4];
        float3 vFinalLighting;
        float3 vHalfDir[4];
        half4 vDotNH;
        half4 vDotLH;
        
        
    #endif
};

struct PoiCamera
{
    half3 viewDir;
    half3 tangentViewDir;
    half3 decalTangentViewDir;
    half3 forwardDir;
    half3 worldPos;
    float viewDotNormal;
    float distanceToModel;
    float distanceToVert;
    float3 reflectionDir;
    float3 vertexReflectionDir;
    float2 screenUV;
    float4 clipPos;
    #if defined(GRAIN)
        float4 worldDirection;
    #endif
    float4 grabPos;
};

struct PoiMesh
{
    float3 normals[2];
    float4 tangent;
    float3 binormal;
    float3 localPos;
    float3 worldPos;
    float3 modelPos;
    float3 tangentSpaceNormal;
    float2 uv[5];
    float4 vertexColor;
    fixed3 barycentricCoordinates;
    #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
        float4 lightmapUV;
    #endif
    float isFrontFace;
    #ifdef FUR
        float furAlpha;
    #endif
};

struct PoiTangentData
{
    float3x3 tangentTransform;
    float3x3 tangentToWorld;
};

struct FragmentCommonData
{
    half3 diffColor, specColor;
    // Note: smoothness & oneMinusReflectivity for optimization purposes, mostly for DX9 SM2.0 level.
    // Most of the math is being done on these (1-x) values, and that saves a few precious ALU slots.
    half oneMinusReflectivity, smoothness;
    float3 normalWorld;
    float3 eyeVec;
    half alpha;
    float3 posWorld;
    
    #if UNITY_STANDARD_SIMPLE
        half3 reflUVW;
    #endif
    
    #if UNITY_STANDARD_SIMPLE
        half3 tangentSpaceNormal;
    #endif
};

struct Debug
{
    float debug1;
    float2 debug2;
    float3 debug3;
    float4 debug4;
};

struct PoiMods
{
    float4 audioLink;
    fixed audioLinkTextureExists;
    float4 globalMasks;
    float audioLinkVersion;
    float4 audioLinkTexture;
};

static Debug debug;
static PoiLighting poiLight;
static PoiCamera poiCam;
static PoiMesh poiMesh;
static PoiMods poiMods;
static UnityGI gi;
static FragmentCommonData s;
static PoiTangentData poiTData;

#endif