work on depth of field

This commit is contained in:
Tuomas Katajisto 2025-10-23 20:22:27 +03:00
parent 8489b84660
commit e68b69cf5b
11 changed files with 1432 additions and 143 deletions

View File

@ -4,5 +4,8 @@
"saturation": 1.202777, "saturation": 1.202777,
"gamma": 1.019477, "gamma": 1.019477,
"tonemap": 1, "tonemap": 1,
"ssao": 2.603531 "ssao": 1.276337,
"dilate_separation": 31.199354,
"dilate_size": 7,
"dof_blur_size": 3
} }

View File

@ -8,7 +8,7 @@ current_trile_offset_index : s32 = 0;
current_world_config : *World_Config = null; current_world_config : *World_Config = null;
in_shadowmap_pass : bool = false; in_shadowmap_pass : bool = false;
in_reflection_pass : bool = false; in_reflection_pass : bool = false;
in_gbuffer_pass : bool = false; in_gbuffer_pass : bool = false;
shadow_mvp : Matrix4; shadow_mvp : Matrix4;
backend_handle_command :: (cmd: *Render_Command) { backend_handle_command :: (cmd: *Render_Command) {
@ -123,9 +123,8 @@ backend_draw_trile_positions_gbuffer :: (trile : string, amount : s32, worldConf
bindings : sg_bindings; bindings : sg_bindings;
bindings.vertex_buffers[0] = trilegfx.vertex_buffer; bindings.vertex_buffers[0] = trilegfx.vertex_buffer;
bindings.vertex_buffers[1] = trilegfx.normal_buffer; bindings.vertex_buffers[1] = trilegfx.normal_buffer;
bindings.vertex_buffers[2] = trilegfx.centre_buffer; bindings.vertex_buffers[2] = gPipelines.trile.bind.vertex_buffers[3];
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3]; bindings.vertex_buffer_offsets[2] = offset;
bindings.vertex_buffer_offsets[3] = offset;
bindings.samplers[0] = gPipelines.trile.bind.samplers[0]; bindings.samplers[0] = gPipelines.trile.bind.samplers[0];
bindings.images[0] = trilegfx.trixel_colors; bindings.images[0] = trilegfx.trixel_colors;
@ -271,9 +270,15 @@ backend_process_command_buckets :: () {
sg_draw(0, 6, 1); sg_draw(0, 6, 1);
sg_end_pass(); sg_end_pass();
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_ssao_attachments })); sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_ssao_attachments }));
sg_apply_pipeline(gPipelines.op.pipeline); 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; 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_apply_bindings(*gPipelines.op.bind);
sg_draw(0, 6, 1); sg_draw(0, 6, 1);
sg_end_pass(); sg_end_pass();
@ -286,13 +291,14 @@ backend_process_command_buckets :: () {
sg_end_pass(); sg_end_pass();
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple. current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
dof_process();
// Begin drawing to swapchain // Begin drawing to swapchain
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, swapchain = cast,force(sg_swapchain) sglue_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: // Draw the render texture and do post processing:
sg_apply_pipeline(gPipelines.postprocess.pipeline); 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); sg_apply_bindings(*gPipelines.postprocess.bind);
post_process_config_uniform : Post_Process_Config; post_process_config_uniform : Post_Process_Config;
fill_uniform_with_engine_data(*post_process_config_uniform , *current_post_process); fill_uniform_with_engine_data(*post_process_config_uniform , *current_post_process);

View File

@ -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();
}

View File

