Debian Codegraph @

src/scene/glsl/generated-pascal/screen_effect_library.glsl.inc

raw
1 { -*- buffer-read-only: t -*- }
2 { DON'T EDIT -- this file was automatically generated from "source/screen_effect_library.glsl" }
3 '/* The library of common functions for GLSL screen effects.' + LineEnding +
4 ' The ObjectPascal code that includes this will take care to define (or not)' + LineEnding +
5 ' symbols MULTI_SAMPLING_x, DEPTH at the beginning of this file.' + LineEnding +
6 ' Screen effect code using these functions is safe to work both with and without' + LineEnding +
7 ' multi-sampling.' + LineEnding +
8 '*/' + LineEnding +
9 '' + LineEnding +
10 '#ifdef MULTI_SAMPLING' + LineEnding +
11 ' #extension GL_ARB_texture_multisample : enable' + LineEnding +
12 ' uniform sampler2DMS screen;' + LineEnding +
13 ' #ifdef DEPTH' + LineEnding +
14 ' uniform sampler2DMS screen_depth;' + LineEnding +
15 ' #endif' + LineEnding +
16 '#else' + LineEnding +
17 ' uniform sampler2D screen;' + LineEnding +
18 ' #ifdef DEPTH' + LineEnding +
19 ' uniform sampler2D screen_depth;' + LineEnding +
20 ' #endif' + LineEnding +
21 '#endif' + LineEnding +
22 '' + LineEnding +
23 'varying vec2 screenf_01_position;' + LineEnding +
24 '' + LineEnding +
25 'uniform int screen_height;' + LineEnding +
26 'uniform int screen_width;' + LineEnding +
27 '' + LineEnding +
28 '/* Library of integer-based functions ---------------------------------------- */' + LineEnding +
29 '' + LineEnding +
30 'ivec2 screen_position()' + LineEnding +
31 '{' + LineEnding +
32 ' return ivec2(' + LineEnding +
33 ' int(screenf_01_position.s * float(screen_width)),' + LineEnding +
34 ' int(screenf_01_position.t * float(screen_height)));' + LineEnding +
35 '}' + LineEnding +
36 '' + LineEnding +
37 'int screen_x()' + LineEnding +
38 '{' + LineEnding +
39 ' return int(screenf_01_position.s * float(screen_width));' + LineEnding +
40 '}' + LineEnding +
41 '' + LineEnding +
42 'int screen_y()' + LineEnding +
43 '{' + LineEnding +
44 ' return int(screenf_01_position.t * float(screen_height));' + LineEnding +
45 '}' + LineEnding +
46 '' + LineEnding +
47 'vec4 screen_get_color(ivec2 position)' + LineEnding +
48 '{' + LineEnding +
49 '/* TODO: it would be nice to autogenerate this code */' + LineEnding +
50 '#ifdef MULTI_SAMPLING_16' + LineEnding +
51 ' return ( texelFetch(screen, position, 0) +' + LineEnding +
52 ' texelFetch(screen, position, 1) +' + LineEnding +
53 ' texelFetch(screen, position, 2) +' + LineEnding +
54 ' texelFetch(screen, position, 3) +' + LineEnding +
55 ' texelFetch(screen, position, 4) +' + LineEnding +
56 ' texelFetch(screen, position, 5) +' + LineEnding +
57 ' texelFetch(screen, position, 6) +' + LineEnding +
58 ' texelFetch(screen, position, 7) +' + LineEnding +
59 ' texelFetch(screen, position, 8) +' + LineEnding +
60 ' texelFetch(screen, position, 9) +' + LineEnding +
61 ' texelFetch(screen, position, 10) +' + LineEnding +
62 ' texelFetch(screen, position, 11) +' + LineEnding +
63 ' texelFetch(screen, position, 12) +' + LineEnding +
64 ' texelFetch(screen, position, 13) +' + LineEnding +
65 ' texelFetch(screen, position, 14) +' + LineEnding +
66 ' texelFetch(screen, position, 15) ) / 16.0;' + LineEnding +
67 '#else' + LineEnding +
68 '#ifdef MULTI_SAMPLING_8' + LineEnding +
69 ' return ( texelFetch(screen, position, 0) +' + LineEnding +
70 ' texelFetch(screen, position, 1) +' + LineEnding +
71 ' texelFetch(screen, position, 2) +' + LineEnding +
72 ' texelFetch(screen, position, 3) +' + LineEnding +
73 ' texelFetch(screen, position, 4) +' + LineEnding +
74 ' texelFetch(screen, position, 5) +' + LineEnding +
75 ' texelFetch(screen, position, 6) +' + LineEnding +
76 ' texelFetch(screen, position, 7) ) / 8.0;' + LineEnding +
77 '#else' + LineEnding +
78 '#ifdef MULTI_SAMPLING_4' + LineEnding +
79 ' return ( texelFetch(screen, position, 0) +' + LineEnding +
80 ' texelFetch(screen, position, 1) +' + LineEnding +
81 ' texelFetch(screen, position, 2) +' + LineEnding +
82 ' texelFetch(screen, position, 3) ) / 4.0;' + LineEnding +
83 '#else' + LineEnding +
84 '#ifdef MULTI_SAMPLING_2' + LineEnding +
85 ' return ( texelFetch(screen, position, 0) +' + LineEnding +
86 ' texelFetch(screen, position, 1) ) / 2.0;' + LineEnding +
87 '#else' + LineEnding +
88 ' return texture2D(screen,' + LineEnding +
89 ' /* Texture coordinates provided in screenf_01_position are already hitting' + LineEnding +
90 ' exactly the middle of the pixel.' + LineEnding +
91 ' But functions screen_position, screen_x, screen_y cut off the half pixel' + LineEnding +
92 ' size. So we restore it now by "+ vec2(0.5)". */' + LineEnding +
93 ' (vec2(position) + vec2(0.5)) / vec2(screen_width, screen_height));' + LineEnding +
94 '#endif' + LineEnding +
95 '#endif' + LineEnding +
96 '#endif' + LineEnding +
97 '#endif' + LineEnding +
98 '}' + LineEnding +
99 '' + LineEnding +
100 '#ifdef DEPTH' + LineEnding +
101 'float screen_get_depth(ivec2 position)' + LineEnding +
102 '{' + LineEnding +
103 '/* TODO: it would be nice to autogenerate this code */' + LineEnding +
104 '#ifdef MULTI_SAMPLING_16' + LineEnding +
105 ' return ( texelFetch(screen_depth, position, 0).r +' + LineEnding +
106 ' texelFetch(screen_depth, position, 1).r +' + LineEnding +
107 ' texelFetch(screen_depth, position, 2).r +' + LineEnding +
108 ' texelFetch(screen_depth, position, 3).r +' + LineEnding +
109 ' texelFetch(screen_depth, position, 4).r +' + LineEnding +
110 ' texelFetch(screen_depth, position, 5).r +' + LineEnding +
111 ' texelFetch(screen_depth, position, 6).r +' + LineEnding +
112 ' texelFetch(screen_depth, position, 7).r +' + LineEnding +
113 ' texelFetch(screen_depth, position, 8).r +' + LineEnding +
114 ' texelFetch(screen_depth, position, 9).r +' + LineEnding +
115 ' texelFetch(screen_depth, position, 10).r +' + LineEnding +
116 ' texelFetch(screen_depth, position, 11).r +' + LineEnding +
117 ' texelFetch(screen_depth, position, 12).r +' + LineEnding +
118 ' texelFetch(screen_depth, position, 13).r +' + LineEnding +
119 ' texelFetch(screen_depth, position, 14).r +' + LineEnding +
120 ' texelFetch(screen_depth, position, 15).r ) / 16.0;' + LineEnding +
121 '#else' + LineEnding +
122 '#ifdef MULTI_SAMPLING_8' + LineEnding +
123 ' return ( texelFetch(screen_depth, position, 0).r +' + LineEnding +
124 ' texelFetch(screen_depth, position, 1).r +' + LineEnding +
125 ' texelFetch(screen_depth, position, 2).r +' + LineEnding +
126 ' texelFetch(screen_depth, position, 3).r +' + LineEnding +
127 ' texelFetch(screen_depth, position, 4).r +' + LineEnding +
128 ' texelFetch(screen_depth, position, 5).r +' + LineEnding +
129 ' texelFetch(screen_depth, position, 6).r +' + LineEnding +
130 ' texelFetch(screen_depth, position, 7).r ) / 8.0;' + LineEnding +
131 '#else' + LineEnding +
132 '#ifdef MULTI_SAMPLING_4' + LineEnding +
133 ' return ( texelFetch(screen_depth, position, 0).r +' + LineEnding +
134 ' texelFetch(screen_depth, position, 1).r +' + LineEnding +
135 ' texelFetch(screen_depth, position, 2).r +' + LineEnding +
136 ' texelFetch(screen_depth, position, 3).r ) / 4.0;' + LineEnding +
137 '#else' + LineEnding +
138 '#ifdef MULTI_SAMPLING_2' + LineEnding +
139 ' return ( texelFetch(screen_depth, position, 0).r +' + LineEnding +
140 ' texelFetch(screen_depth, position, 1).r ) / 2.0;' + LineEnding +
141 '#else' + LineEnding +
142 ' return texture2D(screen_depth,' + LineEnding +
143 ' (vec2(position) + vec2(0.5)) / vec2(screen_width, screen_height)).r;' + LineEnding +
144 '#endif' + LineEnding +
145 '#endif' + LineEnding +
146 '#endif' + LineEnding +
147 '#endif' + LineEnding +
148 '}' + LineEnding +
149 '' + LineEnding +
150 'float screen_get_depth_fast(ivec2 position)' + LineEnding +
151 '{' + LineEnding +
152 '#ifdef MULTI_SAMPLING' + LineEnding +
153 ' return texelFetch(screen_depth, position, 0).r;' + LineEnding +
154 '#else' + LineEnding +
155 ' return texture2D(screen_depth,' + LineEnding +
156 ' (vec2(position) + vec2(0.5)) / vec2(screen_width, screen_height)).r;' + LineEnding +
157 '#endif' + LineEnding +
158 '}' + LineEnding +
159 '#endif' + LineEnding +
160 '' + LineEnding +
161 '/* Library of float-based functions ------------------------------------------ */' + LineEnding +
162 '' + LineEnding +
163 'vec2 screenf_position()' + LineEnding +
164 '{' + LineEnding +
165 ' return screenf_01_position *' + LineEnding +
166 ' vec2(float(screen_width), float(screen_height));' + LineEnding +
167 '}' + LineEnding +
168 '' + LineEnding +
169 'float screenf_x()' + LineEnding +
170 '{' + LineEnding +
171 ' return screenf_01_position.s * float(screen_width);' + LineEnding +
172 '}' + LineEnding +
173 '' + LineEnding +
174 'float screenf_y()' + LineEnding +
175 '{' + LineEnding +
176 ' return screenf_01_position.t * float(screen_height);' + LineEnding +
177 '}' + LineEnding +
178 '' + LineEnding +
179 'vec4 screenf_get_color(vec2 position)' + LineEnding +
180 '{' + LineEnding +
181 '/* TODO: it would be nice to autogenerate this code */' + LineEnding +
182 '#ifdef MULTI_SAMPLING_16' + LineEnding +
183 ' return ( texelFetch(screen, ivec2(position), 0) +' + LineEnding +
184 ' texelFetch(screen, ivec2(position), 1) +' + LineEnding +
185 ' texelFetch(screen, ivec2(position), 2) +' + LineEnding +
186 ' texelFetch(screen, ivec2(position), 3) +' + LineEnding +
187 ' texelFetch(screen, ivec2(position), 4) +' + LineEnding +
188 ' texelFetch(screen, ivec2(position), 5) +' + LineEnding +
189 ' texelFetch(screen, ivec2(position), 6) +' + LineEnding +
190 ' texelFetch(screen, ivec2(position), 7) +' + LineEnding +
191 ' texelFetch(screen, ivec2(position), 8) +' + LineEnding +
192 ' texelFetch(screen, ivec2(position), 9) +' + LineEnding +
193 ' texelFetch(screen, ivec2(position), 10) +' + LineEnding +
194 ' texelFetch(screen, ivec2(position), 11) +' + LineEnding +
195 ' texelFetch(screen, ivec2(position), 12) +' + LineEnding +
196 ' texelFetch(screen, ivec2(position), 13) +' + LineEnding +
197 ' texelFetch(screen, ivec2(position), 14) +' + LineEnding +
198 ' texelFetch(screen, ivec2(position), 15) ) / 16.0;' + LineEnding +
199 '#else' + LineEnding +
200 '#ifdef MULTI_SAMPLING_8' + LineEnding +
201 ' return ( texelFetch(screen, ivec2(position), 0) +' + LineEnding +
202 ' texelFetch(screen, ivec2(position), 1) +' + LineEnding +
203 ' texelFetch(screen, ivec2(position), 2) +' + LineEnding +
204 ' texelFetch(screen, ivec2(position), 3) +' + LineEnding +
205 ' texelFetch(screen, ivec2(position), 4) +' + LineEnding +
206 ' texelFetch(screen, ivec2(position), 5) +' + LineEnding +
207 ' texelFetch(screen, ivec2(position), 6) +' + LineEnding +
208 ' texelFetch(screen, ivec2(position), 7) ) / 8.0;' + LineEnding +
209 '#else' + LineEnding +
210 '#ifdef MULTI_SAMPLING_4' + LineEnding +
211 ' return ( texelFetch(screen, ivec2(position), 0) +' + LineEnding +
212 ' texelFetch(screen, ivec2(position), 1) +' + LineEnding +
213 ' texelFetch(screen, ivec2(position), 2) +' + LineEnding +
214 ' texelFetch(screen, ivec2(position), 3) ) / 4.0;' + LineEnding +
215 '#else' + LineEnding +
216 '#ifdef MULTI_SAMPLING_2' + LineEnding +
217 ' return ( texelFetch(screen, ivec2(position), 0) +' + LineEnding +
218 ' texelFetch(screen, ivec2(position), 1) ) / 2.0;' + LineEnding +
219 '#else' + LineEnding +
220 ' return texture2D(screen, position / vec2(screen_width, screen_height));' + LineEnding +
221 '#endif' + LineEnding +
222 '#endif' + LineEnding +
223 '#endif' + LineEnding +
224 '#endif' + LineEnding +
225 '}' + LineEnding +
226 '' + LineEnding +
227 'vec4 screenf_get_original_color()' + LineEnding +
228 '{' + LineEnding +
229 '#ifdef MULTI_SAMPLING' + LineEnding +
230 ' // We cannot do something much more optimal in this case, so just call full screenf_get_color' + LineEnding +
231 ' return screenf_get_color(screenf_position());' + LineEnding +
232 '#else' + LineEnding +
233 ' return texture2D(screen, screenf_01_position);' + LineEnding +
234 '#endif' + LineEnding +
235 '}' + LineEnding +
236 '' + LineEnding +
237 'vec4 screenf_01_get_color(vec2 position_01)' + LineEnding +
238 '{' + LineEnding +
239 '#ifdef MULTI_SAMPLING' + LineEnding +
240 ' // We cannot do something much more optimal in this case, so just call full screenf_get_color' + LineEnding +
241 ' return screenf_get_color(position_01 * vec2(float(screen_width), float(screen_height)));' + LineEnding +
242 '#else' + LineEnding +
243 ' return texture2D(screen, position_01);' + LineEnding +
244 '#endif' + LineEnding +
245 '}' + LineEnding +
246 '' + LineEnding +
247 '#ifdef DEPTH' + LineEnding +
248 'float screenf_get_depth(vec2 position)' + LineEnding +
249 '{' + LineEnding +
250 '/* TODO: it would be nice to autogenerate this code */' + LineEnding +
251 '#ifdef MULTI_SAMPLING_16' + LineEnding +
252 ' return ( texelFetch(screen_depth, ivec2(position), 0).r +' + LineEnding +
253 ' texelFetch(screen_depth, ivec2(position), 1).r +' + LineEnding +
254 ' texelFetch(screen_depth, ivec2(position), 2).r +' + LineEnding +
255 ' texelFetch(screen_depth, ivec2(position), 3).r +' + LineEnding +
256 ' texelFetch(screen_depth, ivec2(position), 4).r +' + LineEnding +
257 ' texelFetch(screen_depth, ivec2(position), 5).r +' + LineEnding +
258 ' texelFetch(screen_depth, ivec2(position), 6).r +' + LineEnding +
259 ' texelFetch(screen_depth, ivec2(position), 7).r +' + LineEnding +
260 ' texelFetch(screen_depth, ivec2(position), 8).r +' + LineEnding +
261 ' texelFetch(screen_depth, ivec2(position), 9).r +' + LineEnding +
262 ' texelFetch(screen_depth, ivec2(position), 10).r +' + LineEnding +
263 ' texelFetch(screen_depth, ivec2(position), 11).r +' + LineEnding +
264 ' texelFetch(screen_depth, ivec2(position), 12).r +' + LineEnding +
265 ' texelFetch(screen_depth, ivec2(position), 13).r +' + LineEnding +
266 ' texelFetch(screen_depth, ivec2(position), 14).r +' + LineEnding +
267 ' texelFetch(screen_depth, ivec2(position), 15).r ) / 16.0;' + LineEnding +
268 '#else' + LineEnding +
269 '#ifdef MULTI_SAMPLING_8' + LineEnding +
270 ' return ( texelFetch(screen_depth, ivec2(position), 0).r +' + LineEnding +
271 ' texelFetch(screen_depth, ivec2(position), 1).r +' + LineEnding +
272 ' texelFetch(screen_depth, ivec2(position), 2).r +' + LineEnding +
273 ' texelFetch(screen_depth, ivec2(position), 3).r +' + LineEnding +
274 ' texelFetch(screen_depth, ivec2(position), 4).r +' + LineEnding +
275 ' texelFetch(screen_depth, ivec2(position), 5).r +' + LineEnding +
276 ' texelFetch(screen_depth, ivec2(position), 6).r +' + LineEnding +
277 ' texelFetch(screen_depth, ivec2(position), 7).r ) / 8.0;' + LineEnding +
278 '#else' + LineEnding +
279 '#ifdef MULTI_SAMPLING_4' + LineEnding +
280 ' return ( texelFetch(screen_depth, ivec2(position), 0).r +' + LineEnding +
281 ' texelFetch(screen_depth, ivec2(position), 1).r +' + LineEnding +
282 ' texelFetch(screen_depth, ivec2(position), 2).r +' + LineEnding +
283 ' texelFetch(screen_depth, ivec2(position), 3).r ) / 4.0;' + LineEnding +
284 '#else' + LineEnding +
285 '#ifdef MULTI_SAMPLING_2' + LineEnding +
286 ' return ( texelFetch(screen_depth, ivec2(position), 0).r +' + LineEnding +
287 ' texelFetch(screen_depth, ivec2(position), 1).r ) / 2.0;' + LineEnding +
288 '#else' + LineEnding +
289 ' return texture2D(screen_depth, position / vec2(screen_width, screen_height)).r;' + LineEnding +
290 '#endif' + LineEnding +
291 '#endif' + LineEnding +
292 '#endif' + LineEnding +
293 '#endif' + LineEnding +
294 '}' + LineEnding +
295 '' + LineEnding +
296 'float screenf_01_get_depth(vec2 position_01)' + LineEnding +
297 '{' + LineEnding +
298 '#ifdef MULTI_SAMPLING' + LineEnding +
299 ' // We cannot do something much more optimal in this case, so just call full screenf_get_depth' + LineEnding +
300 ' return screenf_get_depth(position_01 * vec2(float(screen_width), float(screen_height)));' + LineEnding +
301 '#else' + LineEnding +
302 ' return texture2D(screen_depth, position_01).r;' + LineEnding +
303 '#endif' + LineEnding +
304 '}' + LineEnding +
305 '' + LineEnding +
306 'float screenf_get_original_depth()' + LineEnding +
307 '{' + LineEnding +
308 '#ifdef MULTI_SAMPLING' + LineEnding +
309 ' // We cannot do something much more optimal in this case, so just call full screenf_get_depth' + LineEnding +
310 ' return screenf_get_depth(screenf_position());' + LineEnding +
311 '#else' + LineEnding +
312 ' return texture2D(screen_depth, screenf_01_position).r;' + LineEnding +
313 '#endif' + LineEnding +
314 '}' + LineEnding +
315 '' + LineEnding +
316 'float screenf_get_depth_fast(vec2 position)' + LineEnding +
317 '{' + LineEnding +
318 '#ifdef MULTI_SAMPLING' + LineEnding +
319 ' return texelFetch(screen_depth, ivec2(position), 0).r;' + LineEnding +
320 '#else' + LineEnding +
321 ' return texture2D(screen_depth, position / vec2(screen_width, screen_height)).r;' + LineEnding +
322 '#endif' + LineEnding +
323 '}' + LineEnding +
324 '#endif' + LineEnding +
325 ''