diff --git a/game/resources/postprocess.json b/game/resources/postprocess.json index d08262e..69629e7 100644 --- a/game/resources/postprocess.json +++ b/game/resources/postprocess.json @@ -4,5 +4,8 @@ "saturation": 1.202777, "gamma": 1.019477, "tonemap": 1, - "ssao": 2.603531 + "ssao": 1.276337, + "dilate_separation": 31.199354, + "dilate_size": 7, + "dof_blur_size": 3 } \ No newline at end of file diff --git a/src/rendering/backend_sokol.jai b/src/rendering/backend_sokol.jai index 7bbf273..2eb2fab 100644 --- a/src/rendering/backend_sokol.jai +++ b/src/rendering/backend_sokol.jai @@ -8,7 +8,7 @@ current_trile_offset_index : s32 = 0; current_world_config : *World_Config = null; in_shadowmap_pass : bool = false; in_reflection_pass : bool = false; -in_gbuffer_pass : bool = false; +in_gbuffer_pass : bool = false; shadow_mvp : Matrix4; backend_handle_command :: (cmd: *Render_Command) { @@ -123,9 +123,8 @@ backend_draw_trile_positions_gbuffer :: (trile : string, amount : s32, worldConf bindings : sg_bindings; bindings.vertex_buffers[0] = trilegfx.vertex_buffer; bindings.vertex_buffers[1] = trilegfx.normal_buffer; - bindings.vertex_buffers[2] = trilegfx.centre_buffer; - bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3]; - bindings.vertex_buffer_offsets[3] = offset; + bindings.vertex_buffers[2] = gPipelines.trile.bind.vertex_buffers[3]; + bindings.vertex_buffer_offsets[2] = offset; bindings.samplers[0] = gPipelines.trile.bind.samplers[0]; bindings.images[0] = trilegfx.trixel_colors; @@ -271,9 +270,15 @@ backend_process_command_buckets :: () { sg_draw(0, 6, 1); sg_end_pass(); + + sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_ssao_attachments })); sg_apply_pipeline(gPipelines.op.pipeline); + op_uniform : Op_Fs_Params; + op_uniform.blur_size = 1; + op_uniform.op = 0; gPipelines.op.bind.images[0] = g_postprocess_a; + sg_apply_uniforms(UB_op_fs_params, *(sg_range.{ ptr = *op_uniform, size = size_of(type_of(op_uniform)) })); sg_apply_bindings(*gPipelines.op.bind); sg_draw(0, 6, 1); sg_end_pass(); @@ -286,13 +291,14 @@ backend_process_command_buckets :: () { sg_end_pass(); current_trile_offset_index = 0; // This is not optimal, but it is nice and simple. + dof_process(); // Begin drawing to swapchain sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, swapchain = cast,force(sg_swapchain) sglue_swapchain() })); // Draw the render texture and do post processing: sg_apply_pipeline(gPipelines.postprocess.pipeline); - gPipelines.postprocess.bind.images[0] = g_rendertex; + gPipelines.postprocess.bind.images[0] = g_postprocess_a; sg_apply_bindings(*gPipelines.postprocess.bind); post_process_config_uniform : Post_Process_Config; fill_uniform_with_engine_data(*post_process_config_uniform , *current_post_process); diff --git a/src/rendering/backend_sokol_helpers.jai b/src/rendering/backend_sokol_helpers.jai new file mode 100644 index 0000000..82cd5e8 --- /dev/null +++ b/src/rendering/backend_sokol_helpers.jai @@ -0,0 +1,37 @@ +dof_process :: () { + sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_postprocess_attach_a })); + sg_apply_pipeline(gPipelines.op.pipeline); + op_uniform_dilate : Op_Fs_Params; + op_uniform_dilate.blur_size = current_post_process.dof_blur_size; + op_uniform_dilate.op=2; + gPipelines.op.bind.images[0] = g_rendertex; + sg_apply_uniforms(UB_op_fs_params, *(sg_range.{ ptr = *op_uniform_dilate, size = size_of(type_of(op_uniform_dilate)) })); + sg_apply_bindings(*gPipelines.op.bind); + sg_draw(0, 6, 1); + sg_end_pass(); + + sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_postprocess_attach_b })); + sg_apply_pipeline(gPipelines.op.pipeline); + op_uniform_dof_blur : Op_Fs_Params; + op_uniform_dof_blur.blur_size = current_post_process.dilate_size; + op_uniform_dof_blur.separation = current_post_process.dilate_separation; + op_uniform_dof_blur.op=1; + gPipelines.op.bind.images[0] = g_postprocess_a; + sg_apply_uniforms(UB_op_fs_params, *(sg_range.{ ptr = *op_uniform_dof_blur, size = size_of(type_of(op_uniform_dof_blur)) })); + sg_apply_bindings(*gPipelines.op.bind); + sg_draw(0, 6, 1); + sg_end_pass(); + + sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_postprocess_attach_a })); + sg_apply_pipeline(gPipelines.mix.pipeline); + mix_uniform : Mix_Fs_Params; + mix_uniform.op = 0; + gPipelines.mix.bind.images[0] = g_postprocess_b; + gPipelines.mix.bind.images[1] = g_rendertex; + gPipelines.mix.bind.images[2] = g_gbuf_position; + sg_apply_uniforms(UB_op_fs_params, *(sg_range.{ ptr = *mix_uniform, size = size_of(type_of(mix_uniform)) })); + sg_apply_bindings(*gPipelines.mix.bind); + sg_draw(0, 6, 1); + sg_end_pass(); +} + diff --git a/src/rendering/pipelines.jai b/src/rendering/pipelines.jai index 4093287..0e3f48d 100644 --- a/src/rendering/pipelines.jai +++ b/src/rendering/pipelines.jai @@ -61,6 +61,8 @@ gPipelines : struct { postprocess : Pipeline_Binding; op : Pipeline_Binding; + + mix : Pipeline_Binding; // Renders the SSAO texture using things from the gbuffer pass. ssao: Pipeline_Binding; @@ -136,6 +138,7 @@ create_pipelines :: () { create_postprocess_pipeline(); create_ssao_pipeline(); create_op_pipeline(); + create_mix_pipeline(); create_shadowmap_image(); create_final_image(); @@ -313,10 +316,9 @@ create_gbuffer_pipeline :: () { instance_buffer := sg_buffer_desc.{ usage = .STREAM, size = 16 * 4096 * 4 * 4}; - pipeline.layout.attrs[ATTR_trile_position] = .{ format = .FLOAT3, buffer_index = 0 }; - pipeline.layout.attrs[ATTR_trile_normal] = .{ format = .FLOAT3, buffer_index = 1 }; - pipeline.layout.attrs[ATTR_trile_centre] = .{ format = .FLOAT3, buffer_index = 2 }; - pipeline.layout.attrs[ATTR_trile_instance] = .{ format = .FLOAT4, buffer_index = 3 }; + pipeline.layout.attrs[ATTR_gbuffer_position] = .{ format = .FLOAT3, buffer_index = 0 }; + pipeline.layout.attrs[ATTR_gbuffer_normal] = .{ format = .FLOAT3, buffer_index = 1 }; + pipeline.layout.attrs[ATTR_gbuffer_instance] = .{ format = .FLOAT4, buffer_index = 2 }; pipeline.depth = .{ write_enabled = true, compare = .LESS_EQUAL, @@ -689,6 +691,7 @@ create_postprocess_pipeline :: () { } +// Takes in a texture, manipulates it and outputs it. create_op_pipeline :: () { platconf := get_plat_conf(); pipeline: sg_pipeline_desc; @@ -749,6 +752,67 @@ create_op_pipeline :: () { } +// Takes in 2-3 textures, and mixes them. +create_mix_pipeline :: () { + platconf := get_plat_conf(); + pipeline: sg_pipeline_desc; + shader_desc := mix_shader_desc(sg_query_backend()); + pipeline.shader = sg_make_shader(*shader_desc); + + pipeline.layout.attrs[ATTR_mix_position] = .{ format = .FLOAT2 }; + pipeline.layout.attrs[ATTR_mix_uv] = .{ format = .FLOAT2 }; + pipeline.index_type = .UINT16; + + color_state := sg_color_target_state.{ + blend = .{ + enabled = true, + src_factor_rgb = .SRC_ALPHA, + dst_factor_rgb = .ONE_MINUS_SRC_ALPHA + } + }; + pipeline.depth = .{ + write_enabled = true, + compare = .LESS_EQUAL, + pixel_format = .DEPTH + }; + + pipeline.color_count = 1; + pipeline.colors[0] = color_state; + + gPipelines.mix.pipeline = sg_make_pipeline(*pipeline); + + quad_vertices : [16]float = .[ + -1.0, 1.0, 0.0, flip_if_plat(1.0), // top-let + -1.0, -1.0, 0.0, flip_if_plat(0.0), // bottom-let + 1.0, -1.0, 1.0, flip_if_plat(0.0), // bottom-right + 1.0, 1.0, 1.0, flip_if_plat(1.0), // top-right + ]; + quad_indices : [6]u16 = .[ + 0, 1, 2, 0, 2, 3 + ]; + + vbuffer := sg_buffer_desc.{ size = size_of(float) * 16, data = .{ + ptr = quad_vertices.data, + size = 16 * 4 + }}; + ibuffer := sg_buffer_desc.{ size = size_of(u16) * 6, data = .{ + ptr = quad_indices.data, + size = 6 * 2 + }, + type = .INDEXBUFFER, + }; + + gPipelines.mix.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer); + gPipelines.mix.bind.index_buffer = sg_make_buffer(*ibuffer); + gPipelines.mix.bind.samplers[0] = sg_make_sampler(*(sg_sampler_desc.{ + wrap_u = .CLAMP_TO_EDGE, + wrap_v = .CLAMP_TO_EDGE, + min_filter = .NEAREST, + mag_filter = .NEAREST, + })); + +} + create_ssao_images :: () { if g_ssaobuf.id != INVALID_ID then sg_destroy_image(g_ssaobuf); if g_ssaobuf_depth.id != INVALID_ID then sg_destroy_image(g_ssaobuf_depth); diff --git a/src/rendering/post_processing.jai b/src/rendering/post_processing.jai index 7d668f9..ab0df78 100644 --- a/src/rendering/post_processing.jai +++ b/src/rendering/post_processing.jai @@ -1,10 +1,13 @@ Post_Process :: struct { - exposure : float = 0.0; @Slider,-1,1,0.1; - contrast : float = 1.0; @Slider,0.1,4.0,0.1; - saturation : float = 1.0; @Slider,0.0,2.0,0.1; - gamma : float = 1.0; @Slider,0.3,3.0,0.1; - tonemap : float = 1.0; @Slider,0,1,1; - ssao : float = 1.0; @Slider,0,5,0.1; + exposure : float = 0.0; @Slider,-1,1,0.1; + contrast : float = 1.0; @Slider,0.1,4.0,0.1; + saturation : float = 1.0; @Slider,0.0,2.0,0.1; + gamma : float = 1.0; @Slider,0.3,3.0,0.1; + tonemap : float = 1.0; @Slider,0,1,1; + ssao : float = 1.0; @Slider,0,5,0.1; + dilate_separation : float = 1.0; @Slider,0,100,0.1; + dilate_size : s32 = 2; @Slider,0,10,1; + dof_blur_size : s32 = 2; @Slider,0,10,1; } current_post_process : Post_Process; diff --git a/src/rendering/rendering.jai b/src/rendering/rendering.jai index c0bf432..509b938 100644 --- a/src/rendering/rendering.jai +++ b/src/rendering/rendering.jai @@ -17,6 +17,7 @@ #load "helpers.jai"; #load "pipelines.jai"; #load "post_processing.jai"; +#load "backend_sokol_helpers.jai"; #scope_file diff --git a/src/shaders/jai/shader_mix.jai b/src/shaders/jai/shader_mix.jai new file mode 100644 index 0000000..fea8e1f --- /dev/null +++ b/src/shaders/jai/shader_mix.jai @@ -0,0 +1,409 @@ +/* + #version:1# (machine generated, don't edit!) + + Generated by sokol-shdc (https://github.com/floooh/sokol-tools) + + Cmdline: + sokol-shdc -i shader_mix.glsl -o ./jai/shader_mix.jai -l glsl430:glsl300es:metal_macos -f sokol_jai + + Overview: + ========= + Shader program: 'mix': + Get shader desc: mix_shader_desc(sg_query_backend()) + Vertex Shader: vs_mix + Fragment Shader: fs_mix + Attributes: + ATTR_mix_position => 0 + ATTR_mix_uv => 1 + Bindings: + Uniform block 'mix_fs_params': + Jai struct: Mix_Fs_Params + Bind slot: UB_mix_fs_params => 1 + Image 'mixtex_c': + Image type: ._2D + Sample type: .FLOAT + Multisampled: false + Bind slot: IMG_mixtex_c => 2 + Sampler 'mixsmp': + Type: .FILTERING + Bind slot: SMP_mixsmp => 0 +*/ +ATTR_mix_position :: 0; +ATTR_mix_uv :: 1; +UB_mix_fs_params :: 1; +IMG_mixtex_c :: 2; +SMP_mixsmp :: 0; +Mix_Fs_Params :: struct { + op: s32; + _: [12]u8; +}; +/* + #version 430 + + layout(location = 0) in vec2 position; + layout(location = 0) out vec2 texcoord; + layout(location = 1) in vec2 uv; + + void main() + { + gl_Position = vec4(position, 0.5, 1.0); + texcoord = uv; + } + +*/ +vs_mix_source_glsl430 := u8.[ + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,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,0x32,0x20,0x70,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,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,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x32,0x20,0x75,0x76,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,0x76, + 0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e, + 0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78, + 0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, + +]; +/* + #version 430 + + uniform ivec4 mix_fs_params[1]; + layout(binding = 16) uniform sampler2D mixtex_c_mixsmp; + + layout(location = 0) in vec2 texcoord; + layout(location = 0) out vec4 frag_color; + + void main() + { + if (mix_fs_params[0].x == 0) + { + frag_color = vec4(texture(mixtex_c_mixsmp, texcoord).xyz, 1.0); + } + else + { + frag_color = vec4(1.0); + } + } + +*/ +fs_mix_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,0x69,0x76,0x65,0x63,0x34,0x20,0x6d,0x69,0x78,0x5f, + 0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61, + 0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31, + 0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c, + 0x65,0x72,0x32,0x44,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x5f,0x6d,0x69, + 0x78,0x73,0x6d,0x70,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,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x69,0x66,0x20,0x28,0x6d, + 0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e, + 0x78,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28, + 0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c, + 0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20, + 0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20, + 0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20, + 0x76,0x65,0x63,0x34,0x28,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d, + 0x0a,0x7d,0x0a,0x0a,0x00, +]; +/* + #version 300 es + + layout(location = 0) in vec2 position; + out vec2 texcoord; + layout(location = 1) in vec2 uv; + + void main() + { + gl_Position = vec4(position, 0.5, 1.0); + texcoord = uv; + } + +*/ +vs_mix_source_glsl300es := u8.[ + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,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,0x32,0x20,0x70,0x6f, + 0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32, + 0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x32,0x20,0x75,0x76,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,0x76,0x65,0x63, + 0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c, + 0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f, + 0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +]; +/* + #version 300 es + precision mediump float; + precision highp int; + + uniform ivec4 mix_fs_params[1]; + uniform highp sampler2D mixtex_c_mixsmp; + + in highp vec2 texcoord; + layout(location = 0) out highp vec4 frag_color; + + void main() + { + if (mix_fs_params[0].x == 0) + { + frag_color = vec4(texture(mixtex_c_mixsmp, texcoord).xyz, 1.0); + } + else + { + frag_color = vec4(1.0); + } + } + +*/ +fs_mix_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,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x69,0x76,0x65,0x63,0x34,0x20,0x6d,0x69,0x78, + 0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x5f, + 0x6d,0x69,0x78,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68, + 0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x69,0x66,0x20,0x28,0x6d,0x69,0x78,0x5f,0x66,0x73,0x5f,0x70, + 0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x20,0x3d,0x3d,0x20,0x30,0x29, + 0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66, + 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34, + 0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f, + 0x63,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f, + 0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20, + 0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x31,0x2e, + 0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00, +]; +/* + #include + #include + + using namespace metal; + + struct main0_out + { + float2 texcoord [[user(locn0)]]; + float4 gl_Position [[position]]; + }; + + struct main0_in + { + float2 position [[attribute(0)]]; + float2 uv [[attribute(1)]]; + }; + + vertex main0_out main0(main0_in in [[stage_in]]) + { + main0_out out = {}; + out.gl_Position = float4(in.position, 0.5, 1.0); + out.texcoord = in.uv; + return out; + } + +*/ +vs_mix_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,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,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,0x32,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,0x32,0x20,0x75,0x76,0x20,0x5b, + 0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,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,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,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e, + 0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31, + 0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x74,0x65,0x78, + 0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d, + 0x0a,0x0a,0x00, +]; +/* + #include + #include + + using namespace metal; + + struct mix_fs_params + { + int op; + }; + + struct main0_out + { + float4 frag_color [[color(0)]]; + }; + + struct main0_in + { + float2 texcoord [[user(locn0)]]; + }; + + fragment main0_out main0(main0_in in [[stage_in]], constant mix_fs_params& _9 [[buffer(0)]], texture2d mixtex_c [[texture(0)]], sampler mixsmp [[sampler(0)]]) + { + main0_out out = {}; + if (_9.op == 0) + { + out.frag_color = float4(mixtex_c.sample(mixsmp, in.texcoord).xyz, 1.0); + } + else + { + out.frag_color = float4(1.0); + } + return out; + } + +*/ +fs_mix_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, + 0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x6f,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,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,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20, + 0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,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,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74, + 0x20,0x6d,0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20, + 0x5f,0x39,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d, + 0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61, + 0x74,0x3e,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x20,0x5b,0x5b,0x74,0x65, + 0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70, + 0x6c,0x65,0x72,0x20,0x6d,0x69,0x78,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d, + 0x70,0x6c,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,0x66,0x20,0x28,0x5f,0x39,0x2e, + 0x6f,0x70,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20, + 0x20,0x20,0x20,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,0x6d, + 0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x6d, + 0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f, + 0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20, + 0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,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,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a, + 0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a, + 0x7d,0x0a,0x0a,0x00, +]; +mix_shader_desc :: (backend: sg_backend) -> sg_shader_desc { + desc: sg_shader_desc; + desc.label = "mix_shader"; + if backend == { + case .GLCORE; + desc.vertex_func.source = xx *vs_mix_source_glsl430; + desc.vertex_func.entry = "main"; + desc.fragment_func.source = xx *fs_mix_source_glsl430; + desc.fragment_func.entry = "main"; + desc.attrs[0].base_type = .FLOAT; + desc.attrs[0].glsl_name = "position"; + desc.attrs[1].base_type = .FLOAT; + desc.attrs[1].glsl_name = "uv"; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 16; + desc.uniform_blocks[1].glsl_uniforms[0].type = .INT4; + desc.uniform_blocks[1].glsl_uniforms[0].array_count = 1; + desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "mix_fs_params"; + desc.images[2].stage = .FRAGMENT; + desc.images[2].multisampled = false; + desc.images[2].image_type = ._2D; + desc.images[2].sample_type = .FLOAT; + desc.samplers[0].stage = .FRAGMENT; + desc.samplers[0].sampler_type = .FILTERING; + desc.image_sampler_pairs[0].stage = .FRAGMENT; + desc.image_sampler_pairs[0].image_slot = 2; + desc.image_sampler_pairs[0].sampler_slot = 0; + desc.image_sampler_pairs[0].glsl_name = "mixtex_c_mixsmp"; + case .GLES3; + desc.vertex_func.source = xx *vs_mix_source_glsl300es; + desc.vertex_func.entry = "main"; + desc.fragment_func.source = xx *fs_mix_source_glsl300es; + desc.fragment_func.entry = "main"; + desc.attrs[0].base_type = .FLOAT; + desc.attrs[0].glsl_name = "position"; + desc.attrs[1].base_type = .FLOAT; + desc.attrs[1].glsl_name = "uv"; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 16; + desc.uniform_blocks[1].glsl_uniforms[0].type = .INT4; + desc.uniform_blocks[1].glsl_uniforms[0].array_count = 1; + desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "mix_fs_params"; + desc.images[2].stage = .FRAGMENT; + desc.images[2].multisampled = false; + desc.images[2].image_type = ._2D; + desc.images[2].sample_type = .FLOAT; + desc.samplers[0].stage = .FRAGMENT; + desc.samplers[0].sampler_type = .FILTERING; + desc.image_sampler_pairs[0].stage = .FRAGMENT; + desc.image_sampler_pairs[0].image_slot = 2; + desc.image_sampler_pairs[0].sampler_slot = 0; + desc.image_sampler_pairs[0].glsl_name = "mixtex_c_mixsmp"; + case .METAL_MACOS; + desc.vertex_func.source = xx *vs_mix_source_metal_macos; + desc.vertex_func.entry = "main0"; + desc.fragment_func.source = xx *fs_mix_source_metal_macos; + desc.fragment_func.entry = "main0"; + desc.attrs[0].base_type = .FLOAT; + desc.attrs[1].base_type = .FLOAT; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 16; + desc.uniform_blocks[1].msl_buffer_n = 0; + desc.images[2].stage = .FRAGMENT; + desc.images[2].multisampled = false; + desc.images[2].image_type = ._2D; + desc.images[2].sample_type = .FLOAT; + desc.images[2].msl_texture_n = 0; + desc.samplers[0].stage = .FRAGMENT; + desc.samplers[0].sampler_type = .FILTERING; + desc.samplers[0].msl_sampler_n = 0; + desc.image_sampler_pairs[0].stage = .FRAGMENT; + desc.image_sampler_pairs[0].image_slot = 2; + desc.image_sampler_pairs[0].sampler_slot = 0; + } + return desc; +} diff --git a/src/shaders/jai/shader_op.jai b/src/shaders/jai/shader_op.jai index 160c782..6fe6f52 100644 --- a/src/shaders/jai/shader_op.jai +++ b/src/shaders/jai/shader_op.jai @@ -16,6 +16,9 @@ ATTR_op_position => 0 ATTR_op_uv => 1 Bindings: + Uniform block 'op_fs_params': + Jai struct: Op_Fs_Params + Bind slot: UB_op_fs_params => 1 Image 'optex': Image type: ._2D Sample type: .FLOAT @@ -27,8 +30,15 @@ */ ATTR_op_position :: 0; ATTR_op_uv :: 1; +UB_op_fs_params :: 1; IMG_optex :: 0; SMP_opsmp :: 0; +Op_Fs_Params :: struct { + blur_size: s32; + op: s32; + separation: float; + _: [4]u8; +}; /* #version 430 @@ -62,6 +72,15 @@ vs_op_source_glsl430 := u8.[ /* #version 430 + struct op_fs_params + { + int blur_size; + int op; + float separation; + }; + + uniform op_fs_params _10; + layout(binding = 16) uniform sampler2D optex_opsmp; layout(location = 0) in vec2 texcoord; @@ -69,54 +88,253 @@ vs_op_source_glsl430 := u8.[ void main() { - vec2 _28 = vec2(1.0) / vec2(textureSize(optex_opsmp, 0)); - float result = 0.0; - for (int x = -2; x < 2; x++) + if (_10.op == 2) { - for (int y = -2; y < 2; y++) + vec2 _40 = vec2(1.0) / vec2(textureSize(optex_opsmp, 0)); + vec3 result = vec3(0.0); + int _50 = -_10.blur_size; + for (int x = _50; x < _10.blur_size; x++) { - result += texture(optex_opsmp, texcoord + (vec2(float(x), float(y)) * _28)).x; + for (int y = _50; y < _10.blur_size; y++) + { + result += texture(optex_opsmp, texcoord + (vec2(float(x), float(y)) * _40)).xyz; + } + } + frag_color = vec4(result / vec3(float(((_10.blur_size * 2) * _10.blur_size) * 2)), 1.0); + } + else + { + if (_10.op == 1) + { + vec2 _132 = vec2(textureSize(optex_opsmp, 0)); + frag_color = texture(optex_opsmp, gl_FragCoord.xy / _132); + if (_10.blur_size <= 0) + { + return; + } + float mx = 0.0; + vec4 cmx = frag_color; + int _158 = -_10.blur_size; + for (int i = _158; i <= _10.blur_size; i++) + { + for (int j = _158; j <= _10.blur_size; j++) + { + if (!(distance(vec2(float(i), float(j)), vec2(0.0)) <= float(_10.blur_size))) + { + continue; + } + vec4 _214 = texture(optex_opsmp, (gl_FragCoord.xy + (vec2(float(i), float(j)) * _10.separation)) / _132); + float _221 = dot(_214.xyz, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)); + if (_221 > mx) + { + mx = _221; + cmx = _214; + } + } + } + vec4 _233 = frag_color; + vec3 _242 = mix(_233.xyz, cmx.xyz, vec3(smoothstep(0.100000001490116119384765625, 0.300000011920928955078125, mx))); + frag_color.x = _242.x; + frag_color.y = _242.y; + frag_color.z = _242.z; + } + else + { + vec2 _263 = vec2(1.0) / vec2(textureSize(optex_opsmp, 0)); + float result_1 = 0.0; + int _268 = -_10.blur_size; + for (int x_1 = _268; x_1 < _10.blur_size; x_1++) + { + for (int y_1 = _268; y_1 < _10.blur_size; y_1++) + { + result_1 += texture(optex_opsmp, texcoord + (vec2(float(x_1), float(y_1)) * _263)).x; + } + } + float _322 = result_1 / float(((_10.blur_size * 2) * _10.blur_size) * 2); + frag_color = vec4(_322, _322, _322, 1.0); } } - float _84 = result * 0.0625; - frag_color = vec4(_84, _84, _84, 1.0); } */ fs_op_source_glsl430 := u8.[ - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61, - 0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31, - 0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c, - 0x65,0x72,0x32,0x44,0x20,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70, - 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,0x32,0x20, - 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x76,0x65,0x63,0x32,0x20,0x5f,0x32,0x38,0x20, - 0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x31,0x2e,0x30,0x29,0x20,0x2f,0x20,0x76,0x65, - 0x63,0x32,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x53,0x69,0x7a,0x65,0x28,0x6f, - 0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x30,0x29,0x29,0x3b, - 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x65,0x73,0x75,0x6c, - 0x74,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72, - 0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d,0x32,0x3b,0x20,0x78,0x20, - 0x3c,0x20,0x32,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a, - 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74, - 0x20,0x79,0x20,0x3d,0x20,0x2d,0x32,0x3b,0x20,0x79,0x20,0x3c,0x20,0x32,0x3b,0x20, - 0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20, - 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x72,0x65,0x73,0x75,0x6c, - 0x74,0x20,0x2b,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f,0x70,0x74, - 0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f, - 0x72,0x64,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74, - 0x28,0x78,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x79,0x29,0x29,0x20,0x2a, - 0x20,0x5f,0x32,0x38,0x29,0x29,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, - 0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c, - 0x6f,0x61,0x74,0x20,0x5f,0x38,0x34,0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74, - 0x20,0x2a,0x20,0x30,0x2e,0x30,0x36,0x32,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,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20, - 0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74, + 0x72,0x75,0x63,0x74,0x20,0x6f,0x70,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x62,0x6c,0x75,0x72, + 0x5f,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x6f, + 0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x65,0x70, + 0x61,0x72,0x61,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x75,0x6e,0x69, + 0x66,0x6f,0x72,0x6d,0x20,0x6f,0x70,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x20,0x5f,0x31,0x30,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62, + 0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x36,0x29,0x20,0x75,0x6e,0x69, + 0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x6f, + 0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,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,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f, + 0x72,0x64,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,0x69,0x66,0x20,0x28,0x5f,0x31,0x30,0x2e,0x6f,0x70,0x20,0x3d,0x3d,0x20,0x32, + 0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x76,0x65,0x63,0x32,0x20,0x5f,0x34,0x30,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28, + 0x31,0x2e,0x30,0x29,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x74,0x65,0x78,0x74, + 0x75,0x72,0x65,0x53,0x69,0x7a,0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70, + 0x73,0x6d,0x70,0x2c,0x20,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x3d,0x20, + 0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x35,0x30,0x20,0x3d,0x20,0x2d,0x5f,0x31, + 0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20, + 0x3d,0x20,0x5f,0x35,0x30,0x3b,0x20,0x78,0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62, + 0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x79,0x20, + 0x3d,0x20,0x5f,0x35,0x30,0x3b,0x20,0x79,0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62, + 0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x72,0x65,0x73, + 0x75,0x6c,0x74,0x20,0x2b,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f, + 0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63, + 0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f, + 0x61,0x74,0x28,0x78,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x79,0x29,0x29, + 0x20,0x2a,0x20,0x5f,0x34,0x30,0x29,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28, + 0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2f,0x20,0x76,0x65,0x63,0x33,0x28,0x66,0x6c, + 0x6f,0x61,0x74,0x28,0x28,0x28,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73, + 0x69,0x7a,0x65,0x20,0x2a,0x20,0x32,0x29,0x20,0x2a,0x20,0x5f,0x31,0x30,0x2e,0x62, + 0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x29,0x20,0x2a,0x20,0x32,0x29,0x29,0x2c, + 0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20, + 0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x30,0x2e,0x6f,0x70,0x20,0x3d, + 0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,0x20, + 0x5f,0x31,0x33,0x32,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x74,0x65,0x78,0x74, + 0x75,0x72,0x65,0x53,0x69,0x7a,0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70, + 0x73,0x6d,0x70,0x2c,0x20,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f,0x70,0x74,0x65,0x78, + 0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x43, + 0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x20,0x2f,0x20,0x5f,0x31,0x33,0x32,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20, + 0x28,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x20,0x3c, + 0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x6d,0x78,0x20,0x3d,0x20, + 0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6d,0x78,0x20,0x3d,0x20,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x31,0x35,0x38,0x20,0x3d,0x20,0x2d, + 0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28, + 0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,0x20,0x5f,0x31,0x35,0x38,0x3b,0x20,0x69,0x20, + 0x3c,0x3d,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65, + 0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x6a,0x20, + 0x3d,0x20,0x5f,0x31,0x35,0x38,0x3b,0x20,0x6a,0x20,0x3c,0x3d,0x20,0x5f,0x31,0x30, + 0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x6a,0x2b,0x2b,0x29, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x21,0x28,0x64,0x69,0x73, + 0x74,0x61,0x6e,0x63,0x65,0x28,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74, + 0x28,0x69,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x6a,0x29,0x29,0x2c,0x20, + 0x76,0x65,0x63,0x32,0x28,0x30,0x2e,0x30,0x29,0x29,0x20,0x3c,0x3d,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x28,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a, + 0x65,0x29,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x63,0x6f,0x6e,0x74,0x69,0x6e,0x75,0x65,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x32,0x31,0x34, + 0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f,0x70,0x74,0x65,0x78, + 0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x28,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67, + 0x43,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x32, + 0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x28,0x6a,0x29,0x29,0x20,0x2a,0x20,0x5f,0x31,0x30,0x2e,0x73,0x65,0x70,0x61,0x72, + 0x61,0x74,0x69,0x6f,0x6e,0x29,0x29,0x20,0x2f,0x20,0x5f,0x31,0x33,0x32,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x32,0x31,0x20, + 0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x31,0x34,0x2e,0x78,0x79,0x7a,0x2c,0x20, + 0x76,0x65,0x63,0x33,0x28,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,0x2c, + 0x20,0x30,0x2e,0x35,0x38,0x39,0x39,0x39,0x39,0x39,0x37,0x33,0x37,0x37,0x33,0x39, + 0x35,0x36,0x32,0x39,0x38,0x38,0x32,0x38,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x31, + 0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x34,0x30,0x33,0x39,0x35,0x33,0x35,0x35, + 0x32,0x32,0x34,0x36,0x30,0x39,0x33,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x69,0x66,0x20,0x28,0x5f,0x32,0x32,0x31,0x20,0x3e,0x20,0x6d,0x78,0x29,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6d,0x78, + 0x20,0x3d,0x20,0x5f,0x32,0x32,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x63,0x6d,0x78,0x20,0x3d,0x20,0x5f,0x32,0x31,0x34,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76, + 0x65,0x63,0x34,0x20,0x5f,0x32,0x33,0x33,0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f, + 0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x34,0x32,0x20,0x3d,0x20,0x6d, + 0x69,0x78,0x28,0x5f,0x32,0x33,0x33,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x63,0x6d,0x78, + 0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x73,0x6d,0x6f,0x6f,0x74, + 0x68,0x73,0x74,0x65,0x70,0x28,0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30, + 0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34,0x37,0x36,0x35, + 0x36,0x32,0x35,0x2c,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,0x2c, + 0x20,0x6d,0x78,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78, + 0x20,0x3d,0x20,0x5f,0x32,0x34,0x32,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x2e,0x79,0x20,0x3d,0x20,0x5f,0x32,0x34,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63, + 0x6f,0x6c,0x6f,0x72,0x2e,0x7a,0x20,0x3d,0x20,0x5f,0x32,0x34,0x32,0x2e,0x7a,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65, + 0x63,0x32,0x20,0x5f,0x32,0x36,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x31, + 0x2e,0x30,0x29,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x74,0x65,0x78,0x74,0x75, + 0x72,0x65,0x53,0x69,0x7a,0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73, + 0x6d,0x70,0x2c,0x20,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x65,0x73,0x75,0x6c, + 0x74,0x5f,0x31,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x32,0x36,0x38,0x20, + 0x3d,0x20,0x2d,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f, + 0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x5f,0x31,0x20,0x3d,0x20,0x5f,0x32,0x36, + 0x38,0x3b,0x20,0x78,0x5f,0x31,0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75, + 0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x78,0x5f,0x31,0x2b,0x2b,0x29,0x0a,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72, + 0x20,0x28,0x69,0x6e,0x74,0x20,0x79,0x5f,0x31,0x20,0x3d,0x20,0x5f,0x32,0x36,0x38, + 0x3b,0x20,0x79,0x5f,0x31,0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72, + 0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x79,0x5f,0x31,0x2b,0x2b,0x29,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x5f,0x31,0x20,0x2b,0x3d,0x20, + 0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70, + 0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20, + 0x28,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x78,0x5f,0x31,0x29, + 0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x79,0x5f,0x31,0x29,0x29,0x20,0x2a,0x20, + 0x5f,0x32,0x36,0x33,0x29,0x29,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x32,0x32, + 0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x5f,0x31,0x20,0x2f,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x28,0x28,0x28,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73, + 0x69,0x7a,0x65,0x20,0x2a,0x20,0x32,0x29,0x20,0x2a,0x20,0x5f,0x31,0x30,0x2e,0x62, + 0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x29,0x20,0x2a,0x20,0x32,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x33, + 0x32,0x32,0x2c,0x20,0x5f,0x33,0x32,0x32,0x2c,0x20,0x5f,0x33,0x32,0x32,0x2c,0x20, + 0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a, + 0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00, ]; /* #version 300 es @@ -151,6 +369,15 @@ vs_op_source_glsl300es := u8.[ precision mediump float; precision highp int; + struct op_fs_params + { + int blur_size; + int op; + highp float separation; + }; + + uniform op_fs_params _10; + uniform highp sampler2D optex_opsmp; in highp vec2 texcoord; @@ -158,17 +385,72 @@ vs_op_source_glsl300es := u8.[ void main() { - highp vec2 _28 = vec2(1.0) / vec2(textureSize(optex_opsmp, 0)); - highp float result = 0.0; - for (int x = -2; x < 2; x++) + if (_10.op == 2) { - for (int y = -2; y < 2; y++) + highp vec2 _40 = vec2(1.0) / vec2(textureSize(optex_opsmp, 0)); + highp vec3 result = vec3(0.0); + int _50 = -_10.blur_size; + for (int x = _50; x < _10.blur_size; x++) { - result += texture(optex_opsmp, texcoord + (vec2(float(x), float(y)) * _28)).x; + for (int y = _50; y < _10.blur_size; y++) + { + result += texture(optex_opsmp, texcoord + (vec2(float(x), float(y)) * _40)).xyz; + } + } + frag_color = vec4(result / vec3(float(((_10.blur_size * 2) * _10.blur_size) * 2)), 1.0); + } + else + { + if (_10.op == 1) + { + highp vec2 _132 = vec2(textureSize(optex_opsmp, 0)); + frag_color = texture(optex_opsmp, gl_FragCoord.xy / _132); + if (_10.blur_size <= 0) + { + return; + } + highp float mx = 0.0; + highp vec4 cmx = frag_color; + int _158 = -_10.blur_size; + for (int i = _158; i <= _10.blur_size; i++) + { + for (int j = _158; j <= _10.blur_size; j++) + { + if (!(distance(vec2(float(i), float(j)), vec2(0.0)) <= float(_10.blur_size))) + { + continue; + } + highp vec4 _214 = texture(optex_opsmp, (gl_FragCoord.xy + (vec2(float(i), float(j)) * _10.separation)) / _132); + highp float _221 = dot(_214.xyz, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)); + if (_221 > mx) + { + mx = _221; + cmx = _214; + } + } + } + highp vec4 _233 = frag_color; + highp vec3 _242 = mix(_233.xyz, cmx.xyz, vec3(smoothstep(0.100000001490116119384765625, 0.300000011920928955078125, mx))); + frag_color.x = _242.x; + frag_color.y = _242.y; + frag_color.z = _242.z; + } + else + { + highp vec2 _263 = vec2(1.0) / vec2(textureSize(optex_opsmp, 0)); + highp float result_1 = 0.0; + int _268 = -_10.blur_size; + for (int x_1 = _268; x_1 < _10.blur_size; x_1++) + { + for (int y_1 = _268; y_1 < _10.blur_size; y_1++) + { + result_1 += texture(optex_opsmp, texcoord + (vec2(float(x_1), float(y_1)) * _263)).x; + } + } + highp float _322 = result_1 / float(((_10.blur_size * 2) * _10.blur_size) * 2); + frag_color = vec4(_322, _322, _322, 1.0); } } - highp float _84 = result * 0.0625; - frag_color = vec4(_84, _84, _84, 1.0); } */ @@ -176,7 +458,14 @@ fs_op_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,0x75, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x73, + 0x74,0x72,0x75,0x63,0x74,0x20,0x6f,0x70,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61, + 0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x62,0x6c,0x75, + 0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20, + 0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x20,0x73,0x65,0x70,0x61,0x72,0x61,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x7d,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x6f,0x70,0x5f,0x66, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x5f,0x31,0x30,0x3b,0x0a,0x0a,0x75, 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73, 0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65, @@ -185,30 +474,171 @@ fs_op_source_glsl300es := u8.[ 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, - 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x32,0x38,0x20,0x3d, - 0x20,0x76,0x65,0x63,0x32,0x28,0x31,0x2e,0x30,0x29,0x20,0x2f,0x20,0x76,0x65,0x63, - 0x32,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x53,0x69,0x7a,0x65,0x28,0x6f,0x70, - 0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x30,0x29,0x29,0x3b,0x0a, - 0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20, - 0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20, - 0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d, - 0x32,0x3b,0x20,0x78,0x20,0x3c,0x20,0x32,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20, - 0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72, - 0x20,0x28,0x69,0x6e,0x74,0x20,0x79,0x20,0x3d,0x20,0x2d,0x32,0x3b,0x20,0x79,0x20, - 0x3c,0x20,0x32,0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x69,0x66,0x20,0x28,0x5f,0x31,0x30,0x2e,0x6f,0x70,0x20,0x3d,0x3d,0x20,0x32,0x29, + 0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68, + 0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x34,0x30,0x20,0x3d,0x20, + 0x76,0x65,0x63,0x32,0x28,0x31,0x2e,0x30,0x29,0x20,0x2f,0x20,0x76,0x65,0x63,0x32, + 0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x53,0x69,0x7a,0x65,0x28,0x6f,0x70,0x74, + 0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x30,0x29,0x29,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63, + 0x33,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x3d,0x20,0x76,0x65,0x63,0x33,0x28, + 0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x6e, + 0x74,0x20,0x5f,0x35,0x30,0x20,0x3d,0x20,0x2d,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75, + 0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x5f,0x35,0x30, + 0x3b,0x20,0x78,0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73, + 0x69,0x7a,0x65,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, - 0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2b,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72, - 0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x74, - 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x32,0x28, - 0x66,0x6c,0x6f,0x61,0x74,0x28,0x78,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28, - 0x79,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x38,0x29,0x29,0x2e,0x78,0x3b,0x0a,0x20, - 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20, - 0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f, - 0x38,0x34,0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2a,0x20,0x30,0x2e, - 0x30,0x36,0x32,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,0x38,0x34,0x2c, - 0x20,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b, - 0x0a,0x7d,0x0a,0x0a,0x00, + 0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x79,0x20,0x3d,0x20,0x5f,0x35,0x30, + 0x3b,0x20,0x79,0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73, + 0x69,0x7a,0x65,0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2b, + 0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f, + 0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20, + 0x2b,0x20,0x28,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x78,0x29, + 0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x79,0x29,0x29,0x20,0x2a,0x20,0x5f,0x34, + 0x30,0x29,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x72,0x65,0x73,0x75,0x6c, + 0x74,0x20,0x2f,0x20,0x76,0x65,0x63,0x33,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x28, + 0x28,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x20,0x2a, + 0x20,0x32,0x29,0x20,0x2a,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73, + 0x69,0x7a,0x65,0x29,0x20,0x2a,0x20,0x32,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65, + 0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69, + 0x66,0x20,0x28,0x5f,0x31,0x30,0x2e,0x6f,0x70,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32, + 0x20,0x5f,0x31,0x33,0x32,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x74,0x65,0x78, + 0x74,0x75,0x72,0x65,0x53,0x69,0x7a,0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f, + 0x70,0x73,0x6d,0x70,0x2c,0x20,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f,0x70,0x74,0x65, + 0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67, + 0x43,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x20,0x2f,0x20,0x5f,0x31,0x33,0x32,0x29, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66, + 0x20,0x28,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x20, + 0x3c,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x20,0x6d,0x78,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65, + 0x63,0x34,0x20,0x63,0x6d,0x78,0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x69,0x6e,0x74,0x20,0x5f,0x31,0x35,0x38,0x20,0x3d,0x20,0x2d,0x5f,0x31,0x30, + 0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74, + 0x20,0x69,0x20,0x3d,0x20,0x5f,0x31,0x35,0x38,0x3b,0x20,0x69,0x20,0x3c,0x3d,0x20, + 0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x69, + 0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x6a,0x20,0x3d,0x20,0x5f, + 0x31,0x35,0x38,0x3b,0x20,0x6a,0x20,0x3c,0x3d,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c, + 0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x6a,0x2b,0x2b,0x29,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x21,0x28,0x64,0x69,0x73,0x74,0x61,0x6e, + 0x63,0x65,0x28,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x29, + 0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x6a,0x29,0x29,0x2c,0x20,0x76,0x65,0x63, + 0x32,0x28,0x30,0x2e,0x30,0x29,0x29,0x20,0x3c,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x28,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x29,0x29, + 0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x63,0x6f,0x6e,0x74,0x69,0x6e,0x75,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x5f, + 0x32,0x31,0x34,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f,0x70, + 0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x28,0x67,0x6c,0x5f,0x46, + 0x72,0x61,0x67,0x43,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x20,0x2b,0x20,0x28,0x76, + 0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x29,0x2c,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x28,0x6a,0x29,0x29,0x20,0x2a,0x20,0x5f,0x31,0x30,0x2e,0x73,0x65, + 0x70,0x61,0x72,0x61,0x74,0x69,0x6f,0x6e,0x29,0x29,0x20,0x2f,0x20,0x5f,0x31,0x33, + 0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x20,0x5f,0x32,0x32,0x31,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f, + 0x32,0x31,0x34,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,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,0x2c,0x20,0x30,0x2e,0x35,0x38,0x39,0x39, + 0x39,0x39,0x39,0x37,0x33,0x37,0x37,0x33,0x39,0x35,0x36,0x32,0x39,0x38,0x38,0x32, + 0x38,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x31,0x30,0x39,0x39,0x39,0x39,0x39,0x39, + 0x39,0x34,0x30,0x33,0x39,0x35,0x33,0x35,0x35,0x32,0x32,0x34,0x36,0x30,0x39,0x33, + 0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x32, + 0x32,0x31,0x20,0x3e,0x20,0x6d,0x78,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6d,0x78,0x20,0x3d,0x20,0x5f,0x32,0x32,0x31, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x6d,0x78,0x20,0x3d,0x20, + 0x5f,0x32,0x31,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65, + 0x63,0x34,0x20,0x5f,0x32,0x33,0x33,0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f,0x63, + 0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x34, + 0x32,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f,0x32,0x33,0x33,0x2e,0x78,0x79,0x7a, + 0x2c,0x20,0x63,0x6d,0x78,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28, + 0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x30,0x2e,0x31,0x30,0x30, + 0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33, + 0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,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,0x2c,0x20,0x6d,0x78,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x32,0x34,0x32,0x2e,0x78,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x79,0x20,0x3d,0x20,0x5f,0x32,0x34,0x32,0x2e, + 0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66, + 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x7a,0x20,0x3d,0x20,0x5f,0x32, + 0x34,0x32,0x2e,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x32, + 0x36,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x31,0x2e,0x30,0x29,0x20,0x2f, + 0x20,0x76,0x65,0x63,0x32,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x53,0x69,0x7a, + 0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x30, + 0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x65,0x73,0x75, + 0x6c,0x74,0x5f,0x31,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x32,0x36,0x38, + 0x20,0x3d,0x20,0x2d,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a, + 0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66, + 0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x5f,0x31,0x20,0x3d,0x20,0x5f,0x32, + 0x36,0x38,0x3b,0x20,0x78,0x5f,0x31,0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c, + 0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x78,0x5f,0x31,0x2b,0x2b,0x29,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f, + 0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x79,0x5f,0x31,0x20,0x3d,0x20,0x5f,0x32,0x36, + 0x38,0x3b,0x20,0x79,0x5f,0x31,0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75, + 0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x79,0x5f,0x31,0x2b,0x2b,0x29,0x0a,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x5f,0x31,0x20,0x2b,0x3d, + 0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f, + 0x70,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b, + 0x20,0x28,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x78,0x5f,0x31, + 0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x79,0x5f,0x31,0x29,0x29,0x20,0x2a, + 0x20,0x5f,0x32,0x36,0x33,0x29,0x29,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x5f,0x33,0x32,0x32,0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74, + 0x5f,0x31,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x28,0x28,0x5f,0x31,0x30, + 0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x20,0x2a,0x20,0x32,0x29,0x20, + 0x2a,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x29, + 0x20,0x2a,0x20,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20, + 0x76,0x65,0x63,0x34,0x28,0x5f,0x33,0x32,0x32,0x2c,0x20,0x5f,0x33,0x32,0x32,0x2c, + 0x20,0x5f,0x33,0x32,0x32,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a, + 0x00, ]; /* #include @@ -273,6 +703,13 @@ vs_op_source_metal_macos := u8.[ using namespace metal; + struct op_fs_params + { + int blur_size; + int op; + float separation; + }; + struct main0_out { float4 frag_color [[color(0)]]; @@ -283,20 +720,75 @@ vs_op_source_metal_macos := u8.[ float2 texcoord [[user(locn0)]]; }; - fragment main0_out main0(main0_in in [[stage_in]], texture2d optex [[texture(0)]], sampler opsmp [[sampler(0)]]) + fragment main0_out main0(main0_in in [[stage_in]], constant op_fs_params& _10 [[buffer(0)]], texture2d optex [[texture(0)]], sampler opsmp [[sampler(0)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; - float2 _28 = float2(1.0) / float2(int2(optex.get_width(), optex.get_height())); - float result = 0.0; - for (int x = -2; x < 2; x++) + if (_10.op == 2) { - for (int y = -2; y < 2; y++) + float2 _40 = float2(1.0) / float2(int2(optex.get_width(), optex.get_height())); + float3 result = float3(0.0); + int _50 = -_10.blur_size; + for (int x = _50; x < _10.blur_size; x++) { - result += optex.sample(opsmp, (in.texcoord + (float2(float(x), float(y)) * _28))).x; + for (int y = _50; y < _10.blur_size; y++) + { + result += optex.sample(opsmp, (in.texcoord + (float2(float(x), float(y)) * _40))).xyz; + } + } + out.frag_color = float4(result / float3(float(((_10.blur_size * 2) * _10.blur_size) * 2)), 1.0); + } + else + { + if (_10.op == 1) + { + float2 _132 = float2(int2(optex.get_width(), optex.get_height())); + out.frag_color = optex.sample(opsmp, (gl_FragCoord.xy / _132)); + if (_10.blur_size <= 0) + { + return out; + } + float mx = 0.0; + float4 cmx = out.frag_color; + int _158 = -_10.blur_size; + for (int i = _158; i <= _10.blur_size; i++) + { + for (int j = _158; j <= _10.blur_size; j++) + { + if (!(distance(float2(float(i), float(j)), float2(0.0)) <= float(_10.blur_size))) + { + continue; + } + float4 _214 = optex.sample(opsmp, ((gl_FragCoord.xy + (float2(float(i), float(j)) * _10.separation)) / _132)); + float _221 = dot(_214.xyz, float3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)); + if (_221 > mx) + { + mx = _221; + cmx = _214; + } + } + } + float4 _233 = out.frag_color; + float3 _242 = mix(_233.xyz, cmx.xyz, float3(smoothstep(0.100000001490116119384765625, 0.300000011920928955078125, mx))); + out.frag_color.x = _242.x; + out.frag_color.y = _242.y; + out.frag_color.z = _242.z; + } + else + { + float2 _263 = float2(1.0) / float2(int2(optex.get_width(), optex.get_height())); + float result_1 = 0.0; + int _268 = -_10.blur_size; + for (int x_1 = _268; x_1 < _10.blur_size; x_1++) + { + for (int y_1 = _268; y_1 < _10.blur_size; y_1++) + { + result_1 += optex.sample(opsmp, (in.texcoord + (float2(float(x_1), float(y_1)) * _263))).x; + } + } + float _322 = result_1 / float(((_10.blur_size * 2) * _10.blur_size) * 2); + out.frag_color = float4(_322, _322, _322, 1.0); } } - float _84 = result * 0.0625; - out.frag_color = float4(_84, _84, _84, 1.0); return out; } @@ -306,49 +798,203 @@ fs_op_source_metal_macos := u8.[ 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,0x32,0x20, - 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28, - 0x6c,0x6f,0x63,0x6e,0x30,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,0x2c, - 0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74, - 0x3e,0x20,0x6f,0x70,0x74,0x65,0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72, - 0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20, - 0x6f,0x70,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,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,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x32,0x38,0x20,0x3d, - 0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x31,0x2e,0x30,0x29,0x20,0x2f,0x20,0x66, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6f, + 0x70,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x69,0x6e,0x74,0x20,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x65,0x70,0x61,0x72,0x61,0x74,0x69,0x6f, + 0x6e,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,0x32,0x20,0x74, + 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c, + 0x6f,0x63,0x6e,0x30,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,0x2c,0x20, + 0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x6f,0x70,0x5f,0x66,0x73,0x5f,0x70, + 0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,0x30,0x20,0x5b,0x5b,0x62,0x75,0x66, + 0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72, + 0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x6f,0x70,0x74,0x65,0x78, + 0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c, + 0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x6f,0x70,0x73,0x6d,0x70,0x20,0x5b, + 0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x43,0x6f,0x6f, + 0x72,0x64,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,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,0x69, + 0x66,0x20,0x28,0x5f,0x31,0x30,0x2e,0x6f,0x70,0x20,0x3d,0x3d,0x20,0x32,0x29,0x0a, + 0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x32,0x20,0x5f,0x34,0x30,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x32,0x28,0x31,0x2e,0x30,0x29,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28, + 0x69,0x6e,0x74,0x32,0x28,0x6f,0x70,0x74,0x65,0x78,0x2e,0x67,0x65,0x74,0x5f,0x77, + 0x69,0x64,0x74,0x68,0x28,0x29,0x2c,0x20,0x6f,0x70,0x74,0x65,0x78,0x2e,0x67,0x65, + 0x74,0x5f,0x68,0x65,0x69,0x67,0x68,0x74,0x28,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x72,0x65,0x73, + 0x75,0x6c,0x74,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30, + 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f, + 0x35,0x30,0x20,0x3d,0x20,0x2d,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73, + 0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72, + 0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x5f,0x35,0x30,0x3b,0x20,0x78, + 0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65, + 0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72, + 0x20,0x28,0x69,0x6e,0x74,0x20,0x79,0x20,0x3d,0x20,0x5f,0x35,0x30,0x3b,0x20,0x79, + 0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65, + 0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2b,0x3d,0x20,0x6f, + 0x70,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x6f,0x70,0x73,0x6d, + 0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20, + 0x2b,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28, + 0x78,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x79,0x29,0x29,0x20,0x2a,0x20, + 0x5f,0x34,0x30,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,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,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2f,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x33,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x28,0x28,0x5f,0x31,0x30,0x2e, + 0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x20,0x2a,0x20,0x32,0x29,0x20,0x2a, + 0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x29,0x20, + 0x2a,0x20,0x32,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20, + 0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31, + 0x30,0x2e,0x6f,0x70,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x31,0x33,0x32,0x20,0x3d,0x20,0x66, 0x6c,0x6f,0x61,0x74,0x32,0x28,0x69,0x6e,0x74,0x32,0x28,0x6f,0x70,0x74,0x65,0x78, 0x2e,0x67,0x65,0x74,0x5f,0x77,0x69,0x64,0x74,0x68,0x28,0x29,0x2c,0x20,0x6f,0x70, 0x74,0x65,0x78,0x2e,0x67,0x65,0x74,0x5f,0x68,0x65,0x69,0x67,0x68,0x74,0x28,0x29, - 0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x65, - 0x73,0x75,0x6c,0x74,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, - 0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d,0x32,0x3b, - 0x20,0x78,0x20,0x3c,0x20,0x32,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20, - 0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28, - 0x69,0x6e,0x74,0x20,0x79,0x20,0x3d,0x20,0x2d,0x32,0x3b,0x20,0x79,0x20,0x3c,0x20, - 0x32,0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, - 0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x72,0x65, - 0x73,0x75,0x6c,0x74,0x20,0x2b,0x3d,0x20,0x6f,0x70,0x74,0x65,0x78,0x2e,0x73,0x61, - 0x6d,0x70,0x6c,0x65,0x28,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e, - 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x28,0x66,0x6c,0x6f,0x61, - 0x74,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x78,0x29,0x2c,0x20,0x66,0x6c,0x6f, - 0x61,0x74,0x28,0x79,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x38,0x29,0x29,0x29,0x2e, - 0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20, - 0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x38,0x34, - 0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2a,0x20,0x30,0x2e,0x30,0x36, - 0x32,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,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,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, + 0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d, + 0x20,0x6f,0x70,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x6f,0x70, + 0x73,0x6d,0x70,0x2c,0x20,0x28,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x43,0x6f,0x6f, + 0x72,0x64,0x2e,0x78,0x79,0x20,0x2f,0x20,0x5f,0x31,0x33,0x32,0x29,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28, + 0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x20,0x3c,0x3d, + 0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x6d,0x78, + 0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6d,0x78,0x20,0x3d, + 0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x6e,0x74, + 0x20,0x5f,0x31,0x35,0x38,0x20,0x3d,0x20,0x2d,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75, + 0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x20,0x3d, + 0x20,0x5f,0x31,0x35,0x38,0x3b,0x20,0x69,0x20,0x3c,0x3d,0x20,0x5f,0x31,0x30,0x2e, + 0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f, + 0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x6a,0x20,0x3d,0x20,0x5f,0x31,0x35,0x38,0x3b, + 0x20,0x6a,0x20,0x3c,0x3d,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73, + 0x69,0x7a,0x65,0x3b,0x20,0x6a,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x69,0x66,0x20,0x28,0x21,0x28,0x64,0x69,0x73,0x74,0x61,0x6e,0x63,0x65,0x28,0x66, + 0x6c,0x6f,0x61,0x74,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x29,0x2c,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x28,0x6a,0x29,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x32,0x28,0x30,0x2e,0x30,0x29,0x29,0x20,0x3c,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x28,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x29,0x29, + 0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x63,0x6f,0x6e,0x74,0x69,0x6e,0x75,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x31,0x34,0x20, + 0x3d,0x20,0x6f,0x70,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x6f, + 0x70,0x73,0x6d,0x70,0x2c,0x20,0x28,0x28,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x43, + 0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x20,0x2b,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74, + 0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x28,0x6a,0x29,0x29,0x20,0x2a,0x20,0x5f,0x31,0x30,0x2e,0x73,0x65,0x70,0x61, + 0x72,0x61,0x74,0x69,0x6f,0x6e,0x29,0x29,0x20,0x2f,0x20,0x5f,0x31,0x33,0x32,0x29, + 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x32, + 0x31,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x31,0x34,0x2e,0x78,0x79,0x7a, + 0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,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,0x2c,0x20,0x30,0x2e,0x35,0x38,0x39,0x39,0x39,0x39,0x39,0x37,0x33, + 0x37,0x37,0x33,0x39,0x35,0x36,0x32,0x39,0x38,0x38,0x32,0x38,0x31,0x32,0x35,0x2c, + 0x20,0x30,0x2e,0x31,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x34,0x30,0x33,0x39, + 0x35,0x33,0x35,0x35,0x32,0x32,0x34,0x36,0x30,0x39,0x33,0x37,0x35,0x29,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x32,0x32,0x31,0x20,0x3e,0x20, + 0x6d,0x78,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x6d,0x78,0x20,0x3d,0x20,0x5f,0x32,0x32,0x31,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x63,0x6d,0x78,0x20,0x3d,0x20,0x5f,0x32,0x31,0x34,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x33,0x33,0x20,0x3d, + 0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x33,0x20,0x5f,0x32,0x34,0x32,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f, + 0x32,0x33,0x33,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x63,0x6d,0x78,0x2e,0x78,0x79,0x7a, + 0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73, + 0x74,0x65,0x70,0x28,0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34, + 0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32, + 0x35,0x2c,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,0x2c,0x20,0x6d, + 0x78,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, + 0x2e,0x78,0x20,0x3d,0x20,0x5f,0x32,0x34,0x32,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61, + 0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x79,0x20,0x3d,0x20,0x5f,0x32,0x34,0x32, + 0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x7a, + 0x20,0x3d,0x20,0x5f,0x32,0x34,0x32,0x2e,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x6c,0x73, + 0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f, + 0x32,0x36,0x33,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x31,0x2e,0x30, + 0x29,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x69,0x6e,0x74,0x32,0x28, + 0x6f,0x70,0x74,0x65,0x78,0x2e,0x67,0x65,0x74,0x5f,0x77,0x69,0x64,0x74,0x68,0x28, + 0x29,0x2c,0x20,0x6f,0x70,0x74,0x65,0x78,0x2e,0x67,0x65,0x74,0x5f,0x68,0x65,0x69, + 0x67,0x68,0x74,0x28,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x65,0x73,0x75,0x6c, + 0x74,0x5f,0x31,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x32,0x36,0x38,0x20, + 0x3d,0x20,0x2d,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f, + 0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x5f,0x31,0x20,0x3d,0x20,0x5f,0x32,0x36, + 0x38,0x3b,0x20,0x78,0x5f,0x31,0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75, + 0x72,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x78,0x5f,0x31,0x2b,0x2b,0x29,0x0a,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72, + 0x20,0x28,0x69,0x6e,0x74,0x20,0x79,0x5f,0x31,0x20,0x3d,0x20,0x5f,0x32,0x36,0x38, + 0x3b,0x20,0x79,0x5f,0x31,0x20,0x3c,0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72, + 0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x79,0x5f,0x31,0x2b,0x2b,0x29,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x5f,0x31,0x20,0x2b,0x3d,0x20, + 0x6f,0x70,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x6f,0x70,0x73, + 0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64, + 0x20,0x2b,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74, + 0x28,0x78,0x5f,0x31,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x79,0x5f,0x31, + 0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x33,0x29,0x29,0x29,0x2e,0x78,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x20,0x5f,0x33,0x32,0x32,0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x5f, + 0x31,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x28,0x28,0x5f,0x31,0x30,0x2e, + 0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x20,0x2a,0x20,0x32,0x29,0x20,0x2a, + 0x20,0x5f,0x31,0x30,0x2e,0x62,0x6c,0x75,0x72,0x5f,0x73,0x69,0x7a,0x65,0x29,0x20, + 0x2a,0x20,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,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,0x33,0x32,0x32,0x2c,0x20, + 0x5f,0x33,0x32,0x32,0x2c,0x20,0x5f,0x33,0x32,0x32,0x2c,0x20,0x31,0x2e,0x30,0x29, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20, + 0x7d,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74, + 0x3b,0x0a,0x7d,0x0a,0x0a,0x00, ]; op_shader_desc :: (backend: sg_backend) -> sg_shader_desc { desc: sg_shader_desc; @@ -363,6 +1009,18 @@ op_shader_desc :: (backend: sg_backend) -> sg_shader_desc { desc.attrs[0].glsl_name = "position"; desc.attrs[1].base_type = .FLOAT; desc.attrs[1].glsl_name = "uv"; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 16; + desc.uniform_blocks[1].glsl_uniforms[0].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_10.blur_size"; + desc.uniform_blocks[1].glsl_uniforms[1].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_10.op"; + desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_10.separation"; desc.images[0].stage = .FRAGMENT; desc.images[0].multisampled = false; desc.images[0].image_type = ._2D; @@ -382,6 +1040,18 @@ op_shader_desc :: (backend: sg_backend) -> sg_shader_desc { desc.attrs[0].glsl_name = "position"; desc.attrs[1].base_type = .FLOAT; desc.attrs[1].glsl_name = "uv"; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 16; + desc.uniform_blocks[1].glsl_uniforms[0].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_10.blur_size"; + desc.uniform_blocks[1].glsl_uniforms[1].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_10.op"; + desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_10.separation"; desc.images[0].stage = .FRAGMENT; desc.images[0].multisampled = false; desc.images[0].image_type = ._2D; @@ -399,6 +1069,10 @@ op_shader_desc :: (backend: sg_backend) -> sg_shader_desc { desc.fragment_func.entry = "main0"; desc.attrs[0].base_type = .FLOAT; desc.attrs[1].base_type = .FLOAT; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 16; + desc.uniform_blocks[1].msl_buffer_n = 0; desc.images[0].stage = .FRAGMENT; desc.images[0].multisampled = false; desc.images[0].image_type = ._2D; diff --git a/src/shaders/shader_mix.glsl b/src/shaders/shader_mix.glsl new file mode 100644 index 0000000..e679907 --- /dev/null +++ b/src/shaders/shader_mix.glsl @@ -0,0 +1,46 @@ +@vs vs_mix +in vec2 position; +in vec2 uv; + +out vec2 texcoord; + +void main() { + gl_Position = vec4(position, 0.5, 1.0); + texcoord = uv; +} +@end + +@fs fs_mix +in vec2 texcoord; +out vec4 frag_color; + +layout(binding=1) uniform mix_fs_params { + int op; + /* + List of mixs: + 0. blur for ssao + 1. dilate. + 2. normal blur + */ +}; + +layout(binding = 0) uniform texture2D mixtex_a; +layout(binding = 1) uniform texture2D mixtex_b; +layout(binding = 2) uniform texture2D mixtex_c; +layout(binding = 0) uniform sampler mixsmp; + +void main() { + if(op == 0) { + vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(mixtex_a, mixsmp), 0)); + vec3 result = vec3(0.0); + result += texture(sampler2D(mixtex_a, mixsmp), texcoord).xyz; + result += texture(sampler2D(mixtex_b, mixsmp), texcoord).xyz; + result = texture(sampler2D(mixtex_c, mixsmp), texcoord).xyz; + frag_color = vec4(result, 1.0); + } else { + frag_color = vec4(1.0); + } +} +@end + +@program mix vs_mix fs_mix diff --git a/src/shaders/shader_op.glsl b/src/shaders/shader_op.glsl index 5368138..5f894de 100644 --- a/src/shaders/shader_op.glsl +++ b/src/shaders/shader_op.glsl @@ -14,21 +14,67 @@ void main() { in vec2 texcoord; out vec4 frag_color; +layout(binding=1) uniform op_fs_params { + int blur_size; + int op; + float separation; + /* + List of ops: + 0. blur for ssao + 1. dilate. + 2. normal blur + */ +}; + layout(binding = 0) uniform texture2D optex; layout(binding = 0) uniform sampler opsmp; void main() { - vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(optex, opsmp), 0)); - float result = 0.0; - for (int x = -2; x < 2; ++x) - { - for (int y = -2; y < 2; ++y) + if(op == 2) { + vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(optex, opsmp), 0)); + vec3 result = vec3(0.0); + for (int x = -blur_size; x < blur_size; ++x) { - vec2 offset = vec2(float(x), float(y)) * texelSize; - result += texture(sampler2D(optex, opsmp), texcoord + offset).r; + for (int y = -blur_size; y < blur_size; ++y) + { + vec2 offset = vec2(float(x), float(y)) * texelSize; + result += texture(sampler2D(optex, opsmp), texcoord + offset).xyz; + } } + frag_color = vec4((result / (blur_size*2 * blur_size*2)), 1.0); + } + else if(op == 1) { + float minThreshold = 0.1; + float maxThreshold = 0.3; + vec2 texSize = textureSize(sampler2D(optex, opsmp), 0).xy; + vec2 fragCoord = gl_FragCoord.xy; + frag_color = texture(sampler2D(optex, opsmp), fragCoord / texSize); + if (blur_size <= 0) { return; } + float mx = 0.0; + vec4 cmx = frag_color; + for (int i = -blur_size; i <= blur_size; ++i) { + for (int j = -blur_size; j <= blur_size; ++j) { + if (!(distance(vec2(i, j), vec2(0, 0)) <= blur_size)) { continue; } + vec4 c = texture(sampler2D(optex,opsmp),(gl_FragCoord.xy + (vec2(i, j) * separation)) / texSize); + float mxt = dot(c.rgb, vec3(0.3, 0.59, 0.11)); + if (mxt > mx) { + mx = mxt; + cmx = c; + } + } + } + frag_color.rgb = mix(frag_color.rgb, cmx.rgb, smoothstep(minThreshold, maxThreshold, mx)); + } else { + vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(optex, opsmp), 0)); + float result = 0.0; + for (int x = -blur_size; x < blur_size; ++x) { + for (int y = -blur_size; y < blur_size; ++y) { + vec2 offset = vec2(float(x), float(y)) * texelSize; + result += texture(sampler2D(optex, opsmp), texcoord + offset).r; + } + } + frag_color = vec4(vec3(result / (blur_size*2 * blur_size*2)), 1.0); } - frag_color = vec4(vec3(result / (4.0 * 4.0)), 1.0); } @end diff --git a/trueno/trueno.xcodeproj/project.xcworkspace/xcuserdata/tuomas.katajisto.xcuserdatad/UserInterfaceState.xcuserstate b/trueno/trueno.xcodeproj/project.xcworkspace/xcuserdata/tuomas.katajisto.xcuserdatad/UserInterfaceState.xcuserstate index a1fe4b1..cea6e65 100644 Binary files a/trueno/trueno.xcodeproj/project.xcworkspace/xcuserdata/tuomas.katajisto.xcuserdatad/UserInterfaceState.xcuserstate and b/trueno/trueno.xcodeproj/project.xcworkspace/xcuserdata/tuomas.katajisto.xcuserdatad/UserInterfaceState.xcuserstate differ