1 #ifndef SHADER_scene_terrain_H
2 #define SHADER_scene_terrain_H
3 static void shader_scene_terrain_link(void);
4 static void shader_scene_terrain_register(void);
5 static struct vg_shader _shader_scene_terrain
= {
6 .name
= "scene_terrain",
7 .link
= shader_scene_terrain_link
,
10 .orig_file
= "shaders/scene.vs",
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"
18 "const float k_motion_lerp_amount = 0.01;\n"
22 "out vec3 aMotionVec0;\n"
23 "out vec3 aMotionVec1;\n"
25 "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
27 " // This magically solves some artifacting errors!\n"
29 " vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
31 " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
32 " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n"
37 "uniform mat4x3 uMdl;\n"
39 "uniform mat4 uPvmPrev;\n"
44 "out vec3 aWorldCo;\n"
46 "flat out ivec4 light_indices;\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"
54 " vs_motion_out( vproj0, vproj1 );\n"
56 " gl_Position = vproj0;\n"
59 " aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n"
61 " aWorldCo = world_pos0;\n"
63 " light_indices = a_lights;\n"
68 .orig_file
= "shaders/scene_terrain.fs",
70 "uniform sampler2D uTexGarbage;\n"
71 "uniform sampler2D uTexGradients;\n"
72 "uniform vec3 uCamera;\n"
73 "uniform vec3 uSandColour;\n"
74 "uniform vec2 uBlendOffset;\n"
75 "uniform vec3 uBoard0;\n"
76 "uniform vec3 uBoard1;\n"
85 "flat in ivec4 light_indices;\n"
87 "uniform samplerBuffer uLightsArray;\n"
88 "uniform usampler3D uLightsIndex;\n"
91 "layout (location = 0) out vec4 oColour;\n"
93 "layout (std140) uniform ub_world_lighting\n"
96 " vec4 g_cube_inv_range;\n"
98 " vec4 g_light_colours[3];\n"
99 " vec4 g_light_directions[3];\n"
100 " vec4 g_ambient_colour;\n"
102 " vec4 g_water_plane;\n"
103 " vec4 g_depth_bounds;\n"
104 " float g_water_fog;\n"
106 " int g_light_count;\n"
107 " int g_light_preview;\n"
108 " int g_shadow_samples;\n"
110 " int g_debug_indices;\n"
111 " int g_debug_complexity;\n"
115 " //vec4 g_point_light_positions[32];\n"
116 " //vec4 g_point_light_colours[32];\n"
119 "uniform sampler2D g_world_depth;\n"
121 "float world_depth_sample( vec3 pos )\n"
123 " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
124 " return texture( g_world_depth, depth_coord ).r;\n"
127 "float world_water_depth( vec3 pos )\n"
129 " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
130 " float ref_depth = g_water_plane.y*g_water_plane.w;\n"
131 " return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
134 "float shadow_sample( vec3 vdir )\n"
136 " vec3 sample_pos = aWorldCo + vdir;\n"
137 " float height_sample = world_depth_sample( sample_pos );\n"
139 " float fdelta = height_sample - sample_pos.y;\n"
140 " return clamp( fdelta, 0.1, 0.2 )-0.1;\n"
143 "vec3 apply_fog( vec3 vfrag, float fdist )\n"
145 " float dist = pow(fdist*0.0008,1.2);\n"
146 " return mix( vfrag, vec3(0.55,0.76,1.0), min( 1.0, dist ) );\n"
150 "// New lighting model\n"
152 "vec3 newlight_compute_ambient()\n"
154 " return g_ambient_colour.rgb;\n"
157 "float newlight_compute_sun_shadow( vec3 dir )\n"
159 " if( g_shadow_samples == 0 )\n"
164 " float fspread = g_light_colours[0].w;\n"
165 " vec3 vdir = dir;\n"
166 " float flength = g_light_directions[0].w;\n"
168 " float famt = 0.0;\n"
169 " famt+=shadow_sample((vdir+vec3(-0.563, 0.550, 0.307)*fspread)*flength*0.1);\n"
170 " famt+=shadow_sample((vdir+vec3( 0.808, 0.686, 0.346)*fspread)*flength*0.2);\n"
171 " famt+=shadow_sample((vdir+vec3( 0.787, 0.074,-0.065)*fspread)*flength*0.3);\n"
172 " famt+=shadow_sample((vdir+vec3(-0.593, 0.071,-0.425)*fspread)*flength*0.4);\n"
173 " famt+=shadow_sample((vdir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n"
174 " famt+=shadow_sample((vdir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n"
175 " famt+=shadow_sample((vdir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n"
176 " famt+=shadow_sample((vdir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n"
178 " return 1.0 - famt;\n"
181 "vec3 newlight_compute_world_diffuse( vec3 wnormal )\n"
183 " vec3 vtotal = g_ambient_colour.rgb;\n"
185 " for( int i=0; i<g_light_count; i++ )\n"
187 " vec3 vcolour = g_light_colours[i].rgb;\n"
188 " vec3 vdir = g_light_directions[i].xyz;\n"
190 " float flight = max(dot( vdir, wnormal )*0.75+0.25,0.0);\n"
191 " vtotal += vcolour*flight;\n"
197 "vec3 newlight_compute_sun_spec( vec3 wnormal, vec3 halfview, float fintensity )\n"
199 " vec3 vcolour = g_light_colours[0].rgb;\n"
200 " vec3 vdir = g_light_directions[0].xyz;\n"
202 " vec3 specdir = reflect( -vdir, wnormal );\n"
203 " float spec = pow(max(dot( halfview, specdir ), 0.0), 10.0);\n"
204 " return vcolour*spec*fintensity;\n"
207 "float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n"
209 " vec3 specdir = reflect( -dir, wnormal );\n"
210 " return pow(max(dot( halfview, specdir ), 0.0), exponent);\n"
213 "vec3 newlight_compute_quadratic( vec3 wnormal, float max_dist,\n"
214 " vec3 light_colour, vec3 light_pos )\n"
216 " vec3 light_delta = light_pos-aWorldCo;\n"
218 " float dist2 = dot(light_delta,light_delta);\n"
220 " float quadratic = dist2*100.0;\n"
221 " float attenuation = 1.0f/( 1.0f + quadratic );\n"
222 " attenuation *= max( dot( normalize(light_delta), wnormal ), 0.0 );\n"
224 " float falloff = max( 0.0, 1.0-(dist2*max_dist) );\n"
225 " return light_colour * attenuation * falloff;\n"
228 "vec3 newlight_compute_spot( vec3 wnormal, vec3 halfview, \n"
229 " vec3 light_colour, vec3 light_pos,\n"
230 " vec4 light_dir )\n"
232 " vec3 light_delta = (light_pos-aWorldCo) * 10.0;\n"
234 " float quadratic = dot(light_delta,light_delta);\n"
235 " float attenuation = 1.0f/( 1.0f + quadratic );\n"
237 " light_delta = normalize( light_delta );\n"
238 " attenuation *= max( 0.0, dot( light_delta, wnormal ) );\n"
240 " float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) ),\n"
241 " falloff = max( 0.0,( spot_theta - light_dir.w ) / (1.0-light_dir.w) );\n"
243 " return light_colour*attenuation*falloff;\n"
248 "const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n"
249 "const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n"
250 "const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n"
251 "const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n"
252 "const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n"
253 "const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 ) * 1.125;\n"
255 "const float SUN_ANGLE = 0.0001;\n"
256 "const float TIME_RATE = 0.025;\n"
258 "const float PI = 3.14159265;\n"
260 "struct world_info\n"
270 "float luminance( vec3 v )\n"
272 " return dot( v, vec3(0.2126, 0.7152, 0.0722) );\n"
275 "vec3 scene_ambient( vec3 dir, const world_info w )\n"
277 " float sun_azimuth = dot( dir.xz, w.sun_dir.xz ) * 0.4 + 0.6;\n"
278 " float sky_gradient = dir.y;\n"
280 " /* Blend phase colours */\n"
281 " vec3 ambient = DAYSKY_COLOUR * (w.day_phase-w.sunset_phase*0.1);\n"
282 " ambient += SUNSET_COLOUR * (1.0-dir.y*0.5) * w.sunset_phase * sun_azimuth;\n"
283 " ambient += NIGHTSKY_COLOUR * (1.0-w.day_phase);\n"
285 " /* Add gradient */\n"
286 " ambient -= sky_gradient * luminance(ambient);\n"
291 "vec3 scene_sky( vec3 ray_dir, const world_info w )\n"
293 " ray_dir.y = abs( ray_dir.y );\n"
294 " vec3 sky_colour = scene_ambient( ray_dir, w );\n"
297 " float sun_theta = dot( ray_dir, w.sun_dir );\n"
298 " float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n"
299 " float sun_shape = pow( sun_size, 2000.0 );\n"
300 " sun_shape += sun_size * max(w.sun_dir.y,0.0) * 0.5;\n"
302 " vec3 sun_colour = mix( vec3(1.0), SUNSET_COLOUR, w.sunset_phase*0.5 );\n"
303 " sun_colour *= sun_shape;\n"
305 " vec3 composite = sky_colour + sun_colour;\n"
306 " return composite;\n"
309 "vec3 scene_compute_ambient( vec3 normal, const world_info w )\n"
311 " return scene_ambient( (normal * vec3(1.0,-1.0,1.0)) * 0.5 + 0.5, w );\n"
314 "vec3 SR_LIGHT( vec3 normal, vec2 dir, vec3 colour )\n"
316 " vec3 dir3 = vec3\n"
318 " cos(dir.y) * cos(dir.x),\n"
320 " sin(dir.y) * cos(dir.x)\n"
323 " float flight = max( dot( normal, dir3 ) * 0.75 + 0.25, 0.0 );\n"
325 " return flight * colour;\n"
328 "vec3 scene_lighting_old( vec3 normal, const world_info w )\n"
330 " vec3 SR_COLOUR_SUN = vec3( 1.36, 1.35, 1.01 );\n"
331 " vec3 SR_COLOUR_FILL = vec3( 0.33, 0.56, 0.64 );\n"
332 " vec3 SR_COLOUR_RIM = vec3( 0.05, 0.05, 0.23 );\n"
334 " return SR_LIGHT( normal, vec2( 0.63, -0.08 ), SR_COLOUR_SUN ) +\n"
335 " SR_LIGHT( normal, vec2( -2.60, -0.13 ), SR_COLOUR_FILL ) + \n"
336 " SR_LIGHT( normal, vec2( 2.60, -0.84 ), SR_COLOUR_RIM ) ;\n"
339 "vec3 scene_lighting( vec3 normal, float shadow, vec3 halfview, const world_info w )\n"
341 " float fresnel = 1.0 - abs(dot(normal,halfview));\n"
343 " vec3 sky_reflection = 0.5 * fresnel * mix( DAYSKY_COLOUR, SUNSET_COLOUR, w.sunset_phase );\n"
344 " vec3 light_sun = max(0.0,dot(normal,w.sun_dir)*0.75+0.25) * SUN_COLOUR \n"
347 " float scaled_shadow = max( shadow, 1.0 - max(w.sun_dir.y,0.0) );\n"
349 " vec3 ambient = mix( AMBIENT_COLOUR, SUNSET_AMBIENT, w.sunset_phase );\n"
351 " return ambient + (light_sun + sky_reflection) * shadow;\n"
358 " float sun_theta = dot( normal, w.sun_dir );\n"
360 " float softness_min = 0.5;\n"
361 " float softness = softness_min + w.sunset_phase * (1.0-softness_min);\n"
362 " float light_min = 0.0 * w.day_phase;\n"
363 " float light_direct = light_min + smoothstep( -softness, softness, sun_theta ) * (1.0-light_min);\n"
364 " light_direct *= clamp(w.sun_dir.y * 4.0 + 1.0,0.0,1.0) * shadow;\n"
366 " float light_bounce = 0.5 + 0.5 * dot( -normal, w.sun_dir );\n"
367 " light_bounce *= light_bounce * max( w.sun_dir.y, 0.0 );\n"
369 " vec3 light_colour = SUN_COLOUR*w.day_phase + (SUNSET_COLOUR*w.sunset_phase + 0.1);\n"
370 " vec3 dark_colour = mix( AMBIENT_COLOUR, SUNSET_AMBIENT, w.sunset_phase );\n"
372 " float spec = newlight_specular( normal, w.sun_dir, halfview, 2.0 ) \n"
373 " * 0.2 * shadow * w.day_phase;\n"
375 " return mix(dark_colour, light_colour, light_direct) + \n"
377 " dark_colour * light_bounce;\n"
380 "void scene_state( float world_time, out world_info w )\n"
382 " w.time = world_time;\n"
383 " w.time_of_day = fract( w.time );\n"
384 " w.day_phase = cos( w.time_of_day * PI * 2.0 ) * 0.5 + 0.5;\n"
385 " w.sunset_phase = cos( w.time_of_day * PI * 4.0 + PI ) * 0.5 + 0.5;\n"
386 " w.sunset_phase = pow( w.sunset_phase, 6.0 );\n"
388 " float a = w.time_of_day * PI * 2.0;\n"
389 " w.sun_dir = normalize( vec3( sin( a ), cos( a ), 0.2) );\n"
395 "float sdLine( vec3 p, vec3 a, vec3 b )\n"
397 " vec3 pa = p - a;\n"
398 " vec3 ba = b - a;\n"
400 " float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n"
401 " return length( pa - ba*h );\n"
404 "float compute_board_shadow()\n"
406 " // player shadow\n"
407 " float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
408 " float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
409 " player_shadow *= player_shadow*player_shadow*player_shadow;\n"
411 " return 1.0 - player_shadow*0.8;\n"
414 "vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist )\n"
416 " float dist = pow(fdist*0.0010,0.78);\n"
417 " return mix( vfrag, colour, min( 1.0, dist ) );\n"
420 "vec3 rand33(vec3 p3)\n"
422 " p3 = fract(p3 * vec3(.1031, .1030, .0973));\n"
423 " p3 += dot(p3, p3.yxz+33.33);\n"
424 " return fract((p3.xxy + p3.yxx)*p3.zyx);\n"
427 "vec3 scene_calculate_light( int light_index, \n"
428 " vec3 halfview, vec3 co, vec3 normal )\n"
430 " vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n"
431 " vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n"
432 " vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n"
434 " vec3 light_delta = light_co.xyz-co;\n"
435 " float dist2 = dot(light_delta,light_delta);\n"
437 " light_delta = normalize( light_delta );\n"
439 " float quadratic = dist2*100.0;\n"
440 " float attenuation = 1.0f/( 1.0f + quadratic );\n"
441 " attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
443 " float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
445 " if( light_dir.w < 0.999999 )\n"
447 " float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n"
448 " falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n"
451 " return light_colour.rgb * attenuation * falloff;\n"
454 "vec3 scene_calculate_packed_light_patch( uint packed_index, \n"
455 " vec3 halfview, vec3 co, vec3 normal )\n"
457 " uint light_count = packed_index & 0x3u;\n"
459 " vec3 l = vec3(0.0);\n"
461 " if( light_count >= 1u )\n"
463 " int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n"
464 " int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n"
465 " int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n"
467 " l += scene_calculate_light( index_0, halfview, co, normal );\n"
469 " if( light_count >= 2u )\n"
471 " l += scene_calculate_light( index_1, halfview, co, normal );\n"
473 " if( light_count >= 3u )\n"
475 " l += scene_calculate_light( index_2, halfview, co, normal );\n"
483 "vec3 scene_do_lighting( vec3 diffuse, vec3 wnormal )\n"
485 " world_info world;\n"
486 " scene_state( g_time, world );\n"
489 " vec3 halfview = uCamera - aWorldCo;\n"
490 " float fdist = length(halfview);\n"
491 " halfview /= fdist;\n"
493 " vec3 total_light = vec3(0.0);\n"
494 " float world_shadow = newlight_compute_sun_shadow( world.sun_dir \n"
495 " * (1.0/(max(world.sun_dir.y,0.0)+0.2)) );\n"
496 " float board_shadow = compute_board_shadow();\n"
498 " total_light += scene_lighting( wnormal, min( board_shadow, world_shadow ), \n"
499 " halfview, world );\n"
501 " vec3 cube_coord = (aWorldCo - g_cube_min.xyz) * g_cube_inv_range.xyz;\n"
502 " cube_coord = floor( cube_coord );\n"
504 " if( g_debug_indices == 1 )\n"
506 " return rand33(cube_coord);\n"
509 " if( g_debug_complexity == 1 )\n"
511 " ivec3 coord = ivec3( cube_coord );\n"
512 " uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n"
514 " uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n"
515 " return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n"
518 " // FIXME: this should absolutely must be clamped!\n"
520 " ivec3 coord = ivec3( cube_coord );\n"
521 " uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n"
524 " scene_calculate_packed_light_patch( index_sample.x,\n"
525 " halfview, aWorldCo, wnormal ) \n"
528 " scene_calculate_packed_light_patch( index_sample.y,\n"
529 " halfview, aWorldCo, wnormal )\n"
532 " vec3 fog_colour = scene_sky( -halfview, world );\n"
533 " return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n"
538 "const float k_motion_lerp_amount = 0.01;\n"
542 "layout (location = 1) out vec2 oMotionVec;\n"
544 "in vec3 aMotionVec0;\n"
545 "in vec3 aMotionVec1;\n"
547 "void compute_motion_vectors()\n"
549 " // Write motion vectors\n"
550 " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n"
551 " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n"
553 " oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
560 " compute_motion_vectors();\n"
564 " vec3 vfrag = vec3(0.5,0.5,0.5);\n"
566 " // ws modulation\n"
567 " vec4 wgarbage = texture( uTexGarbage, aCo.xz * 0.015 );\n"
569 " // Creating normal patches\n"
570 " vec3 modnorm = (wgarbage.rgb-0.4) * 1.4;\n"
571 " vec3 qnorm = normalize(floor(aNorm.xyz*4.0+modnorm)*0.25);\n"
572 " qnorm += vec3(0.001,0.0,0.0);\n"
574 " vec2 dir = normalize(qnorm.xz);\n"
575 " vec2 uvdiffuse = aCo.xz * 0.02;\n"
576 " uvdiffuse = mat2(dir.y, dir.x, -dir.x, dir.y) * uvdiffuse;\n"
578 " // Patch local noise\n"
579 " vec4 rgarbage = texture( uTexGarbage, uvdiffuse );\n"
581 " // Colour blending\n"
582 " float amtgrass = step(qnorm.y,0.6);\n"
583 " float amtsand = min(max((aCo.y - 10.0) * -0.1,0.0)*qnorm.y,1.0);\n"
584 " vec2 uvgradients = aUv + vec2( amtgrass + rgarbage.a*0.8 )*uBlendOffset;\n"
585 " vfrag = texture( uTexGradients, uvgradients ).rgb;\n"
586 " vfrag = mix( vfrag, uSandColour, amtsand );\n"
588 " qnorm = mix( qnorm, aNorm.xyz, amtsand );\n"
590 " if( g_light_preview == 1 )\n"
592 " vfrag = vec3(0.5);\n"
595 " vfrag = scene_do_lighting( vfrag, qnorm );\n"
596 " oColour = vec4(vfrag, 1.0);\n"
601 static GLuint _uniform_scene_terrain_uMdl
;
602 static GLuint _uniform_scene_terrain_uPv
;
603 static GLuint _uniform_scene_terrain_uPvmPrev
;
604 static GLuint _uniform_scene_terrain_uTexGarbage
;
605 static GLuint _uniform_scene_terrain_uTexGradients
;
606 static GLuint _uniform_scene_terrain_uCamera
;
607 static GLuint _uniform_scene_terrain_uSandColour
;
608 static GLuint _uniform_scene_terrain_uBlendOffset
;
609 static GLuint _uniform_scene_terrain_uBoard0
;
610 static GLuint _uniform_scene_terrain_uBoard1
;
611 static GLuint _uniform_scene_terrain_uLightsArray
;
612 static GLuint _uniform_scene_terrain_uLightsIndex
;
613 static GLuint _uniform_scene_terrain_g_world_depth
;
614 static void shader_scene_terrain_uMdl(m4x3f m
){
615 glUniformMatrix4x3fv(_uniform_scene_terrain_uMdl
,1,GL_FALSE
,(float*)m
);
617 static void shader_scene_terrain_uPv(m4x4f m
){
618 glUniformMatrix4fv(_uniform_scene_terrain_uPv
,1,GL_FALSE
,(float*)m
);
620 static void shader_scene_terrain_uPvmPrev(m4x4f m
){
621 glUniformMatrix4fv(_uniform_scene_terrain_uPvmPrev
,1,GL_FALSE
,(float*)m
);
623 static void shader_scene_terrain_uTexGarbage(int i
){
624 glUniform1i(_uniform_scene_terrain_uTexGarbage
,i
);
626 static void shader_scene_terrain_uTexGradients(int i
){
627 glUniform1i(_uniform_scene_terrain_uTexGradients
,i
);
629 static void shader_scene_terrain_uCamera(v3f v
){
630 glUniform3fv(_uniform_scene_terrain_uCamera
,1,v
);
632 static void shader_scene_terrain_uSandColour(v3f v
){
633 glUniform3fv(_uniform_scene_terrain_uSandColour
,1,v
);
635 static void shader_scene_terrain_uBlendOffset(v2f v
){
636 glUniform2fv(_uniform_scene_terrain_uBlendOffset
,1,v
);
638 static void shader_scene_terrain_uBoard0(v3f v
){
639 glUniform3fv(_uniform_scene_terrain_uBoard0
,1,v
);
641 static void shader_scene_terrain_uBoard1(v3f v
){
642 glUniform3fv(_uniform_scene_terrain_uBoard1
,1,v
);
644 static void shader_scene_terrain_g_world_depth(int i
){
645 glUniform1i(_uniform_scene_terrain_g_world_depth
,i
);
647 static void shader_scene_terrain_register(void){
648 vg_shader_register( &_shader_scene_terrain
);
650 static void shader_scene_terrain_use(void){ glUseProgram(_shader_scene_terrain
.id
); }
651 static void shader_scene_terrain_link(void){
652 _uniform_scene_terrain_uMdl
= glGetUniformLocation( _shader_scene_terrain
.id
, "uMdl" );
653 _uniform_scene_terrain_uPv
= glGetUniformLocation( _shader_scene_terrain
.id
, "uPv" );
654 _uniform_scene_terrain_uPvmPrev
= glGetUniformLocation( _shader_scene_terrain
.id
, "uPvmPrev" );
655 _uniform_scene_terrain_uTexGarbage
= glGetUniformLocation( _shader_scene_terrain
.id
, "uTexGarbage" );
656 _uniform_scene_terrain_uTexGradients
= glGetUniformLocation( _shader_scene_terrain
.id
, "uTexGradients" );
657 _uniform_scene_terrain_uCamera
= glGetUniformLocation( _shader_scene_terrain
.id
, "uCamera" );
658 _uniform_scene_terrain_uSandColour
= glGetUniformLocation( _shader_scene_terrain
.id
, "uSandColour" );
659 _uniform_scene_terrain_uBlendOffset
= glGetUniformLocation( _shader_scene_terrain
.id
, "uBlendOffset" );
660 _uniform_scene_terrain_uBoard0
= glGetUniformLocation( _shader_scene_terrain
.id
, "uBoard0" );
661 _uniform_scene_terrain_uBoard1
= glGetUniformLocation( _shader_scene_terrain
.id
, "uBoard1" );
662 _uniform_scene_terrain_uLightsArray
= glGetUniformLocation( _shader_scene_terrain
.id
, "uLightsArray" );
663 _uniform_scene_terrain_uLightsIndex
= glGetUniformLocation( _shader_scene_terrain
.id
, "uLightsIndex" );
664 _uniform_scene_terrain_g_world_depth
= glGetUniformLocation( _shader_scene_terrain
.id
, "g_world_depth" );
666 #endif /* SHADER_scene_terrain_H */