diff --git a/build.sh b/build.sh index e23d233..3c2663e 100755 --- a/build.sh +++ b/build.sh @@ -4,5 +4,5 @@ cd src/shaders/ ./compile_shaders.sh cd .. cd .. -jai-linux -x64 first.jai +jai -x64 first.jai ./first diff --git a/resources/lut.png b/resources/lut.png new file mode 100644 index 0000000..56c9846 Binary files /dev/null and b/resources/lut.png differ diff --git a/src/arbtri.jai b/src/arbtri.jai index cb35cfd..ac4486e 100644 --- a/src/arbtri.jai +++ b/src/arbtri.jai @@ -61,21 +61,22 @@ arb_tri_add :: (tri: Arb_Tri) { array_add(*arbTriState.trilist, tri); } +transform_to_screen_x :: (coord: float) -> float { + w, h := get_window_size(); + return (coord / cast(float) w) * 2.0 - 1.0; +} + +transform_to_screen_y :: (coord: float) -> float { + w, h := get_window_size(); + return (coord / cast(float) h) * 2.0 - 1.0; +} + arb_tri_flush :: () { if !arbTriState.active { return; } - transform_to_screen_x :: (coord: float) -> float { - w, h := get_window_size(); - return (coord / cast(float) w) * 2.0 - 1.0; - } - - transform_to_screen_y :: (coord: float) -> float { - w, h := get_window_size(); - return (coord / cast(float) h) * 2.0 - 1.0; - } arbTriState.active = false; diff --git a/src/editor/iprof.jai b/src/editor/iprof.jai index d5ab804..825d9be 100644 --- a/src/editor/iprof.jai +++ b/src/editor/iprof.jai @@ -69,6 +69,8 @@ init_profiler :: () { iprof_conf.text_width = text_width; iprof_conf.draw_rectangle = draw_rectangle_prof; iprof_conf.draw_line = draw_line; + iprof_conf.graph_begin = graph_begin; + iprof_conf.graph_end = graph_end; } draw_profiler :: () { diff --git a/src/editor/trile_editor.jai b/src/editor/trile_editor.jai index 176e26c..723be9e 100644 --- a/src/editor/trile_editor.jai +++ b/src/editor/trile_editor.jai @@ -240,7 +240,12 @@ draw_trile :: () { mvp := create_viewproj(*cam); vs_params : Vs_Params; vs_params.mvp = mvp.floats; + vs_params.camera = cam.position.component; + world_conf : Trixel_World_Config; + wc : *World_Config = *(World_Config.{}); + world_config_to_shader_type(wc, *world_conf); + trixels : [4096]Position_Color; min_distance : float = 999.0; @@ -272,8 +277,6 @@ draw_trile :: () { for y: 0..15 { for z: 0..15 { if current_trile.trixels[x][y][z].empty then continue; - hit := does_ray_hit_cube(ray, .{ .{x * TRIXEL_SIZE, y * TRIXEL_SIZE, z * TRIXEL_SIZE}, .{TRIXEL_SIZE, TRIXEL_SIZE, TRIXEL_SIZE}}); - trixels[trixel_count].pos.x = x * (1.0 / 16.0) + TRIXEL_SIZE_HALF; trixels[trixel_count].pos.y = y * (1.0 / 16.0) + TRIXEL_SIZE_HALF; @@ -287,7 +290,7 @@ draw_trile :: () { trixel_color = .{1.0, 0.0, 0.0}; } - trixels[trixel_count].col = .{trixel_color.x, trixel_color.y, trixel_color.z, 1.0}; + trixels[trixel_count].col = .{trixel_color.x, trixel_color.y, trixel_color.z, material_encode_to_float(current_trile.trixels[x][y][z].material)}; trixel_count += 1; } } @@ -301,6 +304,7 @@ draw_trile :: () { sg_apply_pipeline(gPipelines.trixel.pipeline); sg_apply_bindings(*gPipelines.trixel.bind); sg_apply_uniforms(UB_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) })); + sg_apply_uniforms(UB_trixel_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))})); sg_draw(0, 36, trixel_count); } diff --git a/src/load.jai b/src/load.jai index 0a796ef..ddaadad 100644 --- a/src/load.jai +++ b/src/load.jai @@ -1,15 +1,14 @@ MAX_FILE_SIZE :: 200_000; buf : [MAX_FILE_SIZE]u8; -mandatory_done : bool = false; +mandatory_loads_left : s32 = 0; init_after_mandatory_done : bool = false; mandatory_loads_done :: () -> bool { - return mandatory_done; + return mandatory_loads_left <= 0; } init_font_loads :: () { - print("SENDING LOAD!!!!\n"); sfetch_send(*(sfetch_request_t.{ path = "./resources/DroidSerif-Regular.ttf".data, callback = fontcb, @@ -22,7 +21,6 @@ init_font_loads :: () { fontcb :: (res: *sfetch_response_t) #c_call { push_context,defer_pop default_context; - print("RDY! Finished? % Fetched? % \n", res.fetched, res.finished); state.font_default.fons_font = fonsAddFontMem(state.fons, "sans", res.data.ptr, xx res.data.size, 0); ui_init_font_fields(*state.font_default); mandatory_done = true; diff --git a/src/main.jai b/src/main.jai index deb7333..db3bbe3 100644 --- a/src/main.jai +++ b/src/main.jai @@ -1,4 +1,4 @@ -#import "Basic"; +#import "Basic"()(MEMORY_DEBUGGER=true); #import "Math"; #import "Input"; #import "Hash_Table"; @@ -131,7 +131,7 @@ frame :: () { input_per_frame_event_and_flag_update(); - memory_visualizer_per_frame_update(); + // memory_visualizer_per_frame_update(); profiler_update(); reset_temporary_storage(); diff --git a/src/shaders/jai/shader_trixel.jai b/src/shaders/jai/shader_trixel.jai index ed6b81b..da977ae 100644 --- a/src/shaders/jai/shader_trixel.jai +++ b/src/shaders/jai/shader_trixel.jai @@ -21,19 +21,47 @@ Uniform block 'vs_params': Jai struct: Vs_Params Bind slot: UB_vs_params => 0 + Uniform block 'trixel_world_config': + Jai struct: Trixel_World_Config + Bind slot: UB_trixel_world_config => 1 */ ATTR_trixel_position :: 0; ATTR_trixel_normal :: 1; ATTR_trixel_inst :: 2; ATTR_trixel_inst_col :: 3; UB_vs_params :: 0; +UB_trixel_world_config :: 1; Vs_Params :: struct { mvp: [16]float; + camera: [3]float; + _: [4]u8; +}; +Trixel_World_Config :: struct { + skyBase: [3]float; + _: [4]u8; + skyTop: [3]float; + _: [4]u8; + sunDisk: [3]float; + _: [4]u8; + horizonHalo: [3]float; + _: [4]u8; + sunHalo: [3]float; + _: [4]u8; + sunLightColor: [3]float; + _: [4]u8; + sunPosition: [3]float; + sunIntensity: float; + hasClouds: s32; + hasPlane: s32; + planeHeight: float; + planeType: s32; + time: float; + _: [12]u8; }; /* #version 430 - uniform vec4 vs_params[4]; + uniform vec4 vs_params[5]; layout(location = 2) in vec4 inst; layout(location = 0) in vec4 position; layout(location = 1) out vec4 fnormal; @@ -41,6 +69,7 @@ Vs_Params :: struct { layout(location = 0) out vec4 color; layout(location = 3) in vec4 inst_col; layout(location = 2) out vec4 pos; + layout(location = 3) out vec3 cam; void main() { @@ -48,13 +77,14 @@ Vs_Params :: struct { fnormal = normal; color = inst_col; pos = gl_Position; + cam = vs_params[4].xyz; } */ vs_trixel_source_glsl430 := u8.[ 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e, 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, - 0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28, + 0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28, 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e, 0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x3b,0x0a,0x6c,0x61,0x79,0x6f, 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, @@ -70,75 +100,284 @@ vs_trixel_source_glsl430 := u8.[ 0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34, 0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75, 0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20, - 0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x0a,0x76, - 0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20, - 0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d, - 0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d, - 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20, - 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73, - 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65, - 0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20, - 0x2b,0x20,0x69,0x6e,0x73,0x74,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29, - 0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20, - 0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f, - 0x72,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x20,0x20, - 0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74, - 0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, + 0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x6c,0x61, + 0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, + 0x33,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x63,0x61,0x6d,0x3b, + 0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a, + 0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20, + 0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73, + 0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31, + 0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c, + 0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a, + 0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78, + 0x79,0x7a,0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31, + 0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c, + 0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f, + 0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x61,0x6d,0x20, + 0x3d,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78, + 0x79,0x7a,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, ]; /* #version 430 + struct trixel_world_config + { + vec3 skyBase; + vec3 skyTop; + vec3 sunDisk; + vec3 horizonHalo; + vec3 sunHalo; + vec3 sunLightColor; + vec3 sunPosition; + float sunIntensity; + int hasClouds; + int hasPlane; + float planeHeight; + int planeType; + float time; + }; + + uniform trixel_world_config _200; + layout(location = 0) in vec4 color; - layout(location = 2) in vec4 pos; layout(location = 1) in vec4 fnormal; + layout(location = 3) in vec3 cam; + layout(location = 2) in vec4 pos; layout(location = 0) out vec4 frag_color; + vec3 fresnelSchlick(float cosTheta, vec3 F0) + { + return F0 + ((vec3(1.0) - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0)); + } + + float DistributionGGX(vec3 N, vec3 H, float roughness) + { + float _36 = roughness * roughness; + float _40 = _36 * _36; + float _46 = max(dot(N, H), 0.0); + float _59 = ((_46 * _46) * (_40 - 1.0)) + 1.0; + return _40 / ((3.141285419464111328125 * _59) * _59); + } + + float GeometrySchlickGGX(float NdotV, float roughness) + { + float _72 = roughness + 1.0; + float _78 = (_72 * _72) * 0.125; + return NdotV / ((NdotV * (1.0 - _78)) + _78); + } + + float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness) + { + float param = max(dot(N, V), 0.0); + float param_1 = roughness; + float param_2 = max(dot(N, L), 0.0); + float param_3 = roughness; + return GeometrySchlickGGX(param_2, param_3) * GeometrySchlickGGX(param, param_1); + } + void main() { - frag_color = vec4(((color.xyz * 0.300000011920928955078125) + ((color.xyz * max(0.0, dot(normalize(vec3(5.0, 5.0, 2.0) - pos.xyz), fnormal.xyz))) * 0.5)) + (((color.xyz * max(0.0, dot(normalize(vec3(-5.0, -2.0, -2.0) - pos.xyz), fnormal.xyz))) * 0.300000011920928955078125) * vec3(1.0, 0.699999988079071044921875, 0.699999988079071044921875)), 1.0); + int _150 = int(round(color.w * 255.0)); + float _172 = max(float((_150 >> 5) & 7) * 0.14285714924335479736328125, 0.0500000007450580596923828125); + float _178 = float((_150 >> 3) & 3) * 0.3333333432674407958984375; + vec3 light = color.xyz * 0.300000011920928955078125; + vec3 _187 = normalize(fnormal.xyz); + vec3 _196 = normalize(cam - pos.xyz); + vec3 _205 = normalize(_200.sunPosition); + vec3 _210 = normalize(_196 + _205); + float param = max(dot(_210, _196), 0.0); + vec3 param_1 = mix(vec3(0.039999999105930328369140625), color.xyz, vec3(_178)); + vec3 _227 = fresnelSchlick(param, param_1); + vec3 param_2 = _187; + vec3 param_3 = _210; + float param_4 = _172; + vec3 param_5 = _187; + vec3 param_6 = _196; + vec3 param_7 = _205; + float param_8 = _172; + float _262 = max(dot(_187, _205), 0.0); + vec3 _294 = light; + vec3 _295 = _294 + ((((((vec3(1.0) - _227) * (1.0 - _178)) * color.xyz) * vec3(0.3183410167694091796875)) + ((_227 * (DistributionGGX(param_2, param_3, param_4) * GeometrySmith(param_5, param_6, param_7, param_8))) / vec3(((4.0 * max(dot(_187, _196), 0.0)) * _262) + 9.9999997473787516355514526367188e-05))) * _262); + light = _295; + frag_color = vec4(_295, 1.0); } */ fs_trixel_source_glsl430 := u8.[ - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61, + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74, + 0x72,0x75,0x63,0x74,0x20,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f,0x77,0x6f,0x72,0x6c, + 0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76, + 0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x54,0x6f,0x70,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e, + 0x48,0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x73, + 0x75,0x6e,0x48,0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33, + 0x20,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69, + 0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20, + 0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x69,0x6e,0x74,0x20,0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64,0x73,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x68,0x61,0x73,0x50,0x6c,0x61,0x6e, + 0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x6c,0x61, + 0x6e,0x65,0x48,0x65,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e, + 0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x54,0x79,0x70,0x65,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x74,0x69,0x6d,0x65,0x3b,0x0a,0x7d,0x3b,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f, + 0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x20,0x5f,0x32,0x30, + 0x30,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74, + 0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c, + 0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20, + 0x76,0x65,0x63,0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61, 0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, - 0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72, + 0x33,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x63,0x61,0x6d,0x3b,0x0a, + 0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20, + 0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73, 0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f, - 0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70, - 0x6f,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74, - 0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34, - 0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74, - 0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f, - 0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c, - 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, - 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, - 0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x28,0x63,0x6f,0x6c,0x6f,0x72, - 0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30, - 0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32, - 0x35,0x29,0x20,0x2b,0x20,0x28,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a, - 0x20,0x2a,0x20,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28, - 0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x76,0x65,0x63,0x33,0x28,0x35, - 0x2e,0x30,0x2c,0x20,0x35,0x2e,0x30,0x2c,0x20,0x32,0x2e,0x30,0x29,0x20,0x2d,0x20, - 0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x2c,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61, - 0x6c,0x2e,0x78,0x79,0x7a,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x29, - 0x20,0x2b,0x20,0x28,0x28,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20, - 0x2a,0x20,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x6e, - 0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x76,0x65,0x63,0x33,0x28,0x2d,0x35, - 0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x20, - 0x2d,0x20,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x2c,0x20,0x66,0x6e,0x6f,0x72, - 0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33, - 0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35, - 0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28, - 0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38, - 0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x2c, - 0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30, - 0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x2c,0x20,0x31, - 0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, + 0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20, + 0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x65,0x63, + 0x33,0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b, + 0x28,0x66,0x6c,0x6f,0x61,0x74,0x20,0x63,0x6f,0x73,0x54,0x68,0x65,0x74,0x61,0x2c, + 0x20,0x76,0x65,0x63,0x33,0x20,0x46,0x30,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x46,0x30,0x20,0x2b,0x20,0x28,0x28,0x76,0x65, + 0x63,0x33,0x28,0x31,0x2e,0x30,0x29,0x20,0x2d,0x20,0x46,0x30,0x29,0x20,0x2a,0x20, + 0x70,0x6f,0x77,0x28,0x63,0x6c,0x61,0x6d,0x70,0x28,0x31,0x2e,0x30,0x20,0x2d,0x20, + 0x63,0x6f,0x73,0x54,0x68,0x65,0x74,0x61,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31, + 0x2e,0x30,0x29,0x2c,0x20,0x35,0x2e,0x30,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x66, + 0x6c,0x6f,0x61,0x74,0x20,0x44,0x69,0x73,0x74,0x72,0x69,0x62,0x75,0x74,0x69,0x6f, + 0x6e,0x47,0x47,0x58,0x28,0x76,0x65,0x63,0x33,0x20,0x4e,0x2c,0x20,0x76,0x65,0x63, + 0x33,0x20,0x48,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x6f,0x75,0x67,0x68, + 0x6e,0x65,0x73,0x73,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x20,0x5f,0x33,0x36,0x20,0x3d,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65,0x73, + 0x73,0x20,0x2a,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x30,0x20,0x3d,0x20,0x5f, + 0x33,0x36,0x20,0x2a,0x20,0x5f,0x33,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x20,0x5f,0x34,0x36,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f, + 0x74,0x28,0x4e,0x2c,0x20,0x48,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x39,0x20,0x3d,0x20,0x28, + 0x28,0x5f,0x34,0x36,0x20,0x2a,0x20,0x5f,0x34,0x36,0x29,0x20,0x2a,0x20,0x28,0x5f, + 0x34,0x30,0x20,0x2d,0x20,0x31,0x2e,0x30,0x29,0x29,0x20,0x2b,0x20,0x31,0x2e,0x30, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x34,0x30, + 0x20,0x2f,0x20,0x28,0x28,0x33,0x2e,0x31,0x34,0x31,0x32,0x38,0x35,0x34,0x31,0x39, + 0x34,0x36,0x34,0x31,0x31,0x31,0x33,0x32,0x38,0x31,0x32,0x35,0x20,0x2a,0x20,0x5f, + 0x35,0x39,0x29,0x20,0x2a,0x20,0x5f,0x35,0x39,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x66, + 0x6c,0x6f,0x61,0x74,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,0x79,0x53,0x63,0x68, + 0x6c,0x69,0x63,0x6b,0x47,0x47,0x58,0x28,0x66,0x6c,0x6f,0x61,0x74,0x20,0x4e,0x64, + 0x6f,0x74,0x56,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x6f,0x75,0x67,0x68, + 0x6e,0x65,0x73,0x73,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x20,0x5f,0x37,0x32,0x20,0x3d,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65,0x73, + 0x73,0x20,0x2b,0x20,0x31,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x5f,0x37,0x38,0x20,0x3d,0x20,0x28,0x5f,0x37,0x32,0x20,0x2a,0x20, + 0x5f,0x37,0x32,0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x32,0x35,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x4e,0x64,0x6f,0x74,0x56,0x20,0x2f, + 0x20,0x28,0x28,0x4e,0x64,0x6f,0x74,0x56,0x20,0x2a,0x20,0x28,0x31,0x2e,0x30,0x20, + 0x2d,0x20,0x5f,0x37,0x38,0x29,0x29,0x20,0x2b,0x20,0x5f,0x37,0x38,0x29,0x3b,0x0a, + 0x7d,0x0a,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72, + 0x79,0x53,0x6d,0x69,0x74,0x68,0x28,0x76,0x65,0x63,0x33,0x20,0x4e,0x2c,0x20,0x76, + 0x65,0x63,0x33,0x20,0x56,0x2c,0x20,0x76,0x65,0x63,0x33,0x20,0x4c,0x2c,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x29,0x0a, + 0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61, + 0x6d,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x4e,0x2c,0x20,0x56, + 0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x72,0x6f,0x75, + 0x67,0x68,0x6e,0x65,0x73,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28, + 0x64,0x6f,0x74,0x28,0x4e,0x2c,0x20,0x4c,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d, + 0x5f,0x33,0x20,0x3d,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x47,0x65,0x6f,0x6d,0x65, + 0x74,0x72,0x79,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x47,0x47,0x58,0x28,0x70,0x61, + 0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x20, + 0x2a,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,0x79,0x53,0x63,0x68,0x6c,0x69,0x63, + 0x6b,0x47,0x47,0x58,0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61, + 0x6d,0x5f,0x31,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61, + 0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f, + 0x31,0x35,0x30,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x72,0x6f,0x75,0x6e,0x64,0x28, + 0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x77,0x20,0x2a,0x20,0x32,0x35,0x35,0x2e,0x30,0x29, + 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x37, + 0x32,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x28,0x5f, + 0x31,0x35,0x30,0x20,0x3e,0x3e,0x20,0x35,0x29,0x20,0x26,0x20,0x37,0x29,0x20,0x2a, + 0x20,0x30,0x2e,0x31,0x34,0x32,0x38,0x35,0x37,0x31,0x34,0x39,0x32,0x34,0x33,0x33, + 0x35,0x34,0x37,0x39,0x37,0x33,0x36,0x33,0x32,0x38,0x31,0x32,0x35,0x2c,0x20,0x30, + 0x2e,0x30,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x37,0x34,0x35,0x30,0x35,0x38, + 0x30,0x35,0x39,0x36,0x39,0x32,0x33,0x38,0x32,0x38,0x31,0x32,0x35,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x37,0x38,0x20,0x3d, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x28,0x5f,0x31,0x35,0x30,0x20,0x3e,0x3e,0x20, + 0x33,0x29,0x20,0x26,0x20,0x33,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33,0x33,0x33,0x33, + 0x33,0x33,0x33,0x34,0x33,0x32,0x36,0x37,0x34,0x34,0x30,0x37,0x39,0x35,0x38,0x39, + 0x38,0x34,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20, + 0x6c,0x69,0x67,0x68,0x74,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79, + 0x7a,0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39, + 0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x38,0x37,0x20,0x3d,0x20, + 0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x66,0x6e,0x6f,0x72,0x6d,0x61, + 0x6c,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33, + 0x20,0x5f,0x31,0x39,0x36,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a, + 0x65,0x28,0x63,0x61,0x6d,0x20,0x2d,0x20,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x30,0x35,0x20, + 0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,0x30,0x30, + 0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x31,0x30,0x20,0x3d,0x20,0x6e, + 0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x31,0x39,0x36,0x20,0x2b,0x20, + 0x5f,0x32,0x30,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74, + 0x28,0x5f,0x32,0x31,0x30,0x2c,0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,0x20,0x30,0x2e, + 0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72, + 0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x76,0x65,0x63,0x33,0x28, + 0x30,0x2e,0x30,0x33,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x31,0x30,0x35,0x39,0x33, + 0x30,0x33,0x32,0x38,0x33,0x36,0x39,0x31,0x34,0x30,0x36,0x32,0x35,0x29,0x2c,0x20, + 0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28, + 0x5f,0x31,0x37,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33, + 0x20,0x5f,0x32,0x32,0x37,0x20,0x3d,0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53, + 0x63,0x68,0x6c,0x69,0x63,0x6b,0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61, + 0x72,0x61,0x6d,0x5f,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33, + 0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f, + 0x33,0x20,0x3d,0x20,0x5f,0x32,0x31,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x20,0x3d,0x20,0x5f,0x31, + 0x37,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72, + 0x61,0x6d,0x5f,0x35,0x20,0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x36,0x20,0x3d,0x20, + 0x5f,0x31,0x39,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70, + 0x61,0x72,0x61,0x6d,0x5f,0x37,0x20,0x3d,0x20,0x5f,0x32,0x30,0x35,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x38, + 0x20,0x3d,0x20,0x5f,0x31,0x37,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x5f,0x32,0x36,0x32,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f, + 0x74,0x28,0x5f,0x31,0x38,0x37,0x2c,0x20,0x5f,0x32,0x30,0x35,0x29,0x2c,0x20,0x30, + 0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32, + 0x39,0x34,0x20,0x3d,0x20,0x6c,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x39,0x35,0x20,0x3d,0x20,0x5f,0x32,0x39,0x34, + 0x20,0x2b,0x20,0x28,0x28,0x28,0x28,0x28,0x28,0x76,0x65,0x63,0x33,0x28,0x31,0x2e, + 0x30,0x29,0x20,0x2d,0x20,0x5f,0x32,0x32,0x37,0x29,0x20,0x2a,0x20,0x28,0x31,0x2e, + 0x30,0x20,0x2d,0x20,0x5f,0x31,0x37,0x38,0x29,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,0x30, + 0x2e,0x33,0x31,0x38,0x33,0x34,0x31,0x30,0x31,0x36,0x37,0x36,0x39,0x34,0x30,0x39, + 0x31,0x37,0x39,0x36,0x38,0x37,0x35,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x5f,0x32, + 0x32,0x37,0x20,0x2a,0x20,0x28,0x44,0x69,0x73,0x74,0x72,0x69,0x62,0x75,0x74,0x69, + 0x6f,0x6e,0x47,0x47,0x58,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20,0x70, + 0x61,0x72,0x61,0x6d,0x5f,0x33,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x29, + 0x20,0x2a,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,0x79,0x53,0x6d,0x69,0x74,0x68, + 0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x35,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f, + 0x36,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x37,0x2c,0x20,0x70,0x61,0x72,0x61, + 0x6d,0x5f,0x38,0x29,0x29,0x29,0x20,0x2f,0x20,0x76,0x65,0x63,0x33,0x28,0x28,0x28, + 0x34,0x2e,0x30,0x20,0x2a,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31, + 0x38,0x37,0x2c,0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x29, + 0x20,0x2a,0x20,0x5f,0x32,0x36,0x32,0x29,0x20,0x2b,0x20,0x39,0x2e,0x39,0x39,0x39, + 0x39,0x39,0x39,0x37,0x34,0x37,0x33,0x37,0x38,0x37,0x35,0x31,0x36,0x33,0x35,0x35, + 0x35,0x31,0x34,0x35,0x32,0x36,0x33,0x36,0x37,0x31,0x38,0x38,0x65,0x2d,0x30,0x35, + 0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x6c,0x69,0x67,0x68,0x74,0x20,0x3d,0x20,0x5f,0x32,0x39,0x35,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20, + 0x76,0x65,0x63,0x34,0x28,0x5f,0x32,0x39,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b, + 0x0a,0x7d,0x0a,0x0a,0x00, ]; /* #version 300 es - uniform vec4 vs_params[4]; + uniform vec4 vs_params[5]; layout(location = 2) in vec4 inst; layout(location = 0) in vec4 position; out vec4 fnormal; @@ -146,6 +385,7 @@ fs_trixel_source_glsl430 := u8.[ out vec4 color; layout(location = 3) in vec4 inst_col; out vec4 pos; + out vec3 cam; void main() { @@ -153,13 +393,14 @@ fs_trixel_source_glsl430 := u8.[ fnormal = normal; color = inst_col; pos = gl_Position; + cam = vs_params[4].xyz; } */ vs_trixel_source_glsl300es := u8.[ 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, - 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29, 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x3b,0x0a,0x6c, 0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d, @@ -172,33 +413,108 @@ vs_trixel_source_glsl300es := u8.[ 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33, 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63, 0x6f,0x6c,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73, - 0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b, - 0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, - 0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, - 0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, - 0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d, - 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20, - 0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e, - 0x78,0x79,0x7a,0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x2e,0x78,0x79,0x7a,0x2c,0x20, - 0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61, - 0x6c,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20, - 0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c, - 0x3b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50, - 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, + 0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x63,0x61,0x6d,0x3b,0x0a, + 0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d, + 0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d, + 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20, + 0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79, + 0x7a,0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e, + 0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20, + 0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f, + 0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73, + 0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x61,0x6d,0x20,0x3d, + 0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79, + 0x7a,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, ]; /* #version 300 es precision mediump float; precision highp int; + struct trixel_world_config + { + highp vec3 skyBase; + highp vec3 skyTop; + highp vec3 sunDisk; + highp vec3 horizonHalo; + highp vec3 sunHalo; + highp vec3 sunLightColor; + highp vec3 sunPosition; + highp float sunIntensity; + int hasClouds; + int hasPlane; + highp float planeHeight; + int planeType; + highp float time; + }; + + uniform trixel_world_config _200; + in highp vec4 color; - in highp vec4 pos; in highp vec4 fnormal; + in highp vec3 cam; + in highp vec4 pos; layout(location = 0) out highp vec4 frag_color; + highp vec3 fresnelSchlick(highp float cosTheta, highp vec3 F0) + { + return F0 + ((vec3(1.0) - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0)); + } + + highp float DistributionGGX(highp vec3 N, highp vec3 H, highp float roughness) + { + highp float _36 = roughness * roughness; + highp float _40 = _36 * _36; + highp float _46 = max(dot(N, H), 0.0); + highp float _59 = ((_46 * _46) * (_40 - 1.0)) + 1.0; + return _40 / ((3.141285419464111328125 * _59) * _59); + } + + highp float GeometrySchlickGGX(highp float NdotV, highp float roughness) + { + highp float _72 = roughness + 1.0; + highp float _78 = (_72 * _72) * 0.125; + return NdotV / ((NdotV * (1.0 - _78)) + _78); + } + + highp float GeometrySmith(highp vec3 N, highp vec3 V, highp vec3 L, highp float roughness) + { + highp float param = max(dot(N, V), 0.0); + highp float param_1 = roughness; + highp float param_2 = max(dot(N, L), 0.0); + highp float param_3 = roughness; + return GeometrySchlickGGX(param_2, param_3) * GeometrySchlickGGX(param, param_1); + } + void main() { - frag_color = vec4(((color.xyz * 0.300000011920928955078125) + ((color.xyz * max(0.0, dot(normalize(vec3(5.0, 5.0, 2.0) - pos.xyz), fnormal.xyz))) * 0.5)) + (((color.xyz * max(0.0, dot(normalize(vec3(-5.0, -2.0, -2.0) - pos.xyz), fnormal.xyz))) * 0.300000011920928955078125) * vec3(1.0, 0.699999988079071044921875, 0.699999988079071044921875)), 1.0); + int _150 = int(round(color.w * 255.0)); + highp float _172 = max(float((_150 >> 5) & 7) * 0.14285714924335479736328125, 0.0500000007450580596923828125); + highp float _178 = float((_150 >> 3) & 3) * 0.3333333432674407958984375; + highp vec3 light = color.xyz * 0.300000011920928955078125; + highp vec3 _187 = normalize(fnormal.xyz); + highp vec3 _196 = normalize(cam - pos.xyz); + highp vec3 _205 = normalize(_200.sunPosition); + highp vec3 _210 = normalize(_196 + _205); + highp float param = max(dot(_210, _196), 0.0); + highp vec3 param_1 = mix(vec3(0.039999999105930328369140625), color.xyz, vec3(_178)); + highp vec3 _227 = fresnelSchlick(param, param_1); + highp vec3 param_2 = _187; + highp vec3 param_3 = _210; + highp float param_4 = _172; + highp vec3 param_5 = _187; + highp vec3 param_6 = _196; + highp vec3 param_7 = _205; + highp float param_8 = _172; + highp float _262 = max(dot(_187, _205), 0.0); + highp vec3 _294 = light; + highp vec3 _295 = _294 + ((((((vec3(1.0) - _227) * (1.0 - _178)) * color.xyz) * vec3(0.3183410167694091796875)) + ((_227 * (DistributionGGX(param_2, param_3, param_4) * GeometrySmith(param_5, param_6, param_7, param_8))) / vec3(((4.0 * max(dot(_187, _196), 0.0)) * _262) + 9.9999997473787516355514526367188e-05))) * _262); + light = _295; + frag_color = vec4(_295, 1.0); } */ @@ -206,38 +522,190 @@ fs_trixel_source_glsl300es := u8.[ 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, - 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x69, - 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, - 0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63, - 0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20, - 0x76,0x65,0x63,0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61, - 0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, - 0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63, - 0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76, - 0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20, - 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65, - 0x63,0x34,0x28,0x28,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a, - 0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39, - 0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x28, - 0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x6d,0x61,0x78, - 0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c, - 0x69,0x7a,0x65,0x28,0x76,0x65,0x63,0x33,0x28,0x35,0x2e,0x30,0x2c,0x20,0x35,0x2e, - 0x30,0x2c,0x20,0x32,0x2e,0x30,0x29,0x20,0x2d,0x20,0x70,0x6f,0x73,0x2e,0x78,0x79, - 0x7a,0x29,0x2c,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29, - 0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x28, - 0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x6d,0x61,0x78,0x28, - 0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69, - 0x7a,0x65,0x28,0x76,0x65,0x63,0x33,0x28,0x2d,0x35,0x2e,0x30,0x2c,0x20,0x2d,0x32, - 0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x20,0x2d,0x20,0x70,0x6f,0x73,0x2e, - 0x78,0x79,0x7a,0x29,0x2c,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79, - 0x7a,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30, - 0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32, - 0x35,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30, - 0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31, - 0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39, - 0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39, - 0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d, - 0x0a,0x0a,0x00, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x73, + 0x74,0x72,0x75,0x63,0x74,0x20,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f,0x77,0x6f,0x72, + 0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x42,0x61, + 0x73,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65, + 0x63,0x33,0x20,0x73,0x6b,0x79,0x54,0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68, + 0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x44,0x69,0x73, + 0x6b,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63, + 0x33,0x20,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75, + 0x6e,0x48,0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70, + 0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76, + 0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x20,0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64,0x73, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x68,0x61,0x73,0x50,0x6c,0x61, + 0x6e,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x48,0x65,0x69,0x67,0x68,0x74,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x54,0x79, + 0x70,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x20,0x74,0x69,0x6d,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f,0x77,0x6f,0x72, + 0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x20,0x5f,0x32,0x30,0x30,0x3b,0x0a, + 0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76, + 0x65,0x63,0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x63,0x61,0x6d,0x3b,0x0a, + 0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f, + 0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69, + 0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68, + 0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x3b,0x0a,0x0a,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x66, + 0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x28,0x68,0x69, + 0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x63,0x6f,0x73,0x54,0x68,0x65, + 0x74,0x61,0x2c,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x46, + 0x30,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20, + 0x46,0x30,0x20,0x2b,0x20,0x28,0x28,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x29, + 0x20,0x2d,0x20,0x46,0x30,0x29,0x20,0x2a,0x20,0x70,0x6f,0x77,0x28,0x63,0x6c,0x61, + 0x6d,0x70,0x28,0x31,0x2e,0x30,0x20,0x2d,0x20,0x63,0x6f,0x73,0x54,0x68,0x65,0x74, + 0x61,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x2c,0x20,0x35,0x2e, + 0x30,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x20,0x44,0x69,0x73,0x74,0x72,0x69,0x62,0x75,0x74,0x69,0x6f,0x6e, + 0x47,0x47,0x58,0x28,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x4e, + 0x2c,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x48,0x2c,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x6f,0x75,0x67, + 0x68,0x6e,0x65,0x73,0x73,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67, + 0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x36,0x20,0x3d,0x20,0x72, + 0x6f,0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x20,0x2a,0x20,0x72,0x6f,0x75,0x67,0x68, + 0x6e,0x65,0x73,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x30,0x20,0x3d,0x20,0x5f,0x33,0x36,0x20, + 0x2a,0x20,0x5f,0x33,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x36,0x20,0x3d,0x20,0x6d,0x61,0x78, + 0x28,0x64,0x6f,0x74,0x28,0x4e,0x2c,0x20,0x48,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x20,0x5f,0x35,0x39,0x20,0x3d,0x20,0x28,0x28,0x5f,0x34,0x36,0x20,0x2a,0x20, + 0x5f,0x34,0x36,0x29,0x20,0x2a,0x20,0x28,0x5f,0x34,0x30,0x20,0x2d,0x20,0x31,0x2e, + 0x30,0x29,0x29,0x20,0x2b,0x20,0x31,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72, + 0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x34,0x30,0x20,0x2f,0x20,0x28,0x28,0x33,0x2e, + 0x31,0x34,0x31,0x32,0x38,0x35,0x34,0x31,0x39,0x34,0x36,0x34,0x31,0x31,0x31,0x33, + 0x32,0x38,0x31,0x32,0x35,0x20,0x2a,0x20,0x5f,0x35,0x39,0x29,0x20,0x2a,0x20,0x5f, + 0x35,0x39,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,0x79,0x53,0x63,0x68,0x6c, + 0x69,0x63,0x6b,0x47,0x47,0x58,0x28,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x4e,0x64,0x6f,0x74,0x56,0x2c,0x20,0x68,0x69,0x67,0x68,0x70,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x5f,0x37,0x32,0x20,0x3d,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65, + 0x73,0x73,0x20,0x2b,0x20,0x31,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69, + 0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x37,0x38,0x20,0x3d,0x20, + 0x28,0x5f,0x37,0x32,0x20,0x2a,0x20,0x5f,0x37,0x32,0x29,0x20,0x2a,0x20,0x30,0x2e, + 0x31,0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20, + 0x4e,0x64,0x6f,0x74,0x56,0x20,0x2f,0x20,0x28,0x28,0x4e,0x64,0x6f,0x74,0x56,0x20, + 0x2a,0x20,0x28,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x37,0x38,0x29,0x29,0x20,0x2b, + 0x20,0x5f,0x37,0x38,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x68,0x69,0x67,0x68,0x70,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,0x79,0x53,0x6d, + 0x69,0x74,0x68,0x28,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x4e, + 0x2c,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x56,0x2c,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x4c,0x2c,0x20,0x68,0x69, + 0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e, + 0x65,0x73,0x73,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x6d, + 0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x4e,0x2c,0x20,0x56,0x29,0x2c,0x20,0x30,0x2e, + 0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x72,0x6f, + 0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67, + 0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32, + 0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x4e,0x2c,0x20,0x4c,0x29, + 0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20, + 0x3d,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,0x79, + 0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x47,0x47,0x58,0x28,0x70,0x61,0x72,0x61,0x6d, + 0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x20,0x2a,0x20,0x47, + 0x65,0x6f,0x6d,0x65,0x74,0x72,0x79,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x47,0x47, + 0x58,0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31, + 0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28, + 0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x31,0x35,0x30, + 0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x72,0x6f,0x75,0x6e,0x64,0x28,0x63,0x6f,0x6c, + 0x6f,0x72,0x2e,0x77,0x20,0x2a,0x20,0x32,0x35,0x35,0x2e,0x30,0x29,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20, + 0x5f,0x31,0x37,0x32,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x66,0x6c,0x6f,0x61,0x74, + 0x28,0x28,0x5f,0x31,0x35,0x30,0x20,0x3e,0x3e,0x20,0x35,0x29,0x20,0x26,0x20,0x37, + 0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x34,0x32,0x38,0x35,0x37,0x31,0x34,0x39,0x32, + 0x34,0x33,0x33,0x35,0x34,0x37,0x39,0x37,0x33,0x36,0x33,0x32,0x38,0x31,0x32,0x35, + 0x2c,0x20,0x30,0x2e,0x30,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x37,0x34,0x35, + 0x30,0x35,0x38,0x30,0x35,0x39,0x36,0x39,0x32,0x33,0x38,0x32,0x38,0x31,0x32,0x35, + 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x5f,0x31,0x37,0x38,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28, + 0x28,0x5f,0x31,0x35,0x30,0x20,0x3e,0x3e,0x20,0x33,0x29,0x20,0x26,0x20,0x33,0x29, + 0x20,0x2a,0x20,0x30,0x2e,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x34,0x33,0x32,0x36, + 0x37,0x34,0x34,0x30,0x37,0x39,0x35,0x38,0x39,0x38,0x34,0x33,0x37,0x35,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x6c, + 0x69,0x67,0x68,0x74,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a, + 0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32, + 0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31, + 0x38,0x37,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x66, + 0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x39,0x36, + 0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x61,0x6d, + 0x20,0x2d,0x20,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x30,0x35, + 0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,0x30, + 0x30,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f, + 0x32,0x31,0x30,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28, + 0x5f,0x31,0x39,0x36,0x20,0x2b,0x20,0x5f,0x32,0x30,0x35,0x29,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61, + 0x72,0x61,0x6d,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x32, + 0x31,0x30,0x2c,0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20, + 0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x76,0x65, + 0x63,0x33,0x28,0x30,0x2e,0x30,0x33,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x31,0x30, + 0x35,0x39,0x33,0x30,0x33,0x32,0x38,0x33,0x36,0x39,0x31,0x34,0x30,0x36,0x32,0x35, + 0x29,0x2c,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65, + 0x63,0x33,0x28,0x5f,0x31,0x37,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68, + 0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x32,0x37,0x20,0x3d, + 0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x28, + 0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20, + 0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70, + 0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x5f,0x32,0x31,0x30,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70, + 0x61,0x72,0x61,0x6d,0x5f,0x34,0x20,0x3d,0x20,0x5f,0x31,0x37,0x32,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61, + 0x72,0x61,0x6d,0x5f,0x35,0x20,0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72, + 0x61,0x6d,0x5f,0x36,0x20,0x3d,0x20,0x5f,0x31,0x39,0x36,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61, + 0x6d,0x5f,0x37,0x20,0x3d,0x20,0x5f,0x32,0x30,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61, + 0x6d,0x5f,0x38,0x20,0x3d,0x20,0x5f,0x31,0x37,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x36,0x32, + 0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x38,0x37,0x2c, + 0x20,0x5f,0x32,0x30,0x35,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x39, + 0x34,0x20,0x3d,0x20,0x6c,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68, + 0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x39,0x35,0x20,0x3d, + 0x20,0x5f,0x32,0x39,0x34,0x20,0x2b,0x20,0x28,0x28,0x28,0x28,0x28,0x28,0x76,0x65, + 0x63,0x33,0x28,0x31,0x2e,0x30,0x29,0x20,0x2d,0x20,0x5f,0x32,0x32,0x37,0x29,0x20, + 0x2a,0x20,0x28,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x31,0x37,0x38,0x29,0x29,0x20, + 0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x76, + 0x65,0x63,0x33,0x28,0x30,0x2e,0x33,0x31,0x38,0x33,0x34,0x31,0x30,0x31,0x36,0x37, + 0x36,0x39,0x34,0x30,0x39,0x31,0x37,0x39,0x36,0x38,0x37,0x35,0x29,0x29,0x20,0x2b, + 0x20,0x28,0x28,0x5f,0x32,0x32,0x37,0x20,0x2a,0x20,0x28,0x44,0x69,0x73,0x74,0x72, + 0x69,0x62,0x75,0x74,0x69,0x6f,0x6e,0x47,0x47,0x58,0x28,0x70,0x61,0x72,0x61,0x6d, + 0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x2c,0x20,0x70,0x61,0x72, + 0x61,0x6d,0x5f,0x34,0x29,0x20,0x2a,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,0x79, + 0x53,0x6d,0x69,0x74,0x68,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x35,0x2c,0x20,0x70, + 0x61,0x72,0x61,0x6d,0x5f,0x36,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x37,0x2c, + 0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x38,0x29,0x29,0x29,0x20,0x2f,0x20,0x76,0x65, + 0x63,0x33,0x28,0x28,0x28,0x34,0x2e,0x30,0x20,0x2a,0x20,0x6d,0x61,0x78,0x28,0x64, + 0x6f,0x74,0x28,0x5f,0x31,0x38,0x37,0x2c,0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,0x20, + 0x30,0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x32,0x29,0x20,0x2b,0x20, + 0x39,0x2e,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x34,0x37,0x33,0x37,0x38,0x37,0x35, + 0x31,0x36,0x33,0x35,0x35,0x35,0x31,0x34,0x35,0x32,0x36,0x33,0x36,0x37,0x31,0x38, + 0x38,0x65,0x2d,0x30,0x35,0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x32,0x29, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x6c,0x69,0x67,0x68,0x74,0x20,0x3d,0x20,0x5f,0x32, + 0x39,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c, + 0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x32,0x39,0x35,0x2c,0x20, + 0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, ]; /* #include @@ -248,6 +716,7 @@ fs_trixel_source_glsl300es := u8.[ struct vs_params { float4x4 mvp; + float3 camera; }; struct main0_out @@ -255,6 +724,7 @@ fs_trixel_source_glsl300es := u8.[ float4 color [[user(locn0)]]; float4 fnormal [[user(locn1)]]; float4 pos [[user(locn2)]]; + float3 cam [[user(locn3)]]; float4 gl_Position [[position]]; }; @@ -273,6 +743,7 @@ fs_trixel_source_glsl300es := u8.[ out.fnormal = in.normal; out.color = in.inst_col; out.pos = out.gl_Position; + out.cam = _26.camera; return out; } @@ -284,54 +755,78 @@ vs_trixel_source_metal_macos := u8.[ 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76, 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, - 0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x7d,0x3b,0x0a, - 0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75, - 0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63, - 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, - 0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34, - 0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28, - 0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c, - 0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28, - 0x6c,0x6f,0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c, - 0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, - 0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d, - 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, - 0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20, - 0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69, - 0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, - 0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x61, - 0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20, - 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x20,0x5b, - 0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b, - 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74, - 0x5f,0x63,0x6f,0x6c,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65, - 0x28,0x33,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65, - 0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e, - 0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b, - 0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73, - 0x74,0x61,0x6e,0x74,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20, - 0x5f,0x32,0x36,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d, - 0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f, - 0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20, - 0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, - 0x20,0x3d,0x20,0x5f,0x32,0x36,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x66,0x6c,0x6f, - 0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e, - 0x78,0x79,0x7a,0x20,0x2b,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x2e,0x78,0x79, - 0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74, - 0x2e,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x6e,0x6f, - 0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f, - 0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f, - 0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x70,0x6f,0x73,0x20,0x3d, - 0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, - 0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74, - 0x3b,0x0a,0x7d,0x0a,0x0a,0x00, + 0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x63,0x61,0x6d,0x65,0x72,0x61,0x3b,0x0a, + 0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30, + 0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c, + 0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73, + 0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73, + 0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x63,0x61,0x6d,0x20,0x5b,0x5b,0x75,0x73, + 0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x33,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d, + 0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69, + 0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74, + 0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20, + 0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73, + 0x74,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x32,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69, + 0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62, + 0x75,0x74,0x65,0x28,0x33,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65, + 0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e, + 0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63, + 0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x26,0x20,0x5f,0x32,0x36,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28, + 0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x32,0x36,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69, + 0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74, + 0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x6f,0x75,0x74,0x2e,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x69,0x6e, + 0x2e,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74, + 0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74, + 0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x70,0x6f, + 0x73,0x20,0x3d,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x61,0x6d, + 0x20,0x3d,0x20,0x5f,0x32,0x36,0x2e,0x63,0x61,0x6d,0x65,0x72,0x61,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d, + 0x0a,0x0a,0x00, ]; /* + #pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; + struct trixel_world_config + { + float3 skyBase; + float3 skyTop; + float3 sunDisk; + float3 horizonHalo; + float3 sunHalo; + float3 sunLightColor; + packed_float3 sunPosition; + float sunIntensity; + int hasClouds; + int hasPlane; + float planeHeight; + int planeType; + float time; + }; + struct main0_out { float4 frag_color [[color(0)]]; @@ -342,65 +837,288 @@ vs_trixel_source_metal_macos := u8.[ float4 color [[user(locn0)]]; float4 fnormal [[user(locn1)]]; float4 pos [[user(locn2)]]; + float3 cam [[user(locn3)]]; }; - fragment main0_out main0(main0_in in [[stage_in]]) + static inline __attribute__((always_inline)) + float3 fresnelSchlick(thread const float& cosTheta, thread const float3& F0) + { + return F0 + ((float3(1.0) - F0) * powr(fast::clamp(1.0 - cosTheta, 0.0, 1.0), 5.0)); + } + + static inline __attribute__((always_inline)) + float DistributionGGX(thread const float3& N, thread const float3& H, thread const float& roughness) + { + float _36 = roughness * roughness; + float _40 = _36 * _36; + float _46 = fast::max(dot(N, H), 0.0); + float _59 = ((_46 * _46) * (_40 - 1.0)) + 1.0; + return _40 / ((3.141285419464111328125 * _59) * _59); + } + + static inline __attribute__((always_inline)) + float GeometrySchlickGGX(thread const float& NdotV, thread const float& roughness) + { + float _72 = roughness + 1.0; + float _78 = (_72 * _72) * 0.125; + return NdotV / ((NdotV * (1.0 - _78)) + _78); + } + + static inline __attribute__((always_inline)) + float GeometrySmith(thread const float3& N, thread const float3& V, thread const float3& L, thread const float& roughness) + { + float param = fast::max(dot(N, V), 0.0); + float param_1 = roughness; + float param_2 = fast::max(dot(N, L), 0.0); + float param_3 = roughness; + return GeometrySchlickGGX(param_2, param_3) * GeometrySchlickGGX(param, param_1); + } + + fragment main0_out main0(main0_in in [[stage_in]], constant trixel_world_config& _200 [[buffer(0)]]) { main0_out out = {}; - out.frag_color = float4(((in.color.xyz * 0.300000011920928955078125) + ((in.color.xyz * fast::max(0.0, dot(fast::normalize(float3(5.0, 5.0, 2.0) - in.pos.xyz), in.fnormal.xyz))) * 0.5)) + (((in.color.xyz * fast::max(0.0, dot(fast::normalize(float3(-5.0, -2.0, -2.0) - in.pos.xyz), in.fnormal.xyz))) * 0.300000011920928955078125) * float3(1.0, 0.699999988079071044921875, 0.699999988079071044921875)), 1.0); + int _150 = int(round(in.color.w * 255.0)); + float _172 = fast::max(float((_150 >> 5) & 7) * 0.14285714924335479736328125, 0.0500000007450580596923828125); + float _178 = float((_150 >> 3) & 3) * 0.3333333432674407958984375; + float3 light = in.color.xyz * 0.300000011920928955078125; + float3 _187 = fast::normalize(in.fnormal.xyz); + float3 _196 = fast::normalize(in.cam - in.pos.xyz); + float3 _205 = fast::normalize(float3(_200.sunPosition)); + float3 _210 = fast::normalize(_196 + _205); + float param = fast::max(dot(_210, _196), 0.0); + float3 param_1 = mix(float3(0.039999999105930328369140625), in.color.xyz, float3(_178)); + float3 _227 = fresnelSchlick(param, param_1); + float3 param_2 = _187; + float3 param_3 = _210; + float param_4 = _172; + float3 param_5 = _187; + float3 param_6 = _196; + float3 param_7 = _205; + float param_8 = _172; + float _262 = fast::max(dot(_187, _205), 0.0); + float3 _294 = light; + float3 _295 = _294 + ((((((float3(1.0) - _227) * (1.0 - _178)) * in.color.xyz) * float3(0.3183410167694091796875)) + ((_227 * (DistributionGGX(param_2, param_3, param_4) * GeometrySmith(param_5, param_6, param_7, param_8))) / float3(((4.0 * fast::max(dot(_187, _196), 0.0)) * _262) + 9.9999997473787516355514526367188e-05))) * _262); + light = _295; + out.frag_color = float4(_295, 1.0); return out; } */ fs_trixel_source_metal_macos := u8.[ - 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, - 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, - 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, - 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, - 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d, - 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, - 0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, - 0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d, - 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, - 0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20, - 0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63, - 0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74, - 0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72, - 0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, - 0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72, - 0x28,0x6c,0x6f,0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66, - 0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75, - 0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e, - 0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d, - 0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75, - 0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20, - 0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d, - 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x28,0x69,0x6e,0x2e,0x63,0x6f,0x6c, - 0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30, - 0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38, - 0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x28,0x28,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f, - 0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61, - 0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x66,0x61,0x73,0x74,0x3a, - 0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x66,0x6c,0x6f,0x61,0x74, - 0x33,0x28,0x35,0x2e,0x30,0x2c,0x20,0x35,0x2e,0x30,0x2c,0x20,0x32,0x2e,0x30,0x29, - 0x20,0x2d,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x2c,0x20, - 0x69,0x6e,0x2e,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29,0x29, - 0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x28,0x69, - 0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x66,0x61, - 0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74, - 0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65, - 0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x2d,0x35,0x2e,0x30,0x2c,0x20,0x2d,0x32, - 0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x20,0x2d,0x20,0x69,0x6e,0x2e,0x70, - 0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x2c,0x20,0x69,0x6e,0x2e,0x66,0x6e,0x6f,0x72, - 0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33, + 0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x63,0x6c,0x61,0x6e,0x67,0x20,0x64,0x69, + 0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x20,0x69,0x67,0x6e,0x6f,0x72,0x65,0x64, + 0x20,0x22,0x2d,0x57,0x6d,0x69,0x73,0x73,0x69,0x6e,0x67,0x2d,0x70,0x72,0x6f,0x74, + 0x6f,0x74,0x79,0x70,0x65,0x73,0x22,0x0a,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64, + 0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,0x73,0x74,0x64,0x6c,0x69,0x62,0x3e, + 0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f, + 0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,0x75,0x73,0x69,0x6e,0x67,0x20,0x6e, + 0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a, + 0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f,0x77, + 0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x6b,0x79,0x42,0x61,0x73,0x65, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x6b,0x79, + 0x54,0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20, + 0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x33,0x20,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x75,0x6e,0x48, + 0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20, + 0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x70,0x61,0x63,0x6b,0x65,0x64,0x5f,0x66,0x6c,0x6f,0x61,0x74,0x33, + 0x20,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e, + 0x73,0x69,0x74,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x68,0x61, + 0x73,0x43,0x6c,0x6f,0x75,0x64,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74, + 0x20,0x68,0x61,0x73,0x50,0x6c,0x61,0x6e,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x48,0x65,0x69,0x67,0x68,0x74, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x54, + 0x79,0x70,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x74, + 0x69,0x6d,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20, + 0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a, + 0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30, + 0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f, + 0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65, + 0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65, + 0x72,0x28,0x6c,0x6f,0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x63,0x61,0x6d,0x20,0x5b,0x5b,0x75,0x73,0x65, + 0x72,0x28,0x6c,0x6f,0x63,0x6e,0x33,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a, + 0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x5f,0x5f, + 0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x61,0x6c,0x77, + 0x61,0x79,0x73,0x5f,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x29,0x29,0x0a,0x66,0x6c,0x6f, + 0x61,0x74,0x33,0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69, + 0x63,0x6b,0x28,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x26,0x20,0x63,0x6f,0x73,0x54,0x68,0x65,0x74,0x61,0x2c, + 0x20,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x33,0x26,0x20,0x46,0x30,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x46,0x30,0x20,0x2b,0x20,0x28,0x28,0x66,0x6c, + 0x6f,0x61,0x74,0x33,0x28,0x31,0x2e,0x30,0x29,0x20,0x2d,0x20,0x46,0x30,0x29,0x20, + 0x2a,0x20,0x70,0x6f,0x77,0x72,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x63,0x6c,0x61, + 0x6d,0x70,0x28,0x31,0x2e,0x30,0x20,0x2d,0x20,0x63,0x6f,0x73,0x54,0x68,0x65,0x74, + 0x61,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x2c,0x20,0x35,0x2e, + 0x30,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x69, + 0x6e,0x6c,0x69,0x6e,0x65,0x20,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74, + 0x65,0x5f,0x5f,0x28,0x28,0x61,0x6c,0x77,0x61,0x79,0x73,0x5f,0x69,0x6e,0x6c,0x69, + 0x6e,0x65,0x29,0x29,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x20,0x44,0x69,0x73,0x74,0x72, + 0x69,0x62,0x75,0x74,0x69,0x6f,0x6e,0x47,0x47,0x58,0x28,0x74,0x68,0x72,0x65,0x61, + 0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x26,0x20, + 0x4e,0x2c,0x20,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x33,0x26,0x20,0x48,0x2c,0x20,0x74,0x68,0x72,0x65,0x61, + 0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x26,0x20,0x72, + 0x6f,0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x36,0x20,0x3d,0x20,0x72,0x6f,0x75,0x67, + 0x68,0x6e,0x65,0x73,0x73,0x20,0x2a,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65,0x73, + 0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x30, + 0x20,0x3d,0x20,0x5f,0x33,0x36,0x20,0x2a,0x20,0x5f,0x33,0x36,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x36,0x20,0x3d,0x20,0x66,0x61, + 0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x4e,0x2c,0x20,0x48, + 0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x5f,0x35,0x39,0x20,0x3d,0x20,0x28,0x28,0x5f,0x34,0x36,0x20,0x2a, + 0x20,0x5f,0x34,0x36,0x29,0x20,0x2a,0x20,0x28,0x5f,0x34,0x30,0x20,0x2d,0x20,0x31, + 0x2e,0x30,0x29,0x29,0x20,0x2b,0x20,0x31,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x34,0x30,0x20,0x2f,0x20,0x28,0x28,0x33, + 0x2e,0x31,0x34,0x31,0x32,0x38,0x35,0x34,0x31,0x39,0x34,0x36,0x34,0x31,0x31,0x31, + 0x33,0x32,0x38,0x31,0x32,0x35,0x20,0x2a,0x20,0x5f,0x35,0x39,0x29,0x20,0x2a,0x20, + 0x5f,0x35,0x39,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20, + 0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75, + 0x74,0x65,0x5f,0x5f,0x28,0x28,0x61,0x6c,0x77,0x61,0x79,0x73,0x5f,0x69,0x6e,0x6c, + 0x69,0x6e,0x65,0x29,0x29,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x20,0x47,0x65,0x6f,0x6d, + 0x65,0x74,0x72,0x79,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x47,0x47,0x58,0x28,0x74, + 0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x26,0x20,0x4e,0x64,0x6f,0x74,0x56,0x2c,0x20,0x74,0x68,0x72,0x65,0x61,0x64, + 0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x26,0x20,0x72,0x6f, + 0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x20,0x5f,0x37,0x32,0x20,0x3d,0x20,0x72,0x6f,0x75,0x67,0x68, + 0x6e,0x65,0x73,0x73,0x20,0x2b,0x20,0x31,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x37,0x38,0x20,0x3d,0x20,0x28,0x5f,0x37,0x32, + 0x20,0x2a,0x20,0x5f,0x37,0x32,0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x32,0x35,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x4e,0x64,0x6f,0x74, + 0x56,0x20,0x2f,0x20,0x28,0x28,0x4e,0x64,0x6f,0x74,0x56,0x20,0x2a,0x20,0x28,0x31, + 0x2e,0x30,0x20,0x2d,0x20,0x5f,0x37,0x38,0x29,0x29,0x20,0x2b,0x20,0x5f,0x37,0x38, + 0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x69,0x6e,0x6c, + 0x69,0x6e,0x65,0x20,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f, + 0x5f,0x28,0x28,0x61,0x6c,0x77,0x61,0x79,0x73,0x5f,0x69,0x6e,0x6c,0x69,0x6e,0x65, + 0x29,0x29,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72, + 0x79,0x53,0x6d,0x69,0x74,0x68,0x28,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f, + 0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x26,0x20,0x4e,0x2c,0x20,0x74, + 0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x33,0x26,0x20,0x56,0x2c,0x20,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f, + 0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x26,0x20,0x4c,0x2c,0x20,0x74, + 0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x26,0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x29,0x0a,0x7b,0x0a, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x20, + 0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28, + 0x4e,0x2c,0x20,0x56,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d, + 0x20,0x72,0x6f,0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20, + 0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x4e,0x2c, + 0x20,0x4c,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x72, + 0x6f,0x75,0x67,0x68,0x6e,0x65,0x73,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65, + 0x74,0x75,0x72,0x6e,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,0x79,0x53,0x63,0x68, + 0x6c,0x69,0x63,0x6b,0x47,0x47,0x58,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x2c, + 0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x20,0x2a,0x20,0x47,0x65,0x6f,0x6d, + 0x65,0x74,0x72,0x79,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x47,0x47,0x58,0x28,0x70, + 0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x3b,0x0a, + 0x7d,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f, + 0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x74, + 0x72,0x69,0x78,0x65,0x6c,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66, + 0x69,0x67,0x26,0x20,0x5f,0x32,0x30,0x30,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65, + 0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61, + 0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x31,0x35,0x30,0x20,0x3d, + 0x20,0x69,0x6e,0x74,0x28,0x72,0x6f,0x75,0x6e,0x64,0x28,0x69,0x6e,0x2e,0x63,0x6f, + 0x6c,0x6f,0x72,0x2e,0x77,0x20,0x2a,0x20,0x32,0x35,0x35,0x2e,0x30,0x29,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x37,0x32,0x20, + 0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x66,0x6c,0x6f,0x61, + 0x74,0x28,0x28,0x5f,0x31,0x35,0x30,0x20,0x3e,0x3e,0x20,0x35,0x29,0x20,0x26,0x20, + 0x37,0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x34,0x32,0x38,0x35,0x37,0x31,0x34,0x39, + 0x32,0x34,0x33,0x33,0x35,0x34,0x37,0x39,0x37,0x33,0x36,0x33,0x32,0x38,0x31,0x32, + 0x35,0x2c,0x20,0x30,0x2e,0x30,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x37,0x34, + 0x35,0x30,0x35,0x38,0x30,0x35,0x39,0x36,0x39,0x32,0x33,0x38,0x32,0x38,0x31,0x32, + 0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31, + 0x37,0x38,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x28,0x5f,0x31,0x35,0x30, + 0x20,0x3e,0x3e,0x20,0x33,0x29,0x20,0x26,0x20,0x33,0x29,0x20,0x2a,0x20,0x30,0x2e, + 0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x34,0x33,0x32,0x36,0x37,0x34,0x34,0x30,0x37, + 0x39,0x35,0x38,0x39,0x38,0x34,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x33,0x20,0x6c,0x69,0x67,0x68,0x74,0x20,0x3d,0x20,0x69,0x6e, + 0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x33, 0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35, - 0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74, - 0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39, - 0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37, - 0x35,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37, - 0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x2c, - 0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72, - 0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, + 0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x33,0x20,0x5f,0x31,0x38,0x37,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a, + 0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x69,0x6e,0x2e,0x66,0x6e, + 0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x31,0x39,0x36,0x20,0x3d,0x20,0x66,0x61, + 0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x69,0x6e, + 0x2e,0x63,0x61,0x6d,0x20,0x2d,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79, + 0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f, + 0x32,0x30,0x35,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d, + 0x61,0x6c,0x69,0x7a,0x65,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x32,0x30, + 0x30,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x31,0x30, + 0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69, + 0x7a,0x65,0x28,0x5f,0x31,0x39,0x36,0x20,0x2b,0x20,0x5f,0x32,0x30,0x35,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d, + 0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74, + 0x28,0x5f,0x32,0x31,0x30,0x2c,0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,0x20,0x30,0x2e, + 0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70, + 0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x66,0x6c,0x6f, + 0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x33,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x31, + 0x30,0x35,0x39,0x33,0x30,0x33,0x32,0x38,0x33,0x36,0x39,0x31,0x34,0x30,0x36,0x32, + 0x35,0x29,0x2c,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a, + 0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x37,0x38,0x29,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x32,0x37, + 0x20,0x3d,0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63, + 0x6b,0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31, + 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61, + 0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33, + 0x20,0x3d,0x20,0x5f,0x32,0x31,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x20,0x3d,0x20,0x5f,0x31,0x37, + 0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61, + 0x72,0x61,0x6d,0x5f,0x35,0x20,0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x36, + 0x20,0x3d,0x20,0x5f,0x31,0x39,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x37,0x20,0x3d,0x20,0x5f,0x32, + 0x30,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61, + 0x72,0x61,0x6d,0x5f,0x38,0x20,0x3d,0x20,0x5f,0x31,0x37,0x32,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x36,0x32,0x20,0x3d,0x20,0x66, + 0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x38, + 0x37,0x2c,0x20,0x5f,0x32,0x30,0x35,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x39,0x34,0x20, + 0x3d,0x20,0x6c,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x33,0x20,0x5f,0x32,0x39,0x35,0x20,0x3d,0x20,0x5f,0x32,0x39,0x34,0x20, + 0x2b,0x20,0x28,0x28,0x28,0x28,0x28,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x31, + 0x2e,0x30,0x29,0x20,0x2d,0x20,0x5f,0x32,0x32,0x37,0x29,0x20,0x2a,0x20,0x28,0x31, + 0x2e,0x30,0x20,0x2d,0x20,0x5f,0x31,0x37,0x38,0x29,0x29,0x20,0x2a,0x20,0x69,0x6e, + 0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x33,0x31,0x38,0x33,0x34,0x31,0x30,0x31,0x36, + 0x37,0x36,0x39,0x34,0x30,0x39,0x31,0x37,0x39,0x36,0x38,0x37,0x35,0x29,0x29,0x20, + 0x2b,0x20,0x28,0x28,0x5f,0x32,0x32,0x37,0x20,0x2a,0x20,0x28,0x44,0x69,0x73,0x74, + 0x72,0x69,0x62,0x75,0x74,0x69,0x6f,0x6e,0x47,0x47,0x58,0x28,0x70,0x61,0x72,0x61, + 0x6d,0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x2c,0x20,0x70,0x61, + 0x72,0x61,0x6d,0x5f,0x34,0x29,0x20,0x2a,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72, + 0x79,0x53,0x6d,0x69,0x74,0x68,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x35,0x2c,0x20, + 0x70,0x61,0x72,0x61,0x6d,0x5f,0x36,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x37, + 0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x38,0x29,0x29,0x29,0x20,0x2f,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x33,0x28,0x28,0x28,0x34,0x2e,0x30,0x20,0x2a,0x20,0x66,0x61, + 0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x38,0x37, + 0x2c,0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x29,0x20,0x2a, + 0x20,0x5f,0x32,0x36,0x32,0x29,0x20,0x2b,0x20,0x39,0x2e,0x39,0x39,0x39,0x39,0x39, + 0x39,0x37,0x34,0x37,0x33,0x37,0x38,0x37,0x35,0x31,0x36,0x33,0x35,0x35,0x35,0x31, + 0x34,0x35,0x32,0x36,0x33,0x36,0x37,0x31,0x38,0x38,0x65,0x2d,0x30,0x35,0x29,0x29, + 0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6c, + 0x69,0x67,0x68,0x74,0x20,0x3d,0x20,0x5f,0x32,0x39,0x35,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20, + 0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x5f,0x32,0x39,0x35,0x2c,0x20,0x31, + 0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20, + 0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, ]; trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc { desc: sg_shader_desc; @@ -421,10 +1139,52 @@ trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc { desc.attrs[3].glsl_name = "inst_col"; desc.uniform_blocks[0].stage = .VERTEX; desc.uniform_blocks[0].layout = .STD140; - desc.uniform_blocks[0].size = 64; + desc.uniform_blocks[0].size = 80; desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4; - desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4; + desc.uniform_blocks[0].glsl_uniforms[0].array_count = 5; desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "vs_params"; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 144; + desc.uniform_blocks[1].glsl_uniforms[0].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_200.skyBase"; + desc.uniform_blocks[1].glsl_uniforms[1].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_200.skyTop"; + desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_200.sunDisk"; + desc.uniform_blocks[1].glsl_uniforms[3].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[3].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_200.horizonHalo"; + desc.uniform_blocks[1].glsl_uniforms[4].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[4].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[4].glsl_name = "_200.sunHalo"; + desc.uniform_blocks[1].glsl_uniforms[5].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[5].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[5].glsl_name = "_200.sunLightColor"; + desc.uniform_blocks[1].glsl_uniforms[6].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[6].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[6].glsl_name = "_200.sunPosition"; + desc.uniform_blocks[1].glsl_uniforms[7].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[7].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[7].glsl_name = "_200.sunIntensity"; + desc.uniform_blocks[1].glsl_uniforms[8].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[8].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[8].glsl_name = "_200.hasClouds"; + desc.uniform_blocks[1].glsl_uniforms[9].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[9].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[9].glsl_name = "_200.hasPlane"; + desc.uniform_blocks[1].glsl_uniforms[10].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[10].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[10].glsl_name = "_200.planeHeight"; + desc.uniform_blocks[1].glsl_uniforms[11].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[11].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[11].glsl_name = "_200.planeType"; + desc.uniform_blocks[1].glsl_uniforms[12].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[12].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[12].glsl_name = "_200.time"; case .GLES3; desc.vertex_func.source = xx *vs_trixel_source_glsl300es; desc.vertex_func.entry = "main"; @@ -440,10 +1200,52 @@ trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc { desc.attrs[3].glsl_name = "inst_col"; desc.uniform_blocks[0].stage = .VERTEX; desc.uniform_blocks[0].layout = .STD140; - desc.uniform_blocks[0].size = 64; + desc.uniform_blocks[0].size = 80; desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4; - desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4; + desc.uniform_blocks[0].glsl_uniforms[0].array_count = 5; desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "vs_params"; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 144; + desc.uniform_blocks[1].glsl_uniforms[0].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_200.skyBase"; + desc.uniform_blocks[1].glsl_uniforms[1].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_200.skyTop"; + desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_200.sunDisk"; + desc.uniform_blocks[1].glsl_uniforms[3].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[3].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_200.horizonHalo"; + desc.uniform_blocks[1].glsl_uniforms[4].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[4].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[4].glsl_name = "_200.sunHalo"; + desc.uniform_blocks[1].glsl_uniforms[5].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[5].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[5].glsl_name = "_200.sunLightColor"; + desc.uniform_blocks[1].glsl_uniforms[6].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[6].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[6].glsl_name = "_200.sunPosition"; + desc.uniform_blocks[1].glsl_uniforms[7].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[7].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[7].glsl_name = "_200.sunIntensity"; + desc.uniform_blocks[1].glsl_uniforms[8].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[8].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[8].glsl_name = "_200.hasClouds"; + desc.uniform_blocks[1].glsl_uniforms[9].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[9].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[9].glsl_name = "_200.hasPlane"; + desc.uniform_blocks[1].glsl_uniforms[10].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[10].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[10].glsl_name = "_200.planeHeight"; + desc.uniform_blocks[1].glsl_uniforms[11].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[11].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[11].glsl_name = "_200.planeType"; + desc.uniform_blocks[1].glsl_uniforms[12].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[12].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[12].glsl_name = "_200.time"; case .METAL_MACOS; desc.vertex_func.source = xx *vs_trixel_source_metal_macos; desc.vertex_func.entry = "main0"; @@ -455,8 +1257,12 @@ trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc { desc.attrs[3].base_type = .FLOAT; desc.uniform_blocks[0].stage = .VERTEX; desc.uniform_blocks[0].layout = .STD140; - desc.uniform_blocks[0].size = 64; + desc.uniform_blocks[0].size = 80; desc.uniform_blocks[0].msl_buffer_n = 0; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 144; + desc.uniform_blocks[1].msl_buffer_n = 0; } return desc; } diff --git a/src/shaders/shader_trixel.glsl b/src/shaders/shader_trixel.glsl index dc6a405..1ca85b7 100644 --- a/src/shaders/shader_trixel.glsl +++ b/src/shaders/shader_trixel.glsl @@ -7,12 +7,13 @@ in vec4 inst_col; layout(binding=0) uniform vs_params { mat4 mvp; + vec3 camera; }; - out vec4 color; out vec4 fnormal; out vec4 pos; +out vec3 cam; void main() { vec3 instancepos = inst.xyz; @@ -20,30 +21,107 @@ void main() { fnormal = normal; color = inst_col; pos = gl_Position; + cam = camera; } @end @fs fs_trixel + +layout(binding=1) uniform trixel_world_config { + vec3 skyBase; + vec3 skyTop; + vec3 sunDisk; + vec3 horizonHalo; + vec3 sunHalo; + vec3 sunLightColor; + vec3 sunPosition; + float sunIntensity; + + int hasClouds; + + int hasPlane; + float planeHeight; + int planeType; + + float time; +}; + in vec4 color; in vec4 fnormal; in vec4 pos; +in vec3 cam; out vec4 frag_color; +const float PI = 3.1412854; + + +float DistributionGGX(vec3 N, vec3 H, float roughness) { + float a = roughness*roughness; + float a2 = a*a; + float NdotH = max(dot(N, H), 0.0); + float NdotH2 = NdotH*NdotH; + float num = a2; + float denom = (NdotH2 * (a2 - 1.0) + 1.0); + denom = PI * denom * denom; + return num / denom; +} + +float GeometrySchlickGGX(float NdotV, float roughness) { + float r = (roughness + 1.0); + float k = (r*r) / 8.0; + float num = NdotV; + float denom = NdotV * (1.0 - k) + k; + return num / denom; +} + +float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness) { + float NdotV = max(dot(N, V), 0.0); + float NdotL = max(dot(N, L), 0.0); + float ggx2 = GeometrySchlickGGX(NdotV, roughness); + float ggx1 = GeometrySchlickGGX(NdotL, roughness); + return ggx1 * ggx2; +} + + +vec3 fresnelSchlick(float cosTheta, vec3 F0) { + return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0); +} void main() { - - // 2 lights. - vec3 light1 = vec3(5.0, 5.0, 2.0); - vec3 light2 = vec3(-5.0, -2.0, -2.0); - + // Get the material info. vec3 albedo = color.xyz; - vec3 light = 0.3 * albedo; + int packedMaterial = int(round(color.w*255.0)); + float emittance = float((packedMaterial >> 1) & 0x3) / 3.0; + int roughnessInt = (packedMaterial >> 5) & 0x7; + float roughness = max(float(roughnessInt) / 7.0, 0.05); + float metallic = float((packedMaterial >> 3) & 0x3) / 3.0; - vec3 light1dir = normalize(light1 - pos.xyz); - vec3 light2dir = normalize(light2 - pos.xyz); - light += max(0.0, dot(light1dir, fnormal.xyz)) * albedo * 0.5; - light += max(0.0, dot(light2dir, fnormal.xyz)) * albedo * 0.3 * vec3(1.0, 0.7, 0.7); - frag_color = vec4(light, 1.0); + // Ambient light. + vec3 light = 0.3 * albedo; + + // // Make emitting things look bright. + // if(emittance > 0.01) return vec4(albedo, 1.0); + + vec3 N = normalize(fnormal.xyz); + vec3 V = normalize(cam - pos.xyz); + vec3 L = normalize(sunPosition); + vec3 H = normalize(V + L); + + vec3 F0 = vec3(0.04); + F0 = mix(F0, albedo, metallic); + vec3 F = fresnelSchlick(max(dot(H,V), 0.0), F0); + float NDF = DistributionGGX(N, H, roughness); + float G = GeometrySmith(N, V, L, roughness); + vec3 numerator = NDF * G * F; + float denominator = 4.0 * max(dot(N, V), 0.0) * max(dot(N, L), 0.0) + 0.0001; + vec3 specular = numerator / denominator; + float NdotL = max(dot(N, L), 0.0); + vec3 kD = vec3(1.0) - F; + kD *= 1.0 - metallic; + + light += (kD * albedo / PI + specular) * NdotL * vec3(1.0, 1.0, 1.0); + + frag_color = vec4(vec3(light), 1.0); } @end diff --git a/src/trile.jai b/src/trile.jai index 9b338f8..646c6d7 100644 --- a/src/trile.jai +++ b/src/trile.jai @@ -94,7 +94,7 @@ material_to_rgba :: (mat: Material) -> (r: u8, g: u8, b: u8, a: u8) { r : u8 = cast(u8) (mat.color.x * 255.0); g : u8 = cast(u8) (mat.color.y * 255.0); b : u8 = cast(u8) (mat.color.z * 255.0); - a : u8 = material_encode_to_char(mat); // @ToDo: Do actual material value encode here. + a : u8 = material_encode_to_char(mat); return r,g,b,a; } diff --git a/src/world.jai b/src/world.jai index 347bc75..749fd74 100644 --- a/src/world.jai +++ b/src/world.jai @@ -5,23 +5,29 @@ World_Config :: struct { horizonHalo : Vector3 = .{1.0, 1.0, 1.0}; sunHalo : Vector3 = .{1.0, 1.0, 1.0}; sunLightColor : Vector3 = .{1.0, 1.0, 1.0}; - sunPosition : Vector3 = #run normalize(Vector3.{0.5, 0.5, 0.5}); + sunPosition : Vector3 = #run normalize(Vector3.{0.2, 0.3, 0.4}); sunIntensity : float = 2.0; - hasClouds : int = 1; + hasClouds : s32 = 1; - hasPlane : int = 0; + hasPlane : s32 = 0; planeHeight : float = 0.0; - planeType : int = 0; + planeType : s32 = 0; } +// Copies over all the fields of our world config into a given shader type. +// Requires that the shader type has all of the fields the world config has. world_config_to_shader_type :: (wc: *World_Config, data: *$T) { - data.skyBase = wc.skyBase.component; - data.skyTop = wc.skyTop.component; - data.sunDisk = wc.sunDisk.component; - data.horizonHalo = wc.horizonHalo.component; - data.sunHalo = wc.sunHalo.component; - data.time = cast(float) get_time(); + generate_copy_code :: () -> string { + builder : String_Builder; + ti := type_info(World_Config); + for ti.members { + if it.type == type_info(Vector3) then print_to_builder(*builder, "data.% = wc.%.component;\n", it.name, it.name); + else print_to_builder(*builder, "data.% = wc.%;\n", it.name, it.name); + } + return builder_to_string(*builder); + } + #insert #run generate_copy_code(); } IVector3 :: struct {