summaryrefslogtreecommitdiff
path: root/VRCSDK3AvatarsLegacy/Assets/_PoiyomiShaders/Shaders/Includes/CGI_Poicludes.cginc
blob: f6128639e1ba228f3e0a8d35bc9975bed1edee20 (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
#ifndef POICLUDES
    #define POICLUDES
    
    UNITY_DECLARE_TEX2D(_MainTex); float4 _MainTex_ST; float4 _MainTex_TexelSize;
    sampler2D _PoiGrab;
    float _Clip;
    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;
        UNITY_VERTEX_INPUT_INSTANCE_ID
    };
    
    
    
    #ifdef OUTLINE
        float _LineWidth;
        float _OutlineEmission;
        float4 _LineColor;
        sampler2D _OutlineTexture; float4 _OutlineTexture_ST;
        float4 _OutlineTexturePan;
        float4 _OutlineFadeDistance;
        float4 _OutlineGlobalPan;
    #endif
    
    struct PoiLighting
    {
        half3 direction;
        half3 color;
        fixed attenuation;
        #if defined(POINT) || defined(SPOT)
            fixed additiveShadow;
        #endif
        half3 directLighting;
        half3 indirectLighting;
        half lightMap;
        half3 rampedLightMap;
        half3 finalLighting;
        half3 halfDir;
        half nDotL;
        half nDotH;
        half lDotv;
        half lDotH;
        half nDotV;
        half N0DotV;
        half diffuseTerm;
        
        // 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];
            
            #ifdef POI_VAR_DOTLH
                half4 vDotLH;
            #endif
            
            #ifdef POI_VAR_DOTNH
                half4 vDotNH;
            #endif
            
        #endif
    };
    
    struct PoiCamera
    {
        half3 viewDir;
        half3 tangentViewDir;
        half3 forwardDir;
        half3 worldPos;
        float viewDotNormal;
        float distanceToModel;
        float distanceToVert;
        float3 reflectionDir;
        float3 vertexReflectionDir;
        float2 screenUV;
        float4 clipPos;
        #if defined(GRAIN)
            float4 screenPos;
        #endif
        float4 grabPos;
    };
    
    struct PoiMesh
    {
        float3 normals[2];
        float3 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;
    };
    
    static Debug debug;
    static PoiLighting poiLight;
    static PoiCamera poiCam;
    static PoiMesh poiMesh;
    static UnityGI gi;
    static FragmentCommonData s;
    static PoiTangentData poiTData;
    float4 finalColor;
    float3 finalEmission;
    float4 mainTexture;
    float4 albedo;
    
#endif