@ -61,6 +61,8 @@ gPipelines : struct {
postprocess : Pipeline_Binding; postprocess : Pipeline_Binding;
op : Pipeline_Binding; op : Pipeline_Binding;
mix : Pipeline_Binding;
// Renders the SSAO texture using things from the gbuffer pass. // Renders the SSAO texture using things from the gbuffer pass.
ssao: Pipeline_Binding; ssao: Pipeline_Binding;
@ -136,6 +138,7 @@ create_pipelines :: () {
create_postprocess_pipeline(); create_postprocess_pipeline();
create_ssao_pipeline(); create_ssao_pipeline();
create_op_pipeline(); create_op_pipeline();
create_mix_pipeline();
create_shadowmap_image(); create_shadowmap_image();
create_final_image(); create_final_image();
@ -313,10 +316,9 @@ create_gbuffer_pipeline :: () {
instance_buffer := sg_buffer_desc.{ usage = .STREAM, size = 16 * 4096 * 4 * 4}; 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_gbuffer_position] = .{ format = .FLOAT3, buffer_index = 0 };
pipeline.layout.attrs[ATTR_trile_normal] = .{ format = .FLOAT3, buffer_index = 1 }; pipeline.layout.attrs[ATTR_gbuffer_normal] = .{ format = .FLOAT3, buffer_index = 1 };
pipeline.layout.attrs[ATTR_trile_centre] = .{ format = .FLOAT3, buffer_index = 2 }; pipeline.layout.attrs[ATTR_gbuffer_instance] = .{ format = .FLOAT4, buffer_index = 2 };
pipeline.layout.attrs[ATTR_trile_instance] = .{ format = .FLOAT4, buffer_index = 3 };
pipeline.depth = .{ pipeline.depth = .{
write_enabled = true, write_enabled = true,
compare = .LESS_EQUAL, compare = .LESS_EQUAL,
@ -689,6 +691,7 @@ create_postprocess_pipeline :: () {
} }
// Takes in a texture, manipulates it and outputs it.
create_op_pipeline :: () { create_op_pipeline :: () {
platconf := get_plat_conf(); platconf := get_plat_conf();
pipeline: sg_pipeline_desc; 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 :: () { create_ssao_images :: () {
if g_ssaobuf.id != INVALID_ID then sg_destroy_image(g_ssaobuf); 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); if g_ssaobuf_depth.id != INVALID_ID then sg_destroy_image(g_ssaobuf_depth);

View File

@ -1,10 +1,13 @@
Post_Process :: struct { Post_Process :: struct {
exposure : float = 0.0; @Slider,-1,1,0.1; exposure : float = 0.0; @Slider,-1,1,0.1;
contrast : float = 1.0; @Slider,0.1,4.0,0.1; contrast : float = 1.0; @Slider,0.1,4.0,0.1;
saturation : float = 1.0; @Slider,0.0,2.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; gamma : float = 1.0; @Slider,0.3,3.0,0.1;
tonemap : float = 1.0; @Slider,0,1,1; tonemap : float = 1.0; @Slider,0,1,1;
ssao : float = 1.0; @Slider,0,5,0.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; current_post_process : Post_Process;

View File

@ -17,6 +17,7 @@
#load "helpers.jai"; #load "helpers.jai";
#load "pipelines.jai"; #load "pipelines.jai";
#load "post_processing.jai"; #load "post_processing.jai";
#load "backend_sokol_helpers.jai";
#scope_file #scope_file

View File

@ -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 <metal_stdlib>
#include <simd/simd.h>
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 <metal_stdlib>
#include <simd/simd.h>
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<float> 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;
}

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -14,21 +14,67 @@ void main() {
in vec2 texcoord; in vec2 texcoord;
out vec4 frag_color; 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 texture2D optex;
layout(binding = 0) uniform sampler opsmp; layout(binding = 0) uniform sampler opsmp;
void main() { void main() {
vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(optex, opsmp), 0)); if(op == 2) {
float result = 0.0; vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(optex, opsmp), 0));
for (int x = -2; x < 2; ++x) vec3 result = vec3(0.0);
{ for (int x = -blur_size; x < blur_size; ++x)
for (int y = -2; y < 2; ++y)
{ {
vec2 offset = vec2(float(x), float(y)) * texelSize; for (int y = -blur_size; y < blur_size; ++y)
result += texture(sampler2D(optex, opsmp), texcoord + offset).r; {
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 @end