perf improvements

This commit is contained in:
Tuomas Katajisto 2026-04-05 11:25:23 +03:00
parent 57414915b7
commit e6382913fa
16 changed files with 5373 additions and 5355 deletions

View File

@ -258,7 +258,7 @@ frame :: () {
add_frame_profiling_point("After UI draw"); add_frame_profiling_point("After UI draw");
#if !FLAG_RELEASE_BUILD { #if !FLAG_RELEASE_BUILD {
prepare_text(debug_font, tprint("frametime: % ms", latest_frametime * 1000)); prepare_text(debug_font, tprint("frametime: % ms", delta_time * 1000));
draw_prepared_text(debug_font, 10, 10, .{0.0, 1.0, 0.0, 1.0}); draw_prepared_text(debug_font, 10, 10, .{0.0, 1.0, 0.0, 1.0});
draw_editor(); draw_editor();
} }
@ -276,7 +276,6 @@ frame :: () {
#if OS != .WASM { profiler_update(); } #if OS != .WASM { profiler_update(); }
reset_temporary_storage(); reset_temporary_storage();
frame_end_time := get_time(); frame_end_time := get_time();
latest_frametime = frame_end_time - frame_start_time;
input_per_frame_event_and_flag_update(); input_per_frame_event_and_flag_update();
} }

View File

@ -1,13 +1,13 @@
#import,dir "../../modules/sokol-jai/sokol/app"(DEBUG = !FLAG_RELEASE_BUILD); #import,dir "../../modules/sokol-jai/sokol/app"(DEBUG = FLAG_RELEASE_BUILD);
#import,dir "../../modules/sokol-jai/sokol/gfx"(DEBUG = !FLAG_RELEASE_BUILD); #import,dir "../../modules/sokol-jai/sokol/gfx"(DEBUG = FLAG_RELEASE_BUILD);
#import,dir "../../modules/sokol-jai/sokol/gl"(DEBUG = !FLAG_RELEASE_BUILD); #import,dir "../../modules/sokol-jai/sokol/gl"(DEBUG = FLAG_RELEASE_BUILD);
#import,dir "../../modules/sokol-jai/sokol/glue"(DEBUG = !FLAG_RELEASE_BUILD); #import,dir "../../modules/sokol-jai/sokol/glue"(DEBUG = FLAG_RELEASE_BUILD);
#import,dir "../../modules/sokol-jai/sokol/shape"(DEBUG = !FLAG_RELEASE_BUILD); #import,dir "../../modules/sokol-jai/sokol/shape"(DEBUG = FLAG_RELEASE_BUILD);
#import,dir "../../modules/sokol-jai/sokol/fontstash"; #import,dir "../../modules/sokol-jai/sokol/fontstash";
#import,dir "../../modules/sokol-jai/sokol/log"(DEBUG = !FLAG_RELEASE_BUILD); #import,dir "../../modules/sokol-jai/sokol/log"(DEBUG = FLAG_RELEASE_BUILD);
#import,dir "../../modules/sokol-jai/sokol/time"(DEBUG = !FLAG_RELEASE_BUILD); #import,dir "../../modules/sokol-jai/sokol/time"(DEBUG = FLAG_RELEASE_BUILD);
#import,dir "../../modules/sokol-jai/sokol/fetch"(DEBUG = !FLAG_RELEASE_BUILD); #import,dir "../../modules/sokol-jai/sokol/fetch"(DEBUG = FLAG_RELEASE_BUILD);
#import,dir "../../modules/sokol-jai/sokol/audio"(DEBUG = !FLAG_RELEASE_BUILD); #import,dir "../../modules/sokol-jai/sokol/audio"(DEBUG = FLAG_RELEASE_BUILD);
#load "../main.jai"; #load "../main.jai";

View File

