summaryrefslogtreecommitdiff
path: root/VRCSDK3AvatarsLegacy/Assets/_PoiyomiShaders/Shaders/Patreon/VoxelCubed/Includes/PoiFrag.cginc
blob: 7d277674ffd112c16e307d20c481d83c4acb34e4 (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
#ifndef POIFRAG
    #define POIFRAG
    
    int _CubeGradientDebug;

    float4 frag(v2f i, float facing: VFACE): SV_Target
    {
        if (_CubeGradientDebug == 1)
        {
            float4 debugCol = frac(i.localPos.z);
            if(debugCol.x <= 0.001)
            {
                debugCol.rgb = float3(1,0,0);
            }
            return debugCol;
        }
        
        #ifdef BASICS
            calculateBasics(i);
        #endif
        
        #ifdef LIGHTING
            calculateLighting(i);
        #endif
        
        #ifdef DND_LIGHTING
            calculateDNDLighting(i);
        #endif
        
        #ifdef FORWARD_BASE_PASS
            #ifdef REFRACTION
                calculateRefraction(i);
            #endif
        #endif
        
        #ifdef METAL
            calculateReflections(i.uv, i.normal, viewDirection);
        #endif
        
        #ifdef TEXTURE_BLENDING
            calculateTextureBlending(blendAlpha, mainTexture, albedo, i.uv);
        #endif
        
        clip(mainTexture.a * alphaMask - _Clip);
        
        #ifdef MATCAP
            calculateMatcap(viewDirection, i.normal, i.uv);
        #endif
        
        #ifdef LIGHTING
            #ifdef SUBSURFACE
                calculateSubsurfaceScattering(i, viewDirection);
            #endif
        #endif
        
        #ifdef RIM_LIGHTING
            calculateRimLighting(i.uv, viewDotNormal);
        #endif
        
        #ifdef PANOSPHERE
            calculatePanosphere(i.worldPos, i.uv);
        #endif
        
        #ifdef SCROLLING_LAYERS
            calculateScrollingLayers(i.uv);
        #endif
        
        #ifdef EMISSION
            calculateEmission(i.uv, i.localPos);
        #endif
        
        float4 finalColor = albedo;
        
        #ifdef RIM_LIGHTING
            applyRimColor(finalColor);
        #endif
        
        #ifdef MATCAP
            applyMatcap(finalColor);
        #endif
        
        #ifdef PANOSPHERE
            applyPanosphereColor(finalColor);
        #endif
        
        #ifdef FORWARD_BASE_PASS
            #ifdef REFRACTION
                applyRefraction(finalColor);
            #endif
        #endif
        
        
        float4 finalColorBeforeLighting = finalColor;
        
        #ifdef LIGHTING
            applyLighting(finalColor);
        #endif
        
        #ifdef DND_LIGHTING
            applyDNDLighting(finalColor);
        #endif
        
        #ifdef METAL
            applyReflections(finalColor, finalColorBeforeLighting);
        #endif
        
        #ifdef SPECULAR
            calculateSpecular(i.normal, albedo, viewDirection, i.uv);
        #endif
        
        #ifdef FORWARD_BASE_PASS
            #ifdef LIGHTING
                #ifdef SPECULAR
                    //applyLightingToSpecular();
                    applySpecular(finalColor);
                #endif
            #endif
            
            #ifdef PANOSPHERE
                applyPanosphereEmission(finalColor);
            #endif
            
            #ifdef EMISSION
                applyEmission(finalColor);
            #endif
            
            #ifdef RIM_LIGHTING
                ApplyRimEmission(finalColor);
            #endif
        #endif
        
        #ifdef LIGHTING
            #if (defined(POINT) || defined(SPOT))
                #ifdef METAL
                    applyAdditiveReflectiveLighting(finalColor);
                #endif
                #ifdef TRANSPARENT
                    finalColor.rgb *= finalColor.a;
                #endif
                
                #ifdef SPECULAR
                    applySpecular(finalColor);
                #endif
            #endif
        #endif
        
        #ifdef LIGHTING
            #ifdef SUBSURFACE
                applySubsurfaceScattering(finalColor);
            #endif
        #endif
        
        #ifdef FORWARD_BASE_PASS
            UNITY_APPLY_FOG(i.fogCoord, finalColor);
        #endif
        
        return finalColor;
    }
#endif