1[
2 {"type":"CommentPreproc","value":"#include"},
3 {"type":"Text","value":" "},
4 {"type":"CommentPreprocFile","value":"\u003cmetal_stdlib\u003e"},
5 {"type":"CommentPreproc","value":"\n"},
6 {"type":"Text","value":"\n"},
7 {"type":"Keyword","value":"using"},
8 {"type":"Text","value":" "},
9 {"type":"Keyword","value":"namespace"},
10 {"type":"Text","value":" "},
11 {"type":"Name","value":"metal"},
12 {"type":"Punctuation","value":";"},
13 {"type":"Text","value":"\n\n"},
14 {"type":"CommentSingle","value":"// Include header shared between C code and .metal files.\n"},
15 {"type":"CommentPreproc","value":"#include"},
16 {"type":"Text","value":" "},
17 {"type":"CommentPreprocFile","value":"\"AAPLShaderTypes.h\""},
18 {"type":"CommentPreproc","value":"\n"},
19 {"type":"Text","value":"\n"},
20 {"type":"CommentSingle","value":"// Include header shared between all .metal files.\n"},
21 {"type":"CommentPreproc","value":"#include"},
22 {"type":"Text","value":" "},
23 {"type":"CommentPreprocFile","value":"\"AAPLShaderCommon.h\""},
24 {"type":"CommentPreproc","value":"\n"},
25 {"type":"Text","value":"\n"},
26 {"type":"Keyword","value":"struct"},
27 {"type":"Text","value":" "},
28 {"type":"NameClass","value":"VertexOutput"},
29 {"type":"Text","value":"\n"},
30 {"type":"Punctuation","value":"{"},
31 {"type":"Text","value":"\n "},
32 {"type":"KeywordType","value":"float4"},
33 {"type":"Text","value":" "},
34 {"type":"Name","value":"position"},
35 {"type":"Text","value":" "},
36 {"type":"NameAttribute","value":"[[position]]"},
37 {"type":"Punctuation","value":";"},
38 {"type":"Text","value":"\n"},
39 {"type":"Punctuation","value":"};"},
40 {"type":"Text","value":"\n\n"},
41 {"type":"CommentSingle","value":"// A depth pre-pass is necessary in forward plus rendering to produce\n// minimum and maximum depth bounds for light culling.\n"},
42 {"type":"Keyword","value":"vertex"},
43 {"type":"Text","value":" "},
44 {"type":"Name","value":"VertexOutput"},
45 {"type":"Text","value":" "},
46 {"type":"NameFunction","value":"depth_pre_pass_vertex"},
47 {"type":"Punctuation","value":"("},
48 {"type":"Name","value":"Vertex"},
49 {"type":"Text","value":" "},
50 {"type":"Name","value":"in"},
51 {"type":"Text","value":" "},
52 {"type":"NameAttribute","value":"[[ stage_in ]]"},
53 {"type":"Punctuation","value":","},
54 {"type":"Text","value":"\n "},
55 {"type":"Keyword","value":"constant"},
56 {"type":"Text","value":" "},
57 {"type":"Name","value":"AAPLFrameData"},
58 {"type":"Text","value":" "},
59 {"type":"Operator","value":"\u0026"},
60 {"type":"Text","value":" "},
61 {"type":"Name","value":"frameData"},
62 {"type":"Text","value":" "},
63 {"type":"Punctuation","value":"[["},
64 {"type":"Text","value":" "},
65 {"type":"Name","value":"buffer"},
66 {"type":"Punctuation","value":"("},
67 {"type":"Name","value":"AAPLBufferIndexFrameData"},
68 {"type":"Punctuation","value":")"},
69 {"type":"Text","value":" "},
70 {"type":"Punctuation","value":"]])"},
71 {"type":"Text","value":"\n"},
72 {"type":"Punctuation","value":"{"},
73 {"type":"Text","value":"\n "},
74 {"type":"CommentSingle","value":"// Make the position a float4 to perform 4x4 matrix math on it.\n"},
75 {"type":"Text","value":" "},
76 {"type":"Name","value":"VertexOutput"},
77 {"type":"Text","value":" "},
78 {"type":"Name","value":"out"},
79 {"type":"Punctuation","value":";"},
80 {"type":"Text","value":"\n "},
81 {"type":"KeywordType","value":"float4"},
82 {"type":"Text","value":" "},
83 {"type":"Name","value":"position"},
84 {"type":"Text","value":" "},
85 {"type":"Operator","value":"="},
86 {"type":"Text","value":" "},
87 {"type":"KeywordType","value":"float4"},
88 {"type":"Punctuation","value":"("},
89 {"type":"Name","value":"in"},
90 {"type":"Punctuation","value":"."},
91 {"type":"Name","value":"position"},
92 {"type":"Punctuation","value":","},
93 {"type":"Text","value":" "},
94 {"type":"LiteralNumberFloat","value":"1.0"},
95 {"type":"Punctuation","value":");"},
96 {"type":"Text","value":"\n\n "},
97 {"type":"CommentSingle","value":"// Calculate the position in clip space.\n"},
98 {"type":"Text","value":" "},
99 {"type":"Name","value":"out"},
100 {"type":"Punctuation","value":"."},
101 {"type":"Name","value":"position"},
102 {"type":"Text","value":" "},
103 {"type":"Operator","value":"="},
104 {"type":"Text","value":" "},
105 {"type":"Name","value":"frameData"},
106 {"type":"Punctuation","value":"."},
107 {"type":"Name","value":"projectionMatrix"},
108 {"type":"Text","value":" "},
109 {"type":"Operator","value":"*"},
110 {"type":"Text","value":" "},
111 {"type":"Name","value":"frameData"},
112 {"type":"Punctuation","value":"."},
113 {"type":"Name","value":"modelViewMatrix"},
114 {"type":"Text","value":" "},
115 {"type":"Operator","value":"*"},
116 {"type":"Text","value":" "},
117 {"type":"Name","value":"position"},
118 {"type":"Punctuation","value":";"},
119 {"type":"Text","value":"\n\n "},
120 {"type":"Keyword","value":"return"},
121 {"type":"Text","value":" "},
122 {"type":"Name","value":"out"},
123 {"type":"Punctuation","value":";"},
124 {"type":"Text","value":"\n"},
125 {"type":"Punctuation","value":"}"},
126 {"type":"Text","value":"\n\n"},
127 {"type":"Keyword","value":"fragment"},
128 {"type":"Text","value":" "},
129 {"type":"Name","value":"ColorData"},
130 {"type":"Text","value":" "},
131 {"type":"NameFunction","value":"depth_pre_pass_fragment"},
132 {"type":"Punctuation","value":"("},
133 {"type":"Name","value":"VertexOutput"},
134 {"type":"Text","value":" "},
135 {"type":"Name","value":"in"},
136 {"type":"Text","value":" "},
137 {"type":"NameAttribute","value":"[[ stage_in ]]"},
138 {"type":"Punctuation","value":")"},
139 {"type":"Text","value":"\n"},
140 {"type":"Punctuation","value":"{"},
141 {"type":"Text","value":"\n "},
142 {"type":"CommentSingle","value":"// Populate on-tile geometry buffer data.\n"},
143 {"type":"Text","value":" "},
144 {"type":"Name","value":"ColorData"},
145 {"type":"Text","value":" "},
146 {"type":"Name","value":"f"},
147 {"type":"Punctuation","value":";"},
148 {"type":"Text","value":"\n\n "},
149 {"type":"CommentSingle","value":"// Setting color in the depth pre-pass is unnecessary, but may make debugging easier.\n"},
150 {"type":"Text","value":" "},
151 {"type":"CommentSingle","value":"// f.lighting = half4(0, 0, 0, 1);\n"},
152 {"type":"Text","value":"\n "},
153 {"type":"CommentSingle","value":"// Set the depth in clip space, which you use in `AAPLCulling` to perform per-tile light culling.\n"},
154 {"type":"Text","value":" "},
155 {"type":"Name","value":"f"},
156 {"type":"Punctuation","value":"."},
157 {"type":"Name","value":"depth"},
158 {"type":"Text","value":" "},
159 {"type":"Operator","value":"="},
160 {"type":"Text","value":" "},
161 {"type":"Name","value":"in"},
162 {"type":"Punctuation","value":"."},
163 {"type":"Name","value":"position"},
164 {"type":"Punctuation","value":"."},
165 {"type":"Name","value":"z"},
166 {"type":"Punctuation","value":";"},
167 {"type":"Text","value":"\n\n "},
168 {"type":"Keyword","value":"return"},
169 {"type":"Text","value":" "},
170 {"type":"Name","value":"f"},
171 {"type":"Punctuation","value":";"},
172 {"type":"Text","value":"\n"},
173 {"type":"Punctuation","value":"}"},
174 {"type":"Text","value":"\n"}
175]
View as plain text