@ -239,7 +239,7 @@ backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *
fs_params.screen_w = w; fs_params.screen_w = w;
fs_params.screen_h = h; fs_params.screen_h = h;
lc := *current_lighting_config; lc := *current_lighting_config;
fs_params.rdm_enabled = lc.rdm_enabled; fs_params.rdm_enabled = ifx in_reflection_pass then 0 else lc.rdm_enabled;
fs_params.ambient_intensity = lc.ambient_intensity; fs_params.ambient_intensity = lc.ambient_intensity;
fs_params.emissive_scale = lc.emissive_scale; fs_params.emissive_scale = lc.emissive_scale;
fs_params.rdm_diff_scale = lc.rdm_diff_scale; fs_params.rdm_diff_scale = lc.rdm_diff_scale;
@ -464,7 +464,7 @@ backend_process_command_buckets :: () {
end_frame_profiling_group("G-Buffer pass"); end_frame_profiling_group("G-Buffer pass");
start_frame_profiling_group("SSAO pass"); start_frame_profiling_group("SSAO pass");
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_postprocess_attach_a })); sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_ssao_attachments }));
sg_apply_pipeline(gPipelines.ssao.pipeline); sg_apply_pipeline(gPipelines.ssao.pipeline);
gPipelines.ssao.bind.images[0] = g_gbuf_position; gPipelines.ssao.bind.images[0] = g_gbuf_position;
gPipelines.ssao.bind.images[1] = g_gbuf_normal; gPipelines.ssao.bind.images[1] = g_gbuf_normal;
@ -480,19 +480,6 @@ backend_process_command_buckets :: () {
sg_end_pass(); sg_end_pass();
end_frame_profiling_group("SSAO pass"); end_frame_profiling_group("SSAO pass");
start_frame_profiling_group("SSAO blur 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 = current_post_process.ssao_size;
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();
end_frame_profiling_group("SSAO blur pass");
// 5. Main pass // 5. Main pass
start_frame_profiling_group("Main pass"); start_frame_profiling_group("Main pass");
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_rendertex_attachments})); sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_rendertex_attachments}));
@ -506,8 +493,8 @@ backend_process_command_buckets :: () {
start_frame_profiling_group("Postprocess pass"); start_frame_profiling_group("Postprocess pass");
if !bypass_postprocess { if !bypass_postprocess {
bloom_process(); bloom_process();
dof_process();
} }
end_frame_profiling_group("Postprocess pass"); end_frame_profiling_group("Postprocess pass");
start_frame_profiling_group("Final pass"); start_frame_profiling_group("Final pass");
@ -516,8 +503,9 @@ backend_process_command_buckets :: () {
// 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] = ifx bypass_postprocess then g_rendertex else g_postprocess_a; gPipelines.postprocess.bind.images[0] = g_rendertex;
gPipelines.postprocess.bind.images[1] = LUT_list[g_current_lut_texture_index].image; gPipelines.postprocess.bind.images[1] = LUT_list[g_current_lut_texture_index].image;
gPipelines.postprocess.bind.images[2] = g_bloom_tex;
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;
if bypass_postprocess { if bypass_postprocess {

View File

@ -1,27 +1,11 @@
bloom_process :: () { bloom_process :: () {
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_postprocess_attach_a })); sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_bloom_attach }));
sg_apply_pipeline(gPipelines.op.pipeline); sg_apply_pipeline(gPipelines.bloom.pipeline);
op_uniform_bloom : Op_Fs_Params; params : Bloom_Params;
op_uniform_bloom.blur_size = current_post_process.bloom_size; params.bloom_treshold = current_post_process.bloom_treshold;
op_uniform_bloom.separation = current_post_process.bloom_separation; gPipelines.bloom.bind.images[IMG_bloom_src] = g_rendertex;
op_uniform_bloom.bloom_treshold = current_post_process.bloom_treshold; sg_apply_uniforms(UB_bloom_params, *(sg_range.{ ptr = *params, size = size_of(type_of(params)) }));
op_uniform_bloom.bloom_amount = current_post_process.bloom_amount; sg_apply_bindings(*gPipelines.bloom.bind);
op_uniform_bloom.op=3;
gPipelines.op.bind.images[0] = g_rendertex;
sg_apply_uniforms(UB_op_fs_params, *(sg_range.{ ptr = *op_uniform_bloom, size = size_of(type_of(op_uniform_bloom)) }));
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.mix.pipeline);
mix_uniform : Mix_Fs_Params;
mix_uniform.op = 1;
gPipelines.mix.bind.images[0] = g_postprocess_a;
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_draw(0, 6, 1);
sg_end_pass(); sg_end_pass();
} }

