From bececcbb7b2e886e72425e7c070e1fdc3aa126dc Mon Sep 17 00:00:00 2001 From: hgn Date: Tue, 26 Mar 2024 22:24:16 +0000 Subject: [PATCH] ignore autogenerated headers --- .gitignore | 6 +- shaders/blit.h | 18 - shaders/blit_transition.h | 18 - shaders/blitblur.h | 48 - shaders/blitcolour.h | 18 - shaders/impl.c | 11483 --------------------------- shaders/model_board_view.h | 65 - shaders/model_character_view.h | 56 - shaders/model_entity.h | 40 - shaders/model_font.h | 63 - shaders/model_gate.h | 43 - shaders/model_gate_unlinked.h | 38 - shaders/model_menu.h | 33 - shaders/model_sky.h | 35 - shaders/model_sky_space.h | 35 - shaders/particle.h | 18 - shaders/point_map.h | 168 - shaders/routeui.h | 18 - shaders/scene_cubemapped.h | 60 - shaders/scene_depth.h | 45 - shaders/scene_foliage.h | 55 - shaders/scene_font.h | 65 - shaders/scene_fxglow.h | 45 - shaders/scene_override.h | 75 - shaders/scene_position.h | 45 - shaders/scene_route.h | 55 - shaders/scene_scoretext.h | 55 - shaders/scene_standard.h | 50 - shaders/scene_standard_alphatest.h | 50 - shaders/scene_terrain.h | 55 - shaders/scene_vertex_blend.h | 45 - shaders/scene_water.h | 100 - shaders/scene_water_fast.h | 70 - shaders/trail.h | 23 - 34 files changed, 5 insertions(+), 13091 deletions(-) delete mode 100644 shaders/blit.h delete mode 100644 shaders/blit_transition.h delete mode 100644 shaders/blitblur.h delete mode 100644 shaders/blitcolour.h delete mode 100644 shaders/impl.c delete mode 100644 shaders/model_board_view.h delete mode 100644 shaders/model_character_view.h delete mode 100644 shaders/model_entity.h delete mode 100644 shaders/model_font.h delete mode 100644 shaders/model_gate.h delete mode 100644 shaders/model_gate_unlinked.h delete mode 100644 shaders/model_menu.h delete mode 100644 shaders/model_sky.h delete mode 100644 shaders/model_sky_space.h delete mode 100644 shaders/particle.h delete mode 100644 shaders/point_map.h delete mode 100644 shaders/routeui.h delete mode 100644 shaders/scene_cubemapped.h delete mode 100644 shaders/scene_depth.h delete mode 100644 shaders/scene_foliage.h delete mode 100644 shaders/scene_font.h delete mode 100644 shaders/scene_fxglow.h delete mode 100644 shaders/scene_override.h delete mode 100644 shaders/scene_position.h delete mode 100644 shaders/scene_route.h delete mode 100644 shaders/scene_scoretext.h delete mode 100644 shaders/scene_standard.h delete mode 100644 shaders/scene_standard_alphatest.h delete mode 100644 shaders/scene_terrain.h delete mode 100644 shaders/scene_vertex_blend.h delete mode 100644 shaders/scene_water.h delete mode 100644 shaders/scene_water_fast.h delete mode 100644 shaders/trail.h diff --git a/.gitignore b/.gitignore index 7f613b9..16634e9 100755 --- a/.gitignore +++ b/.gitignore @@ -14,9 +14,13 @@ bin/ dist/ models_src/boards/workshop +# auto generated code +shaders/*.h +shaders/impl.c +skaterift_blender/_combined.py + compile_commands.json skaterift_blender/__pycache__/ -skaterift_blender/_combined.py sound_src/rtj3_01_down.ogg sound_src/song.ogg diff --git a/shaders/blit.h b/shaders/blit.h deleted file mode 100644 index 94d3dce..0000000 --- a/shaders/blit.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_blit; -extern GLuint _uniform_blit_uInverseRatio; -extern GLuint _uniform_blit_uTexMain; -static inline void shader_blit_uInverseRatio(v2f v) -{ - glUniform2fv(_uniform_blit_uInverseRatio,1,v); -} -static inline void shader_blit_uTexMain(int i) -{ - glUniform1i(_uniform_blit_uTexMain,i); -} -static inline void shader_blit_use(void); -static inline void shader_blit_use(void) -{ - glUseProgram(_shader_blit.id); -} diff --git a/shaders/blit_transition.h b/shaders/blit_transition.h deleted file mode 100644 index f73d1d4..0000000 --- a/shaders/blit_transition.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_blit_transition; -extern GLuint _uniform_blit_transition_uInverseRatio; -extern GLuint _uniform_blit_transition_uT; -static inline void shader_blit_transition_uInverseRatio(v2f v) -{ - glUniform2fv(_uniform_blit_transition_uInverseRatio,1,v); -} -static inline void shader_blit_transition_uT(f32 f) -{ - glUniform1f(_uniform_blit_transition_uT,f); -} -static inline void shader_blit_transition_use(void); -static inline void shader_blit_transition_use(void) -{ - glUseProgram(_shader_blit_transition.id); -} diff --git a/shaders/blitblur.h b/shaders/blitblur.h deleted file mode 100644 index 8a75c38..0000000 --- a/shaders/blitblur.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_blitblur; -extern GLuint _uniform_blitblur_uInverseRatio; -extern GLuint _uniform_blitblur_uTexMain; -extern GLuint _uniform_blitblur_uTexMotion; -extern GLuint _uniform_blitblur_uBlurStrength; -extern GLuint _uniform_blitblur_uOverrideDir; -extern GLuint _uniform_blitblur_uTime; -extern GLuint _uniform_blitblur_uGlitchStrength; -extern GLuint _uniform_blitblur_uClampUv; -static inline void shader_blitblur_uInverseRatio(v2f v) -{ - glUniform2fv(_uniform_blitblur_uInverseRatio,1,v); -} -static inline void shader_blitblur_uTexMain(int i) -{ - glUniform1i(_uniform_blitblur_uTexMain,i); -} -static inline void shader_blitblur_uTexMotion(int i) -{ - glUniform1i(_uniform_blitblur_uTexMotion,i); -} -static inline void shader_blitblur_uBlurStrength(f32 f) -{ - glUniform1f(_uniform_blitblur_uBlurStrength,f); -} -static inline void shader_blitblur_uOverrideDir(v2f v) -{ - glUniform2fv(_uniform_blitblur_uOverrideDir,1,v); -} -static inline void shader_blitblur_uTime(f32 f) -{ - glUniform1f(_uniform_blitblur_uTime,f); -} -static inline void shader_blitblur_uGlitchStrength(f32 f) -{ - glUniform1f(_uniform_blitblur_uGlitchStrength,f); -} -static inline void shader_blitblur_uClampUv(v2f v) -{ - glUniform2fv(_uniform_blitblur_uClampUv,1,v); -} -static inline void shader_blitblur_use(void); -static inline void shader_blitblur_use(void) -{ - glUseProgram(_shader_blitblur.id); -} diff --git a/shaders/blitcolour.h b/shaders/blitcolour.h deleted file mode 100644 index 1bd3349..0000000 --- a/shaders/blitcolour.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_blitcolour; -extern GLuint _uniform_blitcolour_uInverseRatio; -extern GLuint _uniform_blitcolour_uColour; -static inline void shader_blitcolour_uInverseRatio(v2f v) -{ - glUniform2fv(_uniform_blitcolour_uInverseRatio,1,v); -} -static inline void shader_blitcolour_uColour(v4f v) -{ - glUniform4fv(_uniform_blitcolour_uColour,1,v); -} -static inline void shader_blitcolour_use(void); -static inline void shader_blitcolour_use(void) -{ - glUseProgram(_shader_blitcolour.id); -} diff --git a/shaders/impl.c b/shaders/impl.c deleted file mode 100644 index eeebab1..0000000 --- a/shaders/impl.c +++ /dev/null @@ -1,11483 +0,0 @@ -#include "shaders/scene_standard.h" -struct vg_shader _shader_scene_standard = { - .name = "scene_standard", - .vs = -{ -.orig_file = "shaders/scene.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_standard.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"uniform sampler2D uTexMain;\n" -"uniform vec3 uCamera;\n" -"uniform vec4 uPlane;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 7 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 8 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" vec3 vfrag = vec3(0.5,0.5,0.5);\n" -" vec4 vsamplemain = texture( uTexMain, aUv );\n" -" vec3 qnorm = aNorm.xyz;\n" -"\n" -" vfrag = vsamplemain.rgb;\n" -"\n" -" if( g_light_preview == 1 )\n" -" {\n" -" vfrag = vec3(0.5);\n" -" }\n" -"\n" -" vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n" -" oColour = vec4( vfrag, 1.0 );\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_standard_uMdl; -GLuint _uniform_scene_standard_uPv; -GLuint _uniform_scene_standard_uPvmPrev; -GLuint _uniform_scene_standard_uTexGarbage; -GLuint _uniform_scene_standard_uTexMain; -GLuint _uniform_scene_standard_uCamera; -GLuint _uniform_scene_standard_uPlane; -GLuint _uniform_scene_standard_g_world_depth; -GLuint _uniform_scene_standard_uLightsArray; -GLuint _uniform_scene_standard_uLightsIndex; -#include "shaders/scene_standard_alphatest.h" -struct vg_shader _shader_scene_standard_alphatest = { - .name = "scene_standard_alphatest", - .vs = -{ -.orig_file = "shaders/scene.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_standard_alphatest.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"uniform sampler2D uTexMain;\n" -"uniform vec3 uCamera;\n" -"uniform vec4 uPlane;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 7 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 8 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" vec3 vfrag = vec3(0.5,0.5,0.5);\n" -" vec4 vsamplemain = texture( uTexMain, aUv );\n" -" vec3 qnorm = aNorm.xyz;\n" -"\n" -" if( vsamplemain.a < 0.15 )\n" -" discard;\n" -"\n" -" vfrag = vsamplemain.rgb;\n" -"\n" -" if( g_light_preview == 1 )\n" -" {\n" -" vfrag = vec3(0.5);\n" -" }\n" -"\n" -" vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n" -" oColour = vec4(vfrag, 1.0);\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_standard_alphatest_uMdl; -GLuint _uniform_scene_standard_alphatest_uPv; -GLuint _uniform_scene_standard_alphatest_uPvmPrev; -GLuint _uniform_scene_standard_alphatest_uTexGarbage; -GLuint _uniform_scene_standard_alphatest_uTexMain; -GLuint _uniform_scene_standard_alphatest_uCamera; -GLuint _uniform_scene_standard_alphatest_uPlane; -GLuint _uniform_scene_standard_alphatest_g_world_depth; -GLuint _uniform_scene_standard_alphatest_uLightsArray; -GLuint _uniform_scene_standard_alphatest_uLightsIndex; -#include "shaders/scene_foliage.h" -struct vg_shader _shader_scene_foliage = { - .name = "scene_foliage", - .vs = -{ -.orig_file = "shaders/scene_foliage.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"uniform float uTime;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main(){\n" -" vec4 vsine = sin(vec4(uTime + a_co.x, uTime*0.7 + a_co.z,uTime,uTime*1.3));\n" -" vec3 co = a_co + vsine.xyz * a_norm.w * 0.5;\n" -" \n" -" vec3 world_pos0 = uMdl * vec4( co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_foliage.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"uniform sampler2D uTexMain;\n" -"uniform vec3 uCamera;\n" -"uniform vec4 uPlane;\n" -"\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.4;\n" -"#line 1 1 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 8 0 \n" -"#line 1 2 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"void main(){\n" -" compute_motion_vectors();\n" -"\n" -" vec3 vfrag = vec3(0.5,0.5,0.5);\n" -" vec4 vsamplemain = texture( uTexMain, aUv );\n" -" vec3 qnorm = aNorm.xyz;\n" -"\n" -" if( vsamplemain.a < 0.15 )\n" -" discard;\n" -"\n" -" vfrag = vsamplemain.rgb;\n" -"\n" -" if( g_light_preview == 1 ){\n" -" vfrag = vec3(0.5);\n" -" }\n" -"\n" -" vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n" -" oColour = vec4(vfrag, 1.0);\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_foliage_uMdl; -GLuint _uniform_scene_foliage_uPv; -GLuint _uniform_scene_foliage_uPvmPrev; -GLuint _uniform_scene_foliage_uTime; -GLuint _uniform_scene_foliage_uTexGarbage; -GLuint _uniform_scene_foliage_uTexMain; -GLuint _uniform_scene_foliage_uCamera; -GLuint _uniform_scene_foliage_uPlane; -GLuint _uniform_scene_foliage_g_world_depth; -GLuint _uniform_scene_foliage_uLightsArray; -GLuint _uniform_scene_foliage_uLightsIndex; -#include "shaders/scene_override.h" -struct vg_shader _shader_scene_override = { - .name = "scene_override", - .vs = -{ -.orig_file = "shaders/scene_override.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"uniform mat3 uNormalMtx;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( uNormalMtx * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_override.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"uniform sampler2D uTexMain;\n" -"uniform vec3 uCamera;\n" -"uniform vec4 uPlane;\n" -"\n" -"uniform vec4 uPlayerPos; /* w: distance to uSpawnPos */\n" -"uniform vec4 uSpawnPos; /* w: inverse distance to uPlayerPos */\n" -"uniform bool uAlphatest;\n" -"uniform vec4 uMapInfo; /* x: min, y: max, z: iso line amount */\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 12 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 13 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 14 0 \n" -"\n" -"vec2 smin( float a, float b, float k ){\n" -" float h = max( k-abs(a-b), 0.0 )/k;\n" -" float m = h*h*0.5;\n" -" float s = m*k*(1.0/2.0);\n" -"\n" -" if( a < b )\n" -" return vec2(a-s,m);\n" -" else\n" -" return vec2(b-s,1.0-m);\n" -"}\n" -"\n" -"void main(){\n" -" vec2 ssuv = gl_FragCoord.xy;\n" -" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" -" float dither = fract( vDither.g / 71.0 ) - 0.5;\n" -"\n" -" float dcam = (-8.0+distance( aCo, uCamera ))/4.0;\n" -" float dy0 = aCo.y - uMapInfo.x;\n" -" float dy1 = uMapInfo.y - aCo.y;\n" -"\n" -" if( min(min(dy0,dy1)*0.5, dcam) + dither < 0.51 ) \n" -" discard;\n" -"\n" -" compute_motion_vectors();\n" -"\n" -" vec3 vfrag = vec3(0.898,0.811,0.716);\n" -" vec3 qnorm = aNorm.xyz;\n" -"\n" -" qnorm = normalize(floor(aNorm.xyz*4.0)*0.25);\n" -" qnorm += vec3(0.001,0.0,0.0);\n" -"\n" -" if( uAlphatest ){\n" -" vec4 vSample = texture( uTexMain, aUv );\n" -" if( vSample.a < 0.5 )\n" -" discard;\n" -" }\n" -" else{\n" -" }\n" -"\n" -" vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n" -" \n" -" // dots\n" -" float d0 = distance( aCo, uPlayerPos.xyz )*2.0;\n" -" float d1 = distance( aCo, uSpawnPos.xyz );\n" -"\n" -" vec2 dm = smin( d0, d1, 10.0 );\n" -" float dd = fract(dm.x*0.2-g_realtime*0.5) * \n" -" max(0.0,1.0-dm.x*0.04) * \n" -" max(0.0,qnorm.y);\n" -" vec3 emit = mix(vec3(1.0,0.0,0.0),vec3(0.0,1.0,0.0),dm.y)*dd;\n" -"\n" -" // line\n" -" vec3 v0 = (uSpawnPos.xyz-uPlayerPos.xyz)*uSpawnPos.w;\n" -" float t = clamp( dot(aCo-uPlayerPos.xyz,v0), 0.0, uPlayerPos.w );\n" -" vec3 p0 = uPlayerPos.xyz + v0*t;\n" -" float d3 = distance(p0,aCo);\n" -" emit += vec3(fract(t*0.2-g_realtime+d3*0.2)*max(0.0,1.0-d3*0.2));\n" -"\n" -" vfrag += emit;\n" -"\n" -" if( uMapInfo.z > 0.0 ){\n" -" float height = fract( aCo.y * 0.1 );\n" -" float lg = 2.0*length(vec2(dFdx(height), dFdy(height)));\n" -" vfrag *= 1.0f+(lg*0.2*uMapInfo.z);\n" -" }\n" -"\n" -" oColour = vec4( vfrag, 1.0 );\n" -" //oColour = vec4( vfrag, 1.0 );\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_override_uMdl; -GLuint _uniform_scene_override_uPv; -GLuint _uniform_scene_override_uPvmPrev; -GLuint _uniform_scene_override_uNormalMtx; -GLuint _uniform_scene_override_uTexGarbage; -GLuint _uniform_scene_override_uTexMain; -GLuint _uniform_scene_override_uCamera; -GLuint _uniform_scene_override_uPlane; -GLuint _uniform_scene_override_uPlayerPos; -GLuint _uniform_scene_override_uSpawnPos; -GLuint _uniform_scene_override_uAlphatest; -GLuint _uniform_scene_override_uMapInfo; -GLuint _uniform_scene_override_g_world_depth; -GLuint _uniform_scene_override_uLightsArray; -GLuint _uniform_scene_override_uLightsIndex; -#include "shaders/scene_fxglow.h" -struct vg_shader _shader_scene_fxglow = { - .name = "scene_fxglow", - .vs = -{ -.orig_file = "shaders/scene_fxglow.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"uniform vec2 uUvOffset;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv + uUvOffset;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_fxglow.fs", -.static_src = -"uniform sampler2D uTexMain;\n" -"uniform vec3 uCamera;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 5 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 6 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 7 0 \n" -"\n" -"void main(){\n" -" oMotionVec = vec2(0.0);\n" -"\n" -" vec4 vsamplemain = texture( uTexMain, aUv );\n" -"\n" -" vec2 ssuv = gl_FragCoord.xy;\n" -" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" -" float dither = fract( vDither.g / 71.0 ) - 0.5;\n" -"\n" -" if( vsamplemain.a+dither<0.5 )\n" -" discard;\n" -"\n" -" oColour = vec4( vsamplemain.rgb, 1.0 );\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_fxglow_uMdl; -GLuint _uniform_scene_fxglow_uPv; -GLuint _uniform_scene_fxglow_uPvmPrev; -GLuint _uniform_scene_fxglow_uUvOffset; -GLuint _uniform_scene_fxglow_uTexMain; -GLuint _uniform_scene_fxglow_uCamera; -GLuint _uniform_scene_fxglow_g_world_depth; -GLuint _uniform_scene_fxglow_uLightsArray; -GLuint _uniform_scene_fxglow_uLightsIndex; -#include "shaders/scene_vertex_blend.h" -struct vg_shader _shader_scene_vertex_blend = { - .name = "scene_vertex_blend", - .vs = -{ -.orig_file = "shaders/scene.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_vertex_blend.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"uniform sampler2D uTexGradients;\n" -"uniform vec3 uCamera;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 6 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 7 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 8 0 \n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" vec3 vfrag = vec3(0.5,0.5,0.5);\n" -"\n" -" // ws modulation\n" -" vec4 wgarbage = vec4(0.5,0.5,0.5,1.0);\n" -" \n" -" // Creating normal patches\n" -" vec3 modnorm = (wgarbage.rgb-0.4) * 1.4;\n" -" vec3 qnorm = normalize(floor(aNorm.xyz*4.0+modnorm)*0.25);\n" -" qnorm += vec3(0.001,0.0,0.0);\n" -"\n" -" vec3 tangent0 = normalize(cross(qnorm,vec3(0.0,1.0,0.0)));\n" -" vec3 tangent1 = cross(qnorm,tangent0);\n" -" vec2 uvdiffuse = vec2( dot(tangent0,aCo), dot(tangent1,aCo) ) * 0.160;\n" -" \n" -" // Patch local noise\n" -" vec4 rgarbage = texture( uTexGarbage, uvdiffuse );\n" -"\n" -" // Colour blending\n" -" float fblendclip = step(0.380,aNorm.w + (rgarbage.r-0.5)*-1.740)*0.320;\n" -" vec2 uvgradients = aUv + vec2( fblendclip, 0.0 );\n" -"\n" -" vfrag = texture( uTexGradients, uvgradients ).rgb;\n" -" vfrag -= rgarbage.a*0.04;\n" -"\n" -" if( g_light_preview == 1 )\n" -" {\n" -" vfrag = vec3(0.5);\n" -" }\n" -"\n" -" vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n" -" oColour = vec4(vfrag, 1.0);\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_vertex_blend_uMdl; -GLuint _uniform_scene_vertex_blend_uPv; -GLuint _uniform_scene_vertex_blend_uPvmPrev; -GLuint _uniform_scene_vertex_blend_uTexGarbage; -GLuint _uniform_scene_vertex_blend_uTexGradients; -GLuint _uniform_scene_vertex_blend_uCamera; -GLuint _uniform_scene_vertex_blend_g_world_depth; -GLuint _uniform_scene_vertex_blend_uLightsArray; -GLuint _uniform_scene_vertex_blend_uLightsIndex; -#include "shaders/scene_terrain.h" -struct vg_shader _shader_scene_terrain = { - .name = "scene_terrain", - .vs = -{ -.orig_file = "shaders/scene.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_terrain.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"uniform sampler2D uTexGradients;\n" -"uniform vec3 uCamera;\n" -"uniform vec3 uSandColour;\n" -"uniform vec2 uBlendOffset;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 8 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 9 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 10 0 \n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" // Colour\n" -" // ------\n" -" vec3 vfrag = vec3(0.5,0.5,0.5);\n" -"\n" -" // ws modulation\n" -" vec4 wgarbage = texture( uTexGarbage, aCo.xz * 0.015 );\n" -" \n" -" // Creating normal patches\n" -" vec3 modnorm = (wgarbage.rgb-0.4) * 1.4;\n" -" vec3 qnorm = normalize(floor(aNorm.xyz*4.0+modnorm)*0.25);\n" -" qnorm += vec3(0.001,0.0,0.0);\n" -"\n" -" vec2 dir = normalize(qnorm.xz);\n" -" vec2 uvdiffuse = aCo.xz * 0.02;\n" -" uvdiffuse = mat2(dir.y, dir.x, -dir.x, dir.y) * uvdiffuse;\n" -" \n" -" // Patch local noise\n" -" vec4 rgarbage = texture( uTexGarbage, uvdiffuse );\n" -"\n" -" // Colour blending\n" -" float amtgrass = step(qnorm.y,0.6);\n" -" float amtsand = min(max((aCo.y - 10.0) * -0.1,0.0)*qnorm.y,1.0);\n" -" vec2 uvgradients = aUv + vec2( amtgrass + rgarbage.a*0.8 )*uBlendOffset;\n" -" vfrag = texture( uTexGradients, uvgradients ).rgb;\n" -" vfrag = mix( vfrag, uSandColour, amtsand );\n" -"\n" -" qnorm = mix( qnorm, aNorm.xyz, amtsand );\n" -" \n" -" if( g_light_preview == 1 )\n" -" {\n" -" vfrag = vec3(0.5);\n" -" }\n" -"\n" -" vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n" -" oColour = vec4(vfrag, 1.0);\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_terrain_uMdl; -GLuint _uniform_scene_terrain_uPv; -GLuint _uniform_scene_terrain_uPvmPrev; -GLuint _uniform_scene_terrain_uTexGarbage; -GLuint _uniform_scene_terrain_uTexGradients; -GLuint _uniform_scene_terrain_uCamera; -GLuint _uniform_scene_terrain_uSandColour; -GLuint _uniform_scene_terrain_uBlendOffset; -GLuint _uniform_scene_terrain_g_world_depth; -GLuint _uniform_scene_terrain_uLightsArray; -GLuint _uniform_scene_terrain_uLightsIndex; -#include "shaders/scene_route.h" -struct vg_shader _shader_scene_route = { - .name = "scene_route", - .vs = -{ -.orig_file = "shaders/scene_override.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"uniform mat3 uNormalMtx;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( uNormalMtx * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_route.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"uniform sampler2D uTexGradients;\n" -"uniform vec3 uCamera;\n" -"uniform vec4 uColour;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 7 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 8 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float filtered_stripe( in float p, in float ddx, in float ddy )\n" -"{\n" -" float w = max(abs(ddx), abs(ddy)) + 0.02;\n" -" float i = (abs(fract((p-0.5*w)/2.0)-0.5)-abs(fract((p+0.5*w)/2.0)-0.5))/w;\n" -" return 0.5 - i;\n" -"}\n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" vec3 vfrag = vec3(0.5,0.5,0.5);\n" -"\n" -" // ws modulation\n" -" vec4 wgarbage = texture( uTexGarbage, aCo.xz * 0.015 );\n" -"\n" -" // Creating normal patches\n" -" vec3 modnorm = (wgarbage.rgb-0.4) * 1.4;\n" -" vec3 qnorm = normalize(floor(aNorm.xyz*4.0+modnorm)*0.25);\n" -" qnorm += vec3(0.001,0.0,0.0);\n" -"\n" -" vec3 tangent0 = normalize(cross(qnorm,vec3(0.0,1.0,0.0)));\n" -" vec3 tangent1 = cross(qnorm,tangent0);\n" -" vec2 uvdiffuse = vec2( dot(tangent0,aCo), dot(tangent1,aCo) ) * 0.035;\n" -" \n" -" // Patch local noise\n" -" vec4 rgarbage = texture( uTexGarbage, uvdiffuse );\n" -"\n" -" vfrag = pow(uColour.rgb,vec3(1.0/2.2));\n" -" vfrag -= rgarbage.a*0.1;\n" -"\n" -" if( wgarbage.g < 0.1 )\n" -" discard;\n" -"\n" -" float movep = (aUv.x + abs(aUv.y-0.5)*0.4 - g_realtime)*2.0;\n" -" float stripe = filtered_stripe( movep, dFdx(movep), dFdy(movep) );\n" -" vfrag *= 0.9+stripe*uColour.a; \n" -"\n" -" if( g_light_preview == 1 )\n" -" {\n" -" vfrag = vec3(0.5);\n" -" }\n" -"\n" -" // Lighting\n" -" oColour = vec4( scene_compute_lighting( vfrag, qnorm, aWorldCo ), 1.0 );\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_route_uMdl; -GLuint _uniform_scene_route_uPv; -GLuint _uniform_scene_route_uPvmPrev; -GLuint _uniform_scene_route_uNormalMtx; -GLuint _uniform_scene_route_uTexGarbage; -GLuint _uniform_scene_route_uTexGradients; -GLuint _uniform_scene_route_uCamera; -GLuint _uniform_scene_route_uColour; -GLuint _uniform_scene_route_g_world_depth; -GLuint _uniform_scene_route_uLightsArray; -GLuint _uniform_scene_route_uLightsIndex; -#include "shaders/scene_depth.h" -struct vg_shader _shader_scene_depth = { - .name = "scene_depth", - .vs = -{ -.orig_file = "shaders/scene.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_depth.fs", -.static_src = -"out vec4 FragColor;\n" -"\n" -"uniform vec3 uCamera;\n" -"uniform vec3 uBoard0;\n" -"uniform vec3 uBoard1;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 8 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"// Water blending\n" -"// ==============\n" -"\n" -"float water_depth( vec3 pos, vec3 halfview )\n" -"{\n" -" vec3 pnorm = g_water_plane.xyz;\n" -" float pdist = g_water_plane.w;\n" -"\n" -" float d = dot( pnorm, halfview );\n" -" float t = dot((pnorm*pdist - pos), pnorm) / d;\n" -"\n" -" // TODO: Make g_water_fog a material param\n" -" return t * 0.3;//g_water_fog;\n" -"}\n" -"\n" -"void main()\n" -"{\n" -" vec3 halfview = normalize( uCamera - aWorldCo );\n" -" float depth = water_depth( aWorldCo, halfview );\n" -" FragColor = vec4( depth, 0.0, 0.0, 0.0 );\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_depth_uMdl; -GLuint _uniform_scene_depth_uPv; -GLuint _uniform_scene_depth_uPvmPrev; -GLuint _uniform_scene_depth_uCamera; -GLuint _uniform_scene_depth_uBoard0; -GLuint _uniform_scene_depth_uBoard1; -GLuint _uniform_scene_depth_g_world_depth; -GLuint _uniform_scene_depth_uLightsArray; -GLuint _uniform_scene_depth_uLightsIndex; -#include "shaders/scene_position.h" -struct vg_shader _shader_scene_position = { - .name = "scene_position", - .vs = -{ -.orig_file = "shaders/scene.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_position.fs", -.static_src = -"out vec4 FragColor;\n" -"\n" -"uniform vec3 uCamera;\n" -"uniform vec3 uBoard0;\n" -"uniform vec3 uBoard1;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 8 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"void main()\n" -"{\n" -" float height_full = aWorldCo.y;\n" -" float height_water = height_full;\n" -"\n" -" if( height_water > (g_water_plane.y * g_water_plane.w) + 2.0 )\n" -" height_water = -99999.9;\n" -"\n" -" FragColor = vec4( height_full, height_water, 0.0, 0.0 );\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_position_uMdl; -GLuint _uniform_scene_position_uPv; -GLuint _uniform_scene_position_uPvmPrev; -GLuint _uniform_scene_position_uCamera; -GLuint _uniform_scene_position_uBoard0; -GLuint _uniform_scene_position_uBoard1; -GLuint _uniform_scene_position_g_world_depth; -GLuint _uniform_scene_position_uLightsArray; -GLuint _uniform_scene_position_uLightsIndex; -#include "shaders/scene_cubemapped.h" -struct vg_shader _shader_scene_cubemapped = { - .name = "scene_cubemapped", - .vs = -{ -.orig_file = "shaders/scene.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_cubemapped.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"uniform sampler2D uTexMain;\n" -"uniform samplerCube uTexCubemap;\n" -"uniform vec3 uCamera;\n" -"uniform vec4 uPlane;\n" -"uniform vec4 uColour;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 9 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 10 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 11 0 \n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" vec3 vfrag = vec3(0.5,0.5,0.5);\n" -" vec4 vsamplemain = texture( uTexMain, aUv );\n" -" vec4 wgarbage = texture( uTexGarbage, aCo.xz * 0.0015 + aCo.yx*0.002 );\n" -" vec3 qnorm = aNorm.xyz;\n" -" vfrag = vsamplemain.rgb;\n" -"\n" -" if( g_light_preview == 1 ){\n" -" vfrag = vec3(0.5);\n" -" }\n" -"\n" -" vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n" -" oColour = vec4( vfrag, 1.0 );\n" -"\n" -" vec3 halfdir = normalize( aWorldCo - uCamera );\n" -" vec3 reflectdir = reflect( halfdir, qnorm );\n" -" oColour = mix( oColour, \n" -" vec4(texture(uTexCubemap,reflectdir).rgb * uColour.rgb, 1.0),\n" -" uColour.a*wgarbage.b );\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_cubemapped_uMdl; -GLuint _uniform_scene_cubemapped_uPv; -GLuint _uniform_scene_cubemapped_uPvmPrev; -GLuint _uniform_scene_cubemapped_uTexGarbage; -GLuint _uniform_scene_cubemapped_uTexMain; -GLuint _uniform_scene_cubemapped_uTexCubemap; -GLuint _uniform_scene_cubemapped_uCamera; -GLuint _uniform_scene_cubemapped_uPlane; -GLuint _uniform_scene_cubemapped_uColour; -GLuint _uniform_scene_cubemapped_g_world_depth; -GLuint _uniform_scene_cubemapped_uLightsArray; -GLuint _uniform_scene_cubemapped_uLightsIndex; -#include "shaders/scene_water.h" -struct vg_shader _shader_scene_water = { - .name = "scene_water", - .vs = -{ -.orig_file = "shaders/scene.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_water.fs", -.static_src = -"uniform sampler2D uTexMain;\n" -"uniform sampler2D uTexDudv;\n" -"uniform sampler2D uTexBack;\n" -"\n" -"uniform vec2 uInvRes;\n" -"uniform float uTime;\n" -"uniform vec3 uCamera;\n" -"uniform float uSurfaceY;\n" -"uniform vec3 uBoard0;\n" -"uniform vec3 uBoard1;\n" -"\n" -"uniform vec3 uShoreColour;\n" -"uniform vec3 uOceanColour;\n" -"uniform float uFresnel;\n" -"uniform float uWaterScale;\n" -"uniform vec4 uWaveSpeed;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 19 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 20 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 21 0 \n" -"\n" -"// Pasted from common_world.glsl\n" -"vec3 water_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" float light_mask = compute_board_shadow();\n" -"\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" return diffuse * total_light;\n" -"}\n" -"\n" -"vec4 water_surf( vec3 halfview, vec3 vnorm, float depthvalue, \n" -" vec4 beneath, vec4 above, vec4 dudva )\n" -"{\n" -" vec3 surface_tint = mix(uShoreColour, uOceanColour, depthvalue);\n" -"\n" -" float ffresnel = pow(1.0-dot( vnorm, halfview ),uFresnel);\n" -"\n" -" vec3 lightdir = vec3(0.95,0.0,-0.3);\n" -" vec3 specdir = reflect( -lightdir, vnorm );\n" -" float spec = pow(max(dot(halfview,specdir),0.0),20.0)*0.3;\n" -" \n" -" // Depth \n" -" float depthblend = pow( beneath.r, 0.8 );\n" -"\n" -" // Foam\n" -" float fband = fract( aCo.z*0.02+uTime*0.1+depthvalue*10.0 );\n" -" fband = step( fband+dudva.a*0.8, 0.3 ) * max((1.0-depthvalue*4.0),0.0);\n" -"\n" -" vec4 surf = mix( vec4(surface_tint,depthblend), \n" -" vec4(1.0,1.0,1.0,0.5), fband );\n" -" surf.rgb = water_compute_lighting( surf.rgb, aNorm.xyz, aWorldCo );\n" -" surf.rgb = mix(surf.rgb, above.rgb, ffresnel );\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" surf.rgb = scene_apply_fog( surf.rgb, fog_colour, \n" -" distance(uCamera, aWorldCo) );\n" -"\n" -" return surf;\n" -"}\n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" // Create texture coords\n" -" vec2 ssuv = gl_FragCoord.xy*uInvRes;\n" -" \n" -" // Surface colour composite\n" -" float depthvalue = clamp( -world_water_depth(aCo)*(1.0/25.0), 0.0,1.0 );\n" -"\n" -" vec2 world_coord = aCo.xz * uWaterScale;\n" -" //TODO: Material param ( 0.008, 0.006, 0.003, 0.03 );\n" -" vec4 time_offsets = vec4( uTime ) * vec4( 0.08, -0.08, -0.03, -0.01 );\n" -" vec4 dudva = texture( uTexDudv, world_coord + time_offsets.xy )-0.5;\n" -" vec4 dudvb = texture( uTexDudv, world_coord *7.0 - time_offsets.zw )-0.5;\n" -"\n" -" vec3 surfnorm = dudva.rgb + dudvb.rgb;\n" -" surfnorm = normalize(vec3(0.0,1.0,0.0) + dudva.xyz*0.4 + dudvb.xyz*0.1);\n" -" \n" -" // Lighting\n" -" vec3 halfview = -normalize( aCo-uCamera );\n" -"\n" -" // Sample textures\n" -" vec4 above = texture( uTexMain, ssuv+ surfnorm.xz*0.2 );\n" -" vec4 beneath = texture( uTexBack, ssuv );\n" -"\n" -" // Fog\n" -" float fdist = pow(length( aCo.xz-uCamera.xz ) * 0.00047, 2.6);\n" -"\n" -" // Composite\n" -" vec4 vsurface = water_surf( halfview, surfnorm, depthvalue, beneath, above, dudva );\n" -" vsurface.a -= fdist;\n" -"\n" -" oColour = vsurface;\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_water_uMdl; -GLuint _uniform_scene_water_uPv; -GLuint _uniform_scene_water_uPvmPrev; -GLuint _uniform_scene_water_uTexMain; -GLuint _uniform_scene_water_uTexDudv; -GLuint _uniform_scene_water_uTexBack; -GLuint _uniform_scene_water_uInvRes; -GLuint _uniform_scene_water_uTime; -GLuint _uniform_scene_water_uCamera; -GLuint _uniform_scene_water_uSurfaceY; -GLuint _uniform_scene_water_uBoard0; -GLuint _uniform_scene_water_uBoard1; -GLuint _uniform_scene_water_uShoreColour; -GLuint _uniform_scene_water_uOceanColour; -GLuint _uniform_scene_water_uFresnel; -GLuint _uniform_scene_water_uWaterScale; -GLuint _uniform_scene_water_uWaveSpeed; -GLuint _uniform_scene_water_g_world_depth; -GLuint _uniform_scene_water_uLightsArray; -GLuint _uniform_scene_water_uLightsIndex; -#include "shaders/scene_water_fast.h" -struct vg_shader _shader_scene_water_fast = { - .name = "scene_water_fast", - .vs = -{ -.orig_file = "shaders/scene.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_water_fast.fs", -.static_src = -"uniform sampler2D uTexDudv;\n" -"\n" -"uniform float uTime;\n" -"uniform vec3 uCamera;\n" -"uniform float uSurfaceY;\n" -"uniform vec3 uBoard0;\n" -"uniform vec3 uBoard1;\n" -"\n" -"uniform vec3 uShoreColour;\n" -"uniform vec3 uOceanColour;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 13 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 14 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 15 0 \n" -"\n" -"vec4 water_surf( vec3 halfview, vec3 vnorm, float depthvalue )\n" -"{\n" -" vec3 surface_tint = mix(uShoreColour, uOceanColour, depthvalue);\n" -"\n" -" float ffresnel = pow(1.0-dot( vnorm, halfview ),5.0);\n" -"\n" -" vec3 lightdir = vec3(0.95,0.0,-0.3);\n" -" vec3 specdir = reflect( -lightdir, vnorm );\n" -" float spec = pow(max(dot(halfview,specdir),0.0),20.0)*0.3;\n" -" \n" -" return vec4( surface_tint + spec, max(min(depthvalue*4.0, 1.0),0.0) );\n" -"}\n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" // Surface colour composite\n" -" float depthvalue = clamp( -world_water_depth( aCo )*(1.0/25.0), 0.0, 1.0 );\n" -"\n" -" vec2 world_coord = aCo.xz * 0.008;\n" -" vec4 time_offsets = vec4( uTime ) * vec4( 0.008, 0.006, 0.003, 0.03 );\n" -" vec4 dudva = texture( uTexDudv, world_coord + time_offsets.xy )-0.5;\n" -" vec4 dudvb = texture( uTexDudv, world_coord *7.0 - time_offsets.zw )-0.5;\n" -"\n" -" vec3 surfnorm = dudva.rgb + dudvb.rgb;\n" -" surfnorm = normalize(vec3(0.0,1.0,0.0) + dudva.xyz*0.4 + dudvb.xyz*0.1);\n" -" \n" -" // Foam\n" -" float fband = fract( aCo.z*0.02+uTime*0.1+depthvalue*10.0 );\n" -" fband = step( fband+dudva.a*0.8, 0.3 ) * max((1.0-depthvalue*4.0),0.0);\n" -"\n" -" // Lighting\n" -" vec3 halfview = -normalize( aCo-uCamera );\n" -"\n" -" // Fog\n" -" float fdist = pow(length( aCo.xz-uCamera.xz ) * 0.00047, 2.6);\n" -"\n" -" // Composite\n" -" vec4 vsurface = water_surf( halfview, surfnorm, depthvalue );\n" -" vsurface.a -= fdist;\n" -" oColour = mix( vsurface, vec4(1.0,1.0,1.0,0.5), fband );\n" -" oColour.rgb = scene_compute_lighting( oColour.rgb, aNorm.xyz, aWorldCo );\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_water_fast_uMdl; -GLuint _uniform_scene_water_fast_uPv; -GLuint _uniform_scene_water_fast_uPvmPrev; -GLuint _uniform_scene_water_fast_uTexDudv; -GLuint _uniform_scene_water_fast_uTime; -GLuint _uniform_scene_water_fast_uCamera; -GLuint _uniform_scene_water_fast_uSurfaceY; -GLuint _uniform_scene_water_fast_uBoard0; -GLuint _uniform_scene_water_fast_uBoard1; -GLuint _uniform_scene_water_fast_uShoreColour; -GLuint _uniform_scene_water_fast_uOceanColour; -GLuint _uniform_scene_water_fast_g_world_depth; -GLuint _uniform_scene_water_fast_uLightsArray; -GLuint _uniform_scene_water_fast_uLightsIndex; -#include "shaders/scene_scoretext.h" -struct vg_shader _shader_scene_scoretext = { - .name = "scene_scoretext", - .vs = -{ -.orig_file = "shaders/scene_sfd.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec4 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"uniform vec3 uInfo;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" float w = ((a_norm.w)-0.5)*2.0 + fract(uInfo.z) - 0.0;\n" -" float c = -cos(w*0.6);\n" -" float s = -sin(w*0.6);\n" -" float r = 0.2;\n" -"\n" -" float w1 = clamp( w*4.0 - a_co.y*10.0, -1.0, 1.0 ) * (3.14159265*0.5);\n" -" float c1 = cos(w1);\n" -" float s1 = sin(w1);\n" -"\n" -" float yoff = step(0.01,fract(uInfo.z))*-0.5;\n" -"\n" -" mat4x3 mlocal;\n" -" mlocal[0] = vec3(c1, s1,0.0);\n" -" mlocal[1] = vec3(-s1,c1,0.0);\n" -" mlocal[2] = vec3(0.0,0.0,1.0);\n" -" mlocal[3] = vec3(c*r,uInfo.y*0.875 + s*r,uInfo.x*0.5);\n" -"\n" -" vec3 local_pos0 = mlocal * vec4( a_co, 1.0 );\n" -" vec3 world_pos0 = uMdl * vec4( local_pos0, 1.0 );\n" -"\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( local_pos0, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv + vec2( floor(uInfo.z+0.5)*(1.0/64.0), yoff );\n" -" aNorm = vec4( mat3(uMdl) * mat3(mlocal) * a_norm.xyz, a_norm.w );\n" -" aCo = a_co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_standard.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"uniform sampler2D uTexMain;\n" -"uniform vec3 uCamera;\n" -"uniform vec4 uPlane;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 7 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 8 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" vec3 vfrag = vec3(0.5,0.5,0.5);\n" -" vec4 vsamplemain = texture( uTexMain, aUv );\n" -" vec3 qnorm = aNorm.xyz;\n" -"\n" -" vfrag = vsamplemain.rgb;\n" -"\n" -" if( g_light_preview == 1 )\n" -" {\n" -" vfrag = vec3(0.5);\n" -" }\n" -"\n" -" vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n" -" oColour = vec4( vfrag, 1.0 );\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_scoretext_uMdl; -GLuint _uniform_scene_scoretext_uPv; -GLuint _uniform_scene_scoretext_uPvmPrev; -GLuint _uniform_scene_scoretext_uInfo; -GLuint _uniform_scene_scoretext_uTexGarbage; -GLuint _uniform_scene_scoretext_uTexMain; -GLuint _uniform_scene_scoretext_uCamera; -GLuint _uniform_scene_scoretext_uPlane; -GLuint _uniform_scene_scoretext_g_world_depth; -GLuint _uniform_scene_scoretext_uLightsArray; -GLuint _uniform_scene_scoretext_uLightsIndex; -#include "shaders/scene_font.h" -struct vg_shader _shader_scene_font = { - .name = "scene_font", - .vs = -{ -.orig_file = "shaders/model_font.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec3 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 6 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"uniform vec4 uOffset;\n" -"\n" -"out vec2 aUv;\n" -"out vec4 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 co = a_co*uOffset.w+uOffset.xyz;\n" -" vec3 world_pos0 = uMdl * vec4( co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -"\n" -" aUv = a_uv;\n" -" aNorm = vec4( mat3(uMdl) * a_norm, 0.0 );\n" -" aCo = co;\n" -" aWorldCo = world_pos0;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/scene_font.fs", -.static_src = -"uniform sampler2D uTexGarbage; // unused\n" -"uniform sampler2D uTexMain; // unused\n" -"uniform vec3 uCamera;\n" -"uniform float uTime;\n" -"uniform float uOpacity;\n" -"uniform float uColourize;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 9 0 \n" -"#line 1 2 \n" -"// :D\n" -"\n" -"in vec2 aUv;\n" -"in vec4 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"float sdLine( vec3 p, vec3 a, vec3 b )\n" -"{\n" -" vec3 pa = p - a;\n" -" vec3 ba = b - a;\n" -"\n" -" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n" -" return length( pa - ba*h );\n" -"}\n" -"\n" -"float compute_board_shadow()\n" -"{\n" -" // player shadow\n" -" float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n" -" g_board_1.xyz )-0.1 );\n" -" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n" -" player_shadow *= player_shadow*player_shadow*player_shadow;\n" -"\n" -" return 1.0 - player_shadow*0.8;\n" -"}\n" -"\n" -"vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )\n" -"{\n" -" return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n" -"}\n" -"\n" -"#line 10 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 11 0 \n" -"\n" -"vec3 pal( float t ){\n" -" vec3 a = vec3(0.30,0.3,0.3);\n" -" vec3 b = vec3(0.8);\n" -" vec3 c = vec3(0.28,0.3,0.4);\n" -" vec3 d = vec3(0.00,0.1,0.1);\n" -" return a + b*cos( 6.28318*(c*t+d) );\n" -"}\n" -"\n" -"void main(){\n" -" compute_motion_vectors();\n" -" vec3 vfrag = vec3(0.5,0.5,0.5);\n" -" vec3 qnorm = aNorm.xyz;\n" -"\n" -" //vec4 vsamplemain = texture( uTexMain, aUv );\n" -" //vfrag = vsamplemain.rgb;\n" -"\n" -" vec4 spread0 = uTime*0.0002*vec4( 17.3,-19.6, 23.2,-47.7 );\n" -" vec4 spread1 = uTime*0.0002*vec4( -13.3, 12.6,-28.2, 14.7 );\n" -"\n" -" vec2 p = aCo.xy + vec2(0.3);\n" -" float a = atan( p.y/p.x );\n" -" vec4 v0 = step( vec4(0.5), fract(vec4(a) + spread0) );\n" -" vec4 v1 = step( vec4(0.5), fract(vec4(a) + spread1) );\n" -"\n" -" float d = ( v0.x+v0.y+v0.z+v0.w +\n" -" v1.x+v1.y+v1.z+v1.w ) * 0.125;\n" -" \n" -" float dither = fract(dot(vec2(171.0,231.0),gl_FragCoord.xy)/71.0);\n" -" float x = d*0.8+length(p)*0.3;\n" -" x = (floor(x*8.0) + step(dither, fract(x * 8.0))) / 8.0;\n" -"\n" -" if( x + (uOpacity*2.0-1.0) < 0.5 ) \n" -" discard;\n" -"\n" -" vfrag = mix( vec3(x), pal( x ), uColourize );\n" -"\n" -" if( g_light_preview == 1 ){\n" -" vfrag = vec3(0.5);\n" -" }\n" -"\n" -" vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n" -" oColour = vec4( vfrag, 1.0 );\n" -"}\n" -""}, -}; - -GLuint _uniform_scene_font_uMdl; -GLuint _uniform_scene_font_uPv; -GLuint _uniform_scene_font_uPvmPrev; -GLuint _uniform_scene_font_uOffset; -GLuint _uniform_scene_font_uTexGarbage; -GLuint _uniform_scene_font_uTexMain; -GLuint _uniform_scene_font_uCamera; -GLuint _uniform_scene_font_uTime; -GLuint _uniform_scene_font_uOpacity; -GLuint _uniform_scene_font_uColourize; -GLuint _uniform_scene_font_g_world_depth; -GLuint _uniform_scene_font_uLightsArray; -GLuint _uniform_scene_font_uLightsIndex; -#include "shaders/model_sky.h" -struct vg_shader _shader_model_sky = { - .name = "model_sky", - .vs = -{ -.orig_file = "shaders/model.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec3 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"layout (location=3) in vec4 a_colour;\n" -"layout (location=4) in vec4 a_weights;\n" -"layout (location=5) in ivec4 a_groups;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec4 aColour;\n" -"out vec2 aUv;\n" -"out vec3 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -" aWorldCo = world_pos0;\n" -" aColour = a_colour;\n" -" aUv = a_uv;\n" -" aNorm = normalize( mat3(uMdl) * a_norm );\n" -" aCo = a_co;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/model_sky.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"\n" -"in vec4 aColour;\n" -"in vec2 aUv;\n" -"in vec3 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"// Spooky!\n" -"const vec3 uCamera = vec3(0.0);\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 13 0 \n" -"#line 1 2 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 14 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 15 0 \n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" vec3 rd = normalize(aNorm);\n" -"\n" -" float fmove = g_time * 5.0;\n" -" vec2 cloudplane = (rd.xz / (rd.y*sign(rd.y))) * 0.025;\n" -" vec4 clouds1 = texture( uTexGarbage, cloudplane + vec2(0.1,0.4)*fmove*2.0 );\n" -" vec4 clouds2 = texture( uTexGarbage, cloudplane*2.0 + vec2(0.3,0.1)*fmove );\n" -"\n" -" float cloud_d = max(clouds1.b*clouds2.r -0.2 - clouds2.g*0.4,0.0);\n" -" float cloud_e = pow(cloud_d,1.5)*pow(abs(rd.y),0.3)*2.0;\n" -"\n" -" oColour = vec4( clearskies_sky( -rd ) ,1.0);\n" -"\n" -" vec3 cloud_colour = mix( mix(g_nightsky_colour.rgb,vec3(1.0),g_day_phase), \n" -" g_sunset_colour.rgb, g_sunset_phase );\n" -"\n" -" oColour.rgb = mix( oColour.rgb, cloud_colour, cloud_e );\n" -"}\n" -""}, -}; - -GLuint _uniform_model_sky_uMdl; -GLuint _uniform_model_sky_uPv; -GLuint _uniform_model_sky_uPvmPrev; -GLuint _uniform_model_sky_uTexGarbage; -GLuint _uniform_model_sky_g_world_depth; -GLuint _uniform_model_sky_uLightsArray; -GLuint _uniform_model_sky_uLightsIndex; -#include "shaders/model_sky_space.h" -struct vg_shader _shader_model_sky_space = { - .name = "model_sky_space", - .vs = -{ -.orig_file = "shaders/model.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec3 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"layout (location=3) in vec4 a_colour;\n" -"layout (location=4) in vec4 a_weights;\n" -"layout (location=5) in ivec4 a_groups;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec4 aColour;\n" -"out vec2 aUv;\n" -"out vec3 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -" aWorldCo = world_pos0;\n" -" aColour = a_colour;\n" -" aUv = a_uv;\n" -" aNorm = normalize( mat3(uMdl) * a_norm );\n" -" aCo = a_co;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/model_sky_space.fs", -.static_src = -"uniform sampler2D uTexGarbage;\n" -"\n" -"in vec4 aColour;\n" -"in vec2 aUv;\n" -"in vec3 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"// Spooky!\n" -"const vec3 uCamera = vec3(0.0);\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 13 0 \n" -"#line 1 2 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 14 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 15 0 \n" -"\n" -"float stars1( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"void main(){\n" -" compute_motion_vectors();\n" -"\n" -" vec3 rd = -normalize(aNorm);\n" -"\n" -" float star = 0.0;\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( rd, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n" -" }\n" -"\n" -" oColour = vec4( vec3(star*20.0), 1.0);\n" -"}\n" -""}, -}; - -GLuint _uniform_model_sky_space_uMdl; -GLuint _uniform_model_sky_space_uPv; -GLuint _uniform_model_sky_space_uPvmPrev; -GLuint _uniform_model_sky_space_uTexGarbage; -GLuint _uniform_model_sky_space_g_world_depth; -GLuint _uniform_model_sky_space_uLightsArray; -GLuint _uniform_model_sky_space_uLightsIndex; -#include "shaders/model_menu.h" -struct vg_shader _shader_model_menu = { - .name = "model_menu", - .vs = -{ -.orig_file = "shaders/model.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec3 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"layout (location=3) in vec4 a_colour;\n" -"layout (location=4) in vec4 a_weights;\n" -"layout (location=5) in ivec4 a_groups;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec4 aColour;\n" -"out vec2 aUv;\n" -"out vec3 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -" aWorldCo = world_pos0;\n" -" aColour = a_colour;\n" -" aUv = a_uv;\n" -" aNorm = normalize( mat3(uMdl) * a_norm );\n" -" aCo = a_co;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/model_menu.fs", -.static_src = -"out vec4 FragColor;\n" -"\n" -"uniform sampler2D uTexMain;\n" -"uniform vec4 uColour;\n" -"\n" -"in vec4 aColour;\n" -"in vec2 aUv;\n" -"in vec3 aNorm;\n" -"in vec3 aCo;\n" -"\n" -"void main()\n" -"{\n" -" vec4 diffuse = texture( uTexMain, aUv );\n" -"\n" -" if( diffuse.a < 0.5 )\n" -" discard;\n" -"\n" -" FragColor = vec4( diffuse.rgb, 1.0 ) * uColour;\n" -"}\n" -""}, -}; - -GLuint _uniform_model_menu_uMdl; -GLuint _uniform_model_menu_uPv; -GLuint _uniform_model_menu_uPvmPrev; -GLuint _uniform_model_menu_uTexMain; -GLuint _uniform_model_menu_uColour; -#include "shaders/model_character_view.h" -struct vg_shader _shader_model_character_view = { - .name = "model_character_view", - .vs = -{ -.orig_file = "shaders/model_skinned.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec3 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"layout (location=3) in vec4 a_colour;\n" -"layout (location=4) in vec4 a_weights;\n" -"layout (location=5) in ivec4 a_groups;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"uniform mat4 uPv;\n" -"uniform mat4x3 uTransforms[32];\n" -"\n" -"out vec4 aColour;\n" -"out vec2 aUv;\n" -"out vec3 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec4 co_local = vec4( a_co, 1.0 );\n" -" vec3 co0 = uTransforms[ a_groups[0] ] * co_local;\n" -" vec3 co1 = uTransforms[ a_groups[1] ] * co_local;\n" -" vec3 co2 = uTransforms[ a_groups[2] ] * co_local;\n" -" vec3 n0 = mat3(uTransforms[ a_groups[0] ]) * a_norm;\n" -" vec3 n1 = mat3(uTransforms[ a_groups[1] ]) * a_norm;\n" -" vec3 n2 = mat3(uTransforms[ a_groups[2] ]) * a_norm;\n" -"\n" -" vec3 world_pos = co0*a_weights[0] + co1*a_weights[1] + co2*a_weights[2];\n" -" vec3 world_normal = n0*a_weights[0] + n1*a_weights[1] + n2*a_weights[2];\n" -" \n" -" gl_Position = uPv * vec4( world_pos, 1.0 );\n" -" aColour = a_colour;\n" -" aUv = a_uv;\n" -" aNorm = world_normal;\n" -" aCo = a_co;\n" -" aWorldCo = world_pos;\n" -"\n" -" // TODO: motion vectors\n" -" aMotionVec0 = vec3(1.0);\n" -" aMotionVec1 = vec3(1.0);\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/model_character_view.fs", -.static_src = -"uniform sampler2D uTexMain;\n" -"uniform vec3 uCamera;\n" -"\n" -"in vec4 aColour;\n" -"in vec2 aUv;\n" -"in vec3 aNorm;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"#line 1 1 \n" -"// :D\n" -"const float CLEARSKIES_LIGHT_DOT_MIN = 0.0;\n" -"\n" -"#line 11 0 \n" -"#line 1 2 \n" -"layout (location = 0) out vec4 oColour;\n" -"\n" -"// OpenGL wiki: Recommends do not use vec3 because of drivers. hence the v4s...\n" -"layout (std140) uniform ub_world_lighting\n" -"{\n" -" vec4 g_cube_min;\n" -" vec4 g_cube_inv_range;\n" -"\n" -" vec4 g_water_plane;\n" -" vec4 g_depth_bounds;\n" -"\n" -" vec4 g_daysky_colour;\n" -" vec4 g_nightsky_colour;\n" -" vec4 g_sunset_colour;\n" -" vec4 g_ambient_colour;\n" -" vec4 g_sunset_ambient;\n" -" vec4 g_sun_colour;\n" -" vec4 g_sun_dir;\n" -" vec4 g_board_0;\n" -" vec4 g_board_1;\n" -"\n" -" float g_water_fog;\n" -" float g_time;\n" -" float g_realtime;\n" -" float g_shadow_length;\n" -" float g_shadow_spread;\n" -"\n" -" float g_time_of_day;\n" -" float g_day_phase;\n" -" float g_sunset_phase;\n" -"\n" -" int g_light_preview;\n" -" int g_shadow_samples;\n" -"\n" -" int g_debug_indices;\n" -" int g_debug_complexity;\n" -"};\n" -"\n" -"uniform sampler2D g_world_depth;\n" -"uniform samplerBuffer uLightsArray;\n" -"uniform usampler3D uLightsIndex;\n" -"\n" -"#line 1 1 \n" -"//const vec3 DAYSKY_COLOUR = vec3( 0.37, 0.54, 0.97 );\n" -"//const vec3 NIGHTSKY_COLOUR = vec3( 0.03, 0.05, 0.20 );\n" -"//const vec3 SUNSET_COLOUR = vec3( 1.00, 0.32, 0.01 );\n" -"//const vec3 AMBIENT_COLOUR = vec3( 0.13, 0.17, 0.35 );\n" -"//const vec3 SUNSET_AMBIENT = vec3( 0.25, 0.17, 0.51 );\n" -"//const vec3 SUN_COLOUR = vec3( 1.10, 0.89, 0.35 );\n" -"\n" -"const float SUN_ANGLE = 0.0001;\n" -"const float PI = 3.14159265358979323846264;\n" -"\n" -"//struct world_info\n" -"//{\n" -"// float time,\n" -"// time_of_day,\n" -"// day_phase,\n" -"// sunset_phase;\n" -"// \n" -"// vec3 sun_dir;\n" -"//};\n" -"\n" -"vec3 rand33(vec3 p3)\n" -"{\n" -" p3 = fract(p3 * vec3(.1031, .1030, .0973));\n" -" p3 += dot(p3, p3.yxz+33.33);\n" -" return fract((p3.xxy + p3.yxx)*p3.zyx);\n" -"}\n" -"\n" -"float stars( vec3 rd, float rr, float size ){\n" -" vec3 co = rd * rr;\n" -"\n" -" float a = atan(co.y, length(co.xz)) + 4.0 * PI;\n" -"\n" -" float spaces = 1.0 / rr;\n" -" size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;\n" -" a -= mod(a, spaces) - spaces * 0.5;\n" -"\n" -" float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);\n" -" \n" -" float plane = atan(co.z, co.x) + 4.0 * PI;\n" -" plane = plane - mod(plane, PI / count);\n" -"\n" -" vec2 delta = rand33(vec3(plane, a, 0.0)).xy;\n" -"\n" -" float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;\n" -" float ydist = sqrt(rr * rr - level * level);\n" -" float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);\n" -" vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);\n" -" float star = smoothstep(size, 0.0, distance(center, co));\n" -" return star;\n" -"}\n" -"\n" -"float luminance( vec3 v )\n" -"{\n" -" return dot( v, vec3(0.2126, 0.7052, 0.0722) );\n" -"}\n" -"\n" -"vec3 clearskies_ambient( vec3 dir )\n" -"{\n" -" float sun_azimuth = g_sunset_phase * (dot( dir.xz, g_sun_dir.xz )*0.4+0.6);\n" -" float sky_gradient = dir.y;\n" -" \n" -" /* Blend phase colours */\n" -" vec3 ambient = g_daysky_colour.rgb * (g_day_phase-g_sunset_phase*0.1);\n" -" ambient += g_sunset_colour.rgb * (1.0-dir.y*0.5)*sun_azimuth;\n" -" ambient += g_nightsky_colour.rgb * (1.0-g_day_phase);\n" -" \n" -" /* Add gradient */\n" -" ambient -= sky_gradient * luminance(ambient)*1.6;\n" -" \n" -" return ambient;\n" -"}\n" -"\n" -"vec3 clearskies_sky( vec3 ray_dir )\n" -"{\n" -" ray_dir.y = abs( ray_dir.y );\n" -" vec3 sky_colour = clearskies_ambient( ray_dir );\n" -" \n" -" /* Sun */\n" -" float sun_theta = dot( ray_dir, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 + SUN_ANGLE );\n" -" float sun_shape = pow( sun_size, 2000.0 );\n" -" sun_shape += sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" \n" -" float star = 0.0;\n" -" float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n" -"\n" -" if( star_blend > 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 12 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 13 0 \n" -"#line 1 4 \n" -"uniform sampler2D uTexSceneDepth;\n" -"uniform vec3 uInverseRatioDepth;\n" -"uniform vec3 uInverseRatioMain;\n" -"uniform int uDepthMode;\n" -"uniform float uDitherCutoff;\n" -"\n" -"float linear_depth( float depth, float near, float far ) {\n" -" float z = depth * 2.0 - 1.0;\n" -" return (2.0 * near * far) / (far + near - z * (far - near)); \n" -"}\n" -"\n" -"void depth_compare_dither()\n" -"{\n" -" if( uDepthMode == 1 )\n" -" {\n" -" vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy \n" -" * uInverseRatioDepth.xy;\n" -" float back_depth = texture( uTexSceneDepth, back_coord ).r;\n" -" float front_depth = gl_FragCoord.z/gl_FragCoord.w;\n" -"\n" -" back_depth = linear_depth( back_depth, 0.1, 2100.0 );\n" -" float diff = back_depth - front_depth;\n" -"\n" -" vec2 ssuv = gl_FragCoord.xy;\n" -" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" -" float dither = fract( vDither.g / 71.0 ) - 0.5;\n" -"\n" -" if( step(0.0,diff)+dither<0.3 )\n" -" discard;\n" -" }\n" -"\n" -" if( uDepthMode == 2 )\n" -" {\n" -" vec2 ssuv = gl_FragCoord.xy;\n" -" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" -" float dither = fract( vDither.g / 71.0 );\n" -" if( dither 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 12 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 13 0 \n" -"#line 1 4 \n" -"uniform sampler2D uTexSceneDepth;\n" -"uniform vec3 uInverseRatioDepth;\n" -"uniform vec3 uInverseRatioMain;\n" -"uniform int uDepthMode;\n" -"uniform float uDitherCutoff;\n" -"\n" -"float linear_depth( float depth, float near, float far ) {\n" -" float z = depth * 2.0 - 1.0;\n" -" return (2.0 * near * far) / (far + near - z * (far - near)); \n" -"}\n" -"\n" -"void depth_compare_dither()\n" -"{\n" -" if( uDepthMode == 1 )\n" -" {\n" -" vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy \n" -" * uInverseRatioDepth.xy;\n" -" float back_depth = texture( uTexSceneDepth, back_coord ).r;\n" -" float front_depth = gl_FragCoord.z/gl_FragCoord.w;\n" -"\n" -" back_depth = linear_depth( back_depth, 0.1, 2100.0 );\n" -" float diff = back_depth - front_depth;\n" -"\n" -" vec2 ssuv = gl_FragCoord.xy;\n" -" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" -" float dither = fract( vDither.g / 71.0 ) - 0.5;\n" -"\n" -" if( step(0.0,diff)+dither<0.3 )\n" -" discard;\n" -" }\n" -"\n" -" if( uDepthMode == 2 )\n" -" {\n" -" vec2 ssuv = gl_FragCoord.xy;\n" -" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" -" float dither = fract( vDither.g / 71.0 );\n" -" if( dither 0.001 ){\n" -" for( float j = 1.0; j <= 4.1; j += 1.0 ){\n" -" float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n" -" star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n" -" }\n" -" }\n" -" \n" -" vec3 composite = sky_colour + sun_colour + star*star_blend;\n" -" return composite;\n" -"}\n" -"\n" -"vec3 clearskies_lighting( vec3 normal, float shadow, vec3 halfview )\n" -"{\n" -" float fresnel = 1.0 - abs(dot(normal,halfview));\n" -"\n" -" vec3 reflect_colour = mix( g_daysky_colour.rgb, g_sunset_colour.rgb, \n" -" g_sunset_phase );\n" -"\n" -" vec3 sky_reflection = 0.5 * fresnel * reflect_colour;\n" -" vec3 light_sun = max( CLEARSKIES_LIGHT_DOT_MIN, \n" -" dot(normal,g_sun_dir.xyz)*0.75+0.25\n" -" ) * g_sun_colour.rgb * g_day_phase;\n" -"\n" -" float scaled_shadow = max( shadow, 1.0 - max(g_sun_dir.y,0.0) );\n" -" vec3 ambient = mix( g_ambient_colour.rgb, g_sunset_ambient.rgb, \n" -" g_sunset_phase );\n" -"\n" -" return ambient + (light_sun + sky_reflection) * shadow;\n" -"}\n" -"\n" -"#line 44 0 \n" -"\n" -"float world_depth_sample( vec3 pos )\n" -"{\n" -" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" -" return texture( g_world_depth, depth_coord ).r;\n" -"}\n" -"\n" -"float world_water_depth( vec3 pos )\n" -"{\n" -" float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return world_depth_sample( pos ) - ref_depth;\n" -"}\n" -"\n" -"float shadow_sample( vec3 co ){\n" -" float height_sample = world_depth_sample( co );\n" -"\n" -" float fdelta = height_sample - co.y;\n" -" return clamp( fdelta, 0.2, 0.4 )-0.2;\n" -"}\n" -"\n" -"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" -" if( g_shadow_samples == 0 ){\n" -" return 1.0;\n" -" }\n" -"\n" -" float fspread = g_shadow_spread;\n" -" float flength = g_shadow_length;\n" -"\n" -" float famt = 0.0;\n" -" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" -"\n" -" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" -"\n" -" return 1.0 - famt;\n" -"}\n" -"\n" -"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n" -"{\n" -" vec3 specdir = reflect( -dir, wnormal );\n" -" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n" -"}\n" -"\n" -"vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){\n" -" float dist = pow(fdist*0.0010,0.78);\n" -" return mix( vfrag, colour, min( 1.0, dist ) );\n" -"}\n" -"\n" -"vec3 scene_calculate_light( int light_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" vec4 light_colour = texelFetch( uLightsArray, light_index+0 );\n" -" vec4 light_co = texelFetch( uLightsArray, light_index+1 );\n" -" vec4 light_dir = texelFetch( uLightsArray, light_index+2 );\n" -"\n" -" vec3 light_delta = light_co.xyz-co;\n" -" float dist2 = dot(light_delta,light_delta);\n" -"\n" -" light_delta = normalize( light_delta );\n" -"\n" -" float quadratic = dist2*100.0;\n" -" float attenuation = 1.0/( 1.0 + quadratic );\n" -" attenuation *= max( dot( light_delta, normal ), 0.0 );\n" -"\n" -" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" -"\n" -" if( light_dir.w < 0.999999 ){\n" -" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) );\n" -" falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) );\n" -" }\n" -"\n" -" return light_colour.rgb * attenuation * falloff \n" -" * step( g_day_phase, light_colour.w );\n" -"}\n" -"\n" -"vec3 scene_calculate_packed_light_patch( uint packed_index, \n" -" vec3 halfview, vec3 co, vec3 normal )\n" -"{\n" -" uint light_count = packed_index & 0x3u;\n" -"\n" -" vec3 l = vec3(0.0);\n" -"\n" -" if( light_count >= 1u ){\n" -" int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u );\n" -" int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u );\n" -" int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u );\n" -"\n" -" l += scene_calculate_light( index_0, halfview, co, normal );\n" -"\n" -" if( light_count >= 2u ){\n" -" l += scene_calculate_light( index_1, halfview, co, normal );\n" -"\n" -" if( light_count >= 3u ){\n" -" l += scene_calculate_light( index_2, halfview, co, normal );\n" -" }\n" -" }\n" -" }\n" -"\n" -" return l;\n" -"}\n" -"\n" -"vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,\n" -" float light_mask )\n" -"{\n" -" if( g_light_preview == 1 )\n" -" diffuse = vec3(0.75);\n" -"\n" -" // Lighting\n" -" vec3 halfview = uCamera - co;\n" -" float fdist = length(halfview);\n" -" halfview /= fdist;\n" -"\n" -" float world_shadow = newlight_compute_sun_shadow( \n" -" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" -"\n" -" vec3 total_light = clearskies_lighting( \n" -" normal, min( light_mask, world_shadow ), halfview );\n" -"\n" -" vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;\n" -" cube_coord = floor( cube_coord );\n" -"\n" -" if( g_debug_indices == 1 )\n" -" {\n" -" return rand33(cube_coord);\n" -" }\n" -"\n" -" if( g_debug_complexity == 1 )\n" -" {\n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);\n" -" return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );\n" -" }\n" -"\n" -" // FIXME: this coord should absolutely must be clamped!\n" -" \n" -" ivec3 coord = ivec3( cube_coord );\n" -" uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );\n" -"\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.x,\n" -" halfview, co, normal ) \n" -" * light_mask;\n" -" total_light += \n" -" scene_calculate_packed_light_patch( index_sample.y,\n" -" halfview, co, normal )\n" -" * light_mask;\n" -"\n" -" // Take a section of the sky function to give us a matching fog colour\n" -"\n" -" vec3 fog_colour = clearskies_ambient( -halfview );\n" -" float sun_theta = dot( -halfview, g_sun_dir.xyz );\n" -" float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );\n" -" float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;\n" -" \n" -" vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n" -" sun_colour *= sun_shape;\n" -"\n" -" fog_colour += sun_colour;\n" -" return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" -"}\n" -"\n" -"#line 12 0 \n" -"#line 1 3 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 13 0 \n" -"\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" -"\n" -" vec3 qnorm = normalize(floor(aNorm*2.0)*0.5) + vec3(0.001,0.0,0.0);\n" -" vec3 diffuse = texture( uTexMain, aUv ).rgb;\n" -" vec3 composite = world_compute_lighting( diffuse, qnorm, aWorldCo, 1.0 );\n" -"\n" -" oColour = vec4( composite, 1.0 );\n" -"}\n" -""}, -}; - -GLuint _uniform_model_entity_uMdl; -GLuint _uniform_model_entity_uPv; -GLuint _uniform_model_entity_uPvmPrev; -GLuint _uniform_model_entity_uTexMain; -GLuint _uniform_model_entity_uCamera; -GLuint _uniform_model_entity_g_world_depth; -GLuint _uniform_model_entity_uLightsArray; -GLuint _uniform_model_entity_uLightsIndex; -#include "shaders/model_gate.h" -struct vg_shader _shader_model_gate = { - .name = "model_gate", - .vs = -{ -.orig_file = "shaders/model.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec3 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"layout (location=3) in vec4 a_colour;\n" -"layout (location=4) in vec4 a_weights;\n" -"layout (location=5) in ivec4 a_groups;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec4 aColour;\n" -"out vec2 aUv;\n" -"out vec3 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -" aWorldCo = world_pos0;\n" -" aColour = a_colour;\n" -" aUv = a_uv;\n" -" aNorm = normalize( mat3(uMdl) * a_norm );\n" -" aCo = a_co;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/model_gate_lq.fs", -.static_src = -"out vec4 FragColor;\n" -"\n" -"uniform float uTime;\n" -"uniform vec3 uCam;\n" -"uniform vec2 uInvRes;\n" -"uniform vec4 uColour;\n" -"\n" -"in vec3 aNorm;\n" -"in vec2 aUv;\n" -"in vec3 aCo;\n" -"\n" -"void main()\n" -"{\n" -" vec2 ssuv = gl_FragCoord.xy;\n" -" float opacity = 1.0-smoothstep(0.0,1.0,aUv.y+uColour.a);\n" -" \n" -" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" -" float dither = fract( vDither.g / 71.0 ) - 0.5;\n" -"\n" -" if( opacity+dither<0.5 )\n" -" discard;\n" -"\n" -" FragColor = uColour;\n" -"}\n" -""}, -}; - -GLuint _uniform_model_gate_uMdl; -GLuint _uniform_model_gate_uPv; -GLuint _uniform_model_gate_uPvmPrev; -GLuint _uniform_model_gate_uTime; -GLuint _uniform_model_gate_uCam; -GLuint _uniform_model_gate_uInvRes; -GLuint _uniform_model_gate_uColour; -#include "shaders/model_gate_unlinked.h" -struct vg_shader _shader_model_gate_unlinked = { - .name = "model_gate_unlinked", - .vs = -{ -.orig_file = "shaders/model.vs", -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec3 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"layout (location=3) in vec4 a_colour;\n" -"layout (location=4) in vec4 a_weights;\n" -"layout (location=5) in ivec4 a_groups;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 9 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec4 aColour;\n" -"out vec2 aUv;\n" -"out vec3 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -" aWorldCo = world_pos0;\n" -" aColour = a_colour;\n" -" aUv = a_uv;\n" -" aNorm = normalize( mat3(uMdl) * a_norm );\n" -" aCo = a_co;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/model_gate_unlinked.fs", -.static_src = -"out vec4 FragColor;\n" -"\n" -"uniform float uTime;\n" -"uniform vec3 uCam;\n" -"uniform vec4 uColour;\n" -"\n" -"in vec3 aNorm;\n" -"in vec2 aUv;\n" -"in vec3 aCo;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 12 0 \n" -"\n" -"const int NOISE_LOOP = 3;\n" -"vec3 digital_noise( uvec3 iuv ){\n" -" iuv *=uvec3(8,2524,7552);\n" -" for( int i=0; i 0.0 ){\n" -" // uvec3 p = uvec3( gl_FragCoord.xy, uint(uTime*30.0) );\n" -" // vec2 g = digital_noise(p).xy;\n" -" // vuv = aUv + g.xy*uGlitchStrength - uGlitchStrength*0.5;\n" -" //}\n" -"\n" -" vec2 vrand = rand_hash22( vuv ) * 2.0 - vec2(1.0);\n" -" vec2 vrand1 = rand_hash22( vrand ) * 2.0 - vec2(1.0);\n" -" \n" -" vec2 vdir = texture( uTexMotion, vuv ).xy * uBlurStrength + uOverrideDir;\n" -"\n" -" vec4 vcolour0 = texture( uTexMain, min(vuv + vdir*vrand.x,uClampUv) );\n" -" vec4 vcolour1 = texture( uTexMain, min(vuv + vdir*vrand.y,uClampUv) );\n" -" vec4 vcolour2 = texture( uTexMain, min(vuv + vdir*vrand1.x,uClampUv) );\n" -" vec4 vcolour3 = texture( uTexMain, min(vuv + vdir*vrand1.y,uClampUv) );\n" -"\n" -" FragColor = ( vcolour0 + vcolour1 + vcolour2 + vcolour3 ) * 0.25;\n" -"}\n" -""}, -}; - -GLuint _uniform_blitblur_uInverseRatio; -GLuint _uniform_blitblur_uTexMain; -GLuint _uniform_blitblur_uTexMotion; -GLuint _uniform_blitblur_uBlurStrength; -GLuint _uniform_blitblur_uOverrideDir; -GLuint _uniform_blitblur_uTime; -GLuint _uniform_blitblur_uGlitchStrength; -GLuint _uniform_blitblur_uClampUv; -#include "shaders/blitcolour.h" -struct vg_shader _shader_blitcolour = { - .name = "blitcolour", - .vs = -{ -.orig_file = "shaders/blit.vs", -.static_src = -"layout (location=0) in vec2 a_co;\n" -"out vec2 aUv;\n" -"\n" -"uniform vec2 uInverseRatio;\n" -"\n" -"void main()\n" -"{\n" -" gl_Position = vec4(a_co*2.0-1.0,0.0,1.0);\n" -" aUv = a_co * uInverseRatio;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/colour.fs", -.static_src = -"out vec4 FragColor;\n" -"uniform vec4 uColour;\n" -"\n" -"in vec2 aUv;\n" -"\n" -"void main()\n" -"{\n" -" FragColor = uColour;\n" -"}\n" -""}, -}; - -GLuint _uniform_blitcolour_uInverseRatio; -GLuint _uniform_blitcolour_uColour; -#include "shaders/blit_transition.h" -struct vg_shader _shader_blit_transition = { - .name = "blit_transition", - .vs = -{ -.orig_file = "shaders/blit.vs", -.static_src = -"layout (location=0) in vec2 a_co;\n" -"out vec2 aUv;\n" -"\n" -"uniform vec2 uInverseRatio;\n" -"\n" -"void main()\n" -"{\n" -" gl_Position = vec4(a_co*2.0-1.0,0.0,1.0);\n" -" aUv = a_co * uInverseRatio;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/blit_transition.fs", -.static_src = -"out vec4 FragColor;\n" -"in vec2 aUv;\n" -"uniform float uT;\n" -"\n" -"void main(){\n" -" float d = uT + distance( aUv, vec2(0.5,0.5) );\n" -"\n" -" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), gl_FragCoord.xy) );\n" -" float dither = fract( vDither.g / 71.0 ) - 0.5;\n" -"\n" -" if( d+dither < -0.5 )\n" -" discard;\n" -"\n" -" FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n" -"}\n" -""}, -}; - -GLuint _uniform_blit_transition_uInverseRatio; -GLuint _uniform_blit_transition_uT; -#include "shaders/routeui.h" -struct vg_shader _shader_routeui = { - .name = "routeui", - .vs = -{ -.orig_file = "shaders/routeui.vs", -.static_src = -"layout (location=0) in vec2 a_co;\n" -"\n" -"uniform vec4 uOffset;\n" -"\n" -"void main()\n" -"{\n" -" vec2 vpos = a_co * uOffset.zw + uOffset.xy;\n" -" gl_Position = vec4(vpos,0.0,1.0);\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/routeui.fs", -.static_src = -"out vec4 FragColor;\n" -"\n" -"uniform vec4 uColour;\n" -"\n" -"void main()\n" -"{\n" -" FragColor = uColour;\n" -"}\n" -""}, -}; - -GLuint _uniform_routeui_uOffset; -GLuint _uniform_routeui_uColour; - - -void vg_auto_shader_link(void) -{ - _uniform_scene_standard_uMdl = glGetUniformLocation( _shader_scene_standard.id, "uMdl" ); - _uniform_scene_standard_uPv = glGetUniformLocation( _shader_scene_standard.id, "uPv" ); - _uniform_scene_standard_uPvmPrev = glGetUniformLocation( _shader_scene_standard.id, "uPvmPrev" ); - _uniform_scene_standard_uTexGarbage = glGetUniformLocation( _shader_scene_standard.id, "uTexGarbage" ); - _uniform_scene_standard_uTexMain = glGetUniformLocation( _shader_scene_standard.id, "uTexMain" ); - _uniform_scene_standard_uCamera = glGetUniformLocation( _shader_scene_standard.id, "uCamera" ); - _uniform_scene_standard_uPlane = glGetUniformLocation( _shader_scene_standard.id, "uPlane" ); - _uniform_scene_standard_g_world_depth = glGetUniformLocation( _shader_scene_standard.id, "g_world_depth" ); - _uniform_scene_standard_uLightsArray = glGetUniformLocation( _shader_scene_standard.id, "uLightsArray" ); - _uniform_scene_standard_uLightsIndex = glGetUniformLocation( _shader_scene_standard.id, "uLightsIndex" ); - _uniform_scene_standard_alphatest_uMdl = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uMdl" ); - _uniform_scene_standard_alphatest_uPv = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uPv" ); - _uniform_scene_standard_alphatest_uPvmPrev = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uPvmPrev" ); - _uniform_scene_standard_alphatest_uTexGarbage = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uTexGarbage" ); - _uniform_scene_standard_alphatest_uTexMain = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uTexMain" ); - _uniform_scene_standard_alphatest_uCamera = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uCamera" ); - _uniform_scene_standard_alphatest_uPlane = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uPlane" ); - _uniform_scene_standard_alphatest_g_world_depth = glGetUniformLocation( _shader_scene_standard_alphatest.id, "g_world_depth" ); - _uniform_scene_standard_alphatest_uLightsArray = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uLightsArray" ); - _uniform_scene_standard_alphatest_uLightsIndex = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uLightsIndex" ); - _uniform_scene_foliage_uMdl = glGetUniformLocation( _shader_scene_foliage.id, "uMdl" ); - _uniform_scene_foliage_uPv = glGetUniformLocation( _shader_scene_foliage.id, "uPv" ); - _uniform_scene_foliage_uPvmPrev = glGetUniformLocation( _shader_scene_foliage.id, "uPvmPrev" ); - _uniform_scene_foliage_uTime = glGetUniformLocation( _shader_scene_foliage.id, "uTime" ); - _uniform_scene_foliage_uTexGarbage = glGetUniformLocation( _shader_scene_foliage.id, "uTexGarbage" ); - _uniform_scene_foliage_uTexMain = glGetUniformLocation( _shader_scene_foliage.id, "uTexMain" ); - _uniform_scene_foliage_uCamera = glGetUniformLocation( _shader_scene_foliage.id, "uCamera" ); - _uniform_scene_foliage_uPlane = glGetUniformLocation( _shader_scene_foliage.id, "uPlane" ); - _uniform_scene_foliage_g_world_depth = glGetUniformLocation( _shader_scene_foliage.id, "g_world_depth" ); - _uniform_scene_foliage_uLightsArray = glGetUniformLocation( _shader_scene_foliage.id, "uLightsArray" ); - _uniform_scene_foliage_uLightsIndex = glGetUniformLocation( _shader_scene_foliage.id, "uLightsIndex" ); - _uniform_scene_override_uMdl = glGetUniformLocation( _shader_scene_override.id, "uMdl" ); - _uniform_scene_override_uPv = glGetUniformLocation( _shader_scene_override.id, "uPv" ); - _uniform_scene_override_uPvmPrev = glGetUniformLocation( _shader_scene_override.id, "uPvmPrev" ); - _uniform_scene_override_uNormalMtx = glGetUniformLocation( _shader_scene_override.id, "uNormalMtx" ); - _uniform_scene_override_uTexGarbage = glGetUniformLocation( _shader_scene_override.id, "uTexGarbage" ); - _uniform_scene_override_uTexMain = glGetUniformLocation( _shader_scene_override.id, "uTexMain" ); - _uniform_scene_override_uCamera = glGetUniformLocation( _shader_scene_override.id, "uCamera" ); - _uniform_scene_override_uPlane = glGetUniformLocation( _shader_scene_override.id, "uPlane" ); - _uniform_scene_override_uPlayerPos = glGetUniformLocation( _shader_scene_override.id, "uPlayerPos" ); - _uniform_scene_override_uSpawnPos = glGetUniformLocation( _shader_scene_override.id, "uSpawnPos" ); - _uniform_scene_override_uAlphatest = glGetUniformLocation( _shader_scene_override.id, "uAlphatest" ); - _uniform_scene_override_uMapInfo = glGetUniformLocation( _shader_scene_override.id, "uMapInfo" ); - _uniform_scene_override_g_world_depth = glGetUniformLocation( _shader_scene_override.id, "g_world_depth" ); - _uniform_scene_override_uLightsArray = glGetUniformLocation( _shader_scene_override.id, "uLightsArray" ); - _uniform_scene_override_uLightsIndex = glGetUniformLocation( _shader_scene_override.id, "uLightsIndex" ); - _uniform_scene_fxglow_uMdl = glGetUniformLocation( _shader_scene_fxglow.id, "uMdl" ); - _uniform_scene_fxglow_uPv = glGetUniformLocation( _shader_scene_fxglow.id, "uPv" ); - _uniform_scene_fxglow_uPvmPrev = glGetUniformLocation( _shader_scene_fxglow.id, "uPvmPrev" ); - _uniform_scene_fxglow_uUvOffset = glGetUniformLocation( _shader_scene_fxglow.id, "uUvOffset" ); - _uniform_scene_fxglow_uTexMain = glGetUniformLocation( _shader_scene_fxglow.id, "uTexMain" ); - _uniform_scene_fxglow_uCamera = glGetUniformLocation( _shader_scene_fxglow.id, "uCamera" ); - _uniform_scene_fxglow_g_world_depth = glGetUniformLocation( _shader_scene_fxglow.id, "g_world_depth" ); - _uniform_scene_fxglow_uLightsArray = glGetUniformLocation( _shader_scene_fxglow.id, "uLightsArray" ); - _uniform_scene_fxglow_uLightsIndex = glGetUniformLocation( _shader_scene_fxglow.id, "uLightsIndex" ); - _uniform_scene_vertex_blend_uMdl = glGetUniformLocation( _shader_scene_vertex_blend.id, "uMdl" ); - _uniform_scene_vertex_blend_uPv = glGetUniformLocation( _shader_scene_vertex_blend.id, "uPv" ); - _uniform_scene_vertex_blend_uPvmPrev = glGetUniformLocation( _shader_scene_vertex_blend.id, "uPvmPrev" ); - _uniform_scene_vertex_blend_uTexGarbage = glGetUniformLocation( _shader_scene_vertex_blend.id, "uTexGarbage" ); - _uniform_scene_vertex_blend_uTexGradients = glGetUniformLocation( _shader_scene_vertex_blend.id, "uTexGradients" ); - _uniform_scene_vertex_blend_uCamera = glGetUniformLocation( _shader_scene_vertex_blend.id, "uCamera" ); - _uniform_scene_vertex_blend_g_world_depth = glGetUniformLocation( _shader_scene_vertex_blend.id, "g_world_depth" ); - _uniform_scene_vertex_blend_uLightsArray = glGetUniformLocation( _shader_scene_vertex_blend.id, "uLightsArray" ); - _uniform_scene_vertex_blend_uLightsIndex = glGetUniformLocation( _shader_scene_vertex_blend.id, "uLightsIndex" ); - _uniform_scene_terrain_uMdl = glGetUniformLocation( _shader_scene_terrain.id, "uMdl" ); - _uniform_scene_terrain_uPv = glGetUniformLocation( _shader_scene_terrain.id, "uPv" ); - _uniform_scene_terrain_uPvmPrev = glGetUniformLocation( _shader_scene_terrain.id, "uPvmPrev" ); - _uniform_scene_terrain_uTexGarbage = glGetUniformLocation( _shader_scene_terrain.id, "uTexGarbage" ); - _uniform_scene_terrain_uTexGradients = glGetUniformLocation( _shader_scene_terrain.id, "uTexGradients" ); - _uniform_scene_terrain_uCamera = glGetUniformLocation( _shader_scene_terrain.id, "uCamera" ); - _uniform_scene_terrain_uSandColour = glGetUniformLocation( _shader_scene_terrain.id, "uSandColour" ); - _uniform_scene_terrain_uBlendOffset = glGetUniformLocation( _shader_scene_terrain.id, "uBlendOffset" ); - _uniform_scene_terrain_g_world_depth = glGetUniformLocation( _shader_scene_terrain.id, "g_world_depth" ); - _uniform_scene_terrain_uLightsArray = glGetUniformLocation( _shader_scene_terrain.id, "uLightsArray" ); - _uniform_scene_terrain_uLightsIndex = glGetUniformLocation( _shader_scene_terrain.id, "uLightsIndex" ); - _uniform_scene_route_uMdl = glGetUniformLocation( _shader_scene_route.id, "uMdl" ); - _uniform_scene_route_uPv = glGetUniformLocation( _shader_scene_route.id, "uPv" ); - _uniform_scene_route_uPvmPrev = glGetUniformLocation( _shader_scene_route.id, "uPvmPrev" ); - _uniform_scene_route_uNormalMtx = glGetUniformLocation( _shader_scene_route.id, "uNormalMtx" ); - _uniform_scene_route_uTexGarbage = glGetUniformLocation( _shader_scene_route.id, "uTexGarbage" ); - _uniform_scene_route_uTexGradients = glGetUniformLocation( _shader_scene_route.id, "uTexGradients" ); - _uniform_scene_route_uCamera = glGetUniformLocation( _shader_scene_route.id, "uCamera" ); - _uniform_scene_route_uColour = glGetUniformLocation( _shader_scene_route.id, "uColour" ); - _uniform_scene_route_g_world_depth = glGetUniformLocation( _shader_scene_route.id, "g_world_depth" ); - _uniform_scene_route_uLightsArray = glGetUniformLocation( _shader_scene_route.id, "uLightsArray" ); - _uniform_scene_route_uLightsIndex = glGetUniformLocation( _shader_scene_route.id, "uLightsIndex" ); - _uniform_scene_depth_uMdl = glGetUniformLocation( _shader_scene_depth.id, "uMdl" ); - _uniform_scene_depth_uPv = glGetUniformLocation( _shader_scene_depth.id, "uPv" ); - _uniform_scene_depth_uPvmPrev = glGetUniformLocation( _shader_scene_depth.id, "uPvmPrev" ); - _uniform_scene_depth_uCamera = glGetUniformLocation( _shader_scene_depth.id, "uCamera" ); - _uniform_scene_depth_uBoard0 = glGetUniformLocation( _shader_scene_depth.id, "uBoard0" ); - _uniform_scene_depth_uBoard1 = glGetUniformLocation( _shader_scene_depth.id, "uBoard1" ); - _uniform_scene_depth_g_world_depth = glGetUniformLocation( _shader_scene_depth.id, "g_world_depth" ); - _uniform_scene_depth_uLightsArray = glGetUniformLocation( _shader_scene_depth.id, "uLightsArray" ); - _uniform_scene_depth_uLightsIndex = glGetUniformLocation( _shader_scene_depth.id, "uLightsIndex" ); - _uniform_scene_position_uMdl = glGetUniformLocation( _shader_scene_position.id, "uMdl" ); - _uniform_scene_position_uPv = glGetUniformLocation( _shader_scene_position.id, "uPv" ); - _uniform_scene_position_uPvmPrev = glGetUniformLocation( _shader_scene_position.id, "uPvmPrev" ); - _uniform_scene_position_uCamera = glGetUniformLocation( _shader_scene_position.id, "uCamera" ); - _uniform_scene_position_uBoard0 = glGetUniformLocation( _shader_scene_position.id, "uBoard0" ); - _uniform_scene_position_uBoard1 = glGetUniformLocation( _shader_scene_position.id, "uBoard1" ); - _uniform_scene_position_g_world_depth = glGetUniformLocation( _shader_scene_position.id, "g_world_depth" ); - _uniform_scene_position_uLightsArray = glGetUniformLocation( _shader_scene_position.id, "uLightsArray" ); - _uniform_scene_position_uLightsIndex = glGetUniformLocation( _shader_scene_position.id, "uLightsIndex" ); - _uniform_scene_cubemapped_uMdl = glGetUniformLocation( _shader_scene_cubemapped.id, "uMdl" ); - _uniform_scene_cubemapped_uPv = glGetUniformLocation( _shader_scene_cubemapped.id, "uPv" ); - _uniform_scene_cubemapped_uPvmPrev = glGetUniformLocation( _shader_scene_cubemapped.id, "uPvmPrev" ); - _uniform_scene_cubemapped_uTexGarbage = glGetUniformLocation( _shader_scene_cubemapped.id, "uTexGarbage" ); - _uniform_scene_cubemapped_uTexMain = glGetUniformLocation( _shader_scene_cubemapped.id, "uTexMain" ); - _uniform_scene_cubemapped_uTexCubemap = glGetUniformLocation( _shader_scene_cubemapped.id, "uTexCubemap" ); - _uniform_scene_cubemapped_uCamera = glGetUniformLocation( _shader_scene_cubemapped.id, "uCamera" ); - _uniform_scene_cubemapped_uPlane = glGetUniformLocation( _shader_scene_cubemapped.id, "uPlane" ); - _uniform_scene_cubemapped_uColour = glGetUniformLocation( _shader_scene_cubemapped.id, "uColour" ); - _uniform_scene_cubemapped_g_world_depth = glGetUniformLocation( _shader_scene_cubemapped.id, "g_world_depth" ); - _uniform_scene_cubemapped_uLightsArray = glGetUniformLocation( _shader_scene_cubemapped.id, "uLightsArray" ); - _uniform_scene_cubemapped_uLightsIndex = glGetUniformLocation( _shader_scene_cubemapped.id, "uLightsIndex" ); - _uniform_scene_water_uMdl = glGetUniformLocation( _shader_scene_water.id, "uMdl" ); - _uniform_scene_water_uPv = glGetUniformLocation( _shader_scene_water.id, "uPv" ); - _uniform_scene_water_uPvmPrev = glGetUniformLocation( _shader_scene_water.id, "uPvmPrev" ); - _uniform_scene_water_uTexMain = glGetUniformLocation( _shader_scene_water.id, "uTexMain" ); - _uniform_scene_water_uTexDudv = glGetUniformLocation( _shader_scene_water.id, "uTexDudv" ); - _uniform_scene_water_uTexBack = glGetUniformLocation( _shader_scene_water.id, "uTexBack" ); - _uniform_scene_water_uInvRes = glGetUniformLocation( _shader_scene_water.id, "uInvRes" ); - _uniform_scene_water_uTime = glGetUniformLocation( _shader_scene_water.id, "uTime" ); - _uniform_scene_water_uCamera = glGetUniformLocation( _shader_scene_water.id, "uCamera" ); - _uniform_scene_water_uSurfaceY = glGetUniformLocation( _shader_scene_water.id, "uSurfaceY" ); - _uniform_scene_water_uBoard0 = glGetUniformLocation( _shader_scene_water.id, "uBoard0" ); - _uniform_scene_water_uBoard1 = glGetUniformLocation( _shader_scene_water.id, "uBoard1" ); - _uniform_scene_water_uShoreColour = glGetUniformLocation( _shader_scene_water.id, "uShoreColour" ); - _uniform_scene_water_uOceanColour = glGetUniformLocation( _shader_scene_water.id, "uOceanColour" ); - _uniform_scene_water_uFresnel = glGetUniformLocation( _shader_scene_water.id, "uFresnel" ); - _uniform_scene_water_uWaterScale = glGetUniformLocation( _shader_scene_water.id, "uWaterScale" ); - _uniform_scene_water_uWaveSpeed = glGetUniformLocation( _shader_scene_water.id, "uWaveSpeed" ); - _uniform_scene_water_g_world_depth = glGetUniformLocation( _shader_scene_water.id, "g_world_depth" ); - _uniform_scene_water_uLightsArray = glGetUniformLocation( _shader_scene_water.id, "uLightsArray" ); - _uniform_scene_water_uLightsIndex = glGetUniformLocation( _shader_scene_water.id, "uLightsIndex" ); - _uniform_scene_water_fast_uMdl = glGetUniformLocation( _shader_scene_water_fast.id, "uMdl" ); - _uniform_scene_water_fast_uPv = glGetUniformLocation( _shader_scene_water_fast.id, "uPv" ); - _uniform_scene_water_fast_uPvmPrev = glGetUniformLocation( _shader_scene_water_fast.id, "uPvmPrev" ); - _uniform_scene_water_fast_uTexDudv = glGetUniformLocation( _shader_scene_water_fast.id, "uTexDudv" ); - _uniform_scene_water_fast_uTime = glGetUniformLocation( _shader_scene_water_fast.id, "uTime" ); - _uniform_scene_water_fast_uCamera = glGetUniformLocation( _shader_scene_water_fast.id, "uCamera" ); - _uniform_scene_water_fast_uSurfaceY = glGetUniformLocation( _shader_scene_water_fast.id, "uSurfaceY" ); - _uniform_scene_water_fast_uBoard0 = glGetUniformLocation( _shader_scene_water_fast.id, "uBoard0" ); - _uniform_scene_water_fast_uBoard1 = glGetUniformLocation( _shader_scene_water_fast.id, "uBoard1" ); - _uniform_scene_water_fast_uShoreColour = glGetUniformLocation( _shader_scene_water_fast.id, "uShoreColour" ); - _uniform_scene_water_fast_uOceanColour = glGetUniformLocation( _shader_scene_water_fast.id, "uOceanColour" ); - _uniform_scene_water_fast_g_world_depth = glGetUniformLocation( _shader_scene_water_fast.id, "g_world_depth" ); - _uniform_scene_water_fast_uLightsArray = glGetUniformLocation( _shader_scene_water_fast.id, "uLightsArray" ); - _uniform_scene_water_fast_uLightsIndex = glGetUniformLocation( _shader_scene_water_fast.id, "uLightsIndex" ); - _uniform_scene_scoretext_uMdl = glGetUniformLocation( _shader_scene_scoretext.id, "uMdl" ); - _uniform_scene_scoretext_uPv = glGetUniformLocation( _shader_scene_scoretext.id, "uPv" ); - _uniform_scene_scoretext_uPvmPrev = glGetUniformLocation( _shader_scene_scoretext.id, "uPvmPrev" ); - _uniform_scene_scoretext_uInfo = glGetUniformLocation( _shader_scene_scoretext.id, "uInfo" ); - _uniform_scene_scoretext_uTexGarbage = glGetUniformLocation( _shader_scene_scoretext.id, "uTexGarbage" ); - _uniform_scene_scoretext_uTexMain = glGetUniformLocation( _shader_scene_scoretext.id, "uTexMain" ); - _uniform_scene_scoretext_uCamera = glGetUniformLocation( _shader_scene_scoretext.id, "uCamera" ); - _uniform_scene_scoretext_uPlane = glGetUniformLocation( _shader_scene_scoretext.id, "uPlane" ); - _uniform_scene_scoretext_g_world_depth = glGetUniformLocation( _shader_scene_scoretext.id, "g_world_depth" ); - _uniform_scene_scoretext_uLightsArray = glGetUniformLocation( _shader_scene_scoretext.id, "uLightsArray" ); - _uniform_scene_scoretext_uLightsIndex = glGetUniformLocation( _shader_scene_scoretext.id, "uLightsIndex" ); - _uniform_scene_font_uMdl = glGetUniformLocation( _shader_scene_font.id, "uMdl" ); - _uniform_scene_font_uPv = glGetUniformLocation( _shader_scene_font.id, "uPv" ); - _uniform_scene_font_uPvmPrev = glGetUniformLocation( _shader_scene_font.id, "uPvmPrev" ); - _uniform_scene_font_uOffset = glGetUniformLocation( _shader_scene_font.id, "uOffset" ); - _uniform_scene_font_uTexGarbage = glGetUniformLocation( _shader_scene_font.id, "uTexGarbage" ); - _uniform_scene_font_uTexMain = glGetUniformLocation( _shader_scene_font.id, "uTexMain" ); - _uniform_scene_font_uCamera = glGetUniformLocation( _shader_scene_font.id, "uCamera" ); - _uniform_scene_font_uTime = glGetUniformLocation( _shader_scene_font.id, "uTime" ); - _uniform_scene_font_uOpacity = glGetUniformLocation( _shader_scene_font.id, "uOpacity" ); - _uniform_scene_font_uColourize = glGetUniformLocation( _shader_scene_font.id, "uColourize" ); - _uniform_scene_font_g_world_depth = glGetUniformLocation( _shader_scene_font.id, "g_world_depth" ); - _uniform_scene_font_uLightsArray = glGetUniformLocation( _shader_scene_font.id, "uLightsArray" ); - _uniform_scene_font_uLightsIndex = glGetUniformLocation( _shader_scene_font.id, "uLightsIndex" ); - _uniform_model_sky_uMdl = glGetUniformLocation( _shader_model_sky.id, "uMdl" ); - _uniform_model_sky_uPv = glGetUniformLocation( _shader_model_sky.id, "uPv" ); - _uniform_model_sky_uPvmPrev = glGetUniformLocation( _shader_model_sky.id, "uPvmPrev" ); - _uniform_model_sky_uTexGarbage = glGetUniformLocation( _shader_model_sky.id, "uTexGarbage" ); - _uniform_model_sky_g_world_depth = glGetUniformLocation( _shader_model_sky.id, "g_world_depth" ); - _uniform_model_sky_uLightsArray = glGetUniformLocation( _shader_model_sky.id, "uLightsArray" ); - _uniform_model_sky_uLightsIndex = glGetUniformLocation( _shader_model_sky.id, "uLightsIndex" ); - _uniform_model_sky_space_uMdl = glGetUniformLocation( _shader_model_sky_space.id, "uMdl" ); - _uniform_model_sky_space_uPv = glGetUniformLocation( _shader_model_sky_space.id, "uPv" ); - _uniform_model_sky_space_uPvmPrev = glGetUniformLocation( _shader_model_sky_space.id, "uPvmPrev" ); - _uniform_model_sky_space_uTexGarbage = glGetUniformLocation( _shader_model_sky_space.id, "uTexGarbage" ); - _uniform_model_sky_space_g_world_depth = glGetUniformLocation( _shader_model_sky_space.id, "g_world_depth" ); - _uniform_model_sky_space_uLightsArray = glGetUniformLocation( _shader_model_sky_space.id, "uLightsArray" ); - _uniform_model_sky_space_uLightsIndex = glGetUniformLocation( _shader_model_sky_space.id, "uLightsIndex" ); - _uniform_model_menu_uMdl = glGetUniformLocation( _shader_model_menu.id, "uMdl" ); - _uniform_model_menu_uPv = glGetUniformLocation( _shader_model_menu.id, "uPv" ); - _uniform_model_menu_uPvmPrev = glGetUniformLocation( _shader_model_menu.id, "uPvmPrev" ); - _uniform_model_menu_uTexMain = glGetUniformLocation( _shader_model_menu.id, "uTexMain" ); - _uniform_model_menu_uColour = glGetUniformLocation( _shader_model_menu.id, "uColour" ); - _uniform_model_character_view_uPv = glGetUniformLocation( _shader_model_character_view.id, "uPv" ); - _uniform_model_character_view_uTransforms = glGetUniformLocation( _shader_model_character_view.id, "uTransforms" ); - _uniform_model_character_view_uTexMain = glGetUniformLocation( _shader_model_character_view.id, "uTexMain" ); - _uniform_model_character_view_uCamera = glGetUniformLocation( _shader_model_character_view.id, "uCamera" ); - _uniform_model_character_view_g_world_depth = glGetUniformLocation( _shader_model_character_view.id, "g_world_depth" ); - _uniform_model_character_view_uLightsArray = glGetUniformLocation( _shader_model_character_view.id, "uLightsArray" ); - _uniform_model_character_view_uLightsIndex = glGetUniformLocation( _shader_model_character_view.id, "uLightsIndex" ); - _uniform_model_character_view_uTexSceneDepth = glGetUniformLocation( _shader_model_character_view.id, "uTexSceneDepth" ); - _uniform_model_character_view_uInverseRatioDepth = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioDepth" ); - _uniform_model_character_view_uInverseRatioMain = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioMain" ); - _uniform_model_character_view_uDepthMode = glGetUniformLocation( _shader_model_character_view.id, "uDepthMode" ); - _uniform_model_character_view_uDitherCutoff = glGetUniformLocation( _shader_model_character_view.id, "uDitherCutoff" ); - _uniform_model_board_view_uMdl = glGetUniformLocation( _shader_model_board_view.id, "uMdl" ); - _uniform_model_board_view_uPv = glGetUniformLocation( _shader_model_board_view.id, "uPv" ); - _uniform_model_board_view_uPvmPrev = glGetUniformLocation( _shader_model_board_view.id, "uPvmPrev" ); - _uniform_model_board_view_uTexMain = glGetUniformLocation( _shader_model_board_view.id, "uTexMain" ); - _uniform_model_board_view_uCamera = glGetUniformLocation( _shader_model_board_view.id, "uCamera" ); - _uniform_model_board_view_g_world_depth = glGetUniformLocation( _shader_model_board_view.id, "g_world_depth" ); - _uniform_model_board_view_uLightsArray = glGetUniformLocation( _shader_model_board_view.id, "uLightsArray" ); - _uniform_model_board_view_uLightsIndex = glGetUniformLocation( _shader_model_board_view.id, "uLightsIndex" ); - _uniform_model_board_view_uTexSceneDepth = glGetUniformLocation( _shader_model_board_view.id, "uTexSceneDepth" ); - _uniform_model_board_view_uInverseRatioDepth = glGetUniformLocation( _shader_model_board_view.id, "uInverseRatioDepth" ); - _uniform_model_board_view_uInverseRatioMain = glGetUniformLocation( _shader_model_board_view.id, "uInverseRatioMain" ); - _uniform_model_board_view_uDepthMode = glGetUniformLocation( _shader_model_board_view.id, "uDepthMode" ); - _uniform_model_board_view_uDitherCutoff = glGetUniformLocation( _shader_model_board_view.id, "uDitherCutoff" ); - _uniform_model_entity_uMdl = glGetUniformLocation( _shader_model_entity.id, "uMdl" ); - _uniform_model_entity_uPv = glGetUniformLocation( _shader_model_entity.id, "uPv" ); - _uniform_model_entity_uPvmPrev = glGetUniformLocation( _shader_model_entity.id, "uPvmPrev" ); - _uniform_model_entity_uTexMain = glGetUniformLocation( _shader_model_entity.id, "uTexMain" ); - _uniform_model_entity_uCamera = glGetUniformLocation( _shader_model_entity.id, "uCamera" ); - _uniform_model_entity_g_world_depth = glGetUniformLocation( _shader_model_entity.id, "g_world_depth" ); - _uniform_model_entity_uLightsArray = glGetUniformLocation( _shader_model_entity.id, "uLightsArray" ); - _uniform_model_entity_uLightsIndex = glGetUniformLocation( _shader_model_entity.id, "uLightsIndex" ); - _uniform_model_gate_uMdl = glGetUniformLocation( _shader_model_gate.id, "uMdl" ); - _uniform_model_gate_uPv = glGetUniformLocation( _shader_model_gate.id, "uPv" ); - _uniform_model_gate_uPvmPrev = glGetUniformLocation( _shader_model_gate.id, "uPvmPrev" ); - _uniform_model_gate_uTime = glGetUniformLocation( _shader_model_gate.id, "uTime" ); - _uniform_model_gate_uCam = glGetUniformLocation( _shader_model_gate.id, "uCam" ); - _uniform_model_gate_uInvRes = glGetUniformLocation( _shader_model_gate.id, "uInvRes" ); - _uniform_model_gate_uColour = glGetUniformLocation( _shader_model_gate.id, "uColour" ); - _uniform_model_gate_unlinked_uMdl = glGetUniformLocation( _shader_model_gate_unlinked.id, "uMdl" ); - _uniform_model_gate_unlinked_uPv = glGetUniformLocation( _shader_model_gate_unlinked.id, "uPv" ); - _uniform_model_gate_unlinked_uPvmPrev = glGetUniformLocation( _shader_model_gate_unlinked.id, "uPvmPrev" ); - _uniform_model_gate_unlinked_uTime = glGetUniformLocation( _shader_model_gate_unlinked.id, "uTime" ); - _uniform_model_gate_unlinked_uCam = glGetUniformLocation( _shader_model_gate_unlinked.id, "uCam" ); - _uniform_model_gate_unlinked_uColour = glGetUniformLocation( _shader_model_gate_unlinked.id, "uColour" ); - _uniform_model_font_uMdl = glGetUniformLocation( _shader_model_font.id, "uMdl" ); - _uniform_model_font_uPv = glGetUniformLocation( _shader_model_font.id, "uPv" ); - _uniform_model_font_uPvmPrev = glGetUniformLocation( _shader_model_font.id, "uPvmPrev" ); - _uniform_model_font_uOffset = glGetUniformLocation( _shader_model_font.id, "uOffset" ); - _uniform_model_font_uTexMain = glGetUniformLocation( _shader_model_font.id, "uTexMain" ); - _uniform_model_font_uColour = glGetUniformLocation( _shader_model_font.id, "uColour" ); - _uniform_model_font_uTexSceneDepth = glGetUniformLocation( _shader_model_font.id, "uTexSceneDepth" ); - _uniform_model_font_uInverseRatioDepth = glGetUniformLocation( _shader_model_font.id, "uInverseRatioDepth" ); - _uniform_model_font_uInverseRatioMain = glGetUniformLocation( _shader_model_font.id, "uInverseRatioMain" ); - _uniform_model_font_uDepthMode = glGetUniformLocation( _shader_model_font.id, "uDepthMode" ); - _uniform_model_font_uDitherCutoff = glGetUniformLocation( _shader_model_font.id, "uDitherCutoff" ); - _uniform_particle_uPv = glGetUniformLocation( _shader_particle.id, "uPv" ); - _uniform_particle_uPvPrev = glGetUniformLocation( _shader_particle.id, "uPvPrev" ); - _uniform_trail_uPv = glGetUniformLocation( _shader_trail.id, "uPv" ); - _uniform_trail_uPvPrev = glGetUniformLocation( _shader_trail.id, "uPvPrev" ); - _uniform_trail_uColour = glGetUniformLocation( _shader_trail.id, "uColour" ); - _uniform_blit_uInverseRatio = glGetUniformLocation( _shader_blit.id, "uInverseRatio" ); - _uniform_blit_uTexMain = glGetUniformLocation( _shader_blit.id, "uTexMain" ); - _uniform_blitblur_uInverseRatio = glGetUniformLocation( _shader_blitblur.id, "uInverseRatio" ); - _uniform_blitblur_uTexMain = glGetUniformLocation( _shader_blitblur.id, "uTexMain" ); - _uniform_blitblur_uTexMotion = glGetUniformLocation( _shader_blitblur.id, "uTexMotion" ); - _uniform_blitblur_uBlurStrength = glGetUniformLocation( _shader_blitblur.id, "uBlurStrength" ); - _uniform_blitblur_uOverrideDir = glGetUniformLocation( _shader_blitblur.id, "uOverrideDir" ); - _uniform_blitblur_uTime = glGetUniformLocation( _shader_blitblur.id, "uTime" ); - _uniform_blitblur_uGlitchStrength = glGetUniformLocation( _shader_blitblur.id, "uGlitchStrength" ); - _uniform_blitblur_uClampUv = glGetUniformLocation( _shader_blitblur.id, "uClampUv" ); - _uniform_blitcolour_uInverseRatio = glGetUniformLocation( _shader_blitcolour.id, "uInverseRatio" ); - _uniform_blitcolour_uColour = glGetUniformLocation( _shader_blitcolour.id, "uColour" ); - _uniform_blit_transition_uInverseRatio = glGetUniformLocation( _shader_blit_transition.id, "uInverseRatio" ); - _uniform_blit_transition_uT = glGetUniformLocation( _shader_blit_transition.id, "uT" ); - _uniform_routeui_uOffset = glGetUniformLocation( _shader_routeui.id, "uOffset" ); - _uniform_routeui_uColour = glGetUniformLocation( _shader_routeui.id, "uColour" ); -} - -void vg_auto_shader_register(void) -{ - vg_shader_register( &_shader_scene_standard ); - vg_shader_register( &_shader_scene_standard_alphatest ); - vg_shader_register( &_shader_scene_foliage ); - vg_shader_register( &_shader_scene_override ); - vg_shader_register( &_shader_scene_fxglow ); - vg_shader_register( &_shader_scene_vertex_blend ); - vg_shader_register( &_shader_scene_terrain ); - vg_shader_register( &_shader_scene_route ); - vg_shader_register( &_shader_scene_depth ); - vg_shader_register( &_shader_scene_position ); - vg_shader_register( &_shader_scene_cubemapped ); - vg_shader_register( &_shader_scene_water ); - vg_shader_register( &_shader_scene_water_fast ); - vg_shader_register( &_shader_scene_scoretext ); - vg_shader_register( &_shader_scene_font ); - vg_shader_register( &_shader_model_sky ); - vg_shader_register( &_shader_model_sky_space ); - vg_shader_register( &_shader_model_menu ); - vg_shader_register( &_shader_model_character_view ); - vg_shader_register( &_shader_model_board_view ); - vg_shader_register( &_shader_model_entity ); - vg_shader_register( &_shader_model_gate ); - vg_shader_register( &_shader_model_gate_unlinked ); - vg_shader_register( &_shader_model_font ); - vg_shader_register( &_shader_particle ); - vg_shader_register( &_shader_trail ); - vg_shader_register( &_shader_blit ); - vg_shader_register( &_shader_blitblur ); - vg_shader_register( &_shader_blitcolour ); - vg_shader_register( &_shader_blit_transition ); - vg_shader_register( &_shader_routeui ); -} - diff --git a/shaders/model_board_view.h b/shaders/model_board_view.h deleted file mode 100644 index c5aa59a..0000000 --- a/shaders/model_board_view.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_model_board_view; -extern GLuint _uniform_model_board_view_uMdl; -extern GLuint _uniform_model_board_view_uPv; -extern GLuint _uniform_model_board_view_uPvmPrev; -extern GLuint _uniform_model_board_view_uTexMain; -extern GLuint _uniform_model_board_view_uCamera; -extern GLuint _uniform_model_board_view_g_world_depth; -extern GLuint _uniform_model_board_view_uLightsArray; -extern GLuint _uniform_model_board_view_uLightsIndex; -extern GLuint _uniform_model_board_view_uTexSceneDepth; -extern GLuint _uniform_model_board_view_uInverseRatioDepth; -extern GLuint _uniform_model_board_view_uInverseRatioMain; -extern GLuint _uniform_model_board_view_uDepthMode; -extern GLuint _uniform_model_board_view_uDitherCutoff; -static inline void shader_model_board_view_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_model_board_view_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_board_view_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_board_view_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_board_view_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_board_view_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_board_view_uTexMain(int i) -{ - glUniform1i(_uniform_model_board_view_uTexMain,i); -} -static inline void shader_model_board_view_uCamera(v3f v) -{ - glUniform3fv(_uniform_model_board_view_uCamera,1,v); -} -static inline void shader_model_board_view_g_world_depth(int i) -{ - glUniform1i(_uniform_model_board_view_g_world_depth,i); -} -static inline void shader_model_board_view_uTexSceneDepth(int i) -{ - glUniform1i(_uniform_model_board_view_uTexSceneDepth,i); -} -static inline void shader_model_board_view_uInverseRatioDepth(v3f v) -{ - glUniform3fv(_uniform_model_board_view_uInverseRatioDepth,1,v); -} -static inline void shader_model_board_view_uInverseRatioMain(v3f v) -{ - glUniform3fv(_uniform_model_board_view_uInverseRatioMain,1,v); -} -static inline void shader_model_board_view_uDepthMode(int b) -{ - glUniform1i(_uniform_model_board_view_uDepthMode,b); -} -static inline void shader_model_board_view_uDitherCutoff(f32 f) -{ - glUniform1f(_uniform_model_board_view_uDitherCutoff,f); -} -static inline void shader_model_board_view_use(void); -static inline void shader_model_board_view_use(void) -{ - glUseProgram(_shader_model_board_view.id); -} diff --git a/shaders/model_character_view.h b/shaders/model_character_view.h deleted file mode 100644 index 40e27cb..0000000 --- a/shaders/model_character_view.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_model_character_view; -extern GLuint _uniform_model_character_view_uPv; -extern GLuint _uniform_model_character_view_uTransforms; -extern GLuint _uniform_model_character_view_uTexMain; -extern GLuint _uniform_model_character_view_uCamera; -extern GLuint _uniform_model_character_view_g_world_depth; -extern GLuint _uniform_model_character_view_uLightsArray; -extern GLuint _uniform_model_character_view_uLightsIndex; -extern GLuint _uniform_model_character_view_uTexSceneDepth; -extern GLuint _uniform_model_character_view_uInverseRatioDepth; -extern GLuint _uniform_model_character_view_uInverseRatioMain; -extern GLuint _uniform_model_character_view_uDepthMode; -extern GLuint _uniform_model_character_view_uDitherCutoff; -static inline void shader_model_character_view_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_character_view_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_character_view_uTexMain(int i) -{ - glUniform1i(_uniform_model_character_view_uTexMain,i); -} -static inline void shader_model_character_view_uCamera(v3f v) -{ - glUniform3fv(_uniform_model_character_view_uCamera,1,v); -} -static inline void shader_model_character_view_g_world_depth(int i) -{ - glUniform1i(_uniform_model_character_view_g_world_depth,i); -} -static inline void shader_model_character_view_uTexSceneDepth(int i) -{ - glUniform1i(_uniform_model_character_view_uTexSceneDepth,i); -} -static inline void shader_model_character_view_uInverseRatioDepth(v3f v) -{ - glUniform3fv(_uniform_model_character_view_uInverseRatioDepth,1,v); -} -static inline void shader_model_character_view_uInverseRatioMain(v3f v) -{ - glUniform3fv(_uniform_model_character_view_uInverseRatioMain,1,v); -} -static inline void shader_model_character_view_uDepthMode(int b) -{ - glUniform1i(_uniform_model_character_view_uDepthMode,b); -} -static inline void shader_model_character_view_uDitherCutoff(f32 f) -{ - glUniform1f(_uniform_model_character_view_uDitherCutoff,f); -} -static inline void shader_model_character_view_use(void); -static inline void shader_model_character_view_use(void) -{ - glUseProgram(_shader_model_character_view.id); -} diff --git a/shaders/model_entity.h b/shaders/model_entity.h deleted file mode 100644 index e198e03..0000000 --- a/shaders/model_entity.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_model_entity; -extern GLuint _uniform_model_entity_uMdl; -extern GLuint _uniform_model_entity_uPv; -extern GLuint _uniform_model_entity_uPvmPrev; -extern GLuint _uniform_model_entity_uTexMain; -extern GLuint _uniform_model_entity_uCamera; -extern GLuint _uniform_model_entity_g_world_depth; -extern GLuint _uniform_model_entity_uLightsArray; -extern GLuint _uniform_model_entity_uLightsIndex; -static inline void shader_model_entity_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_model_entity_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_entity_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_entity_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_entity_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_entity_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_entity_uTexMain(int i) -{ - glUniform1i(_uniform_model_entity_uTexMain,i); -} -static inline void shader_model_entity_uCamera(v3f v) -{ - glUniform3fv(_uniform_model_entity_uCamera,1,v); -} -static inline void shader_model_entity_g_world_depth(int i) -{ - glUniform1i(_uniform_model_entity_g_world_depth,i); -} -static inline void shader_model_entity_use(void); -static inline void shader_model_entity_use(void) -{ - glUseProgram(_shader_model_entity.id); -} diff --git a/shaders/model_font.h b/shaders/model_font.h deleted file mode 100644 index 0b3fc25..0000000 --- a/shaders/model_font.h +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_model_font; -extern GLuint _uniform_model_font_uMdl; -extern GLuint _uniform_model_font_uPv; -extern GLuint _uniform_model_font_uPvmPrev; -extern GLuint _uniform_model_font_uOffset; -extern GLuint _uniform_model_font_uTexMain; -extern GLuint _uniform_model_font_uColour; -extern GLuint _uniform_model_font_uTexSceneDepth; -extern GLuint _uniform_model_font_uInverseRatioDepth; -extern GLuint _uniform_model_font_uInverseRatioMain; -extern GLuint _uniform_model_font_uDepthMode; -extern GLuint _uniform_model_font_uDitherCutoff; -static inline void shader_model_font_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_model_font_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_font_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_font_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_font_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_font_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_font_uOffset(v4f v) -{ - glUniform4fv(_uniform_model_font_uOffset,1,v); -} -static inline void shader_model_font_uTexMain(int i) -{ - glUniform1i(_uniform_model_font_uTexMain,i); -} -static inline void shader_model_font_uColour(v4f v) -{ - glUniform4fv(_uniform_model_font_uColour,1,v); -} -static inline void shader_model_font_uTexSceneDepth(int i) -{ - glUniform1i(_uniform_model_font_uTexSceneDepth,i); -} -static inline void shader_model_font_uInverseRatioDepth(v3f v) -{ - glUniform3fv(_uniform_model_font_uInverseRatioDepth,1,v); -} -static inline void shader_model_font_uInverseRatioMain(v3f v) -{ - glUniform3fv(_uniform_model_font_uInverseRatioMain,1,v); -} -static inline void shader_model_font_uDepthMode(int b) -{ - glUniform1i(_uniform_model_font_uDepthMode,b); -} -static inline void shader_model_font_uDitherCutoff(f32 f) -{ - glUniform1f(_uniform_model_font_uDitherCutoff,f); -} -static inline void shader_model_font_use(void); -static inline void shader_model_font_use(void) -{ - glUseProgram(_shader_model_font.id); -} diff --git a/shaders/model_gate.h b/shaders/model_gate.h deleted file mode 100644 index 49986ba..0000000 --- a/shaders/model_gate.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_model_gate; -extern GLuint _uniform_model_gate_uMdl; -extern GLuint _uniform_model_gate_uPv; -extern GLuint _uniform_model_gate_uPvmPrev; -extern GLuint _uniform_model_gate_uTime; -extern GLuint _uniform_model_gate_uCam; -extern GLuint _uniform_model_gate_uInvRes; -extern GLuint _uniform_model_gate_uColour; -static inline void shader_model_gate_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_model_gate_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_gate_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_gate_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_gate_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_gate_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_gate_uTime(f32 f) -{ - glUniform1f(_uniform_model_gate_uTime,f); -} -static inline void shader_model_gate_uCam(v3f v) -{ - glUniform3fv(_uniform_model_gate_uCam,1,v); -} -static inline void shader_model_gate_uInvRes(v2f v) -{ - glUniform2fv(_uniform_model_gate_uInvRes,1,v); -} -static inline void shader_model_gate_uColour(v4f v) -{ - glUniform4fv(_uniform_model_gate_uColour,1,v); -} -static inline void shader_model_gate_use(void); -static inline void shader_model_gate_use(void) -{ - glUseProgram(_shader_model_gate.id); -} diff --git a/shaders/model_gate_unlinked.h b/shaders/model_gate_unlinked.h deleted file mode 100644 index 93ab1e3..0000000 --- a/shaders/model_gate_unlinked.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_model_gate_unlinked; -extern GLuint _uniform_model_gate_unlinked_uMdl; -extern GLuint _uniform_model_gate_unlinked_uPv; -extern GLuint _uniform_model_gate_unlinked_uPvmPrev; -extern GLuint _uniform_model_gate_unlinked_uTime; -extern GLuint _uniform_model_gate_unlinked_uCam; -extern GLuint _uniform_model_gate_unlinked_uColour; -static inline void shader_model_gate_unlinked_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_model_gate_unlinked_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_gate_unlinked_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_gate_unlinked_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_gate_unlinked_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_gate_unlinked_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_gate_unlinked_uTime(f32 f) -{ - glUniform1f(_uniform_model_gate_unlinked_uTime,f); -} -static inline void shader_model_gate_unlinked_uCam(v3f v) -{ - glUniform3fv(_uniform_model_gate_unlinked_uCam,1,v); -} -static inline void shader_model_gate_unlinked_uColour(v4f v) -{ - glUniform4fv(_uniform_model_gate_unlinked_uColour,1,v); -} -static inline void shader_model_gate_unlinked_use(void); -static inline void shader_model_gate_unlinked_use(void) -{ - glUseProgram(_shader_model_gate_unlinked.id); -} diff --git a/shaders/model_menu.h b/shaders/model_menu.h deleted file mode 100644 index 774d4c8..0000000 --- a/shaders/model_menu.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_model_menu; -extern GLuint _uniform_model_menu_uMdl; -extern GLuint _uniform_model_menu_uPv; -extern GLuint _uniform_model_menu_uPvmPrev; -extern GLuint _uniform_model_menu_uTexMain; -extern GLuint _uniform_model_menu_uColour; -static inline void shader_model_menu_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_model_menu_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_menu_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_menu_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_menu_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_menu_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_menu_uTexMain(int i) -{ - glUniform1i(_uniform_model_menu_uTexMain,i); -} -static inline void shader_model_menu_uColour(v4f v) -{ - glUniform4fv(_uniform_model_menu_uColour,1,v); -} -static inline void shader_model_menu_use(void); -static inline void shader_model_menu_use(void) -{ - glUseProgram(_shader_model_menu.id); -} diff --git a/shaders/model_sky.h b/shaders/model_sky.h deleted file mode 100644 index 534d693..0000000 --- a/shaders/model_sky.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_model_sky; -extern GLuint _uniform_model_sky_uMdl; -extern GLuint _uniform_model_sky_uPv; -extern GLuint _uniform_model_sky_uPvmPrev; -extern GLuint _uniform_model_sky_uTexGarbage; -extern GLuint _uniform_model_sky_g_world_depth; -extern GLuint _uniform_model_sky_uLightsArray; -extern GLuint _uniform_model_sky_uLightsIndex; -static inline void shader_model_sky_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_model_sky_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_sky_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_sky_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_sky_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_sky_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_sky_uTexGarbage(int i) -{ - glUniform1i(_uniform_model_sky_uTexGarbage,i); -} -static inline void shader_model_sky_g_world_depth(int i) -{ - glUniform1i(_uniform_model_sky_g_world_depth,i); -} -static inline void shader_model_sky_use(void); -static inline void shader_model_sky_use(void) -{ - glUseProgram(_shader_model_sky.id); -} diff --git a/shaders/model_sky_space.h b/shaders/model_sky_space.h deleted file mode 100644 index 474d072..0000000 --- a/shaders/model_sky_space.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_model_sky_space; -extern GLuint _uniform_model_sky_space_uMdl; -extern GLuint _uniform_model_sky_space_uPv; -extern GLuint _uniform_model_sky_space_uPvmPrev; -extern GLuint _uniform_model_sky_space_uTexGarbage; -extern GLuint _uniform_model_sky_space_g_world_depth; -extern GLuint _uniform_model_sky_space_uLightsArray; -extern GLuint _uniform_model_sky_space_uLightsIndex; -static inline void shader_model_sky_space_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_model_sky_space_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_sky_space_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_sky_space_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_sky_space_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_model_sky_space_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_model_sky_space_uTexGarbage(int i) -{ - glUniform1i(_uniform_model_sky_space_uTexGarbage,i); -} -static inline void shader_model_sky_space_g_world_depth(int i) -{ - glUniform1i(_uniform_model_sky_space_g_world_depth,i); -} -static inline void shader_model_sky_space_use(void); -static inline void shader_model_sky_space_use(void) -{ - glUseProgram(_shader_model_sky_space.id); -} diff --git a/shaders/particle.h b/shaders/particle.h deleted file mode 100644 index 43ad3ac..0000000 --- a/shaders/particle.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_particle; -extern GLuint _uniform_particle_uPv; -extern GLuint _uniform_particle_uPvPrev; -static inline void shader_particle_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_particle_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_particle_uPvPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_particle_uPvPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_particle_use(void); -static inline void shader_particle_use(void) -{ - glUseProgram(_shader_particle.id); -} diff --git a/shaders/point_map.h b/shaders/point_map.h deleted file mode 100644 index 006c98f..0000000 --- a/shaders/point_map.h +++ /dev/null @@ -1,168 +0,0 @@ -#ifndef SHADER_point_map_H -#define SHADER_point_map_H -static void shader_point_map_link(void); -static void shader_point_map_register(void); -static struct vg_shader _shader_point_map = { - .name = "point_map", - .link = shader_point_map_link, - .vs = -{ -.orig_file = "shaders/cloud.vs", -.static_src = -"layout (location=0) in vec4 a_co;\n" -"layout (location=1) in vec4 a_colour;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 5 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat3 uNormMtx;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"uniform vec4 uAnim;\n" -"\n" -"out vec4 aColour;\n" -"out vec3 aWorldCo;\n" -"out vec3 aCo;\n" -"\n" -"vec2 rand_hash22( vec2 p )\n" -"{\n" -" vec3 p3 = fract(vec3(p.xyx) * 213.8976123);\n" -" p3 += dot(p3, p3.yzx+19.19);\n" -" return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y));\n" -"}\n" -"\n" -"vec3 gridify( vec3 p, float s, float t )\n" -"{\n" -" vec3 co = p*s;\n" -" vec2 r2 = rand_hash22(p.xz);\n" -" vec3 grid = (vec3(floor(co.x),co.y,floor(co.z))+vec3(0.5,0.0,0.5)) * (1.0/s);\n" -"\n" -" float t1 = 1.0-t;\n" -" t1 = 1.0-t1*t1;\n" -" float t2 = t*t;\n" -"\n" -" return mix( p, grid, t1 ) + t2*vec3(0.0,r2.y*r2.y*0.2,0.0);\n" -"}\n" -"\n" -"void main()\n" -"{\n" -" vec3 co = gridify( a_co.xyz, uAnim.x, uAnim.y );\n" -"\n" -" vec3 world_pos0 = uMdl * vec4( co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( co, 1.0 );\n" -"\n" -" float scaler = smoothstep(0.6,0.58,length(co.xz));\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -" gl_PointSize = (9.0*scaler) / (max( gl_Position.z, 2.0 ));\n" -" aWorldCo = world_pos0;\n" -" aColour = a_colour*scaler*(1.0-uAnim.y*uAnim.y);\n" -" aCo = co;\n" -"}\n" -""}, - .fs = -{ -.orig_file = "shaders/cloud.fs", -.static_src = -"out vec4 FragColor;\n" -"\n" -"#line 1 1 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"layout (location = 1) out vec2 oMotionVec;\n" -"\n" -"in vec3 aMotionVec0;\n" -"in vec3 aMotionVec1;\n" -"\n" -"void compute_motion_vectors()\n" -"{\n" -" // Write motion vectors\n" -" vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" -" vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -"\n" -" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" -"}\n" -"\n" -"#line 4 0 \n" -"\n" -"uniform vec3 uCamera;\n" -"\n" -"in vec4 aColour;\n" -"in vec3 aCo;\n" -"in vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec2 ssuv = gl_FragCoord.xy;\n" -" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" -" float dither = fract( vDither.g / 71.0 ) - 0.5;\n" -"\n" -" float diff = length(gl_PointCoord.xy-vec2(0.5));\n" -" if( diff+dither>0.5 )discard;\n" -"\n" -" compute_motion_vectors();\n" -" FragColor = aColour;\n" -"}\n" -""}, -}; - -static GLuint _uniform_point_map_uMdl; -static GLuint _uniform_point_map_uNormMtx; -static GLuint _uniform_point_map_uPv; -static GLuint _uniform_point_map_uPvmPrev; -static GLuint _uniform_point_map_uAnim; -static GLuint _uniform_point_map_uCamera; -static void shader_point_map_uMdl(m4x3f m){ - glUniformMatrix4x3fv(_uniform_point_map_uMdl,1,GL_FALSE,(float*)m); -} -static void shader_point_map_uNormMtx(m3x3f m){ - glUniformMatrix3fv(_uniform_point_map_uNormMtx,1,GL_FALSE,(float*)m); -} -static void shader_point_map_uPv(m4x4f m){ - glUniformMatrix4fv(_uniform_point_map_uPv,1,GL_FALSE,(float*)m); -} -static void shader_point_map_uPvmPrev(m4x4f m){ - glUniformMatrix4fv(_uniform_point_map_uPvmPrev,1,GL_FALSE,(float*)m); -} -static void shader_point_map_uAnim(v4f v){ - glUniform4fv(_uniform_point_map_uAnim,1,v); -} -static void shader_point_map_uCamera(v3f v){ - glUniform3fv(_uniform_point_map_uCamera,1,v); -} -static void shader_point_map_register(void){ - vg_shader_register( &_shader_point_map ); -} -static void shader_point_map_use(void){ glUseProgram(_shader_point_map.id); } -static void shader_point_map_link(void){ - _uniform_point_map_uMdl = glGetUniformLocation( _shader_point_map.id, "uMdl" ); - _uniform_point_map_uNormMtx = glGetUniformLocation( _shader_point_map.id, "uNormMtx" ); - _uniform_point_map_uPv = glGetUniformLocation( _shader_point_map.id, "uPv" ); - _uniform_point_map_uPvmPrev = glGetUniformLocation( _shader_point_map.id, "uPvmPrev" ); - _uniform_point_map_uAnim = glGetUniformLocation( _shader_point_map.id, "uAnim" ); - _uniform_point_map_uCamera = glGetUniformLocation( _shader_point_map.id, "uCamera" ); -} -#endif /* SHADER_point_map_H */ diff --git a/shaders/routeui.h b/shaders/routeui.h deleted file mode 100644 index 9be8ddc..0000000 --- a/shaders/routeui.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_routeui; -extern GLuint _uniform_routeui_uOffset; -extern GLuint _uniform_routeui_uColour; -static inline void shader_routeui_uOffset(v4f v) -{ - glUniform4fv(_uniform_routeui_uOffset,1,v); -} -static inline void shader_routeui_uColour(v4f v) -{ - glUniform4fv(_uniform_routeui_uColour,1,v); -} -static inline void shader_routeui_use(void); -static inline void shader_routeui_use(void) -{ - glUseProgram(_shader_routeui.id); -} diff --git a/shaders/scene_cubemapped.h b/shaders/scene_cubemapped.h deleted file mode 100644 index f7dfbbd..0000000 --- a/shaders/scene_cubemapped.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_cubemapped; -extern GLuint _uniform_scene_cubemapped_uMdl; -extern GLuint _uniform_scene_cubemapped_uPv; -extern GLuint _uniform_scene_cubemapped_uPvmPrev; -extern GLuint _uniform_scene_cubemapped_uTexGarbage; -extern GLuint _uniform_scene_cubemapped_uTexMain; -extern GLuint _uniform_scene_cubemapped_uTexCubemap; -extern GLuint _uniform_scene_cubemapped_uCamera; -extern GLuint _uniform_scene_cubemapped_uPlane; -extern GLuint _uniform_scene_cubemapped_uColour; -extern GLuint _uniform_scene_cubemapped_g_world_depth; -extern GLuint _uniform_scene_cubemapped_uLightsArray; -extern GLuint _uniform_scene_cubemapped_uLightsIndex; -static inline void shader_scene_cubemapped_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_cubemapped_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_cubemapped_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_cubemapped_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_cubemapped_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_cubemapped_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_cubemapped_uTexGarbage(int i) -{ - glUniform1i(_uniform_scene_cubemapped_uTexGarbage,i); -} -static inline void shader_scene_cubemapped_uTexMain(int i) -{ - glUniform1i(_uniform_scene_cubemapped_uTexMain,i); -} -static inline void shader_scene_cubemapped_uTexCubemap(int i) -{ - glUniform1i(_uniform_scene_cubemapped_uTexCubemap,i); -} -static inline void shader_scene_cubemapped_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_cubemapped_uCamera,1,v); -} -static inline void shader_scene_cubemapped_uPlane(v4f v) -{ - glUniform4fv(_uniform_scene_cubemapped_uPlane,1,v); -} -static inline void shader_scene_cubemapped_uColour(v4f v) -{ - glUniform4fv(_uniform_scene_cubemapped_uColour,1,v); -} -static inline void shader_scene_cubemapped_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_cubemapped_g_world_depth,i); -} -static inline void shader_scene_cubemapped_use(void); -static inline void shader_scene_cubemapped_use(void) -{ - glUseProgram(_shader_scene_cubemapped.id); -} diff --git a/shaders/scene_depth.h b/shaders/scene_depth.h deleted file mode 100644 index d760b33..0000000 --- a/shaders/scene_depth.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_depth; -extern GLuint _uniform_scene_depth_uMdl; -extern GLuint _uniform_scene_depth_uPv; -extern GLuint _uniform_scene_depth_uPvmPrev; -extern GLuint _uniform_scene_depth_uCamera; -extern GLuint _uniform_scene_depth_uBoard0; -extern GLuint _uniform_scene_depth_uBoard1; -extern GLuint _uniform_scene_depth_g_world_depth; -extern GLuint _uniform_scene_depth_uLightsArray; -extern GLuint _uniform_scene_depth_uLightsIndex; -static inline void shader_scene_depth_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_depth_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_depth_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_depth_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_depth_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_depth_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_depth_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_depth_uCamera,1,v); -} -static inline void shader_scene_depth_uBoard0(v3f v) -{ - glUniform3fv(_uniform_scene_depth_uBoard0,1,v); -} -static inline void shader_scene_depth_uBoard1(v3f v) -{ - glUniform3fv(_uniform_scene_depth_uBoard1,1,v); -} -static inline void shader_scene_depth_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_depth_g_world_depth,i); -} -static inline void shader_scene_depth_use(void); -static inline void shader_scene_depth_use(void) -{ - glUseProgram(_shader_scene_depth.id); -} diff --git a/shaders/scene_foliage.h b/shaders/scene_foliage.h deleted file mode 100644 index 2f4249e..0000000 --- a/shaders/scene_foliage.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_foliage; -extern GLuint _uniform_scene_foliage_uMdl; -extern GLuint _uniform_scene_foliage_uPv; -extern GLuint _uniform_scene_foliage_uPvmPrev; -extern GLuint _uniform_scene_foliage_uTime; -extern GLuint _uniform_scene_foliage_uTexGarbage; -extern GLuint _uniform_scene_foliage_uTexMain; -extern GLuint _uniform_scene_foliage_uCamera; -extern GLuint _uniform_scene_foliage_uPlane; -extern GLuint _uniform_scene_foliage_g_world_depth; -extern GLuint _uniform_scene_foliage_uLightsArray; -extern GLuint _uniform_scene_foliage_uLightsIndex; -static inline void shader_scene_foliage_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_foliage_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_foliage_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_foliage_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_foliage_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_foliage_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_foliage_uTime(f32 f) -{ - glUniform1f(_uniform_scene_foliage_uTime,f); -} -static inline void shader_scene_foliage_uTexGarbage(int i) -{ - glUniform1i(_uniform_scene_foliage_uTexGarbage,i); -} -static inline void shader_scene_foliage_uTexMain(int i) -{ - glUniform1i(_uniform_scene_foliage_uTexMain,i); -} -static inline void shader_scene_foliage_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_foliage_uCamera,1,v); -} -static inline void shader_scene_foliage_uPlane(v4f v) -{ - glUniform4fv(_uniform_scene_foliage_uPlane,1,v); -} -static inline void shader_scene_foliage_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_foliage_g_world_depth,i); -} -static inline void shader_scene_foliage_use(void); -static inline void shader_scene_foliage_use(void) -{ - glUseProgram(_shader_scene_foliage.id); -} diff --git a/shaders/scene_font.h b/shaders/scene_font.h deleted file mode 100644 index 53f22c3..0000000 --- a/shaders/scene_font.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_font; -extern GLuint _uniform_scene_font_uMdl; -extern GLuint _uniform_scene_font_uPv; -extern GLuint _uniform_scene_font_uPvmPrev; -extern GLuint _uniform_scene_font_uOffset; -extern GLuint _uniform_scene_font_uTexGarbage; -extern GLuint _uniform_scene_font_uTexMain; -extern GLuint _uniform_scene_font_uCamera; -extern GLuint _uniform_scene_font_uTime; -extern GLuint _uniform_scene_font_uOpacity; -extern GLuint _uniform_scene_font_uColourize; -extern GLuint _uniform_scene_font_g_world_depth; -extern GLuint _uniform_scene_font_uLightsArray; -extern GLuint _uniform_scene_font_uLightsIndex; -static inline void shader_scene_font_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_font_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_font_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_font_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_font_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_font_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_font_uOffset(v4f v) -{ - glUniform4fv(_uniform_scene_font_uOffset,1,v); -} -static inline void shader_scene_font_uTexGarbage(int i) -{ - glUniform1i(_uniform_scene_font_uTexGarbage,i); -} -static inline void shader_scene_font_uTexMain(int i) -{ - glUniform1i(_uniform_scene_font_uTexMain,i); -} -static inline void shader_scene_font_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_font_uCamera,1,v); -} -static inline void shader_scene_font_uTime(f32 f) -{ - glUniform1f(_uniform_scene_font_uTime,f); -} -static inline void shader_scene_font_uOpacity(f32 f) -{ - glUniform1f(_uniform_scene_font_uOpacity,f); -} -static inline void shader_scene_font_uColourize(f32 f) -{ - glUniform1f(_uniform_scene_font_uColourize,f); -} -static inline void shader_scene_font_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_font_g_world_depth,i); -} -static inline void shader_scene_font_use(void); -static inline void shader_scene_font_use(void) -{ - glUseProgram(_shader_scene_font.id); -} diff --git a/shaders/scene_fxglow.h b/shaders/scene_fxglow.h deleted file mode 100644 index 8147639..0000000 --- a/shaders/scene_fxglow.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_fxglow; -extern GLuint _uniform_scene_fxglow_uMdl; -extern GLuint _uniform_scene_fxglow_uPv; -extern GLuint _uniform_scene_fxglow_uPvmPrev; -extern GLuint _uniform_scene_fxglow_uUvOffset; -extern GLuint _uniform_scene_fxglow_uTexMain; -extern GLuint _uniform_scene_fxglow_uCamera; -extern GLuint _uniform_scene_fxglow_g_world_depth; -extern GLuint _uniform_scene_fxglow_uLightsArray; -extern GLuint _uniform_scene_fxglow_uLightsIndex; -static inline void shader_scene_fxglow_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_fxglow_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_fxglow_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_fxglow_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_fxglow_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_fxglow_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_fxglow_uUvOffset(v2f v) -{ - glUniform2fv(_uniform_scene_fxglow_uUvOffset,1,v); -} -static inline void shader_scene_fxglow_uTexMain(int i) -{ - glUniform1i(_uniform_scene_fxglow_uTexMain,i); -} -static inline void shader_scene_fxglow_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_fxglow_uCamera,1,v); -} -static inline void shader_scene_fxglow_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_fxglow_g_world_depth,i); -} -static inline void shader_scene_fxglow_use(void); -static inline void shader_scene_fxglow_use(void) -{ - glUseProgram(_shader_scene_fxglow.id); -} diff --git a/shaders/scene_override.h b/shaders/scene_override.h deleted file mode 100644 index 3b29c99..0000000 --- a/shaders/scene_override.h +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_override; -extern GLuint _uniform_scene_override_uMdl; -extern GLuint _uniform_scene_override_uPv; -extern GLuint _uniform_scene_override_uPvmPrev; -extern GLuint _uniform_scene_override_uNormalMtx; -extern GLuint _uniform_scene_override_uTexGarbage; -extern GLuint _uniform_scene_override_uTexMain; -extern GLuint _uniform_scene_override_uCamera; -extern GLuint _uniform_scene_override_uPlane; -extern GLuint _uniform_scene_override_uPlayerPos; -extern GLuint _uniform_scene_override_uSpawnPos; -extern GLuint _uniform_scene_override_uAlphatest; -extern GLuint _uniform_scene_override_uMapInfo; -extern GLuint _uniform_scene_override_g_world_depth; -extern GLuint _uniform_scene_override_uLightsArray; -extern GLuint _uniform_scene_override_uLightsIndex; -static inline void shader_scene_override_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_override_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_override_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_override_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_override_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_override_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_override_uNormalMtx(m3x3f m) -{ - glUniformMatrix3fv(_uniform_scene_override_uNormalMtx,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_override_uTexGarbage(int i) -{ - glUniform1i(_uniform_scene_override_uTexGarbage,i); -} -static inline void shader_scene_override_uTexMain(int i) -{ - glUniform1i(_uniform_scene_override_uTexMain,i); -} -static inline void shader_scene_override_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_override_uCamera,1,v); -} -static inline void shader_scene_override_uPlane(v4f v) -{ - glUniform4fv(_uniform_scene_override_uPlane,1,v); -} -static inline void shader_scene_override_uPlayerPos(v4f v) -{ - glUniform4fv(_uniform_scene_override_uPlayerPos,1,v); -} -static inline void shader_scene_override_uSpawnPos(v4f v) -{ - glUniform4fv(_uniform_scene_override_uSpawnPos,1,v); -} -static inline void shader_scene_override_uAlphatest(int b) -{ - glUniform1i(_uniform_scene_override_uAlphatest,b); -} -static inline void shader_scene_override_uMapInfo(v4f v) -{ - glUniform4fv(_uniform_scene_override_uMapInfo,1,v); -} -static inline void shader_scene_override_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_override_g_world_depth,i); -} -static inline void shader_scene_override_use(void); -static inline void shader_scene_override_use(void) -{ - glUseProgram(_shader_scene_override.id); -} diff --git a/shaders/scene_position.h b/shaders/scene_position.h deleted file mode 100644 index 2e99c02..0000000 --- a/shaders/scene_position.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_position; -extern GLuint _uniform_scene_position_uMdl; -extern GLuint _uniform_scene_position_uPv; -extern GLuint _uniform_scene_position_uPvmPrev; -extern GLuint _uniform_scene_position_uCamera; -extern GLuint _uniform_scene_position_uBoard0; -extern GLuint _uniform_scene_position_uBoard1; -extern GLuint _uniform_scene_position_g_world_depth; -extern GLuint _uniform_scene_position_uLightsArray; -extern GLuint _uniform_scene_position_uLightsIndex; -static inline void shader_scene_position_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_position_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_position_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_position_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_position_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_position_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_position_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_position_uCamera,1,v); -} -static inline void shader_scene_position_uBoard0(v3f v) -{ - glUniform3fv(_uniform_scene_position_uBoard0,1,v); -} -static inline void shader_scene_position_uBoard1(v3f v) -{ - glUniform3fv(_uniform_scene_position_uBoard1,1,v); -} -static inline void shader_scene_position_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_position_g_world_depth,i); -} -static inline void shader_scene_position_use(void); -static inline void shader_scene_position_use(void) -{ - glUseProgram(_shader_scene_position.id); -} diff --git a/shaders/scene_route.h b/shaders/scene_route.h deleted file mode 100644 index b9fc0aa..0000000 --- a/shaders/scene_route.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_route; -extern GLuint _uniform_scene_route_uMdl; -extern GLuint _uniform_scene_route_uPv; -extern GLuint _uniform_scene_route_uPvmPrev; -extern GLuint _uniform_scene_route_uNormalMtx; -extern GLuint _uniform_scene_route_uTexGarbage; -extern GLuint _uniform_scene_route_uTexGradients; -extern GLuint _uniform_scene_route_uCamera; -extern GLuint _uniform_scene_route_uColour; -extern GLuint _uniform_scene_route_g_world_depth; -extern GLuint _uniform_scene_route_uLightsArray; -extern GLuint _uniform_scene_route_uLightsIndex; -static inline void shader_scene_route_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_route_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_route_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_route_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_route_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_route_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_route_uNormalMtx(m3x3f m) -{ - glUniformMatrix3fv(_uniform_scene_route_uNormalMtx,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_route_uTexGarbage(int i) -{ - glUniform1i(_uniform_scene_route_uTexGarbage,i); -} -static inline void shader_scene_route_uTexGradients(int i) -{ - glUniform1i(_uniform_scene_route_uTexGradients,i); -} -static inline void shader_scene_route_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_route_uCamera,1,v); -} -static inline void shader_scene_route_uColour(v4f v) -{ - glUniform4fv(_uniform_scene_route_uColour,1,v); -} -static inline void shader_scene_route_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_route_g_world_depth,i); -} -static inline void shader_scene_route_use(void); -static inline void shader_scene_route_use(void) -{ - glUseProgram(_shader_scene_route.id); -} diff --git a/shaders/scene_scoretext.h b/shaders/scene_scoretext.h deleted file mode 100644 index 0be2bf2..0000000 --- a/shaders/scene_scoretext.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_scoretext; -extern GLuint _uniform_scene_scoretext_uMdl; -extern GLuint _uniform_scene_scoretext_uPv; -extern GLuint _uniform_scene_scoretext_uPvmPrev; -extern GLuint _uniform_scene_scoretext_uInfo; -extern GLuint _uniform_scene_scoretext_uTexGarbage; -extern GLuint _uniform_scene_scoretext_uTexMain; -extern GLuint _uniform_scene_scoretext_uCamera; -extern GLuint _uniform_scene_scoretext_uPlane; -extern GLuint _uniform_scene_scoretext_g_world_depth; -extern GLuint _uniform_scene_scoretext_uLightsArray; -extern GLuint _uniform_scene_scoretext_uLightsIndex; -static inline void shader_scene_scoretext_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_scoretext_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_scoretext_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_scoretext_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_scoretext_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_scoretext_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_scoretext_uInfo(v3f v) -{ - glUniform3fv(_uniform_scene_scoretext_uInfo,1,v); -} -static inline void shader_scene_scoretext_uTexGarbage(int i) -{ - glUniform1i(_uniform_scene_scoretext_uTexGarbage,i); -} -static inline void shader_scene_scoretext_uTexMain(int i) -{ - glUniform1i(_uniform_scene_scoretext_uTexMain,i); -} -static inline void shader_scene_scoretext_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_scoretext_uCamera,1,v); -} -static inline void shader_scene_scoretext_uPlane(v4f v) -{ - glUniform4fv(_uniform_scene_scoretext_uPlane,1,v); -} -static inline void shader_scene_scoretext_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_scoretext_g_world_depth,i); -} -static inline void shader_scene_scoretext_use(void); -static inline void shader_scene_scoretext_use(void) -{ - glUseProgram(_shader_scene_scoretext.id); -} diff --git a/shaders/scene_standard.h b/shaders/scene_standard.h deleted file mode 100644 index 0dca3c7..0000000 --- a/shaders/scene_standard.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_standard; -extern GLuint _uniform_scene_standard_uMdl; -extern GLuint _uniform_scene_standard_uPv; -extern GLuint _uniform_scene_standard_uPvmPrev; -extern GLuint _uniform_scene_standard_uTexGarbage; -extern GLuint _uniform_scene_standard_uTexMain; -extern GLuint _uniform_scene_standard_uCamera; -extern GLuint _uniform_scene_standard_uPlane; -extern GLuint _uniform_scene_standard_g_world_depth; -extern GLuint _uniform_scene_standard_uLightsArray; -extern GLuint _uniform_scene_standard_uLightsIndex; -static inline void shader_scene_standard_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_standard_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_standard_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_standard_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_standard_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_standard_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_standard_uTexGarbage(int i) -{ - glUniform1i(_uniform_scene_standard_uTexGarbage,i); -} -static inline void shader_scene_standard_uTexMain(int i) -{ - glUniform1i(_uniform_scene_standard_uTexMain,i); -} -static inline void shader_scene_standard_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_standard_uCamera,1,v); -} -static inline void shader_scene_standard_uPlane(v4f v) -{ - glUniform4fv(_uniform_scene_standard_uPlane,1,v); -} -static inline void shader_scene_standard_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_standard_g_world_depth,i); -} -static inline void shader_scene_standard_use(void); -static inline void shader_scene_standard_use(void) -{ - glUseProgram(_shader_scene_standard.id); -} diff --git a/shaders/scene_standard_alphatest.h b/shaders/scene_standard_alphatest.h deleted file mode 100644 index 73fc7a6..0000000 --- a/shaders/scene_standard_alphatest.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_standard_alphatest; -extern GLuint _uniform_scene_standard_alphatest_uMdl; -extern GLuint _uniform_scene_standard_alphatest_uPv; -extern GLuint _uniform_scene_standard_alphatest_uPvmPrev; -extern GLuint _uniform_scene_standard_alphatest_uTexGarbage; -extern GLuint _uniform_scene_standard_alphatest_uTexMain; -extern GLuint _uniform_scene_standard_alphatest_uCamera; -extern GLuint _uniform_scene_standard_alphatest_uPlane; -extern GLuint _uniform_scene_standard_alphatest_g_world_depth; -extern GLuint _uniform_scene_standard_alphatest_uLightsArray; -extern GLuint _uniform_scene_standard_alphatest_uLightsIndex; -static inline void shader_scene_standard_alphatest_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_standard_alphatest_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_standard_alphatest_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_standard_alphatest_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_standard_alphatest_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_standard_alphatest_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_standard_alphatest_uTexGarbage(int i) -{ - glUniform1i(_uniform_scene_standard_alphatest_uTexGarbage,i); -} -static inline void shader_scene_standard_alphatest_uTexMain(int i) -{ - glUniform1i(_uniform_scene_standard_alphatest_uTexMain,i); -} -static inline void shader_scene_standard_alphatest_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_standard_alphatest_uCamera,1,v); -} -static inline void shader_scene_standard_alphatest_uPlane(v4f v) -{ - glUniform4fv(_uniform_scene_standard_alphatest_uPlane,1,v); -} -static inline void shader_scene_standard_alphatest_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_standard_alphatest_g_world_depth,i); -} -static inline void shader_scene_standard_alphatest_use(void); -static inline void shader_scene_standard_alphatest_use(void) -{ - glUseProgram(_shader_scene_standard_alphatest.id); -} diff --git a/shaders/scene_terrain.h b/shaders/scene_terrain.h deleted file mode 100644 index 37b6a3c..0000000 --- a/shaders/scene_terrain.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_terrain; -extern GLuint _uniform_scene_terrain_uMdl; -extern GLuint _uniform_scene_terrain_uPv; -extern GLuint _uniform_scene_terrain_uPvmPrev; -extern GLuint _uniform_scene_terrain_uTexGarbage; -extern GLuint _uniform_scene_terrain_uTexGradients; -extern GLuint _uniform_scene_terrain_uCamera; -extern GLuint _uniform_scene_terrain_uSandColour; -extern GLuint _uniform_scene_terrain_uBlendOffset; -extern GLuint _uniform_scene_terrain_g_world_depth; -extern GLuint _uniform_scene_terrain_uLightsArray; -extern GLuint _uniform_scene_terrain_uLightsIndex; -static inline void shader_scene_terrain_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_terrain_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_terrain_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_terrain_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_terrain_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_terrain_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_terrain_uTexGarbage(int i) -{ - glUniform1i(_uniform_scene_terrain_uTexGarbage,i); -} -static inline void shader_scene_terrain_uTexGradients(int i) -{ - glUniform1i(_uniform_scene_terrain_uTexGradients,i); -} -static inline void shader_scene_terrain_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_terrain_uCamera,1,v); -} -static inline void shader_scene_terrain_uSandColour(v3f v) -{ - glUniform3fv(_uniform_scene_terrain_uSandColour,1,v); -} -static inline void shader_scene_terrain_uBlendOffset(v2f v) -{ - glUniform2fv(_uniform_scene_terrain_uBlendOffset,1,v); -} -static inline void shader_scene_terrain_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_terrain_g_world_depth,i); -} -static inline void shader_scene_terrain_use(void); -static inline void shader_scene_terrain_use(void) -{ - glUseProgram(_shader_scene_terrain.id); -} diff --git a/shaders/scene_vertex_blend.h b/shaders/scene_vertex_blend.h deleted file mode 100644 index 376c81b..0000000 --- a/shaders/scene_vertex_blend.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_vertex_blend; -extern GLuint _uniform_scene_vertex_blend_uMdl; -extern GLuint _uniform_scene_vertex_blend_uPv; -extern GLuint _uniform_scene_vertex_blend_uPvmPrev; -extern GLuint _uniform_scene_vertex_blend_uTexGarbage; -extern GLuint _uniform_scene_vertex_blend_uTexGradients; -extern GLuint _uniform_scene_vertex_blend_uCamera; -extern GLuint _uniform_scene_vertex_blend_g_world_depth; -extern GLuint _uniform_scene_vertex_blend_uLightsArray; -extern GLuint _uniform_scene_vertex_blend_uLightsIndex; -static inline void shader_scene_vertex_blend_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_vertex_blend_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_vertex_blend_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_vertex_blend_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_vertex_blend_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_vertex_blend_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_vertex_blend_uTexGarbage(int i) -{ - glUniform1i(_uniform_scene_vertex_blend_uTexGarbage,i); -} -static inline void shader_scene_vertex_blend_uTexGradients(int i) -{ - glUniform1i(_uniform_scene_vertex_blend_uTexGradients,i); -} -static inline void shader_scene_vertex_blend_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_vertex_blend_uCamera,1,v); -} -static inline void shader_scene_vertex_blend_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_vertex_blend_g_world_depth,i); -} -static inline void shader_scene_vertex_blend_use(void); -static inline void shader_scene_vertex_blend_use(void) -{ - glUseProgram(_shader_scene_vertex_blend.id); -} diff --git a/shaders/scene_water.h b/shaders/scene_water.h deleted file mode 100644 index 50ac3d2..0000000 --- a/shaders/scene_water.h +++ /dev/null @@ -1,100 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_water; -extern GLuint _uniform_scene_water_uMdl; -extern GLuint _uniform_scene_water_uPv; -extern GLuint _uniform_scene_water_uPvmPrev; -extern GLuint _uniform_scene_water_uTexMain; -extern GLuint _uniform_scene_water_uTexDudv; -extern GLuint _uniform_scene_water_uTexBack; -extern GLuint _uniform_scene_water_uInvRes; -extern GLuint _uniform_scene_water_uTime; -extern GLuint _uniform_scene_water_uCamera; -extern GLuint _uniform_scene_water_uSurfaceY; -extern GLuint _uniform_scene_water_uBoard0; -extern GLuint _uniform_scene_water_uBoard1; -extern GLuint _uniform_scene_water_uShoreColour; -extern GLuint _uniform_scene_water_uOceanColour; -extern GLuint _uniform_scene_water_uFresnel; -extern GLuint _uniform_scene_water_uWaterScale; -extern GLuint _uniform_scene_water_uWaveSpeed; -extern GLuint _uniform_scene_water_g_world_depth; -extern GLuint _uniform_scene_water_uLightsArray; -extern GLuint _uniform_scene_water_uLightsIndex; -static inline void shader_scene_water_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_water_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_water_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_water_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_water_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_water_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_water_uTexMain(int i) -{ - glUniform1i(_uniform_scene_water_uTexMain,i); -} -static inline void shader_scene_water_uTexDudv(int i) -{ - glUniform1i(_uniform_scene_water_uTexDudv,i); -} -static inline void shader_scene_water_uTexBack(int i) -{ - glUniform1i(_uniform_scene_water_uTexBack,i); -} -static inline void shader_scene_water_uInvRes(v2f v) -{ - glUniform2fv(_uniform_scene_water_uInvRes,1,v); -} -static inline void shader_scene_water_uTime(f32 f) -{ - glUniform1f(_uniform_scene_water_uTime,f); -} -static inline void shader_scene_water_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_water_uCamera,1,v); -} -static inline void shader_scene_water_uSurfaceY(f32 f) -{ - glUniform1f(_uniform_scene_water_uSurfaceY,f); -} -static inline void shader_scene_water_uBoard0(v3f v) -{ - glUniform3fv(_uniform_scene_water_uBoard0,1,v); -} -static inline void shader_scene_water_uBoard1(v3f v) -{ - glUniform3fv(_uniform_scene_water_uBoard1,1,v); -} -static inline void shader_scene_water_uShoreColour(v3f v) -{ - glUniform3fv(_uniform_scene_water_uShoreColour,1,v); -} -static inline void shader_scene_water_uOceanColour(v3f v) -{ - glUniform3fv(_uniform_scene_water_uOceanColour,1,v); -} -static inline void shader_scene_water_uFresnel(f32 f) -{ - glUniform1f(_uniform_scene_water_uFresnel,f); -} -static inline void shader_scene_water_uWaterScale(f32 f) -{ - glUniform1f(_uniform_scene_water_uWaterScale,f); -} -static inline void shader_scene_water_uWaveSpeed(v4f v) -{ - glUniform4fv(_uniform_scene_water_uWaveSpeed,1,v); -} -static inline void shader_scene_water_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_water_g_world_depth,i); -} -static inline void shader_scene_water_use(void); -static inline void shader_scene_water_use(void) -{ - glUseProgram(_shader_scene_water.id); -} diff --git a/shaders/scene_water_fast.h b/shaders/scene_water_fast.h deleted file mode 100644 index e0f1b4c..0000000 --- a/shaders/scene_water_fast.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_scene_water_fast; -extern GLuint _uniform_scene_water_fast_uMdl; -extern GLuint _uniform_scene_water_fast_uPv; -extern GLuint _uniform_scene_water_fast_uPvmPrev; -extern GLuint _uniform_scene_water_fast_uTexDudv; -extern GLuint _uniform_scene_water_fast_uTime; -extern GLuint _uniform_scene_water_fast_uCamera; -extern GLuint _uniform_scene_water_fast_uSurfaceY; -extern GLuint _uniform_scene_water_fast_uBoard0; -extern GLuint _uniform_scene_water_fast_uBoard1; -extern GLuint _uniform_scene_water_fast_uShoreColour; -extern GLuint _uniform_scene_water_fast_uOceanColour; -extern GLuint _uniform_scene_water_fast_g_world_depth; -extern GLuint _uniform_scene_water_fast_uLightsArray; -extern GLuint _uniform_scene_water_fast_uLightsIndex; -static inline void shader_scene_water_fast_uMdl(m4x3f m) -{ - glUniformMatrix4x3fv(_uniform_scene_water_fast_uMdl,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_water_fast_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_water_fast_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_water_fast_uPvmPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_scene_water_fast_uPvmPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_scene_water_fast_uTexDudv(int i) -{ - glUniform1i(_uniform_scene_water_fast_uTexDudv,i); -} -static inline void shader_scene_water_fast_uTime(f32 f) -{ - glUniform1f(_uniform_scene_water_fast_uTime,f); -} -static inline void shader_scene_water_fast_uCamera(v3f v) -{ - glUniform3fv(_uniform_scene_water_fast_uCamera,1,v); -} -static inline void shader_scene_water_fast_uSurfaceY(f32 f) -{ - glUniform1f(_uniform_scene_water_fast_uSurfaceY,f); -} -static inline void shader_scene_water_fast_uBoard0(v3f v) -{ - glUniform3fv(_uniform_scene_water_fast_uBoard0,1,v); -} -static inline void shader_scene_water_fast_uBoard1(v3f v) -{ - glUniform3fv(_uniform_scene_water_fast_uBoard1,1,v); -} -static inline void shader_scene_water_fast_uShoreColour(v3f v) -{ - glUniform3fv(_uniform_scene_water_fast_uShoreColour,1,v); -} -static inline void shader_scene_water_fast_uOceanColour(v3f v) -{ - glUniform3fv(_uniform_scene_water_fast_uOceanColour,1,v); -} -static inline void shader_scene_water_fast_g_world_depth(int i) -{ - glUniform1i(_uniform_scene_water_fast_g_world_depth,i); -} -static inline void shader_scene_water_fast_use(void); -static inline void shader_scene_water_fast_use(void) -{ - glUseProgram(_shader_scene_water_fast.id); -} diff --git a/shaders/trail.h b/shaders/trail.h deleted file mode 100644 index b9ab766..0000000 --- a/shaders/trail.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "vg/vg_engine.h" -extern struct vg_shader _shader_trail; -extern GLuint _uniform_trail_uPv; -extern GLuint _uniform_trail_uPvPrev; -extern GLuint _uniform_trail_uColour; -static inline void shader_trail_uPv(m4x4f m) -{ - glUniformMatrix4fv(_uniform_trail_uPv,1,GL_FALSE,(f32*)m); -} -static inline void shader_trail_uPvPrev(m4x4f m) -{ - glUniformMatrix4fv(_uniform_trail_uPvPrev,1,GL_FALSE,(f32*)m); -} -static inline void shader_trail_uColour(v4f v) -{ - glUniform4fv(_uniform_trail_uColour,1,v); -} -static inline void shader_trail_use(void); -static inline void shader_trail_use(void) -{ - glUseProgram(_shader_trail.id); -} -- 2.25.1