generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUVTileDiscard.orlsource
162 lines (146 loc) · 7.25 KB
/
UVTileDiscard.orlsource
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
// Original Inventory System code by s-ilent (https://gitlab.com/s-ilent/SCSS)
// Modified by lackofbindings for use with ORELs.
// Original license is as follows:
// MIT License
//
// Copyright (c) 2018 s-ilent
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
%Properties()
{
UI_UVTDiscardHeader("# UV Tile Discard", Int) = 0
[Toggle(UV_DISCARD)]_UVDiscardOn("Enable UV Discard", Int) = 0
[Enum(UV1, 0, UV2, 1, UV3, 2, UV4, 3)]_InventoryUVSet("UV Set %ShowIf(_UVDiscardOn)", Int) = 2
[IntRange]_InventoryCols("Tiles X %ShowIf(_UVDiscardOn)", Range(1,17)) = 17
[IntRange]_InventoryRows("Tiles Y %ShowIf(_UVDiscardOn)", Range(1,16)) = 1
UI_UVTDiscardNote("> Counting starts at the bottom left and goes across each row up to the top right. \nRemember to count zero! %ShowIf(_UVDiscardOn)", Int) = 0
[ToggleUI]_InventoryItem00Animated("Toggle Tile 0 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem01Animated("Toggle Tile 1 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem02Animated("Toggle Tile 2 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem03Animated("Toggle Tile 3 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem04Animated("Toggle Tile 4 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem05Animated("Toggle Tile 5 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem06Animated("Toggle Tile 6 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem07Animated("Toggle Tile 7 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem08Animated("Toggle Tile 8 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem09Animated("Toggle Tile 9 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem10Animated("Toggle Tile 10 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem11Animated("Toggle Tile 11 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem12Animated("Toggle Tile 12 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem13Animated("Toggle Tile 13 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem14Animated("Toggle Tile 14 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem15Animated("Toggle Tile 15 %ShowIf(_UVDiscardOn)", Int) = 1
[ToggleUI]_InventoryItem16Animated("Toggle Tile 16 %ShowIf(_UVDiscardOn)", Int) = 1
}
%ShaderFeatures()
{
#pragma shader_feature_local UV_DISCARD
}
%Variables()
{
int _InventoryUVSet;
int _InventoryRows;
int _InventoryCols;
half _InventoryItem00Animated;
half _InventoryItem01Animated;
half _InventoryItem02Animated;
half _InventoryItem03Animated;
half _InventoryItem04Animated;
half _InventoryItem05Animated;
half _InventoryItem06Animated;
half _InventoryItem07Animated;
half _InventoryItem08Animated;
half _InventoryItem09Animated;
half _InventoryItem10Animated;
half _InventoryItem11Animated;
half _InventoryItem12Animated;
half _InventoryItem13Animated;
half _InventoryItem14Animated;
half _InventoryItem15Animated;
half _InventoryItem16Animated;
}
%Vertex("UVTDiscardVert", -1)
{
inline float getInventoryMask(float2 uv)
{
// Initialize mask, This will cut things out
float inventoryMask = 0.0;
// Which UV section are we in?
uv = floor(uv);
int itemID = (_InventoryCols * uv.y) + uv.x;
// Check against limits
inventoryMask += (uv.y >= _InventoryRows);
inventoryMask += (uv.x >= _InventoryCols);
// Check against toggles
inventoryMask += (itemID <= 0) * _InventoryItem00Animated;
inventoryMask += (itemID == 1) * _InventoryItem01Animated;
inventoryMask += (itemID == 2) * _InventoryItem02Animated;
inventoryMask += (itemID == 3) * _InventoryItem03Animated;
inventoryMask += (itemID == 4) * _InventoryItem04Animated;
inventoryMask += (itemID == 5) * _InventoryItem05Animated;
inventoryMask += (itemID == 6) * _InventoryItem06Animated;
inventoryMask += (itemID == 7) * _InventoryItem07Animated;
inventoryMask += (itemID == 8) * _InventoryItem08Animated;
inventoryMask += (itemID == 9) * _InventoryItem09Animated;
inventoryMask += (itemID == 10) * _InventoryItem10Animated;
inventoryMask += (itemID == 11) * _InventoryItem11Animated;
inventoryMask += (itemID == 12) * _InventoryItem12Animated;
inventoryMask += (itemID == 13) * _InventoryItem13Animated;
inventoryMask += (itemID == 14) * _InventoryItem14Animated;
inventoryMask += (itemID == 15) * _InventoryItem15Animated;
inventoryMask += (itemID == 16) * _InventoryItem16Animated;
// Higher than 17? Enabled by default
inventoryMask += (itemID >= 17);
return round(inventoryMask);
}
void UVTDiscardVert(inout VertexData v, inout FragmentData o)
{
#ifdef UV_DISCARD
// Choose UV channel
half2 uv = v.uv0;
switch (_InventoryUVSet)
{
case 0: uv = v.uv0; break;
case 1: uv = v.uv1; break;
case 2: uv = v.uv2; break;
case 3: uv = v.uv3; break;
}
// Determine if this vertex should be discarded
float inventoryMask = getInventoryMask(uv);
// Apply the inventory mask.
// Set the output variables based on the mask to completely remove it.
// - Set the clip-space position to one that won't be rendered
// - Set the vertex alpha to zero
// - Disable outlines
// Original from SCSS
// o.pos.z = inventoryMask ? o.pos.z : 1e+9;
// o.posWorld = inventoryMask ? o.posWorld : 0;
// o.vertex = inventoryMask ? o.vertex : 1e+9;
// o.color.a = inventoryMask ? o.color.a : -1;
// o.extraData.xz = inventoryMask ? o.extraData.xz : 0;
// Ported to ORL
// o.pos.z = inventoryMask ? o.pos.z : asfloat(-1);
// o.worldPos = inventoryMask ? o.worldPos : 0;
// v.vertex = inventoryMask ? v.vertex : asfloat(-1);
// v.color.a = inventoryMask ? v.color.a : -1;
// From ORL UVTDiscard
v.vertex = inventoryMask ? v.vertex : asfloat(-1);
#endif
}
}