View File

@ -172,7 +172,7 @@ get_low_res :: (width: s32, height: s32, max_dimension: s32 = 720) -> (s32, s32)
get_render_size :: () -> (s32, s32) { get_render_size :: () -> (s32, s32) {
w,h := get_window_size(); w,h := get_window_size();
// w, h = get_low_res(w,h, 480); // w, h = get_low_res(w,h, 480);
return w, h; return w * 2, h * 2;
} }
flip_y_if_plat :: inline (v: Vector2) -> Vector2 { flip_y_if_plat :: inline (v: Vector2) -> Vector2 {

View File

@ -37,6 +37,9 @@ g_postprocess_b_depth : sg_image;
g_postprocess_attach_a : sg_attachments; g_postprocess_attach_a : sg_attachments;
g_postprocess_attach_b : sg_attachments; g_postprocess_attach_b : sg_attachments;
g_bloom_tex : sg_image;
g_bloom_attach : sg_attachments;
gPipelines : struct { gPipelines : struct {
// G-Buffer generation for SSAO and other effects // G-Buffer generation for SSAO and other effects
@ -69,6 +72,8 @@ gPipelines : struct {
mix : Pipeline_Binding; mix : Pipeline_Binding;
bloom : Pipeline_Binding;
billboard : Pipeline_Binding; billboard : Pipeline_Binding;
gbuffer_billboard : Pipeline_Binding; gbuffer_billboard : Pipeline_Binding;
@ -154,6 +159,7 @@ create_pipelines :: () {
create_ssao_pipeline(); create_ssao_pipeline();
create_op_pipeline(); create_op_pipeline();
create_mix_pipeline(); create_mix_pipeline();
create_bloom_pipeline();
create_billboard_pipeline(); create_billboard_pipeline();
create_gbuffer_billboard_pipeline(); create_gbuffer_billboard_pipeline();
create_particle_pipeline(); create_particle_pipeline();
@ -531,14 +537,14 @@ create_plane_pipeline_reflection_images :: () {
w, h := get_render_size(); w, h := get_render_size();
img_desc := sg_image_desc.{ img_desc := sg_image_desc.{
width = w/2, width = w/3,
height = h/2, height = h/3,
pixel_format = .RGBA32F, pixel_format = .RGBA8,
render_target = true, render_target = true,
}; };
depth_desc := sg_image_desc.{ depth_desc := sg_image_desc.{
width = w/2, width = w/3,
height = h/2, height = h/3,
pixel_format = .DEPTH, pixel_format = .DEPTH,
render_target = true, render_target = true,
}; };
@ -740,6 +746,13 @@ create_postprocess_pipeline :: () {
mag_filter = .LINEAR, mag_filter = .LINEAR,
})); }));
gPipelines.postprocess.bind.samplers[2] = sg_make_sampler(*(sg_sampler_desc.{
wrap_u = .CLAMP_TO_EDGE,
wrap_v = .CLAMP_TO_EDGE,
min_filter = .LINEAR,
mag_filter = .LINEAR,
}));
} }
// Takes in a texture, manipulates it and outputs it. // Takes in a texture, manipulates it and outputs it.
@ -979,6 +992,52 @@ create_mix_pipeline :: () {
} }
create_bloom_pipeline :: () {
platconf := get_plat_conf();
pipeline: sg_pipeline_desc;
shader_desc := bloom_shader_desc(sg_query_backend());
pipeline.shader = sg_make_shader(*shader_desc);
pipeline.layout.attrs[ATTR_bloom_position] = .{ format = .FLOAT2 };
pipeline.layout.attrs[ATTR_bloom_uv] = .{ format = .FLOAT2 };
pipeline.index_type = .UINT16;
pipeline.color_count = 1;
pipeline.colors[0] = .{ pixel_format = .RGBA32F };
gPipelines.bloom.pipeline = sg_make_pipeline(*pipeline);
quad_vertices : [16]float = .[
-1.0, 1.0, 0.0, flip_if_plat(1.0),
-1.0, -1.0, 0.0, flip_if_plat(0.0),
1.0, -1.0, 1.0, flip_if_plat(0.0),
1.0, 1.0, 1.0, flip_if_plat(1.0),
];
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.bloom.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
gPipelines.bloom.bind.index_buffer = sg_make_buffer(*ibuffer);
gPipelines.bloom.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);
@ -991,7 +1050,7 @@ create_ssao_images :: () {
width = w/2, width = w/2,
height = h/2, height = h/2,
render_target = true, render_target = true,
pixel_format = .RGBA32F pixel_format = .RGBA8
}; };
img_desc.sample_count = 1; img_desc.sample_count = 1;
g_ssaobuf = sg_make_image(*img_desc); g_ssaobuf = sg_make_image(*img_desc);
@ -1029,6 +1088,21 @@ create_ssao_images :: () {
g_postprocess_attach_a = sg_make_attachments(*attachmentsDescA); g_postprocess_attach_a = sg_make_attachments(*attachmentsDescA);
sg_destroy_attachments(g_postprocess_attach_b); sg_destroy_attachments(g_postprocess_attach_b);
g_postprocess_attach_b = sg_make_attachments(*attachmentsDescB); g_postprocess_attach_b = sg_make_attachments(*attachmentsDescB);
if g_bloom_tex.id != INVALID_ID then sg_destroy_image(g_bloom_tex);
bloom_img_desc := sg_image_desc.{
width = w/8,
height = h/8,
pixel_format = .RGBA32F,
render_target = true,
sample_count = 1,
};
g_bloom_tex = sg_make_image(*bloom_img_desc);
bloom_attach_desc := sg_attachments_desc.{
colors[0].image = g_bloom_tex,
};
sg_destroy_attachments(g_bloom_attach);
g_bloom_attach = sg_make_attachments(*bloom_attach_desc);
} }
create_ssao_pipeline :: () { create_ssao_pipeline :: () {

View File

@ -14,8 +14,6 @@ Post_Process :: struct {
dof_min : float = 1.0; @Slider,0,10,1; dof_min : float = 1.0; @Slider,0,10,1;
dof_max : float = 3.0; @Slider,0,50,1; dof_max : float = 3.0; @Slider,0,50,1;
dof_point : float = 5.0; @Slider,0,30,1; dof_point : float = 5.0; @Slider,0,30,1;
bloom_size : s32 = 5; @Slider,0,10,1;
bloom_separation : float = 3.0; @Slider,0,10,1;
bloom_treshold : float = 0.4; @Slider,0,1,0.1; bloom_treshold : float = 0.4; @Slider,0,1,0.1;
bloom_amount : float = 0.0; @Slider,0,5,0.1; bloom_amount : float = 0.0; @Slider,0,5,0.1;

View File

@ -183,6 +183,7 @@ tasks_to_commands :: () {
memcpy(drawCmd.uv_rects.data, particleTask.uv_rects.data, particleTask.count * size_of(Vector4)); memcpy(drawCmd.uv_rects.data, particleTask.uv_rects.data, particleTask.count * size_of(Vector4));
memcpy(drawCmd.colors.data, particleTask.colors.data, particleTask.count * size_of(Vector4)); memcpy(drawCmd.colors.data, particleTask.colors.data, particleTask.count * size_of(Vector4));
array_add(*render_command_buckets.main, drawCmd); array_add(*render_command_buckets.main, drawCmd);
array_add(*render_command_buckets.reflection, drawCmd);
case .SET_CAMERA; case .SET_CAMERA;
task := (cast(*Rendering_Task_Set_Camera)it); task := (cast(*Rendering_Task_Set_Camera)it);
command := New(Render_Command_Set_Camera,, temp); command := New(Render_Command_Set_Camera,, temp);

View File

@ -0,0 +1,423 @@
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc -i shader_bloom.glsl -o ./jai/shader_bloom.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
Overview:
=========
Shader program: 'bloom':
Get shader desc: bloom_shader_desc(sg_query_backend())
Vertex Shader: vs_bloom
Fragment Shader: fs_bloom
Attributes:
ATTR_bloom_position => 0
ATTR_bloom_uv => 1
Bindings:
Uniform block 'bloom_params':
Jai struct: Bloom_Params
Bind slot: UB_bloom_params => 0
Image 'bloom_src':
Image type: ._2D
Sample type: .FLOAT
Multisampled: false
Bind slot: IMG_bloom_src => 0
Sampler 'bloom_src_smp':
Type: .FILTERING
Bind slot: SMP_bloom_src_smp => 0
*/
ATTR_bloom_position :: 0;
ATTR_bloom_uv :: 1;
UB_bloom_params :: 0;
IMG_bloom_src :: 0;
SMP_bloom_src_smp :: 0;
Bloom_Params :: struct {
bloom_treshold: float;
_: [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_bloom_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 vec4 bloom_params[1];
layout(binding = 16) uniform sampler2D bloom_src_bloom_src_smp;
layout(location = 0) in vec2 texcoord;
layout(location = 0) out vec4 frag_color;
void main()
{
vec4 _24 = texture(bloom_src_bloom_src_smp, texcoord);
vec4 color = _24;
if (max(_24.x, max(_24.y, _24.z)) < bloom_params[0].x)
{
color = vec4(0.0, 0.0, 0.0, 1.0);
}
frag_color = vec4(color.xyz, 1.0);
}
*/
fs_bloom_source_glsl430 := u8.[
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x6c,0x6f,0x6f,0x6d,
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,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,
0x6f,0x6d,0x5f,0x73,0x72,0x63,0x5f,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,0x34,0x20,0x5f,0x32,0x34,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,
0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,
0x6f,0x6f,0x6d,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,
0x63,0x6f,0x6f,0x72,0x64,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x32,0x34,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x69,0x66,0x20,0x28,0x6d,0x61,0x78,0x28,0x5f,0x32,0x34,0x2e,0x78,0x2c,
0x20,0x6d,0x61,0x78,0x28,0x5f,0x32,0x34,0x2e,0x79,0x2c,0x20,0x5f,0x32,0x34,0x2e,
0x7a,0x29,0x29,0x20,0x3c,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,
0x65,0x63,0x34,0x28,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,
0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,
0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,
0x76,0x65,0x63,0x34,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x2c,0x20,
0x31,0x2e,0x30,0x29,0x3b,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_bloom_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 highp vec4 bloom_params[1];
uniform highp sampler2D bloom_src_bloom_src_smp;
in highp vec2 texcoord;
layout(location = 0) out highp vec4 frag_color;
void main()
{
highp vec4 _24 = texture(bloom_src_bloom_src_smp, texcoord);
highp vec4 color = _24;
if (max(_24.x, max(_24.y, _24.z)) < bloom_params[0].x)
{
color = vec4(0.0, 0.0, 0.0, 1.0);
}
frag_color = vec4(color.xyz, 1.0);
}
*/
fs_bloom_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,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
0x34,0x20,0x62,0x6c,0x6f,0x6f,0x6d,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,0x62,0x6c,0x6f,0x6f,0x6d,
0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x73,0x72,0x63,0x5f,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,
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x32,0x34,0x20,0x3d,
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x73,
0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,
0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,
0x72,0x20,0x3d,0x20,0x5f,0x32,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,
0x28,0x6d,0x61,0x78,0x28,0x5f,0x32,0x34,0x2e,0x78,0x2c,0x20,0x6d,0x61,0x78,0x28,
0x5f,0x32,0x34,0x2e,0x79,0x2c,0x20,0x5f,0x32,0x34,0x2e,0x7a,0x29,0x29,0x20,0x3c,
0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,
0x2e,0x78,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x30,
0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,
0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,
0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,
0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,
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_bloom_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 bloom_params
{
float bloom_treshold;
};
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 bloom_params& _42 [[buffer(0)]], texture2d<float> bloom_src [[texture(0)]], sampler bloom_src_smp [[sampler(0)]])
{
main0_out out = {};
float4 _24 = bloom_src.sample(bloom_src_smp, in.texcoord);
float4 color = _24;
if (fast::max(_24.x, fast::max(_24.y, _24.z)) < _42.bloom_treshold)
{
color = float4(0.0, 0.0, 0.0, 1.0);
}
out.frag_color = float4(color.xyz, 1.0);
return out;
}
*/
fs_bloom_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,0x62,
0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x74,0x72,
0x65,0x73,0x68,0x6f,0x6c,0x64,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,0x62,0x6c,
0x6f,0x6f,0x6d,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x34,0x32,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,
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x73,0x72,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,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x73,0x72,0x63,0x5f,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,0x34,0x20,0x5f,0x32,0x34,0x20,0x3d,0x20,0x62,0x6c,0x6f,0x6f,0x6d,
0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,
0x6d,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,0x65,
0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x32,0x34,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,
0x61,0x78,0x28,0x5f,0x32,0x34,0x2e,0x78,0x2c,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,
0x6d,0x61,0x78,0x28,0x5f,0x32,0x34,0x2e,0x79,0x2c,0x20,0x5f,0x32,0x34,0x2e,0x7a,
0x29,0x29,0x20,0x3c,0x20,0x5f,0x34,0x32,0x2e,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x74,
0x72,0x65,0x73,0x68,0x6f,0x6c,0x64,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x28,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,
0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,
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,0x63,0x6f,0x6c,
0x6f,0x72,0x2e,0x78,0x79,0x7a,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,
];
bloom_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc: sg_shader_desc;
desc.label = "bloom_shader";
if backend == {
case .GLCORE;
desc.vertex_func.source = xx *vs_bloom_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = xx *fs_bloom_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[0].stage = .FRAGMENT;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 16;
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 1;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "bloom_params";
desc.images[0].stage = .FRAGMENT;
desc.images[0].multisampled = false;
desc.images[0].image_type = ._2D;
desc.images[0].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 = 0;
desc.image_sampler_pairs[0].sampler_slot = 0;
desc.image_sampler_pairs[0].glsl_name = "bloom_src_bloom_src_smp";
case .GLES3;
desc.vertex_func.source = xx *vs_bloom_source_glsl300es;
desc.vertex_func.entry = "main";
desc.fragment_func.source = xx *fs_bloom_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[0].stage = .FRAGMENT;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 16;
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 1;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "bloom_params";
desc.images[0].stage = .FRAGMENT;
desc.images[0].multisampled = false;
desc.images[0].image_type = ._2D;
desc.images[0].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 = 0;
desc.image_sampler_pairs[0].sampler_slot = 0;
desc.image_sampler_pairs[0].glsl_name = "bloom_src_bloom_src_smp";
case .METAL_MACOS;
desc.vertex_func.source = xx *vs_bloom_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = xx *fs_bloom_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[1].base_type = .FLOAT;
desc.uniform_blocks[0].stage = .FRAGMENT;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 16;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.images[0].stage = .FRAGMENT;
desc.images[0].multisampled = false;
desc.images[0].image_type = ._2D;
desc.images[0].sample_type = .FLOAT;
desc.images[0].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 = 0;
desc.image_sampler_pairs[0].sampler_slot = 0;
}
return desc;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
@vs vs_bloom
in vec2 position;
in vec2 uv;
out vec2 texcoord;
void main() {
gl_Position = vec4(position, 0.5, 1.0);
texcoord = uv;
}
@end
@fs fs_bloom
in vec2 texcoord;
out vec4 frag_color;
layout(binding=0) uniform bloom_params {
float bloom_treshold;
};
layout(binding = 0) uniform texture2D bloom_src;
layout(binding = 0) uniform sampler bloom_src_smp;
void main() {
vec4 color = texture(sampler2D(bloom_src, bloom_src_smp), texcoord);
float value = max(color.r, max(color.g, color.b));
if(value < bloom_treshold) { color = vec4(0.0, 0.0, 0.0, 1.0); }
frag_color = vec4(color.rgb, 1.0);
}
@end
@program bloom vs_bloom fs_bloom

View File

@ -18,6 +18,8 @@ layout(binding = 0) uniform texture2D pptex;
layout(binding = 0) uniform sampler ppsmp; layout(binding = 0) uniform sampler ppsmp;
layout(binding = 1) uniform texture2D lut; layout(binding = 1) uniform texture2D lut;
layout(binding = 1) uniform sampler lut_linear; layout(binding = 1) uniform sampler lut_linear;
layout(binding = 2) uniform texture2D bloom_tex;
layout(binding = 2) uniform sampler bloom_smp;
layout(binding=0) uniform post_process_config { layout(binding=0) uniform post_process_config {
float exposure; float exposure;
@ -34,6 +36,7 @@ layout(binding=0) uniform post_process_config {
float barrel_distortion_intensity; float barrel_distortion_intensity;
int lut_mode; int lut_mode;
float dither_intensity; float dither_intensity;
float bloom_amount;
}; };
vec3 aces(vec3 x) { vec3 aces(vec3 x) {
@ -85,8 +88,8 @@ void main() {
float b = texture(sampler2D(pptex, ppsmp), distorted_texcoord - vec2(chromatic_aberration_intensity, 0.0)).b; float b = texture(sampler2D(pptex, ppsmp), distorted_texcoord - vec2(chromatic_aberration_intensity, 0.0)).b;
vec3 sampled_color_hdr = vec4(r, g, b, 1.0).rgb; vec3 sampled_color_hdr = vec4(r, g, b, 1.0).rgb;
vec3 bloom_color = texture(sampler2D(bloom_tex, bloom_smp), distorted_texcoord).rgb;
vec3 color_hdr = sampled_color_hdr * exposure; vec3 color_hdr = (sampled_color_hdr + bloom_color * bloom_amount) * exposure;
vec3 color_ldr_linear; vec3 color_ldr_linear;
if(tonemap > 0.5) { if(tonemap > 0.5) {

View File

@ -62,18 +62,6 @@ float noise(vec3 x)
mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z); mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z);
} }
const mat3 m = mat3(0.0, 1.60, 1.20, -1.6, 0.72, -0.96, -1.2, -0.96, 1.28);
float fbm(vec3 p)
{
float f = 0.0;
f += noise(p) / 2.0; p = m * p * 1.1;
f += noise(p) / 4.0; p = m * p * 1.2;
f += noise(p) / 6.0; p = m * p * 1.3;
f += noise(p) / 12.0; p = m * p * 1.4;
f += noise(p) / 24.0;
return f;
}
vec3 sky(vec3 skypos, vec3 sunpos) { vec3 sky(vec3 skypos, vec3 sunpos) {
vec3 sunCol = sunDisk.xyz; vec3 sunCol = sunDisk.xyz;
@ -111,13 +99,6 @@ vec3 sky(vec3 skypos, vec3 sunpos) {
final += mix(horizonHalo.xyz, vec3(0.0,0.0,0.0), clamp(abs(npos.y) * 20.0, 0.0, 1.0)) * 0.8; final += mix(horizonHalo.xyz, vec3(0.0,0.0,0.0), clamp(abs(npos.y) * 20.0, 0.0, 1.0)) * 0.8;
final = vec3(final); final = vec3(final);
// Cirrus Clouds
if(hasClouds == 1) {
float density = smoothstep(1.0 - cirrus, 1.0, fbm(npos.xyz / npos.y * 2.0 + time * 0.05)) * 0.3;
final.rgb = mix(final.rgb, vec3(1.0, 1.0, 1.0), max(0.0, npos.y) * density * 2.0);
}
return final; return final;
} }

View File

@ -341,7 +341,7 @@ vec3 sample_rdm(vec3 N, vec3 V, vec3 rdm_center, vec3 diff, int roughness, ivec3
} }
float maxDist = 20.0; float maxDist = 20.0;
int steps = 40; int steps = 10;
for (int i = 0; i < steps; i++) { for (int i = 0; i < steps; i++) {
float t = maxDist * float(i + 1) / float(steps); float t = maxDist * float(i + 1) / float(steps);
vec3 samplePos = diff + t * reflected; vec3 samplePos = diff + t * reflected;
@ -453,7 +453,9 @@ void main() {
vec3 pos_after_adjust = ipos - orig_normal * 0.02; vec3 pos_after_adjust = ipos - orig_normal * 0.02;
int count = 0; int count = 0;
vec4 trixel_material; vec4 trixel_material;
while (count < 5) { int maxCount = 5;
if(is_reflection == 1) maxCount = 1;
while (count < maxCount) {
int xpos = int(clamp(pos_after_adjust.z, 0.0001, 0.99999) * 16.0); int xpos = int(clamp(pos_after_adjust.z, 0.0001, 0.99999) * 16.0);
int ypos = int(clamp(pos_after_adjust.y, 0.0001, 0.99999) * 16.0); int ypos = int(clamp(pos_after_adjust.y, 0.0001, 0.99999) * 16.0);
int zpos = int(clamp(pos_after_adjust.x, 0.0001, 0.99999) * 16.0); int zpos = int(clamp(pos_after_adjust.x, 0.0001, 0.99999) * 16.0);
@ -489,6 +491,16 @@ void main() {
N = vec3(0.0, 0.0, sign(fnormal.z)); N = vec3(0.0, 0.0, sign(fnormal.z));
} }
if (is_reflection == 1) {
vec3 V = normalize(cam - vpos.xyz);
vec3 L = normalize(sunPosition);
float NdotL = max(dot(N, L), 0.0);
vec3 light = albedo * NdotL * sunLightColor * sunIntensity;
light += 0.1 * albedo;
frag_color = vec4(light, 1.0);
return;
}
vec3 V = normalize(cam - vpos.xyz); vec3 V = normalize(cam - vpos.xyz);
vec3 L = normalize(sunPosition); vec3 L = normalize(sunPosition);
vec3 H = normalize(V + L); vec3 H = normalize(V + L);
@ -519,7 +531,7 @@ void main() {
vec3 hemispherePos = trileCenter + N * 0.49; vec3 hemispherePos = trileCenter + N * 0.49;
ivec3 local = ivec3(mod(floor(trileCenter), 32.0)); ivec3 local = ivec3(mod(floor(trileCenter), 32.0));
vec4 atlas_rect_check = rdm_get_atlas_rect(local, roughnessInt); vec4 atlas_rect_check = rdm_get_atlas_rect(local, roughnessInt);
float ssao_sample = texture(sampler2D(ssaotex, trilesmp), vec2(gl_FragCoord.x / float(screen_w), gl_FragCoord.y / float(screen_h)), 0).r; float ssao_sample = texture(sampler2D(ssaotex, rdmsmp), vec2(gl_FragCoord.x / float(screen_w), gl_FragCoord.y / float(screen_h)), 0).r;
// Emissive — self-lit, not shadowed. // Emissive — self-lit, not shadowed.
vec3 emissive = albedo * emittance * emissive_scale; vec3 emissive = albedo * emittance * emissive_scale;