rendering improvements
This commit is contained in:
parent
5e30f3f2ab
commit
dcad1dbe7f
33
first.jai
33
first.jai
@ -125,11 +125,11 @@ wasm_copy_assets :: () {
|
||||
}
|
||||
}
|
||||
|
||||
metaprogramming_loop :: (trueno_opts: Trueno_Build_Options, w: *Workspace) {
|
||||
metaprogramming_loop :: (trueno_opts: Trueno_Build_Options, w: *Workspace, iprof_plugin: *Iprof.My_Plugin = null) {
|
||||
while true {
|
||||
message := compiler_wait_for_message();
|
||||
// @ToDo: add iprof to this refactored metaprogram
|
||||
// if trueno_opts.iprof_enabled then iprof_plugin.message(iprof_plugin, message)
|
||||
// Fixed iprof integration
|
||||
if iprof_plugin then iprof_plugin.message(iprof_plugin, message);
|
||||
custom_message_handler(message, w);
|
||||
if message.kind == .COMPLETE then break;
|
||||
}
|
||||
@ -152,26 +152,27 @@ native_build :: (opts: Build_Options, trueno_opts: Trueno_Build_Options) {
|
||||
|
||||
set_build_options(opts, w);
|
||||
iprof_plugin: *Iprof.My_Plugin;
|
||||
intercept_flags: Intercept_Flags;
|
||||
|
||||
// profile := iprof;
|
||||
if trueno_opts.iprof_enabled {
|
||||
iprof_plugin = cast(*Iprof.My_Plugin) Iprof.get_plugin();
|
||||
iprof_plugin.workspace = w;
|
||||
// Instrumenting all modules creates >65536 unique (parent,zone) hash entries,
|
||||
// which trips Iprof's MAX_HASH_SIZE assert. Limit to our own files.
|
||||
iprof_plugin.instrument_modules = false;
|
||||
iprof_plugin.before_intercept(iprof_plugin, *intercept_flags);
|
||||
}
|
||||
|
||||
// if profile {
|
||||
// iprof_plugin = cast(*Iprof.My_Plugin) Iprof.get_plugin();
|
||||
// iprof_plugin.workspace = w;
|
||||
|
||||
// // Set options
|
||||
// iprof_plugin.instrument_modules = true;
|
||||
|
||||
// iprof_plugin.before_intercept(iprof_plugin, null);
|
||||
// }
|
||||
|
||||
compiler_begin_intercept(w);
|
||||
compiler_begin_intercept(w, intercept_flags);
|
||||
if trueno_opts.iprof_enabled {
|
||||
iprof_plugin.add_source(iprof_plugin);
|
||||
}
|
||||
add_trueno_opts_to_compiler_strings(trueno_opts, w);
|
||||
add_asset_buffer_sizes_to_compiler_strings(trueno_opts, w);
|
||||
add_build_file("src/platform_specific/main_native.jai", w);
|
||||
add_shaders_to_workspace(w);
|
||||
|
||||
metaprogramming_loop(trueno_opts, *w);
|
||||
metaprogramming_loop(trueno_opts, *w, iprof_plugin);
|
||||
|
||||
if trueno_opts.iprof_enabled {
|
||||
iprof_plugin.finish(iprof_plugin);
|
||||
|
||||
@ -57,6 +57,10 @@ sh_loader_handle_completed :: (req: *Fetch_Request, data: []u8) {
|
||||
return;
|
||||
}
|
||||
n := sh_header.probe_n;
|
||||
if n != SH_PROBE_N {
|
||||
log_error("SH: probe_n mismatch for chunk % (file=%, expected=%) — re-bake required", req.chunk_key, n, SH_PROBE_N);
|
||||
return;
|
||||
}
|
||||
total_values := cast(s64) n * n * n * 12;
|
||||
bytes_per_val := ifx sh_header.version >= 2 then size_of(u16) else size_of(float);
|
||||
if data.count < header_size + total_values * bytes_per_val {
|
||||
|
||||
@ -7,10 +7,13 @@ audio_thread_context : #Context;
|
||||
audio_init_thread_context :: () {
|
||||
audio_thread_context = default_context;
|
||||
audio_thread_context.temporary_storage = *audio_thread_temp_storage;
|
||||
audio_thread_temp_storage.data = audio_thread_temp_storage_data.data;
|
||||
audio_thread_temp_storage.size = audio_thread_temp_storage_data.count;
|
||||
audio_thread_temp_storage.original_data = audio_thread_temp_storage_data.data;
|
||||
audio_thread_temp_storage.original_size = audio_thread_temp_storage_data.count;
|
||||
audio_thread_temp_storage.data = audio_thread_temp_storage_data.data;
|
||||
audio_thread_temp_storage.size = audio_thread_temp_storage_data.count;
|
||||
// Iprof's zone stack/hash are global. The audio callback runs on a separate
|
||||
// thread, so any instrumented call from inside it races with the main thread
|
||||
// and corrupts those globals. Mark this context as "inside profiler runtime"
|
||||
// so Automatic_Zone_Guarded skips the begin/end on this thread.
|
||||
audio_thread_context.already_inside_profiler_runtime = true;
|
||||
audio_thread_context_ready = true;
|
||||
}
|
||||
|
||||
|
||||
@ -23,12 +23,16 @@ Profiler_Mode :: enum {
|
||||
profiler_mode : Profiler_Mode = .CLOSED;
|
||||
|
||||
draw_text :: (x: float, y: float, text: string, color: Vector4) {
|
||||
_, h := get_window_size();
|
||||
half_height := cast(float) iprof_font.character_height * 0.5;
|
||||
prepare_text(*iprof_font, text);
|
||||
draw_prepared_text(*iprof_font, xx x, xx y, color);
|
||||
draw_prepared_text(*iprof_font, xx x, xx (cast(float) h - y - half_height), color);
|
||||
}
|
||||
|
||||
draw_line :: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2, color: Vector4) {
|
||||
immediate_quad(p0, p1, p2, p3, color);
|
||||
_, h := get_window_size();
|
||||
hf := cast(float) h;
|
||||
immediate_quad(.{p0.x, hf - p0.y}, .{p1.x, hf - p1.y}, .{p2.x, hf - p2.y}, .{p3.x, hf - p3.y}, color);
|
||||
}
|
||||
|
||||
text_width :: (text: string) -> float {
|
||||
@ -43,7 +47,9 @@ text_width :: (text: string) -> float {
|
||||
}
|
||||
|
||||
draw_rectangle_prof :: (x0: float, y0: float, x1: float, y1: float, color: Vector4) {
|
||||
r := GR.Rect.{x0,y0,x1-x0,y1-y0};
|
||||
_, h := get_window_size();
|
||||
hf := cast(float) h;
|
||||
r := GR.Rect.{x0, hf - y0, x1 - x0, (hf - y1) - (hf - y0)};
|
||||
draw_rectangle(r, color);
|
||||
}
|
||||
|
||||
@ -85,11 +91,17 @@ init_profiler :: () {
|
||||
|
||||
draw_profiler :: () {
|
||||
if profiler_mode == .CLOSED then return;
|
||||
|
||||
// Prevent recursive profiler calls during drawing
|
||||
old_value := context.already_inside_profiler_runtime;
|
||||
context.already_inside_profiler_runtime = true;
|
||||
defer context.already_inside_profiler_runtime = old_value;
|
||||
|
||||
w,h := get_window_size();
|
||||
draw_rectangle(.{xx(w-700), 0, 700, xx(h) }, .{0,0,0,1});
|
||||
__Iprof.draw(xx (w - 700), 20,699,xx h, *iprof_conf);
|
||||
__Iprof.draw(xx (w - 700), 20, 699, xx h, *iprof_conf);
|
||||
if profiler_mode == .FULL {
|
||||
__Iprof.draw_graph(0,xx h,xx(w-700),200, *iprof_conf);
|
||||
__Iprof.draw_graph(0, 100, xx(w-700), 100, *iprof_conf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,6 +139,7 @@ tick_profiler :: () {
|
||||
__Iprof.graph_select_sample();
|
||||
}
|
||||
|
||||
__Iprof.set_cursor_screen_coordinates(xx input_mouse_x, xx input_mouse_y);
|
||||
_, h := get_window_size();
|
||||
__Iprof.set_cursor_screen_coordinates(xx input_mouse_x, xx (cast(float) h - input_mouse_y));
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,16 +465,21 @@ add_trile :: (name: string, x: s32, y: s32, z: s32, orientation: u8 = 0) {
|
||||
inst := Trile_Instance.{x = lx, y = ly, z = lz, orientation = orientation};
|
||||
|
||||
// Find existing group for this trile type, or create one.
|
||||
added := false;
|
||||
for *group: chunk.groups {
|
||||
if group.trile_name == name {
|
||||
array_add(*group.instances, inst);
|
||||
return;
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
group: Chunk_Trile_Group;
|
||||
group.trile_name = sprint("%", name);
|
||||
array_add(*group.instances, inst);
|
||||
array_add(*chunk.groups, group);
|
||||
if !added {
|
||||
group: Chunk_Trile_Group;
|
||||
group.trile_name = sprint("%", name);
|
||||
array_add(*group.instances, inst);
|
||||
array_add(*chunk.groups, group);
|
||||
}
|
||||
invalidate_buried_around(*curworld.world, x, y, z);
|
||||
} @Command
|
||||
|
||||
remove_trile :: (x: s32, y: s32, z: s32) {
|
||||
@ -486,14 +491,21 @@ remove_trile :: (x: s32, y: s32, z: s32) {
|
||||
|
||||
lx, ly, lz := world_to_local(x, y, z);
|
||||
|
||||
removed := false;
|
||||
for *group: chunk.groups {
|
||||
for inst, idx: group.instances {
|
||||
if inst.x == lx && inst.y == ly && inst.z == lz {
|
||||
array_unordered_remove_by_index(*group.instances, idx);
|
||||
return;
|
||||
if group.is_buried.count > idx {
|
||||
array_unordered_remove_by_index(*group.is_buried, idx);
|
||||
}
|
||||
removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if removed break;
|
||||
}
|
||||
if removed invalidate_buried_around(*curworld.world, x, y, z);
|
||||
} @Command
|
||||
|
||||
|
||||
|
||||
@ -17,11 +17,11 @@ rdm_global_manifest_filename :: (world_name: string) -> string {
|
||||
return sprint("%/worlds/%/rdm_manifest.json", GAME_RESOURCES_DIR, world_name);
|
||||
}
|
||||
|
||||
// SH probe grid (2 probes per trile per axis = 64x64x64 per 32x32x32 chunk)
|
||||
// SH probe grid (1 probe per trile per axis = 32x32x32 per 32x32x32 chunk)
|
||||
|
||||
SH_FILE_MAGIC :: u32.[0x44475348][0]; // "SHGD" as little-endian u32
|
||||
SH_PROBE_N :: 64; // probes per axis (2 per trile in a 32-trile chunk)
|
||||
SH_TEX_W :: SH_PROBE_N * 3; // 192 — 3 RGBA texels per probe along X
|
||||
SH_PROBE_N :: 32; // probes per axis (1 per trile in a 32-trile chunk)
|
||||
SH_TEX_W :: SH_PROBE_N * 3; // 96 — 3 RGBA texels per probe along X
|
||||
|
||||
SH_Grid_File_Header :: struct {
|
||||
magic: u32;
|
||||
|
||||
@ -36,7 +36,7 @@ draw_subwindow_texture_debug :: (state: *GR.Subwindow_State, r: GR.Rect, data: *
|
||||
case 3; image = g_gbuf_position;
|
||||
case 4; image = g_gbuf_normal;
|
||||
case 5; image = g_ssaobuf;
|
||||
case 6; image = g_bloom_tex;
|
||||
case 6; image = g_bloom_up_1;
|
||||
case 7; image = g_dof_tex;
|
||||
case 8; image = g_rdm_atlas;
|
||||
}
|
||||
|
||||
@ -574,6 +574,11 @@ draw_meta_tab :: (theme: *GR.Overall_Theme, area: GR.Rect) {
|
||||
}
|
||||
r.y += row_h * 2;
|
||||
|
||||
r.h = row_h;
|
||||
changed := GR.base_checkbox(r, "Opaque (occludes neighbors)", editor_current_trile.is_opaque, *theme.checkbox_theme);
|
||||
if changed editor_current_trile.is_opaque = !editor_current_trile.is_opaque;
|
||||
r.y += row_h * 2;
|
||||
|
||||
r.h = row_h;
|
||||
if GR.button(r, "Delete trile", *theme.button_theme) {
|
||||
name_copy := copy_string(editor_current_trile.name,, temp);
|
||||
|
||||
@ -90,8 +90,10 @@ debug_font : *Font;
|
||||
|
||||
init :: () {
|
||||
sg_setup(*(sg_desc.{
|
||||
environment = cast,force(sg_environment) sglue_environment(),
|
||||
logger = .{ func = slog_func },
|
||||
environment = cast,force(sg_environment) sglue_environment(),
|
||||
logger = .{ func = slog_func },
|
||||
attachments_pool_size = 64,
|
||||
buffer_pool_size = 1024,
|
||||
}));
|
||||
sgl_setup(*(sgl_desc_t.{
|
||||
logger = .{ func = slog_func },
|
||||
@ -257,7 +259,6 @@ frame :: () {
|
||||
tick_ui();
|
||||
add_frame_profiling_point("After UI tick");
|
||||
|
||||
// This populates our render task queue.
|
||||
if should_tick_game then game_draw();
|
||||
add_frame_profiling_point("After game draw");
|
||||
|
||||
@ -270,7 +271,7 @@ frame :: () {
|
||||
draw_prepared_text(debug_font, 10, 10, .{0.0, 1.0, 0.0, 1.0});
|
||||
draw_editor();
|
||||
}
|
||||
|
||||
|
||||
add_particle_render_tasks();
|
||||
add_frame_profiling_point("After editor draw");
|
||||
render();
|
||||
|
||||
@ -22,8 +22,6 @@ sapp_init :: () {
|
||||
default_context.temporary_storage = *temporary_storage;
|
||||
temporary_storage.data = temporary_storage_data.data;
|
||||
temporary_storage.size = temporary_storage_data.count;
|
||||
temporary_storage.original_data = temporary_storage_data.data;
|
||||
temporary_storage.original_size = temporary_storage_data.count;
|
||||
default_allocator = default_context.allocator;
|
||||
|
||||
push_context default_context {
|
||||
|
||||
@ -57,8 +57,9 @@ Render_Command_Draw_Trile_Positions :: struct {
|
||||
chunk_key : Chunk_Key;
|
||||
amount : s32;
|
||||
conf : *World_Config;
|
||||
preview_mode : s32 = 0; // 0=normal, 1=add preview (blue), 2=delete preview (red)
|
||||
offset_index : s32 = 0; // index into trile_offsets, assigned at task-conversion time
|
||||
preview_mode : s32 = 0; // 0=normal, 1=add preview (blue), 2=delete preview (red)
|
||||
offset_index : s32 = 0; // index into trile_offsets, assigned at task-conversion time
|
||||
lod_index : s32 = 0;
|
||||
}
|
||||
|
||||
Render_Command_Add_Trile_RDM_Position :: struct {
|
||||
|
||||
@ -24,7 +24,7 @@ backend_handle_command :: (cmd: *Render_Command) {
|
||||
backend_add_trile_positions(add_command.positions);
|
||||
case .DRAW_TRILE_POSITIONS;
|
||||
draw_command := cast(*Render_Command_Draw_Trile_Positions)cmd;
|
||||
backend_draw_trile_positions(draw_command.trile, draw_command.amount, draw_command.conf, draw_command.chunk_key, draw_command.preview_mode, draw_command.offset_index);
|
||||
backend_draw_trile_positions(draw_command.trile, draw_command.amount, draw_command.conf, draw_command.chunk_key, draw_command.preview_mode, draw_command.offset_index, draw_command.lod_index);
|
||||
case .ADD_TRILE_RDM_POSITION;
|
||||
add_command := cast(*Render_Command_Add_Trile_RDM_Position)cmd;
|
||||
backend_add_trile_rdm_position(add_command.position);
|
||||
@ -141,15 +141,15 @@ backend_add_trile_positions :: (positions : []Vector4) {
|
||||
array_add(*trile_offsets, offset);
|
||||
}
|
||||
|
||||
backend_draw_trile_positions :: (trile : string, amount : s32, worldConf: *World_Config, chunk_key: Chunk_Key, preview_mode: s32 = 0, offset_index: s32 = 0) {
|
||||
backend_draw_trile_positions :: (trile : string, amount : s32, worldConf: *World_Config, chunk_key: Chunk_Key, preview_mode: s32 = 0, offset_index: s32 = 0, lod_index: s32 = 0) {
|
||||
if in_gbuffer_pass {
|
||||
backend_draw_trile_positions_gbuffer(trile, amount, worldConf, offset_index);
|
||||
backend_draw_trile_positions_gbuffer(trile, amount, worldConf, offset_index, lod_index);
|
||||
} else {
|
||||
backend_draw_trile_positions_main(trile, amount, worldConf, chunk_key, preview_mode, offset_index);
|
||||
backend_draw_trile_positions_main(trile, amount, worldConf, chunk_key, preview_mode, offset_index, lod_index);
|
||||
}
|
||||
}
|
||||
|
||||
backend_draw_trile_positions_gbuffer :: (trile : string, amount : s32, worldConf: *World_Config, offset_index: s32) {
|
||||
backend_draw_trile_positions_gbuffer :: (trile : string, amount : s32, worldConf: *World_Config, offset_index: s32, lod_index: s32 = 0) {
|
||||
if offset_index >= trile_offsets.count then return;
|
||||
mvp := create_viewproj(*camera);
|
||||
view := create_lookat(*camera);
|
||||
@ -163,10 +163,27 @@ backend_draw_trile_positions_gbuffer :: (trile : string, amount : s32, worldConf
|
||||
offset := trile_offsets[offset_index];
|
||||
|
||||
trilegfx := get_trile_gfx(trile);
|
||||
|
||||
vbuf, nbuf, cbuf : sg_buffer;
|
||||
vcount : s64;
|
||||
if lod_index == 0 {
|
||||
vbuf = trilegfx.vertex_buffer;
|
||||
nbuf = trilegfx.normal_buffer;
|
||||
cbuf = trilegfx.centre_buffer;
|
||||
vcount = trilegfx.vertex_count;
|
||||
} else {
|
||||
lod := ifx lod_index == 1 then *trilegfx.lod_4 else *trilegfx.lod_2;
|
||||
if lod.vertex_count == 0 return;
|
||||
vbuf = lod.vertex_buffer;
|
||||
nbuf = lod.normal_buffer;
|
||||
cbuf = lod.color_buffer; // unused by gbuffer shader; bound to satisfy pipeline layout
|
||||
vcount = lod.vertex_count;
|
||||
}
|
||||
|
||||
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[0] = vbuf;
|
||||
bindings.vertex_buffers[1] = nbuf;
|
||||
bindings.vertex_buffers[2] = cbuf;
|
||||
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
|
||||
bindings.vertex_buffer_offsets[3] = offset;
|
||||
bindings.samplers[0] = gPipelines.trile.bind.samplers[0];
|
||||
@ -174,10 +191,10 @@ backend_draw_trile_positions_gbuffer :: (trile : string, amount : s32, worldConf
|
||||
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_gbuffer_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params))}));
|
||||
sg_draw(0, cast(s32) trilegfx.vertex_count, amount);
|
||||
sg_draw(0, cast(s32) vcount, amount);
|
||||
}
|
||||
|
||||
backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *World_Config, chunk_key: Chunk_Key, preview_mode: s32 = 0, offset_index: s32 = 0) {
|
||||
backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *World_Config, chunk_key: Chunk_Key, preview_mode: s32 = 0, offset_index: s32 = 0, lod_index: s32 = 0) {
|
||||
start_frame_profiling_group("Draw trile positions");
|
||||
if offset_index >= trile_offsets.count {
|
||||
end_frame_profiling_group("Draw trile positions");
|
||||
@ -187,24 +204,84 @@ backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *
|
||||
trilegfx := get_trile_gfx(trile);
|
||||
offset := trile_offsets[offset_index];
|
||||
|
||||
// Pick mesh source based on LOD level. For shadow + gbuffer we keep the original pipeline
|
||||
// and just swap which buffers feed it; the shader's centre attribute is unused so we bind
|
||||
// the LOD color buffer as a placeholder to satisfy the pipeline layout.
|
||||
vbuf, nbuf, cbuf : sg_buffer;
|
||||
vcount : s64;
|
||||
if lod_index == 0 {
|
||||
vbuf = trilegfx.vertex_buffer;
|
||||
nbuf = trilegfx.normal_buffer;
|
||||
cbuf = trilegfx.centre_buffer;
|
||||
vcount = trilegfx.vertex_count;
|
||||
} else {
|
||||
lod := ifx lod_index == 1 then *trilegfx.lod_4 else *trilegfx.lod_2;
|
||||
if lod.vertex_count == 0 {
|
||||
end_frame_profiling_group("Draw trile positions");
|
||||
return;
|
||||
}
|
||||
vbuf = lod.vertex_buffer;
|
||||
nbuf = lod.normal_buffer;
|
||||
cbuf = lod.color_buffer;
|
||||
vcount = lod.vertex_count;
|
||||
}
|
||||
|
||||
if in_shadowmap_pass {
|
||||
vs_params : Trile_Shadow_Vs_Params;
|
||||
vs_params.mvp = shadow_mvp.floats;
|
||||
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[0] = vbuf;
|
||||
bindings.vertex_buffers[1] = nbuf;
|
||||
bindings.vertex_buffers[2] = cbuf;
|
||||
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
|
||||
bindings.vertex_buffer_offsets[3] = offset;
|
||||
sg_apply_pipeline(gPipelines.trile_shadow.pipeline);
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_trile_shadow_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_draw(0, cast(s32) trilegfx.vertex_count, amount);
|
||||
sg_draw(0, cast(s32) vcount, amount);
|
||||
end_frame_profiling_group("Draw trile positions");
|
||||
return;
|
||||
}
|
||||
|
||||
mvp := create_viewproj(*camera);
|
||||
|
||||
if lod_index >= 1 {
|
||||
// LOD path: dedicated shader, vertex color, no ray-march/SSAO/shadow/SH/BRDF.
|
||||
sg_apply_pipeline(gPipelines.trile_lod.pipeline);
|
||||
|
||||
lod_vs : Trile_Lod_Vs_Params;
|
||||
lod_vs.mvp = mvp.floats;
|
||||
lod_vs.camera = camera.position.component;
|
||||
|
||||
lod_fs : Trile_Lod_Fs_Params;
|
||||
lod_fs.skyBase = worldConf.skyBase.component;
|
||||
lod_fs.sunPosition = worldConf.sunPosition.component;
|
||||
lod_fs.sunLightColor = worldConf.sunLightColor.component;
|
||||
lod_fs.sunIntensity = worldConf.sunIntensity;
|
||||
lc := *current_lighting_config;
|
||||
lod_fs.ambient_color = lc.ambient_color.component;
|
||||
lod_fs.ambient_intensity = lc.ambient_intensity;
|
||||
lod_fs.planeHeight = effective_plane_height(worldConf);
|
||||
lod_fs.deepColor = worldConf.deepColor.component;
|
||||
lod_fs.is_reflection = ifx in_reflection_pass then cast(s32)1 else cast(s32)0;
|
||||
lod_fs.fog_start = FOG_START;
|
||||
lod_fs.fog_end = FOG_END;
|
||||
|
||||
bindings : sg_bindings;
|
||||
bindings.vertex_buffers[0] = vbuf;
|
||||
bindings.vertex_buffers[1] = nbuf;
|
||||
bindings.vertex_buffers[2] = cbuf;
|
||||
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
|
||||
bindings.vertex_buffer_offsets[3] = offset;
|
||||
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_trile_lod_vs_params, *(sg_range.{ ptr = *lod_vs, size = size_of(type_of(lod_vs)) }));
|
||||
sg_apply_uniforms(UB_trile_lod_fs_params, *(sg_range.{ ptr = *lod_fs, size = size_of(type_of(lod_fs)) }));
|
||||
sg_draw(0, cast(s32) vcount, amount);
|
||||
end_frame_profiling_group("Draw trile positions");
|
||||
return;
|
||||
}
|
||||
|
||||
vs_params : Trile_Vs_Params;
|
||||
vs_params.mvp = mvp.floats;
|
||||
vs_params.mvp_shadow = shadow_mvp.floats;
|
||||
@ -215,9 +292,9 @@ backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *
|
||||
world_conf.planeHeight = effective_plane_height(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[0] = vbuf;
|
||||
bindings.vertex_buffers[1] = nbuf;
|
||||
bindings.vertex_buffers[2] = cbuf;
|
||||
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
|
||||
bindings.vertex_buffer_offsets[3] = offset;
|
||||
bindings.samplers[0] = gPipelines.trile.bind.samplers[0];
|
||||
@ -247,13 +324,15 @@ backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *
|
||||
fs_params.is_preview = preview_mode;
|
||||
fs_params.indirect_tint = lc.indirect_tint.component;
|
||||
fs_params.sh_enabled = ifx (chunk != null && chunk.sh_valid && !in_reflection_pass) then cast(s32)1 else cast(s32)0;
|
||||
fs_params.fog_start = FOG_START;
|
||||
fs_params.fog_end = FOG_END;
|
||||
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_trile_fs_params, *(sg_range.{ ptr = *fs_params, size = size_of(type_of(fs_params)) }));
|
||||
sg_apply_uniforms(UB_trile_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params))}));
|
||||
sg_apply_uniforms(UB_trile_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
|
||||
add_frame_profiling_point("After drawing setup");
|
||||
sg_draw(0, cast(s32) trilegfx.vertex_count, amount);
|
||||
sg_draw(0, cast(s32) vcount, amount);
|
||||
end_frame_profiling_group("Draw trile positions");
|
||||
}
|
||||
backend_add_trile_rdm_position :: (position: Vector4) {
|
||||
@ -600,7 +679,8 @@ backend_process_command_buckets :: () {
|
||||
start_frame_profiling_group("Postprocess pass");
|
||||
if !bypass_postprocess {
|
||||
bloom_process();
|
||||
dof_process();
|
||||
dof_downsample_process();
|
||||
dof_bokeh_process();
|
||||
}
|
||||
|
||||
end_frame_profiling_group("Postprocess pass");
|
||||
@ -613,29 +693,23 @@ backend_process_command_buckets :: () {
|
||||
sg_apply_pipeline(gPipelines.postprocess.pipeline);
|
||||
gPipelines.postprocess.bind.images[0] = g_rendertex;
|
||||
gPipelines.postprocess.bind.images[1] = LUT_list[g_current_lut_texture_index].image;
|
||||
gPipelines.postprocess.bind.images[2] = g_bloom_tex;
|
||||
gPipelines.postprocess.bind.images[2] = g_bloom_up_1;
|
||||
gPipelines.postprocess.bind.images[3] = g_dof_tex;
|
||||
gPipelines.postprocess.bind.images[4] = g_gbuf_position;
|
||||
sg_apply_bindings(*gPipelines.postprocess.bind);
|
||||
post_process_config_uniform : Post_Process_Config;
|
||||
post_process_dof_config_uniform : Dof_Config;
|
||||
if bypass_postprocess {
|
||||
neutral : Post_Process;
|
||||
neutral.tonemap = current_post_process.tonemap;
|
||||
fill_uniform_with_engine_data(*post_process_config_uniform, *neutral);
|
||||
} else {
|
||||
fill_uniform_with_engine_data(*post_process_config_uniform, *current_post_process);
|
||||
w,h := get_render_size();
|
||||
|
||||
post_process_dof_config_uniform.dof_tex_width = cast(float)w/2;
|
||||
post_process_dof_config_uniform.dof_tex_height = cast(float)h/2;
|
||||
post_process_dof_config_uniform.dof_point = current_post_process.dof_point;
|
||||
post_process_dof_config_uniform.dof_min = current_post_process.dof_min;
|
||||
post_process_dof_config_uniform.dof_max = current_post_process.dof_max;
|
||||
|
||||
}
|
||||
sg_apply_uniforms(UB_post_process_config, *(sg_range.{ ptr = *post_process_config_uniform, size = size_of(type_of(post_process_config_uniform)) }));
|
||||
sg_apply_uniforms(UB_dof_config, *(sg_range.{ ptr = *post_process_dof_config_uniform, size = size_of(type_of(post_process_dof_config_uniform)) }));
|
||||
dof_config_uniform : Dof_Config;
|
||||
dof_config_uniform.dof_max = current_post_process.dof_max;
|
||||
dof_config_uniform.dof_point = current_post_process.dof_point;
|
||||
sg_apply_uniforms(UB_dof_config, *(sg_range.{ ptr = *dof_config_uniform, size = size_of(type_of(dof_config_uniform)) }));
|
||||
sg_draw(0, 6, 1);
|
||||
|
||||
sgl_defaults();
|
||||
|
||||
@ -1,66 +1,81 @@
|
||||
bloom_process :: () {
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_bloom_attach }));
|
||||
sg_apply_pipeline(gPipelines.bloom.pipeline);
|
||||
params : Bloom_Params;
|
||||
params.bloom_treshold = current_post_process.bloom_treshold;
|
||||
gPipelines.bloom.bind.images[IMG_bloom_src] = g_rendertex;
|
||||
sg_apply_uniforms(UB_bloom_params, *(sg_range.{ ptr = *params, size = size_of(type_of(params)) }));
|
||||
sg_apply_bindings(*gPipelines.bloom.bind);
|
||||
w, h := get_render_size();
|
||||
fw := cast(float)w;
|
||||
fh := cast(float)h;
|
||||
|
||||
// Prefilter: threshold + downsample full-res → down_1 (w/2)
|
||||
{
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_bloom_down_1_attach }));
|
||||
sg_apply_pipeline(gPipelines.bloom_prefilter.pipeline);
|
||||
p : Bloom_Prefilter_Params;
|
||||
p.src_texel_x = 1.0 / fw;
|
||||
p.src_texel_y = 1.0 / fh;
|
||||
p.threshold = current_post_process.bloom_treshold;
|
||||
gPipelines.bloom_prefilter.bind.images[IMG_bloom_prefilter_src] = g_rendertex;
|
||||
sg_apply_uniforms(UB_bloom_prefilter_params, *(sg_range.{ ptr = *p, size = size_of(type_of(p)) }));
|
||||
sg_apply_bindings(*gPipelines.bloom_prefilter.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
}
|
||||
|
||||
// Downsample chain
|
||||
bloom_downsample :: (src: sg_image, dst_attach: sg_attachments, src_w: float, src_h: float) {
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = dst_attach }));
|
||||
sg_apply_pipeline(gPipelines.bloom_downsample.pipeline);
|
||||
p : Bloom_Downsample_Params;
|
||||
p.src_texel_x = 1.0 / src_w;
|
||||
p.src_texel_y = 1.0 / src_h;
|
||||
gPipelines.bloom_downsample.bind.images[IMG_bloom_downsample_src] = src;
|
||||
sg_apply_uniforms(UB_bloom_downsample_params, *(sg_range.{ ptr = *p, size = size_of(type_of(p)) }));
|
||||
sg_apply_bindings(*gPipelines.bloom_downsample.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
}
|
||||
bloom_downsample(g_bloom_down_1, g_bloom_down_2_attach, fw/2, fh/2);
|
||||
bloom_downsample(g_bloom_down_2, g_bloom_down_3_attach, fw/4, fh/4);
|
||||
bloom_downsample(g_bloom_down_3, g_bloom_down_4_attach, fw/8, fh/8);
|
||||
|
||||
// Upsample chain: tent(small) + large → dest
|
||||
bloom_upsample :: (small: sg_image, large: sg_image, dst_attach: sg_attachments, small_w: float, small_h: float) {
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = dst_attach }));
|
||||
sg_apply_pipeline(gPipelines.bloom_upsample.pipeline);
|
||||
p : Bloom_Upsample_Params;
|
||||
p.src_texel_x = 1.0 / small_w;
|
||||
p.src_texel_y = 1.0 / small_h;
|
||||
gPipelines.bloom_upsample.bind.images[IMG_bloom_upsample_small] = small;
|
||||
gPipelines.bloom_upsample.bind.images[IMG_bloom_upsample_large] = large;
|
||||
sg_apply_uniforms(UB_bloom_upsample_params, *(sg_range.{ ptr = *p, size = size_of(type_of(p)) }));
|
||||
sg_apply_bindings(*gPipelines.bloom_upsample.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
}
|
||||
bloom_upsample(g_bloom_down_4, g_bloom_down_3, g_bloom_up_3_attach, fw/16, fh/16);
|
||||
bloom_upsample(g_bloom_up_3, g_bloom_down_2, g_bloom_up_2_attach, fw/8, fh/8);
|
||||
bloom_upsample(g_bloom_up_2, g_bloom_down_1, g_bloom_up_1_attach, fw/4, fh/4);
|
||||
}
|
||||
|
||||
dof_downsample_process :: () {
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_dof_downsample_attach }));
|
||||
sg_apply_pipeline(gPipelines.dof_downsample.pipeline);
|
||||
gPipelines.dof_downsample.bind.images[IMG_dof_downsample_src] = g_rendertex;
|
||||
sg_apply_bindings(*gPipelines.dof_downsample.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
}
|
||||
|
||||
dof_process :: () {
|
||||
dof_bokeh_process :: () {
|
||||
w, h := get_render_size();
|
||||
half_w := cast(float)(w / 2);
|
||||
half_h := cast(float)(h / 2);
|
||||
radius := current_post_process.dof_blur_size * 3.0;
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_dof_attach }));
|
||||
sg_apply_pipeline(gPipelines.dof.pipeline);
|
||||
params : Dof_Params;
|
||||
// params.dof_treshold = current_post_process.dof_treshold;
|
||||
gPipelines.dof.bind.images[IMG_dof_src] = g_rendertex;
|
||||
sg_apply_uniforms(UB_dof_params, *(sg_range.{ ptr = *params, size = size_of(type_of(params)) }));
|
||||
sg_apply_bindings(*gPipelines.dof.bind);
|
||||
sg_apply_pipeline(gPipelines.dof_blur.pipeline);
|
||||
params : Dof_Blur_Params;
|
||||
params.bokeh_radius_x = radius / half_w;
|
||||
params.bokeh_radius_y = radius / half_h;
|
||||
gPipelines.dof_blur.bind.images[IMG_dof_blur_src] = g_dof_downsample_tex;
|
||||
sg_apply_uniforms(UB_dof_blur_params, *(sg_range.{ ptr = *params, size = size_of(type_of(params)) }));
|
||||
sg_apply_bindings(*gPipelines.dof_blur.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
}
|
||||
|
||||
// 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_postprocess_b;
|
||||
// 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_rendertex_attachments }));
|
||||
// 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.dilate_min = current_post_process.dilate_min;
|
||||
// op_uniform_dof_blur.dilate_max = current_post_process.dilate_max;
|
||||
// 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;
|
||||
// mix_uniform.dof_min = current_post_process.dof_min;
|
||||
// mix_uniform.dof_max = current_post_process.dof_max;
|
||||
// mix_uniform.dof_point = current_post_process.dof_point;
|
||||
// gPipelines.mix.bind.images[0] = g_rendertex;
|
||||
// gPipelines.mix.bind.images[1] = g_postprocess_b;
|
||||
// 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();
|
||||
// }
|
||||
|
||||
|
||||
@ -45,6 +45,18 @@ aabb_in_frustum :: (planes: [6]Vector4, bmin: Vector3, bmax: Vector3) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
LOD_NEAR_DIST :: 40.0;
|
||||
LOD_FAR_DIST :: 80.0;
|
||||
|
||||
// 3-band LOD selection: instances closer than LOD_DISTANCES[i] use LOD level i.
|
||||
// i = 0 → full detail
|
||||
// i = 1 → 4^3 cube grid
|
||||
// i = 2 → 2^3 cube grid
|
||||
// beyond LOD_DISTANCES[2] → culled.
|
||||
LOD_DISTANCES :: float.[50.0, 100.0, 200.0];
|
||||
FOG_START :: 60.0;
|
||||
FOG_END :: 195.0;
|
||||
|
||||
create_world_rendering_tasks :: (world: *World, camera: Camera, plane_height: float = 0) {
|
||||
create_sky_rendering_task(*world.conf);
|
||||
create_set_light_rendering_task(*world.conf);
|
||||
@ -64,8 +76,8 @@ create_world_rendering_tasks :: (world: *World, camera: Camera, plane_height: fl
|
||||
|
||||
// Gather positions for camera-visible instances (all passes) and
|
||||
// shadow-only instances (chunks visible from sun but not camera).
|
||||
gathered : [..]Gathered_Positions;
|
||||
gathered.allocator = temp;
|
||||
gathered_per_lod : [3][..]Gathered_Positions;
|
||||
for i: 0..2 gathered_per_lod[i].allocator = temp;
|
||||
shad_gathered : [..]Gathered_Positions;
|
||||
shad_gathered.allocator = temp;
|
||||
rdm_extra : [..]Gathered_Positions; // RDM-flagged instances visible to camera; shadow/gbuffer/reflection use base pipeline
|
||||
@ -93,7 +105,8 @@ create_world_rendering_tasks :: (world: *World, camera: Camera, plane_height: fl
|
||||
if !in_cam && !in_reflect && !in_shad continue;
|
||||
|
||||
for group: chunk.groups {
|
||||
for inst: group.instances {
|
||||
for inst, idx: group.instances {
|
||||
if idx < group.is_buried.count && group.is_buried[idx] continue;
|
||||
wx, wy, wz := chunk_local_to_world(chunk.coord, inst.x, inst.y, inst.z);
|
||||
imin := Vector3.{cast(float)wx, cast(float)wy, cast(float)wz};
|
||||
imax := imin + .{1, 1, 1};
|
||||
@ -103,6 +116,17 @@ create_world_rendering_tasks :: (world: *World, camera: Camera, plane_height: fl
|
||||
inst_shad := in_shad && aabb_in_frustum(shadow_planes, imin, imax);
|
||||
if !inst_cam && !inst_reflect && !inst_shad continue;
|
||||
|
||||
dist := length(imin + .{0.5, 0.5, 0.5} - camera.position);
|
||||
|
||||
lod_idx : s32 = -1;
|
||||
for i: 0..2 {
|
||||
if dist < LOD_DISTANCES[i] {
|
||||
lod_idx = cast(s32) i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if lod_idx < 0 continue; // beyond cull distance
|
||||
|
||||
pos := Vector4.{cast(float)wx, cast(float)wy, cast(float)wz, cast(float)inst.orientation};
|
||||
is_rdm := is_rdm_instance_enabled(world, wx, wy, wz);
|
||||
if inst_cam || inst_reflect {
|
||||
@ -113,7 +137,7 @@ create_world_rendering_tasks :: (world: *World, camera: Camera, plane_height: fl
|
||||
array_add(*rdm_main, .{name = group.trile_name, position = pos});
|
||||
}
|
||||
} else {
|
||||
target := find_or_create(*gathered, group.trile_name, chunk.coord);
|
||||
target := find_or_create(*gathered_per_lod[lod_idx], group.trile_name, chunk.coord);
|
||||
array_add(*target.positions, pos);
|
||||
}
|
||||
} else {
|
||||
@ -124,14 +148,17 @@ create_world_rendering_tasks :: (world: *World, camera: Camera, plane_height: fl
|
||||
}
|
||||
}
|
||||
|
||||
for g: gathered {
|
||||
if g.positions.count < 1 continue;
|
||||
triletask : Rendering_Task_Trile;
|
||||
triletask.trile = g.name;
|
||||
triletask.chunk_key = g.chunk_key;
|
||||
triletask.positions = g.positions;
|
||||
triletask.worldConf = *world.conf;
|
||||
add_rendering_task(triletask);
|
||||
for lod_idx: 0..2 {
|
||||
for g: gathered_per_lod[lod_idx] {
|
||||
if g.positions.count < 1 continue;
|
||||
triletask : Rendering_Task_Trile;
|
||||
triletask.trile = g.name;
|
||||
triletask.chunk_key = g.chunk_key;
|
||||
triletask.positions = g.positions;
|
||||
triletask.worldConf = *world.conf;
|
||||
triletask.lod_index = cast(s32) lod_idx;
|
||||
add_rendering_task(triletask);
|
||||
}
|
||||
}
|
||||
for g: shad_gathered {
|
||||
if g.positions.count < 1 continue;
|
||||
|
||||
153
src/rendering/lodgen.jai
Normal file
153
src/rendering/lodgen.jai
Normal file
@ -0,0 +1,153 @@
|
||||
// LOD bake for triles. Independent of meshgen.jai's quad-mesh path.
|
||||
//
|
||||
// Approach:
|
||||
// 1. Downsample the 16^3 source trixels into a smaller N^3 grid of LOD voxels
|
||||
// (avg color across non-empty source trixels in each block, empty if all empty).
|
||||
// 2. Bake a cube-grid mesh: one cube per non-empty LOD voxel, only emit faces whose
|
||||
// neighbor in the LOD grid is empty (or out of bounds). Color is baked into the
|
||||
// vertex color buffer.
|
||||
// 3. The result feeds a separate trile_lod pipeline that uses vertex color and skips
|
||||
// texture sampling, ray-march, SSAO, shadow, SH, etc.
|
||||
|
||||
LOD_Voxel :: struct {
|
||||
color : Vector3;
|
||||
empty : bool;
|
||||
}
|
||||
|
||||
downsample_trile :: (src: *Trile, target_size: int) -> []LOD_Voxel {
|
||||
block := 16 / target_size; // source trixels per LOD voxel along one axis
|
||||
out := NewArray(target_size * target_size * target_size, LOD_Voxel,, temp);
|
||||
for lx: 0..target_size-1 {
|
||||
for ly: 0..target_size-1 {
|
||||
for lz: 0..target_size-1 {
|
||||
sum_r, sum_g, sum_b : float;
|
||||
count : int = 0;
|
||||
for dx: 0..block-1 {
|
||||
for dy: 0..block-1 {
|
||||
for dz: 0..block-1 {
|
||||
sx := lx * block + dx;
|
||||
sy := ly * block + dy;
|
||||
sz := lz * block + dz;
|
||||
if src.trixels[sx][sy][sz].empty continue;
|
||||
c := src.trixels[sx][sy][sz].material.color;
|
||||
sum_r += c.x;
|
||||
sum_g += c.y;
|
||||
sum_b += c.z;
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
idx := (lx * target_size + ly) * target_size + lz;
|
||||
if count == 0 {
|
||||
out[idx].empty = true;
|
||||
} else {
|
||||
out[idx].color = .{ sum_r / count, sum_g / count, sum_b / count };
|
||||
out[idx].empty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bake_lod_cube_mesh :: (lod: []LOD_Voxel, target_size: int) -> Trile_GFX_LOD {
|
||||
inv_n := 1.0 / cast(float)target_size;
|
||||
|
||||
verts : [..]float;
|
||||
norms : [..]float;
|
||||
colors : [..]float;
|
||||
verts.allocator = temp;
|
||||
norms.allocator = temp;
|
||||
colors.allocator = temp;
|
||||
|
||||
voxel_at :: (lod: []LOD_Voxel, n: int, x: int, y: int, z: int) -> LOD_Voxel #expand {
|
||||
idx := (x * n + y) * n + z;
|
||||
return lod[idx];
|
||||
}
|
||||
|
||||
// Each face: 4 corners (offsets in [0,1] within a unit voxel) + outward normal.
|
||||
Face :: struct {
|
||||
nx, ny, nz : float;
|
||||
ax, ay, az : float;
|
||||
bx, by, bz : float;
|
||||
cx, cy, cz : float;
|
||||
dx, dy, dz : float;
|
||||
}
|
||||
// Order: -X, +X, -Y, +Y, -Z, +Z. CCW winding when viewed from outside.
|
||||
faces :: Face.[
|
||||
.{ -1, 0, 0, 0,0,0, 0,0,1, 0,1,1, 0,1,0 },
|
||||
.{ 1, 0, 0, 1,0,0, 1,1,0, 1,1,1, 1,0,1 },
|
||||
.{ 0,-1, 0, 0,0,0, 1,0,0, 1,0,1, 0,0,1 },
|
||||
.{ 0, 1, 0, 0,1,0, 0,1,1, 1,1,1, 1,1,0 },
|
||||
.{ 0, 0,-1, 0,0,0, 0,1,0, 1,1,0, 1,0,0 },
|
||||
.{ 0, 0, 1, 1,0,1, 1,1,1, 0,1,1, 0,0,1 },
|
||||
];
|
||||
neighbor_offsets :: int.[ -1, 1, -1, 1, -1, 1 ];
|
||||
neighbor_axes :: int.[ 0, 0, 1, 1, 2, 2 ]; // 0=x, 1=y, 2=z
|
||||
|
||||
for lx: 0..target_size-1 {
|
||||
for ly: 0..target_size-1 {
|
||||
for lz: 0..target_size-1 {
|
||||
v := voxel_at(lod, target_size, lx, ly, lz);
|
||||
if v.empty continue;
|
||||
|
||||
base_x := cast(float)lx * inv_n;
|
||||
base_y := cast(float)ly * inv_n;
|
||||
base_z := cast(float)lz * inv_n;
|
||||
|
||||
for f: 0..5 {
|
||||
nx, ny, nz := lx, ly, lz;
|
||||
if neighbor_axes[f] == 0 nx += neighbor_offsets[f];
|
||||
else if neighbor_axes[f] == 1 ny += neighbor_offsets[f];
|
||||
else nz += neighbor_offsets[f];
|
||||
|
||||
visible := false;
|
||||
if nx < 0 || nx >= target_size || ny < 0 || ny >= target_size || nz < 0 || nz >= target_size {
|
||||
visible = true;
|
||||
} else {
|
||||
if voxel_at(lod, target_size, nx, ny, nz).empty visible = true;
|
||||
}
|
||||
if !visible continue;
|
||||
|
||||
face := faces[f];
|
||||
push_vert :: (px: float, py: float, pz: float) #expand {
|
||||
array_add(*verts, base_x + px * inv_n);
|
||||
array_add(*verts, base_y + py * inv_n);
|
||||
array_add(*verts, base_z + pz * inv_n);
|
||||
array_add(*norms, face.nx);
|
||||
array_add(*norms, face.ny);
|
||||
array_add(*norms, face.nz);
|
||||
array_add(*colors, v.color.x);
|
||||
array_add(*colors, v.color.y);
|
||||
array_add(*colors, v.color.z);
|
||||
}
|
||||
// tri 1: a b c
|
||||
push_vert(face.ax, face.ay, face.az);
|
||||
push_vert(face.bx, face.by, face.bz);
|
||||
push_vert(face.cx, face.cy, face.cz);
|
||||
// tri 2: a c d
|
||||
push_vert(face.ax, face.ay, face.az);
|
||||
push_vert(face.cx, face.cy, face.cz);
|
||||
push_vert(face.dx, face.dy, face.dz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out : Trile_GFX_LOD;
|
||||
out.vertex_count = verts.count / 3;
|
||||
if out.vertex_count == 0 return out;
|
||||
|
||||
out.vertex_buffer = sg_make_buffer(*(sg_buffer_desc.{ data = .{ ptr = verts.data, size = xx (verts.count * 4) } }));
|
||||
out.normal_buffer = sg_make_buffer(*(sg_buffer_desc.{ data = .{ ptr = norms.data, size = xx (norms.count * 4) } }));
|
||||
out.color_buffer = sg_make_buffer(*(sg_buffer_desc.{ data = .{ ptr = colors.data, size = xx (colors.count * 4) } }));
|
||||
return out;
|
||||
}
|
||||
|
||||
destroy_trile_gfx_lod :: (lod: *Trile_GFX_LOD) {
|
||||
if lod.vertex_count == 0 return;
|
||||
sg_destroy_buffer(lod.vertex_buffer);
|
||||
sg_destroy_buffer(lod.normal_buffer);
|
||||
sg_destroy_buffer(lod.color_buffer);
|
||||
lod.vertex_count = 0;
|
||||
}
|
||||
@ -498,6 +498,12 @@ generate_trile_gfx_matias :: (trileptr : *Trile) -> Trile_GFX {
|
||||
context.allocator = old_alloc;
|
||||
vecsCopy := array_copy(triangleVecs);
|
||||
Pool.reset(*meshgenpool);
|
||||
return .{ img, trile_vert_buffer, trile_normal_buffer, trile_centre_buffer, vecsCopy, triangleVecs.count / 3 };
|
||||
|
||||
lod4_voxels := downsample_trile(trileptr, 4);
|
||||
lod_4 := bake_lod_cube_mesh(lod4_voxels, 4);
|
||||
lod2_voxels := downsample_trile(trileptr, 2);
|
||||
lod_2 := bake_lod_cube_mesh(lod2_voxels, 2);
|
||||
|
||||
return .{ img, trile_vert_buffer, trile_normal_buffer, trile_centre_buffer, vecsCopy, triangleVecs.count / 3, lod_4, lod_2 };
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,11 +43,18 @@ g_postprocess_b_depth : sg_image;
|
||||
g_postprocess_attach_a : sg_attachments;
|
||||
g_postprocess_attach_b : sg_attachments;
|
||||
|
||||
g_bloom_tex : sg_image;
|
||||
g_bloom_attach : sg_attachments;
|
||||
g_bloom_down_1 : sg_image; g_bloom_down_1_attach : sg_attachments;
|
||||
g_bloom_down_2 : sg_image; g_bloom_down_2_attach : sg_attachments;
|
||||
g_bloom_down_3 : sg_image; g_bloom_down_3_attach : sg_attachments;
|
||||
g_bloom_down_4 : sg_image; g_bloom_down_4_attach : sg_attachments;
|
||||
g_bloom_up_3 : sg_image; g_bloom_up_3_attach : sg_attachments;
|
||||
g_bloom_up_2 : sg_image; g_bloom_up_2_attach : sg_attachments;
|
||||
g_bloom_up_1 : sg_image; g_bloom_up_1_attach : sg_attachments;
|
||||
|
||||
g_dof_tex : sg_image;
|
||||
g_dof_attach : sg_attachments;
|
||||
g_dof_tex : sg_image;
|
||||
g_dof_attach : sg_attachments;
|
||||
g_dof_downsample_tex : sg_image;
|
||||
g_dof_downsample_attach: sg_attachments;
|
||||
|
||||
|
||||
gPipelines : struct {
|
||||
@ -74,6 +81,9 @@ gPipelines : struct {
|
||||
// Depth-only shadow pass for triles (no lighting/RDM)
|
||||
trile_shadow : Pipeline_Binding;
|
||||
|
||||
// Cube-grid LOD pipeline for distant triles (vertex color, no ray-march)
|
||||
trile_lod : Pipeline_Binding;
|
||||
|
||||
// Renders the ground plane. (just water)
|
||||
plane : Pipeline_Binding;
|
||||
|
||||
@ -84,8 +94,12 @@ gPipelines : struct {
|
||||
|
||||
mix : Pipeline_Binding;
|
||||
|
||||
bloom : Pipeline_Binding;
|
||||
dof: Pipeline_Binding;
|
||||
bloom_prefilter : Pipeline_Binding;
|
||||
bloom_downsample : Pipeline_Binding;
|
||||
bloom_upsample : Pipeline_Binding;
|
||||
|
||||
dof_downsample : Pipeline_Binding;
|
||||
dof_blur : Pipeline_Binding;
|
||||
|
||||
billboard : Pipeline_Binding;
|
||||
|
||||
@ -169,14 +183,18 @@ create_pipelines :: () {
|
||||
create_trile_pipeline();
|
||||
create_trile_rdm_pipeline();
|
||||
create_trile_shadow_pipeline();
|
||||
create_trile_lod_pipeline();
|
||||
create_sky_pipeline();
|
||||
create_plane_pipeline();
|
||||
create_postprocess_pipeline();
|
||||
create_ssao_pipeline();
|
||||
create_op_pipeline();
|
||||
create_mix_pipeline();
|
||||
create_bloom_pipeline();
|
||||
create_dof_pipeline();
|
||||
create_bloom_prefilter_pipeline();
|
||||
create_bloom_downsample_pipeline();
|
||||
create_bloom_upsample_pipeline();
|
||||
create_dof_downsample_pipeline();
|
||||
create_dof_blur_pipeline();
|
||||
create_billboard_pipeline();
|
||||
create_gbuffer_billboard_pipeline();
|
||||
create_particle_pipeline();
|
||||
@ -518,6 +536,39 @@ create_trile_shadow_pipeline :: () {
|
||||
gPipelines.trile_shadow.pipeline = sg_make_pipeline(*pipeline);
|
||||
}
|
||||
|
||||
create_trile_lod_pipeline :: () {
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := trile_lod_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
pipeline.layout.buffers[0].stride = 4*3;
|
||||
pipeline.layout.buffers[1].stride = 4*3;
|
||||
pipeline.layout.buffers[2].stride = 4*3;
|
||||
pipeline.layout.buffers[3].step_func = .PER_INSTANCE;
|
||||
|
||||
pipeline.layout.attrs[ATTR_trile_lod_position] = .{ format = .FLOAT3, buffer_index = 0 };
|
||||
pipeline.layout.attrs[ATTR_trile_lod_normal] = .{ format = .FLOAT3, buffer_index = 1 };
|
||||
pipeline.layout.attrs[ATTR_trile_lod_color] = .{ format = .FLOAT3, buffer_index = 2 };
|
||||
pipeline.layout.attrs[ATTR_trile_lod_instance] = .{ format = .FLOAT4, buffer_index = 3 };
|
||||
|
||||
pipeline.depth = .{
|
||||
write_enabled = true,
|
||||
compare = .LESS_EQUAL,
|
||||
pixel_format = .DEPTH,
|
||||
};
|
||||
|
||||
pipeline.color_count = 1;
|
||||
pipeline.colors[0] = sg_color_target_state.{
|
||||
pixel_format = .RGBA16F,
|
||||
blend = .{
|
||||
enabled = true,
|
||||
src_factor_rgb = .SRC_ALPHA,
|
||||
dst_factor_rgb = .ONE_MINUS_SRC_ALPHA,
|
||||
},
|
||||
};
|
||||
|
||||
gPipelines.trile_lod.pipeline = sg_make_pipeline(*pipeline);
|
||||
}
|
||||
|
||||
create_sky_pipeline :: () {
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := sky_shader_desc(sg_query_backend());
|
||||
@ -829,6 +880,13 @@ create_postprocess_pipeline :: () {
|
||||
mag_filter = .LINEAR,
|
||||
}));
|
||||
|
||||
gPipelines.postprocess.bind.samplers[4] = sg_make_sampler(*(sg_sampler_desc.{
|
||||
wrap_u = .CLAMP_TO_EDGE,
|
||||
wrap_v = .CLAMP_TO_EDGE,
|
||||
min_filter = .NEAREST,
|
||||
mag_filter = .NEAREST,
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
// Takes in a texture, manipulates it and outputs it.
|
||||
@ -1065,68 +1123,92 @@ 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.depth.pixel_format = .NONE;
|
||||
|
||||
pipeline.color_count = 1;
|
||||
pipeline.colors[0] = .{ pixel_format = .RGBA16F };
|
||||
|
||||
gPipelines.bloom.pipeline = sg_make_pipeline(*pipeline);
|
||||
bloom_quad_vbuffer : sg_buffer;
|
||||
bloom_quad_ibuffer : sg_buffer;
|
||||
|
||||
create_bloom_quad_buffers :: () {
|
||||
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
|
||||
];
|
||||
quad_indices : [6]u16 = .[ 0, 1, 2, 0, 2, 3 ];
|
||||
bloom_quad_vbuffer = sg_make_buffer(*(sg_buffer_desc.{ size = size_of(float) * 16, data = .{ ptr = quad_vertices.data, size = 16 * 4 }}));
|
||||
bloom_quad_ibuffer = sg_make_buffer(*(sg_buffer_desc.{ size = size_of(u16) * 6, data = .{ ptr = quad_indices.data, size = 6 * 2 }, type = .INDEXBUFFER }));
|
||||
}
|
||||
|
||||
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.{
|
||||
linear_clamp_sampler :: () -> sg_sampler {
|
||||
return sg_make_sampler(*(sg_sampler_desc.{
|
||||
wrap_u = .CLAMP_TO_EDGE,
|
||||
wrap_v = .CLAMP_TO_EDGE,
|
||||
min_filter = .NEAREST,
|
||||
mag_filter = .NEAREST,
|
||||
min_filter = .LINEAR,
|
||||
mag_filter = .LINEAR,
|
||||
}));
|
||||
}
|
||||
|
||||
create_dof_pipeline :: () {
|
||||
create_bloom_prefilter_pipeline :: () {
|
||||
create_bloom_quad_buffers();
|
||||
pipeline: sg_pipeline_desc;
|
||||
pipeline.shader = sg_make_shader(*bloom_prefilter_shader_desc(sg_query_backend()));
|
||||
pipeline.layout.attrs[ATTR_bloom_prefilter_position] = .{ format = .FLOAT2 };
|
||||
pipeline.layout.attrs[ATTR_bloom_prefilter_uv] = .{ format = .FLOAT2 };
|
||||
pipeline.index_type = .UINT16;
|
||||
pipeline.depth.pixel_format = .NONE;
|
||||
pipeline.color_count = 1;
|
||||
pipeline.colors[0] = .{ pixel_format = .RGBA16F };
|
||||
gPipelines.bloom_prefilter.pipeline = sg_make_pipeline(*pipeline);
|
||||
gPipelines.bloom_prefilter.bind.vertex_buffers[0] = bloom_quad_vbuffer;
|
||||
gPipelines.bloom_prefilter.bind.index_buffer = bloom_quad_ibuffer;
|
||||
gPipelines.bloom_prefilter.bind.samplers[SMP_bloom_prefilter_src_smp] = linear_clamp_sampler();
|
||||
}
|
||||
|
||||
create_bloom_downsample_pipeline :: () {
|
||||
pipeline: sg_pipeline_desc;
|
||||
pipeline.shader = sg_make_shader(*bloom_downsample_shader_desc(sg_query_backend()));
|
||||
pipeline.layout.attrs[ATTR_bloom_downsample_position] = .{ format = .FLOAT2 };
|
||||
pipeline.layout.attrs[ATTR_bloom_downsample_uv] = .{ format = .FLOAT2 };
|
||||
pipeline.index_type = .UINT16;
|
||||
pipeline.depth.pixel_format = .NONE;
|
||||
pipeline.color_count = 1;
|
||||
pipeline.colors[0] = .{ pixel_format = .RGBA16F };
|
||||
gPipelines.bloom_downsample.pipeline = sg_make_pipeline(*pipeline);
|
||||
gPipelines.bloom_downsample.bind.vertex_buffers[0] = bloom_quad_vbuffer;
|
||||
gPipelines.bloom_downsample.bind.index_buffer = bloom_quad_ibuffer;
|
||||
gPipelines.bloom_downsample.bind.samplers[SMP_bloom_downsample_src_smp] = linear_clamp_sampler();
|
||||
}
|
||||
|
||||
create_bloom_upsample_pipeline :: () {
|
||||
pipeline: sg_pipeline_desc;
|
||||
pipeline.shader = sg_make_shader(*bloom_upsample_shader_desc(sg_query_backend()));
|
||||
pipeline.layout.attrs[ATTR_bloom_upsample_position] = .{ format = .FLOAT2 };
|
||||
pipeline.layout.attrs[ATTR_bloom_upsample_uv] = .{ format = .FLOAT2 };
|
||||
pipeline.index_type = .UINT16;
|
||||
pipeline.depth.pixel_format = .NONE;
|
||||
pipeline.color_count = 1;
|
||||
pipeline.colors[0] = .{ pixel_format = .RGBA16F };
|
||||
gPipelines.bloom_upsample.pipeline = sg_make_pipeline(*pipeline);
|
||||
gPipelines.bloom_upsample.bind.vertex_buffers[0] = bloom_quad_vbuffer;
|
||||
gPipelines.bloom_upsample.bind.index_buffer = bloom_quad_ibuffer;
|
||||
gPipelines.bloom_upsample.bind.samplers[SMP_bloom_upsample_small_smp] = linear_clamp_sampler();
|
||||
gPipelines.bloom_upsample.bind.samplers[SMP_bloom_upsample_large_smp] = linear_clamp_sampler();
|
||||
}
|
||||
|
||||
create_dof_downsample_pipeline :: () {
|
||||
platconf := get_plat_conf();
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := dof_shader_desc(sg_query_backend());
|
||||
shader_desc := dof_downsample_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
|
||||
pipeline.layout.attrs[ATTR_dof_position] = .{ format = .FLOAT2 };
|
||||
pipeline.layout.attrs[ATTR_dof_uv] = .{ format = .FLOAT2 };
|
||||
pipeline.layout.attrs[ATTR_dof_downsample_position] = .{ format = .FLOAT2 };
|
||||
pipeline.layout.attrs[ATTR_dof_downsample_uv] = .{ format = .FLOAT2 };
|
||||
pipeline.index_type = .UINT16;
|
||||
pipeline.depth.pixel_format = .NONE;
|
||||
|
||||
pipeline.color_count = 1;
|
||||
pipeline.colors[0] = .{ pixel_format = .RGBA16F };
|
||||
|
||||
gPipelines.dof.pipeline = sg_make_pipeline(*pipeline);
|
||||
gPipelines.dof_downsample.pipeline = sg_make_pipeline(*pipeline);
|
||||
|
||||
quad_vertices : [16]float = .[
|
||||
-1.0, 1.0, 0.0, flip_if_plat(1.0),
|
||||
@ -1149,13 +1231,60 @@ create_dof_pipeline :: () {
|
||||
type = .INDEXBUFFER,
|
||||
};
|
||||
|
||||
gPipelines.dof.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||
gPipelines.dof.bind.index_buffer = sg_make_buffer(*ibuffer);
|
||||
gPipelines.dof.bind.samplers[0] = sg_make_sampler(*(sg_sampler_desc.{
|
||||
gPipelines.dof_downsample.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||
gPipelines.dof_downsample.bind.index_buffer = sg_make_buffer(*ibuffer);
|
||||
gPipelines.dof_downsample.bind.samplers[SMP_dof_downsample_src_smp] = sg_make_sampler(*(sg_sampler_desc.{
|
||||
wrap_u = .CLAMP_TO_EDGE,
|
||||
wrap_v = .CLAMP_TO_EDGE,
|
||||
min_filter = .NEAREST,
|
||||
mag_filter = .NEAREST,
|
||||
min_filter = .LINEAR,
|
||||
mag_filter = .LINEAR,
|
||||
}));
|
||||
}
|
||||
|
||||
create_dof_blur_pipeline :: () {
|
||||
platconf := get_plat_conf();
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := dof_blur_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
|
||||
pipeline.layout.attrs[ATTR_dof_blur_position] = .{ format = .FLOAT2 };
|
||||
pipeline.layout.attrs[ATTR_dof_blur_uv] = .{ format = .FLOAT2 };
|
||||
pipeline.index_type = .UINT16;
|
||||
pipeline.depth.pixel_format = .NONE;
|
||||
|
||||
pipeline.color_count = 1;
|
||||
pipeline.colors[0] = .{ pixel_format = .RGBA16F };
|
||||
|
||||
gPipelines.dof_blur.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.dof_blur.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||
gPipelines.dof_blur.bind.index_buffer = sg_make_buffer(*ibuffer);
|
||||
gPipelines.dof_blur.bind.samplers[SMP_dof_blur_src_smp] = sg_make_sampler(*(sg_sampler_desc.{
|
||||
wrap_u = .CLAMP_TO_EDGE,
|
||||
wrap_v = .CLAMP_TO_EDGE,
|
||||
min_filter = .LINEAR,
|
||||
mag_filter = .LINEAR,
|
||||
}));
|
||||
}
|
||||
|
||||
@ -1257,35 +1386,44 @@ create_ssao_images :: () {
|
||||
sg_destroy_attachments(g_postprocess_attach_b);
|
||||
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 = .RGBA16F,
|
||||
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);
|
||||
bloom_levels := sg_image.[g_bloom_down_1, g_bloom_down_2, g_bloom_down_3, g_bloom_down_4, g_bloom_up_3, g_bloom_up_2, g_bloom_up_1];
|
||||
for * bloom_levels { if it.id != INVALID_ID then sg_destroy_image(<<it); }
|
||||
|
||||
make_bloom_level :: (img: *sg_image, attach: *sg_attachments, width: s32, height: s32) {
|
||||
<<img = sg_make_image(*(sg_image_desc.{ width=width, height=height, pixel_format=.RGBA16F, render_target=true, sample_count=1 }));
|
||||
sg_destroy_attachments(<<attach);
|
||||
<<attach = sg_make_attachments(*(sg_attachments_desc.{ colors[0].image = <<img }));
|
||||
}
|
||||
|
||||
make_bloom_level(*g_bloom_down_1, *g_bloom_down_1_attach, w/2, h/2);
|
||||
make_bloom_level(*g_bloom_down_2, *g_bloom_down_2_attach, w/4, h/4);
|
||||
make_bloom_level(*g_bloom_down_3, *g_bloom_down_3_attach, w/8, h/8);
|
||||
make_bloom_level(*g_bloom_down_4, *g_bloom_down_4_attach, w/16, h/16);
|
||||
make_bloom_level(*g_bloom_up_3, *g_bloom_up_3_attach, w/8, h/8);
|
||||
make_bloom_level(*g_bloom_up_2, *g_bloom_up_2_attach, w/4, h/4);
|
||||
make_bloom_level(*g_bloom_up_1, *g_bloom_up_1_attach, w/2, h/2);
|
||||
|
||||
if g_dof_tex.id != INVALID_ID then sg_destroy_image(g_dof_tex);
|
||||
if g_dof_tex.id != INVALID_ID then sg_destroy_image(g_dof_tex);
|
||||
if g_dof_downsample_tex.id != INVALID_ID then sg_destroy_image(g_dof_downsample_tex);
|
||||
|
||||
dof_img_desc := sg_image_desc.{
|
||||
width = cast(s32)((cast(float)w)/1.5),
|
||||
height = cast(s32)((cast(float)h)/1.5),
|
||||
width = w/2,
|
||||
height = h/2,
|
||||
pixel_format = .RGBA16F,
|
||||
render_target = true,
|
||||
sample_count = 1,
|
||||
};
|
||||
g_dof_tex = sg_make_image(*dof_img_desc);
|
||||
dof_attach_desc := sg_attachments_desc.{
|
||||
colors[0].image = g_dof_tex,
|
||||
};
|
||||
g_dof_tex = sg_make_image(*dof_img_desc);
|
||||
g_dof_downsample_tex = sg_make_image(*dof_img_desc);
|
||||
|
||||
sg_destroy_attachments(g_dof_attach);
|
||||
g_dof_attach = sg_make_attachments(*dof_attach_desc);
|
||||
g_dof_attach = sg_make_attachments(*(sg_attachments_desc.{
|
||||
colors[0].image = g_dof_tex,
|
||||
}));
|
||||
sg_destroy_attachments(g_dof_downsample_attach);
|
||||
g_dof_downsample_attach = sg_make_attachments(*(sg_attachments_desc.{
|
||||
colors[0].image = g_dof_downsample_tex,
|
||||
}));
|
||||
}
|
||||
|
||||
create_ssao_pipeline :: () {
|
||||
|
||||
@ -10,7 +10,7 @@ Post_Process :: struct {
|
||||
dilate_size : s32 = 0; @Slider,0,10,1;
|
||||
dilate_min : float = 0.1; @Slider,0,1,0.1;
|
||||
dilate_max : float = 0.3; @Slider,0,1,0.1;
|
||||
dof_blur_size : s32 = 0; @Slider,0,10,1;
|
||||
dof_blur_size : float = 1.0; @Slider,0.0,2.0,0.1;
|
||||
dof_min : float = 1.0; @Slider,0,10,1;
|
||||
dof_max : float = 3.0; @Slider,0,50,1;
|
||||
dof_point : float = 5.0; @Slider,0,30,1;
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#load "arbtri.jai";
|
||||
#load "debug_draw.jai";
|
||||
#load "meshgen.jai";
|
||||
#load "lodgen.jai";
|
||||
#load "helpers.jai";
|
||||
#load "animation.jai";
|
||||
#load "pipelines.jai";
|
||||
|
||||
@ -62,6 +62,7 @@ Rendering_Task_Trile :: struct {
|
||||
preview_mode : s32 = 0; // 0=normal, 1=add preview (blue), 2=delete preview (red)
|
||||
shadow_only : bool = false; // only submit to shadow bucket (frustum-culled from camera)
|
||||
skip_main : bool = false; // RDM-flagged instances still cast shadows / write gbuffer / reflect, but main pass uses the RDM pipeline
|
||||
lod_index : s32 = 0; // 0 = full detail, 1 = 4^3 LOD, 2 = 2^3 LOD
|
||||
}
|
||||
|
||||
Rendering_Task_Trile_RDM :: struct {
|
||||
@ -159,6 +160,7 @@ tasks_to_commands :: () {
|
||||
drawPositionsCmd.conf = trileTask.worldConf;
|
||||
drawPositionsCmd.preview_mode = trileTask.preview_mode;
|
||||
drawPositionsCmd.offset_index = trile_add_counter;
|
||||
drawPositionsCmd.lod_index = trileTask.lod_index;
|
||||
trile_add_counter += 1;
|
||||
if trileTask.shadow_only {
|
||||
array_add(*render_command_buckets.shadow, drawPositionsCmd);
|
||||
|
||||
@ -1,423 +0,0 @@
|
||||
/*
|
||||
#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;
|
||||
}
|
||||
491
src/shaders/jai/shader_bloom_downsample.jai
Normal file
491
src/shaders/jai/shader_bloom_downsample.jai
Normal file
@ -0,0 +1,491 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_bloom_downsample.glsl -o ./jai/shader_bloom_downsample.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'bloom_downsample':
|
||||
Get shader desc: bloom_downsample_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_bloom_downsample
|
||||
Fragment Shader: fs_bloom_downsample
|
||||
Attributes:
|
||||
ATTR_bloom_downsample_position => 0
|
||||
ATTR_bloom_downsample_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'bloom_downsample_params':
|
||||
Jai struct: Bloom_Downsample_Params
|
||||
Bind slot: UB_bloom_downsample_params => 0
|
||||
Image 'bloom_downsample_src':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_bloom_downsample_src => 0
|
||||
Sampler 'bloom_downsample_src_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_bloom_downsample_src_smp => 0
|
||||
*/
|
||||
ATTR_bloom_downsample_position :: 0;
|
||||
ATTR_bloom_downsample_uv :: 1;
|
||||
UB_bloom_downsample_params :: 0;
|
||||
IMG_bloom_downsample_src :: 0;
|
||||
SMP_bloom_downsample_src_smp :: 0;
|
||||
Bloom_Downsample_Params :: struct {
|
||||
src_texel_x: float;
|
||||
src_texel_y: float;
|
||||
_: [8]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_downsample_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_downsample_params[1];
|
||||
layout(binding = 16) uniform sampler2D bloom_downsample_src_bloom_downsample_src_smp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 _23 = vec2(bloom_downsample_params[0].x, bloom_downsample_params[0].y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
frag_color = vec4((((texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + _23).xyz) * 0.25, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_downsample_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,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,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,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,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,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x32,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,0x20,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
||||
0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x20,
|
||||
0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x34,0x39,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,
|
||||
0x76,0x65,0x63,0x34,0x28,0x28,0x28,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,
|
||||
0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,
|
||||
0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,
|
||||
0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,
|
||||
0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,
|
||||
0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,
|
||||
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,
|
||||
0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,
|
||||
0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,
|
||||
0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x32,0x35,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_downsample_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_downsample_params[1];
|
||||
uniform highp sampler2D bloom_downsample_src_bloom_downsample_src_smp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec2 _23 = vec2(bloom_downsample_params[0].x, bloom_downsample_params[0].y) * 0.5;
|
||||
highp float _44 = _23.x;
|
||||
highp float _45 = -_44;
|
||||
highp float _48 = _23.y;
|
||||
highp float _49 = -_48;
|
||||
frag_color = vec4((((texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + _23).xyz) * 0.25, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_downsample_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,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,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,0x64,0x6f,0x77,0x6e,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,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,0x32,0x20,0x5f,0x32,0x33,0x20,
|
||||
0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,
|
||||
0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,
|
||||
0x5d,0x2e,0x78,0x2c,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,
|
||||
0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,
|
||||
0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,
|
||||
0x5f,0x32,0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,
|
||||
0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
||||
0x5f,0x34,0x39,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x28,0x28,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x35,0x2c,
|
||||
0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,
|
||||
0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,
|
||||
0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,
|
||||
0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x35,
|
||||
0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,
|
||||
0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,
|
||||
0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,
|
||||
0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,
|
||||
0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,0x2e,0x32,
|
||||
0x35,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_downsample_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_downsample_params
|
||||
{
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
};
|
||||
|
||||
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_downsample_params& _12 [[buffer(0)]], texture2d<float> bloom_downsample_src [[texture(0)]], sampler bloom_downsample_src_smp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 _23 = float2(_12.src_texel_x, _12.src_texel_y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
out.frag_color = float4((((bloom_downsample_src.sample(bloom_downsample_src_smp, (in.texcoord + float2(_45, _49))).xyz + bloom_downsample_src.sample(bloom_downsample_src_smp, (in.texcoord + float2(_44, _49))).xyz) + bloom_downsample_src.sample(bloom_downsample_src_smp, (in.texcoord + float2(_45, _48))).xyz) + bloom_downsample_src.sample(bloom_downsample_src_smp, (in.texcoord + _23)).xyz) * 0.25, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_downsample_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,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,0x5f,0x78,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x72,0x63,0x5f,0x74,0x65,
|
||||
0x78,0x65,0x6c,0x5f,0x79,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,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,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,
|
||||
0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,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,0x64,0x6f,0x77,
|
||||
0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,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,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x32,0x28,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,0x5f,
|
||||
0x78,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,
|
||||
0x5f,0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x78,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x20,
|
||||
0x3d,0x20,0x2d,0x5f,0x34,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x39,0x20,0x3d,0x20,0x2d,
|
||||
0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,
|
||||
0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||
0x28,0x28,0x28,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,
|
||||
0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,
|
||||
0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,
|
||||
0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x34,
|
||||
0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,
|
||||
0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x34,0x35,
|
||||
0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,
|
||||
0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,
|
||||
0x72,0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,
|
||||
0x2a,0x20,0x30,0x2e,0x32,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,
|
||||
0x0a,0x00,
|
||||
];
|
||||
bloom_downsample_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "bloom_downsample_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_bloom_downsample_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_downsample_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_downsample_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_downsample_src_bloom_downsample_src_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_bloom_downsample_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_downsample_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_downsample_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_downsample_src_bloom_downsample_src_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_bloom_downsample_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_bloom_downsample_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;
|
||||
}
|
||||
552
src/shaders/jai/shader_bloom_prefilter.jai
Normal file
552
src/shaders/jai/shader_bloom_prefilter.jai
Normal file
@ -0,0 +1,552 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_bloom_prefilter.glsl -o ./jai/shader_bloom_prefilter.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'bloom_prefilter':
|
||||
Get shader desc: bloom_prefilter_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_bloom_prefilter
|
||||
Fragment Shader: fs_bloom_prefilter
|
||||
Attributes:
|
||||
ATTR_bloom_prefilter_position => 0
|
||||
ATTR_bloom_prefilter_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'bloom_prefilter_params':
|
||||
Jai struct: Bloom_Prefilter_Params
|
||||
Bind slot: UB_bloom_prefilter_params => 0
|
||||
Image 'bloom_prefilter_src':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_bloom_prefilter_src => 0
|
||||
Sampler 'bloom_prefilter_src_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_bloom_prefilter_src_smp => 0
|
||||
*/
|
||||
ATTR_bloom_prefilter_position :: 0;
|
||||
ATTR_bloom_prefilter_uv :: 1;
|
||||
UB_bloom_prefilter_params :: 0;
|
||||
IMG_bloom_prefilter_src :: 0;
|
||||
SMP_bloom_prefilter_src_smp :: 0;
|
||||
Bloom_Prefilter_Params :: struct {
|
||||
src_texel_x: float;
|
||||
src_texel_y: float;
|
||||
threshold: float;
|
||||
_: [4]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_prefilter_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_prefilter_params[1];
|
||||
layout(binding = 16) uniform sampler2D bloom_prefilter_src_bloom_prefilter_src_smp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 _23 = vec2(bloom_prefilter_params[0].x, bloom_prefilter_params[0].y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
vec3 _105 = (((texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + _23).xyz) * 0.25;
|
||||
vec3 color = _105;
|
||||
if (dot(_105, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)) < bloom_prefilter_params[0].z)
|
||||
{
|
||||
color = vec3(0.0);
|
||||
}
|
||||
frag_color = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_prefilter_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,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,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,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,
|
||||
0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,
|
||||
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,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,0x20,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,
|
||||
0x5f,0x32,0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,
|
||||
0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,
|
||||
0x39,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
|
||||
0x63,0x33,0x20,0x5f,0x31,0x30,0x35,0x20,0x3d,0x20,0x28,0x28,0x28,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,
|
||||
0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,
|
||||
0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,
|
||||
0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,
|
||||
0x32,0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,
|
||||
0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,
|
||||
0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,
|
||||
0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,
|
||||
0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,
|
||||
0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,
|
||||
0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,
|
||||
0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,
|
||||
0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,
|
||||
0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,0x2e,0x32,
|
||||
0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x3d,0x20,0x5f,0x31,0x30,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,
|
||||
0x20,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x30,0x35,0x2c,0x20,0x76,0x65,0x63,0x33,
|
||||
0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,0x39,0x39,0x39,0x32,0x37,0x35,0x32,0x30,
|
||||
0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,
|
||||
0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,0x31,0x38,0x32,0x32,0x35,0x30,0x39,0x37,
|
||||
0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x37,0x32,0x32,0x30,0x30,0x30,
|
||||
0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,
|
||||
0x35,0x29,0x29,0x20,0x3c,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,
|
||||
0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,
|
||||
0x7a,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,0x33,0x28,0x30,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,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_prefilter_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_prefilter_params[1];
|
||||
uniform highp sampler2D bloom_prefilter_src_bloom_prefilter_src_smp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec2 _23 = vec2(bloom_prefilter_params[0].x, bloom_prefilter_params[0].y) * 0.5;
|
||||
highp float _44 = _23.x;
|
||||
highp float _45 = -_44;
|
||||
highp float _48 = _23.y;
|
||||
highp float _49 = -_48;
|
||||
highp vec3 _105 = (((texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + _23).xyz) * 0.25;
|
||||
highp vec3 color = _105;
|
||||
if (dot(_105, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)) < bloom_prefilter_params[0].z)
|
||||
{
|
||||
color = vec3(0.0);
|
||||
}
|
||||
frag_color = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_prefilter_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,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,
|
||||
0x72,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,0x70,0x72,0x65,0x66,0x69,
|
||||
0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,
|
||||
0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,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,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,
|
||||
0x65,0x63,0x32,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,
|
||||
0x74,0x65,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,
|
||||
0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x78,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,
|
||||
0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,
|
||||
0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x39,0x20,0x3d,
|
||||
0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x30,0x35,0x20,0x3d,0x20,0x28,0x28,0x28,
|
||||
0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,
|
||||
0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,
|
||||
0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,
|
||||
0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,
|
||||
0x78,0x79,0x7a,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,
|
||||
0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,
|
||||
0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,
|
||||
0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,
|
||||
0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,
|
||||
0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,
|
||||
0x32,0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,
|
||||
0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,
|
||||
0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x76,0x65,0x63,0x33,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x31,0x30,
|
||||
0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x64,0x6f,0x74,0x28,0x5f,
|
||||
0x31,0x30,0x35,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,
|
||||
0x39,0x39,0x39,0x39,0x32,0x37,0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,
|
||||
0x32,0x35,0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,
|
||||
0x36,0x31,0x38,0x32,0x32,0x35,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,
|
||||
0x30,0x2e,0x30,0x37,0x32,0x32,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,
|
||||
0x32,0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x20,0x3c,0x20,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x7a,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,0x33,0x28,0x30,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,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_prefilter_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_prefilter_params
|
||||
{
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
float threshold;
|
||||
};
|
||||
|
||||
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_prefilter_params& _12 [[buffer(0)]], texture2d<float> bloom_prefilter_src [[texture(0)]], sampler bloom_prefilter_src_smp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 _23 = float2(_12.src_texel_x, _12.src_texel_y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
float3 _105 = (((bloom_prefilter_src.sample(bloom_prefilter_src_smp, (in.texcoord + float2(_45, _49))).xyz + bloom_prefilter_src.sample(bloom_prefilter_src_smp, (in.texcoord + float2(_44, _49))).xyz) + bloom_prefilter_src.sample(bloom_prefilter_src_smp, (in.texcoord + float2(_45, _48))).xyz) + bloom_prefilter_src.sample(bloom_prefilter_src_smp, (in.texcoord + _23)).xyz) * 0.25;
|
||||
float3 color = _105;
|
||||
if (dot(_105, float3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)) < _12.threshold)
|
||||
{
|
||||
color = float3(0.0);
|
||||
}
|
||||
out.frag_color = float4(color, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_prefilter_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,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,0x5f,0x78,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,
|
||||
0x65,0x6c,0x5f,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
||||
0x74,0x68,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,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,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,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,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,0x70,
|
||||
0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,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,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x32,0x28,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,
|
||||
0x5f,0x78,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,
|
||||
0x6c,0x5f,0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,
|
||||
0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,
|
||||
0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x39,0x20,0x3d,0x20,
|
||||
0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
|
||||
0x20,0x5f,0x31,0x30,0x35,0x20,0x3d,0x20,0x28,0x28,0x28,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x2e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,
|
||||
0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,
|
||||
0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,
|
||||
0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,
|
||||
0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,
|
||||
0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,
|
||||
0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,
|
||||
0x29,0x20,0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,
|
||||
0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x34,
|
||||
0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,
|
||||
0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,
|
||||
0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,
|
||||
0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,
|
||||
0x20,0x30,0x2e,0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x33,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x31,0x30,0x35,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x30,0x35,
|
||||
0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,
|
||||
0x39,0x39,0x39,0x32,0x37,0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,
|
||||
0x35,0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,
|
||||
0x31,0x38,0x32,0x32,0x35,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,
|
||||
0x2e,0x30,0x37,0x32,0x32,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,
|
||||
0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x20,0x3c,0x20,0x5f,0x31,
|
||||
0x32,0x2e,0x74,0x68,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,0x33,0x28,0x30,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,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_prefilter_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "bloom_prefilter_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_bloom_prefilter_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_prefilter_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_prefilter_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_prefilter_src_bloom_prefilter_src_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_bloom_prefilter_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_prefilter_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_prefilter_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_prefilter_src_bloom_prefilter_src_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_bloom_prefilter_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_bloom_prefilter_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;
|
||||
}
|
||||
563
src/shaders/jai/shader_bloom_upsample.jai
Normal file
563
src/shaders/jai/shader_bloom_upsample.jai
Normal file
@ -0,0 +1,563 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_bloom_upsample.glsl -o ./jai/shader_bloom_upsample.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'bloom_upsample':
|
||||
Get shader desc: bloom_upsample_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_bloom_upsample
|
||||
Fragment Shader: fs_bloom_upsample
|
||||
Attributes:
|
||||
ATTR_bloom_upsample_position => 0
|
||||
ATTR_bloom_upsample_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'bloom_upsample_params':
|
||||
Jai struct: Bloom_Upsample_Params
|
||||
Bind slot: UB_bloom_upsample_params => 0
|
||||
Image 'bloom_upsample_small':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_bloom_upsample_small => 0
|
||||
Image 'bloom_upsample_large':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_bloom_upsample_large => 1
|
||||
Sampler 'bloom_upsample_small_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_bloom_upsample_small_smp => 0
|
||||
Sampler 'bloom_upsample_large_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_bloom_upsample_large_smp => 1
|
||||
*/
|
||||
ATTR_bloom_upsample_position :: 0;
|
||||
ATTR_bloom_upsample_uv :: 1;
|
||||
UB_bloom_upsample_params :: 0;
|
||||
IMG_bloom_upsample_small :: 0;
|
||||
IMG_bloom_upsample_large :: 1;
|
||||
SMP_bloom_upsample_small_smp :: 0;
|
||||
SMP_bloom_upsample_large_smp :: 1;
|
||||
Bloom_Upsample_Params :: struct {
|
||||
src_texel_x: float;
|
||||
src_texel_y: float;
|
||||
_: [8]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_upsample_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_upsample_params[1];
|
||||
layout(binding = 16) uniform sampler2D bloom_upsample_small_bloom_upsample_small_smp;
|
||||
layout(binding = 17) uniform sampler2D bloom_upsample_large_bloom_upsample_large_smp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 _23 = vec2(bloom_upsample_params[0].x, bloom_upsample_params[0].y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
frag_color = vec4(((((texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + _23).xyz) * 0.25) + texture(bloom_upsample_large_bloom_upsample_large_smp, texcoord).xyz, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_upsample_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,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,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,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,
|
||||
0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x37,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,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,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,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,
|
||||
0x20,0x76,0x65,0x63,0x32,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,
|
||||
0x2c,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
||||
0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x20,
|
||||
0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x34,0x39,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,
|
||||
0x76,0x65,0x63,0x34,0x28,0x28,0x28,0x28,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,
|
||||
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,
|
||||
0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,
|
||||
0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,
|
||||
0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,
|
||||
0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,
|
||||
0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,
|
||||
0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,
|
||||
0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,
|
||||
0x72,0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,
|
||||
0x20,0x30,0x2e,0x32,0x35,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x6c,0x61,0x72,0x67,0x65,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,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,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_upsample_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_upsample_params[1];
|
||||
uniform highp sampler2D bloom_upsample_small_bloom_upsample_small_smp;
|
||||
uniform highp sampler2D bloom_upsample_large_bloom_upsample_large_smp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec2 _23 = vec2(bloom_upsample_params[0].x, bloom_upsample_params[0].y) * 0.5;
|
||||
highp float _44 = _23.x;
|
||||
highp float _45 = -_44;
|
||||
highp float _48 = _23.y;
|
||||
highp float _49 = -_48;
|
||||
frag_color = vec4(((((texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + _23).xyz) * 0.25) + texture(bloom_upsample_large_bloom_upsample_large_smp, texcoord).xyz, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_upsample_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,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
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,0x75,0x70,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,
|
||||
0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,
|
||||
0x70,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,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,
|
||||
0x61,0x72,0x67,0x65,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,0x32,
|
||||
0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,
|
||||
0x2e,0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,
|
||||
0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,
|
||||
0x20,0x5f,0x32,0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,
|
||||
0x34,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x5f,0x34,0x39,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,
|
||||
0x63,0x34,0x28,0x28,0x28,0x28,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,
|
||||
0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,
|
||||
0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,
|
||||
0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x74,
|
||||
0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,
|
||||
0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,
|
||||
0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,
|
||||
0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,
|
||||
0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,
|
||||
0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,
|
||||
0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,
|
||||
0x2e,0x32,0x35,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,
|
||||
0x72,0x67,0x65,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,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,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_upsample_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_upsample_params
|
||||
{
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
};
|
||||
|
||||
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_upsample_params& _12 [[buffer(0)]], texture2d<float> bloom_upsample_small [[texture(0)]], texture2d<float> bloom_upsample_large [[texture(1)]], sampler bloom_upsample_small_smp [[sampler(0)]], sampler bloom_upsample_large_smp [[sampler(1)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 _23 = float2(_12.src_texel_x, _12.src_texel_y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
out.frag_color = float4(((((bloom_upsample_small.sample(bloom_upsample_small_smp, (in.texcoord + float2(_45, _49))).xyz + bloom_upsample_small.sample(bloom_upsample_small_smp, (in.texcoord + float2(_44, _49))).xyz) + bloom_upsample_small.sample(bloom_upsample_small_smp, (in.texcoord + float2(_45, _48))).xyz) + bloom_upsample_small.sample(bloom_upsample_small_smp, (in.texcoord + _23)).xyz) * 0.25) + bloom_upsample_large.sample(bloom_upsample_large_smp, in.texcoord).xyz, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_upsample_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,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,0x5f,0x78,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,
|
||||
0x6c,0x5f,0x79,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,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x26,0x20,0x5f,0x31,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,0x75,0x70,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x20,0x5b,0x5b,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,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,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,
|
||||
0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x31,0x29,0x5d,0x5d,0x2c,
|
||||
0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,
|
||||
0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,
|
||||
0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,
|
||||
0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,
|
||||
0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,0x73,
|
||||
0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x31,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,0x33,0x20,0x3d,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x28,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,
|
||||
0x65,0x6c,0x5f,0x78,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,
|
||||
0x78,0x65,0x6c,0x5f,0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,
|
||||
0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
||||
0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x39,0x20,
|
||||
0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,
|
||||
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x34,0x28,0x28,0x28,0x28,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x2e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,
|
||||
0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x32,0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,0x2e,
|
||||
0x78,0x79,0x7a,0x20,0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x2e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,
|
||||
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,0x2e,0x78,0x79,
|
||||
0x7a,0x29,0x20,0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,
|
||||
0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,
|
||||
0x29,0x20,0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,
|
||||
0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x29,0x2e,0x78,
|
||||
0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,0x2e,0x32,0x35,0x29,0x20,0x2b,0x20,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,
|
||||
0x67,0x65,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,
|
||||
0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,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,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
];
|
||||
bloom_upsample_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "bloom_upsample_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_bloom_upsample_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_upsample_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_upsample_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[1].stage = .FRAGMENT;
|
||||
desc.samplers[1].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_upsample_small_bloom_upsample_small_smp";
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 1;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 1;
|
||||
desc.image_sampler_pairs[1].glsl_name = "bloom_upsample_large_bloom_upsample_large_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_bloom_upsample_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_upsample_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_upsample_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[1].stage = .FRAGMENT;
|
||||
desc.samplers[1].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_upsample_small_bloom_upsample_small_smp";
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 1;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 1;
|
||||
desc.image_sampler_pairs[1].glsl_name = "bloom_upsample_large_bloom_upsample_large_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_bloom_upsample_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_bloom_upsample_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.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.images[1].msl_texture_n = 1;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.samplers[1].stage = .FRAGMENT;
|
||||
desc.samplers[1].sampler_type = .FILTERING;
|
||||
desc.samplers[1].msl_sampler_n = 1;
|
||||
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[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 1;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 1;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
566
src/shaders/jai/shader_dof_blur.jai
Normal file
566
src/shaders/jai/shader_dof_blur.jai
Normal file
@ -0,0 +1,566 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_dof_blur.glsl -o ./jai/shader_dof_blur.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'dof_blur':
|
||||
Get shader desc: dof_blur_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_dof_blur
|
||||
Fragment Shader: fs_dof_blur
|
||||
Attributes:
|
||||
ATTR_dof_blur_position => 0
|
||||
ATTR_dof_blur_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'dof_blur_params':
|
||||
Jai struct: Dof_Blur_Params
|
||||
Bind slot: UB_dof_blur_params => 0
|
||||
Image 'dof_blur_src':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_dof_blur_src => 0
|
||||
Sampler 'dof_blur_src_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_dof_blur_src_smp => 0
|
||||
*/
|
||||
ATTR_dof_blur_position :: 0;
|
||||
ATTR_dof_blur_uv :: 1;
|
||||
UB_dof_blur_params :: 0;
|
||||
IMG_dof_blur_src :: 0;
|
||||
SMP_dof_blur_src_smp :: 0;
|
||||
Dof_Blur_Params :: struct {
|
||||
bokeh_radius_x: float;
|
||||
bokeh_radius_y: float;
|
||||
_: [8]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_dof_blur_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 dof_blur_params[1];
|
||||
layout(binding = 16) uniform sampler2D dof_blur_src_dof_blur_src_smp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 _24 = texture(dof_blur_src_dof_blur_src_smp, texcoord);
|
||||
vec4 best = _24;
|
||||
float best_lum = dot(_24.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
float _50 = float(i);
|
||||
float _52 = _50 * 2.3999631404876708984375;
|
||||
vec4 _88 = texture(dof_blur_src_dof_blur_src_smp, texcoord + ((vec2(cos(_52), sin(_52)) * sqrt((_50 * 0.0322580635547637939453125) + 0.001000000047497451305389404296875)) * vec2(dof_blur_params[0].x, dof_blur_params[0].y)));
|
||||
float _92 = dot(_88.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
if (_92 > best_lum)
|
||||
{
|
||||
best = _88;
|
||||
best_lum = _92;
|
||||
}
|
||||
}
|
||||
frag_color = best;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_blur_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,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,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,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,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,0x64,0x6f,0x66,
|
||||
0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x62,0x6c,
|
||||
0x75,0x72,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,
|
||||
0x62,0x65,0x73,0x74,0x20,0x3d,0x20,0x5f,0x32,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x20,0x3d,
|
||||
0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x34,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,
|
||||
0x63,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,0x39,0x39,0x39,0x32,0x37,0x35,
|
||||
0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x37,
|
||||
0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,0x31,0x38,0x32,0x32,0x35,0x30,
|
||||
0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x37,0x32,0x32,0x30,
|
||||
0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,0x32,0x31,
|
||||
0x38,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,
|
||||
0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,0x20,0x33,
|
||||
0x32,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x30,0x20,
|
||||
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x32,0x20,0x3d,0x20,
|
||||
0x5f,0x35,0x30,0x20,0x2a,0x20,0x32,0x2e,0x33,0x39,0x39,0x39,0x36,0x33,0x31,0x34,
|
||||
0x30,0x34,0x38,0x37,0x36,0x37,0x30,0x38,0x39,0x38,0x34,0x33,0x37,0x35,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x38,0x38,
|
||||
0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,
|
||||
0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,
|
||||
0x72,0x64,0x20,0x2b,0x20,0x28,0x28,0x76,0x65,0x63,0x32,0x28,0x63,0x6f,0x73,0x28,
|
||||
0x5f,0x35,0x32,0x29,0x2c,0x20,0x73,0x69,0x6e,0x28,0x5f,0x35,0x32,0x29,0x29,0x20,
|
||||
0x2a,0x20,0x73,0x71,0x72,0x74,0x28,0x28,0x5f,0x35,0x30,0x20,0x2a,0x20,0x30,0x2e,
|
||||
0x30,0x33,0x32,0x32,0x35,0x38,0x30,0x36,0x33,0x35,0x35,0x34,0x37,0x36,0x33,0x37,
|
||||
0x39,0x33,0x39,0x34,0x35,0x33,0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x30,0x2e,0x30,
|
||||
0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x34,0x37,0x34,0x39,0x37,0x34,0x35,
|
||||
0x31,0x33,0x30,0x35,0x33,0x38,0x39,0x34,0x30,0x34,0x32,0x39,0x36,0x38,0x37,0x35,
|
||||
0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28,0x64,0x6f,0x66,0x5f,0x62,0x6c,
|
||||
0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,0x20,
|
||||
0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
|
||||
0x30,0x5d,0x2e,0x79,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x39,0x32,0x20,0x3d,0x20,0x64,0x6f,0x74,
|
||||
0x28,0x5f,0x38,0x38,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,
|
||||
0x2e,0x32,0x31,0x32,0x35,0x39,0x39,0x39,0x39,0x32,0x37,0x35,0x32,0x30,0x37,0x35,
|
||||
0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,0x32,0x30,
|
||||
0x30,0x30,0x30,0x36,0x39,0x36,0x31,0x38,0x32,0x32,0x35,0x30,0x39,0x37,0x36,0x35,
|
||||
0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x37,0x32,0x32,0x30,0x30,0x30,0x30,0x30,
|
||||
0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,
|
||||
0x39,0x32,0x20,0x3e,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x29,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x62,0x65,0x73,0x74,0x20,0x3d,0x20,0x5f,0x38,0x38,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x65,0x73,
|
||||
0x74,0x5f,0x6c,0x75,0x6d,0x20,0x3d,0x20,0x5f,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x62,0x65,
|
||||
0x73,0x74,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_dof_blur_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 dof_blur_params[1];
|
||||
uniform highp sampler2D dof_blur_src_dof_blur_src_smp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec4 _24 = texture(dof_blur_src_dof_blur_src_smp, texcoord);
|
||||
highp vec4 best = _24;
|
||||
highp float best_lum = dot(_24.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
highp float _50 = float(i);
|
||||
highp float _52 = _50 * 2.3999631404876708984375;
|
||||
highp vec4 _88 = texture(dof_blur_src_dof_blur_src_smp, texcoord + ((vec2(cos(_52), sin(_52)) * sqrt((_50 * 0.0322580635547637939453125) + 0.001000000047497451305389404296875)) * vec2(dof_blur_params[0].x, dof_blur_params[0].y)));
|
||||
highp float _92 = dot(_88.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
if (_92 > best_lum)
|
||||
{
|
||||
best = _88;
|
||||
best_lum = _92;
|
||||
}
|
||||
}
|
||||
frag_color = best;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_blur_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,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,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,0x64,0x6f,
|
||||
0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,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,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x64,
|
||||
0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,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,0x62,0x65,0x73,0x74,0x20,
|
||||
0x3d,0x20,0x5f,0x32,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x20,
|
||||
0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x34,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,
|
||||
0x65,0x63,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,0x39,0x39,0x39,0x32,0x37,
|
||||
0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,
|
||||
0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,0x31,0x38,0x32,0x32,0x35,
|
||||
0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x37,0x32,0x32,
|
||||
0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,0x32,
|
||||
0x31,0x38,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,
|
||||
0x28,0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,0x20,
|
||||
0x33,0x32,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x35,0x30,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x32,0x20,0x3d,0x20,0x5f,0x35,0x30,
|
||||
0x20,0x2a,0x20,0x32,0x2e,0x33,0x39,0x39,0x39,0x36,0x33,0x31,0x34,0x30,0x34,0x38,
|
||||
0x37,0x36,0x37,0x30,0x38,0x39,0x38,0x34,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||
0x5f,0x38,0x38,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x64,0x6f,
|
||||
0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x28,0x28,0x76,0x65,0x63,0x32,0x28,0x63,
|
||||
0x6f,0x73,0x28,0x5f,0x35,0x32,0x29,0x2c,0x20,0x73,0x69,0x6e,0x28,0x5f,0x35,0x32,
|
||||
0x29,0x29,0x20,0x2a,0x20,0x73,0x71,0x72,0x74,0x28,0x28,0x5f,0x35,0x30,0x20,0x2a,
|
||||
0x20,0x30,0x2e,0x30,0x33,0x32,0x32,0x35,0x38,0x30,0x36,0x33,0x35,0x35,0x34,0x37,
|
||||
0x36,0x33,0x37,0x39,0x33,0x39,0x34,0x35,0x33,0x31,0x32,0x35,0x29,0x20,0x2b,0x20,
|
||||
0x30,0x2e,0x30,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x34,0x37,0x34,0x39,
|
||||
0x37,0x34,0x35,0x31,0x33,0x30,0x35,0x33,0x38,0x39,0x34,0x30,0x34,0x32,0x39,0x36,
|
||||
0x38,0x37,0x35,0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28,0x64,0x6f,0x66,
|
||||
0x5f,0x62,0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,
|
||||
0x78,0x2c,0x20,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
||||
0x5f,0x39,0x32,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x38,0x38,0x2e,0x78,0x79,
|
||||
0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,0x39,
|
||||
0x39,0x39,0x32,0x37,0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,0x35,
|
||||
0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,0x31,
|
||||
0x38,0x32,0x32,0x35,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,
|
||||
0x30,0x37,0x32,0x32,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,
|
||||
0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x39,0x32,0x20,0x3e,0x20,0x62,0x65,
|
||||
0x73,0x74,0x5f,0x6c,0x75,0x6d,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x65,
|
||||
0x73,0x74,0x20,0x3d,0x20,0x5f,0x38,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x20,0x3d,
|
||||
0x20,0x5f,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x62,0x65,0x73,0x74,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_dof_blur_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 dof_blur_params
|
||||
{
|
||||
float bokeh_radius_x;
|
||||
float bokeh_radius_y;
|
||||
};
|
||||
|
||||
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 dof_blur_params& _72 [[buffer(0)]], texture2d<float> dof_blur_src [[texture(0)]], sampler dof_blur_src_smp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float4 _24 = dof_blur_src.sample(dof_blur_src_smp, in.texcoord);
|
||||
float4 best = _24;
|
||||
float best_lum = dot(_24.xyz, float3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
float _50 = float(i);
|
||||
float _52 = _50 * 2.3999631404876708984375;
|
||||
float4 _88 = dof_blur_src.sample(dof_blur_src_smp, (in.texcoord + ((float2(cos(_52), sin(_52)) * sqrt((_50 * 0.0322580635547637939453125) + 0.001000000047497451305389404296875)) * float2(_72.bokeh_radius_x, _72.bokeh_radius_y))));
|
||||
float _92 = dot(_88.xyz, float3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
if (_92 > best_lum)
|
||||
{
|
||||
best = _88;
|
||||
best_lum = _92;
|
||||
}
|
||||
}
|
||||
out.frag_color = best;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_blur_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,0x64,
|
||||
0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x6f,0x6b,0x65,0x68,
|
||||
0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x5f,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x62,0x6f,0x6b,0x65,0x68,0x5f,0x72,0x61,0x64,0x69,0x75,
|
||||
0x73,0x5f,0x79,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,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x37,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,
|
||||
0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,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,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,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,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x28,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,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,
|
||||
0x62,0x65,0x73,0x74,0x20,0x3d,0x20,0x5f,0x32,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x20,0x3d,
|
||||
0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x34,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,0x39,0x39,0x39,0x32,
|
||||
0x37,0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,
|
||||
0x2e,0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,0x31,0x38,0x32,0x32,
|
||||
0x35,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x37,0x32,
|
||||
0x32,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,
|
||||
0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,
|
||||
0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,
|
||||
0x20,0x33,0x32,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,
|
||||
0x30,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x32,0x20,
|
||||
0x3d,0x20,0x5f,0x35,0x30,0x20,0x2a,0x20,0x32,0x2e,0x33,0x39,0x39,0x39,0x36,0x33,
|
||||
0x31,0x34,0x30,0x34,0x38,0x37,0x36,0x37,0x30,0x38,0x39,0x38,0x34,0x33,0x37,0x35,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||
0x20,0x5f,0x38,0x38,0x20,0x3d,0x20,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,
|
||||
0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,
|
||||
0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x28,0x28,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x28,0x63,0x6f,0x73,0x28,0x5f,0x35,0x32,0x29,0x2c,0x20,0x73,
|
||||
0x69,0x6e,0x28,0x5f,0x35,0x32,0x29,0x29,0x20,0x2a,0x20,0x73,0x71,0x72,0x74,0x28,
|
||||
0x28,0x5f,0x35,0x30,0x20,0x2a,0x20,0x30,0x2e,0x30,0x33,0x32,0x32,0x35,0x38,0x30,
|
||||
0x36,0x33,0x35,0x35,0x34,0x37,0x36,0x33,0x37,0x39,0x33,0x39,0x34,0x35,0x33,0x31,
|
||||
0x32,0x35,0x29,0x20,0x2b,0x20,0x30,0x2e,0x30,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x34,0x37,0x34,0x39,0x37,0x34,0x35,0x31,0x33,0x30,0x35,0x33,0x38,0x39,
|
||||
0x34,0x30,0x34,0x32,0x39,0x36,0x38,0x37,0x35,0x29,0x29,0x20,0x2a,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x28,0x5f,0x37,0x32,0x2e,0x62,0x6f,0x6b,0x65,0x68,0x5f,0x72,
|
||||
0x61,0x64,0x69,0x75,0x73,0x5f,0x78,0x2c,0x20,0x5f,0x37,0x32,0x2e,0x62,0x6f,0x6b,
|
||||
0x65,0x68,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x5f,0x79,0x29,0x29,0x29,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
||||
0x39,0x32,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x38,0x38,0x2e,0x78,0x79,0x7a,
|
||||
0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,
|
||||
0x39,0x39,0x39,0x32,0x37,0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,
|
||||
0x35,0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,
|
||||
0x31,0x38,0x32,0x32,0x35,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,
|
||||
0x2e,0x30,0x37,0x32,0x32,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,
|
||||
0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x39,0x32,0x20,0x3e,0x20,0x62,
|
||||
0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,
|
||||
0x65,0x73,0x74,0x20,0x3d,0x20,0x5f,0x38,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x20,
|
||||
0x3d,0x20,0x5f,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,
|
||||
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,0x62,0x65,0x73,0x74,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,
|
||||
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
dof_blur_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "dof_blur_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_dof_blur_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_dof_blur_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 = "dof_blur_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 = "dof_blur_src_dof_blur_src_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_dof_blur_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_dof_blur_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 = "dof_blur_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 = "dof_blur_src_dof_blur_src_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_dof_blur_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_dof_blur_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;
|
||||
}
|
||||
@ -4,39 +4,31 @@
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_dof.glsl -o ./jai/shader_dof.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
sokol-shdc -i shader_dof_downsample.glsl -o ./jai/shader_dof_downsample.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'dof':
|
||||
Get shader desc: dof_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_dof
|
||||
Fragment Shader: fs_dof
|
||||
Shader program: 'dof_downsample':
|
||||
Get shader desc: dof_downsample_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_dof_downsample
|
||||
Fragment Shader: fs_dof_downsample
|
||||
Attributes:
|
||||
ATTR_dof_position => 0
|
||||
ATTR_dof_uv => 1
|
||||
ATTR_dof_downsample_position => 0
|
||||
ATTR_dof_downsample_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'dof_params':
|
||||
Jai struct: Dof_Params
|
||||
Bind slot: UB_dof_params => 0
|
||||
Image 'dof_src':
|
||||
Image 'dof_downsample_src':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_dof_src => 0
|
||||
Sampler 'dof_src_smp':
|
||||
Bind slot: IMG_dof_downsample_src => 0
|
||||
Sampler 'dof_downsample_src_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_dof_src_smp => 0
|
||||
Bind slot: SMP_dof_downsample_src_smp => 0
|
||||
*/
|
||||
ATTR_dof_position :: 0;
|
||||
ATTR_dof_uv :: 1;
|
||||
UB_dof_params :: 0;
|
||||
IMG_dof_src :: 0;
|
||||
SMP_dof_src_smp :: 0;
|
||||
Dof_Params :: struct {
|
||||
dof_treshold: float;
|
||||
_: [12]u8;
|
||||
};
|
||||
ATTR_dof_downsample_position :: 0;
|
||||
ATTR_dof_downsample_uv :: 1;
|
||||
IMG_dof_downsample_src :: 0;
|
||||
SMP_dof_downsample_src_smp :: 0;
|
||||
/*
|
||||
#version 430
|
||||
|
||||
@ -51,7 +43,7 @@ Dof_Params :: struct {
|
||||
}
|
||||
|
||||
*/
|
||||
vs_dof_source_glsl430 := u8.[
|
||||
vs_dof_downsample_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,
|
||||
@ -70,52 +62,37 @@ vs_dof_source_glsl430 := u8.[
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 dof_params[1];
|
||||
layout(binding = 16) uniform sampler2D dof_src_dof_src_smp;
|
||||
layout(binding = 16) uniform sampler2D dof_downsample_src_dof_downsample_src_smp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 _24 = texture(dof_src_dof_src_smp, texcoord);
|
||||
vec4 color = _24;
|
||||
if (max(_24.x, max(_24.y, _24.z)) < dof_params[0].x)
|
||||
{
|
||||
color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
frag_color = vec4(color.xyz, 1.0);
|
||||
frag_color = vec4(texture(dof_downsample_src_dof_downsample_src_smp, texcoord).xyz, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_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,0x64,0x6f,0x66,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,0x64,0x6f,0x66,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,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,0x64,0x6f,
|
||||
0x66,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,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,0x64,0x6f,0x66,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,
|
||||
fs_dof_downsample_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,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,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,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,
|
||||
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,
|
||||
0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||
0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x64,
|
||||
0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x72,0x63,0x5f,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,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
@ -131,7 +108,7 @@ fs_dof_source_glsl430 := u8.[
|
||||
}
|
||||
|
||||
*/
|
||||
vs_dof_source_glsl300es := u8.[
|
||||
vs_dof_downsample_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,
|
||||
@ -150,55 +127,38 @@ vs_dof_source_glsl300es := u8.[
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp vec4 dof_params[1];
|
||||
uniform highp sampler2D dof_src_dof_src_smp;
|
||||
uniform highp sampler2D dof_downsample_src_dof_downsample_src_smp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
in highp vec2 texcoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec4 _24 = texture(dof_src_dof_src_smp, texcoord);
|
||||
highp vec4 color = _24;
|
||||
if (max(_24.x, max(_24.y, _24.z)) < dof_params[0].x)
|
||||
{
|
||||
color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
frag_color = vec4(color.xyz, 1.0);
|
||||
frag_color = vec4(texture(dof_downsample_src_dof_downsample_src_smp, texcoord).xyz, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_source_glsl300es := u8.[
|
||||
fs_dof_downsample_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,0x64,0x6f,0x66,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,0x64,0x6f,0x66,0x5f,0x73,0x72,0x63,
|
||||
0x5f,0x64,0x6f,0x66,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,0x64,0x6f,0x66,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,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,0x64,0x6f,0x66,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,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x64,0x6f,
|
||||
0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,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,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,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,
|
||||
0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,
|
||||
0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,
|
||||
0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x64,
|
||||
0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,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,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
@ -227,7 +187,7 @@ fs_dof_source_glsl300es := u8.[
|
||||
}
|
||||
|
||||
*/
|
||||
vs_dof_source_metal_macos := u8.[
|
||||
vs_dof_downsample_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,
|
||||
@ -263,11 +223,6 @@ vs_dof_source_metal_macos := u8.[
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct dof_params
|
||||
{
|
||||
float dof_treshold;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
@ -278,29 +233,20 @@ vs_dof_source_metal_macos := u8.[
|
||||
float2 texcoord [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], constant dof_params& _42 [[buffer(0)]], texture2d<float> dof_src [[texture(0)]], sampler dof_src_smp [[sampler(0)]])
|
||||
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> dof_downsample_src [[texture(0)]], sampler dof_downsample_src_smp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float4 _24 = dof_src.sample(dof_src_smp, in.texcoord);
|
||||
float4 color = _24;
|
||||
if (fast::max(_24.x, fast::max(_24.y, _24.z)) < _42.dof_treshold)
|
||||
{
|
||||
color = float4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
out.frag_color = float4(color.xyz, 1.0);
|
||||
out.frag_color = float4(dof_downsample_src.sample(dof_downsample_src_smp, in.texcoord).xyz, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_source_metal_macos := u8.[
|
||||
fs_dof_downsample_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,0x64,
|
||||
0x6f,0x66,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x74,0x72,0x65,0x73,0x68,0x6f,
|
||||
0x6c,0x64,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
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,
|
||||
@ -311,53 +257,36 @@ fs_dof_source_metal_macos := u8.[
|
||||
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,0x64,0x6f,0x66,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,0x64,0x6f,0x66,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,0x64,0x6f,0x66,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,0x64,0x6f,0x66,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,
|
||||
0x64,0x6f,0x66,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,0x64,0x6f,0x66,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,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x3e,0x20,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
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,0x64,0x6f,0x66,
|
||||
0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,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,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x64,0x6f,0x66,0x5f,0x64,0x6f,
|
||||
0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x28,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,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,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,
|
||||
0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
dof_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
dof_downsample_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "dof_shader";
|
||||
desc.label = "dof_downsample_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_dof_source_glsl430;
|
||||
desc.vertex_func.source = xx *vs_dof_downsample_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_dof_source_glsl430;
|
||||
desc.fragment_func.source = xx *fs_dof_downsample_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 = "dof_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
@ -367,22 +296,16 @@ dof_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
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 = "dof_src_dof_src_smp";
|
||||
desc.image_sampler_pairs[0].glsl_name = "dof_downsample_src_dof_downsample_src_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_dof_source_glsl300es;
|
||||
desc.vertex_func.source = xx *vs_dof_downsample_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_dof_source_glsl300es;
|
||||
desc.fragment_func.source = xx *fs_dof_downsample_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 = "dof_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
@ -392,18 +315,14 @@ dof_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
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 = "dof_src_dof_src_smp";
|
||||
desc.image_sampler_pairs[0].glsl_name = "dof_downsample_src_dof_downsample_src_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_dof_source_metal_macos;
|
||||
desc.vertex_func.source = xx *vs_dof_downsample_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_dof_source_metal_macos;
|
||||
desc.fragment_func.source = xx *fs_dof_downsample_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;
|
||||
@ -58,7 +58,7 @@ Gbuffer_Billboard_Vs_Params :: struct {
|
||||
vec3 _53 = gbuffer_billboard_vs_params[5].xyz - gbuffer_billboard_vs_params[7].xyz;
|
||||
_53.y = 0.0;
|
||||
vec3 look_dir = normalize(_53);
|
||||
if (gbuffer_billboard_vs_params[12].x < (-10.0))
|
||||
if (gbuffer_billboard_vs_params[12].x > (-10.0))
|
||||
{
|
||||
look_dir = gbuffer_billboard_vs_params[12].xyz;
|
||||
}
|
||||
@ -98,7 +98,7 @@ vs_gbuffer_billboard_source_glsl430 := u8.[
|
||||
0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x33,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x67,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x32,0x5d,0x2e,0x78,0x20,0x3c,0x20,0x28,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x32,0x5d,0x2e,0x78,0x20,0x3e,0x20,0x28,
|
||||
0x2d,0x31,0x30,0x2e,0x30,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,
|
||||
0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,
|
||||
@ -236,7 +236,7 @@ fs_gbuffer_billboard_source_glsl430 := u8.[
|
||||
vec3 _53 = gbuffer_billboard_vs_params[5].xyz - gbuffer_billboard_vs_params[7].xyz;
|
||||
_53.y = 0.0;
|
||||
vec3 look_dir = normalize(_53);
|
||||
if (gbuffer_billboard_vs_params[12].x < (-10.0))
|
||||
if (gbuffer_billboard_vs_params[12].x > (-10.0))
|
||||
{
|
||||
look_dir = gbuffer_billboard_vs_params[12].xyz;
|
||||
}
|
||||
@ -273,7 +273,7 @@ vs_gbuffer_billboard_source_glsl300es := u8.[
|
||||
0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x67,
|
||||
0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x32,0x5d,0x2e,0x78,
|
||||
0x20,0x3c,0x20,0x28,0x2d,0x31,0x30,0x2e,0x30,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x3e,0x20,0x28,0x2d,0x31,0x30,0x2e,0x30,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,
|
||||
0x69,0x72,0x20,0x3d,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,
|
||||
0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
@ -434,7 +434,7 @@ fs_gbuffer_billboard_source_glsl300es := u8.[
|
||||
float3 _53 = _24.offset - _24.cam;
|
||||
_53.y = 0.0;
|
||||
float3 look_dir = fast::normalize(_53);
|
||||
if (_24.faceDir.x < (-10.0))
|
||||
if (_24.faceDir.x > (-10.0))
|
||||
{
|
||||
look_dir = _24.faceDir;
|
||||
}
|
||||
@ -494,7 +494,7 @@ vs_gbuffer_billboard_source_metal_macos := u8.[
|
||||
0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,
|
||||
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x32,0x34,0x2e,0x66,0x61,0x63,0x65,
|
||||
0x44,0x69,0x72,0x2e,0x78,0x20,0x3c,0x20,0x28,0x2d,0x31,0x30,0x2e,0x30,0x29,0x29,
|
||||
0x44,0x69,0x72,0x2e,0x78,0x20,0x3e,0x20,0x28,0x2d,0x31,0x30,0x2e,0x30,0x29,0x29,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6c,
|
||||
0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x5f,0x32,0x34,0x2e,0x66,0x61,
|
||||
0x63,0x65,0x44,0x69,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -93,7 +93,7 @@ vs_sh_deferred_source_glsl430 := u8.[
|
||||
vec3 sh_eval(ivec3 probe, vec3 N)
|
||||
{
|
||||
int _35 = probe.x * 3;
|
||||
int _45 = (probe.z * 64) + probe.y;
|
||||
int _45 = (probe.z * 32) + probe.y;
|
||||
vec4 _65 = texelFetch(sh_chunk_sh_smp, ivec2(_35, _45), 0);
|
||||
vec4 _76 = texelFetch(sh_chunk_sh_smp, ivec2(_35 + 1, _45), 0);
|
||||
vec4 _87 = texelFetch(sh_chunk_sh_smp, ivec2(_35 + 2, _45), 0);
|
||||
@ -103,7 +103,7 @@ vs_sh_deferred_source_glsl430 := u8.[
|
||||
float sh_probe_energy(ivec3 probe)
|
||||
{
|
||||
int _176 = probe.x * 3;
|
||||
int _183 = (probe.z * 64) + probe.y;
|
||||
int _183 = (probe.z * 32) + probe.y;
|
||||
return max(0.88622701168060302734375 * ((texelFetch(sh_chunk_sh_smp, ivec2(_176, _183), 0).x + texelFetch(sh_chunk_sh_smp, ivec2(_176 + 1, _183), 0).x) + texelFetch(sh_chunk_sh_smp, ivec2(_176 + 2, _183), 0).x), 0.0);
|
||||
}
|
||||
|
||||
@ -196,10 +196,10 @@ vs_sh_deferred_source_glsl430 := u8.[
|
||||
discard;
|
||||
}
|
||||
mat4 _442 = mat4(sh_deferred_params[0], sh_deferred_params[1], sh_deferred_params[2], sh_deferred_params[3]);
|
||||
vec3 _466 = clamp((_404 - (sh_deferred_params[4].xyz - vec3(2.0))) * vec3(1.77777779102325439453125), vec3(0.0), vec3(63.0));
|
||||
vec3 _466 = clamp((_404 - (sh_deferred_params[4].xyz - vec3(2.0))) * vec3(0.888888895511627197265625), vec3(0.0), vec3(31.0));
|
||||
ivec3 _470 = ivec3(floor(_466));
|
||||
ivec3 param = _470;
|
||||
ivec3 param_1 = min((_470 + ivec3(1)), ivec3(63));
|
||||
ivec3 param_1 = min((_470 + ivec3(1)), ivec3(31));
|
||||
vec3 param_2 = fract(_466);
|
||||
vec3 param_3 = normalize(mat3(_442[0].xyz, _442[1].xyz, _442[2].xyz) * normalize(texture(gbuf_norm_sh_smp, quad_uv).xyz));
|
||||
frag_color = vec4(sh_eval_trilinear(param, param_1, param_2, param_3), 1.0);
|
||||
@ -231,7 +231,7 @@ fs_sh_deferred_source_glsl430 := u8.[
|
||||
0x20,0x4e,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x33,
|
||||
0x35,0x20,0x3d,0x20,0x70,0x72,0x6f,0x62,0x65,0x2e,0x78,0x20,0x2a,0x20,0x33,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x28,
|
||||
0x70,0x72,0x6f,0x62,0x65,0x2e,0x7a,0x20,0x2a,0x20,0x36,0x34,0x29,0x20,0x2b,0x20,
|
||||
0x70,0x72,0x6f,0x62,0x65,0x2e,0x7a,0x20,0x2a,0x20,0x33,0x32,0x29,0x20,0x2b,0x20,
|
||||
0x70,0x72,0x6f,0x62,0x65,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,
|
||||
0x34,0x20,0x5f,0x36,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,0x65,0x6c,0x46,0x65,0x74,
|
||||
0x63,0x68,0x28,0x73,0x68,0x5f,0x63,0x68,0x75,0x6e,0x6b,0x5f,0x73,0x68,0x5f,0x73,
|
||||
@ -277,7 +277,7 @@ fs_sh_deferred_source_glsl430 := u8.[
|
||||
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x31,0x37,0x36,0x20,
|
||||
0x3d,0x20,0x70,0x72,0x6f,0x62,0x65,0x2e,0x78,0x20,0x2a,0x20,0x33,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x31,0x38,0x33,0x20,0x3d,0x20,0x28,0x70,
|
||||
0x72,0x6f,0x62,0x65,0x2e,0x7a,0x20,0x2a,0x20,0x36,0x34,0x29,0x20,0x2b,0x20,0x70,
|
||||
0x72,0x6f,0x62,0x65,0x2e,0x7a,0x20,0x2a,0x20,0x33,0x32,0x29,0x20,0x2b,0x20,0x70,
|
||||
0x72,0x6f,0x62,0x65,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,
|
||||
0x72,0x6e,0x20,0x6d,0x61,0x78,0x28,0x30,0x2e,0x38,0x38,0x36,0x32,0x32,0x37,0x30,
|
||||
0x31,0x31,0x36,0x38,0x30,0x36,0x30,0x33,0x30,0x32,0x37,0x33,0x34,0x33,0x37,0x35,
|
||||
@ -440,33 +440,33 @@ fs_sh_deferred_source_glsl430 := u8.[
|
||||
0x20,0x63,0x6c,0x61,0x6d,0x70,0x28,0x28,0x5f,0x34,0x30,0x34,0x20,0x2d,0x20,0x28,
|
||||
0x73,0x68,0x5f,0x64,0x65,0x66,0x65,0x72,0x72,0x65,0x64,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x76,0x65,0x63,0x33,
|
||||
0x28,0x32,0x2e,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,0x31,
|
||||
0x2e,0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x39,0x31,0x30,0x32,0x33,0x32,0x35,0x34,
|
||||
0x33,0x39,0x34,0x35,0x33,0x31,0x32,0x35,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,
|
||||
0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x36,0x33,0x2e,0x30,0x29,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x76,0x65,0x63,0x33,0x20,0x5f,0x34,0x37,
|
||||
0x30,0x20,0x3d,0x20,0x69,0x76,0x65,0x63,0x33,0x28,0x66,0x6c,0x6f,0x6f,0x72,0x28,
|
||||
0x5f,0x34,0x36,0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x76,0x65,0x63,
|
||||
0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x5f,0x34,0x37,0x30,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x69,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,
|
||||
0x31,0x20,0x3d,0x20,0x6d,0x69,0x6e,0x28,0x28,0x5f,0x34,0x37,0x30,0x20,0x2b,0x20,
|
||||
0x69,0x76,0x65,0x63,0x33,0x28,0x31,0x29,0x29,0x2c,0x20,0x69,0x76,0x65,0x63,0x33,
|
||||
0x28,0x36,0x33,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x66,0x72,0x61,0x63,0x74,0x28,
|
||||
0x5f,0x34,0x36,0x36,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x69,0x7a,0x65,0x28,0x6d,0x61,0x74,0x33,0x28,0x5f,0x34,0x34,0x32,0x5b,0x30,0x5d,
|
||||
0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x34,0x34,0x32,0x5b,0x31,0x5d,0x2e,0x78,0x79,
|
||||
0x7a,0x2c,0x20,0x5f,0x34,0x34,0x32,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,
|
||||
0x2a,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x74,0x65,0x78,0x74,
|
||||
0x75,0x72,0x65,0x28,0x67,0x62,0x75,0x66,0x5f,0x6e,0x6f,0x72,0x6d,0x5f,0x73,0x68,
|
||||
0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,0x78,
|
||||
0x79,0x7a,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x73,0x68,0x5f,0x65,
|
||||
0x76,0x61,0x6c,0x5f,0x74,0x72,0x69,0x6c,0x69,0x6e,0x65,0x61,0x72,0x28,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x28,0x32,0x2e,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,0x30,
|
||||
0x2e,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x39,0x35,0x35,0x31,0x31,0x36,0x32,0x37,
|
||||
0x31,0x39,0x37,0x32,0x36,0x35,0x36,0x32,0x35,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,
|
||||
0x28,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x33,0x31,0x2e,0x30,
|
||||
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x76,0x65,0x63,0x33,0x20,0x5f,0x34,
|
||||
0x37,0x30,0x20,0x3d,0x20,0x69,0x76,0x65,0x63,0x33,0x28,0x66,0x6c,0x6f,0x6f,0x72,
|
||||
0x28,0x5f,0x34,0x36,0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x76,0x65,
|
||||
0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x5f,0x34,0x37,0x30,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x69,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x5f,0x31,0x20,0x3d,0x20,0x6d,0x69,0x6e,0x28,0x28,0x5f,0x34,0x37,0x30,0x20,0x2b,
|
||||
0x20,0x69,0x76,0x65,0x63,0x33,0x28,0x31,0x29,0x29,0x2c,0x20,0x69,0x76,0x65,0x63,
|
||||
0x33,0x28,0x33,0x31,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,
|
||||
0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x66,0x72,0x61,0x63,0x74,
|
||||
0x28,0x5f,0x34,0x36,0x36,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,
|
||||
0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,
|
||||
0x6c,0x69,0x7a,0x65,0x28,0x6d,0x61,0x74,0x33,0x28,0x5f,0x34,0x34,0x32,0x5b,0x30,
|
||||
0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x34,0x34,0x32,0x5b,0x31,0x5d,0x2e,0x78,
|
||||
0x79,0x7a,0x2c,0x20,0x5f,0x34,0x34,0x32,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,
|
||||
0x20,0x2a,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x28,0x67,0x62,0x75,0x66,0x5f,0x6e,0x6f,0x72,0x6d,0x5f,0x73,
|
||||
0x68,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,
|
||||
0x78,0x79,0x7a,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x73,0x68,0x5f,
|
||||
0x65,0x76,0x61,0x6c,0x5f,0x74,0x72,0x69,0x6c,0x69,0x6e,0x65,0x61,0x72,0x28,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,
|
||||
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
@ -512,7 +512,7 @@ vs_sh_deferred_source_glsl300es := u8.[
|
||||
highp vec3 sh_eval(ivec3 probe, highp vec3 N)
|
||||
{
|
||||
int _35 = probe.x * 3;
|
||||
int _45 = (probe.z * 64) + probe.y;
|
||||
int _45 = (probe.z * 32) + probe.y;
|
||||
highp vec4 _65 = texelFetch(sh_chunk_sh_smp, ivec2(_35, _45), 0);
|
||||
highp vec4 _76 = texelFetch(sh_chunk_sh_smp, ivec2(_35 + 1, _45), 0);
|
||||
highp vec4 _87 = texelFetch(sh_chunk_sh_smp, ivec2(_35 + 2, _45), 0);
|
||||
@ -522,7 +522,7 @@ vs_sh_deferred_source_glsl300es := u8.[
|
||||
highp float sh_probe_energy(ivec3 probe)
|
||||
{
|
||||
int _176 = probe.x * 3;
|
||||
int _183 = (probe.z * 64) + probe.y;
|
||||
int _183 = (probe.z * 32) + probe.y;
|
||||
return max(0.88622701168060302734375 * ((texelFetch(sh_chunk_sh_smp, ivec2(_176, _183), 0).x + texelFetch(sh_chunk_sh_smp, ivec2(_176 + 1, _183), 0).x) + texelFetch(sh_chunk_sh_smp, ivec2(_176 + 2, _183), 0).x), 0.0);
|
||||
}
|
||||
|
||||
@ -615,10 +615,10 @@ vs_sh_deferred_source_glsl300es := u8.[
|
||||
discard;
|
||||
}
|
||||
highp mat4 _442 = mat4(sh_deferred_params[0], sh_deferred_params[1], sh_deferred_params[2], sh_deferred_params[3]);
|
||||
highp vec3 _466 = clamp((_404 - (sh_deferred_params[4].xyz - vec3(2.0))) * vec3(1.77777779102325439453125), vec3(0.0), vec3(63.0));
|
||||
highp vec3 _466 = clamp((_404 - (sh_deferred_params[4].xyz - vec3(2.0))) * vec3(0.888888895511627197265625), vec3(0.0), vec3(31.0));
|
||||
ivec3 _470 = ivec3(floor(_466));
|
||||
ivec3 param = _470;
|
||||
ivec3 param_1 = min((_470 + ivec3(1)), ivec3(63));
|
||||
ivec3 param_1 = min((_470 + ivec3(1)), ivec3(31));
|
||||
highp vec3 param_2 = fract(_466);
|
||||
highp vec3 param_3 = normalize(mat3(_442[0].xyz, _442[1].xyz, _442[2].xyz) * normalize(texture(gbuf_norm_sh_smp, quad_uv).xyz));
|
||||
frag_color = vec4(sh_eval_trilinear(param, param_1, param_2, param_3), 1.0);
|
||||
@ -651,7 +651,7 @@ fs_sh_deferred_source_glsl300es := u8.[
|
||||
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x33,0x35,0x20,0x3d,
|
||||
0x20,0x70,0x72,0x6f,0x62,0x65,0x2e,0x78,0x20,0x2a,0x20,0x33,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x28,0x70,0x72,0x6f,
|
||||
0x62,0x65,0x2e,0x7a,0x20,0x2a,0x20,0x36,0x34,0x29,0x20,0x2b,0x20,0x70,0x72,0x6f,
|
||||
0x62,0x65,0x2e,0x7a,0x20,0x2a,0x20,0x33,0x32,0x29,0x20,0x2b,0x20,0x70,0x72,0x6f,
|
||||
0x62,0x65,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x5f,0x36,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,0x65,0x6c,
|
||||
0x46,0x65,0x74,0x63,0x68,0x28,0x73,0x68,0x5f,0x63,0x68,0x75,0x6e,0x6b,0x5f,0x73,
|
||||
@ -698,7 +698,7 @@ fs_sh_deferred_source_glsl300es := u8.[
|
||||
0x72,0x6f,0x62,0x65,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,
|
||||
0x5f,0x31,0x37,0x36,0x20,0x3d,0x20,0x70,0x72,0x6f,0x62,0x65,0x2e,0x78,0x20,0x2a,
|
||||
0x20,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x31,0x38,0x33,
|
||||
0x20,0x3d,0x20,0x28,0x70,0x72,0x6f,0x62,0x65,0x2e,0x7a,0x20,0x2a,0x20,0x36,0x34,
|
||||
0x20,0x3d,0x20,0x28,0x70,0x72,0x6f,0x62,0x65,0x2e,0x7a,0x20,0x2a,0x20,0x33,0x32,
|
||||
0x29,0x20,0x2b,0x20,0x70,0x72,0x6f,0x62,0x65,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6d,0x61,0x78,0x28,0x30,0x2e,0x38,0x38,
|
||||
0x36,0x32,0x32,0x37,0x30,0x31,0x31,0x36,0x38,0x30,0x36,0x30,0x33,0x30,0x32,0x37,
|
||||
@ -869,33 +869,33 @@ fs_sh_deferred_source_glsl300es := u8.[
|
||||
0x28,0x73,0x68,0x5f,0x64,0x65,0x66,0x65,0x72,0x72,0x65,0x64,0x5f,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x76,0x65,0x63,
|
||||
0x33,0x28,0x32,0x2e,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,
|
||||
0x31,0x2e,0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x39,0x31,0x30,0x32,0x33,0x32,0x35,
|
||||
0x34,0x33,0x39,0x34,0x35,0x33,0x31,0x32,0x35,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,
|
||||
0x28,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x36,0x33,0x2e,0x30,
|
||||
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x76,0x65,0x63,0x33,0x20,0x5f,0x34,
|
||||
0x37,0x30,0x20,0x3d,0x20,0x69,0x76,0x65,0x63,0x33,0x28,0x66,0x6c,0x6f,0x6f,0x72,
|
||||
0x28,0x5f,0x34,0x36,0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x76,0x65,
|
||||
0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x5f,0x34,0x37,0x30,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x69,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x5f,0x31,0x20,0x3d,0x20,0x6d,0x69,0x6e,0x28,0x28,0x5f,0x34,0x37,0x30,0x20,0x2b,
|
||||
0x20,0x69,0x76,0x65,0x63,0x33,0x28,0x31,0x29,0x29,0x2c,0x20,0x69,0x76,0x65,0x63,
|
||||
0x33,0x28,0x36,0x33,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,
|
||||
0x20,0x66,0x72,0x61,0x63,0x74,0x28,0x5f,0x34,0x36,0x36,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
|
||||
0x28,0x6d,0x61,0x74,0x33,0x28,0x5f,0x34,0x34,0x32,0x5b,0x30,0x5d,0x2e,0x78,0x79,
|
||||
0x7a,0x2c,0x20,0x5f,0x34,0x34,0x32,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,
|
||||
0x5f,0x34,0x34,0x32,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x6e,
|
||||
0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x67,0x62,0x75,0x66,0x5f,0x6e,0x6f,0x72,0x6d,0x5f,0x73,0x68,0x5f,0x73,0x6d,
|
||||
0x70,0x2c,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,0x78,0x79,0x7a,0x29,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x73,0x68,0x5f,0x65,0x76,0x61,0x6c,
|
||||
0x5f,0x74,0x72,0x69,0x6c,0x69,0x6e,0x65,0x61,0x72,0x28,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x2c,0x20,0x31,0x2e,
|
||||
0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x30,0x2e,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x39,0x35,0x35,0x31,0x31,0x36,0x32,
|
||||
0x37,0x31,0x39,0x37,0x32,0x36,0x35,0x36,0x32,0x35,0x29,0x2c,0x20,0x76,0x65,0x63,
|
||||
0x33,0x28,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x33,0x31,0x2e,
|
||||
0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x76,0x65,0x63,0x33,0x20,0x5f,
|
||||
0x34,0x37,0x30,0x20,0x3d,0x20,0x69,0x76,0x65,0x63,0x33,0x28,0x66,0x6c,0x6f,0x6f,
|
||||
0x72,0x28,0x5f,0x34,0x36,0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x76,
|
||||
0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x5f,0x34,0x37,0x30,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6d,0x69,0x6e,0x28,0x28,0x5f,0x34,0x37,0x30,0x20,
|
||||
0x2b,0x20,0x69,0x76,0x65,0x63,0x33,0x28,0x31,0x29,0x29,0x2c,0x20,0x69,0x76,0x65,
|
||||
0x63,0x33,0x28,0x33,0x31,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,
|
||||
0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,
|
||||
0x3d,0x20,0x66,0x72,0x61,0x63,0x74,0x28,0x5f,0x34,0x36,0x36,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,
|
||||
0x65,0x28,0x6d,0x61,0x74,0x33,0x28,0x5f,0x34,0x34,0x32,0x5b,0x30,0x5d,0x2e,0x78,
|
||||
0x79,0x7a,0x2c,0x20,0x5f,0x34,0x34,0x32,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,
|
||||
0x20,0x5f,0x34,0x34,0x32,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,
|
||||
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x74,0x65,0x78,0x74,0x75,0x72,
|
||||
0x65,0x28,0x67,0x62,0x75,0x66,0x5f,0x6e,0x6f,0x72,0x6d,0x5f,0x73,0x68,0x5f,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,0x78,0x79,0x7a,
|
||||
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
|
||||
0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x73,0x68,0x5f,0x65,0x76,0x61,
|
||||
0x6c,0x5f,0x74,0x72,0x69,0x6c,0x69,0x6e,0x65,0x61,0x72,0x28,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
@ -1022,7 +1022,7 @@ vs_sh_deferred_source_metal_macos := u8.[
|
||||
float3 sh_eval(thread const int3& probe, thread const float3& N, texture2d<float> sh_chunk, sampler sh_smp)
|
||||
{
|
||||
int _35 = probe.x * 3;
|
||||
int _45 = (probe.z * 64) + probe.y;
|
||||
int _45 = (probe.z * 32) + probe.y;
|
||||
float4 _65 = sh_chunk.read(uint2(int2(_35, _45)), 0);
|
||||
float4 _76 = sh_chunk.read(uint2(int2(_35 + 1, _45)), 0);
|
||||
float4 _87 = sh_chunk.read(uint2(int2(_35 + 2, _45)), 0);
|
||||
@ -1033,7 +1033,7 @@ vs_sh_deferred_source_metal_macos := u8.[
|
||||
float sh_probe_energy(thread const int3& probe, texture2d<float> sh_chunk, sampler sh_smp)
|
||||
{
|
||||
int _176 = probe.x * 3;
|
||||
int _183 = (probe.z * 64) + probe.y;
|
||||
int _183 = (probe.z * 32) + probe.y;
|
||||
return fast::max(0.88622701168060302734375 * ((sh_chunk.read(uint2(int2(_176, _183)), 0).x + sh_chunk.read(uint2(int2(_176 + 1, _183)), 0).x) + sh_chunk.read(uint2(int2(_176 + 2, _183)), 0).x), 0.0);
|
||||
}
|
||||
|
||||
@ -1130,10 +1130,10 @@ vs_sh_deferred_source_metal_macos := u8.[
|
||||
{
|
||||
discard_fragment();
|
||||
}
|
||||
float3 _466 = fast::clamp((_404 - (_359.chunk_origin.xyz - float3(2.0))) * float3(1.77777779102325439453125), float3(0.0), float3(63.0));
|
||||
float3 _466 = fast::clamp((_404 - (_359.chunk_origin.xyz - float3(2.0))) * float3(0.888888895511627197265625), float3(0.0), float3(31.0));
|
||||
int3 _470 = int3(floor(_466));
|
||||
int3 param = _470;
|
||||
int3 param_1 = min((_470 + int3(1)), int3(63));
|
||||
int3 param_1 = min((_470 + int3(1)), int3(31));
|
||||
float3 param_2 = fract(_466);
|
||||
float3 param_3 = fast::normalize(float3x3(_359.inv_view[0].xyz, _359.inv_view[1].xyz, _359.inv_view[2].xyz) * fast::normalize(gbuf_norm.sample(sh_smp, in.quad_uv).xyz));
|
||||
out.frag_color = float4(sh_eval_trilinear(param, param_1, param_2, param_3, sh_chunk, sh_smp, _359), 1.0);
|
||||
@ -1232,7 +1232,7 @@ fs_sh_deferred_source_metal_macos := u8.[
|
||||
0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x33,0x35,0x20,0x3d,0x20,0x70,
|
||||
0x72,0x6f,0x62,0x65,0x2e,0x78,0x20,0x2a,0x20,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x69,0x6e,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x28,0x70,0x72,0x6f,0x62,0x65,
|
||||
0x2e,0x7a,0x20,0x2a,0x20,0x36,0x34,0x29,0x20,0x2b,0x20,0x70,0x72,0x6f,0x62,0x65,
|
||||
0x2e,0x7a,0x20,0x2a,0x20,0x33,0x32,0x29,0x20,0x2b,0x20,0x70,0x72,0x6f,0x62,0x65,
|
||||
0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,
|
||||
0x36,0x35,0x20,0x3d,0x20,0x73,0x68,0x5f,0x63,0x68,0x75,0x6e,0x6b,0x2e,0x72,0x65,
|
||||
0x61,0x64,0x28,0x75,0x69,0x6e,0x74,0x32,0x28,0x69,0x6e,0x74,0x32,0x28,0x5f,0x33,
|
||||
@ -1284,7 +1284,7 @@ fs_sh_deferred_source_metal_macos := u8.[
|
||||
0x20,0x69,0x6e,0x74,0x20,0x5f,0x31,0x37,0x36,0x20,0x3d,0x20,0x70,0x72,0x6f,0x62,
|
||||
0x65,0x2e,0x78,0x20,0x2a,0x20,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,
|
||||
0x20,0x5f,0x31,0x38,0x33,0x20,0x3d,0x20,0x28,0x70,0x72,0x6f,0x62,0x65,0x2e,0x7a,
|
||||
0x20,0x2a,0x20,0x36,0x34,0x29,0x20,0x2b,0x20,0x70,0x72,0x6f,0x62,0x65,0x2e,0x79,
|
||||
0x20,0x2a,0x20,0x33,0x32,0x29,0x20,0x2b,0x20,0x70,0x72,0x6f,0x62,0x65,0x2e,0x79,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x66,0x61,0x73,
|
||||
0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x30,0x2e,0x38,0x38,0x36,0x32,0x32,0x37,0x30,
|
||||
0x31,0x31,0x36,0x38,0x30,0x36,0x30,0x33,0x30,0x32,0x37,0x33,0x34,0x33,0x37,0x35,
|
||||
@ -1485,39 +1485,39 @@ fs_sh_deferred_source_metal_macos := u8.[
|
||||
0x5f,0x34,0x30,0x34,0x20,0x2d,0x20,0x28,0x5f,0x33,0x35,0x39,0x2e,0x63,0x68,0x75,
|
||||
0x6e,0x6b,0x5f,0x6f,0x72,0x69,0x67,0x69,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x32,0x2e,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x31,0x2e,0x37,0x37,0x37,0x37,0x37,0x37,0x37,
|
||||
0x39,0x31,0x30,0x32,0x33,0x32,0x35,0x34,0x33,0x39,0x34,0x35,0x33,0x31,0x32,0x35,
|
||||
0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x29,0x2c,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x36,0x33,0x2e,0x30,0x29,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x69,0x6e,0x74,0x33,0x20,0x5f,0x34,0x37,0x30,0x20,0x3d,0x20,0x69,
|
||||
0x6e,0x74,0x33,0x28,0x66,0x6c,0x6f,0x6f,0x72,0x28,0x5f,0x34,0x36,0x36,0x29,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x20,0x3d,0x20,0x5f,0x34,0x37,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,
|
||||
0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6d,0x69,0x6e,0x28,
|
||||
0x28,0x5f,0x34,0x37,0x30,0x20,0x2b,0x20,0x69,0x6e,0x74,0x33,0x28,0x31,0x29,0x29,
|
||||
0x2c,0x20,0x69,0x6e,0x74,0x33,0x28,0x36,0x33,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,
|
||||
0x3d,0x20,0x66,0x72,0x61,0x63,0x74,0x28,0x5f,0x34,0x36,0x36,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,
|
||||
0x33,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x69,0x7a,0x65,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,0x28,0x5f,0x33,0x35,
|
||||
0x39,0x2e,0x69,0x6e,0x76,0x5f,0x76,0x69,0x65,0x77,0x5b,0x30,0x5d,0x2e,0x78,0x79,
|
||||
0x7a,0x2c,0x20,0x5f,0x33,0x35,0x39,0x2e,0x69,0x6e,0x76,0x5f,0x76,0x69,0x65,0x77,
|
||||
0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x35,0x39,0x2e,0x69,0x6e,
|
||||
0x76,0x5f,0x76,0x69,0x65,0x77,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,
|
||||
0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
|
||||
0x28,0x67,0x62,0x75,0x66,0x5f,0x6e,0x6f,0x72,0x6d,0x2e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x28,0x73,0x68,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x71,0x75,0x61,
|
||||
0x64,0x5f,0x75,0x76,0x29,0x2e,0x78,0x79,0x7a,0x29,0x29,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,0x73,0x68,0x5f,0x65,0x76,0x61,0x6c,
|
||||
0x5f,0x74,0x72,0x69,0x6c,0x69,0x6e,0x65,0x61,0x72,0x28,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x2c,0x20,0x73,0x68,0x5f,
|
||||
0x63,0x68,0x75,0x6e,0x6b,0x2c,0x20,0x73,0x68,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x5f,
|
||||
0x33,0x35,0x39,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x38,0x38,0x38,0x38,0x38,0x38,0x38,
|
||||
0x39,0x35,0x35,0x31,0x31,0x36,0x32,0x37,0x31,0x39,0x37,0x32,0x36,0x35,0x36,0x32,
|
||||
0x35,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x29,0x2c,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x33,0x31,0x2e,0x30,0x29,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x33,0x20,0x5f,0x34,0x37,0x30,0x20,0x3d,0x20,
|
||||
0x69,0x6e,0x74,0x33,0x28,0x66,0x6c,0x6f,0x6f,0x72,0x28,0x5f,0x34,0x36,0x36,0x29,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x33,0x20,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x20,0x3d,0x20,0x5f,0x34,0x37,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,
|
||||
0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6d,0x69,0x6e,
|
||||
0x28,0x28,0x5f,0x34,0x37,0x30,0x20,0x2b,0x20,0x69,0x6e,0x74,0x33,0x28,0x31,0x29,
|
||||
0x29,0x2c,0x20,0x69,0x6e,0x74,0x33,0x28,0x33,0x31,0x29,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,
|
||||
0x20,0x3d,0x20,0x66,0x72,0x61,0x63,0x74,0x28,0x5f,0x34,0x36,0x36,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x5f,0x33,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,
|
||||
0x6c,0x69,0x7a,0x65,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,0x28,0x5f,0x33,
|
||||
0x35,0x39,0x2e,0x69,0x6e,0x76,0x5f,0x76,0x69,0x65,0x77,0x5b,0x30,0x5d,0x2e,0x78,
|
||||
0x79,0x7a,0x2c,0x20,0x5f,0x33,0x35,0x39,0x2e,0x69,0x6e,0x76,0x5f,0x76,0x69,0x65,
|
||||
0x77,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x35,0x39,0x2e,0x69,
|
||||
0x6e,0x76,0x5f,0x76,0x69,0x65,0x77,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,
|
||||
0x2a,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,
|
||||
0x65,0x28,0x67,0x62,0x75,0x66,0x5f,0x6e,0x6f,0x72,0x6d,0x2e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x28,0x73,0x68,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x71,0x75,
|
||||
0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,0x78,0x79,0x7a,0x29,0x29,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,0x73,0x68,0x5f,0x65,0x76,0x61,
|
||||
0x6c,0x5f,0x74,0x72,0x69,0x6c,0x69,0x6e,0x65,0x61,0x72,0x28,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x2c,0x20,0x73,0x68,
|
||||
0x5f,0x63,0x68,0x75,0x6e,0x6b,0x2c,0x20,0x73,0x68,0x5f,0x73,0x6d,0x70,0x2c,0x20,
|
||||
0x5f,0x33,0x35,0x39,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||
0x00,
|
||||
];
|
||||
sh_deferred_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1491
src/shaders/jai/shader_trile_lod.jai
Normal file
1491
src/shaders/jai/shader_trile_lod.jai
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,32 +0,0 @@
|
||||
@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
|
||||
35
src/shaders/shader_bloom_downsample.glsl
Normal file
35
src/shaders/shader_bloom_downsample.glsl
Normal file
@ -0,0 +1,35 @@
|
||||
@vs vs_bloom_downsample
|
||||
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_downsample
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=0) uniform bloom_downsample_params {
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D bloom_downsample_src;
|
||||
layout(binding = 0) uniform sampler bloom_downsample_src_smp;
|
||||
|
||||
void main() {
|
||||
vec2 ts = vec2(src_texel_x, src_texel_y) * 0.5;
|
||||
vec3 a = texture(sampler2D(bloom_downsample_src, bloom_downsample_src_smp), texcoord + vec2(-ts.x, -ts.y)).rgb;
|
||||
vec3 b = texture(sampler2D(bloom_downsample_src, bloom_downsample_src_smp), texcoord + vec2( ts.x, -ts.y)).rgb;
|
||||
vec3 c = texture(sampler2D(bloom_downsample_src, bloom_downsample_src_smp), texcoord + vec2(-ts.x, ts.y)).rgb;
|
||||
vec3 d = texture(sampler2D(bloom_downsample_src, bloom_downsample_src_smp), texcoord + vec2( ts.x, ts.y)).rgb;
|
||||
frag_color = vec4((a + b + c + d) * 0.25, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program bloom_downsample vs_bloom_downsample fs_bloom_downsample
|
||||
39
src/shaders/shader_bloom_prefilter.glsl
Normal file
39
src/shaders/shader_bloom_prefilter.glsl
Normal file
@ -0,0 +1,39 @@
|
||||
@vs vs_bloom_prefilter
|
||||
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_prefilter
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=0) uniform bloom_prefilter_params {
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
float threshold;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D bloom_prefilter_src;
|
||||
layout(binding = 0) uniform sampler bloom_prefilter_src_smp;
|
||||
|
||||
void main() {
|
||||
vec2 ts = vec2(src_texel_x, src_texel_y) * 0.5;
|
||||
vec3 a = texture(sampler2D(bloom_prefilter_src, bloom_prefilter_src_smp), texcoord + vec2(-ts.x, -ts.y)).rgb;
|
||||
vec3 b = texture(sampler2D(bloom_prefilter_src, bloom_prefilter_src_smp), texcoord + vec2( ts.x, -ts.y)).rgb;
|
||||
vec3 c = texture(sampler2D(bloom_prefilter_src, bloom_prefilter_src_smp), texcoord + vec2(-ts.x, ts.y)).rgb;
|
||||
vec3 d = texture(sampler2D(bloom_prefilter_src, bloom_prefilter_src_smp), texcoord + vec2( ts.x, ts.y)).rgb;
|
||||
vec3 color = (a + b + c + d) * 0.25;
|
||||
float lum = dot(color, vec3(0.2126, 0.7152, 0.0722));
|
||||
if (lum < threshold) color = vec3(0.0);
|
||||
frag_color = vec4(color, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program bloom_prefilter vs_bloom_prefilter fs_bloom_prefilter
|
||||
39
src/shaders/shader_bloom_upsample.glsl
Normal file
39
src/shaders/shader_bloom_upsample.glsl
Normal file
@ -0,0 +1,39 @@
|
||||
@vs vs_bloom_upsample
|
||||
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_upsample
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=0) uniform bloom_upsample_params {
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D bloom_upsample_small;
|
||||
layout(binding = 0) uniform sampler bloom_upsample_small_smp;
|
||||
layout(binding = 1) uniform texture2D bloom_upsample_large;
|
||||
layout(binding = 1) uniform sampler bloom_upsample_large_smp;
|
||||
|
||||
void main() {
|
||||
vec2 ts = vec2(src_texel_x, src_texel_y) * 0.5;
|
||||
vec3 tent =
|
||||
texture(sampler2D(bloom_upsample_small, bloom_upsample_small_smp), texcoord + vec2(-ts.x, -ts.y)).rgb +
|
||||
texture(sampler2D(bloom_upsample_small, bloom_upsample_small_smp), texcoord + vec2( ts.x, -ts.y)).rgb +
|
||||
texture(sampler2D(bloom_upsample_small, bloom_upsample_small_smp), texcoord + vec2(-ts.x, ts.y)).rgb +
|
||||
texture(sampler2D(bloom_upsample_small, bloom_upsample_small_smp), texcoord + vec2( ts.x, ts.y)).rgb;
|
||||
vec3 large = texture(sampler2D(bloom_upsample_large, bloom_upsample_large_smp), texcoord).rgb;
|
||||
frag_color = vec4(tent * 0.25 + large, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program bloom_upsample vs_bloom_upsample fs_bloom_upsample
|
||||
@ -1,32 +0,0 @@
|
||||
@vs vs_dof
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_dof
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=0) uniform dof_params {
|
||||
float dof_treshold;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D dof_src;
|
||||
layout(binding = 0) uniform sampler dof_src_smp;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(sampler2D(dof_src, dof_src_smp), texcoord);
|
||||
float value = max(color.r, max(color.g, color.b));
|
||||
if(value < dof_treshold) { color = vec4(0.0, 0.0, 0.0, 1.0); }
|
||||
frag_color = vec4(color.rgb, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program dof vs_dof fs_dof
|
||||
48
src/shaders/shader_dof_blur.glsl
Normal file
48
src/shaders/shader_dof_blur.glsl
Normal file
@ -0,0 +1,48 @@
|
||||
@vs vs_dof_blur
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_dof_blur
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=0) uniform dof_blur_params {
|
||||
float bokeh_radius_x;
|
||||
float bokeh_radius_y;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D dof_blur_src;
|
||||
layout(binding = 0) uniform sampler dof_blur_src_smp;
|
||||
|
||||
void main() {
|
||||
const int NUM_SAMPLES = 32;
|
||||
const float GOLDEN_ANGLE = 2.39996323;
|
||||
|
||||
vec4 best = texture(sampler2D(dof_blur_src, dof_blur_src_smp), texcoord);
|
||||
float best_lum = dot(best.rgb, vec3(0.2126, 0.7152, 0.0722));
|
||||
|
||||
for (int i = 0; i < NUM_SAMPLES; i++) {
|
||||
float theta = float(i) * GOLDEN_ANGLE;
|
||||
float r = sqrt(float(i) / float(NUM_SAMPLES - 1) + 0.001);
|
||||
vec2 offset = vec2(cos(theta), sin(theta)) * r * vec2(bokeh_radius_x, bokeh_radius_y);
|
||||
vec4 s = texture(sampler2D(dof_blur_src, dof_blur_src_smp), texcoord + offset);
|
||||
float lum = dot(s.rgb, vec3(0.2126, 0.7152, 0.0722));
|
||||
if (lum > best_lum) {
|
||||
best = s;
|
||||
best_lum = lum;
|
||||
}
|
||||
}
|
||||
|
||||
frag_color = best;
|
||||
}
|
||||
@end
|
||||
|
||||
@program dof_blur vs_dof_blur fs_dof_blur
|
||||
25
src/shaders/shader_dof_downsample.glsl
Normal file
25
src/shaders/shader_dof_downsample.glsl
Normal file
@ -0,0 +1,25 @@
|
||||
@vs vs_dof_downsample
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_dof_downsample
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding = 0) uniform texture2D dof_downsample_src;
|
||||
layout(binding = 0) uniform sampler dof_downsample_src_smp;
|
||||
|
||||
void main() {
|
||||
frag_color = vec4(texture(sampler2D(dof_downsample_src, dof_downsample_src_smp), texcoord).rgb, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program dof_downsample vs_dof_downsample fs_dof_downsample
|
||||
@ -22,7 +22,7 @@ void main() {
|
||||
vec3 look_dir = offset - cam;
|
||||
look_dir.y = 0.0;
|
||||
look_dir = normalize(look_dir);
|
||||
if(faceDir.x < -10) look_dir = faceDir;
|
||||
if(faceDir.x > -10) look_dir = faceDir;
|
||||
vec3 world_right = normalize(cross(world_up, look_dir));
|
||||
vec3 world_pos = offset + (world_right * local_pos.x) + (world_up * local_pos.y);
|
||||
gl_Position = mvp * vec4(world_pos, 1.0);
|
||||
|
||||
@ -25,6 +25,11 @@ layout(binding = 3) uniform sampler dof_smp;
|
||||
layout(binding = 4) uniform texture2D pos_buf;
|
||||
layout(binding = 4) uniform sampler pos_smp;
|
||||
|
||||
layout(binding=1) uniform dof_config {
|
||||
float dof_max;
|
||||
float dof_point;
|
||||
};
|
||||
|
||||
layout(binding=0) uniform post_process_config {
|
||||
float exposure;
|
||||
float contrast;
|
||||
@ -43,14 +48,6 @@ layout(binding=0) uniform post_process_config {
|
||||
float bloom_amount;
|
||||
};
|
||||
|
||||
layout(binding=1) uniform dof_config {
|
||||
float dof_min;
|
||||
float dof_max;
|
||||
float dof_point;
|
||||
float dof_tex_width;
|
||||
float dof_tex_height;
|
||||
};
|
||||
|
||||
vec3 aces(vec3 x) {
|
||||
const float a = 2.51;
|
||||
const float b = 0.03;
|
||||
@ -129,11 +126,16 @@ void main() {
|
||||
float r = texture(sampler2D(pptex, ppsmp), distorted_texcoord + vec2(chromatic_aberration_intensity, 0.0)).r;
|
||||
float g = texture(sampler2D(pptex, ppsmp), distorted_texcoord).g;
|
||||
float b = texture(sampler2D(pptex, ppsmp), distorted_texcoord - vec2(chromatic_aberration_intensity, 0.0)).b;
|
||||
sampled_color_hdr = vec3(r,g,b + dof_min * 0.00000000000001);
|
||||
sampled_color_hdr = vec3(r,g,b);
|
||||
} else {
|
||||
sampled_color_hdr = texture(sampler2D(pptex, ppsmp), distorted_texcoord).rgb;
|
||||
}
|
||||
|
||||
float view_z = texture(sampler2D(pos_buf, pos_smp), distorted_texcoord).z;
|
||||
float depth = abs(view_z);
|
||||
float coc = smoothstep(0.0, 1.0, abs(depth - dof_point) / max(dof_max, 0.0001));
|
||||
vec3 dof_blurred = texture(sampler2D(dof_tex, dof_smp), distorted_texcoord).rgb;
|
||||
sampled_color_hdr = mix(sampled_color_hdr, dof_blurred, coc);
|
||||
|
||||
vec3 bloom_color = texture(sampler2D(bloom_tex, bloom_smp), distorted_texcoord).rgb;
|
||||
vec3 color_hdr = (sampled_color_hdr + bloom_color * bloom_amount) * exposure;
|
||||
|
||||
@ -28,7 +28,7 @@ const float PI = 3.14159265359;
|
||||
|
||||
vec3 sh_eval(ivec3 probe, vec3 N) {
|
||||
int base = probe.x * 3;
|
||||
int row = probe.z * 64 + probe.y;
|
||||
int row = probe.z * 32 + probe.y;
|
||||
vec4 t0 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base, row), 0);
|
||||
vec4 t1 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base+1, row), 0);
|
||||
vec4 t2 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base+2, row), 0);
|
||||
@ -41,7 +41,7 @@ vec3 sh_eval(ivec3 probe, vec3 N) {
|
||||
|
||||
float sh_probe_energy(ivec3 probe) {
|
||||
int base = probe.x * 3;
|
||||
int row = probe.z * 64 + probe.y;
|
||||
int row = probe.z * 32 + probe.y;
|
||||
vec4 t0 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base, row), 0);
|
||||
vec4 t1 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base+1, row), 0);
|
||||
vec4 t2 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base+2, row), 0);
|
||||
@ -90,10 +90,10 @@ void main() {
|
||||
vec3 world_norm = normalize(mat3(inv_view) * view_norm);
|
||||
|
||||
const float SH_PAD = 2.0;
|
||||
const float SH_SPACING = (32.0 + 2.0 * SH_PAD) / 64.0;
|
||||
vec3 probe_f = clamp((world_pos - (cmin - vec3(SH_PAD))) / SH_SPACING, vec3(0.0), vec3(63.0));
|
||||
const float SH_SPACING = (32.0 + 2.0 * SH_PAD) / 32.0;
|
||||
vec3 probe_f = clamp((world_pos - (cmin - vec3(SH_PAD))) / SH_SPACING, vec3(0.0), vec3(31.0));
|
||||
ivec3 p0 = ivec3(floor(probe_f));
|
||||
ivec3 p1 = min(p0 + ivec3(1), ivec3(63));
|
||||
ivec3 p1 = min(p0 + ivec3(1), ivec3(31));
|
||||
|
||||
frag_color = vec4(sh_eval_trilinear(p0, p1, fract(probe_f), world_norm), 1.0);
|
||||
}
|
||||
|
||||
@ -100,6 +100,8 @@ layout(binding=3) uniform trile_fs_params {
|
||||
int is_preview;
|
||||
vec3 indirect_tint;
|
||||
int sh_enabled;
|
||||
float fog_start;
|
||||
float fog_end;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D triletex;
|
||||
@ -270,7 +272,13 @@ void main() {
|
||||
light += (1.0 - Frough) * (1.0 - metallic) * indirectDiff / PI * albedo * ssao * indirect_diff_scale;
|
||||
|
||||
vec3 final_color = light + emissive;
|
||||
frag_color = vec4(mix(deepColor, final_color, smoothstep(0.0, planeHeight, vpos.y)), 1.0);
|
||||
final_color = mix(deepColor, final_color, smoothstep(0.0, planeHeight, vpos.y));
|
||||
|
||||
float fog_dist = length(vpos - cam);
|
||||
float fog_factor = smoothstep(fog_start, fog_end, fog_dist);
|
||||
final_color = mix(final_color, skyBase, fog_factor);
|
||||
|
||||
frag_color = vec4(final_color, 1.0);
|
||||
|
||||
if (is_preview == 1) frag_color.rgb = mix(frag_color.rgb, vec3(0.3, 0.7, 1.0), 0.5);
|
||||
else if (is_preview == 2) frag_color.rgb = mix(frag_color.rgb, vec3(1.0, 0.3, 0.2), 0.5);
|
||||
|
||||
97
src/shaders/shader_trile_lod.glsl
Normal file
97
src/shaders/shader_trile_lod.glsl
Normal file
@ -0,0 +1,97 @@
|
||||
@vs vs_trile_lod
|
||||
|
||||
in vec4 position;
|
||||
in vec4 normal;
|
||||
in vec4 color;
|
||||
in vec4 instance;
|
||||
|
||||
layout(binding=0) uniform trile_lod_vs_params {
|
||||
mat4 mvp;
|
||||
vec3 camera;
|
||||
};
|
||||
|
||||
out vec3 vpos;
|
||||
out vec3 cam;
|
||||
out vec3 vcolor;
|
||||
out vec3 vnorm;
|
||||
|
||||
mat3 rot_x(float a) { float c=cos(a),s=sin(a); return mat3(1,0,0, 0,c,-s, 0,s,c); }
|
||||
mat3 rot_y(float a) { float c=cos(a),s=sin(a); return mat3(c,0,s, 0,1,0, -s,0,c); }
|
||||
mat3 rot_z(float a) { float c=cos(a),s=sin(a); return mat3(c,-s,0, s,c,0, 0,0,1); }
|
||||
|
||||
mat3 get_orientation_matrix(int ori) {
|
||||
int face = ori / 4;
|
||||
int twist = ori % 4;
|
||||
float PI = 3.1415927;
|
||||
mat3 base;
|
||||
if (face == 0) base = mat3(1.0);
|
||||
else if (face == 1) base = rot_x(PI);
|
||||
else if (face == 2) base = rot_z(-PI*0.5);
|
||||
else if (face == 3) base = rot_z( PI*0.5);
|
||||
else if (face == 4) base = rot_x( PI*0.5);
|
||||
else base = rot_x(-PI*0.5);
|
||||
return base * rot_y(float(twist) * PI * 0.5);
|
||||
}
|
||||
|
||||
void main() {
|
||||
int ori = int(round(instance.w));
|
||||
mat3 rot = get_orientation_matrix(ori);
|
||||
vec3 local = position.xyz - 0.5;
|
||||
vec3 rotated = rot * local + 0.5;
|
||||
|
||||
gl_Position = mvp * vec4(rotated + instance.xyz, 1.0);
|
||||
vpos = rotated + instance.xyz;
|
||||
cam = camera;
|
||||
vcolor = color.xyz;
|
||||
vnorm = rot * normal.xyz;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_trile_lod
|
||||
|
||||
layout(binding=1) uniform trile_lod_fs_params {
|
||||
vec3 skyBase;
|
||||
vec3 sunPosition;
|
||||
vec3 sunLightColor;
|
||||
float sunIntensity;
|
||||
vec3 ambient_color;
|
||||
float ambient_intensity;
|
||||
float planeHeight;
|
||||
vec3 deepColor;
|
||||
int is_reflection;
|
||||
float fog_start;
|
||||
float fog_end;
|
||||
};
|
||||
|
||||
in vec3 vpos;
|
||||
in vec3 cam;
|
||||
in vec3 vcolor;
|
||||
in vec3 vnorm;
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
if (vpos.y < planeHeight - 0.01 && is_reflection == 1) discard;
|
||||
|
||||
const float PI = 3.1415927;
|
||||
vec3 N = normalize(vnorm);
|
||||
vec3 L = normalize(sunPosition);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
|
||||
vec3 lit;
|
||||
if (is_reflection == 1) {
|
||||
lit = vcolor * (NdotL * sunLightColor * sunIntensity + 0.1) / PI;
|
||||
} else {
|
||||
lit = vcolor * (NdotL * sunLightColor * sunIntensity + ambient_color * ambient_intensity) / PI;
|
||||
}
|
||||
|
||||
vec3 final_color = mix(deepColor, lit, smoothstep(0.0, planeHeight, vpos.y));
|
||||
|
||||
float fog_dist = length(vpos - cam);
|
||||
float fog_factor = smoothstep(fog_start, fog_end, fog_dist);
|
||||
final_color = mix(final_color, skyBase, fog_factor);
|
||||
|
||||
frag_color = vec4(final_color, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program trile_lod vs_trile_lod fs_trile_lod
|
||||
@ -7,6 +7,13 @@ trile_table : Table(string, Trile);
|
||||
|
||||
editor_current_trile : *Trile = null;
|
||||
|
||||
Trile_GFX_LOD :: struct {
|
||||
vertex_buffer : sg_buffer;
|
||||
normal_buffer : sg_buffer;
|
||||
color_buffer : sg_buffer;
|
||||
vertex_count : s64;
|
||||
}
|
||||
|
||||
Trile_GFX :: struct {
|
||||
trixel_colors : sg_image;
|
||||
vertex_buffer : sg_buffer;
|
||||
@ -14,6 +21,9 @@ Trile_GFX :: struct {
|
||||
centre_buffer : sg_buffer;
|
||||
vertices : []float;
|
||||
vertex_count : s64;
|
||||
|
||||
lod_4 : Trile_GFX_LOD; // 4^3 cube grid
|
||||
lod_2 : Trile_GFX_LOD; // 2^3 cube grid
|
||||
};
|
||||
|
||||
get_trile_table_ptr :: () -> *Table(string, Trile) {
|
||||
@ -49,6 +59,8 @@ set_trile_gfx :: (name: string, gfx: Trile_GFX, skip_preexist_check: bool = fals
|
||||
sg_destroy_buffer(old_gfx.normal_buffer);
|
||||
sg_destroy_buffer(old_gfx.centre_buffer);
|
||||
sg_destroy_image(old_gfx.trixel_colors);
|
||||
destroy_trile_gfx_lod(*old_gfx.lod_4);
|
||||
destroy_trile_gfx_lod(*old_gfx.lod_2);
|
||||
array_reset(*old_gfx.vertices);
|
||||
log_debug("Destroyed old GFX buffers for trile: %", name);
|
||||
}
|
||||
@ -65,6 +77,8 @@ set_trile :: (name: string, trile: Trile) {
|
||||
sg_destroy_buffer(old_gfx.normal_buffer);
|
||||
sg_destroy_buffer(old_gfx.centre_buffer);
|
||||
sg_destroy_image(old_gfx.trixel_colors);
|
||||
destroy_trile_gfx_lod(*old_gfx.lod_4);
|
||||
destroy_trile_gfx_lod(*old_gfx.lod_2);
|
||||
array_reset(*old_gfx.vertices);
|
||||
table_remove(*trile_gfx_table, name);
|
||||
}
|
||||
@ -95,6 +109,8 @@ rename_trile :: (old_name: string, new_name: string) {
|
||||
sg_destroy_buffer(old_gfx.normal_buffer);
|
||||
sg_destroy_buffer(old_gfx.centre_buffer);
|
||||
sg_destroy_image(old_gfx.trixel_colors);
|
||||
destroy_trile_gfx_lod(*old_gfx.lod_4);
|
||||
destroy_trile_gfx_lod(*old_gfx.lod_2);
|
||||
array_reset(*old_gfx.vertices);
|
||||
table_remove(*trile_gfx_table, old_name);
|
||||
}
|
||||
@ -112,6 +128,8 @@ delete_trile :: (name: string) {
|
||||
sg_destroy_buffer(old_gfx.normal_buffer);
|
||||
sg_destroy_buffer(old_gfx.centre_buffer);
|
||||
sg_destroy_image(old_gfx.trixel_colors);
|
||||
destroy_trile_gfx_lod(*old_gfx.lod_4);
|
||||
destroy_trile_gfx_lod(*old_gfx.lod_2);
|
||||
array_reset(*old_gfx.vertices);
|
||||
table_remove(*trile_gfx_table, name);
|
||||
}
|
||||
@ -185,22 +203,25 @@ Trixel :: struct {
|
||||
};
|
||||
|
||||
Trile :: struct {
|
||||
name : string = "test";
|
||||
trixels : [16][16][16] Trixel;
|
||||
name : string = "test";
|
||||
is_opaque : bool = true;
|
||||
trixels : [16][16][16] Trixel;
|
||||
};
|
||||
|
||||
TrixelSerialize :: [5]u8;
|
||||
|
||||
TrileSerialize :: struct {
|
||||
name : string = "test";
|
||||
version : int = 0;
|
||||
trixels : [16][16][16] TrixelSerialize;
|
||||
name : string = "test";
|
||||
version : int = 0;
|
||||
is_opaque : u8 = 1;
|
||||
trixels : [16][16][16] TrixelSerialize;
|
||||
};
|
||||
|
||||
trile_to_serialize_form :: (t: Trile) -> TrileSerialize {
|
||||
ts := TrileSerialize.{
|
||||
name = t.name,
|
||||
version = 1,
|
||||
name = t.name,
|
||||
version = 2,
|
||||
is_opaque = ifx t.is_opaque then cast(u8)1 else cast(u8)0,
|
||||
};
|
||||
for i: 0..15 {
|
||||
for j: 0..15 {
|
||||
@ -215,6 +236,8 @@ trile_to_serialize_form :: (t: Trile) -> TrileSerialize {
|
||||
|
||||
trile_from_serialize_form :: (ts: TrileSerialize) -> Trile {
|
||||
t := Trile.{ name = sprint("%", ts.name) };
|
||||
if ts.version >= 2 t.is_opaque = ts.is_opaque != 0;
|
||||
else t.is_opaque = true;
|
||||
for i: 0..15 {
|
||||
for j: 0..15 {
|
||||
for k: 0..15 {
|
||||
|
||||
105
src/world.jai
105
src/world.jai
@ -46,6 +46,7 @@ Trile_Instance :: struct {
|
||||
Chunk_Trile_Group :: struct {
|
||||
trile_name: string;
|
||||
instances: [..]Trile_Instance;
|
||||
is_buried: [..]bool; // Runtime-only, parallel to instances. Not serialized.
|
||||
}
|
||||
|
||||
Chunk :: struct {
|
||||
@ -210,6 +211,7 @@ unload_current_world :: () {
|
||||
for *chunk: current_world.world.chunks {
|
||||
for *group: chunk.groups {
|
||||
array_free(group.instances);
|
||||
array_free(group.is_buried);
|
||||
}
|
||||
array_free(chunk.groups);
|
||||
}
|
||||
@ -224,6 +226,108 @@ set_loaded_world :: (world: World) {
|
||||
current_world.world = world;
|
||||
current_world.valid = true;
|
||||
resolve_emitter_definitions(*current_world.world);
|
||||
for *chunk: current_world.world.chunks {
|
||||
recompute_buried_for_chunk(*current_world.world, chunk);
|
||||
}
|
||||
}
|
||||
|
||||
is_cell_opaque :: (name: string) -> bool {
|
||||
if name.count == 0 return false;
|
||||
t, ok := get_trile(name);
|
||||
if !ok return false;
|
||||
return t.is_opaque;
|
||||
}
|
||||
|
||||
trile_at_world :: (world: *World, wx: s32, wy: s32, wz: s32) -> string {
|
||||
key := world_to_chunk_coord(wx, wy, wz);
|
||||
chunk := table_find_pointer(*world.chunks, key);
|
||||
if !chunk return "";
|
||||
lx, ly, lz := world_to_local(wx, wy, wz);
|
||||
for *group: chunk.groups {
|
||||
for inst: group.instances {
|
||||
if inst.x == lx && inst.y == ly && inst.z == lz {
|
||||
return group.trile_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
BURIED_DIRS :: s32.[ 1,0,0, -1,0,0, 0,1,0, 0,-1,0, 0,0,1, 0,0,-1 ];
|
||||
|
||||
compute_buried_at_world :: (world: *World, wx: s32, wy: s32, wz: s32) -> bool {
|
||||
for axis: 0..5 {
|
||||
nwx := wx + BURIED_DIRS[axis*3+0];
|
||||
nwy := wy + BURIED_DIRS[axis*3+1];
|
||||
nwz := wz + BURIED_DIRS[axis*3+2];
|
||||
if !is_cell_opaque(trile_at_world(world, nwx, nwy, nwz)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
recompute_buried_for_chunk :: (world: *World, chunk: *Chunk) {
|
||||
// Build an O(1) local lookup grid (32^3 trile names) for this chunk so the
|
||||
// common in-chunk neighbor case is a single index lookup. Cross-chunk
|
||||
// neighbors fall back to trile_at_world.
|
||||
GRID :: CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE;
|
||||
grid: [GRID] string;
|
||||
grid_data := grid;
|
||||
for *group: chunk.groups {
|
||||
for inst: group.instances {
|
||||
idx := cast(int)inst.x + CHUNK_SIZE * (cast(int)inst.y + CHUNK_SIZE * cast(int)inst.z);
|
||||
grid_data[idx] = group.trile_name;
|
||||
}
|
||||
}
|
||||
|
||||
for *group: chunk.groups {
|
||||
array_resize(*group.is_buried, group.instances.count);
|
||||
for inst, i: group.instances {
|
||||
wx, wy, wz := chunk_local_to_world(chunk.coord, inst.x, inst.y, inst.z);
|
||||
buried := true;
|
||||
for axis: 0..5 {
|
||||
nwx := wx + BURIED_DIRS[axis*3+0];
|
||||
nwy := wy + BURIED_DIRS[axis*3+1];
|
||||
nwz := wz + BURIED_DIRS[axis*3+2];
|
||||
neighbor_name: string;
|
||||
nkey := world_to_chunk_coord(nwx, nwy, nwz);
|
||||
if nkey == chunk.coord {
|
||||
nlx, nly, nlz := world_to_local(nwx, nwy, nwz);
|
||||
nidx := cast(int)nlx + CHUNK_SIZE * (cast(int)nly + CHUNK_SIZE * cast(int)nlz);
|
||||
neighbor_name = grid_data[nidx];
|
||||
} else {
|
||||
neighbor_name = trile_at_world(world, nwx, nwy, nwz);
|
||||
}
|
||||
if !is_cell_opaque(neighbor_name) {
|
||||
buried = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
group.is_buried[i] = buried;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recompute_buried_at_cell :: (world: *World, wx: s32, wy: s32, wz: s32) {
|
||||
key := world_to_chunk_coord(wx, wy, wz);
|
||||
chunk := table_find_pointer(*world.chunks, key);
|
||||
if !chunk return;
|
||||
lx, ly, lz := world_to_local(wx, wy, wz);
|
||||
for *group: chunk.groups {
|
||||
for inst, i: group.instances {
|
||||
if inst.x == lx && inst.y == ly && inst.z == lz {
|
||||
if group.is_buried.count != group.instances.count array_resize(*group.is_buried, group.instances.count);
|
||||
group.is_buried[i] = compute_buried_at_world(world, wx, wy, wz);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
invalidate_buried_around :: (world: *World, wx: s32, wy: s32, wz: s32) {
|
||||
recompute_buried_at_cell(world, wx, wy, wz);
|
||||
for axis: 0..5 {
|
||||
recompute_buried_at_cell(world, wx + BURIED_DIRS[axis*3+0], wy + BURIED_DIRS[axis*3+1], wz + BURIED_DIRS[axis*3+2]);
|
||||
}
|
||||
}
|
||||
|
||||
resolve_emitter_definitions :: (world: *World) {
|
||||
@ -237,6 +341,7 @@ clear_world :: () {
|
||||
for *chunk: current_world.world.chunks {
|
||||
for *group: chunk.groups {
|
||||
array_free(group.instances);
|
||||
array_free(group.is_buried);
|
||||
}
|
||||
array_free(chunk.groups);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user