checkin
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / scene_standard_alphatest.h
1 #ifndef SHADER_scene_standard_alphatest_H
2 #define SHADER_scene_standard_alphatest_H
3 static void shader_scene_standard_alphatest_link(void);
4 static void shader_scene_standard_alphatest_register(void);
5 static struct vg_shader _shader_scene_standard_alphatest = {
6 .name = "scene_standard_alphatest",
7 .link = shader_scene_standard_alphatest_link,
8 .vs =
9 {
10 .orig_file = "shaders/scene.vs",
11 .static_src =
12 "layout (location=0) in vec3 a_co;\n"
13 "layout (location=1) in vec4 a_norm;\n"
14 "layout (location=2) in vec2 a_uv;\n"
15 "layout (location=3) in ivec4 a_lights;\n"
16 "\n"
17 "#line 1 1 \n"
18 "const float k_motion_lerp_amount = 0.01;\n"
19 "\n"
20 "#line 2 0 \n"
21 "\n"
22 "out vec3 aMotionVec0;\n"
23 "out vec3 aMotionVec1;\n"
24 "\n"
25 "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
26 "{\n"
27 " // This magically solves some artifacting errors!\n"
28 " //\n"
29 " vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
30 "\n"
31 " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
32 " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n"
33 "}\n"
34 "\n"
35 "#line 7 0 \n"
36 "\n"
37 "uniform mat4x3 uMdl;\n"
38 "uniform mat4 uPv;\n"
39 "uniform mat4 uPvmPrev;\n"
40 "\n"
41 "out vec2 aUv;\n"
42 "out vec4 aNorm;\n"
43 "out vec3 aCo;\n"
44 "out vec3 aWorldCo;\n"
45 "\n"
46 "flat out ivec4 light_indices;\n"
47 "\n"
48 "void main()\n"
49 "{\n"
50 " vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n"
51 " vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n"
52 " vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n"
53 "\n"
54 " vs_motion_out( vproj0, vproj1 );\n"
55 "\n"
56 " gl_Position = vproj0;\n"
57 "\n"
58 " aUv = a_uv;\n"
59 " aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n"
60 " aCo = a_co;\n"
61 " aWorldCo = world_pos0;\n"
62 "\n"
63 " light_indices = a_lights;\n"
64 "}\n"
65 ""},
66 .fs =
67 {
68 .orig_file = "shaders/scene_standard_alphatest.fs",
69 .static_src =
70 "uniform sampler2D uTexGarbage;\n"
71 "uniform sampler2D uTexMain;\n"
72 "uniform vec3 uBoard0;\n"
73 "uniform vec3 uBoard1;\n"
74 "uniform vec3 uCamera;\n"
75 "uniform vec4 uPlane;\n"
76 "\n"
77 "#line 1 1 \n"
78 "// :D\n"
79 "\n"
80 "in vec2 aUv;\n"
81 "in vec4 aNorm;\n"
82 "in vec3 aCo;\n"
83 "in vec3 aWorldCo;\n"
84 "flat in ivec4 light_indices;\n"
85 "\n"
86 "uniform samplerBuffer uLightsArray;\n"
87 "\n"
88 "#line 1 1 \n"
89 "layout (location = 0) out vec4 oColour;\n"
90 "\n"
91 "layout (std140) uniform ub_world_lighting\n"
92 "{\n"
93 " vec4 g_light_colours[3];\n"
94 " vec4 g_light_directions[3];\n"
95 " vec4 g_ambient_colour;\n"
96 "\n"
97 " vec4 g_water_plane;\n"
98 " vec4 g_depth_bounds;\n"
99 " float g_water_fog;\n"
100 " float g_time;\n"
101 " int g_light_count;\n"
102 " int g_light_preview;\n"
103 " int g_shadow_samples;\n"
104 "\n"
105 " int g_debug_indices;\n"
106 " int g_debug_complexity;\n"
107 "\n"
108 " // g_time ?\n"
109 "\n"
110 " //vec4 g_point_light_positions[32];\n"
111 " //vec4 g_point_light_colours[32];\n"
112 "};\n"
113 "\n"
114 "uniform sampler2D g_world_depth;\n"
115 "\n"
116 "float world_depth_sample( vec3 pos )\n"
117 "{\n"
118 " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
119 " return texture( g_world_depth, depth_coord ).r;\n"
120 "}\n"
121 "\n"
122 "float world_water_depth( vec3 pos )\n"
123 "{\n"
124 " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
125 " float ref_depth = g_water_plane.y*g_water_plane.w;\n"
126 " return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
127 "}\n"
128 "\n"
129 "float shadow_sample( vec3 vdir )\n"
130 "{\n"
131 " vec3 sample_pos = aWorldCo + vdir;\n"
132 " float height_sample = world_depth_sample( sample_pos );\n"
133 "\n"
134 " float fdelta = height_sample - sample_pos.y;\n"
135 " return clamp( fdelta, 0.1, 0.2 )-0.1;\n"
136 "}\n"
137 "\n"
138 "vec3 apply_fog( vec3 vfrag, float fdist )\n"
139 "{\n"
140 " float dist = pow(fdist*0.0008,1.2);\n"
141 " return mix( vfrag, vec3(0.55,0.76,1.0), min( 1.0, dist ) );\n"
142 "}\n"
143 "\n"
144 "\n"
145 "// New lighting model\n"
146 "\n"
147 "vec3 newlight_compute_ambient()\n"
148 "{\n"
149 " return g_ambient_colour.rgb;\n"
150 "}\n"
151 "\n"
152 "float newlight_compute_sun_shadow( vec3 dir )\n"
153 "{\n"
154 " if( g_shadow_samples == 0 )\n"
155 " {\n"
156 " return 1.0;\n"
157 " }\n"
158 "\n"
159 " float fspread = g_light_colours[0].w;\n"
160 " vec3 vdir = dir;\n"
161 " float flength = g_light_directions[0].w;\n"
162 "\n"
163 " float famt = 0.0;\n"
164 " famt+=shadow_sample((vdir+vec3(-0.563, 0.550, 0.307)*fspread)*flength*0.1);\n"
165 " famt+=shadow_sample((vdir+vec3( 0.808, 0.686, 0.346)*fspread)*flength*0.2);\n"
166 " famt+=shadow_sample((vdir+vec3( 0.787, 0.074,-0.065)*fspread)*flength*0.3);\n"
167 " famt+=shadow_sample((vdir+vec3(-0.593, 0.071,-0.425)*fspread)*flength*0.4);\n"
168 " famt+=shadow_sample((vdir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n"
169 " famt+=shadow_sample((vdir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n"
170 " famt+=shadow_sample((vdir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n"
171 " famt+=shadow_sample((vdir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n"
172 "\n"
173 " return 1.0 - famt;\n"
174 "}\n"
175 "\n"
176 "vec3 newlight_compute_world_diffuse( vec3 wnormal )\n"
177 "{\n"
178 " vec3 vtotal = g_ambient_colour.rgb;\n"
179 "\n"
180 " for( int i=0; i<g_light_count; i++ )\n"
181 " {\n"
182 " vec3 vcolour = g_light_colours[i].rgb;\n"
183 " vec3 vdir = g_light_directions[i].xyz;\n"
184 "\n"
185 " float flight = max(dot( vdir, wnormal )*0.75+0.25,0.0);\n"
186 " vtotal += vcolour*flight;\n"
187 " }\n"
188 "\n"
189 " return vtotal;\n"
190 "}\n"
191 "\n"
192 "vec3 newlight_compute_sun_spec( vec3 wnormal, vec3 halfview, float fintensity )\n"
193 "{\n"
194 " vec3 vcolour = g_light_colours[0].rgb;\n"
195 " vec3 vdir = g_light_directions[0].xyz;\n"
196 "\n"
197 " vec3 specdir = reflect( -vdir, wnormal );\n"
198 " float spec = pow(max(dot( halfview, specdir ), 0.0), 10.0);\n"
199 " return vcolour*spec*fintensity;\n"
200 "}\n"
201 "\n"
202 "float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n"
203 "{\n"
204 " vec3 specdir = reflect( -dir, wnormal );\n"
205 " return pow(max(dot( halfview, specdir ), 0.0), exponent);\n"
206 "}\n"
207 "\n"
208 "vec3 newlight_compute_quadratic( vec3 wnormal, vec3 halfview, \n"
209 " vec3 light_colour, vec3 light_pos )\n"
210 "{\n"
211 " vec3 light_delta = (light_pos-aWorldCo) * 10.0;\n"
212 "\n"
213 " float quadratic = dot(light_delta,light_delta);\n"
214 " float attenuation = 1.0f/( 1.0f + quadratic );\n"
215 " attenuation *= max( 0.0, dot( normalize(light_delta), wnormal ) );\n"
216 "\n"
217 " return light_colour*attenuation;\n"
218 "}\n"
219 "\n"
220 "vec3 newlight_compute_spot( vec3 wnormal, vec3 halfview, \n"
221 " vec3 light_colour, vec3 light_pos,\n"
222 " vec4 light_dir )\n"
223 "{\n"
224 " vec3 light_delta = (light_pos-aWorldCo) * 10.0;\n"
225 "\n"
226 " float quadratic = dot(light_delta,light_delta);\n"
227 " float attenuation = 1.0f/( 1.0f + quadratic );\n"
228 "\n"
229 " light_delta = normalize( light_delta );\n"
230 " attenuation *= max( 0.0, dot( light_delta, wnormal ) );\n"
231 "\n"
232 " float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) ),\n"
233 " falloff = max( 0.0,( spot_theta - light_dir.w ) / (1.0-light_dir.w) );\n"
234 "\n"
235 " return light_colour*attenuation*falloff;\n"
236 "}\n"
237 "\n"
238 "#line 12 0 \n"
239 "#line 1 2 \n"
240 "const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n"
241 "const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n"
242 "const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n"
243 "const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n"
244 "const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n"
245 "const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 ) * 1.125;\n"
246 "\n"
247 "const float SUN_ANGLE = 0.0001;\n"
248 "const float TIME_RATE = 0.025;\n"
249 "\n"
250 "const float PI = 3.14159265;\n"
251 "\n"
252 "struct world_info\n"
253 "{\n"
254 " float time,\n"
255 " time_of_day,\n"
256 " day_phase,\n"
257 " sunset_phase;\n"
258 " \n"
259 " vec3 sun_dir;\n"
260 "};\n"
261 "\n"
262 "float luminance( vec3 v )\n"
263 "{\n"
264 " return dot( v, vec3(0.2126, 0.7152, 0.0722) );\n"
265 "}\n"
266 "\n"
267 "vec3 scene_ambient( vec3 dir, const world_info w )\n"
268 "{\n"
269 " float sun_azimuth = dot( dir.xz, w.sun_dir.xz ) * 0.4 + 0.6;\n"
270 " float sky_gradient = dir.y;\n"
271 " \n"
272 " /* Blend phase colours */\n"
273 " vec3 ambient = DAYSKY_COLOUR * (w.day_phase-w.sunset_phase*0.1);\n"
274 " ambient += SUNSET_COLOUR * (1.0-dir.y*0.5) * w.sunset_phase * sun_azimuth;\n"
275 " ambient += NIGHTSKY_COLOUR * (1.0-w.day_phase);\n"
276 " \n"
277 " /* Add gradient */\n"
278 " ambient -= sky_gradient * luminance(ambient);\n"
279 " \n"
280 " return ambient;\n"
281 "}\n"
282 "\n"
283 "vec3 scene_sky( vec3 ray_dir, const world_info w )\n"
284 "{\n"
285 " ray_dir.y = abs( ray_dir.y );\n"
286 " vec3 sky_colour = scene_ambient( ray_dir, w );\n"
287 " \n"
288 " /* Sun */\n"
289 " float sun_theta = dot( ray_dir, w.sun_dir );\n"
290 " float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n"
291 " float sun_shape = pow( sun_size, 2000.0 );\n"
292 " sun_shape += sun_size * max(w.sun_dir.y,0.0) * 0.5;\n"
293 " \n"
294 " vec3 sun_colour = mix( vec3(1.0), SUNSET_COLOUR, w.sunset_phase*0.5 );\n"
295 " sun_colour *= sun_shape;\n"
296 " \n"
297 " vec3 composite = sky_colour + sun_colour;\n"
298 " return composite;\n"
299 "}\n"
300 "\n"
301 "vec3 scene_compute_ambient( vec3 normal, const world_info w )\n"
302 "{\n"
303 " return scene_ambient( (normal * vec3(1.0,-1.0,1.0)) * 0.5 + 0.5, w );\n"
304 "}\n"
305 "\n"
306 "vec3 SR_LIGHT( vec3 normal, vec2 dir, vec3 colour )\n"
307 "{\n"
308 " vec3 dir3 = vec3\n"
309 " (\n"
310 " cos(dir.y) * cos(dir.x),\n"
311 " sin(dir.x),\n"
312 " sin(dir.y) * cos(dir.x)\n"
313 " );\n"
314 "\n"
315 " float flight = max( dot( normal, dir3 ) * 0.75 + 0.25, 0.0 );\n"
316 " \n"
317 " return flight * colour;\n"
318 "}\n"
319 "\n"
320 "vec3 scene_lighting_old( vec3 normal, const world_info w )\n"
321 "{\n"
322 " vec3 SR_COLOUR_SUN = vec3( 1.36, 1.35, 1.01 );\n"
323 " vec3 SR_COLOUR_FILL = vec3( 0.33, 0.56, 0.64 );\n"
324 " vec3 SR_COLOUR_RIM = vec3( 0.05, 0.05, 0.23 );\n"
325 " \n"
326 " return SR_LIGHT( normal, vec2( 0.63, -0.08 ), SR_COLOUR_SUN ) +\n"
327 " SR_LIGHT( normal, vec2( -2.60, -0.13 ), SR_COLOUR_FILL ) + \n"
328 " SR_LIGHT( normal, vec2( 2.60, -0.84 ), SR_COLOUR_RIM ) ;\n"
329 "}\n"
330 "\n"
331 "vec3 scene_lighting( vec3 normal, float shadow, vec3 halfview, const world_info w )\n"
332 "{\n"
333 " float fresnel = 1.0 - abs(dot(normal,halfview));\n"
334 "\n"
335 " vec3 sky_reflection = 0.5 * fresnel * mix( DAYSKY_COLOUR, SUNSET_COLOUR, w.sunset_phase );\n"
336 " vec3 light_sun = max(0.0,dot(normal,w.sun_dir)*0.75+0.25) * SUN_COLOUR \n"
337 " * w.day_phase;\n"
338 "\n"
339 " float scaled_shadow = max( shadow, 1.0 - max(w.sun_dir.y,0.0) );\n"
340 "\n"
341 " vec3 ambient = mix( AMBIENT_COLOUR, SUNSET_AMBIENT, w.sunset_phase );\n"
342 "\n"
343 " return ambient + (light_sun + sky_reflection) * shadow;\n"
344 "\n"
345 "\n"
346 "\n"
347 "\n"
348 "\n"
349 "\n"
350 " float sun_theta = dot( normal, w.sun_dir );\n"
351 "\n"
352 " float softness_min = 0.5;\n"
353 " float softness = softness_min + w.sunset_phase * (1.0-softness_min);\n"
354 " float light_min = 0.0 * w.day_phase;\n"
355 " float light_direct = light_min + smoothstep( -softness, softness, sun_theta ) * (1.0-light_min);\n"
356 " light_direct *= clamp(w.sun_dir.y * 4.0 + 1.0,0.0,1.0) * shadow;\n"
357 " \n"
358 " float light_bounce = 0.5 + 0.5 * dot( -normal, w.sun_dir );\n"
359 " light_bounce *= light_bounce * max( w.sun_dir.y, 0.0 );\n"
360 " \n"
361 " vec3 light_colour = SUN_COLOUR*w.day_phase + (SUNSET_COLOUR*w.sunset_phase + 0.1);\n"
362 " vec3 dark_colour = mix( AMBIENT_COLOUR, SUNSET_AMBIENT, w.sunset_phase );\n"
363 " \n"
364 " float spec = newlight_specular( normal, w.sun_dir, halfview, 2.0 ) \n"
365 " * 0.2 * shadow * w.day_phase;\n"
366 " \n"
367 " return mix(dark_colour, light_colour, light_direct) + \n"
368 " spec +\n"
369 " dark_colour * light_bounce;\n"
370 "}\n"
371 "\n"
372 "void scene_state( float world_time, out world_info w )\n"
373 "{\n"
374 " w.time = world_time;\n"
375 " w.time_of_day = fract( w.time );\n"
376 " w.day_phase = cos( w.time_of_day * PI * 2.0 ) * 0.5 + 0.5;\n"
377 " w.sunset_phase = cos( w.time_of_day * PI * 4.0 + PI ) * 0.5 + 0.5;\n"
378 " w.sunset_phase = pow( w.sunset_phase, 6.0 );\n"
379 " \n"
380 " float a = w.time_of_day * PI * 2.0;\n"
381 " w.sun_dir = normalize( vec3( sin( a ), cos( a ), 0.2) );\n"
382 "}\n"
383 "\n"
384 "\n"
385 "#line 13 0 \n"
386 "\n"
387 "float sdLine( vec3 p, vec3 a, vec3 b )\n"
388 "{\n"
389 " vec3 pa = p - a;\n"
390 " vec3 ba = b - a;\n"
391 "\n"
392 " float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n"
393 " return length( pa - ba*h );\n"
394 "}\n"
395 "\n"
396 "float compute_board_shadow()\n"
397 "{\n"
398 " // player shadow\n"
399 " float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
400 " float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
401 " player_shadow *= player_shadow*player_shadow*player_shadow;\n"
402 "\n"
403 " return 1.0 - player_shadow*0.8;\n"
404 "}\n"
405 "\n"
406 "vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist )\n"
407 "{\n"
408 " float dist = pow(fdist*0.0010,0.78);\n"
409 " return mix( vfrag, colour, min( 1.0, dist ) );\n"
410 "}\n"
411 "\n"
412 "vec3 scene_do_lighting( vec3 diffuse, vec3 wnormal )\n"
413 "{\n"
414 " world_info world;\n"
415 " scene_state( g_time, world );\n"
416 "\n"
417 " // Lighting\n"
418 " vec3 halfview = uCamera - aWorldCo;\n"
419 " float fdist = length(halfview);\n"
420 " halfview /= fdist;\n"
421 "\n"
422 " vec3 total_light = vec3(0.0);\n"
423 "\n"
424 "\n"
425 " float world_shadow = newlight_compute_sun_shadow( world.sun_dir \n"
426 " * (1.0/(max(world.sun_dir.y,0.0)+0.2)) );\n"
427 " float board_shadow = compute_board_shadow();\n"
428 "\n"
429 " total_light += scene_lighting( wnormal, min( board_shadow, world_shadow ), \n"
430 " halfview, world );\n"
431 "\n"
432 " //total_light += scene_lighting_old( wnormal, world );\n"
433 "\n"
434 " // Compute the other lights that exist in the map, not effected by the sun\n"
435 " // shadow\n"
436 "\n"
437 " // read lights\n"
438 " vec4 light_colour_0 = texelFetch( uLightsArray, light_indices.x*3+0 );\n"
439 " vec4 light_colour_1 = texelFetch( uLightsArray, light_indices.y*3+0 );\n"
440 " vec4 light_colour_2 = texelFetch( uLightsArray, light_indices.z*3+0 );\n"
441 " vec4 light_co_0 = texelFetch( uLightsArray, light_indices.x*3+1 );\n"
442 " vec4 light_co_1 = texelFetch( uLightsArray, light_indices.y*3+1 );\n"
443 " vec4 light_co_2 = texelFetch( uLightsArray, light_indices.z*3+1 );\n"
444 " vec4 light_dir_0 = texelFetch( uLightsArray, light_indices.x*3+2 );\n"
445 " vec4 light_dir_1 = texelFetch( uLightsArray, light_indices.y*3+2 );\n"
446 " vec4 light_dir_2 = texelFetch( uLightsArray, light_indices.z*3+2 );\n"
447 "\n"
448 " if( g_debug_indices == 1 )\n"
449 " {\n"
450 " float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),\n"
451 " min( fract(distance(light_co_1.xyz,aWorldCo)),\n"
452 " fract(distance(light_co_2.xyz,aWorldCo)) ) \n"
453 " );\n"
454 " \n"
455 " return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
456 " fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;\n"
457 " }\n"
458 "\n"
459 " if( g_debug_complexity == 1 )\n"
460 " {\n"
461 " return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );\n"
462 " }\n"
463 "\n"
464 " if( light_indices.w >= 1 )\n"
465 " {\n"
466 " total_light += newlight_compute_spot\n"
467 " ( \n"
468 " wnormal, halfview,\n"
469 " light_colour_0.rgb,\n"
470 " light_co_0.xyz,\n"
471 " light_dir_0\n"
472 " ) * board_shadow \n"
473 " * step( world.day_phase, light_colour_0.w );\n"
474 "\n"
475 " if( light_indices.w >= 2 )\n"
476 " {\n"
477 " total_light += newlight_compute_spot\n"
478 " ( \n"
479 " wnormal, halfview,\n"
480 " light_colour_1.rgb,\n"
481 " light_co_1.xyz,\n"
482 " light_dir_1\n"
483 " ) * board_shadow\n"
484 " * step( world.day_phase, light_colour_1.w );\n"
485 "\n"
486 " if( light_indices.w >= 3 )\n"
487 " {\n"
488 " total_light += newlight_compute_spot\n"
489 " ( \n"
490 " wnormal, halfview,\n"
491 " light_colour_2.rgb,\n"
492 " light_co_2.xyz,\n"
493 " light_dir_2\n"
494 " ) * board_shadow\n"
495 " * step( world.day_phase, light_colour_2.w );\n"
496 " }\n"
497 " }\n"
498 " }\n"
499 "\n"
500 " vec3 fog_colour = scene_sky( -halfview, world );\n"
501 " \n"
502 " return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n"
503 "}\n"
504 "\n"
505 "#line 9 0 \n"
506 "#line 1 2 \n"
507 "const float k_motion_lerp_amount = 0.01;\n"
508 "\n"
509 "#line 2 0 \n"
510 "\n"
511 "layout (location = 1) out vec2 oMotionVec;\n"
512 "\n"
513 "in vec3 aMotionVec0;\n"
514 "in vec3 aMotionVec1;\n"
515 "\n"
516 "void compute_motion_vectors()\n"
517 "{\n"
518 " // Write motion vectors\n"
519 " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n"
520 " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n"
521 "\n"
522 " oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
523 "}\n"
524 "\n"
525 "#line 10 0 \n"
526 "\n"
527 "void main()\n"
528 "{\n"
529 " compute_motion_vectors();\n"
530 "\n"
531 " vec3 vfrag = vec3(0.5,0.5,0.5);\n"
532 " vec4 vsamplemain = texture( uTexMain, aUv );\n"
533 " vec3 qnorm = aNorm.xyz;\n"
534 "\n"
535 " if( vsamplemain.a < 0.15 )\n"
536 " discard;\n"
537 "\n"
538 " vfrag = vsamplemain.rgb;\n"
539 "\n"
540 " if( g_light_preview == 1 )\n"
541 " {\n"
542 " vfrag = vec3(0.5);\n"
543 " }\n"
544 "\n"
545 " vfrag = scene_do_lighting( vfrag, qnorm );\n"
546 " oColour = vec4(vfrag, 1.0);\n"
547 "}\n"
548 ""},
549 };
550
551 static GLuint _uniform_scene_standard_alphatest_uMdl;
552 static GLuint _uniform_scene_standard_alphatest_uPv;
553 static GLuint _uniform_scene_standard_alphatest_uPvmPrev;
554 static GLuint _uniform_scene_standard_alphatest_uTexGarbage;
555 static GLuint _uniform_scene_standard_alphatest_uTexMain;
556 static GLuint _uniform_scene_standard_alphatest_uBoard0;
557 static GLuint _uniform_scene_standard_alphatest_uBoard1;
558 static GLuint _uniform_scene_standard_alphatest_uCamera;
559 static GLuint _uniform_scene_standard_alphatest_uPlane;
560 static GLuint _uniform_scene_standard_alphatest_uLightsArray;
561 static GLuint _uniform_scene_standard_alphatest_g_world_depth;
562 static void shader_scene_standard_alphatest_uMdl(m4x3f m){
563 glUniformMatrix4x3fv(_uniform_scene_standard_alphatest_uMdl,1,GL_FALSE,(float*)m);
564 }
565 static void shader_scene_standard_alphatest_uPv(m4x4f m){
566 glUniformMatrix4fv(_uniform_scene_standard_alphatest_uPv,1,GL_FALSE,(float*)m);
567 }
568 static void shader_scene_standard_alphatest_uPvmPrev(m4x4f m){
569 glUniformMatrix4fv(_uniform_scene_standard_alphatest_uPvmPrev,1,GL_FALSE,(float*)m);
570 }
571 static void shader_scene_standard_alphatest_uTexGarbage(int i){
572 glUniform1i(_uniform_scene_standard_alphatest_uTexGarbage,i);
573 }
574 static void shader_scene_standard_alphatest_uTexMain(int i){
575 glUniform1i(_uniform_scene_standard_alphatest_uTexMain,i);
576 }
577 static void shader_scene_standard_alphatest_uBoard0(v3f v){
578 glUniform3fv(_uniform_scene_standard_alphatest_uBoard0,1,v);
579 }
580 static void shader_scene_standard_alphatest_uBoard1(v3f v){
581 glUniform3fv(_uniform_scene_standard_alphatest_uBoard1,1,v);
582 }
583 static void shader_scene_standard_alphatest_uCamera(v3f v){
584 glUniform3fv(_uniform_scene_standard_alphatest_uCamera,1,v);
585 }
586 static void shader_scene_standard_alphatest_uPlane(v4f v){
587 glUniform4fv(_uniform_scene_standard_alphatest_uPlane,1,v);
588 }
589 static void shader_scene_standard_alphatest_g_world_depth(int i){
590 glUniform1i(_uniform_scene_standard_alphatest_g_world_depth,i);
591 }
592 static void shader_scene_standard_alphatest_register(void){
593 vg_shader_register( &_shader_scene_standard_alphatest );
594 }
595 static void shader_scene_standard_alphatest_use(void){ glUseProgram(_shader_scene_standard_alphatest.id); }
596 static void shader_scene_standard_alphatest_link(void){
597 _uniform_scene_standard_alphatest_uMdl = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uMdl" );
598 _uniform_scene_standard_alphatest_uPv = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uPv" );
599 _uniform_scene_standard_alphatest_uPvmPrev = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uPvmPrev" );
600 _uniform_scene_standard_alphatest_uTexGarbage = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uTexGarbage" );
601 _uniform_scene_standard_alphatest_uTexMain = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uTexMain" );
602 _uniform_scene_standard_alphatest_uBoard0 = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uBoard0" );
603 _uniform_scene_standard_alphatest_uBoard1 = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uBoard1" );
604 _uniform_scene_standard_alphatest_uCamera = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uCamera" );
605 _uniform_scene_standard_alphatest_uPlane = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uPlane" );
606 _uniform_scene_standard_alphatest_uLightsArray = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uLightsArray" );
607 _uniform_scene_standard_alphatest_g_world_depth = glGetUniformLocation( _shader_scene_standard_alphatest.id, "g_world_depth" );
608 }
609 #endif /* SHADER_scene_standard_alphatest_H */