summaryrefslogtreecommitdiff
path: root/VRCSDK3AvatarsLegacy/Assets/Avatars/Auri/materials/OptimizedShaders/body/Includes/CGI_PoiOutlineFrag.cginc
blob: 62e63c9191dd034ee4d2915618f3a5115714bbfd (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
float _OutlineRimLightBlend;
float _OutlineLit;
float _OutlineTintMix;
float2 _MainTexPan;
float _MainTextureUV;

float4 frag(v2f i, uint facing: SV_IsFrontFace): COLOR
{
    float4 finalColor = 1;
    
    if (float(0))
    {
        UNITY_SETUP_INSTANCE_ID(i);
        
        float3 finalEmission = 0;
        float4 albedo = 1;
        
        poiMesh.uv[0] = i.uv0.xy;
        poiMesh.uv[1] = i.uv0.zw;
        poiMesh.uv[2] = i.uv1.xy;
        poiMesh.uv[3] = i.uv1.zw;
        
        calculateAttenuation(i);
        InitializeMeshData(i, facing);
        initializeCamera(i);
        calculateTangentData();
        
        float4 mainTexture = UNITY_SAMPLE_TEX2D(_MainTex, TRANSFORM_TEX(poiMesh.uv[float(0)], _MainTex) + _Time.x * float4(0,0,0,0));
        half3 detailMask = 1;
        calculateNormals(detailMask);
        
        #ifdef POI_DATA
            calculateLightingData(i);
        #endif
        #ifdef POI_LIGHTING
            calculateBasePassLightMaps();
        #endif
        
        float3 uselessData0;
        float3 uselessData1;
        initTextureData(albedo, mainTexture, uselessData0, uselessData1, detailMask);
        
        
        fixed4 col = mainTexture;
        float alphaMultiplier = smoothstep(float4(0,0,0,0).x, float4(0,0,0,0).y, distance(getCameraPosition(), i.worldPos));
        float OutlineMask = tex2D(_OutlineMask, TRANSFORM_TEX(poiMesh.uv[float(0)], _OutlineMask) + _Time.x * float4(0,0,0,0)).r;
        clip(OutlineMask * float(0) - 0.001);
        
        col = col * 0.00000000001 + tex2D(_OutlineTexture, TRANSFORM_TEX(poiMesh.uv[float(0)], _OutlineTexture) + _Time.x * float4(0,0,0,0) );
        col.a *= albedo.a;
        col.a *= alphaMultiplier;
        
        #ifdef POI_RANDOM
            col.a *= i.angleAlpha;
        #endif
        
        poiCam.screenUV = calcScreenUVs(i.grabPos);
        col.a *= float4(1,1,1,1).a;
        
        
        if(float(0) == 1)
        {
            applyDithering(col);
        }
        
        clip(col.a - float(0.5));
        
        #ifdef POI_MIRROR
            applyMirrorRenderFrag();
        #endif
        
        
        if(float(0) == 1)
        {
            #ifdef POI_MIRROR
                applyMirrorTexture(mainTexture);
            #endif
            col.rgb = mainTexture.rgb;
        }
        else if(float(0) == 2)
        {
            col.rgb = lerp(col.rgb, poiLight.color, float(0));
        }
        col.rgb *= float4(1,1,1,1).rgb;
        
        if(float(0) == 1)
        {
            col.rgb = lerp(col.rgb, mainTexture.rgb, float(0));
        }
        
        finalColor = col;
        
        #ifdef POI_LIGHTING
            
            if(float(1))
            {
                finalColor.rgb *= calculateFinalLighting(finalColor.rgb, finalColor);
            }
        #endif
        finalColor.rgb += (col.rgb * float(0));
    }
    else
    {
        clip(-1);
    }
    return finalColor;
}