engine tooling work

This commit is contained in:
Tuomas Katajisto 2026-04-02 15:41:43 +03:00
parent 19b7aefa02
commit 435b544540
39 changed files with 7641 additions and 6144 deletions

Binary file not shown.

View File

@ -1,54 +0,0 @@
_______________
Vulkan Version:
- available: 1.4.309
- requesting: 1.3.0
______________________
Used Instance Layers :
VK_LAYER_KHRONOS_validation
Used Instance Extensions :
____________________
Devices : 1
0: AMD Radeon RX 6950 XT
- Compatible
Compatible physical devices found : 1
Using Device:
- Device Name : AMD Radeon RX 6950 XT
- Vendor : AMD
- Driver Version : 2.0.341
- API Version : 1.4.308
- Device Type : Discrete GPU
________________________
Used Device Extensions :
VK_KHR_deferred_host_operations
VK_KHR_acceleration_structure
VK_KHR_ray_query
BLAS Compaction: 2.6MB -> 0.9MB (1.7MB saved, 66.1% smaller)
_______________
Vulkan Version:
- available: 1.4.309
- requesting: 1.3.0
______________________
Used Instance Layers :
VK_LAYER_KHRONOS_validation
Used Instance Extensions :
____________________
Devices : 1
0: AMD Radeon RX 6950 XT
- Compatible
Compatible physical devices found : 1
Using Device:
- Device Name : AMD Radeon RX 6950 XT
- Vendor : AMD
- Driver Version : 2.0.341
- API Version : 1.4.308
- Device Type : Discrete GPU
________________________
Used Device Extensions :
VK_KHR_deferred_host_operations
VK_KHR_acceleration_structure
VK_KHR_ray_query
BLAS Compaction: 2.6MB -> 0.9MB (1.7MB saved, 66.1% smaller)

Binary file not shown.

View File

@ -47,7 +47,7 @@ Tacoma_Context :: struct {}
tacoma_init :: (base_path: *u8) -> *Tacoma_Context #foreign libtacoma; tacoma_init :: (base_path: *u8) -> *Tacoma_Context #foreign libtacoma;
tacoma_destroy :: (ctx: *Tacoma_Context) #foreign libtacoma; tacoma_destroy :: (ctx: *Tacoma_Context) #foreign libtacoma;
tacoma_load_scene :: (ctx: *Tacoma_Context, sky: Sky_Config, ts: Trile_Set, world: World, include_water: s32) #foreign libtacoma; tacoma_load_scene :: (ctx: *Tacoma_Context, sky: Sky_Config, ts: Trile_Set, world: World, include_water: s32) #foreign libtacoma;
tacoma_render_rdm :: (ctx: *Tacoma_Context, world_trile_index: s32, roughness: s32, quality: s32, out_width: *s32, out_height: *s32) -> *float #foreign libtacoma; tacoma_render_rdm :: (ctx: *Tacoma_Context, world_trile_index: s32, roughness: s32, quality: s32, size: s32) -> *float #foreign libtacoma;
tacoma_render_reference :: (ctx: *Tacoma_Context, width: s32, height: s32, eye: Vector3, target: Vector3, roughness: float, quality: s32) -> *float #foreign libtacoma; tacoma_render_reference :: (ctx: *Tacoma_Context, width: s32, height: s32, eye: Vector3, target: Vector3, roughness: float, quality: s32) -> *float #foreign libtacoma;
tacoma_free_result :: (data: *float) #foreign libtacoma; tacoma_free_result :: (data: *float) #foreign libtacoma;

View File

@ -1,4 +1,4 @@
master_volume 0.642776 master_volume 0.475357
music_volume 0.522385 music_volume 0.522385
sfx_volume 1 sfx_volume 1
fullscreen 0 fullscreen 0

View File

@ -6,10 +6,23 @@ Pool :: #import "Pool";
#load "loaders.jai"; #load "loaders.jai";
MAIN_CHUNK_BUFFER_SIZE : s64 : 256 * 1024;
RDM_CHUNK_BUFFER_SIZE : s64 : 64 * 1024 * 1024;
Active_Fetch :: struct {
occupied : bool;
req : Fetch_Request;
accumulated : [..]u8;
chunk_buf : []u8;
}
// Shared types and the global must be #scope_export so that rdm_loader.jai // Shared types and the global must be #scope_export so that rdm_loader.jai
// (a separate file, even when #load-ed) can access them. // (a separate file, even when #load-ed) can access them.
#scope_export #scope_export
CHANNEL_MAIN : u32 : 0;
CHANNEL_RDM : u32 : 1;
Fetch_Type :: enum { Fetch_Type :: enum {
PACK; PACK;
WORLD; WORLD;
@ -35,13 +48,12 @@ Fetch_Request :: struct {
} }
Asset_Manager :: struct { Asset_Manager :: struct {
fetch_queue : [..]Fetch_Request; active : [2]Active_Fetch;
is_fetching : bool; main_queue : [..]Fetch_Request;
current_fetch : Fetch_Request; rdm_queue : [..]Fetch_Request;
loadedPacks : [..]Loaded_Pack; loadedPacks : [..]Loaded_Pack;
pending_hot_reload : bool; pending_hot_reload : bool;
hot_reload_unpause_pending : bool; hot_reload_unpause_pending : bool;
frames_waited : int;
} }
g_asset_manager : Asset_Manager; g_asset_manager : Asset_Manager;
@ -50,66 +62,104 @@ g_asset_manager : Asset_Manager;
#load "rdm_loader.jai"; #load "rdm_loader.jai";
MAX_FILE_SIZE :: 600_000_000;
RDM_ATLAS_MAX_BYTES :: 4096 * 4096 * 4 * 4 + size_of(RDM_File_Header);
RDM_LOOKUP_MAX_BYTES :: 512 * 512 * 4 * 4 + size_of(RDM_File_Header);
buf : []u8;
world_buf : []u8;
world_chunks_buf : []u8;
rdm_atlas_buf : []u8;
rdm_lookup_buf : []u8;
buffer_for_fetch :: (type: Fetch_Type) -> (*u8, u64) {
if type == .PACK return buf.data, xx buf.count;
if type == .WORLD return world_buf.data, xx world_buf.count;
if type == .WORLD_CHUNKS return world_chunks_buf.data, xx world_chunks_buf.count;
if type == .RDM_ATLAS return rdm_atlas_buf.data, xx rdm_atlas_buf.count;
if type == .RDM_LOOKUP return rdm_lookup_buf.data, xx rdm_lookup_buf.count;
return null, 0;
}
fetch_callback :: (res: *sfetch_response_t) #c_call { fetch_callback :: (res: *sfetch_response_t) #c_call {
push_context,defer_pop default_context; push_context,defer_pop default_context;
req := g_asset_manager.current_fetch; af := *g_asset_manager.active[res.channel];
g_asset_manager.is_fetching = false;
if res.fetched {
chunk_count := res.data.size.(s64);
needed := af.accumulated.count + chunk_count;
if af.accumulated.allocated < needed {
new_cap := max(needed, max(af.accumulated.allocated * 2, 1024 * 1024));
array_reserve(*af.accumulated, new_cap);
}
memcpy(af.accumulated.data + af.accumulated.count, res.data.ptr, chunk_count);
af.accumulated.count = needed;
}
if !res.finished then return;
// Mark channel free before processing so that enqueued follow-up requests
// (WORLD -> WORLD_CHUNKS, RDM_ATLAS -> RDM_LOOKUP) are visible on the next tick.
af.occupied = false;
req := af.req;
if res.failed {
handle_fetch_failed(*req);
array_reset(*af.accumulated);
return;
}
data : []u8;
data.data = af.accumulated.data;
data.count = af.accumulated.count;
process_completed_fetch(*req, data);
if req.type == .PACK {
// process_completed_fetch either stored data in Loaded_Pack.data_buffer or
// freed it on parse failure. Either way, zero af.accumulated without freeing.
af.accumulated.data = null;
af.accumulated.count = 0;
af.accumulated.allocated = 0;
} else {
array_reset(*af.accumulated);
}
}
handle_fetch_failed :: (req: *Fetch_Request) {
if req.type == { if req.type == {
case .PACK; case .PACK;
if res.failed { log_error("Failed to load pack '%'", req.pack_name);
log_error("Failed to load pack '%'", req.pack_name);
case .WORLD;
if ends_with(req.path, "world.json") {
fallback_req : Fetch_Request;
fallback_req.type = .WORLD;
fallback_req.world_name = req.world_name;
fallback_req.path = sprint("%/worlds/%/index.world", GAME_RESOURCES_DIR, req.world_name);
fallback_req.should_block = true;
array_add(*g_asset_manager.main_queue, fallback_req);
return; return;
} }
mem := NewArray(res.data.size.(s64), u8, false); log_error("Failed to load world '%'", req.world_name);
memcpy(mem.data, res.data.ptr, res.data.size.(s64));
case .WORLD_CHUNKS;
free(req.world_json_data.data);
log_error("Failed to load chunks.bin for world '%'", req.world_name);
case .RDM_ATLAS;
log_error("RDM: failed to load atlas for chunk %", req.chunk_key);
case .RDM_LOOKUP;
if req.rdm_pending_atlas.id != 0 then sg_destroy_image(req.rdm_pending_atlas);
log_error("RDM: failed to load lookup for chunk %", req.chunk_key);
}
}
process_completed_fetch :: (req: *Fetch_Request, data: []u8) {
if req.type == {
case .PACK;
pack: Loaded_Pack; pack: Loaded_Pack;
Pool.set_allocators(*pack.pool); Pool.set_allocators(*pack.pool);
pack.nameHash = hash.get_hash(req.pack_name); pack.nameHash = hash.get_hash(req.pack_name);
pack.name = sprint("%", req.pack_name); pack.name = sprint("%", req.pack_name);
success := init_from_memory(*pack.content, mem, sprint("%", req.pack_name)); pack.data_buffer = data;
if !success { log_error("Failed to load pack!!"); return; } success := init_from_memory(*pack.content, pack.data_buffer, sprint("%", req.pack_name));
if !success {
log_error("Failed to load pack!!");
free(pack.data_buffer.data);
pack.data_buffer = .{};
return;
}
add_resources_from_pack(*pack); add_resources_from_pack(*pack);
array_add(*g_asset_manager.loadedPacks, pack); array_add(*g_asset_manager.loadedPacks, pack);
case .WORLD; case .WORLD;
if res.failed {
if ends_with(req.path, "world.json") {
fallback_req : Fetch_Request;
fallback_req.type = .WORLD;
fallback_req.world_name = req.world_name;
fallback_req.path = sprint("%/worlds/%/index.world", GAME_RESOURCES_DIR, req.world_name);
fallback_req.should_block = true;
array_add(*g_asset_manager.fetch_queue, fallback_req);
return;
}
log_error("Failed to load world '%'", req.world_name);
return;
}
data: []u8;
data.data = res.data.ptr;
data.count = res.data.size.(s64);
is_json := data.count > 0 && data[0] == #char "{"; is_json := data.count > 0 && data[0] == #char "{";
if is_json { if is_json {
json_copy := NewArray(data.count, u8, false); json_copy := NewArray(data.count, u8, false);
@ -120,13 +170,13 @@ fetch_callback :: (res: *sfetch_response_t) #c_call {
chunks_req.path = sprint("%/worlds/%/chunks.bin", GAME_RESOURCES_DIR, req.world_name); chunks_req.path = sprint("%/worlds/%/chunks.bin", GAME_RESOURCES_DIR, req.world_name);
chunks_req.should_block = true; chunks_req.should_block = true;
chunks_req.world_json_data = json_copy; chunks_req.world_json_data = json_copy;
array_add(*g_asset_manager.fetch_queue, chunks_req); array_add(*g_asset_manager.main_queue, chunks_req);
} else { } else {
world, ok := load_world_from_data(data); world, ok := load_world_from_data(data);
if ok { if ok {
set_loaded_world(world); set_loaded_world(world);
rdm_loader_enqueue_world(*get_current_world().world); rdm_loader_enqueue_world(*get_current_world().world);
log_info("Loaded world (legacy): %", world.name); log_info("Loaded world (legacy): %", req.world_name);
} else { } else {
log_error("Failed to parse world '%'", req.world_name); log_error("Failed to parse world '%'", req.world_name);
} }
@ -136,24 +186,15 @@ fetch_callback :: (res: *sfetch_response_t) #c_call {
json_data := req.world_json_data; json_data := req.world_json_data;
defer free(json_data.data); defer free(json_data.data);
if res.failed {
log_error("Failed to load chunks.bin for world '%'", req.world_name);
return;
}
json_str: string; json_str: string;
json_str.data = json_data.data; json_str.data = json_data.data;
json_str.count = json_data.count; json_str.count = json_data.count;
chunk_bin: []u8; world, ok := load_world_from_json(json_str, data);
chunk_bin.data = res.data.ptr;
chunk_bin.count = res.data.size.(s64);
world, ok := load_world_from_json(json_str, chunk_bin);
if ok { if ok {
set_loaded_world(world); set_loaded_world(world);
rdm_loader_enqueue_world(*get_current_world().world); rdm_loader_enqueue_world(*get_current_world().world);
log_info("Loaded world: %", world.name); log_info("Loaded world: %", req.world_name);
} else { } else {
log_error("Failed to parse world '%'", req.world_name); log_error("Failed to parse world '%'", req.world_name);
} }
@ -162,23 +203,19 @@ fetch_callback :: (res: *sfetch_response_t) #c_call {
curworld := get_current_world(); curworld := get_current_world();
if !curworld.valid || curworld.world.name != req.world_name then return; if !curworld.valid || curworld.world.name != req.world_name then return;
if res.failed {
log_error("RDM: failed to load atlas for chunk %", req.chunk_key);
return;
}
header_size := cast(s64) size_of(RDM_File_Header); header_size := cast(s64) size_of(RDM_File_Header);
if res.data.size < cast(u64) header_size { if data.count < header_size {
log_error("RDM: atlas too small for chunk %", req.chunk_key); log_error("RDM: atlas too small for chunk %", req.chunk_key);
return; return;
} }
header := cast(*RDM_File_Header) res.data.ptr; header := cast(*RDM_File_Header) data.data;
if header.magic != RDM_FILE_MAGIC { if header.magic != RDM_FILE_MAGIC {
log_error("RDM: bad atlas magic for chunk %", req.chunk_key); log_error("RDM: bad atlas magic for chunk %", req.chunk_key);
return; return;
} }
atlas_pixel_bytes := cast(u64) header.width * cast(u64) header.height * 4 * size_of(float); atlas_pixel_bytes := cast(u64) header.width * cast(u64) header.height * 4 * size_of(float);
atlas_imgdata : sg_image_data; atlas_imgdata : sg_image_data;
atlas_imgdata.subimage[0][0] = .{ res.data.ptr + header_size, atlas_pixel_bytes }; atlas_imgdata.subimage[0][0] = .{ data.data + header_size, atlas_pixel_bytes };
atlas_desc : sg_image_desc = .{ atlas_desc : sg_image_desc = .{
render_target = false, render_target = false,
width = header.width, width = header.width,
@ -187,8 +224,8 @@ fetch_callback :: (res: *sfetch_response_t) #c_call {
sample_count = 1, sample_count = 1,
data = atlas_imgdata, data = atlas_imgdata,
}; };
lookup_path: string;
chunk_ptr := table_find_pointer(*curworld.world.chunks, req.chunk_key); chunk_ptr := table_find_pointer(*curworld.world.chunks, req.chunk_key);
lookup_path: string;
if chunk_ptr != null && chunk_ptr.rdm_lookup_path.count > 0 { if chunk_ptr != null && chunk_ptr.rdm_lookup_path.count > 0 {
lookup_path = sprint("%/worlds/%/%", GAME_RESOURCES_DIR, req.world_name, chunk_ptr.rdm_lookup_path); lookup_path = sprint("%/worlds/%/%", GAME_RESOURCES_DIR, req.world_name, chunk_ptr.rdm_lookup_path);
} else { } else {
@ -200,24 +237,23 @@ fetch_callback :: (res: *sfetch_response_t) #c_call {
lookup_req.chunk_key = req.chunk_key; lookup_req.chunk_key = req.chunk_key;
lookup_req.path = lookup_path; lookup_req.path = lookup_path;
lookup_req.rdm_pending_atlas = sg_make_image(*atlas_desc); lookup_req.rdm_pending_atlas = sg_make_image(*atlas_desc);
array_add(*g_asset_manager.fetch_queue, lookup_req); array_add(*g_asset_manager.rdm_queue, lookup_req);
case .RDM_LOOKUP; case .RDM_LOOKUP;
curworld := get_current_world(); curworld := get_current_world();
world_ok := curworld.valid && curworld.world.name == req.world_name; world_ok := curworld.valid && curworld.world.name == req.world_name;
if res.failed || !world_ok { if !world_ok {
if res.failed then log_error("RDM: failed to load lookup for chunk %", req.chunk_key);
if req.rdm_pending_atlas.id != 0 then sg_destroy_image(req.rdm_pending_atlas); if req.rdm_pending_atlas.id != 0 then sg_destroy_image(req.rdm_pending_atlas);
return; return;
} }
header_size := cast(s64) size_of(RDM_File_Header); header_size := cast(s64) size_of(RDM_File_Header);
if res.data.size < cast(u64) header_size { if data.count < header_size {
log_error("RDM: lookup too small for chunk %", req.chunk_key); log_error("RDM: lookup too small for chunk %", req.chunk_key);
sg_destroy_image(req.rdm_pending_atlas); sg_destroy_image(req.rdm_pending_atlas);
return; return;
} }
header := cast(*RDM_File_Header) res.data.ptr; header := cast(*RDM_File_Header) data.data;
if header.magic != RDM_FILE_MAGIC { if header.magic != RDM_FILE_MAGIC {
log_error("RDM: bad lookup magic for chunk %", req.chunk_key); log_error("RDM: bad lookup magic for chunk %", req.chunk_key);
sg_destroy_image(req.rdm_pending_atlas); sg_destroy_image(req.rdm_pending_atlas);
@ -225,7 +261,7 @@ fetch_callback :: (res: *sfetch_response_t) #c_call {
} }
lookup_pixel_bytes := cast(u64) header.width * cast(u64) header.height * 4 * size_of(float); lookup_pixel_bytes := cast(u64) header.width * cast(u64) header.height * 4 * size_of(float);
lookup_imgdata : sg_image_data; lookup_imgdata : sg_image_data;
lookup_imgdata.subimage[0][0] = .{ res.data.ptr + header_size, lookup_pixel_bytes }; lookup_imgdata.subimage[0][0] = .{ data.data + header_size, lookup_pixel_bytes };
lookup_desc : sg_image_desc = .{ lookup_desc : sg_image_desc = .{
render_target = false, render_target = false,
width = header.width, width = header.width,
@ -236,17 +272,17 @@ fetch_callback :: (res: *sfetch_response_t) #c_call {
}; };
chunk := table_find_pointer(*curworld.world.chunks, req.chunk_key); chunk := table_find_pointer(*curworld.world.chunks, req.chunk_key);
if chunk != null { if chunk != null {
chunk.rdm_atlas = req.rdm_pending_atlas; chunk.rdm_atlas = req.rdm_pending_atlas;
chunk.rdm_lookup = sg_make_image(*lookup_desc); chunk.rdm_lookup = sg_make_image(*lookup_desc);
#if !FLAG_RELEASE_BUILD { #if !FLAG_RELEASE_BUILD {
chunk.rdm_lookup_w = header.width; chunk.rdm_lookup_w = header.width;
chunk.rdm_lookup_h = header.height; chunk.rdm_lookup_h = header.height;
num_floats := cast(s64)(header.width * header.height * 4); num_floats := cast(s64)(header.width * header.height * 4);
cpu_copy := NewArray(num_floats, float); cpu_copy := NewArray(num_floats, float);
memcpy(cpu_copy.data, res.data.ptr + header_size, cast(s64)lookup_pixel_bytes); memcpy(cpu_copy.data, data.data + header_size, cast(s64)lookup_pixel_bytes);
chunk.rdm_lookup_cpu = cpu_copy; chunk.rdm_lookup_cpu = cpu_copy;
} }
chunk.rdm_valid = true; chunk.rdm_valid = true;
log_debug("RDM: loaded chunk %", req.chunk_key); log_debug("RDM: loaded chunk %", req.chunk_key);
} else { } else {
sg_destroy_image(req.rdm_pending_atlas); sg_destroy_image(req.rdm_pending_atlas);
@ -256,13 +292,14 @@ fetch_callback :: (res: *sfetch_response_t) #c_call {
} }
Loaded_Pack :: struct { Loaded_Pack :: struct {
name : string; name : string;
nameHash : u32 = 0; nameHash : u32 = 0;
content : Load_Package; data_buffer : []u8;
textures : Table(string, sg_image); content : Load_Package;
animations : Table(string, Animation); textures : Table(string, sg_image);
audio : Table(string, Audio_Data); animations : Table(string, Animation);
pool : Pool.Pool; audio : Table(string, Audio_Data);
pool : Pool.Pool;
} }
add_resources_from_pack :: (pack: *Loaded_Pack) { add_resources_from_pack :: (pack: *Loaded_Pack) {
@ -365,9 +402,6 @@ add_resources_from_pack :: (pack: *Loaded_Pack) {
log_debug("Added anim(%)", anim.name); log_debug("Added anim(%)", anim.name);
} }
} }
// add_new_spritesheets_from_pack(*pack.content, pack.name);
// load_color_lut_images(*pack.content, pack.name);
} }
find_pack_by_name :: (name: string) -> (bool, Loaded_Pack) { find_pack_by_name :: (name: string) -> (bool, Loaded_Pack) {
@ -381,6 +415,31 @@ find_pack_by_name :: (name: string) -> (bool, Loaded_Pack) {
return false, .{}; return false, .{};
} }
dispatch_channel :: (queue: *[..]Fetch_Request, channel: u32) {
af := *g_asset_manager.active[channel];
if af.occupied || queue.count == 0 then return;
req := queue.data[0];
for i: 0..queue.count - 2 {
queue.data[i] = queue.data[i + 1];
}
queue.count -= 1;
af.occupied = true;
af.req = req;
af.accumulated.count = 0;
path_c := to_c_string(req.path);
defer free(path_c);
sfetch_send(*(sfetch_request_t.{
channel = channel,
path = path_c,
callback = fetch_callback,
chunk_size = cast(u32) af.chunk_buf.count,
buffer = .{ ptr = af.chunk_buf.data, size = cast(u64) af.chunk_buf.count },
}));
}
#scope_export #scope_export
free_resources_from_pack :: (pack: *Loaded_Pack) { free_resources_from_pack :: (pack: *Loaded_Pack) {
@ -389,27 +448,40 @@ free_resources_from_pack :: (pack: *Loaded_Pack) {
table_reset(*pack.audio); table_reset(*pack.audio);
table_reset(*pack.animations); table_reset(*pack.animations);
Pool.reset(*pack.pool); Pool.reset(*pack.pool);
if pack.data_buffer.data {
free(pack.data_buffer.data);
pack.data_buffer = .{};
}
} }
asset_manager_init :: () { asset_manager_init :: () {
buf = NewArray(MAX_FILE_SIZE, u8, false); g_asset_manager.active[CHANNEL_MAIN].chunk_buf = NewArray(MAIN_CHUNK_BUFFER_SIZE, u8, false);
world_buf = NewArray(MAX_FILE_SIZE, u8, false); g_asset_manager.active[CHANNEL_RDM].chunk_buf = NewArray(RDM_CHUNK_BUFFER_SIZE, u8, false);
world_chunks_buf = NewArray(MAX_FILE_SIZE, u8, false);
rdm_atlas_buf = NewArray(RDM_ATLAS_MAX_BYTES, u8, false);
rdm_lookup_buf = NewArray(RDM_LOOKUP_MAX_BYTES, u8, false);
} }
mandatory_loads_done :: () -> bool { mandatory_loads_done :: () -> bool {
if g_asset_manager.is_fetching && g_asset_manager.current_fetch.should_block_engine then return false; for channel: 0..1 {
for g_asset_manager.fetch_queue { af := *g_asset_manager.active[channel];
if af.occupied && af.req.should_block_engine then return false;
}
for g_asset_manager.main_queue {
if it.should_block_engine then return false;
}
for g_asset_manager.rdm_queue {
if it.should_block_engine then return false; if it.should_block_engine then return false;
} }
return true; return true;
} }
show_loading_screen :: () -> bool { show_loading_screen :: () -> bool {
if g_asset_manager.is_fetching && g_asset_manager.current_fetch.should_block then return true; for channel: 0..1 {
for g_asset_manager.fetch_queue { af := *g_asset_manager.active[channel];
if af.occupied && af.req.should_block then return true;
}
for g_asset_manager.main_queue {
if it.should_block then return true;
}
for g_asset_manager.rdm_queue {
if it.should_block then return true; if it.should_block then return true;
} }
return false; return false;
@ -417,7 +489,9 @@ show_loading_screen :: () -> bool {
asset_manager_tick :: () { asset_manager_tick :: () {
#if !FLAG_RELEASE_BUILD && OS != .WASM { #if !FLAG_RELEASE_BUILD && OS != .WASM {
if g_asset_manager.pending_hot_reload && !g_asset_manager.is_fetching && g_asset_manager.fetch_queue.count == 0 { if g_asset_manager.pending_hot_reload
&& !g_asset_manager.active[CHANNEL_MAIN].occupied
&& g_asset_manager.main_queue.count == 0 {
g_asset_manager.pending_hot_reload = false; g_asset_manager.pending_hot_reload = false;
hot_reload_all_packs(); hot_reload_all_packs();
} }
@ -427,29 +501,8 @@ asset_manager_tick :: () {
} }
} }
if !g_asset_manager.is_fetching && g_asset_manager.fetch_queue.count > 0 { dispatch_channel(*g_asset_manager.main_queue, CHANNEL_MAIN);
if g_asset_manager.frames_waited < 3 { dispatch_channel(*g_asset_manager.rdm_queue, CHANNEL_RDM);
g_asset_manager.frames_waited += 1;
} else {
g_asset_manager.frames_waited = 0;
req := g_asset_manager.fetch_queue[0];
// Ordered remove from front to preserve queue priority.
for i: 0..g_asset_manager.fetch_queue.count - 2 {
g_asset_manager.fetch_queue[i] = g_asset_manager.fetch_queue[i + 1];
}
g_asset_manager.fetch_queue.count -= 1;
g_asset_manager.current_fetch = req;
g_asset_manager.is_fetching = true;
buf_ptr, buf_size := buffer_for_fetch(req.type);
sfetch_send(*(sfetch_request_t.{
path = to_c_string(req.path),
callback = fetch_callback,
buffer = .{ ptr = buf_ptr, size = buf_size },
}));
}
}
sfetch_dowork(); sfetch_dowork();
} }
@ -461,7 +514,7 @@ load_world :: (name: string) {
req.world_name = sprint("%", name); req.world_name = sprint("%", name);
req.path = sprint("%/worlds/%/world.json", GAME_RESOURCES_DIR, name); req.path = sprint("%/worlds/%/world.json", GAME_RESOURCES_DIR, name);
req.should_block = true; req.should_block = true;
array_add(*g_asset_manager.fetch_queue, req); array_add(*g_asset_manager.main_queue, req);
} }
load_pack :: (name: string, shouldBlock: bool = true, shouldBlockEngine: bool = false) { load_pack :: (name: string, shouldBlock: bool = true, shouldBlockEngine: bool = false) {
@ -471,7 +524,7 @@ load_pack :: (name: string, shouldBlock: bool = true, shouldBlockEngine: bool =
req.path = sprint("%/%.pack", PACK_DIR, name); req.path = sprint("%/%.pack", PACK_DIR, name);
req.should_block = shouldBlock; req.should_block = shouldBlock;
req.should_block_engine = shouldBlockEngine; req.should_block_engine = shouldBlockEngine;
array_add(*g_asset_manager.fetch_queue, req); array_add(*g_asset_manager.main_queue, req);
} }
// Asset management: // Asset management:

View File

@ -75,8 +75,9 @@ load_wav_from_memory :: (data: []u8) -> Audio_Data {
audio_samples : []s16; audio_samples : []s16;
audio_samples.data = cast(*s16)samples.data; audio_samples.data = cast(*s16)samples.data;
audio_samples.count = samples.count / 2; audio_samples.count = samples.count / 2;
for sample: audio_samples { array_resize(*audio.data, audio_samples.count);
array_add(*audio.data, cast(float)sample / 32768.0); for i: 0..audio_samples.count - 1 {
audio.data[i] = cast(float)audio_samples[i] / 32768.0;
} }
audio.channels = format.nChannels; audio.channels = format.nChannels;
audio.sample_rate = format.nSamplesPerSec; audio.sample_rate = format.nSamplesPerSec;

View File

@ -8,16 +8,17 @@ rdm_loader_enqueue_world :: (world: *World) {
for *chunk: world.chunks { for *chunk: world.chunks {
if chunk.rdm_valid then continue; if chunk.rdm_valid then continue;
// Skip if this chunk is already in-flight. // Skip if this chunk is already in-flight on the RDM channel.
if g_asset_manager.is_fetching { af_rdm := *g_asset_manager.active[CHANNEL_RDM];
cf := g_asset_manager.current_fetch; if af_rdm.occupied {
cf := af_rdm.req;
if (cf.type == .RDM_ATLAS || cf.type == .RDM_LOOKUP) && if (cf.type == .RDM_ATLAS || cf.type == .RDM_LOOKUP) &&
cf.world_name == world.name && cf.chunk_key == chunk.coord then continue; cf.world_name == world.name && cf.chunk_key == chunk.coord then continue;
} }
// Skip if already queued (either as atlas or its follow-up lookup). // Skip if already queued (either as atlas or its follow-up lookup).
already_queued := false; already_queued := false;
for g_asset_manager.fetch_queue { for g_asset_manager.rdm_queue {
if (it.type == .RDM_ATLAS || it.type == .RDM_LOOKUP) && if (it.type == .RDM_ATLAS || it.type == .RDM_LOOKUP) &&
it.world_name == world.name && it.chunk_key == chunk.coord { it.world_name == world.name && it.chunk_key == chunk.coord {
already_queued = true; already_queued = true;
@ -35,34 +36,28 @@ rdm_loader_enqueue_world :: (world: *World) {
} else { } else {
req.path = rdm_chunk_filename(world.name, chunk.coord, "rdm_atlas"); req.path = rdm_chunk_filename(world.name, chunk.coord, "rdm_atlas");
} }
array_add(*g_asset_manager.fetch_queue, req); array_add(*g_asset_manager.rdm_queue, req);
} }
} }
// Remove all pending RDM fetches from the queue and invalidate any in-flight // Remove all pending RDM fetches from the queue and invalidate any in-flight
// RDM fetch so its callback discards the result. // RDM fetch so its callback discards the result.
rdm_loader_cancel_all :: () { rdm_loader_cancel_all :: () {
// Filter out RDM items, destroying any atlas images stored inside them. // Destroy any atlas images stored in queued RDM_LOOKUP requests, then drain.
new_count := 0; for i: 0..g_asset_manager.rdm_queue.count - 1 {
for i: 0..g_asset_manager.fetch_queue.count - 1 { item := g_asset_manager.rdm_queue[i];
item := g_asset_manager.fetch_queue[i]; if item.rdm_pending_atlas.id != 0 then sg_destroy_image(item.rdm_pending_atlas);
if item.type == .RDM_ATLAS || item.type == .RDM_LOOKUP {
if item.rdm_pending_atlas.id != 0 then sg_destroy_image(item.rdm_pending_atlas);
continue;
}
g_asset_manager.fetch_queue[new_count] = item;
new_count += 1;
} }
g_asset_manager.fetch_queue.count = new_count; array_reset(*g_asset_manager.rdm_queue);
// Blank the world name on the in-flight request so its callback discards. // Blank the world name on the in-flight RDM request so its callback discards.
if g_asset_manager.is_fetching && af := *g_asset_manager.active[CHANNEL_RDM];
(g_asset_manager.current_fetch.type == .RDM_ATLAS || if af.occupied &&
g_asset_manager.current_fetch.type == .RDM_LOOKUP) { (af.req.type == .RDM_ATLAS || af.req.type == .RDM_LOOKUP) {
if g_asset_manager.current_fetch.rdm_pending_atlas.id != 0 { if af.req.rdm_pending_atlas.id != 0 {
sg_destroy_image(g_asset_manager.current_fetch.rdm_pending_atlas); sg_destroy_image(af.req.rdm_pending_atlas);
g_asset_manager.current_fetch.rdm_pending_atlas = .{}; af.req.rdm_pending_atlas = .{};
} }
g_asset_manager.current_fetch.world_name = ""; af.req.world_name = "";
} }
} }

View File

@ -1,5 +1,6 @@
#if OS != .WASM { #if OS != .WASM {
#load "iprof.jai"; #load "iprof.jai";
#load "trile_thumbnails.jai";
#load "picker.jai"; #load "picker.jai";
#load "trile_editor.jai"; #load "trile_editor.jai";
#load "level_editor.jai"; #load "level_editor.jai";
@ -26,7 +27,10 @@ in_editor_view : bool = false;
init_editor :: () { init_editor :: () {
#if !FLAG_RELEASE_BUILD { #if !FLAG_RELEASE_BUILD {
#if OS != .WASM {init_profiler();} #if OS != .WASM {
init_profiler();
init_trile_thumbnails();
}
init_console(); init_console();
} }
init_keybinds(); init_keybinds();

View File

@ -56,7 +56,8 @@ inspector_y : s32;
inspector_z : s32; inspector_z : s32;
inspector_emitter_def : s32 = -1; inspector_emitter_def : s32 = -1;
inspector_rdm_roughness : int = 0; inspector_rdm_roughness : int = 0;
inspector_note_input : string = ""; inspector_note_deactivate : bool;
inspector_note_activate_next : bool;
editor_billboards_visible : bool = true; editor_billboards_visible : bool = true;
@ -505,6 +506,16 @@ remove_trile :: (x: s32, y: s32, z: s32) {
editor_edit_y :: () -> float {
y := cast(float)editY;
curworld := get_current_world();
if curworld.valid {
ph := effective_plane_height(*curworld.world.conf);
if ph > y && ph < y + 1.0 then y = ph + 0.01;
}
return y;
}
tick_level_editor :: () { tick_level_editor :: () {
#if FLAG_TACOMA_ENABLED { rdm_bake_tick(); } #if FLAG_TACOMA_ENABLED { rdm_bake_tick(); }
tick_level_editor_camera(); tick_level_editor_camera();
@ -532,7 +543,7 @@ tick_level_editor :: () {
} }
ray := get_mouse_ray(*get_level_editor_camera()); ray := get_mouse_ray(*get_level_editor_camera());
hit, point := ray_plane_collision_point(ray, xx editY, 20); hit, point := ray_plane_collision_point(ray, editor_edit_y(), 20);
show_trile_preview = false; show_trile_preview = false;
if hit { if hit {
@ -623,16 +634,7 @@ tick_level_editor :: () {
inspector_x = cast(s32)px; inspector_x = cast(s32)px;
inspector_y = cast(s32)py; inspector_y = cast(s32)py;
inspector_z = cast(s32)pz; inspector_z = cast(s32)pz;
inspector_note_input = ""; inspector_note_deactivate = true;
curworld2 := get_current_world();
if curworld2.valid {
for note: curworld2.world.notes {
if note.position.x == inspector_x && note.position.y == inspector_y && note.position.z == inspector_z {
inspector_note_input = note.text;
break;
}
}
}
} }
} }
} }
@ -773,10 +775,27 @@ draw_inspector_panel :: (r: *GR.Rect, theme: *GR.Overall_Theme) {
trile_name, orientation, has_trile := get_trile_at(world, inspector_x, inspector_y, inspector_z); trile_name, orientation, has_trile := get_trile_at(world, inspector_x, inspector_y, inspector_z);
if has_trile { if has_trile {
GR.label(r.*, tprint("Trile: % orient: %", trile_name, orientation), *t_label_left(theme)); GR.label(r.*, tprint("Trile: % orient: %", trile_name, orientation), *t_label_left(theme));
r.y += r.h;
#if FLAG_TACOMA_ENABLED {
r.h = ui_h(3, 2);
GR.label(r.*, "-- Bake Config --", *t_label_left(theme));
r.y += r.h;
r.h = ui_h(4, 0);
size_ov, qual_ov := get_rdm_instance_override(world, inspector_x, inspector_y, inspector_z);
GR.label(r.*, tprint("Size override (0=default): %", size_ov), *t_label_left(theme));
r.y += r.h;
GR.slider(r.*, *size_ov, 0, 512, 1, *theme.slider_theme);
r.y += r.h;
GR.label(r.*, tprint("Samples override (0=global): %", qual_ov), *t_label_left(theme));
r.y += r.h;
GR.slider(r.*, *qual_ov, 0, 10000, 10, *theme.slider_theme);
r.y += r.h;
set_rdm_instance_override(world, inspector_x, inspector_y, inspector_z, size_ov, qual_ov);
}
} else { } else {
GR.label(r.*, "Trile: (empty)", *t_label_left(theme)); GR.label(r.*, "Trile: (empty)", *t_label_left(theme));
r.y += r.h;
} }
r.y += r.h;
r.y += r.h * 0.5; r.y += r.h * 0.5;
GR.label(r.*, "-- Emitter --", *t_label_left(theme)); GR.label(r.*, "-- Emitter --", *t_label_left(theme));
@ -788,6 +807,18 @@ draw_inspector_panel :: (r: *GR.Rect, theme: *GR.Overall_Theme) {
GR.label(r.*, tprint("Def: %", inst.definition_name), *t_label_left(theme)); GR.label(r.*, tprint("Def: %", inst.definition_name), *t_label_left(theme));
r.y += r.h; r.y += r.h;
r.h = ui_h(4, 0); r.h = ui_h(4, 0);
GR.label(r.*, tprint("Offset X: %", formatFloat(inst.offset.x, trailing_width=2)), *t_label_left(theme));
r.y += r.h;
GR.slider(r.*, *inst.offset.x, -0.5, 0.5, 0.05, *theme.slider_theme);
r.y += r.h;
GR.label(r.*, tprint("Offset Y: %", formatFloat(inst.offset.y, trailing_width=2)), *t_label_left(theme));
r.y += r.h;
GR.slider(r.*, *inst.offset.y, -0.5, 0.5, 0.05, *theme.slider_theme);
r.y += r.h;
GR.label(r.*, tprint("Offset Z: %", formatFloat(inst.offset.z, trailing_width=2)), *t_label_left(theme));
r.y += r.h;
GR.slider(r.*, *inst.offset.z, -0.5, 0.5, 0.05, *theme.slider_theme);
r.y += r.h;
if GR.button(r.*, "Remove Emitter", *theme.button_theme, 300) { if GR.button(r.*, "Remove Emitter", *theme.button_theme, 300) {
array_ordered_remove_by_index(*world.emitter_instances, emitter_idx); array_ordered_remove_by_index(*world.emitter_instances, emitter_idx);
} }
@ -823,33 +854,32 @@ draw_inspector_panel :: (r: *GR.Rect, theme: *GR.Overall_Theme) {
r.y += r.h; r.y += r.h;
note_idx, has_note := find_note_at(world, inspector_x, inspector_y, inspector_z); note_idx, has_note := find_note_at(world, inspector_x, inspector_y, inspector_z);
note_input_action : GR.Text_Input_Action;
if inspector_note_activate_next {
note_input_action = .ACTIVATE;
inspector_note_activate_next = false;
} else if inspector_note_deactivate {
note_input_action = .DEACTIVATE;
inspector_note_deactivate = false;
}
if has_note { if has_note {
note := *world.notes[note_idx]; note := *world.notes[note_idx];
r.h = ui_h(4, 0); r.h = ui_h(4, 0);
a, new_text, _ := GR.text_input(r.*, inspector_note_input, *theme.text_input_theme, 500); a, new_text, _ := GR.text_input(r.*, note.text, *theme.text_input_theme, 500, input_action = note_input_action);
if a & .ENTERED { if (a & .TEXT_MODIFIED) || (a & .ENTERED) note.text = copy_string(new_text);
note.text = copy_string(new_text);
inspector_note_input = note.text;
}
r.y += r.h; r.y += r.h;
if GR.button(r.*, "Remove Note", *theme.button_theme, 302) { if GR.button(r.*, "Remove Note", *theme.button_theme, 302) {
array_ordered_remove_by_index(*world.notes, note_idx); array_ordered_remove_by_index(*world.notes, note_idx);
inspector_note_input = "";
} }
r.y += r.h; r.y += r.h;
} else { } else {
r.h = ui_h(4, 0); r.h = ui_h(4, 0);
a, new_text, _ := GR.text_input(r.*, inspector_note_input, *theme.text_input_theme, 501);
if a & .ENTERED {
inspector_note_input = copy_string(new_text);
}
r.y += r.h;
if GR.button(r.*, "Add Note", *theme.button_theme, 303) { if GR.button(r.*, "Add Note", *theme.button_theme, 303) {
note : Editor_Note; note : Editor_Note;
note.position = .{inspector_x, inspector_y, inspector_z}; note.position = .{inspector_x, inspector_y, inspector_z};
note.text = copy_string(ifx inspector_note_input.count > 0 then inspector_note_input else "Note"); note.text = "";
array_add(*world.notes, note); array_add(*world.notes, note);
inspector_note_input = note.text; inspector_note_activate_next = true;
} }
r.y += r.h; r.y += r.h;
} }
@ -996,6 +1026,7 @@ draw_level_editor :: () {
create_level_editor_preview_tasks(); create_level_editor_preview_tasks();
} }
add_editor_billboards(); add_editor_billboards();
debug_grid(floor(cameraCenter.x), editor_edit_y(), floor(cameraCenter.y), 20, .{0.3, 0.3, 0.35, 0.7});
} }
draw_level_editor_ui :: (theme: *GR.Overall_Theme) { draw_level_editor_ui :: (theme: *GR.Overall_Theme) {

View File

@ -5,7 +5,114 @@ Picker :: enum {
WORLD; WORLD;
} }
current_picker : Picker = .TRILE; current_picker : Picker = .TRILE;
trile_search_text : string;
trile_picker_scroll : float;
draw_trile_picker :: (r_in: GR.Rect, theme: *GR.Overall_Theme) {
r := r_in;
row_h := ui_h(4, 4);
clear_w := ui_w(3, 3);
search_r := r;
search_r.h = row_h;
search_r.w = r.w - clear_w;
_, __, text_state := GR.text_input(search_r, trile_search_text, *theme.text_input_theme, 128);
clear_r := r;
clear_r.h = row_h;
clear_r.x = r.x + r.w - clear_w;
clear_r.w = clear_w;
if GR.button(clear_r, "x", *theme.button_theme) {
if trile_search_text.data free(trile_search_text);
trile_search_text = .{};
if text_state GR.set_input(text_state, "");
}
r.y += row_h;
r.h -= row_h;
current_search := ifx text_state then text_state.text else trile_search_text;
tpt := get_trile_table_ptr();
filtered : [..] string;
filtered.allocator = temp;
for v : tpt {
if !current_search.count || contains(v.name, current_search) {
array_add(*filtered, v.name);
}
}
padding : float = 3.0;
name_h := ui_h(1, 2);
cols : int = 3;
btn_theme := theme.button_theme;
btn_theme.surface_color = .{0, 0, 0, 0};
btn_theme.surface_color_over = .{1, 1, 1, 0.15};
btn_theme.surface_color_down = .{1, 1, 1, 0.25};
btn_theme.surface_color_flash = .{1, 1, 1, 0.15};
btn_theme.frame_color = .{0, 0, 0, 0};
btn_theme.frame_color_over = .{0, 0, 0, 0};
btn_theme.frame_color_down = .{0, 0, 0, 0};
btn_theme.frame_color_flash = .{0, 0, 0, 0};
atlas_valid := g_thumbnail_atlas.tex.id != INVALID_ID;
region, inside := GR.begin_scrollable_region(r, *theme.scrollable_region_theme);
cell_w := inside.w / cast(float)cols;
thumb_h := cell_w - padding * 2.0;
cell_h := thumb_h + name_h + padding;
row_count := (filtered.count + cols - 1) / cols;
total_h := cast(float)row_count * cell_h;
for idx : 0..filtered.count-1 {
name := filtered[idx];
col := idx % cols;
row := idx / cols;
cx := inside.x + cast(float)col * cell_w;
cy := inside.y - trile_picker_scroll + cast(float)row * cell_h;
thumb_r := GR.Rect.{cx + padding, cy, cell_w - padding * 2.0, thumb_h};
label_r := GR.Rect.{cx + padding, cy + thumb_h, cell_w - padding * 2.0, name_h};
cell_r := GR.Rect.{cx, cy, cell_w, cell_h};
if atlas_valid {
uv_min, uv_max, uv_found := get_thumbnail_uv(name);
if uv_found {
set_shader_for_images(*g_thumbnail_atlas);
immediate_quad(
.{thumb_r.x, thumb_r.y},
.{thumb_r.x + thumb_r.w, thumb_r.y},
.{thumb_r.x + thumb_r.w, thumb_r.y + thumb_r.h},
.{thumb_r.x, thumb_r.y + thumb_r.h},
.{1, 1, 1, 1},
.{uv_min.x, uv_min.y}, .{uv_max.x, uv_min.y},
.{uv_max.x, uv_max.y}, .{uv_min.x, uv_max.y}
);
set_shader_for_color();
}
}
is_selected := editor_current_trile != null && editor_current_trile.name == name;
if is_selected {
draw_rectangle(thumb_r, .{0.3, 0.5, 1.0, 0.35});
}
GR.label(label_r, name, *t_label_center(theme));
if GR.button(cell_r, "", *btn_theme, cast(s32)idx) {
editor_current_trile = get_trile(name);
}
}
GR.end_scrollable_region(region, inside.x + inside.w, inside.y - trile_picker_scroll + total_h, *trile_picker_scroll);
}
#scope_export #scope_export
@ -29,8 +136,6 @@ draw_picker :: (theme: *GR.Overall_Theme) {
r.y += tab_r.h; r.y += tab_r.h;
r.h -= tab_r.h; r.h -= tab_r.h;
// @ToDo: Add a scrollable zone here so that
// our triles or worlds can overflow.
if current_picker == { if current_picker == {
case .TRILE; case .TRILE;
draw_trile_picker(r, theme); draw_trile_picker(r, theme);

View File

@ -41,11 +41,17 @@ ctx : *Tacoma.Tacoma_Context;
// --- Chunk RDM bake queue --- // --- Chunk RDM bake queue ---
// Default RDM sizes per roughness level (0=sharpest, 7=diffuse).
// w = 2*size, h = 3*size. Tacoma accepts size directly.
g_rdm_default_sizes : [8]s32 = .[256, 128, 64, 32, 16, 8, 4, 2];
// A single RDM render job: one world_trile at one roughness level. // A single RDM render job: one world_trile at one roughness level.
RDM_Bake_Job :: struct { RDM_Bake_Job :: struct {
world_trile_index: s32; world_trile_index: s32;
roughness: s32; roughness: s32;
world_pos: Vector3; world_pos: Vector3;
size_override: s32; // 0 = use g_rdm_default_sizes[roughness]
quality_override: s32; // 0 = use rdm_bake.quality
} }
RDM_Bake_State :: struct { RDM_Bake_State :: struct {
@ -57,10 +63,19 @@ RDM_Bake_State :: struct {
rdm_bake : RDM_Bake_State; rdm_bake : RDM_Bake_State;
// Predicted pixel dimensions of a single RDM entry at a given roughness level. rdm_job_size :: (job: RDM_Bake_Job) -> s32 {
// roughness 0 → 512×768, roughness 1 → 256×384, ..., roughness 7 → 4×6. if job.size_override > 0 then return job.size_override;
return g_rdm_default_sizes[job.roughness];
}
rdm_job_quality :: (job: RDM_Bake_Job) -> s32 {
if job.quality_override > 0 then return job.quality_override;
return rdm_bake.quality;
}
// Pixel dimensions of a single RDM entry. w = 2*size, h = 3*size.
rdm_entry_predicted_size :: (roughness: s32) -> (w: s32, h: s32) { rdm_entry_predicted_size :: (roughness: s32) -> (w: s32, h: s32) {
size : s32 = cast(s32)(1 << (8 - roughness)); size := g_rdm_default_sizes[roughness];
return 2 * size, 3 * size; return 2 * size, 3 * size;
} }
@ -70,7 +85,9 @@ rdm_simulate_pack_height :: (jobs: []RDM_Bake_Job, canvas_w: s32) -> s32 {
cy : s32 = 0; cy : s32 = 0;
rh : s32 = 0; rh : s32 = 0;
for job: jobs { for job: jobs {
w, h := rdm_entry_predicted_size(job.roughness); s := rdm_job_size(job);
w := 2 * s;
h := 3 * s;
if cx + w > canvas_w { cy += rh; cx = 0; rh = 0; } if cx + w > canvas_w { cy += rh; cx = 0; rh = 0; }
cx += w; cx += w;
if h > rh rh = h; if h > rh rh = h;
@ -87,8 +104,8 @@ rdm_calc_chunk_atlas_size :: (jobs: []RDM_Bake_Job) -> (s32, s32) {
// Estimate canvas width from sqrt(total pixel area). // Estimate canvas width from sqrt(total pixel area).
total_area : s64 = 0; total_area : s64 = 0;
for job: jobs { for job: jobs {
w, h := rdm_entry_predicted_size(job.roughness); s := rdm_job_size(job);
total_area += cast(s64) w * cast(s64) h; total_area += cast(s64)(2 * s) * cast(s64)(3 * s);
} }
target_w : s32 = 16; target_w : s32 = 16;
sqrt_area := cast(s32) sqrt(cast(float) total_area) + 1; sqrt_area := cast(s32) sqrt(cast(float) total_area) + 1;
@ -147,7 +164,8 @@ rdm_bake_start :: (world: World, quality: s32, include_water: bool, chunk_keys:
for group: chunk.groups { for group: chunk.groups {
success, idx := table_find(*trile_name_to_index, group.trile_name); success, idx := table_find(*trile_name_to_index, group.trile_name);
if !success { if !success {
trile := get_trile(group.trile_name); trile, trile_ok := get_trile(group.trile_name);
if !trile_ok continue;
ttrile : Tacoma.Trile_Data; ttrile : Tacoma.Trile_Data;
for x: 0..15 { for x: 0..15 {
for y: 0..15 { for y: 0..15 {
@ -186,10 +204,16 @@ rdm_bake_start :: (world: World, quality: s32, include_water: bool, chunk_keys:
array_add(*world_trile_roughnesses, roughness_mask); array_add(*world_trile_roughnesses, roughness_mask);
if should_bake { if should_bake {
// Emit one job per roughness level present. size_ov, qual_ov := get_rdm_instance_override(*world, wx, wy, wz);
for r: 0..7 { for r: 0..7 {
if roughness_mask & cast(u8)(1 << r) { if roughness_mask & cast(u8)(1 << r) {
array_add(*rdm_bake.jobs, .{world_trile_index = world_trile_idx, roughness = cast(s32) r, world_pos = wpos}); array_add(*rdm_bake.jobs, .{
world_trile_index = world_trile_idx,
roughness = cast(s32) r,
world_pos = wpos,
size_override = size_ov,
quality_override = qual_ov,
});
} }
} }
} }
@ -306,8 +330,10 @@ rdm_bake_tick :: () {
job := rdm_bake.jobs[rdm_bake.current_job]; job := rdm_bake.jobs[rdm_bake.current_job];
w, h : s32; size := rdm_job_size(job);
ptr := Tacoma.tacoma_render_rdm(ctx, job.world_trile_index, job.roughness, rdm_bake.quality, *w, *h); w := 2 * size;
h := 3 * size;
ptr := Tacoma.tacoma_render_rdm(ctx, job.world_trile_index, job.roughness, rdm_job_quality(job), size);
// Find this job's per-chunk bake state. // Find this job's per-chunk bake state.
chunk_key := world_to_chunk_coord(cast(s32) job.world_pos.x, cast(s32) job.world_pos.y, cast(s32) job.world_pos.z); chunk_key := world_to_chunk_coord(cast(s32) job.world_pos.x, cast(s32) job.world_pos.y, cast(s32) job.world_pos.z);
@ -589,9 +615,9 @@ gen_reference :: (w: s32, h: s32, eye: Vector3, target: Vector3, quality: s32, i
gen_rdm :: (quality: s32, include_water: bool, world: World) { gen_rdm :: (quality: s32, include_water: bool, world: World) {
tacoma_start(world, include_water); tacoma_start(world, include_water);
w, h : s32; size := g_rdm_default_sizes[0];
ptr := Tacoma.tacoma_render_rdm(ctx, 0, 0, quality, *w, *h); ptr := Tacoma.tacoma_render_rdm(ctx, 0, 0, quality, size);
tacoma_handle_result(ptr, w, h); tacoma_handle_result(ptr, 2 * size, 3 * size);
tacoma_stop(); tacoma_stop();
} }

View File

@ -12,6 +12,7 @@ emittance : u8 = 0;
hovered_trixel_x : int = -1; hovered_trixel_x : int = -1;
hovered_trixel_y : int = -1; hovered_trixel_y : int = -1;
hovered_trixel_z : int = -1; hovered_trixel_z : int = -1;
hovered_trixel_normal : Vector3;
TRILE_ROTATION_SPEED :: 2.0; TRILE_ROTATION_SPEED :: 2.0;
@ -39,7 +40,22 @@ current_tool : Trile_Editor_Tool = .PAINT;
current_mode : Trile_Editor_Tool_Mode = .AREA; current_mode : Trile_Editor_Tool_Mode = .AREA;
colorMuls : [16][16][16]Vector3; colorMuls : [16][16][16]Vector3;
tiling_preview_active : bool;
tiling_axis : s32 = 0; // 0=+X, 1=+Z, 2=-X, 3=-Z
tiling_orientation : s32 = 0; // 0-23 = face(0..5)*4 + twist(0..3)
tiling_neighbor_trile_name : string;
tiling_neighbor_trile_input : string;
UNDO_MAX :: 32;
undo_trixels : [UNDO_MAX][16][16][16] Trixel;
undo_count : int = 0;
undo_head : int = 0;
redo_trixels : [UNDO_MAX][16][16][16] Trixel;
redo_count : int = 0;
redo_head : int = 0;
meta_name_input : string;
#scope_export #scope_export
ntrile :: (name: string) { ntrile :: (name: string) {
@ -71,6 +87,35 @@ ltrile :: (name: string) {
#scope_file #scope_file
push_undo :: () {
if !editor_current_trile return;
undo_trixels[undo_head] = editor_current_trile.trixels;
undo_head = (undo_head + 1) % UNDO_MAX;
undo_count = min(undo_count + 1, UNDO_MAX);
redo_count = 0;
redo_head = 0;
}
do_undo :: () {
if undo_count == 0 || !editor_current_trile return;
redo_trixels[redo_head] = editor_current_trile.trixels;
redo_head = (redo_head + 1) % UNDO_MAX;
redo_count = min(redo_count + 1, UNDO_MAX);
undo_head = (undo_head - 1 + UNDO_MAX) % UNDO_MAX;
undo_count -= 1;
editor_current_trile.trixels = undo_trixels[undo_head];
}
do_redo :: () {
if redo_count == 0 || !editor_current_trile return;
undo_trixels[undo_head] = editor_current_trile.trixels;
undo_head = (undo_head + 1) % UNDO_MAX;
undo_count = min(undo_count + 1, UNDO_MAX);
redo_head = (redo_head - 1 + UNDO_MAX) % UNDO_MAX;
redo_count -= 1;
editor_current_trile.trixels = redo_trixels[redo_head];
}
apply_tool_to_trixel :: (x: s64, y: s64, z: s64) { apply_tool_to_trixel :: (x: s64, y: s64, z: s64) {
if current_tool == .PAINT { if current_tool == .PAINT {
editor_current_trile.trixels[x][y][z].material.color = current_color; editor_current_trile.trixels[x][y][z].material.color = current_color;
@ -94,14 +139,25 @@ area_active : bool;
handle_tool_click :: () { handle_tool_click :: () {
if hovered_trixel_x < 0 && hovered_trixel_y < 0 && hovered_trixel_z < 0 then return; if hovered_trixel_x < 0 && hovered_trixel_y < 0 && hovered_trixel_z < 0 then return;
if current_mode == .POINT { if current_mode == .POINT {
apply_tool_to_trixel(hovered_trixel_x, hovered_trixel_y, hovered_trixel_z); push_undo();
if current_tool == .ADD {
nx := hovered_trixel_x + cast(int) hovered_trixel_normal.x;
ny := hovered_trixel_y + cast(int) hovered_trixel_normal.y;
nz := hovered_trixel_z + cast(int) hovered_trixel_normal.z;
if nx >= 0 && nx < 16 && ny >= 0 && ny < 16 && nz >= 0 && nz < 16 {
apply_tool_to_trixel(nx, ny, nz);
}
} else {
apply_tool_to_trixel(hovered_trixel_x, hovered_trixel_y, hovered_trixel_z);
}
} }
if current_mode == .BRUSH { if current_mode == .BRUSH {
push_undo();
is_in_radius :: (point : Vector3, radius: float) -> bool { is_in_radius :: (point : Vector3, radius: float) -> bool {
center : Vector3 = .{xx hovered_trixel_x, xx hovered_trixel_y, xx hovered_trixel_z}; center : Vector3 = .{xx hovered_trixel_x, xx hovered_trixel_y, xx hovered_trixel_z};
return length(point - center) <= radius; return length(point - center) <= radius;
} }
for x: 0..15 { for x: 0..15 {
for y: 0..15 { for y: 0..15 {
for z: 0..15 { for z: 0..15 {
@ -114,6 +170,7 @@ handle_tool_click :: () {
} }
if current_mode == .AREA { if current_mode == .AREA {
if area_active { if area_active {
push_undo();
// Apply tool to all trixels in the area. // Apply tool to all trixels in the area.
for x: min(area_start_x, hovered_trixel_x)..max(hovered_trixel_x, area_start_x) { for x: min(area_start_x, hovered_trixel_x)..max(hovered_trixel_x, area_start_x) {
for y: min(area_start_y, hovered_trixel_y)..max(hovered_trixel_y, area_start_y) { for y: min(area_start_y, hovered_trixel_y)..max(hovered_trixel_y, area_start_y) {
@ -166,7 +223,7 @@ tick_trile_editor :: () {
if input_button_states[Key_Code.MOUSE_BUTTON_LEFT] & .START { if input_button_states[Key_Code.MOUSE_BUTTON_LEFT] & .START {
handle_tool_click(); handle_tool_click();
} }
mindist : float = 999999; mindist : float = 999999;
hovered_trixel_x = -1; hovered_trixel_x = -1;
hovered_trixel_y = -1; hovered_trixel_y = -1;
@ -189,6 +246,7 @@ tick_trile_editor :: () {
hovered_trixel_x = x; hovered_trixel_x = x;
hovered_trixel_y = y; hovered_trixel_y = y;
hovered_trixel_z = z; hovered_trixel_z = z;
hovered_trixel_normal = collision.normal;
} }
} }
} }
@ -197,11 +255,20 @@ tick_trile_editor :: () {
for x: 0..15 { for x: 0..15 {
for y: 0..15 { for y: 0..15 {
for z: 0..15 { for z: 0..15 {
if x == hovered_trixel_x && y == hovered_trixel_y && z == hovered_trixel_z { highlighted := false;
colorMuls[x][y][z] = .{0.6, 0.0, 0.0}; if hovered_trixel_x >= 0 {
} else { if current_mode == .BRUSH {
colorMuls[x][y][z] = .{1.0, 1.0, 1.0}; center : Vector3 = .{xx hovered_trixel_x, xx hovered_trixel_y, xx hovered_trixel_z};
highlighted = length(Vector3.{xx x, xx y, xx z} - center) <= xx brush_radius;
} else if current_mode == .AREA && area_active {
highlighted = x >= min(area_start_x, hovered_trixel_x) && x <= max(area_start_x, hovered_trixel_x)
&& y >= min(area_start_y, hovered_trixel_y) && y <= max(area_start_y, hovered_trixel_y)
&& z >= min(area_start_z, hovered_trixel_z) && z <= max(area_start_z, hovered_trixel_z);
} else {
highlighted = x == hovered_trixel_x && y == hovered_trixel_y && z == hovered_trixel_z;
}
} }
colorMuls[x][y][z] = ifx highlighted then Vector3.{0.6, 0.0, 0.0} else .{1.0, 1.0, 1.0};
} }
} }
} }
@ -224,7 +291,8 @@ tick_trile_editor :: () {
trile_editor_shortcuts(); trile_editor_shortcuts();
tilt = clamp(tilt, -(PI/2.0) + 0.01, PI/2.0 - 0.01); tilt = clamp(tilt, -(PI/2.0) + 0.01, PI/2.0 - 0.01);
zoom = clamp(zoom + mouse_delta_z * -0.2, 1.0, 3.0); max_zoom := ifx tiling_preview_active then 5.0 else 3.0;
zoom = clamp(zoom + mouse_delta_z * -0.2, 1.0, max_zoom);
cam := get_trile_editor_camera(); cam := get_trile_editor_camera();
ray := get_mouse_ray(*cam); ray := get_mouse_ray(*cam);
@ -240,10 +308,11 @@ get_trile_editor_camera :: () -> Camera {
qtilt : Quaternion = .{cos(tilt/2.0),sin(tilt/2.0), 0, 0}; qtilt : Quaternion = .{cos(tilt/2.0),sin(tilt/2.0), 0, 0};
rotate(*cameraDir, qrotation * qtilt); rotate(*cameraDir, qrotation * qtilt);
camera.position = .{0.5, 0.5, 0.5}; target := ifx tiling_preview_active then get_tiling_camera_target() else Vector3.{0.5, 0.5, 0.5};
camera.position = target;
camera.position += cameraDir * zoom; camera.position += cameraDir * zoom;
camera.target = .{0.5, 0.5, 0.5}; camera.target = target;
return camera; return camera;
} }
@ -274,6 +343,7 @@ draw_tool_tab :: (theme: *GR.Overall_Theme, area: GR.Rect) {
if keybind_button(r, "Save and gen", .SAVE, *theme.button_theme) { if keybind_button(r, "Save and gen", .SAVE, *theme.button_theme) {
set_trile_gfx(editor_current_trile.name, generate_trile_gfx_matias(editor_current_trile)); set_trile_gfx(editor_current_trile.name, generate_trile_gfx_matias(editor_current_trile));
striles(); striles();
update_trile_thumbnail(editor_current_trile.name);
}; };
} }
@ -392,11 +462,86 @@ draw_material_tab :: (theme: *GR.Overall_Theme, area: GR.Rect) {
} }
TILING_AXIS_NAMES :: string.["+ X", "+ Z", "- X", "- Z", "+ Y", "- Y"];
get_tiling_world_offset :: () -> Vector3 {
if tiling_axis == 0 return .{ 1, 0, 0};
if tiling_axis == 1 return .{ 0, 0, 1};
if tiling_axis == 2 return .{-1, 0, 0};
if tiling_axis == 3 return .{ 0, 0, -1};
if tiling_axis == 4 return .{ 0, 1, 0};
return .{ 0, -1, 0};
}
get_tiling_camera_target :: () -> Vector3 {
off := get_tiling_world_offset();
return Vector3.{0.5, 0.5, 0.5} + off * 0.5;
}
// Build rotation matrices matching the same GLSL convention used in shader_trile.glsl.
// In Jai row-major passed as GLSL column-major: GLSL out[i] = sum_j M_jai[j][i]*v[j].
tiling_rot_x :: (a: float) -> Matrix4 {
c := cos(a); s := sin(a);
m : Matrix4;
m._11 = 1;
m._22 = c; m._23 = s;
m._32 = -s; m._33 = c;
m._44 = 1;
return m;
}
tiling_rot_y :: (a: float) -> Matrix4 {
c := cos(a); s := sin(a);
m : Matrix4;
m._11 = c; m._13 = s;
m._22 = 1;
m._31 = -s; m._33 = c;
m._44 = 1;
return m;
}
tiling_rot_z :: (a: float) -> Matrix4 {
c := cos(a); s := sin(a);
m : Matrix4;
m._11 = c; m._21 = s;
m._12 = -s; m._22 = c;
m._33 = 1;
m._44 = 1;
return m;
}
// Matches get_orientation_matrix(ori) from shader_trile.glsl.
// Jai A*B applies A_eff first in GLSL, so twist*base = twist applied second = same as GLSL base*rot_y(twist).
make_orientation_matrix :: (ori: s32) -> Matrix4 {
face := ori / 4;
twist := ori % 4;
twist_mat : Matrix4;
identity(*twist_mat);
if twist > 0 twist_mat = tiling_rot_y(cast(float)twist * PI / 2.0);
base_mat : Matrix4;
if face == 0 { identity(*base_mat); }
else if face == 1 { base_mat = tiling_rot_x(PI); }
else if face == 2 { base_mat = tiling_rot_z(-PI * 0.5); }
else if face == 3 { base_mat = tiling_rot_z( PI * 0.5); }
else if face == 4 { base_mat = tiling_rot_x( PI * 0.5); }
else { base_mat = tiling_rot_x(-PI * 0.5); }
return twist_mat * base_mat;
}
get_tiling_neighbor_trile :: () -> *Trile {
if tiling_neighbor_trile_name.count > 0 {
t := get_trile(tiling_neighbor_trile_name);
if t return t;
}
return editor_current_trile;
}
draw_trile_editor :: () { draw_trile_editor :: () {
create_set_cam_rendering_task(get_trile_editor_camera(), 0.0); create_set_cam_rendering_task(get_trile_editor_camera(), 0.0);
w := New(World,, temp); w := New(World,, temp);
create_sky_rendering_task(*w.conf); create_sky_rendering_task(*w.conf);
create_trixel_rendering_task(editor_current_trile, *colorMuls); create_trixel_rendering_task(editor_current_trile, *colorMuls);
if tiling_preview_active {
neighbor_trile := get_tiling_neighbor_trile();
create_trixel_rendering_task(neighbor_trile, null, world_offset = get_tiling_world_offset(), brightness = 0.75, tile_rotation = make_orientation_matrix(tiling_orientation), is_secondary = true);
}
} }
trile_editor_shortcuts :: () { trile_editor_shortcuts :: () {
@ -411,7 +556,54 @@ trile_editor_shortcuts :: () {
if is_action_start(Editor_Action.SAVE) { if is_action_start(Editor_Action.SAVE) {
set_trile_gfx(editor_current_trile.name, generate_trile_gfx_matias(editor_current_trile)); set_trile_gfx(editor_current_trile.name, generate_trile_gfx_matias(editor_current_trile));
striles(); striles();
update_trile_thumbnail(editor_current_trile.name);
} }
if is_action_start(Editor_Action.TRIXEL_VIEW_TILE) then tiling_preview_active = !tiling_preview_active;
if is_action_start(Editor_Action.TRIXEL_UNDO) then do_undo();
if is_action_start(Editor_Action.TRIXEL_REDO) then do_redo();
}
draw_meta_tab :: (theme: *GR.Overall_Theme, area: GR.Rect) {
if !editor_current_trile return;
r := area;
row_h := ui_h(4, 0);
r.h = row_h;
GR.label(r, "Name", *t_label_left(theme));
r.y += row_h;
r.h = row_h;
a, new_text, text_state := GR.text_input(r, meta_name_input, *theme.text_input_theme, 128);
if a & .ENTERED meta_name_input = copy_string(new_text);
current_name := ifx text_state then text_state.text else meta_name_input;
r.y += row_h;
r.h = row_h;
if GR.button(r, "Rename", *theme.button_theme) && current_name.count > 0 {
old := copy_string(editor_current_trile.name,, temp);
rename_trile(old, current_name);
meta_name_input = copy_string(current_name);
if editor_current_trile update_trile_thumbnail(editor_current_trile.name);
striles();
}
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);
delete_trile(name_copy);
undo_count = 0; undo_head = 0; redo_count = 0; redo_head = 0;
striles();
return;
}
r.y += row_h * 2;
r.h = row_h;
half := r.w / 2.0;
ur := r; ur.w = half;
rr := r; rr.x = r.x + half; rr.w = r.w - half;
if GR.button(ur, tprint("Undo (%)", undo_count), *theme.button_theme) do_undo();
if GR.button(rr, tprint("Redo (%)", redo_count), *theme.button_theme) do_redo();
} }
draw_trile_editor_ui :: (theme: *GR.Overall_Theme) { draw_trile_editor_ui :: (theme: *GR.Overall_Theme) {
@ -426,7 +618,10 @@ draw_trile_editor_ui :: (theme: *GR.Overall_Theme) {
tab_r.x += tab_r.w; tab_r.x += tab_r.w;
if keybind_button(tab_r, "Material", .TRIXEL_TAB_MATERIAL, *t_button_tab(theme, current_tab == .MATERIAL)) then current_tab = .MATERIAL; if keybind_button(tab_r, "Material", .TRIXEL_TAB_MATERIAL, *t_button_tab(theme, current_tab == .MATERIAL)) then current_tab = .MATERIAL;
tab_r.x += tab_r.w; tab_r.x += tab_r.w;
if keybind_button(tab_r, "Meta", .TRIXEL_TAB_INFO, *t_button_tab(theme, current_tab == .METADATA)) then current_tab = .METADATA; if keybind_button(tab_r, "Meta", .TRIXEL_TAB_INFO, *t_button_tab(theme, current_tab == .METADATA)) {
current_tab = .METADATA;
if editor_current_trile meta_name_input = copy_string(editor_current_trile.name);
}
r.y += tab_r.h; r.y += tab_r.h;
@ -435,6 +630,8 @@ draw_trile_editor_ui :: (theme: *GR.Overall_Theme) {
draw_material_tab(theme, r); draw_material_tab(theme, r);
case .TOOLSET; case .TOOLSET;
draw_tool_tab(theme, r); draw_tool_tab(theme, r);
case .METADATA;
draw_meta_tab(theme, r);
} }
draw_picker(theme); draw_picker(theme);
@ -442,7 +639,7 @@ draw_trile_editor_ui :: (theme: *GR.Overall_Theme) {
// View mode buttons — bottom center of the 3D viewport. // View mode buttons — bottom center of the 3D viewport.
btn_w := 11.0 * vw; btn_w := 11.0 * vw;
btn_h := cast(float) ui_h(4, 0); btn_h := cast(float) ui_h(4, 0);
bar_w := btn_w * 4.0; bar_w := btn_w * 5.0;
bar_x := 100.0 * vw / 2.0 - bar_w / 2.0; bar_x := 100.0 * vw / 2.0 - bar_w / 2.0;
bar_y := 100.0 * vh - btn_h - 1.5 * vh; bar_y := 100.0 * vh - btn_h - 1.5 * vh;
@ -459,4 +656,42 @@ draw_trile_editor_ui :: (theme: *GR.Overall_Theme) {
if keybind_button(r2, "Albedo", .TRIXEL_VIEW_ALBEDO, *t_button_selectable(theme, trixel_view_mode == 2)) then trixel_view_mode = 2; if keybind_button(r2, "Albedo", .TRIXEL_VIEW_ALBEDO, *t_button_selectable(theme, trixel_view_mode == 2)) then trixel_view_mode = 2;
r2.x += btn_w; r2.x += btn_w;
if keybind_button(r2, "Mixed", .TRIXEL_VIEW_MIXED, *t_button_selectable(theme, trixel_view_mode == 3)) then trixel_view_mode = 3; if keybind_button(r2, "Mixed", .TRIXEL_VIEW_MIXED, *t_button_selectable(theme, trixel_view_mode == 3)) then trixel_view_mode = 3;
r2.x += btn_w;
if keybind_button(r2, "Tile", .TRIXEL_VIEW_TILE, *t_button_selectable(theme, tiling_preview_active)) {
tiling_preview_active = !tiling_preview_active;
}
if tiling_preview_active {
ctrl_w := bar_w / 3.0;
ctrl_y := bar_y - btn_h - 0.5 * vh;
ctrl_r : GR.Rect;
ctrl_r.y = ctrl_y; ctrl_r.h = btn_h;
tiling_bar_r : GR.Rect;
tiling_bar_r.x = bar_x; tiling_bar_r.y = ctrl_y; tiling_bar_r.w = bar_w; tiling_bar_r.h = btn_h;
ui_add_mouse_occluder(tiling_bar_r);
// Axis cycle button (Q)
ctrl_r.x = bar_x; ctrl_r.w = ctrl_w;
axis_label := tprint("Axis: %", TILING_AXIS_NAMES[tiling_axis]);
if keybind_button(ctrl_r, axis_label, .TRIXEL_TILING_AXIS, *theme.button_theme) {
tiling_axis = (tiling_axis + 1) % 6;
}
// Orientation cycle button (R) — cycles through all 24 face*twist orientations
ctrl_r.x = bar_x + ctrl_w; ctrl_r.w = ctrl_w;
ori_label := tprint("F% T%", tiling_orientation / 4, tiling_orientation % 4);
if keybind_button(ctrl_r, ori_label, .TRIXEL_TILING_ROTATE, *theme.button_theme) {
tiling_orientation = (tiling_orientation + 1) % 24;
}
// Neighbor trile text input
ctrl_r.x = bar_x + ctrl_w * 2.0; ctrl_r.w = ctrl_w;
a, new_text, _ := GR.text_input(ctrl_r, tiling_neighbor_trile_input, *theme.text_input_theme, 600);
if a & .TEXT_MODIFIED tiling_neighbor_trile_input = copy_string(new_text);
if a & .ENTERED {
tiling_neighbor_trile_input = copy_string(new_text);
tiling_neighbor_trile_name = tiling_neighbor_trile_input;
}
}
} }

View File

@ -0,0 +1,178 @@
#scope_file
THUMB_SIZE :: 64;
ATLAS_SIZE :: 2048;
ATLAS_COLS :: ATLAS_SIZE / THUMB_SIZE;
g_thumbnail_atlas_buf : [ATLAS_SIZE * ATLAS_SIZE * 4] u8;
g_thumbnail_slot_map : Table(string, int);
g_thumbnail_slot_count : int;
blit_slot :: (thumb: *[THUMB_SIZE * THUMB_SIZE * 4] u8, slot: int) {
col := slot % ATLAS_COLS;
row := slot / ATLAS_COLS;
start_x := col * THUMB_SIZE;
start_y := row * THUMB_SIZE;
for py : 0..THUMB_SIZE-1 {
for px : 0..THUMB_SIZE-1 {
ai := ((start_y + py) * ATLAS_SIZE + (start_x + px)) * 4;
ti := (py * THUMB_SIZE + px) * 4;
g_thumbnail_atlas_buf[ai] = (thumb.*)[ti];
g_thumbnail_atlas_buf[ai+1] = (thumb.*)[ti+1];
g_thumbnail_atlas_buf[ai+2] = (thumb.*)[ti+2];
g_thumbnail_atlas_buf[ai+3] = (thumb.*)[ti+3];
}
}
}
render_thumbnail :: (trile: *Trile, out: *[THUMB_SIZE * THUMB_SIZE * 4] u8) {
ray_dir := normalize(Vector3.{-1.0, -1.2, -1.0});
right_vec := normalize(Vector3.{1.0, 0.0, -1.0});
up_vec := -normalize(cross(ray_dir, right_vec));
center := Vector3.{8.0, 8.0, 8.0};
scale : float = 10.5;
light_dir := normalize(Vector3.{-1.0, -2.0, -1.0});
for py : 0..THUMB_SIZE-1 {
for px : 0..THUMB_SIZE-1 {
u : float = (cast(float)px + 0.5) / cast(float)THUMB_SIZE * 2.0 - 1.0;
v : float = -((cast(float)py + 0.5) / cast(float)THUMB_SIZE * 2.0 - 1.0);
o := center + right_vec * (u * scale) + up_vec * (v * scale) - ray_dir * 30.0;
ix := cast(int) floor(o.x);
iy := cast(int) floor(o.y);
iz := cast(int) floor(o.z);
sx := ifx ray_dir.x >= 0.0 then 1 else -1;
sy := ifx ray_dir.y >= 0.0 then 1 else -1;
sz := ifx ray_dir.z >= 0.0 then 1 else -1;
tdx := abs(1.0 / ray_dir.x);
tdy := abs(1.0 / ray_dir.y);
tdz := abs(1.0 / ray_dir.z);
nx := ifx ray_dir.x >= 0.0 then cast(float)(ix + 1) else cast(float)ix;
ny := ifx ray_dir.y >= 0.0 then cast(float)(iy + 1) else cast(float)iy;
nz := ifx ray_dir.z >= 0.0 then cast(float)(iz + 1) else cast(float)iz;
tmx := (nx - o.x) / ray_dir.x;
tmy := (ny - o.y) / ray_dir.y;
tmz := (nz - o.z) / ray_dir.z;
fn : Vector3 = .{0.0, 1.0, 0.0};
hit : bool;
hc : Vector3;
for 0..199 {
if ix >= 0 && ix < 16 && iy >= 0 && iy < 16 && iz >= 0 && iz < 16 {
if !trile.trixels[ix][iy][iz].empty {
hit = true;
hc = trile.trixels[ix][iy][iz].material.color;
break;
}
}
if tmx < tmy && tmx < tmz {
fn = .{cast(float)-sx, 0.0, 0.0};
ix += sx;
tmx += tdx;
} else if tmy < tmz {
fn = .{0.0, cast(float)-sy, 0.0};
iy += sy;
tmy += tdy;
} else {
fn = .{0.0, 0.0, cast(float)-sz};
iz += sz;
tmz += tdz;
}
}
pidx := (py * THUMB_SIZE + px) * 4;
if hit {
diff := max(0.0, dot(fn, -light_dir));
brite := 0.3 + diff * 0.7;
(out.*)[pidx] = xx clamp(cast(int)(hc.x * brite * 255.0 + 0.5), 0, 255);
(out.*)[pidx+1] = xx clamp(cast(int)(hc.y * brite * 255.0 + 0.5), 0, 255);
(out.*)[pidx+2] = xx clamp(cast(int)(hc.z * brite * 255.0 + 0.5), 0, 255);
(out.*)[pidx+3] = 255;
} else {
val : u8 = ifx ((px / 8 + py / 8) % 2 == 0) then cast(u8)55 else cast(u8)38;
(out.*)[pidx] = val;
(out.*)[pidx+1] = val;
(out.*)[pidx+2] = val;
(out.*)[pidx+3] = 255;
}
}
}
}
upload_atlas :: () {
imgdata : sg_image_data;
imgdata.subimage[0][0] = .{ g_thumbnail_atlas_buf.data, cast(u64)(ATLAS_SIZE * ATLAS_SIZE * 4) };
sg_update_image(g_thumbnail_atlas.tex, *imgdata);
}
#scope_export
g_thumbnail_atlas : Ui_Texture;
get_thumbnail_uv :: (name: string) -> (uv_min: Vector2, uv_max: Vector2, found: bool) {
ptr := table_find_pointer(*g_thumbnail_slot_map, name);
if !ptr return .{}, .{}, false;
slot := ptr.*;
col := slot % ATLAS_COLS;
row := slot / ATLAS_COLS;
inv := 1.0 / cast(float)ATLAS_SIZE;
u0 := cast(float)(col * THUMB_SIZE) * inv;
v0 := cast(float)(row * THUMB_SIZE) * inv;
u1 := cast(float)((col + 1) * THUMB_SIZE) * inv;
v1 := cast(float)((row + 1) * THUMB_SIZE) * inv;
return .{u0, v0}, .{u1, v1}, true;
}
update_trile_thumbnail :: (name: string) {
trile := get_trile(name);
if !trile return;
ptr := table_find_pointer(*g_thumbnail_slot_map, name);
slot : int;
if ptr {
slot = ptr.*;
} else {
slot = g_thumbnail_slot_count;
table_set(*g_thumbnail_slot_map, name, slot);
g_thumbnail_slot_count += 1;
}
thumb : [THUMB_SIZE * THUMB_SIZE * 4] u8;
render_thumbnail(trile, *thumb);
blit_slot(*thumb, slot);
if g_thumbnail_atlas.tex.id != INVALID_ID {
upload_atlas();
}
}
init_trile_thumbnails :: () {
tpt := get_trile_table_ptr();
for v : tpt {
trile := get_trile(v.name);
if !trile continue;
slot := g_thumbnail_slot_count;
table_set(*g_thumbnail_slot_map, v.name, slot);
g_thumbnail_slot_count += 1;
thumb : [THUMB_SIZE * THUMB_SIZE * 4] u8;
render_thumbnail(trile, *thumb);
blit_slot(*thumb, slot);
}
desc := sg_image_desc.{
width = xx ATLAS_SIZE,
height = xx ATLAS_SIZE,
pixel_format = .RGBA8,
usage = .DYNAMIC,
};
g_thumbnail_atlas.tex = sg_make_image(*desc);
upload_atlas();
}

View File

@ -43,6 +43,13 @@ Editor_Action :: enum {
TRIXEL_VIEW_NORMALS; TRIXEL_VIEW_NORMALS;
TRIXEL_VIEW_ALBEDO; TRIXEL_VIEW_ALBEDO;
TRIXEL_VIEW_MIXED; TRIXEL_VIEW_MIXED;
TRIXEL_VIEW_TILE;
// Trile editor — tiling controls
TRIXEL_TILING_AXIS;
TRIXEL_TILING_ROTATE;
// Trile editor — undo/redo
TRIXEL_UNDO;
TRIXEL_REDO;
} }
#scope_file; #scope_file;
@ -66,6 +73,7 @@ check_action :: (action: $T, status: Key_Current_State) -> bool {
offset = EDITOR_ACTION_COUNT; offset = EDITOR_ACTION_COUNT;
} }
if console_open_ignore_input then return false; if console_open_ignore_input then return false;
if ui_keyboard_captured then return false;
combo := keys[cast(s32)action + offset]; combo := keys[cast(s32)action + offset];
ctrl_down := cast(bool)(input_button_states[Key_Code.CTRL] & .DOWN); ctrl_down := cast(bool)(input_button_states[Key_Code.CTRL] & .DOWN);
shift_down := cast(bool)(input_button_states[Key_Code.SHIFT] & .DOWN); shift_down := cast(bool)(input_button_states[Key_Code.SHIFT] & .DOWN);
@ -183,4 +191,9 @@ set_default_bindings :: () {
set(.TRIXEL_VIEW_NORMALS, cast(Key_Code) #char "6"); set(.TRIXEL_VIEW_NORMALS, cast(Key_Code) #char "6");
set(.TRIXEL_VIEW_ALBEDO, cast(Key_Code) #char "7"); set(.TRIXEL_VIEW_ALBEDO, cast(Key_Code) #char "7");
set(.TRIXEL_VIEW_MIXED, cast(Key_Code) #char "8"); set(.TRIXEL_VIEW_MIXED, cast(Key_Code) #char "8");
set(.TRIXEL_VIEW_TILE, cast(Key_Code) #char "9");
set(.TRIXEL_TILING_AXIS, cast(Key_Code) #char "Q");
set(.TRIXEL_TILING_ROTATE, cast(Key_Code) #char "R");
set(.TRIXEL_UNDO, cast(Key_Code) #char "Z", ctrl = true);
set(.TRIXEL_REDO, cast(Key_Code) #char "Y", ctrl = true);
} }

View File

@ -97,7 +97,10 @@ init :: () {
logger = .{ func = slog_func }, logger = .{ func = slog_func },
})); }));
sfetch_setup(*(sfetch_desc_t.{ sfetch_setup(*(sfetch_desc_t.{
logger = .{ func = slog_func }, max_requests = 64,
num_channels = 2,
num_lanes = 1,
logger = .{ func = slog_func },
})); }));
asset_manager_init(); asset_manager_init();
#if OS != .WASM { Thread.init(*g_mixer.mutex); } #if OS != .WASM { Thread.init(*g_mixer.mutex); }

View File

@ -51,7 +51,7 @@ hot_reload_all_packs :: () {
array_add(*pack_names, sprint("%", pack.name)); array_add(*pack_names, sprint("%", pack.name));
} }
array_reset(*g_asset_manager.fetch_queue); array_reset(*g_asset_manager.main_queue);
g_mixer.paused = true; g_mixer.paused = true;
g_asset_manager.hot_reload_unpause_pending = true; g_asset_manager.hot_reload_unpause_pending = true;

View File

@ -26,6 +26,7 @@ Particle_Emitter_Instance :: struct {
definition : *Particle_Emitter_Config; definition : *Particle_Emitter_Config;
definition_name : string; definition_name : string;
position : Vector3; position : Vector3;
offset : Vector3;
active : bool = true; active : bool = true;
spawn_accumulator : float; spawn_accumulator : float;
} }
@ -75,7 +76,7 @@ tick_world_emitters :: (dt: float) {
inst.spawn_accumulator += def.emission_rate * dt; inst.spawn_accumulator += def.emission_rate * dt;
while inst.spawn_accumulator >= 1.0 { while inst.spawn_accumulator >= 1.0 {
inst.spawn_accumulator -= 1.0; inst.spawn_accumulator -= 1.0;
spawn_one_particle(inst.position, def); spawn_one_particle(inst.position + inst.offset, def);
} }
} }
} }
@ -144,7 +145,7 @@ add_particle_render_tasks :: () {
anim := batch.anim; anim := batch.anim;
frame_count := anim.frames.count; frame_count := anim.frames.count;
if frame_count == 0 then continue; if frame_count == 0 then continue;
frame := cast(s32)(t * cast(float)(frame_count - 1)); frame := cast(s32)(t * cast(float)frame_count);
if frame < 0 then frame = 0; if frame < 0 then frame = 0;
if frame >= frame_count then frame = cast(s32)(frame_count - 1); if frame >= frame_count then frame = cast(s32)(frame_count - 1);
f := anim.frames[frame]; f := anim.frames[frame];

View File

@ -63,6 +63,7 @@ Render_Command_Update_Trixels :: struct {
c.type = .UPDATE_TRIXELS; c.type = .UPDATE_TRIXELS;
trile : *Trile; trile : *Trile;
colMultipliers : *[16][16][16]Vector3; colMultipliers : *[16][16][16]Vector3;
is_secondary : bool;
} }
Render_Command_Draw_Billboard :: struct { Render_Command_Draw_Billboard :: struct {
@ -76,8 +77,12 @@ Render_Command_Draw_Billboard :: struct {
} }
Render_Command_Draw_Trixels :: struct { Render_Command_Draw_Trixels :: struct {
#as using c : Render_Command; #as using c : Render_Command;
c.type = .DRAW_TRIXELS; c.type = .DRAW_TRIXELS;
world_offset : Vector3;
brightness : float = 1.0;
tile_rotation : Matrix4 = .{_11=1, _22=1, _33=1, _44=1};
is_secondary : bool;
} }
Render_Command_Draw_Particles :: struct { Render_Command_Draw_Particles :: struct {

View File

@ -1,7 +1,9 @@
camera: Camera; camera: Camera;
trixel_count : s32 = 0; trixel_count : s32 = 0;
trixel_view_mode : s32 = 0; trixel_secondary_count : s32 = 0;
trixel_secondary_vbuf : sg_buffer;
trixel_view_mode : s32 = 0;
bypass_postprocess : bool = false; bypass_postprocess : bool = false;
bypass_shadows : bool = false; bypass_shadows : bool = false;
bypass_reflections : bool = false; bypass_reflections : bool = false;
@ -39,7 +41,8 @@ backend_handle_command :: (cmd: *Render_Command) {
trixel_update_command := cast(*Render_Command_Update_Trixels)cmd; trixel_update_command := cast(*Render_Command_Update_Trixels)cmd;
backend_update_trixels(trixel_update_command); backend_update_trixels(trixel_update_command);
case .DRAW_TRIXELS; case .DRAW_TRIXELS;
backend_draw_trixels(); draw_trixels_cmd := cast(*Render_Command_Draw_Trixels)cmd;
backend_draw_trixels(draw_trixels_cmd.*);
case .SET_LIGHT; case .SET_LIGHT;
set_light_command := cast(*Render_Command_Set_Light)cmd; set_light_command := cast(*Render_Command_Set_Light)cmd;
current_world_config = set_light_command.worldConfig; current_world_config = set_light_command.worldConfig;
@ -58,57 +61,66 @@ backend_handle_command :: (cmd: *Render_Command) {
backend_update_trixels :: (cmd: Render_Command_Update_Trixels) { backend_update_trixels :: (cmd: Render_Command_Update_Trixels) {
if cmd.trile == null then return; if cmd.trile == null then return;
trixels : [4096]Position_Color; trixels : [4096]Position_Color;
trixel_count = 0; count : s32 = 0;
for x: 0..15 { for x: 0..15 {
for y: 0..15 { for y: 0..15 {
for z: 0..15 { for z: 0..15 {
if cmd.trile.trixels[x][y][z].empty then continue; if cmd.trile.trixels[x][y][z].empty then continue;
trixels[trixel_count].pos.x = x * (1.0 / 16.0) + TRIXEL_SIZE_HALF; trixels[count].pos.x = x * (1.0 / 16.0) + TRIXEL_SIZE_HALF;
trixels[trixel_count].pos.y = y * (1.0 / 16.0) + TRIXEL_SIZE_HALF; trixels[count].pos.y = y * (1.0 / 16.0) + TRIXEL_SIZE_HALF;
trixels[trixel_count].pos.z = z * (1.0 / 16.0) + TRIXEL_SIZE_HALF; trixels[count].pos.z = z * (1.0 / 16.0) + TRIXEL_SIZE_HALF;
cm := (cmd.colMultipliers.*)[x][y][z]; cm : Vector3 = .{1, 1, 1};
// Encode highlight state in inst.w: non-identity colorMul means highlighted. if cmd.colMultipliers cm = (cmd.colMultipliers.*)[x][y][z];
// 0=normal, 1=hovered, (future: 2=selected, 3=in-brush). trixels[count].pos.w = ifx (cm.x == 1.0 && cm.y == 1.0 && cm.z == 1.0) then 0.0 else 1.0;
trixels[trixel_count].pos.w = ifx (cm.x == 1.0 && cm.y == 1.0 && cm.z == 1.0) then 0.0 else 1.0;
trixel_color := cmd.trile.trixels[x][y][z].material.color * cm; trixel_color := cmd.trile.trixels[x][y][z].material.color * cm;
trixels[count].col = .{trixel_color.x, trixel_color.y, trixel_color.z, material_encode_to_float(cmd.trile.trixels[x][y][z].material)};
trixels[trixel_count].col = .{trixel_color.x, trixel_color.y, trixel_color.z, material_encode_to_float(cmd.trile.trixels[x][y][z].material)}; count += 1;
trixel_count += 1;
} }
} }
} }
sg_update_buffer(gPipelines.trixel.bind.vertex_buffers[2], *(sg_range.{ range := sg_range.{ ptr = trixels.data, size = size_of(type_of(trixels)) };
ptr = trixels.data, if cmd.is_secondary {
size = size_of(type_of(trixels)), trixel_secondary_count = count;
})); sg_update_buffer(trixel_secondary_vbuf, *range);
} else {
trixel_count = count;
sg_update_buffer(gPipelines.trixel.bind.vertex_buffers[2], *range);
}
} }
backend_draw_trixels :: () { backend_draw_trixels :: (cmd: Render_Command_Draw_Trixels) {
if trixel_count == 0 then return; count := ifx cmd.is_secondary then trixel_secondary_count else trixel_count;
if count == 0 then return;
mvp := create_viewproj(*camera); mvp := create_viewproj(*camera);
vs_params : Vs_Params; vs_params : Vs_Params;
vs_params.mvp = mvp.floats; vs_params.mvp = mvp.floats;
vs_params.camera = camera.position.component; vs_params.camera = camera.position.component;
vs_params.world_offset = cmd.world_offset.component;
vs_params.tile_rotation = cmd.tile_rotation.floats;
world_conf : Trixel_World_Config; world_conf : Trixel_World_Config;
wc : *World_Config = *(World_Config.{}); wc : *World_Config = *(World_Config.{});
world_config_to_shader_type(wc, *world_conf); world_config_to_shader_type(wc, *world_conf);
fs_params : Trixel_Fs_Params; fs_params : Trixel_Fs_Params;
fs_params.view_mode = trixel_view_mode; fs_params.view_mode = trixel_view_mode;
fs_params.brightness = cmd.brightness;
bind := gPipelines.trixel.bind;
if cmd.is_secondary bind.vertex_buffers[2] = trixel_secondary_vbuf;
sg_apply_pipeline(gPipelines.trixel.pipeline); sg_apply_pipeline(gPipelines.trixel.pipeline);
sg_apply_bindings(*gPipelines.trixel.bind); sg_apply_bindings(*bind);
sg_apply_uniforms(UB_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) })); sg_apply_uniforms(UB_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
sg_apply_uniforms(UB_trixel_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))})); sg_apply_uniforms(UB_trixel_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
sg_apply_uniforms(UB_trixel_fs_params, *(sg_range.{ ptr = *fs_params, size = size_of(type_of(fs_params)) })); sg_apply_uniforms(UB_trixel_fs_params, *(sg_range.{ ptr = *fs_params, size = size_of(type_of(fs_params)) }));
sg_draw(0, 36, trixel_count); sg_draw(0, 36, count);
} }
backend_add_trile_positions :: (positions : []Vector4) { backend_add_trile_positions :: (positions : []Vector4) {
@ -234,7 +246,8 @@ backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *
fs_params.rdm_spec_scale = lc.rdm_spec_scale; fs_params.rdm_spec_scale = lc.rdm_spec_scale;
fs_params.ambient_color = lc.ambient_color.component; fs_params.ambient_color = lc.ambient_color.component;
fs_params.is_preview = preview_mode; fs_params.is_preview = preview_mode;
fs_params.rdm_tint = lc.rdm_tint.component; fs_params.rdm_tint = lc.rdm_tint.component;
fs_params.rdm_diff_saturation = worldConf.rdmDiffSaturation;
sg_apply_bindings(*bindings); 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_fs_params, *(sg_range.{ ptr = *fs_params, size = size_of(type_of(fs_params)) }));
@ -271,7 +284,7 @@ backend_draw_ground :: (wc: *World_Config) {
plane_data.screen_h = h; plane_data.screen_h = h;
plane_data.cameraPosition = camera.position.component; plane_data.cameraPosition = camera.position.component;
plane_data.reflectionDistortion = 0.1; plane_data.reflectionDistortion = 0.1;
plane_data.shininess = 0.2; plane_data.shininess = wc.waterShininess;
world_config_to_shader_type(wc, *world_conf); world_config_to_shader_type(wc, *world_conf);
@ -484,6 +497,7 @@ backend_process_command_buckets :: () {
for render_command_buckets.main { for render_command_buckets.main {
backend_handle_command(it); backend_handle_command(it);
} }
debug_draw_flush_gpu();
sg_end_pass(); sg_end_pass();
end_frame_profiling_group("Main pass"); end_frame_profiling_group("Main pass");

View File

@ -0,0 +1,144 @@
DEBUG_LINE_MAX :: 65536;
g_debug_line_verts : [DEBUG_LINE_MAX * 2 * 7]float;
g_debug_line_count : int;
debug_draw_enabled : bool = !FLAG_RELEASE_BUILD;
debug_draw_grid : bool = true;
debug_draw_vectors : bool = true;
debug_draw_colliders : bool = true;
toggle_debug_draw :: () {
debug_draw_enabled = !debug_draw_enabled;
} @Command
toggle_debug_grid :: () {
debug_draw_grid = !debug_draw_grid;
} @Command
toggle_debug_vectors :: () {
debug_draw_vectors = !debug_draw_vectors;
} @Command
toggle_debug_colliders :: () {
debug_draw_colliders = !debug_draw_colliders;
} @Command
debug_line :: (a: Vector3, b: Vector3, col: Vector4) {
if !debug_draw_enabled then return;
if g_debug_line_count >= DEBUG_LINE_MAX then return;
base := g_debug_line_count * 14;
g_debug_line_verts[base + 0] = a.x;
g_debug_line_verts[base + 1] = a.y;
g_debug_line_verts[base + 2] = a.z;
g_debug_line_verts[base + 3] = col.x;
g_debug_line_verts[base + 4] = col.y;
g_debug_line_verts[base + 5] = col.z;
g_debug_line_verts[base + 6] = col.w;
g_debug_line_verts[base + 7] = b.x;
g_debug_line_verts[base + 8] = b.y;
g_debug_line_verts[base + 9] = b.z;
g_debug_line_verts[base + 10] = col.x;
g_debug_line_verts[base + 11] = col.y;
g_debug_line_verts[base + 12] = col.z;
g_debug_line_verts[base + 13] = col.w;
g_debug_line_count += 1;
}
debug_vector :: (origin: Vector3, vec: Vector3, col: Vector4) {
if !debug_draw_enabled || !debug_draw_vectors then return;
tip := origin + vec;
shaft := normalize(vec);
debug_line(origin, tip, col);
arrowhead_len : float : 0.15;
arrowhead_back := tip - shaft * arrowhead_len;
perp : Vector3;
if abs(shaft.x) < 0.9 {
perp = normalize(cross(shaft, .{1, 0, 0}));
} else {
perp = normalize(cross(shaft, .{0, 1, 0}));
}
wing := perp * (arrowhead_len * 0.5);
perp2 := cross(shaft, perp);
wing2 := perp2 * (arrowhead_len * 0.5);
debug_line(arrowhead_back + wing, tip, col);
debug_line(arrowhead_back - wing, tip, col);
debug_line(arrowhead_back + wing2, tip, col);
debug_line(arrowhead_back - wing2, tip, col);
}
debug_grid :: (cx: float, y: float, cz: float, half_extent: int, col: Vector4) {
if !debug_draw_enabled || !debug_draw_grid then return;
for i: -half_extent..half_extent {
fi := cast(float)i;
fe := cast(float)half_extent;
debug_line(.{cx + fi, y, cz - fe}, .{cx + fi, y, cz + fe}, col);
debug_line(.{cx - fe, y, cz + fi}, .{cx + fe, y, cz + fi}, col);
}
}
debug_box_2d :: (rect: Collision_Rect, y: float, col: Vector4) {
if !debug_draw_enabled || !debug_draw_colliders then return;
hw := rect.width * 0.5;
hh := rect.height * 0.5;
cx := rect.position.x;
cz := rect.position.y;
p0 := Vector3.{cx - hw, y, cz - hh};
p1 := Vector3.{cx + hw, y, cz - hh};
p2 := Vector3.{cx + hw, y, cz + hh};
p3 := Vector3.{cx - hw, y, cz + hh};
debug_line(p0, p1, col);
debug_line(p1, p2, col);
debug_line(p2, p3, col);
debug_line(p3, p0, col);
}
debug_circle_2d :: (circle: Collision_Circle, y: float, col: Vector4, segments: int = 16) {
if !debug_draw_enabled || !debug_draw_colliders then return;
TAU :: cast(float)(2.0 * 3.14159265358979);
cx := circle.position.x;
cz := circle.position.y;
r := circle.radius;
for i: 0..segments-1 {
t0 := (cast(float)i / cast(float)segments) * TAU;
t1 := (cast(float)(i + 1) / cast(float)segments) * TAU;
a := Vector3.{cx + cos(t0) * r, y, cz + sin(t0) * r};
b := Vector3.{cx + cos(t1) * r, y, cz + sin(t1) * r};
debug_line(a, b, col);
}
}
debug_aabb_3d :: (mn: Vector3, mx: Vector3, col: Vector4) {
if !debug_draw_enabled || !debug_draw_colliders then return;
debug_line(.{mn.x, mn.y, mn.z}, .{mx.x, mn.y, mn.z}, col);
debug_line(.{mn.x, mn.y, mn.z}, .{mn.x, mn.y, mx.z}, col);
debug_line(.{mx.x, mn.y, mn.z}, .{mx.x, mn.y, mx.z}, col);
debug_line(.{mn.x, mn.y, mx.z}, .{mx.x, mn.y, mx.z}, col);
debug_line(.{mn.x, mx.y, mn.z}, .{mx.x, mx.y, mn.z}, col);
debug_line(.{mn.x, mx.y, mn.z}, .{mn.x, mx.y, mx.z}, col);
debug_line(.{mx.x, mx.y, mn.z}, .{mx.x, mx.y, mx.z}, col);
debug_line(.{mn.x, mx.y, mx.z}, .{mx.x, mx.y, mx.z}, col);
debug_line(.{mn.x, mn.y, mn.z}, .{mn.x, mx.y, mn.z}, col);
debug_line(.{mx.x, mn.y, mn.z}, .{mx.x, mx.y, mn.z}, col);
debug_line(.{mn.x, mn.y, mx.z}, .{mn.x, mx.y, mx.z}, col);
debug_line(.{mx.x, mn.y, mx.z}, .{mx.x, mx.y, mx.z}, col);
}
debug_draw_flush_gpu :: () {
if g_debug_line_count == 0 then return;
sg_update_buffer(
gPipelines.debugline.bind.vertex_buffers[0],
*(sg_range.{
ptr = g_debug_line_verts.data,
size = cast(u64)(g_debug_line_count * 14 * size_of(float)),
})
);
mvp := create_viewproj(*camera);
params : Debugline_Vs_Params;
params.mvp = mvp.floats;
sg_apply_pipeline(gPipelines.debugline.pipeline);
sg_apply_bindings(*gPipelines.debugline.bind);
sg_apply_uniforms(UB_debugline_vs_params, *(sg_range.{ ptr = *params, size = size_of(Debugline_Vs_Params) }));
sg_draw(0, xx (g_debug_line_count * 2), 1);
g_debug_line_count = 0;
}

View File

@ -129,10 +129,11 @@ create_set_light_rendering_task :: (conf: *World_Config) {
add_rendering_task(lighttask); add_rendering_task(lighttask);
} }
create_trixel_rendering_task :: (trile: *Trile, muls: *[16][16][16]Vector3) { TRIXEL_IDENTITY : Matrix4 : .{_11=1, _22=1, _33=1, _44=1};
trixeltask := Rendering_Task_Trixels.{type = .TRIXELS, trile = trile, colMultipliers = muls};
create_trixel_rendering_task :: (trile: *Trile, muls: *[16][16][16]Vector3, world_offset: Vector3 = .{}, brightness: float = 1.0, tile_rotation: Matrix4 = TRIXEL_IDENTITY, is_secondary: bool = false) {
trixeltask := Rendering_Task_Trixels.{type = .TRIXELS, trile = trile, colMultipliers = muls, world_offset = world_offset, brightness = brightness, tile_rotation = tile_rotation, is_secondary = is_secondary};
add_rendering_task(trixeltask); add_rendering_task(trixeltask);
} }
create_ground_rendering_task :: (world: *World) { create_ground_rendering_task :: (world: *World) {

View File

@ -398,7 +398,8 @@ Pool :: #import "Pool";
meshgenpool : Pool.Pool; meshgenpool : Pool.Pool;
generate_trile_gfx_matias :: (trileptr : *Trile) -> Trile_GFX { generate_trile_gfx_matias :: (trileptr : *Trile) -> Trile_GFX {
if !meshgenpool.block_allocator.proc then Pool.set_allocators(*meshgenpool); // @ToDo: Only do this if we haven't yet done it. // @ToDo: Only do this if we haven't yet done it.
if !meshgenpool.block_allocator.proc then Pool.set_allocators(*meshgenpool);
old_alloc := context.allocator; old_alloc := context.allocator;
new_context := context; new_context := context;

View File

@ -77,6 +77,8 @@ gPipelines : struct {
particle_alpha : Pipeline_Binding; particle_alpha : Pipeline_Binding;
ssao: Pipeline_Binding; ssao: Pipeline_Binding;
debugline : Pipeline_Binding;
} }
create_final_image :: () { create_final_image :: () {
@ -155,7 +157,8 @@ create_pipelines :: () {
create_billboard_pipeline(); create_billboard_pipeline();
create_gbuffer_billboard_pipeline(); create_gbuffer_billboard_pipeline();
create_particle_pipeline(); create_particle_pipeline();
create_debugline_pipeline();
create_shadowmap_image(); create_shadowmap_image();
create_final_image(); create_final_image();
create_ssao_images(); create_ssao_images();
@ -320,6 +323,9 @@ create_trixel_pipeline :: () {
gPipelines.trixel.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer); gPipelines.trixel.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
gPipelines.trixel.bind.vertex_buffers[1] = sg_make_buffer(*nbuffer); gPipelines.trixel.bind.vertex_buffers[1] = sg_make_buffer(*nbuffer);
gPipelines.trixel.bind.vertex_buffers[2] = sg_make_buffer(*instance_buffer); gPipelines.trixel.bind.vertex_buffers[2] = sg_make_buffer(*instance_buffer);
secondary_instance_buffer := sg_buffer_desc.{ usage = .STREAM, size = 4096 * size_of(Position_Color)};
trixel_secondary_vbuf = sg_make_buffer(*secondary_instance_buffer);
} }
create_gbuffer_pipeline :: () { create_gbuffer_pipeline :: () {
@ -1272,3 +1278,32 @@ create_particle_pipeline :: () {
setup_bind(*gPipelines.particle_additive.bind, idx_buf, vtx_buf, inst1, inst2, inst3, smp); setup_bind(*gPipelines.particle_additive.bind, idx_buf, vtx_buf, inst1, inst2, inst3, smp);
setup_bind(*gPipelines.particle_alpha.bind, idx_buf, vtx_buf, inst1, inst2, inst3, smp); setup_bind(*gPipelines.particle_alpha.bind, idx_buf, vtx_buf, inst1, inst2, inst3, smp);
} }
create_debugline_pipeline :: () {
buf_desc := sg_buffer_desc.{
size = DEBUG_LINE_MAX * 2 * 7 * size_of(float),
usage = .DYNAMIC,
label = "debug_line_verts",
};
gPipelines.debugline.bind.vertex_buffers[0] = sg_make_buffer(*buf_desc);
pipeline : sg_pipeline_desc;
shader_desc := debugline_shader_desc(sg_query_backend());
pipeline.shader = sg_make_shader(*shader_desc);
pipeline.primitive_type = .LINES;
pipeline.layout.buffers[0].stride = 28;
pipeline.layout.attrs[ATTR_debugline_a_pos] = .{ format = .FLOAT3, buffer_index = 0, offset = 0 };
pipeline.layout.attrs[ATTR_debugline_a_col] = .{ format = .FLOAT4, buffer_index = 0, offset = 12 };
pipeline.depth = .{
write_enabled = false,
compare = .LESS_EQUAL,
pixel_format = .DEPTH,
};
color_state := sg_color_target_state.{
pixel_format = .RGBA32F,
};
pipeline.color_count = 1;
pipeline.colors[0] = color_state;
pipeline.label = "debugline_pipeline";
gPipelines.debugline.pipeline = sg_make_pipeline(*pipeline);
}

View File

@ -13,6 +13,7 @@
#load "tasks.jai"; #load "tasks.jai";
#load "camera.jai"; #load "camera.jai";
#load "arbtri.jai"; #load "arbtri.jai";
#load "debug_draw.jai";
#load "meshgen.jai"; #load "meshgen.jai";
#load "helpers.jai"; #load "helpers.jai";
#load "animation.jai"; #load "animation.jai";

View File

@ -65,6 +65,10 @@ Rendering_Task_Trixels :: struct {
t.type = .TRIXELS; t.type = .TRIXELS;
colMultipliers : *[16][16][16]Vector3; colMultipliers : *[16][16][16]Vector3;
trile : *Trile; trile : *Trile;
world_offset : Vector3;
brightness : float = 1.0;
tile_rotation : Matrix4 = .{_11=1, _22=1, _33=1, _44=1};
is_secondary : bool;
} }
Rendering_Task_Particles :: struct { Rendering_Task_Particles :: struct {
@ -108,10 +112,15 @@ tasks_to_commands :: () {
case .TRIXELS; case .TRIXELS;
trixelsTask := (cast(*Rendering_Task_Trixels)it); trixelsTask := (cast(*Rendering_Task_Trixels)it);
updateCommand := New(Render_Command_Update_Trixels,, temp); updateCommand := New(Render_Command_Update_Trixels,, temp);
updateCommand.trile = trixelsTask.trile; updateCommand.trile = trixelsTask.trile;
updateCommand.colMultipliers = trixelsTask.colMultipliers; updateCommand.colMultipliers = trixelsTask.colMultipliers;
updateCommand.is_secondary = trixelsTask.is_secondary;
array_add(*render_command_buckets.setup, updateCommand); array_add(*render_command_buckets.setup, updateCommand);
drawCommand := New(Render_Command_Draw_Trixels,, temp); drawCommand := New(Render_Command_Draw_Trixels,, temp);
drawCommand.world_offset = trixelsTask.world_offset;
drawCommand.brightness = trixelsTask.brightness;
drawCommand.tile_rotation = trixelsTask.tile_rotation;
drawCommand.is_secondary = trixelsTask.is_secondary;
array_add(*render_command_buckets.main, drawCommand); array_add(*render_command_buckets.main, drawCommand);
// Currently no need to draw trixels anywhere but the editor so no // Currently no need to draw trixels anywhere but the editor so no
// need for drawing them in the planar reflection pass... // need for drawing them in the planar reflection pass...

View File

@ -0,0 +1,316 @@
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc -i shader_debugline.glsl -o ./jai/shader_debugline.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
Overview:
=========
Shader program: 'debugline':
Get shader desc: debugline_shader_desc(sg_query_backend())
Vertex Shader: vs_debugline
Fragment Shader: fs_debugline
Attributes:
ATTR_debugline_a_pos => 0
ATTR_debugline_a_col => 1
Bindings:
Uniform block 'debugline_vs_params':
Jai struct: Debugline_Vs_Params
Bind slot: UB_debugline_vs_params => 0
*/
ATTR_debugline_a_pos :: 0;
ATTR_debugline_a_col :: 1;
UB_debugline_vs_params :: 0;
Debugline_Vs_Params :: struct {
mvp: [16]float;
};
/*
#version 430
uniform vec4 debugline_vs_params[4];
layout(location = 0) in vec3 a_pos;
layout(location = 0) out vec4 v_col;
layout(location = 1) in vec4 a_col;
void main()
{
gl_Position = mat4(debugline_vs_params[0], debugline_vs_params[1], debugline_vs_params[2], debugline_vs_params[3]) * vec4(a_pos, 1.0);
v_col = a_col;
}
*/
vs_debugline_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,0x65,0x62,0x75,0x67,
0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,
0x5d,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,0x33,0x20,
0x61,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,
0x76,0x65,0x63,0x34,0x20,0x76,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x61,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,
0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,
0x20,0x6d,0x61,0x74,0x34,0x28,0x64,0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x64,0x65,
0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
0x73,0x5b,0x31,0x5d,0x2c,0x20,0x64,0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x64,0x65,
0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x61,0x5f,0x70,
0x6f,0x73,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,
0x63,0x6f,0x6c,0x20,0x3d,0x20,0x61,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
];
/*
#version 430
layout(location = 0) out vec4 frag_color;
layout(location = 0) in vec4 v_col;
void main()
{
frag_color = v_col;
}
*/
fs_debugline_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,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,0x34,0x20,0x76,0x5f,0x63,0x6f,0x6c,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,0x5f,0x63,0x6f,
0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 300 es
uniform vec4 debugline_vs_params[4];
layout(location = 0) in vec3 a_pos;
out vec4 v_col;
layout(location = 1) in vec4 a_col;
void main()
{
gl_Position = mat4(debugline_vs_params[0], debugline_vs_params[1], debugline_vs_params[2], debugline_vs_params[3]) * vec4(a_pos, 1.0);
v_col = a_col;
}
*/
vs_debugline_source_glsl300es := u8.[
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x64,0x65,
0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
0x73,0x5b,0x34,0x5d,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,0x33,0x20,0x61,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,
0x63,0x34,0x20,0x76,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,
0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x61,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x0a,0x76,
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,
0x61,0x74,0x34,0x28,0x64,0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x64,0x65,0x62,0x75,
0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
0x31,0x5d,0x2c,0x20,0x64,0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x64,0x65,0x62,0x75,
0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x61,0x5f,0x70,0x6f,0x73,
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x63,0x6f,
0x6c,0x20,0x3d,0x20,0x61,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 300 es
precision mediump float;
precision highp int;
layout(location = 0) out highp vec4 frag_color;
in highp vec4 v_col;
void main()
{
frag_color = v_col;
}
*/
fs_debugline_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,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,0x34,0x20,0x76,0x5f,0x63,
0x6f,0x6c,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,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct debugline_vs_params
{
float4x4 mvp;
};
struct main0_out
{
float4 v_col [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 a_pos [[attribute(0)]];
float4 a_col [[attribute(1)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant debugline_vs_params& _19 [[buffer(0)]])
{
main0_out out = {};
out.gl_Position = _19.mvp * float4(in.a_pos, 1.0);
out.v_col = in.a_col;
return out;
}
*/
vs_debugline_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,
0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,
0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,
0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x76,0x5f,0x63,0x6f,0x6c,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,0x33,0x20,0x61,0x5f,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x61,0x74,
0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x61,0x5f,0x63,0x6f,0x6c,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,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x64,
0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x26,0x20,0x5f,0x31,0x39,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,
0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,0x39,0x2e,0x6d,0x76,0x70,0x20,0x2a,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x61,0x5f,0x70,0x6f,0x73,
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,
0x76,0x5f,0x63,0x6f,0x6c,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x61,0x5f,0x63,0x6f,0x6c,
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 main0_out
{
float4 frag_color [[color(0)]];
};
struct main0_in
{
float4 v_col [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.frag_color = in.v_col;
return out;
}
*/
fs_debugline_source_metal_macos := u8.[
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x76,0x5f,0x63,0x6f,0x6c,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,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,0x69,0x6e,0x2e,
0x76,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
debugline_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc: sg_shader_desc;
desc.label = "debugline_shader";
if backend == {
case .GLCORE;
desc.vertex_func.source = xx *vs_debugline_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = xx *fs_debugline_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[0].glsl_name = "a_pos";
desc.attrs[1].base_type = .FLOAT;
desc.attrs[1].glsl_name = "a_col";
desc.uniform_blocks[0].stage = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "debugline_vs_params";
case .GLES3;
desc.vertex_func.source = xx *vs_debugline_source_glsl300es;
desc.vertex_func.entry = "main";
desc.fragment_func.source = xx *fs_debugline_source_glsl300es;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[0].glsl_name = "a_pos";
desc.attrs[1].base_type = .FLOAT;
desc.attrs[1].glsl_name = "a_col";
desc.uniform_blocks[0].stage = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "debugline_vs_params";
case .METAL_MACOS;
desc.vertex_func.source = xx *vs_debugline_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = xx *fs_debugline_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 = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].msl_buffer_n = 0;
}
return desc;
}

View File

@ -250,26 +250,26 @@ vs_plane_source_glsl430 := u8.[
vec3 _274 = normalize(((((texture(normal_map_normalsmp, (pos.xz * 0.4000000059604644775390625) + (_185 * 1.5)).xzy * 2.0) - vec3(1.0)) + ((texture(normal_map_normalsmp, (pos.xz * 0.100000001490116119384765625) + (_185 * 1.7000000476837158203125)).xzy * 2.0) - vec3(1.0))) + ((texture(normal_map_normalsmp, (pos.xz * 1.0) + (_185 * 2.7000000476837158203125)).xzy * 2.0) - vec3(1.0))) + ((texture(normal_map_normalsmp, (pos.xz * 0.0199999995529651641845703125) + (_185 * 0.100000001490116119384765625)).xzy * 2.0) - vec3(1.0))); vec3 _274 = normalize(((((texture(normal_map_normalsmp, (pos.xz * 0.4000000059604644775390625) + (_185 * 1.5)).xzy * 2.0) - vec3(1.0)) + ((texture(normal_map_normalsmp, (pos.xz * 0.100000001490116119384765625) + (_185 * 1.7000000476837158203125)).xzy * 2.0) - vec3(1.0))) + ((texture(normal_map_normalsmp, (pos.xz * 1.0) + (_185 * 2.7000000476837158203125)).xzy * 2.0) - vec3(1.0))) + ((texture(normal_map_normalsmp, (pos.xz * 0.0199999995529651641845703125) + (_185 * 0.100000001490116119384765625)).xzy * 2.0) - vec3(1.0)));
vec3 _285 = normalize(_279.cameraPosition - pos.xyz); vec3 _285 = normalize(_279.cameraPosition - pos.xyz);
vec3 _290 = normalize(_146.sunPosition); vec3 _290 = normalize(_146.sunPosition);
float param = _285.y; float param = max(0.0, dot(_285, _274));
float _317 = min(1.0, fresnelSchlick(param).x + 0.300000011920928955078125); float _321 = min(1.0, fresnelSchlick(param).x + 0.449999988079071044921875);
vec4 _329 = _279.mvp_shadow * vec4(pos.xyz, 1.0); vec4 _338 = _279.mvp_shadow * vec4(floor(pos.xyz * 16.0) * vec3(0.0625), 1.0);
vec3 _341 = ((_329.xyz / vec3(_329.w)) * 0.5) + vec3(0.5); vec3 _350 = ((_338.xyz / vec3(_338.w)) * 0.5) + vec3(0.5);
float _346 = _341.z - 0.001000000047497451305389404296875; float _355 = _350.z - 0.001000000047497451305389404296875;
vec3 _501 = _341; vec3 _512 = _350;
_501.z = _346; _512.z = _355;
float _358 = texture(shadow_plane_shadowsmp, vec3(_501.xy, _346)); float _367 = texture(shadow_plane_shadowsmp, vec3(_512.xy, _355));
vec2 _398 = gl_FragCoord.xy / vec2(float(_279.screen_w), float(_279.screen_h)); vec2 _408 = gl_FragCoord.xy / vec2(float(_279.screen_w), float(_279.screen_h));
_398.y = 1.0 - _398.y; _408.y = 1.0 - _408.y;
vec3 param_1 = normalize(pos.xyz); vec3 param_1 = normalize(pos.xyz);
vec3 param_2 = _146.sunPosition; vec3 param_2 = _146.sunPosition;
float _451 = smoothstep(750.0, 1000.0, length(pos.xz)); float _462 = smoothstep(750.0, 1000.0, length(pos.xz));
frag_color = vec4(mix(mix((((_146.waterColor * max(0.0, dot(_274, _290))) * _146.sunLightColor) * _146.sunIntensity) * _358, texture(reftex_refsmp, _398 + (_274.xz * 0.004999999888241291046142578125)).xyz, vec3(_317)) + (((_146.sunLightColor * _146.sunIntensity) * pow(max(0.0, dot(normalize(_290 + _285), _274)), 32.0)) * _358), sky(param_1, param_2) * _146.skyIntensity, vec3(_451)), mix(mix(0.300000011920928955078125, 0.5, _317), 1.0, _451)); frag_color = vec4(mix(mix((((_146.waterColor * max(0.0, dot(_274, _290))) * _146.sunLightColor) * _146.sunIntensity) * _367, texture(reftex_refsmp, _408 + (_274.xz * 0.007000000216066837310791015625)).xyz, vec3(_321)) + ((((_146.sunLightColor * _146.sunIntensity) * pow(max(0.0, dot(normalize(_290 + _285), _274)), max(_279.shininess, 1.0))) * _321) * _367), sky(param_1, param_2) * _146.skyIntensity, vec3(_462)), mix(mix(0.300000011920928955078125, 0.5, _321), 1.0, _462));
} }
else else
{ {
vec2 param_3 = (pos.xz * 0.0500000007450580596923828125) + vec2(_146.time * 0.00999999977648258209228515625); vec2 param_3 = (pos.xz * 0.0500000007450580596923828125) + vec2(_146.time * 0.00999999977648258209228515625);
float _481 = fbm(param_3); float _492 = fbm(param_3);
frag_color = vec4(_146.deepColor * mix(0.800000011920928955078125, 1.2000000476837158203125, _481), 1.0); frag_color = vec4(_146.deepColor * mix(0.800000011920928955078125, 1.2000000476837158203125, _492), 1.0);
} }
} }
@ -451,46 +451,49 @@ fs_plane_source_glsl430 := u8.[
0x30,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x31, 0x30,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x31,
0x34,0x36,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b, 0x34,0x36,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70, 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,
0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x5f,0x32,0x38,0x35,0x2e,0x79,0x3b,0x0a,0x20, 0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x31, 0x64,0x6f,0x74,0x28,0x5f,0x32,0x38,0x35,0x2c,0x20,0x5f,0x32,0x37,0x34,0x29,0x29,
0x37,0x20,0x3d,0x20,0x6d,0x69,0x6e,0x28,0x31,0x2e,0x30,0x2c,0x20,0x66,0x72,0x65, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x28,0x70,0x61,0x72,0x61, 0x5f,0x33,0x32,0x31,0x20,0x3d,0x20,0x6d,0x69,0x6e,0x28,0x31,0x2e,0x30,0x2c,0x20,
0x6d,0x29,0x2e,0x78,0x20,0x2b,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30, 0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x28,0x70,
0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32, 0x61,0x72,0x61,0x6d,0x29,0x2e,0x78,0x20,0x2b,0x20,0x30,0x2e,0x34,0x34,0x39,0x39,
0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34, 0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,
0x20,0x5f,0x33,0x32,0x39,0x20,0x3d,0x20,0x5f,0x32,0x37,0x39,0x2e,0x6d,0x76,0x70, 0x31,0x38,0x37,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,
0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70, 0x65,0x63,0x34,0x20,0x5f,0x33,0x33,0x38,0x20,0x3d,0x20,0x5f,0x32,0x37,0x39,0x2e,
0x6f,0x73,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20, 0x6d,0x76,0x70,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x20,0x2a,0x20,0x76,0x65,0x63,
0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x33,0x34,0x31,0x20, 0x34,0x28,0x66,0x6c,0x6f,0x6f,0x72,0x28,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x20,
0x3d,0x20,0x28,0x28,0x5f,0x33,0x32,0x39,0x2e,0x78,0x79,0x7a,0x20,0x2f,0x20,0x76, 0x2a,0x20,0x31,0x36,0x2e,0x30,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,0x30,
0x65,0x63,0x33,0x28,0x5f,0x33,0x32,0x39,0x2e,0x77,0x29,0x29,0x20,0x2a,0x20,0x30, 0x2e,0x30,0x36,0x32,0x35,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x33,0x35,0x30,0x20,
0x3d,0x20,0x28,0x28,0x5f,0x33,0x33,0x38,0x2e,0x78,0x79,0x7a,0x20,0x2f,0x20,0x76,
0x65,0x63,0x33,0x28,0x5f,0x33,0x33,0x38,0x2e,0x77,0x29,0x29,0x20,0x2a,0x20,0x30,
0x2e,0x35,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29,0x3b, 0x2e,0x35,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f, 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
0x33,0x34,0x36,0x20,0x3d,0x20,0x5f,0x33,0x34,0x31,0x2e,0x7a,0x20,0x2d,0x20,0x30, 0x33,0x35,0x35,0x20,0x3d,0x20,0x5f,0x33,0x35,0x30,0x2e,0x7a,0x20,0x2d,0x20,0x30,
0x2e,0x30,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x34,0x37,0x34,0x39,0x37, 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, 0x34,0x35,0x31,0x33,0x30,0x35,0x33,0x38,0x39,0x34,0x30,0x34,0x32,0x39,0x36,0x38,
0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33, 0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,
0x20,0x5f,0x35,0x30,0x31,0x20,0x3d,0x20,0x5f,0x33,0x34,0x31,0x3b,0x0a,0x20,0x20, 0x20,0x5f,0x35,0x31,0x32,0x20,0x3d,0x20,0x5f,0x33,0x35,0x30,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x35,0x30,0x31,0x2e,0x7a,0x20,0x3d,0x20,0x5f, 0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x35,0x31,0x32,0x2e,0x7a,0x20,0x3d,0x20,0x5f,
0x33,0x34,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, 0x33,0x35,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x20,0x5f,0x33,0x35,0x38,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72, 0x61,0x74,0x20,0x5f,0x33,0x36,0x37,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,
0x65,0x28,0x73,0x68,0x61,0x64,0x6f,0x77,0x5f,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x73, 0x65,0x28,0x73,0x68,0x61,0x64,0x6f,0x77,0x5f,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x73,
0x68,0x61,0x64,0x6f,0x77,0x73,0x6d,0x70,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x5f, 0x68,0x61,0x64,0x6f,0x77,0x73,0x6d,0x70,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,
0x35,0x30,0x31,0x2e,0x78,0x79,0x2c,0x20,0x5f,0x33,0x34,0x36,0x29,0x29,0x3b,0x0a, 0x35,0x31,0x32,0x2e,0x78,0x79,0x2c,0x20,0x5f,0x33,0x35,0x35,0x29,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x33,0x39, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x34,0x30,
0x38,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x43,0x6f,0x6f,0x72,0x64, 0x38,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x43,0x6f,0x6f,0x72,0x64,
0x2e,0x78,0x79,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74, 0x2e,0x78,0x79,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,
0x28,0x5f,0x32,0x37,0x39,0x2e,0x73,0x63,0x72,0x65,0x65,0x6e,0x5f,0x77,0x29,0x2c, 0x28,0x5f,0x32,0x37,0x39,0x2e,0x73,0x63,0x72,0x65,0x65,0x6e,0x5f,0x77,0x29,0x2c,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x32,0x37,0x39,0x2e,0x73,0x63,0x72,0x65, 0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x32,0x37,0x39,0x2e,0x73,0x63,0x72,0x65,
0x65,0x6e,0x5f,0x68,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x65,0x6e,0x5f,0x68,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x5f,0x33,0x39,0x38,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f, 0x5f,0x34,0x30,0x38,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,
0x33,0x39,0x38,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76, 0x34,0x30,0x38,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,
0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6e,0x6f, 0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6e,0x6f,
0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29, 0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,
0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75, 0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,
0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, 0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x31,0x20,0x3d,0x20, 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x36,0x32,0x20,0x3d,0x20,
0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x37,0x35,0x30,0x2e,0x30, 0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x37,0x35,0x30,0x2e,0x30,
0x2c,0x20,0x31,0x30,0x30,0x30,0x2e,0x30,0x2c,0x20,0x6c,0x65,0x6e,0x67,0x74,0x68, 0x2c,0x20,0x31,0x30,0x30,0x30,0x2e,0x30,0x2c,0x20,0x6c,0x65,0x6e,0x67,0x74,0x68,
0x28,0x70,0x6f,0x73,0x2e,0x78,0x7a,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, 0x28,0x70,0x6f,0x73,0x2e,0x78,0x7a,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
@ -501,46 +504,48 @@ fs_plane_source_glsl430 := u8.[
0x32,0x37,0x34,0x2c,0x20,0x5f,0x32,0x39,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x5f, 0x32,0x37,0x34,0x2c,0x20,0x5f,0x32,0x39,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,
0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f, 0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,
0x72,0x29,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x49,0x6e,0x74, 0x72,0x29,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x49,0x6e,0x74,
0x65,0x6e,0x73,0x69,0x74,0x79,0x29,0x20,0x2a,0x20,0x5f,0x33,0x35,0x38,0x2c,0x20, 0x65,0x6e,0x73,0x69,0x74,0x79,0x29,0x20,0x2a,0x20,0x5f,0x33,0x36,0x37,0x2c,0x20,
0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x72,0x65,0x66,0x74,0x65,0x78,0x5f,0x72, 0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x72,0x65,0x66,0x74,0x65,0x78,0x5f,0x72,
0x65,0x66,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x33,0x39,0x38,0x20,0x2b,0x20,0x28,0x5f, 0x65,0x66,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x34,0x30,0x38,0x20,0x2b,0x20,0x28,0x5f,
0x32,0x37,0x34,0x2e,0x78,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30,0x34,0x39,0x39, 0x32,0x37,0x34,0x2e,0x78,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30,0x37,0x30,0x30,
0x39,0x39,0x39,0x39,0x38,0x38,0x38,0x32,0x34,0x31,0x32,0x39,0x31,0x30,0x34,0x36, 0x30,0x30,0x30,0x30,0x32,0x31,0x36,0x30,0x36,0x36,0x38,0x33,0x37,0x33,0x31,0x30,
0x31,0x34,0x32,0x35,0x37,0x38,0x31,0x32,0x35,0x29,0x29,0x2e,0x78,0x79,0x7a,0x2c, 0x37,0x39,0x31,0x30,0x31,0x35,0x36,0x32,0x35,0x29,0x29,0x2e,0x78,0x79,0x7a,0x2c,
0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x33,0x31,0x37,0x29,0x29,0x20,0x2b,0x20,0x28, 0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x33,0x32,0x31,0x29,0x29,0x20,0x2b,0x20,0x28,
0x28,0x28,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43, 0x28,0x28,0x28,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,
0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x49, 0x43,0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,
0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x29,0x20,0x2a,0x20,0x70,0x6f,0x77,0x28, 0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x29,0x20,0x2a,0x20,0x70,0x6f,0x77,
0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x6e,0x6f,0x72, 0x28,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x6e,0x6f,
0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,0x39,0x30,0x20,0x2b,0x20,0x5f,0x32, 0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,0x39,0x30,0x20,0x2b,0x20,0x5f,
0x38,0x35,0x29,0x2c,0x20,0x5f,0x32,0x37,0x34,0x29,0x29,0x2c,0x20,0x33,0x32,0x2e, 0x32,0x38,0x35,0x29,0x2c,0x20,0x5f,0x32,0x37,0x34,0x29,0x29,0x2c,0x20,0x6d,0x61,
0x30,0x29,0x29,0x20,0x2a,0x20,0x5f,0x33,0x35,0x38,0x29,0x2c,0x20,0x73,0x6b,0x79, 0x78,0x28,0x5f,0x32,0x37,0x39,0x2e,0x73,0x68,0x69,0x6e,0x69,0x6e,0x65,0x73,0x73,
0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f, 0x2c,0x20,0x31,0x2e,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x33,0x32,0x31,0x29,
0x32,0x29,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74, 0x20,0x2a,0x20,0x5f,0x33,0x36,0x37,0x29,0x2c,0x20,0x73,0x6b,0x79,0x28,0x70,0x61,
0x65,0x6e,0x73,0x69,0x74,0x79,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x34,0x35, 0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x29,0x20,
0x31,0x29,0x29,0x2c,0x20,0x6d,0x69,0x78,0x28,0x6d,0x69,0x78,0x28,0x30,0x2e,0x33, 0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,0x73,
0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35, 0x69,0x74,0x79,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x34,0x36,0x32,0x29,0x29,
0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x5f,0x33, 0x2c,0x20,0x6d,0x69,0x78,0x28,0x6d,0x69,0x78,0x28,0x30,0x2e,0x33,0x30,0x30,0x30,
0x31,0x37,0x29,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x5f,0x34,0x35,0x31,0x29,0x29, 0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65, 0x38,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x5f,0x33,0x32,0x31,0x29,
0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76, 0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x5f,0x34,0x36,0x32,0x29,0x29,0x3b,0x0a,0x20,
0x65,0x63,0x32,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x28,0x70, 0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,
0x6f,0x73,0x2e,0x78,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x30,0x35,0x30,0x30,0x30,0x30, 0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,
0x30,0x30,0x30,0x37,0x34,0x35,0x30,0x35,0x38,0x30,0x35,0x39,0x36,0x39,0x32,0x33, 0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x28,0x70,0x6f,0x73,0x2e,
0x38,0x32,0x38,0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f, 0x78,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x30,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
0x31,0x34,0x36,0x2e,0x74,0x69,0x6d,0x65,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30,0x39, 0x37,0x34,0x35,0x30,0x35,0x38,0x30,0x35,0x39,0x36,0x39,0x32,0x33,0x38,0x32,0x38,
0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30, 0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x31,0x34,0x36,
0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20, 0x2e,0x74,0x69,0x6d,0x65,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,
0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x31,0x20, 0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,
0x3d,0x20,0x66,0x62,0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a, 0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c, 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x39,0x32,0x20,0x3d,0x20,0x66,
0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x31,0x34,0x36,0x2e,0x64, 0x62,0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x65,0x65,0x70,0x43,0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x6d,0x69,0x78,0x28,0x30, 0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
0x2e,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38, 0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x31,0x34,0x36,0x2e,0x64,0x65,0x65,0x70,
0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x2c,0x20,0x31,0x2e,0x32,0x30,0x30, 0x43,0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x6d,0x69,0x78,0x28,0x30,0x2e,0x38,0x30,
0x30,0x30,0x30,0x30,0x34,0x37,0x36,0x38,0x33,0x37,0x31,0x35,0x38,0x32,0x30,0x33, 0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,
0x31,0x32,0x35,0x2c,0x20,0x5f,0x34,0x38,0x31,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29, 0x30,0x37,0x38,0x31,0x32,0x35,0x2c,0x20,0x31,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00, 0x30,0x34,0x37,0x36,0x38,0x33,0x37,0x31,0x35,0x38,0x32,0x30,0x33,0x31,0x32,0x35,
0x2c,0x20,0x5f,0x34,0x39,0x32,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00,
]; ];
/* /*
#version 300 es #version 300 es
@ -692,26 +697,26 @@ vs_plane_source_glsl300es := u8.[
highp vec3 _274 = normalize(((((texture(normal_map_normalsmp, (pos.xz * 0.4000000059604644775390625) + (_185 * 1.5)).xzy * 2.0) - vec3(1.0)) + ((texture(normal_map_normalsmp, (pos.xz * 0.100000001490116119384765625) + (_185 * 1.7000000476837158203125)).xzy * 2.0) - vec3(1.0))) + ((texture(normal_map_normalsmp, (pos.xz * 1.0) + (_185 * 2.7000000476837158203125)).xzy * 2.0) - vec3(1.0))) + ((texture(normal_map_normalsmp, (pos.xz * 0.0199999995529651641845703125) + (_185 * 0.100000001490116119384765625)).xzy * 2.0) - vec3(1.0))); highp vec3 _274 = normalize(((((texture(normal_map_normalsmp, (pos.xz * 0.4000000059604644775390625) + (_185 * 1.5)).xzy * 2.0) - vec3(1.0)) + ((texture(normal_map_normalsmp, (pos.xz * 0.100000001490116119384765625) + (_185 * 1.7000000476837158203125)).xzy * 2.0) - vec3(1.0))) + ((texture(normal_map_normalsmp, (pos.xz * 1.0) + (_185 * 2.7000000476837158203125)).xzy * 2.0) - vec3(1.0))) + ((texture(normal_map_normalsmp, (pos.xz * 0.0199999995529651641845703125) + (_185 * 0.100000001490116119384765625)).xzy * 2.0) - vec3(1.0)));
highp vec3 _285 = normalize(_279.cameraPosition - pos.xyz); highp vec3 _285 = normalize(_279.cameraPosition - pos.xyz);
highp vec3 _290 = normalize(_146.sunPosition); highp vec3 _290 = normalize(_146.sunPosition);
highp float param = _285.y; highp float param = max(0.0, dot(_285, _274));
highp float _317 = min(1.0, fresnelSchlick(param).x + 0.300000011920928955078125); highp float _321 = min(1.0, fresnelSchlick(param).x + 0.449999988079071044921875);
highp vec4 _329 = _279.mvp_shadow * vec4(pos.xyz, 1.0); highp vec4 _338 = _279.mvp_shadow * vec4(floor(pos.xyz * 16.0) * vec3(0.0625), 1.0);
highp vec3 _341 = ((_329.xyz / vec3(_329.w)) * 0.5) + vec3(0.5); highp vec3 _350 = ((_338.xyz / vec3(_338.w)) * 0.5) + vec3(0.5);
highp float _346 = _341.z - 0.001000000047497451305389404296875; highp float _355 = _350.z - 0.001000000047497451305389404296875;
highp vec3 _501 = _341; highp vec3 _512 = _350;
_501.z = _346; _512.z = _355;
highp float _358 = texture(shadow_plane_shadowsmp, vec3(_501.xy, _346)); highp float _367 = texture(shadow_plane_shadowsmp, vec3(_512.xy, _355));
highp vec2 _398 = gl_FragCoord.xy / vec2(float(_279.screen_w), float(_279.screen_h)); highp vec2 _408 = gl_FragCoord.xy / vec2(float(_279.screen_w), float(_279.screen_h));
_398.y = 1.0 - _398.y; _408.y = 1.0 - _408.y;
highp vec3 param_1 = normalize(pos.xyz); highp vec3 param_1 = normalize(pos.xyz);
highp vec3 param_2 = _146.sunPosition; highp vec3 param_2 = _146.sunPosition;
highp float _451 = smoothstep(750.0, 1000.0, length(pos.xz)); highp float _462 = smoothstep(750.0, 1000.0, length(pos.xz));
frag_color = vec4(mix(mix((((_146.waterColor * max(0.0, dot(_274, _290))) * _146.sunLightColor) * _146.sunIntensity) * _358, texture(reftex_refsmp, _398 + (_274.xz * 0.004999999888241291046142578125)).xyz, vec3(_317)) + (((_146.sunLightColor * _146.sunIntensity) * pow(max(0.0, dot(normalize(_290 + _285), _274)), 32.0)) * _358), sky(param_1, param_2) * _146.skyIntensity, vec3(_451)), mix(mix(0.300000011920928955078125, 0.5, _317), 1.0, _451)); frag_color = vec4(mix(mix((((_146.waterColor * max(0.0, dot(_274, _290))) * _146.sunLightColor) * _146.sunIntensity) * _367, texture(reftex_refsmp, _408 + (_274.xz * 0.007000000216066837310791015625)).xyz, vec3(_321)) + ((((_146.sunLightColor * _146.sunIntensity) * pow(max(0.0, dot(normalize(_290 + _285), _274)), max(_279.shininess, 1.0))) * _321) * _367), sky(param_1, param_2) * _146.skyIntensity, vec3(_462)), mix(mix(0.300000011920928955078125, 0.5, _321), 1.0, _462));
} }
else else
{ {
highp vec2 param_3 = (pos.xz * 0.0500000007450580596923828125) + vec2(_146.time * 0.00999999977648258209228515625); highp vec2 param_3 = (pos.xz * 0.0500000007450580596923828125) + vec2(_146.time * 0.00999999977648258209228515625);
highp float _481 = fbm(param_3); highp float _492 = fbm(param_3);
frag_color = vec4(_146.deepColor * mix(0.800000011920928955078125, 1.2000000476837158203125, _481), 1.0); frag_color = vec4(_146.deepColor * mix(0.800000011920928955078125, 1.2000000476837158203125, _492), 1.0);
} }
} }
@ -907,42 +912,45 @@ fs_plane_source_glsl300es := u8.[
0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x50, 0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x50,
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61, 0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,
0x72,0x61,0x6d,0x20,0x3d,0x20,0x5f,0x32,0x38,0x35,0x2e,0x79,0x3b,0x0a,0x20,0x20, 0x72,0x61,0x6d,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,
0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61, 0x6f,0x74,0x28,0x5f,0x32,0x38,0x35,0x2c,0x20,0x5f,0x32,0x37,0x34,0x29,0x29,0x3b,
0x74,0x20,0x5f,0x33,0x31,0x37,0x20,0x3d,0x20,0x6d,0x69,0x6e,0x28,0x31,0x2e,0x30, 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,
0x2c,0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b, 0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x32,0x31,0x20,0x3d,0x20,0x6d,0x69,0x6e,0x28,
0x28,0x70,0x61,0x72,0x61,0x6d,0x29,0x2e,0x78,0x20,0x2b,0x20,0x30,0x2e,0x33,0x30, 0x31,0x2e,0x30,0x2c,0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,
0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35, 0x69,0x63,0x6b,0x28,0x70,0x61,0x72,0x61,0x6d,0x29,0x2e,0x78,0x20,0x2b,0x20,0x30,
0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x2e,0x34,0x34,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x33,0x32,0x39, 0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x20,0x3d,0x20,0x5f,0x32,0x37,0x39,0x2e,0x6d,0x76,0x70,0x5f,0x73,0x68,0x61,0x64, 0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,
0x6f,0x77,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x2e,0x78,0x79, 0x33,0x33,0x38,0x20,0x3d,0x20,0x5f,0x32,0x37,0x39,0x2e,0x6d,0x76,0x70,0x5f,0x73,
0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x68,0x61,0x64,0x6f,0x77,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x66,0x6c,0x6f,
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x33,0x34,0x31, 0x6f,0x72,0x28,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x31,0x36,0x2e,
0x20,0x3d,0x20,0x28,0x28,0x5f,0x33,0x32,0x39,0x2e,0x78,0x79,0x7a,0x20,0x2f,0x20, 0x30,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x36,0x32,0x35,
0x76,0x65,0x63,0x33,0x28,0x5f,0x33,0x32,0x39,0x2e,0x77,0x29,0x29,0x20,0x2a,0x20, 0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x33,0x35,0x30,
0x20,0x3d,0x20,0x28,0x28,0x5f,0x33,0x33,0x38,0x2e,0x78,0x79,0x7a,0x20,0x2f,0x20,
0x76,0x65,0x63,0x33,0x28,0x5f,0x33,0x33,0x38,0x2e,0x77,0x29,0x29,0x20,0x2a,0x20,
0x30,0x2e,0x35,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29, 0x30,0x2e,0x35,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x34,0x36,0x20,0x3d,0x20,0x5f,0x33,0x34, 0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x35,0x35,0x20,0x3d,0x20,0x5f,0x33,0x35,
0x31,0x2e,0x7a,0x20,0x2d,0x20,0x30,0x2e,0x30,0x30,0x31,0x30,0x30,0x30,0x30,0x30, 0x30,0x2e,0x7a,0x20,0x2d,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, 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,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, 0x34,0x30,0x34,0x32,0x39,0x36,0x38,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x35, 0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x35,
0x30,0x31,0x20,0x3d,0x20,0x5f,0x33,0x34,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20, 0x31,0x32,0x20,0x3d,0x20,0x5f,0x33,0x35,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x5f,0x35,0x30,0x31,0x2e,0x7a,0x20,0x3d,0x20,0x5f,0x33,0x34,0x36, 0x20,0x20,0x20,0x5f,0x35,0x31,0x32,0x2e,0x7a,0x20,0x3d,0x20,0x5f,0x33,0x35,0x35,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x35,0x38,0x20,0x3d,0x20,0x74,0x65,0x78, 0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x36,0x37,0x20,0x3d,0x20,0x74,0x65,0x78,
0x74,0x75,0x72,0x65,0x28,0x73,0x68,0x61,0x64,0x6f,0x77,0x5f,0x70,0x6c,0x61,0x6e, 0x74,0x75,0x72,0x65,0x28,0x73,0x68,0x61,0x64,0x6f,0x77,0x5f,0x70,0x6c,0x61,0x6e,
0x65,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x73,0x6d,0x70,0x2c,0x20,0x76,0x65,0x63, 0x65,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x73,0x6d,0x70,0x2c,0x20,0x76,0x65,0x63,
0x33,0x28,0x5f,0x35,0x30,0x31,0x2e,0x78,0x79,0x2c,0x20,0x5f,0x33,0x34,0x36,0x29, 0x33,0x28,0x5f,0x35,0x31,0x32,0x2e,0x78,0x79,0x2c,0x20,0x5f,0x33,0x35,0x35,0x29,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70, 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x33,0x39,0x38,0x20,0x3d,0x20,0x67,0x6c,0x5f, 0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x34,0x30,0x38,0x20,0x3d,0x20,0x67,0x6c,0x5f,
0x46,0x72,0x61,0x67,0x43,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x20,0x2f,0x20,0x76, 0x46,0x72,0x61,0x67,0x43,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x20,0x2f,0x20,0x76,
0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x32,0x37,0x39,0x2e,0x73, 0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x32,0x37,0x39,0x2e,0x73,
0x63,0x72,0x65,0x65,0x6e,0x5f,0x77,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28, 0x63,0x72,0x65,0x65,0x6e,0x5f,0x77,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,
0x5f,0x32,0x37,0x39,0x2e,0x73,0x63,0x72,0x65,0x65,0x6e,0x5f,0x68,0x29,0x29,0x3b, 0x5f,0x32,0x37,0x39,0x2e,0x73,0x63,0x72,0x65,0x65,0x6e,0x5f,0x68,0x29,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x33,0x39,0x38,0x2e,0x79,0x20, 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,0x30,0x38,0x2e,0x79,0x20,
0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x33,0x39,0x38,0x2e,0x79,0x3b,0x0a, 0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x34,0x30,0x38,0x2e,0x79,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,
0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6e,0x6f,0x72, 0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6e,0x6f,0x72,
0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b, 0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,
@ -950,7 +958,7 @@ fs_plane_source_glsl300es := u8.[
0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31, 0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31,
0x34,0x36,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, 0x34,0x36,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x31,0x20,0x3d,0x20,0x73,0x6d,0x6f,0x6f,0x74, 0x6f,0x61,0x74,0x20,0x5f,0x34,0x36,0x32,0x20,0x3d,0x20,0x73,0x6d,0x6f,0x6f,0x74,
0x68,0x73,0x74,0x65,0x70,0x28,0x37,0x35,0x30,0x2e,0x30,0x2c,0x20,0x31,0x30,0x30, 0x68,0x73,0x74,0x65,0x70,0x28,0x37,0x35,0x30,0x2e,0x30,0x2c,0x20,0x31,0x30,0x30,
0x30,0x2e,0x30,0x2c,0x20,0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x70,0x6f,0x73,0x2e, 0x30,0x2e,0x30,0x2c,0x20,0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x70,0x6f,0x73,0x2e,
0x78,0x7a,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72, 0x78,0x7a,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,
@ -961,47 +969,49 @@ fs_plane_source_glsl300es := u8.[
0x5f,0x32,0x39,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73, 0x5f,0x32,0x39,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,
0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x29,0x20,0x2a,0x20, 0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x29,0x20,0x2a,0x20,
0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74, 0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,
0x79,0x29,0x20,0x2a,0x20,0x5f,0x33,0x35,0x38,0x2c,0x20,0x74,0x65,0x78,0x74,0x75, 0x79,0x29,0x20,0x2a,0x20,0x5f,0x33,0x36,0x37,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,
0x72,0x65,0x28,0x72,0x65,0x66,0x74,0x65,0x78,0x5f,0x72,0x65,0x66,0x73,0x6d,0x70, 0x72,0x65,0x28,0x72,0x65,0x66,0x74,0x65,0x78,0x5f,0x72,0x65,0x66,0x73,0x6d,0x70,
0x2c,0x20,0x5f,0x33,0x39,0x38,0x20,0x2b,0x20,0x28,0x5f,0x32,0x37,0x34,0x2e,0x78, 0x2c,0x20,0x5f,0x34,0x30,0x38,0x20,0x2b,0x20,0x28,0x5f,0x32,0x37,0x34,0x2e,0x78,
0x7a,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30,0x34,0x39,0x39,0x39,0x39,0x39,0x39,0x38, 0x7a,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30,0x37,0x30,0x30,0x30,0x30,0x30,0x30,0x32,
0x38,0x38,0x32,0x34,0x31,0x32,0x39,0x31,0x30,0x34,0x36,0x31,0x34,0x32,0x35,0x37, 0x31,0x36,0x30,0x36,0x36,0x38,0x33,0x37,0x33,0x31,0x30,0x37,0x39,0x31,0x30,0x31,
0x38,0x31,0x32,0x35,0x29,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33, 0x35,0x36,0x32,0x35,0x29,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,
0x28,0x5f,0x33,0x31,0x37,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x28,0x5f,0x31,0x34, 0x28,0x5f,0x33,0x32,0x31,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x28,0x28,0x5f,0x31,
0x36,0x2e,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x20, 0x34,0x36,0x2e,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,
0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73, 0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,
0x69,0x74,0x79,0x29,0x20,0x2a,0x20,0x70,0x6f,0x77,0x28,0x6d,0x61,0x78,0x28,0x30, 0x73,0x69,0x74,0x79,0x29,0x20,0x2a,0x20,0x70,0x6f,0x77,0x28,0x6d,0x61,0x78,0x28,
0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a, 0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,
0x65,0x28,0x5f,0x32,0x39,0x30,0x20,0x2b,0x20,0x5f,0x32,0x38,0x35,0x29,0x2c,0x20, 0x7a,0x65,0x28,0x5f,0x32,0x39,0x30,0x20,0x2b,0x20,0x5f,0x32,0x38,0x35,0x29,0x2c,
0x5f,0x32,0x37,0x34,0x29,0x29,0x2c,0x20,0x33,0x32,0x2e,0x30,0x29,0x29,0x20,0x2a, 0x20,0x5f,0x32,0x37,0x34,0x29,0x29,0x2c,0x20,0x6d,0x61,0x78,0x28,0x5f,0x32,0x37,
0x20,0x5f,0x33,0x35,0x38,0x29,0x2c,0x20,0x73,0x6b,0x79,0x28,0x70,0x61,0x72,0x61, 0x39,0x2e,0x73,0x68,0x69,0x6e,0x69,0x6e,0x65,0x73,0x73,0x2c,0x20,0x31,0x2e,0x30,
0x6d,0x5f,0x31,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x29,0x20,0x2a,0x20, 0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x33,0x32,0x31,0x29,0x20,0x2a,0x20,0x5f,0x33,
0x5f,0x31,0x34,0x36,0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74, 0x36,0x37,0x29,0x2c,0x20,0x73,0x6b,0x79,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,
0x79,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x34,0x35,0x31,0x29,0x29,0x2c,0x20, 0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x29,0x20,0x2a,0x20,0x5f,0x31,0x34,
0x6d,0x69,0x78,0x28,0x6d,0x69,0x78,0x28,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30, 0x36,0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x2c,0x20,
0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31, 0x76,0x65,0x63,0x33,0x28,0x5f,0x34,0x36,0x32,0x29,0x29,0x2c,0x20,0x6d,0x69,0x78,
0x32,0x35,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x5f,0x33,0x31,0x37,0x29,0x2c,0x20, 0x28,0x6d,0x69,0x78,0x28,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,
0x31,0x2e,0x30,0x2c,0x20,0x5f,0x34,0x35,0x31,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20, 0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x2c,
0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20, 0x20,0x30,0x2e,0x35,0x2c,0x20,0x5f,0x33,0x32,0x31,0x29,0x2c,0x20,0x31,0x2e,0x30,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20, 0x2c,0x20,0x5f,0x34,0x36,0x32,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
0x76,0x65,0x63,0x32,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x28, 0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
0x70,0x6f,0x73,0x2e,0x78,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x30,0x35,0x30,0x30,0x30, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
0x30,0x30,0x30,0x30,0x37,0x34,0x35,0x30,0x35,0x38,0x30,0x35,0x39,0x36,0x39,0x32, 0x32,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x28,0x70,0x6f,0x73,
0x33,0x38,0x32,0x38,0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28, 0x2e,0x78,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x30,0x35,0x30,0x30,0x30,0x30,0x30,0x30,
0x5f,0x31,0x34,0x36,0x2e,0x74,0x69,0x6d,0x65,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30, 0x30,0x37,0x34,0x35,0x30,0x35,0x38,0x30,0x35,0x39,0x36,0x39,0x32,0x33,0x38,0x32,
0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32, 0x38,0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x31,0x34,
0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20, 0x36,0x2e,0x74,0x69,0x6d,0x65,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,
0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61, 0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,
0x74,0x20,0x5f,0x34,0x38,0x31,0x20,0x3d,0x20,0x66,0x62,0x6d,0x28,0x70,0x61,0x72, 0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66, 0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34, 0x34,0x39,0x32,0x20,0x3d,0x20,0x66,0x62,0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,
0x28,0x5f,0x31,0x34,0x36,0x2e,0x64,0x65,0x65,0x70,0x43,0x6f,0x6c,0x6f,0x72,0x20, 0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,
0x2a,0x20,0x6d,0x69,0x78,0x28,0x30,0x2e,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x31, 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x31,
0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35, 0x34,0x36,0x2e,0x64,0x65,0x65,0x70,0x43,0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x6d,
0x2c,0x20,0x31,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x34,0x37,0x36,0x38,0x33, 0x69,0x78,0x28,0x30,0x2e,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,
0x37,0x31,0x35,0x38,0x32,0x30,0x33,0x31,0x32,0x35,0x2c,0x20,0x5f,0x34,0x38,0x31, 0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x2c,0x20,0x31,
0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d, 0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x34,0x37,0x36,0x38,0x33,0x37,0x31,0x35,
0x0a,0x0a,0x00, 0x38,0x32,0x30,0x33,0x31,0x32,0x35,0x2c,0x20,0x5f,0x34,0x39,0x32,0x29,0x2c,0x20,
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00,
]; ];
/* /*
#include <metal_stdlib> #include <metal_stdlib>
@ -1200,26 +1210,26 @@ vs_plane_source_metal_macos := u8.[
float3 _274 = fast::normalize(((((normal_map.sample(normalsmp, ((in.pos.xz * 0.4000000059604644775390625) + (_185 * 1.5))).xzy * 2.0) - float3(1.0)) + ((normal_map.sample(normalsmp, ((in.pos.xz * 0.100000001490116119384765625) + (_185 * 1.7000000476837158203125))).xzy * 2.0) - float3(1.0))) + ((normal_map.sample(normalsmp, ((in.pos.xz * 1.0) + (_185 * 2.7000000476837158203125))).xzy * 2.0) - float3(1.0))) + ((normal_map.sample(normalsmp, ((in.pos.xz * 0.0199999995529651641845703125) + (_185 * 0.100000001490116119384765625))).xzy * 2.0) - float3(1.0))); float3 _274 = fast::normalize(((((normal_map.sample(normalsmp, ((in.pos.xz * 0.4000000059604644775390625) + (_185 * 1.5))).xzy * 2.0) - float3(1.0)) + ((normal_map.sample(normalsmp, ((in.pos.xz * 0.100000001490116119384765625) + (_185 * 1.7000000476837158203125))).xzy * 2.0) - float3(1.0))) + ((normal_map.sample(normalsmp, ((in.pos.xz * 1.0) + (_185 * 2.7000000476837158203125))).xzy * 2.0) - float3(1.0))) + ((normal_map.sample(normalsmp, ((in.pos.xz * 0.0199999995529651641845703125) + (_185 * 0.100000001490116119384765625))).xzy * 2.0) - float3(1.0)));
float3 _285 = fast::normalize(float3(_279.cameraPosition) - in.pos.xyz); float3 _285 = fast::normalize(float3(_279.cameraPosition) - in.pos.xyz);
float3 _290 = fast::normalize(float3(_146.sunPosition)); float3 _290 = fast::normalize(float3(_146.sunPosition));
float param = _285.y; float param = fast::max(0.0, dot(_285, _274));
float _317 = fast::min(1.0, fresnelSchlick(param).x + 0.300000011920928955078125); float _321 = fast::min(1.0, fresnelSchlick(param).x + 0.449999988079071044921875);
float4 _329 = _279.mvp_shadow * float4(in.pos.xyz, 1.0); float4 _338 = _279.mvp_shadow * float4(floor(in.pos.xyz * 16.0) * float3(0.0625), 1.0);
float3 _341 = ((_329.xyz / float3(_329.w)) * 0.5) + float3(0.5); float3 _350 = ((_338.xyz / float3(_338.w)) * 0.5) + float3(0.5);
float _346 = _341.z - 0.001000000047497451305389404296875; float _355 = _350.z - 0.001000000047497451305389404296875;
float3 _501 = _341; float3 _512 = _350;
_501.z = _346; _512.z = _355;
float _358 = shadow.sample_compare(plane_shadowsmp, _501.xy, _346); float _367 = shadow.sample_compare(plane_shadowsmp, _512.xy, _355);
float2 _398 = gl_FragCoord.xy / float2(float(_279.screen_w), float(_279.screen_h)); float2 _408 = gl_FragCoord.xy / float2(float(_279.screen_w), float(_279.screen_h));
_398.y = 1.0 - _398.y; _408.y = 1.0 - _408.y;
float3 param_1 = fast::normalize(in.pos.xyz); float3 param_1 = fast::normalize(in.pos.xyz);
float3 param_2 = float3(_146.sunPosition); float3 param_2 = float3(_146.sunPosition);
float _451 = smoothstep(750.0, 1000.0, length(in.pos.xz)); float _462 = smoothstep(750.0, 1000.0, length(in.pos.xz));
out.frag_color = float4(mix(mix((((_146.waterColor * fast::max(0.0, dot(_274, _290))) * _146.sunLightColor) * _146.sunIntensity) * _358, reftex.sample(refsmp, (_398 + (_274.xz * 0.004999999888241291046142578125))).xyz, float3(_317)) + (((_146.sunLightColor * _146.sunIntensity) * powr(fast::max(0.0, dot(fast::normalize(_290 + _285), _274)), 32.0)) * _358), sky(param_1, param_2, _146) * _146.skyIntensity, float3(_451)), mix(mix(0.300000011920928955078125, 0.5, _317), 1.0, _451)); out.frag_color = float4(mix(mix((((_146.waterColor * fast::max(0.0, dot(_274, _290))) * _146.sunLightColor) * _146.sunIntensity) * _367, reftex.sample(refsmp, (_408 + (_274.xz * 0.007000000216066837310791015625))).xyz, float3(_321)) + ((((_146.sunLightColor * _146.sunIntensity) * powr(fast::max(0.0, dot(fast::normalize(_290 + _285), _274)), fast::max(_279.shininess, 1.0))) * _321) * _367), sky(param_1, param_2, _146) * _146.skyIntensity, float3(_462)), mix(mix(0.300000011920928955078125, 0.5, _321), 1.0, _462));
} }
else else
{ {
float2 param_3 = (in.pos.xz * 0.0500000007450580596923828125) + float2(_146.time * 0.00999999977648258209228515625); float2 param_3 = (in.pos.xz * 0.0500000007450580596923828125) + float2(_146.time * 0.00999999977648258209228515625);
float _481 = fbm(param_3); float _492 = fbm(param_3);
out.frag_color = float4(float3(_146.deepColor) * mix(0.800000011920928955078125, 1.2000000476837158203125, _481), 1.0); out.frag_color = float4(float3(_146.deepColor) * mix(0.800000011920928955078125, 1.2000000476837158203125, _492), 1.0);
} }
return out; return out;
} }
@ -1452,104 +1462,110 @@ fs_plane_source_metal_macos := u8.[
0x6c,0x69,0x7a,0x65,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x34,0x36, 0x6c,0x69,0x7a,0x65,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x34,0x36,
0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x29,0x3b,0x0a, 0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,
0x72,0x61,0x6d,0x20,0x3d,0x20,0x5f,0x32,0x38,0x35,0x2e,0x79,0x3b,0x0a,0x20,0x20, 0x72,0x61,0x6d,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x31,0x37, 0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x38,0x35,0x2c,0x20,0x5f,
0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x69,0x6e,0x28,0x31,0x2e,0x30, 0x32,0x37,0x34,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,
0x2c,0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b, 0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x32,0x31,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,
0x28,0x70,0x61,0x72,0x61,0x6d,0x29,0x2e,0x78,0x20,0x2b,0x20,0x30,0x2e,0x33,0x30, 0x3a,0x3a,0x6d,0x69,0x6e,0x28,0x31,0x2e,0x30,0x2c,0x20,0x66,0x72,0x65,0x73,0x6e,
0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35, 0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x28,0x70,0x61,0x72,0x61,0x6d,0x29,
0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x2e,0x78,0x20,0x2b,0x20,0x30,0x2e,0x34,0x34,0x39,0x39,0x39,0x39,0x39,0x38,0x38,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x33,0x32,0x39,0x20,0x3d,0x20,0x5f, 0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,
0x32,0x37,0x39,0x2e,0x6d,0x76,0x70,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x20,0x2a, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78, 0x20,0x5f,0x33,0x33,0x38,0x20,0x3d,0x20,0x5f,0x32,0x37,0x39,0x2e,0x6d,0x76,0x70,
0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, 0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x33,0x34,0x31,0x20,0x3d,0x20, 0x28,0x66,0x6c,0x6f,0x6f,0x72,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79,
0x28,0x28,0x5f,0x33,0x32,0x39,0x2e,0x78,0x79,0x7a,0x20,0x2f,0x20,0x66,0x6c,0x6f, 0x7a,0x20,0x2a,0x20,0x31,0x36,0x2e,0x30,0x29,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,
0x61,0x74,0x33,0x28,0x5f,0x33,0x32,0x39,0x2e,0x77,0x29,0x29,0x20,0x2a,0x20,0x30, 0x74,0x33,0x28,0x30,0x2e,0x30,0x36,0x32,0x35,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,
0x2e,0x35,0x29,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x35, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74, 0x20,0x5f,0x33,0x35,0x30,0x20,0x3d,0x20,0x28,0x28,0x5f,0x33,0x33,0x38,0x2e,0x78,
0x20,0x5f,0x33,0x34,0x36,0x20,0x3d,0x20,0x5f,0x33,0x34,0x31,0x2e,0x7a,0x20,0x2d, 0x79,0x7a,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x33,0x33,0x38,
0x20,0x30,0x2e,0x30,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x34,0x37,0x34, 0x2e,0x77,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x20,0x2b,0x20,0x66,0x6c,
0x39,0x37,0x34,0x35,0x31,0x33,0x30,0x35,0x33,0x38,0x39,0x34,0x30,0x34,0x32,0x39, 0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x36,0x38,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c, 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x35,0x35,0x20,0x3d,0x20,
0x6f,0x61,0x74,0x33,0x20,0x5f,0x35,0x30,0x31,0x20,0x3d,0x20,0x5f,0x33,0x34,0x31, 0x5f,0x33,0x35,0x30,0x2e,0x7a,0x20,0x2d,0x20,0x30,0x2e,0x30,0x30,0x31,0x30,0x30,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x35,0x30,0x31,0x2e,0x7a, 0x30,0x30,0x30,0x30,0x30,0x34,0x37,0x34,0x39,0x37,0x34,0x35,0x31,0x33,0x30,0x35,
0x20,0x3d,0x20,0x5f,0x33,0x34,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x33,0x38,0x39,0x34,0x30,0x34,0x32,0x39,0x36,0x38,0x37,0x35,0x3b,0x0a,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x35,0x38,0x20,0x3d,0x20,0x73,0x68, 0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x35,0x31,
0x61,0x64,0x6f,0x77,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x63,0x6f,0x6d,0x70, 0x32,0x20,0x3d,0x20,0x5f,0x33,0x35,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
0x61,0x72,0x65,0x28,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77, 0x20,0x20,0x5f,0x35,0x31,0x32,0x2e,0x7a,0x20,0x3d,0x20,0x5f,0x33,0x35,0x35,0x3b,
0x73,0x6d,0x70,0x2c,0x20,0x5f,0x35,0x30,0x31,0x2e,0x78,0x79,0x2c,0x20,0x5f,0x33, 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
0x34,0x36,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, 0x33,0x36,0x37,0x20,0x3d,0x20,0x73,0x68,0x61,0x64,0x6f,0x77,0x2e,0x73,0x61,0x6d,
0x61,0x74,0x32,0x20,0x5f,0x33,0x39,0x38,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x46,0x72, 0x70,0x6c,0x65,0x5f,0x63,0x6f,0x6d,0x70,0x61,0x72,0x65,0x28,0x70,0x6c,0x61,0x6e,
0x61,0x67,0x43,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x20,0x2f,0x20,0x66,0x6c,0x6f, 0x65,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x35,0x31,
0x61,0x74,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x32,0x37,0x39,0x2e,0x73, 0x32,0x2e,0x78,0x79,0x2c,0x20,0x5f,0x33,0x35,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x63,0x72,0x65,0x65,0x6e,0x5f,0x77,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28, 0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x34,0x30,0x38,
0x5f,0x32,0x37,0x39,0x2e,0x73,0x63,0x72,0x65,0x65,0x6e,0x5f,0x68,0x29,0x29,0x3b, 0x20,0x3d,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x43,0x6f,0x6f,0x72,0x64,0x2e,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x33,0x39,0x38,0x2e,0x79,0x20, 0x78,0x79,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x66,0x6c,0x6f,0x61,
0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x33,0x39,0x38,0x2e,0x79,0x3b,0x0a, 0x74,0x28,0x5f,0x32,0x37,0x39,0x2e,0x73,0x63,0x72,0x65,0x65,0x6e,0x5f,0x77,0x29,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70, 0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x32,0x37,0x39,0x2e,0x73,0x63,0x72,
0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e, 0x65,0x65,0x6e,0x5f,0x68,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e, 0x20,0x5f,0x34,0x30,0x38,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,
0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c, 0x5f,0x34,0x30,0x38,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x66, 0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,
0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x50,0x6f, 0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x31,0x20,0x3d,0x20,0x73,0x6d, 0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,
0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x37,0x35,0x30,0x2e,0x30,0x2c,0x20, 0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,
0x31,0x30,0x30,0x30,0x2e,0x30,0x2c,0x20,0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x69, 0x34,0x36,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,
0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x7a,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c, 0x34,0x36,0x32,0x20,0x3d,0x20,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,
0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x6d,0x69,0x78,0x28, 0x28,0x37,0x35,0x30,0x2e,0x30,0x2c,0x20,0x31,0x30,0x30,0x30,0x2e,0x30,0x2c,0x20,
0x6d,0x69,0x78,0x28,0x28,0x28,0x28,0x5f,0x31,0x34,0x36,0x2e,0x77,0x61,0x74,0x65, 0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x7a,
0x72,0x43,0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d, 0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,
0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x37,0x34, 0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,
0x2c,0x20,0x5f,0x32,0x39,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36, 0x61,0x74,0x34,0x28,0x6d,0x69,0x78,0x28,0x6d,0x69,0x78,0x28,0x28,0x28,0x28,0x5f,
0x2e,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x29,0x20, 0x31,0x34,0x36,0x2e,0x77,0x61,0x74,0x65,0x72,0x43,0x6f,0x6c,0x6f,0x72,0x20,0x2a,
0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73, 0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,
0x69,0x74,0x79,0x29,0x20,0x2a,0x20,0x5f,0x33,0x35,0x38,0x2c,0x20,0x72,0x65,0x66, 0x64,0x6f,0x74,0x28,0x5f,0x32,0x37,0x34,0x2c,0x20,0x5f,0x32,0x39,0x30,0x29,0x29,
0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x72,0x65,0x66,0x73,0x6d, 0x29,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,
0x70,0x2c,0x20,0x28,0x5f,0x33,0x39,0x38,0x20,0x2b,0x20,0x28,0x5f,0x32,0x37,0x34, 0x74,0x43,0x6f,0x6c,0x6f,0x72,0x29,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,
0x2e,0x78,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30,0x34,0x39,0x39,0x39,0x39,0x39, 0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x29,0x20,0x2a,0x20,0x5f,
0x39,0x38,0x38,0x38,0x32,0x34,0x31,0x32,0x39,0x31,0x30,0x34,0x36,0x31,0x34,0x32, 0x33,0x36,0x37,0x2c,0x20,0x72,0x65,0x66,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,
0x35,0x37,0x38,0x31,0x32,0x35,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x66, 0x6c,0x65,0x28,0x72,0x65,0x66,0x73,0x6d,0x70,0x2c,0x20,0x28,0x5f,0x34,0x30,0x38,
0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x33,0x31,0x37,0x29,0x29,0x20,0x2b,0x20,0x28, 0x20,0x2b,0x20,0x28,0x5f,0x32,0x37,0x34,0x2e,0x78,0x7a,0x20,0x2a,0x20,0x30,0x2e,
0x28,0x28,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43, 0x30,0x30,0x37,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x31,0x36,0x30,0x36,0x36,0x38,
0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x49, 0x33,0x37,0x33,0x31,0x30,0x37,0x39,0x31,0x30,0x31,0x35,0x36,0x32,0x35,0x29,0x29,
0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x29,0x20,0x2a,0x20,0x70,0x6f,0x77,0x72, 0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x33,
0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20, 0x32,0x31,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x28,0x28,0x5f,0x31,0x34,0x36,0x2e,
0x64,0x6f,0x74,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c, 0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,
0x69,0x7a,0x65,0x28,0x5f,0x32,0x39,0x30,0x20,0x2b,0x20,0x5f,0x32,0x38,0x35,0x29, 0x5f,0x31,0x34,0x36,0x2e,0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,
0x2c,0x20,0x5f,0x32,0x37,0x34,0x29,0x29,0x2c,0x20,0x33,0x32,0x2e,0x30,0x29,0x29, 0x79,0x29,0x20,0x2a,0x20,0x70,0x6f,0x77,0x72,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,
0x20,0x2a,0x20,0x5f,0x33,0x35,0x38,0x29,0x2c,0x20,0x73,0x6b,0x79,0x28,0x70,0x61, 0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x66,0x61,0x73,
0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20, 0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,0x39,
0x5f,0x31,0x34,0x36,0x29,0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x6b,0x79, 0x30,0x20,0x2b,0x20,0x5f,0x32,0x38,0x35,0x29,0x2c,0x20,0x5f,0x32,0x37,0x34,0x29,
0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74, 0x29,0x2c,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x5f,0x32,0x37,
0x33,0x28,0x5f,0x34,0x35,0x31,0x29,0x29,0x2c,0x20,0x6d,0x69,0x78,0x28,0x6d,0x69, 0x39,0x2e,0x73,0x68,0x69,0x6e,0x69,0x6e,0x65,0x73,0x73,0x2c,0x20,0x31,0x2e,0x30,
0x78,0x28,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30, 0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x33,0x32,0x31,0x29,0x20,0x2a,0x20,0x5f,0x33,
0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e, 0x36,0x37,0x29,0x2c,0x20,0x73,0x6b,0x79,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,
0x35,0x2c,0x20,0x5f,0x33,0x31,0x37,0x29,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x5f, 0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20,0x5f,0x31,0x34,0x36,0x29,
0x34,0x35,0x31,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20, 0x20,0x2a,0x20,0x5f,0x31,0x34,0x36,0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,
0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20, 0x73,0x69,0x74,0x79,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x34,0x36,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x61,0x72,0x61,0x6d, 0x32,0x29,0x29,0x2c,0x20,0x6d,0x69,0x78,0x28,0x6d,0x69,0x78,0x28,0x30,0x2e,0x33,
0x5f,0x33,0x20,0x3d,0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x7a,0x20, 0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,
0x2a,0x20,0x30,0x2e,0x30,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x37,0x34,0x35, 0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x5f,0x33,
0x30,0x35,0x38,0x30,0x35,0x39,0x36,0x39,0x32,0x33,0x38,0x32,0x38,0x31,0x32,0x35, 0x32,0x31,0x29,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x5f,0x34,0x36,0x32,0x29,0x29,
0x29,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x31,0x34,0x36,0x2e, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,
0x74,0x69,0x6d,0x65,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39, 0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,
0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38, 0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,
0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x30,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x31,0x20,0x3d,0x20,0x66,0x62, 0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x37,0x34,0x35,0x30,0x35,0x38,0x30,0x35,
0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, 0x39,0x36,0x39,0x32,0x33,0x38,0x32,0x38,0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x66,
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c, 0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x31,0x34,0x36,0x2e,0x74,0x69,0x6d,0x65,0x20,
0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x66,0x6c,0x6f,0x61, 0x2a,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,
0x74,0x33,0x28,0x5f,0x31,0x34,0x36,0x2e,0x64,0x65,0x65,0x70,0x43,0x6f,0x6c,0x6f, 0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,
0x72,0x29,0x20,0x2a,0x20,0x6d,0x69,0x78,0x28,0x30,0x2e,0x38,0x30,0x30,0x30,0x30, 0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38, 0x74,0x20,0x5f,0x34,0x39,0x32,0x20,0x3d,0x20,0x66,0x62,0x6d,0x28,0x70,0x61,0x72,
0x31,0x32,0x35,0x2c,0x20,0x31,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x34,0x37, 0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,
0x36,0x38,0x33,0x37,0x31,0x35,0x38,0x32,0x30,0x33,0x31,0x32,0x35,0x2c,0x20,0x5f, 0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,
0x34,0x38,0x31,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, 0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,
0x7d,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74, 0x34,0x36,0x2e,0x64,0x65,0x65,0x70,0x43,0x6f,0x6c,0x6f,0x72,0x29,0x20,0x2a,0x20,
0x3b,0x0a,0x7d,0x0a,0x0a,0x00, 0x6d,0x69,0x78,0x28,0x30,0x2e,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,
0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x2c,0x20,
0x31,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x34,0x37,0x36,0x38,0x33,0x37,0x31,
0x35,0x38,0x32,0x30,0x33,0x31,0x32,0x35,0x2c,0x20,0x5f,0x34,0x39,0x32,0x29,0x2c,
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
]; ];
plane_shader_desc :: (backend: sg_backend) -> sg_shader_desc { plane_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc: sg_shader_desc; desc: sg_shader_desc;

View File

@ -160,20 +160,24 @@ vs_sky_source_glsl430 := u8.[
vec3 sky(vec3 skypos, vec3 sunpos) vec3 sky(vec3 skypos, vec3 sunpos)
{ {
float _196 = dot(normalize(skypos), normalize(sunpos));
vec3 _199 = normalize(skypos); vec3 _199 = normalize(skypos);
vec3 final = mix(_178.skyBase, _178.skyTop, vec3(clamp(skypos.y * 2.0, 0.0, 0.699999988079071044921875))) + ((_178.sunHalo * clamp((_196 - 0.9700000286102294921875) * 10.0, 0.0, 0.800000011920928955078125)) * 1.0); vec3 _212 = normalize(sunpos);
if (_196 > 0.999499976634979248046875) vec3 _217 = normalize(cross(_212, vec3(0.0, 1.0, 0.0)));
vec3 _229 = normalize(skypos) - (_212 * dot(normalize(skypos), normalize(sunpos)));
float _243 = max(abs(dot(_229, _217)), abs(dot(_229, normalize(cross(_217, _212)))));
float _251 = clamp((0.25 - _243) * 6.0, 0.0, 1.0);
vec3 final = mix(_178.skyBase, _178.skyTop, vec3(clamp(skypos.y * 2.0, 0.0, 0.699999988079071044921875))) + ((_178.sunHalo * _251) * _251);
if (_243 < 0.0320000015199184417724609375)
{ {
final = _178.sunDisk * 3.0; final = _178.sunDisk * 3.0;
} }
float _241 = _199.y; float _276 = _199.y;
final += (mix(_178.horizonHalo, vec3(0.0), vec3(clamp(abs(_241) * 80.0, 0.0, 1.0))) * 0.100000001490116119384765625); final += (mix(_178.horizonHalo, vec3(0.0), vec3(clamp(abs(_276) * 20.0, 0.0, 1.0))) * 0.800000011920928955078125);
if (_178.hasClouds == 1) if (_178.hasClouds == 1)
{ {
vec3 param = ((_199 / vec3(_241)) * 2.0) + vec3(_178.time * 0.0500000007450580596923828125); vec3 param = ((_199 / vec3(_276)) * 2.0) + vec3(_178.time * 0.0500000007450580596923828125);
float _277 = fbm(param); float _312 = fbm(param);
final = mix(final, vec3(1.0), vec3((max(0.0, _241) * (smoothstep(0.5, 1.0, _277) * 0.300000011920928955078125)) * 2.0)); final = mix(final, vec3(1.0), vec3((max(0.0, _276) * (smoothstep(0.5, 1.0, _312) * 0.300000011920928955078125)) * 2.0));
} }
return final; return final;
} }
@ -362,71 +366,84 @@ fs_sky_source_glsl430 := u8.[
0x20,0x5f,0x31,0x37,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,0x65,0x63,0x33,0x20,0x73, 0x20,0x5f,0x31,0x37,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,0x65,0x63,0x33,0x20,0x73,
0x6b,0x79,0x28,0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2c,0x20, 0x6b,0x79,0x28,0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2c,0x20,
0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x70,0x6f,0x73,0x29,0x0a,0x7b,0x0a,0x20, 0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x70,0x6f,0x73,0x29,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x39,0x36,0x20,0x3d,0x20, 0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x39,0x39,0x20,0x3d,0x20,0x6e,
0x64,0x6f,0x74,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b, 0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,
0x79,0x70,0x6f,0x73,0x29,0x2c,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x31,0x32,0x20,
0x28,0x73,0x75,0x6e,0x70,0x6f,0x73,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76, 0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x75,0x6e,0x70,
0x65,0x63,0x33,0x20,0x5f,0x31,0x39,0x39,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61, 0x6f,0x73,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,
0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,0x3b,0x0a,0x20,0x20, 0x31,0x37,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,
0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x6d, 0x72,0x6f,0x73,0x73,0x28,0x5f,0x32,0x31,0x32,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,
0x69,0x78,0x28,0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x2c, 0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x29,0x29,
0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x54,0x6f,0x70,0x2c,0x20,0x76,0x65, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x32,0x39,0x20,
0x63,0x33,0x28,0x63,0x6c,0x61,0x6d,0x70,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2e, 0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,
0x79,0x20,0x2a,0x20,0x32,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e, 0x6f,0x73,0x29,0x20,0x2d,0x20,0x28,0x5f,0x32,0x31,0x32,0x20,0x2a,0x20,0x64,0x6f,
0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30, 0x74,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,
0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x28, 0x6f,0x73,0x29,0x2c,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,
0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x48,0x61,0x6c,0x6f,0x20,0x2a,0x20,0x63, 0x75,0x6e,0x70,0x6f,0x73,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6c,0x61,0x6d,0x70,0x28,0x28,0x5f,0x31,0x39,0x36,0x20,0x2d,0x20,0x30,0x2e,0x39, 0x6f,0x61,0x74,0x20,0x5f,0x32,0x34,0x33,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x61,
0x37,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39, 0x62,0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,0x32,0x32,0x39,0x2c,0x20,0x5f,0x32,0x31,
0x32,0x31,0x38,0x37,0x35,0x29,0x20,0x2a,0x20,0x31,0x30,0x2e,0x30,0x2c,0x20,0x30, 0x37,0x29,0x29,0x2c,0x20,0x61,0x62,0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,0x32,0x32,
0x2e,0x30,0x2c,0x20,0x30,0x2e,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39, 0x39,0x2c,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,
0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x29, 0x73,0x73,0x28,0x5f,0x32,0x31,0x37,0x2c,0x20,0x5f,0x32,0x31,0x32,0x29,0x29,0x29,
0x20,0x2a,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20, 0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,
0x28,0x5f,0x31,0x39,0x36,0x20,0x3e,0x20,0x30,0x2e,0x39,0x39,0x39,0x34,0x39,0x39, 0x35,0x31,0x20,0x3d,0x20,0x63,0x6c,0x61,0x6d,0x70,0x28,0x28,0x30,0x2e,0x32,0x35,
0x39,0x37,0x36,0x36,0x33,0x34,0x39,0x37,0x39,0x32,0x34,0x38,0x30,0x34,0x36,0x38, 0x20,0x2d,0x20,0x5f,0x32,0x34,0x33,0x29,0x20,0x2a,0x20,0x36,0x2e,0x30,0x2c,0x20,
0x37,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, 0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,
0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x5f,0x31,0x37,0x38,0x2e,0x73, 0x65,0x63,0x33,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,
0x75,0x6e,0x44,0x69,0x73,0x6b,0x20,0x2a,0x20,0x33,0x2e,0x30,0x3b,0x0a,0x20,0x20, 0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x2c,0x20,0x5f,0x31,
0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32, 0x37,0x38,0x2e,0x73,0x6b,0x79,0x54,0x6f,0x70,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,
0x34,0x31,0x20,0x3d,0x20,0x5f,0x31,0x39,0x39,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20, 0x63,0x6c,0x61,0x6d,0x70,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2e,0x79,0x20,0x2a,
0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x2b,0x3d,0x20,0x28,0x6d,0x69,0x78,0x28,0x5f, 0x20,0x32,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,
0x31,0x37,0x38,0x2e,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x2c, 0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,
0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33, 0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x5f,0x31,0x37,
0x28,0x63,0x6c,0x61,0x6d,0x70,0x28,0x61,0x62,0x73,0x28,0x5f,0x32,0x34,0x31,0x29, 0x38,0x2e,0x73,0x75,0x6e,0x48,0x61,0x6c,0x6f,0x20,0x2a,0x20,0x5f,0x32,0x35,0x31,
0x20,0x2a,0x20,0x38,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e, 0x29,0x20,0x2a,0x20,0x5f,0x32,0x35,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,
0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x30, 0x66,0x20,0x28,0x5f,0x32,0x34,0x33,0x20,0x3c,0x20,0x30,0x2e,0x30,0x33,0x32,0x30,
0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34,0x37,0x36, 0x30,0x30,0x30,0x30,0x31,0x35,0x31,0x39,0x39,0x31,0x38,0x34,0x34,0x31,0x37,0x37,
0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f, 0x32,0x34,0x36,0x30,0x39,0x33,0x37,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
0x31,0x37,0x38,0x2e,0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64,0x73,0x20,0x3d,0x3d,
0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x28,
0x28,0x5f,0x31,0x39,0x39,0x20,0x2f,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x32,0x34,
0x31,0x29,0x29,0x20,0x2a,0x20,0x32,0x2e,0x30,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,
0x33,0x28,0x5f,0x31,0x37,0x38,0x2e,0x74,0x69,0x6d,0x65,0x20,0x2a,0x20,0x30,0x2e,
0x30,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x37,0x34,0x35,0x30,0x35,0x38,0x30,
0x35,0x39,0x36,0x39,0x32,0x33,0x38,0x32,0x38,0x31,0x32,0x35,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x37,
0x37,0x20,0x3d,0x20,0x66,0x62,0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,
0x6d,0x69,0x78,0x28,0x66,0x69,0x6e,0x61,0x6c,0x2c,0x20,0x76,0x65,0x63,0x33,0x28, 0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x20,0x2a,0x20,0x33,
0x31,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x28,0x6d,0x61,0x78,0x28, 0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x30,0x2e,0x30,0x2c,0x20,0x5f,0x32,0x34,0x31,0x29,0x20,0x2a,0x20,0x28,0x73,0x6d, 0x6f,0x61,0x74,0x20,0x5f,0x32,0x37,0x36,0x20,0x3d,0x20,0x5f,0x31,0x39,0x39,0x2e,
0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e, 0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x2b,0x3d,0x20,
0x30,0x2c,0x20,0x5f,0x32,0x37,0x37,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30, 0x28,0x6d,0x69,0x78,0x28,0x5f,0x31,0x37,0x38,0x2e,0x68,0x6f,0x72,0x69,0x7a,0x6f,
0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30, 0x6e,0x48,0x61,0x6c,0x6f,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x29,
0x37,0x38,0x31,0x32,0x35,0x29,0x29,0x20,0x2a,0x20,0x32,0x2e,0x30,0x29,0x29,0x3b, 0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x63,0x6c,0x61,0x6d,0x70,0x28,0x61,0x62,0x73,
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72, 0x28,0x5f,0x32,0x37,0x36,0x29,0x20,0x2a,0x20,0x32,0x30,0x2e,0x30,0x2c,0x20,0x30,
0x6e,0x20,0x66,0x69,0x6e,0x61,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64, 0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x38,
0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65, 0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,
0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61, 0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,
0x6c,0x69,0x7a,0x65,0x28,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20, 0x20,0x28,0x5f,0x31,0x37,0x38,0x2e,0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64,0x73,
0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20, 0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
0x3d,0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69, 0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,
0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c, 0x3d,0x20,0x28,0x28,0x5f,0x31,0x39,0x39,0x20,0x2f,0x20,0x76,0x65,0x63,0x33,0x28,
0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x73,0x6b,0x79,0x28,0x70,0x61, 0x5f,0x32,0x37,0x36,0x29,0x29,0x20,0x2a,0x20,0x32,0x2e,0x30,0x29,0x20,0x2b,0x20,
0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x20,0x2a,0x20, 0x76,0x65,0x63,0x33,0x28,0x5f,0x31,0x37,0x38,0x2e,0x74,0x69,0x6d,0x65,0x20,0x2a,
0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74, 0x20,0x30,0x2e,0x30,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x37,0x34,0x35,0x30,
0x79,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, 0x35,0x38,0x30,0x35,0x39,0x36,0x39,0x32,0x33,0x38,0x32,0x38,0x31,0x32,0x35,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
0x5f,0x33,0x31,0x32,0x20,0x3d,0x20,0x66,0x62,0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,
0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x66,0x69,0x6e,0x61,0x6c,0x2c,0x20,0x76,0x65,
0x63,0x33,0x28,0x31,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x28,0x6d,
0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x32,0x37,0x36,0x29,0x20,0x2a,0x20,
0x28,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x30,0x2e,0x35,0x2c,
0x20,0x31,0x2e,0x30,0x2c,0x20,0x5f,0x33,0x31,0x32,0x29,0x20,0x2a,0x20,0x30,0x2e,
0x33,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,
0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x29,0x20,0x2a,0x20,0x32,0x2e,0x30,
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,
0x74,0x75,0x72,0x6e,0x20,0x66,0x69,0x6e,0x61,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x6e,0x6f,
0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,
0x5f,0x31,0x20,0x3d,0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,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,0x6b,0x79,
0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,
0x20,0x2a,0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,
0x73,0x69,0x74,0x79,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
]; ];
/* /*
#version 300 es #version 300 es
@ -536,20 +553,24 @@ vs_sky_source_glsl300es := u8.[
highp vec3 sky(highp vec3 skypos, highp vec3 sunpos) highp vec3 sky(highp vec3 skypos, highp vec3 sunpos)
{ {
highp float _196 = dot(normalize(skypos), normalize(sunpos));
highp vec3 _199 = normalize(skypos); highp vec3 _199 = normalize(skypos);
highp vec3 final = mix(_178.skyBase, _178.skyTop, vec3(clamp(skypos.y * 2.0, 0.0, 0.699999988079071044921875))) + ((_178.sunHalo * clamp((_196 - 0.9700000286102294921875) * 10.0, 0.0, 0.800000011920928955078125)) * 1.0); highp vec3 _212 = normalize(sunpos);
if (_196 > 0.999499976634979248046875) highp vec3 _217 = normalize(cross(_212, vec3(0.0, 1.0, 0.0)));
highp vec3 _229 = normalize(skypos) - (_212 * dot(normalize(skypos), normalize(sunpos)));
highp float _243 = max(abs(dot(_229, _217)), abs(dot(_229, normalize(cross(_217, _212)))));
highp float _251 = clamp((0.25 - _243) * 6.0, 0.0, 1.0);
highp vec3 final = mix(_178.skyBase, _178.skyTop, vec3(clamp(skypos.y * 2.0, 0.0, 0.699999988079071044921875))) + ((_178.sunHalo * _251) * _251);
if (_243 < 0.0320000015199184417724609375)
{ {
final = _178.sunDisk * 3.0; final = _178.sunDisk * 3.0;
} }
highp float _241 = _199.y; highp float _276 = _199.y;
final += (mix(_178.horizonHalo, vec3(0.0), vec3(clamp(abs(_241) * 80.0, 0.0, 1.0))) * 0.100000001490116119384765625); final += (mix(_178.horizonHalo, vec3(0.0), vec3(clamp(abs(_276) * 20.0, 0.0, 1.0))) * 0.800000011920928955078125);
if (_178.hasClouds == 1) if (_178.hasClouds == 1)
{ {
highp vec3 param = ((_199 / vec3(_241)) * 2.0) + vec3(_178.time * 0.0500000007450580596923828125); highp vec3 param = ((_199 / vec3(_276)) * 2.0) + vec3(_178.time * 0.0500000007450580596923828125);
highp float _277 = fbm(param); highp float _312 = fbm(param);
final = mix(final, vec3(1.0), vec3((max(0.0, _241) * (smoothstep(0.5, 1.0, _277) * 0.300000011920928955078125)) * 2.0)); final = mix(final, vec3(1.0), vec3((max(0.0, _276) * (smoothstep(0.5, 1.0, _312) * 0.300000011920928955078125)) * 2.0));
} }
return final; return final;
} }
@ -756,75 +777,88 @@ fs_sky_source_glsl300es := u8.[
0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x28,0x68,0x69,0x67,0x68,0x70, 0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x28,0x68,0x69,0x67,0x68,0x70,
0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2c,0x20,0x68,0x69, 0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2c,0x20,0x68,0x69,
0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x70,0x6f,0x73,0x29, 0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x70,0x6f,0x73,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f, 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
0x61,0x74,0x20,0x5f,0x31,0x39,0x36,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x6e,0x6f, 0x33,0x20,0x5f,0x31,0x39,0x39,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,
0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x31,0x32,0x20,
0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x75,0x6e,0x70,
0x6f,0x73,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,
0x65,0x63,0x33,0x20,0x5f,0x32,0x31,0x37,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,
0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x5f,0x32,0x31,0x32,0x2c,
0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,
0x30,0x2e,0x30,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x32,0x39,0x20,0x3d,0x20,0x6e,0x6f,
0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,0x20,
0x2d,0x20,0x28,0x5f,0x32,0x31,0x32,0x20,0x2a,0x20,0x64,0x6f,0x74,0x28,0x6e,0x6f,
0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,0x2c, 0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,0x2c,
0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x75,0x6e,0x70,0x6f, 0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x75,0x6e,0x70,0x6f,
0x73,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76, 0x73,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
0x65,0x63,0x33,0x20,0x5f,0x31,0x39,0x39,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61, 0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x34,0x33,0x20,0x3d,0x20,0x6d,0x61,0x78,
0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,0x3b,0x0a,0x20,0x20, 0x28,0x61,0x62,0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,0x32,0x32,0x39,0x2c,0x20,0x5f,
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x66,0x69,0x6e, 0x32,0x31,0x37,0x29,0x29,0x2c,0x20,0x61,0x62,0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,
0x61,0x6c,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b, 0x32,0x32,0x39,0x2c,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,
0x79,0x42,0x61,0x73,0x65,0x2c,0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x54, 0x72,0x6f,0x73,0x73,0x28,0x5f,0x32,0x31,0x37,0x2c,0x20,0x5f,0x32,0x31,0x32,0x29,
0x6f,0x70,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x63,0x6c,0x61,0x6d,0x70,0x28,0x73, 0x29,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
0x6b,0x79,0x70,0x6f,0x73,0x2e,0x79,0x20,0x2a,0x20,0x32,0x2e,0x30,0x2c,0x20,0x30, 0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x35,0x31,0x20,0x3d,0x20,0x63,0x6c,0x61,
0x2e,0x30,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30, 0x6d,0x70,0x28,0x28,0x30,0x2e,0x32,0x35,0x20,0x2d,0x20,0x5f,0x32,0x34,0x33,0x29,
0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29, 0x20,0x2a,0x20,0x36,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,
0x29,0x20,0x2b,0x20,0x28,0x28,0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x48,0x61, 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
0x6c,0x6f,0x20,0x2a,0x20,0x63,0x6c,0x61,0x6d,0x70,0x28,0x28,0x5f,0x31,0x39,0x36, 0x33,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f,0x31,
0x20,0x2d,0x20,0x30,0x2e,0x39,0x37,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31, 0x37,0x38,0x2e,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x2c,0x20,0x5f,0x31,0x37,0x38,
0x30,0x32,0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x20,0x2a,0x20,0x31, 0x2e,0x73,0x6b,0x79,0x54,0x6f,0x70,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x63,0x6c,
0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x38,0x30,0x30,0x30, 0x61,0x6d,0x70,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2e,0x79,0x20,0x2a,0x20,0x32,
0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37, 0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,
0x38,0x31,0x32,0x35,0x29,0x29,0x20,0x2a,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20, 0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,
0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x39,0x36,0x20,0x3e,0x20,0x30,0x2e, 0x38,0x37,0x35,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x5f,0x31,0x37,0x38,0x2e,
0x39,0x39,0x39,0x34,0x39,0x39,0x39,0x37,0x36,0x36,0x33,0x34,0x39,0x37,0x39,0x32, 0x73,0x75,0x6e,0x48,0x61,0x6c,0x6f,0x20,0x2a,0x20,0x5f,0x32,0x35,0x31,0x29,0x20,
0x34,0x38,0x30,0x34,0x36,0x38,0x37,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a, 0x2a,0x20,0x5f,0x32,0x35,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20, 0x28,0x5f,0x32,0x34,0x33,0x20,0x3c,0x20,0x30,0x2e,0x30,0x33,0x32,0x30,0x30,0x30,
0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x20,0x2a,0x20,0x33, 0x30,0x30,0x31,0x35,0x31,0x39,0x39,0x31,0x38,0x34,0x34,0x31,0x37,0x37,0x32,0x34,
0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x68,0x69, 0x36,0x30,0x39,0x33,0x37,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x34,0x31,0x20,0x3d, 0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x5f,0x31,
0x20,0x5f,0x31,0x39,0x39,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x69,0x6e, 0x37,0x38,0x2e,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x20,0x2a,0x20,0x33,0x2e,0x30,
0x61,0x6c,0x20,0x2b,0x3d,0x20,0x28,0x6d,0x69,0x78,0x28,0x5f,0x31,0x37,0x38,0x2e, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x2c,0x20,0x76,0x65,0x63, 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x37,0x36,0x20,0x3d,0x20,0x5f,
0x33,0x28,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x63,0x6c,0x61, 0x31,0x39,0x39,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,
0x6d,0x70,0x28,0x61,0x62,0x73,0x28,0x5f,0x32,0x34,0x31,0x29,0x20,0x2a,0x20,0x38, 0x20,0x2b,0x3d,0x20,0x28,0x6d,0x69,0x78,0x28,0x5f,0x31,0x37,0x38,0x2e,0x68,0x6f,
0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x29,0x29, 0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,
0x20,0x2a,0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39, 0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x63,0x6c,0x61,0x6d,0x70,
0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35, 0x28,0x61,0x62,0x73,0x28,0x5f,0x32,0x37,0x36,0x29,0x20,0x2a,0x20,0x32,0x30,0x2e,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x37,0x38,0x2e, 0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x29,0x29,0x20,0x2a,
0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64,0x73,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a, 0x20,0x30,0x2e,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,
0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69, 0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,
0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d, 0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x37,0x38,0x2e,0x68,0x61,0x73,0x43,0x6c,
0x20,0x28,0x28,0x5f,0x31,0x39,0x39,0x20,0x2f,0x20,0x76,0x65,0x63,0x33,0x28,0x5f, 0x6f,0x75,0x64,0x73,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
0x32,0x34,0x31,0x29,0x29,0x20,0x2a,0x20,0x32,0x2e,0x30,0x29,0x20,0x2b,0x20,0x76, 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,
0x65,0x63,0x33,0x28,0x5f,0x31,0x37,0x38,0x2e,0x74,0x69,0x6d,0x65,0x20,0x2a,0x20, 0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x28,0x28,0x5f,0x31,
0x30,0x2e,0x30,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x37,0x34,0x35,0x30,0x35, 0x39,0x39,0x20,0x2f,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x32,0x37,0x36,0x29,0x29,
0x38,0x30,0x35,0x39,0x36,0x39,0x32,0x33,0x38,0x32,0x38,0x31,0x32,0x35,0x29,0x3b, 0x20,0x2a,0x20,0x32,0x2e,0x30,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66, 0x31,0x37,0x38,0x2e,0x74,0x69,0x6d,0x65,0x20,0x2a,0x20,0x30,0x2e,0x30,0x35,0x30,
0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x37,0x37,0x20,0x3d,0x20,0x66,0x62,0x6d,0x28, 0x30,0x30,0x30,0x30,0x30,0x30,0x37,0x34,0x35,0x30,0x35,0x38,0x30,0x35,0x39,0x36,
0x70,0x61,0x72,0x61,0x6d,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x39,0x32,0x33,0x38,0x32,0x38,0x31,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x66,0x69,0x6e,0x61, 0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
0x6c,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65, 0x5f,0x33,0x31,0x32,0x20,0x3d,0x20,0x66,0x62,0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,
0x63,0x33,0x28,0x28,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x32,0x34, 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,
0x31,0x29,0x20,0x2a,0x20,0x28,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70, 0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x66,0x69,0x6e,0x61,0x6c,0x2c,0x20,0x76,0x65,
0x28,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x5f,0x32,0x37,0x37,0x29, 0x63,0x33,0x28,0x31,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x28,0x6d,
0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32, 0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x32,0x37,0x36,0x29,0x20,0x2a,0x20,
0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x29,0x20, 0x28,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x30,0x2e,0x35,0x2c,
0x2a,0x20,0x32,0x2e,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20, 0x20,0x31,0x2e,0x30,0x2c,0x20,0x5f,0x33,0x31,0x32,0x29,0x20,0x2a,0x20,0x30,0x2e,
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x66,0x69,0x6e,0x61,0x6c,0x3b, 0x33,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,
0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a, 0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x29,0x20,0x2a,0x20,0x32,0x2e,0x30,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33, 0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,
0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69, 0x74,0x75,0x72,0x6e,0x20,0x66,0x69,0x6e,0x61,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,
0x7a,0x65,0x28,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20, 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,0x33,0x20,0x70,0x61,0x72,0x61, 0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,
0x6d,0x5f,0x31,0x20,0x3d,0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x50,0x6f, 0x6d,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x70,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67, 0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x73,0x6b, 0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,
0x79,0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31, 0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x29,0x20,0x2a,0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65, 0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
0x6e,0x73,0x69,0x74,0x79,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a, 0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x73,0x6b,0x79,0x28,0x70,0x61,0x72,
0x00, 0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x20,0x2a,0x20,0x5f,
0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
]; ];
/* /*
#include <metal_stdlib> #include <metal_stdlib>
@ -978,20 +1012,24 @@ vs_sky_source_metal_macos := u8.[
static inline __attribute__((always_inline)) static inline __attribute__((always_inline))
float3 sky(thread const float3& skypos, thread const float3& sunpos, constant sky_world_config& _178) float3 sky(thread const float3& skypos, thread const float3& sunpos, constant sky_world_config& _178)
{ {
float _196 = dot(fast::normalize(skypos), fast::normalize(sunpos));
float3 _199 = fast::normalize(skypos); float3 _199 = fast::normalize(skypos);
float3 final = mix(_178.skyBase, _178.skyTop, float3(fast::clamp(skypos.y * 2.0, 0.0, 0.699999988079071044921875))) + ((_178.sunHalo * fast::clamp((_196 - 0.9700000286102294921875) * 10.0, 0.0, 0.800000011920928955078125)) * 1.0); float3 _212 = fast::normalize(sunpos);
if (_196 > 0.999499976634979248046875) float3 _217 = fast::normalize(cross(_212, float3(0.0, 1.0, 0.0)));
float3 _229 = fast::normalize(skypos) - (_212 * dot(fast::normalize(skypos), fast::normalize(sunpos)));
float _243 = fast::max(abs(dot(_229, _217)), abs(dot(_229, fast::normalize(cross(_217, _212)))));
float _251 = fast::clamp((0.25 - _243) * 6.0, 0.0, 1.0);
float3 final = mix(_178.skyBase, _178.skyTop, float3(fast::clamp(skypos.y * 2.0, 0.0, 0.699999988079071044921875))) + ((_178.sunHalo * _251) * _251);
if (_243 < 0.0320000015199184417724609375)
{ {
final = _178.sunDisk * 3.0; final = _178.sunDisk * 3.0;
} }
float _241 = _199.y; float _276 = _199.y;
final += (mix(_178.horizonHalo, float3(0.0), float3(fast::clamp(abs(_241) * 80.0, 0.0, 1.0))) * 0.100000001490116119384765625); final += (mix(_178.horizonHalo, float3(0.0), float3(fast::clamp(abs(_276) * 20.0, 0.0, 1.0))) * 0.800000011920928955078125);
if (_178.hasClouds == 1) if (_178.hasClouds == 1)
{ {
float3 param = ((_199 / float3(_241)) * 2.0) + float3(_178.time * 0.0500000007450580596923828125); float3 param = ((_199 / float3(_276)) * 2.0) + float3(_178.time * 0.0500000007450580596923828125);
float _277 = fbm(param); float _312 = fbm(param);
final = mix(final, float3(1.0), float3((fast::max(0.0, _241) * (smoothstep(0.5, 1.0, _277) * 0.300000011920928955078125)) * 2.0)); final = mix(final, float3(1.0), float3((fast::max(0.0, _276) * (smoothstep(0.5, 1.0, _312) * 0.300000011920928955078125)) * 2.0));
} }
return final; return final;
} }
@ -1212,86 +1250,100 @@ fs_sky_source_metal_macos := u8.[
0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x26,0x20,0x73,0x75,0x6e,0x70,0x6f,0x73, 0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x26,0x20,0x73,0x75,0x6e,0x70,0x6f,0x73,
0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x73,0x6b,0x79,0x5f,0x77, 0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x73,0x6b,0x79,0x5f,0x77,
0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x26,0x20,0x5f,0x31,0x37, 0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x26,0x20,0x5f,0x31,0x37,
0x38,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f, 0x38,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,
0x31,0x39,0x36,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a, 0x5f,0x31,0x39,0x39,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,
0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x31,0x32,0x20,
0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,
0x65,0x28,0x73,0x75,0x6e,0x70,0x6f,0x73,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x31,0x37,0x20,0x3d,0x20,0x66,0x61,0x73,
0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,
0x73,0x73,0x28,0x5f,0x32,0x31,0x32,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,
0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x29,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x32,
0x39,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,0x20,0x2d,0x20,0x28,0x5f,
0x32,0x31,0x32,0x20,0x2a,0x20,0x64,0x6f,0x74,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73, 0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,
0x29,0x2c,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69, 0x29,0x2c,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,
0x7a,0x65,0x28,0x73,0x75,0x6e,0x70,0x6f,0x73,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20, 0x7a,0x65,0x28,0x73,0x75,0x6e,0x70,0x6f,0x73,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x31,0x39,0x39,0x20,0x3d,0x20,0x66, 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x34,0x33,0x20,0x3d,0x20,0x66,
0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73, 0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x61,0x62,0x73,0x28,0x64,0x6f,0x74,
0x6b,0x79,0x70,0x6f,0x73,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, 0x28,0x5f,0x32,0x32,0x39,0x2c,0x20,0x5f,0x32,0x31,0x37,0x29,0x29,0x2c,0x20,0x61,
0x74,0x33,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f, 0x62,0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,0x32,0x32,0x39,0x2c,0x20,0x66,0x61,0x73,
0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x2c,0x20,0x5f,0x31,0x37, 0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,
0x38,0x2e,0x73,0x6b,0x79,0x54,0x6f,0x70,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33, 0x73,0x73,0x28,0x5f,0x32,0x31,0x37,0x2c,0x20,0x5f,0x32,0x31,0x32,0x29,0x29,0x29,
0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x63,0x6c,0x61,0x6d,0x70,0x28,0x73,0x6b,0x79, 0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,
0x70,0x6f,0x73,0x2e,0x79,0x20,0x2a,0x20,0x32,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30, 0x35,0x31,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x63,0x6c,0x61,0x6d,0x70,
0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39, 0x28,0x28,0x30,0x2e,0x32,0x35,0x20,0x2d,0x20,0x5f,0x32,0x34,0x33,0x29,0x20,0x2a,
0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x29,0x20, 0x20,0x36,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,
0x2b,0x20,0x28,0x28,0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x48,0x61,0x6c,0x6f, 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x66,0x69,0x6e,0x61,
0x20,0x2a,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x63,0x6c,0x61,0x6d,0x70,0x28,0x28, 0x6c,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,
0x5f,0x31,0x39,0x36,0x20,0x2d,0x20,0x30,0x2e,0x39,0x37,0x30,0x30,0x30,0x30,0x30, 0x42,0x61,0x73,0x65,0x2c,0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x54,0x6f,
0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29, 0x70,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,
0x20,0x2a,0x20,0x31,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e, 0x63,0x6c,0x61,0x6d,0x70,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2e,0x79,0x20,0x2a,
0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39, 0x20,0x32,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,
0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x29,0x20,0x2a,0x20,0x31,0x2e,0x30, 0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x39,0x36,0x20, 0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x5f,0x31,0x37,
0x3e,0x20,0x30,0x2e,0x39,0x39,0x39,0x34,0x39,0x39,0x39,0x37,0x36,0x36,0x33,0x34, 0x38,0x2e,0x73,0x75,0x6e,0x48,0x61,0x6c,0x6f,0x20,0x2a,0x20,0x5f,0x32,0x35,0x31,
0x39,0x37,0x39,0x32,0x34,0x38,0x30,0x34,0x36,0x38,0x37,0x35,0x29,0x0a,0x20,0x20, 0x29,0x20,0x2a,0x20,0x5f,0x32,0x35,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,
0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61, 0x66,0x20,0x28,0x5f,0x32,0x34,0x33,0x20,0x3c,0x20,0x30,0x2e,0x30,0x33,0x32,0x30,
0x6c,0x20,0x3d,0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b, 0x30,0x30,0x30,0x30,0x31,0x35,0x31,0x39,0x39,0x31,0x38,0x34,0x34,0x31,0x37,0x37,
0x20,0x2a,0x20,0x33,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20, 0x32,0x34,0x36,0x30,0x39,0x33,0x37,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x34,0x31,0x20,0x3d,0x20,0x5f, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,
0x31,0x39,0x39,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c, 0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x20,0x2a,0x20,0x33,
0x20,0x2b,0x3d,0x20,0x28,0x6d,0x69,0x78,0x28,0x5f,0x31,0x37,0x38,0x2e,0x68,0x6f, 0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74, 0x6f,0x61,0x74,0x20,0x5f,0x32,0x37,0x36,0x20,0x3d,0x20,0x5f,0x31,0x39,0x39,0x2e,
0x33,0x28,0x30,0x2e,0x30,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x66, 0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x2b,0x3d,0x20,
0x61,0x73,0x74,0x3a,0x3a,0x63,0x6c,0x61,0x6d,0x70,0x28,0x61,0x62,0x73,0x28,0x5f, 0x28,0x6d,0x69,0x78,0x28,0x5f,0x31,0x37,0x38,0x2e,0x68,0x6f,0x72,0x69,0x7a,0x6f,
0x32,0x34,0x31,0x29,0x20,0x2a,0x20,0x38,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30, 0x6e,0x48,0x61,0x6c,0x6f,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,
0x2c,0x20,0x31,0x2e,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x30,0x30, 0x30,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x66,0x61,0x73,0x74,0x3a,
0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33, 0x3a,0x63,0x6c,0x61,0x6d,0x70,0x28,0x61,0x62,0x73,0x28,0x5f,0x32,0x37,0x36,0x29,
0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69, 0x20,0x2a,0x20,0x32,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,
0x66,0x20,0x28,0x5f,0x31,0x37,0x38,0x2e,0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64, 0x30,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x38,0x30,0x30,0x30,0x30,0x30,0x30,
0x73,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20, 0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72, 0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x37,0x38,
0x61,0x6d,0x20,0x3d,0x20,0x28,0x28,0x5f,0x31,0x39,0x39,0x20,0x2f,0x20,0x66,0x6c, 0x2e,0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64,0x73,0x20,0x3d,0x3d,0x20,0x31,0x29,
0x6f,0x61,0x74,0x33,0x28,0x5f,0x32,0x34,0x31,0x29,0x29,0x20,0x2a,0x20,0x32,0x2e, 0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,
0x30,0x29,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x37,0x38, 0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x28,0x28,
0x2e,0x74,0x69,0x6d,0x65,0x20,0x2a,0x20,0x30,0x2e,0x30,0x35,0x30,0x30,0x30,0x30, 0x5f,0x31,0x39,0x39,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x32,
0x30,0x30,0x30,0x37,0x34,0x35,0x30,0x35,0x38,0x30,0x35,0x39,0x36,0x39,0x32,0x33, 0x37,0x36,0x29,0x29,0x20,0x2a,0x20,0x32,0x2e,0x30,0x29,0x20,0x2b,0x20,0x66,0x6c,
0x38,0x32,0x38,0x31,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x37,0x38,0x2e,0x74,0x69,0x6d,0x65,0x20,0x2a,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x37,0x37,0x20,0x3d,0x20,0x66,0x62, 0x20,0x30,0x2e,0x30,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x37,0x34,0x35,0x30,
0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, 0x35,0x38,0x30,0x35,0x39,0x36,0x39,0x32,0x33,0x38,0x32,0x38,0x31,0x32,0x35,0x29,
0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x66,0x69, 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
0x6e,0x61,0x6c,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x31,0x2e,0x30,0x29, 0x5f,0x33,0x31,0x32,0x20,0x3d,0x20,0x66,0x62,0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,
0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a, 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,
0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x32,0x34,0x31,0x29,0x20,0x2a, 0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x66,0x69,0x6e,0x61,0x6c,0x2c,0x20,0x66,0x6c,
0x20,0x28,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x30,0x2e,0x35, 0x6f,0x61,0x74,0x33,0x28,0x31,0x2e,0x30,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x5f,0x32,0x37,0x37,0x29,0x20,0x2a,0x20,0x30, 0x33,0x28,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,
0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38, 0x2c,0x20,0x5f,0x32,0x37,0x36,0x29,0x20,0x2a,0x20,0x28,0x73,0x6d,0x6f,0x6f,0x74,
0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x29,0x20,0x2a,0x20,0x32,0x2e, 0x68,0x73,0x74,0x65,0x70,0x28,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,
0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x72, 0x5f,0x33,0x31,0x32,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,
0x65,0x74,0x75,0x72,0x6e,0x20,0x66,0x69,0x6e,0x61,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a, 0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,
0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f, 0x32,0x35,0x29,0x29,0x20,0x2a,0x20,0x32,0x2e,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,
0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69, 0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x66,
0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d, 0x69,0x6e,0x61,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,
0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x73,0x6b,0x79,0x5f, 0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,
0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x26,0x20,0x5f,0x31, 0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,
0x37,0x38,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d, 0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75, 0x74,0x61,0x6e,0x74,0x20,0x73,0x6b,0x79,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63,
0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20, 0x6f,0x6e,0x66,0x69,0x67,0x26,0x20,0x5f,0x31,0x37,0x38,0x20,0x5b,0x5b,0x62,0x75,
0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x66, 0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x69, 0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,
0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, 0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d, 0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e, 0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f, 0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,
0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20, 0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x73,0x6b,0x79,0x28,0x70,0x61,0x72,0x61,0x6d, 0x28,0x5f,0x31,0x37,0x38,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x5f,0x31,0x37,0x38,0x29, 0x6e,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,
0x20,0x2a,0x20,0x5f,0x31,0x37,0x38,0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e, 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
0x73,0x69,0x74,0x79,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, 0x73,0x6b,0x79,0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, 0x5f,0x31,0x2c,0x20,0x5f,0x31,0x37,0x38,0x29,0x20,0x2a,0x20,0x5f,0x31,0x37,0x38,
0x2e,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,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,
]; ];
sky_shader_desc :: (backend: sg_backend) -> sg_shader_desc { sky_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc: sg_shader_desc; desc: sg_shader_desc;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
@vs vs_debugline
in vec3 a_pos;
in vec4 a_col;
layout(binding=0) uniform debugline_vs_params {
mat4 mvp;
};
out vec4 v_col;
void main() {
gl_Position = mvp * vec4(a_pos, 1.0);
v_col = a_col;
}
@end
@fs fs_debugline
in vec4 v_col;
out vec4 frag_color;
void main() {
frag_color = v_col;
}
@end
@program debugline vs_debugline fs_debugline

View File

@ -122,21 +122,21 @@ void main() {
vec3 halfway_dir = normalize(light_dir + view_dir); vec3 halfway_dir = normalize(light_dir + view_dir);
float diffuse = max(0.0, dot(normal, light_dir)); float diffuse = max(0.0, dot(normal, light_dir));
float spec = pow(max(0.0, dot(halfway_dir, normal)), 32); float spec = pow(max(0.0, dot(halfway_dir, normal)), max(shininess, 1.0));
float fresnel = min(1.0, fresnelSchlick(dot(view_dir, vec3(0.0, 1.0, 0.0))).x + 0.3); float fresnel = min(1.0, fresnelSchlick(max(0.0, dot(view_dir, normal))).x + 0.45);
vec4 shadow_proj_pos = mvp_shadow * vec4(pos.xyz, 1.0); vec4 shadow_proj_pos = mvp_shadow * vec4(floor(pos.xyz * 16.0) / 16.0, 1.0);
vec3 shadow_pos = shadow_proj_pos.xyz / shadow_proj_pos.w; vec3 shadow_pos = shadow_proj_pos.xyz / shadow_proj_pos.w;
shadow_pos = shadow_pos * 0.5 + 0.5; shadow_pos = shadow_pos * 0.5 + 0.5;
shadow_pos.z -= 0.001; shadow_pos.z -= 0.001;
float shadowp = texture(sampler2DShadow(shadow, plane_shadowsmp), shadow_pos); float shadowp = texture(sampler2DShadow(shadow, plane_shadowsmp), shadow_pos);
vec3 refracted_color = waterColor * diffuse * sunLightColor * sunIntensity * shadowp; vec3 refracted_color = waterColor * diffuse * sunLightColor * sunIntensity * shadowp;
vec3 specular_highlight = sunLightColor * sunIntensity * spec * shadowp; vec3 specular_highlight = sunLightColor * sunIntensity * spec * fresnel * shadowp;
vec2 screen_uv = gl_FragCoord.xy / vec2(screen_w, screen_h); vec2 screen_uv = gl_FragCoord.xy / vec2(screen_w, screen_h);
screen_uv.y = 1.0 - screen_uv.y; screen_uv.y = 1.0 - screen_uv.y;
vec2 distortion = normal.xz * 0.005; vec2 distortion = normal.xz * 0.007;
vec3 reflected_color = texture(sampler2D(reftex, refsmp), screen_uv + distortion).rgb; vec3 reflected_color = texture(sampler2D(reftex, refsmp), screen_uv + distortion).rgb;
vec3 surface_color = mix(refracted_color, reflected_color, fresnel); vec3 surface_color = mix(refracted_color, reflected_color, fresnel);

View File

@ -87,16 +87,28 @@ vec3 sky(vec3 skypos, vec3 sunpos) {
vec3 skyGradient = mix(baseSky, topSky, clamp(skypos.y * 2.0, 0.0, 0.7)); vec3 skyGradient = mix(baseSky, topSky, clamp(skypos.y * 2.0, 0.0, 0.7));
vec3 final = skyGradient; // Sun local frame — used for both halo and disk
final += sunHalo.xyz * clamp((sDist - 0.97) * 10.0, 0.0, 0.8) * 1.0; vec3 sunDir = normalize(sunpos);
vec3 sunRight = normalize(cross(sunDir, vec3(0.0, 1.0, 0.0)));
vec3 sunUp = normalize(cross(sunRight, sunDir));
vec3 sd = normalize(skypos) - sunDir * sDist;
float dx = dot(sd, sunRight);
float dy = dot(sd, sunUp);
float squareDist = max(abs(dx), abs(dy));
// Sun disk vec3 final = skyGradient;
if(sDist > 0.9995) {
// Sun halo (square, smooth falloff)
float haloFactor = clamp((0.25 - squareDist) * 6.0, 0.0, 1.0);
final += sunHalo.xyz * haloFactor * haloFactor;
// Sun square
if(squareDist < 0.032) {
final = sunDisk.xyz * 3.0; final = sunDisk.xyz * 3.0;
} }
// Horizon halo // Horizon halo
final += mix(horizonHalo.xyz, vec3(0.0,0.0,0.0), clamp(abs(npos.y) * 80.0, 0.0, 1.0)) * 0.1; final += mix(horizonHalo.xyz, vec3(0.0,0.0,0.0), clamp(abs(npos.y) * 20.0, 0.0, 1.0)) * 0.8;
final = vec3(final); final = vec3(final);

View File

@ -102,6 +102,7 @@ layout(binding=3) uniform trile_fs_params {
vec3 ambient_color; vec3 ambient_color;
int is_preview; int is_preview;
vec3 rdm_tint; vec3 rdm_tint;
float rdm_diff_saturation;
}; };
layout(binding = 0) uniform texture2D triletex; layout(binding = 0) uniform texture2D triletex;
@ -320,14 +321,15 @@ ivec2 rdm_face_pixel_offset(vec4 atlas_rect, int face, int rdmSize) {
vec3 sample_rdm(vec3 N, vec3 V, vec3 rdm_center, vec3 diff, int roughness, ivec3 local_pos) { vec3 sample_rdm(vec3 N, vec3 V, vec3 rdm_center, vec3 diff, int roughness, ivec3 local_pos) {
int face = rdm_index_from_normal(N); int face = rdm_index_from_normal(N);
int rdmSizeInt = int(roughness_to_rdm_size(roughness));
float rdmSize = float(rdmSizeInt);
vec4 atlas_rect = rdm_get_atlas_rect(local_pos, roughness); vec4 atlas_rect = rdm_get_atlas_rect(local_pos, roughness);
if (atlas_rect.z <= 0.0) return vec3(1.0, 0.0, 1.0); // No data - magenta if (atlas_rect.z <= 0.0) return vec3(1.0, 0.0, 1.0); // No data - magenta
ivec2 atlasTexSize = textureSize(sampler2D(rdm_atlas, rdmsmp), 0);
int rdmSizeInt = int(atlas_rect.z * float(atlasTexSize.x)) / 2;
float rdmSize = float(rdmSizeInt);
ivec2 faceOffset = rdm_face_pixel_offset(atlas_rect, face, rdmSizeInt); ivec2 faceOffset = rdm_face_pixel_offset(atlas_rect, face, rdmSizeInt);
// Get 2D UV on this face from the fragment's trile-space position
vec2 uv; vec2 uv;
if (face == 0 || face == 1) { // +Y / -Y if (face == 0 || face == 1) { // +Y / -Y
uv = vec2(ipos.x, ipos.z); uv = vec2(ipos.x, ipos.z);
@ -337,16 +339,9 @@ vec3 sample_rdm(vec3 N, vec3 V, vec3 rdm_center, vec3 diff, int roughness, ivec3
uv = vec2(ipos.z, ipos.y); uv = vec2(ipos.z, ipos.y);
} }
// Step 1: flat UV sampling (known working)
// ivec2 texCoord = ivec2(faceOffset.x + int(uv.x * rdmSize),
// faceOffset.y + int(uv.y * rdmSize));
// vec4 rdmSample = texelFetch(sampler2D(rdm_atlas, rdmsmp), texCoord, 0);
// return vec3(rdmSample.a * 0.2);
vec3 reflected = normalize(reflect(V, N)); vec3 reflected = normalize(reflect(V, N));
if (roughness > 1) { if (roughness > 1) {
// Low-res mips: sample at fixed distance with bilinear filtering
vec3 samplePos = normalize(diff + 2.0 * reflected); vec3 samplePos = normalize(diff + 2.0 * reflected);
vec2 hemiUV = rdm_get_hemioct(samplePos, face, vec2(0.0)); vec2 hemiUV = rdm_get_hemioct(samplePos, face, vec2(0.0));
vec2 atlasSize = vec2(textureSize(sampler2D(rdm_atlas, rdmsmp), 0)); vec2 atlasSize = vec2(textureSize(sampler2D(rdm_atlas, rdmsmp), 0));
@ -354,7 +349,6 @@ vec3 sample_rdm(vec3 N, vec3 V, vec3 rdm_center, vec3 diff, int roughness, ivec3
return texture(sampler2D(rdm_atlas, rdmsmp), texUV).rgb; return texture(sampler2D(rdm_atlas, rdmsmp), texUV).rgb;
} }
// High-res: ray march with depth comparison
float maxDist = 20.0; float maxDist = 20.0;
int steps = 40; int steps = 40;
for (int i = 0; i < steps; i++) { for (int i = 0; i < steps; i++) {
@ -363,9 +357,9 @@ vec3 sample_rdm(vec3 N, vec3 V, vec3 rdm_center, vec3 diff, int roughness, ivec3
if (dot(samplePos, N) < 0.0) continue; if (dot(samplePos, N) < 0.0) continue;
vec2 hemiUV = rdm_get_hemioct(normalize(samplePos), face, vec2(0.0)); vec2 hemiUV = rdm_get_hemioct(normalize(samplePos), face, vec2(0.0));
ivec2 texCoord = ivec2(faceOffset.x + int(hemiUV.x * rdmSize), vec2 atlasSize = vec2(textureSize(sampler2D(rdm_atlas, rdmsmp), 0));
faceOffset.y + int(hemiUV.y * rdmSize)); vec2 texCoord = (vec2(faceOffset) + hemiUV * rdmSize) / atlasSize;
vec4 rdmSample = texelFetch(sampler2D(rdm_atlas, rdmsmp), texCoord, 0); vec4 rdmSample = texture(sampler2D(rdm_atlas, rdmsmp), texCoord, 0);
float depth = rdmSample.a; float depth = rdmSample.a;
float dist = length(samplePos); float dist = length(samplePos);
float stepSize = maxDist / float(steps); float stepSize = maxDist / float(steps);
@ -569,6 +563,8 @@ void main() {
// Indirect diffuse (interpolated from neighbor probes) // Indirect diffuse (interpolated from neighbor probes)
vec3 indirectDiff = sample_rdm_diff(N, vpos - hemispherePos, local) * rdm_tint; vec3 indirectDiff = sample_rdm_diff(N, vpos - hemispherePos, local) * rdm_tint;
float diffLuma = dot(indirectDiff, vec3(0.2126, 0.7152, 0.0722));
indirectDiff = mix(vec3(diffLuma), indirectDiff, rdm_diff_saturation);
vec3 kDiff = 1.0 - Frough; vec3 kDiff = 1.0 - Frough;
kDiff *= 1.0 - metallic; kDiff *= 1.0 - metallic;
light += (kDiff * indirectDiff / PI * albedo) * ssao_sample * rdm_diff_scale; light += (kDiff * indirectDiff / PI * albedo) * ssao_sample * rdm_diff_scale;

View File

@ -8,6 +8,8 @@ in vec4 inst_col;
layout(binding=0) uniform vs_params { layout(binding=0) uniform vs_params {
mat4 mvp; mat4 mvp;
vec3 camera; vec3 camera;
vec3 world_offset;
mat4 tile_rotation;
}; };
out vec4 color; out vec4 color;
@ -18,8 +20,10 @@ out float vtrixel_state;
void main() { void main() {
vec3 instancepos = inst.xyz; vec3 instancepos = inst.xyz;
gl_Position = mvp * (vec4(position.xyz + instancepos, 1.0)); vec3 local = position.xyz + instancepos;
fnormal = normal; vec3 rotated = (tile_rotation * vec4(local - 0.5, 0.0)).xyz + 0.5;
gl_Position = mvp * vec4(rotated + world_offset, 1.0);
fnormal = tile_rotation * vec4(normal.xyz, 0.0);
color = inst_col; color = inst_col;
pos = gl_Position; pos = gl_Position;
cam = camera; cam = camera;
@ -31,6 +35,7 @@ void main() {
layout(binding=2) uniform trixel_fs_params { layout(binding=2) uniform trixel_fs_params {
int view_mode; int view_mode;
float brightness;
}; };
layout(binding=1) uniform trixel_world_config { layout(binding=1) uniform trixel_world_config {
@ -154,6 +159,8 @@ void main() {
frag_color = vec4(light + emissive, 1.0); frag_color = vec4(light + emissive, 1.0);
} }
frag_color.rgb *= brightness;
// Overlay highlight for hovered / selected / brush-radius trixels in all view modes. // Overlay highlight for hovered / selected / brush-radius trixels in all view modes.
// State is encoded per-instance in inst.w: 0=normal, 1=hovered, 2=selected, 3=in-brush. // State is encoded per-instance in inst.w: 0=normal, 1=hovered, 2=selected, 3=in-brush.
if (vtrixel_state > 0.5) { if (vtrixel_state > 0.5) {

View File

@ -85,6 +85,42 @@ get_trile :: (name: string) -> (*Trile, success: bool) {
return trileptr, true; return trileptr, true;
} }
rename_trile :: (old_name: string, new_name: string) {
trile := get_trile(old_name);
if !trile return;
was_current := editor_current_trile != null && editor_current_trile.name == old_name;
gfx_exists, old_gfx := table_find(*trile_gfx_table, old_name);
if gfx_exists {
sg_destroy_buffer(old_gfx.vertex_buffer);
sg_destroy_buffer(old_gfx.normal_buffer);
sg_destroy_buffer(old_gfx.centre_buffer);
sg_destroy_image(old_gfx.trixel_colors);
array_reset(*old_gfx.vertices);
table_remove(*trile_gfx_table, old_name);
}
copy := trile.*;
copy.name = sprint("%", new_name);
set_trile(copy.name, copy);
table_remove(*trile_table, old_name);
if was_current editor_current_trile = table_find_pointer(*trile_table, new_name);
}
delete_trile :: (name: string) {
gfx_exists, old_gfx := table_find(*trile_gfx_table, name);
if gfx_exists {
sg_destroy_buffer(old_gfx.vertex_buffer);
sg_destroy_buffer(old_gfx.normal_buffer);
sg_destroy_buffer(old_gfx.centre_buffer);
sg_destroy_image(old_gfx.trixel_colors);
array_reset(*old_gfx.vertices);
table_remove(*trile_gfx_table, name);
}
table_remove(*trile_table, name);
if editor_current_trile != null && editor_current_trile.name == name {
editor_current_trile = null;
}
}
get_trile_roughness_set :: (trile_name: string) -> u8 { get_trile_roughness_set :: (trile_name: string) -> u8 {
trile, ok := get_trile(trile_name); trile, ok := get_trile(trile_name);
if !ok then return 1 << 7; if !ok then return 1 << 7;
@ -101,6 +137,7 @@ get_trile_roughness_set :: (trile_name: string) -> u8 {
return mask; return mask;
} }
lstrile :: () -> string { lstrile :: () -> string {
count := 0; count := 0;
for v : trile_table { for v : trile_table {
@ -261,16 +298,3 @@ material_from_rgba :: (r: u8, g: u8, b: u8, a: u8) -> Material {
return mat; return mat;
} }
draw_trile_picker :: (r_in: GR.Rect, theme: *GR.Overall_Theme) {
r := r_in;
tpt := get_trile_table_ptr();
r.h = ui_h(4,4);
count := 0;
for v : tpt {
if GR.button(r, v.name, *t_button_selectable(theme, editor_current_trile != null && editor_current_trile.name == v.name), count) {
editor_current_trile = get_trile(v.name);
}
count += 1;
r.y += r.h;
}
}

View File

@ -368,7 +368,8 @@ tick_ui :: () {
vw = (cast(float) w)/100.0; vw = (cast(float) w)/100.0;
vh = (cast(float) h)/100.0; vh = (cast(float) h)/100.0;
array_reset_keeping_memory(*ui_events); array_reset_keeping_memory(*ui_events);
GR.ui_per_frame_update(1, xx w, xx h, get_time()); _, is_active := GR.ui_per_frame_update(1, xx w, xx h, get_time());
ui_keyboard_captured = is_active && !GR.is_grabbing();
#if !FLAG_RELEASE_BUILD { #if !FLAG_RELEASE_BUILD {
tick_editor_ui(); tick_editor_ui();
@ -377,6 +378,7 @@ tick_ui :: () {
} }
} }
ui_keyboard_captured : bool;
checkboxTest : bool = false; checkboxTest : bool = false;
get_font_at_size :: (pixel_height: int) -> *Font { get_font_at_size :: (pixel_height: int) -> *Font {

View File

@ -70,12 +70,45 @@ Editor_Note :: struct {
text : string; text : string;
} }
Rdm_Instance_Override :: struct {
x : s32;
y : s32;
z : s32;
size_override : s32;
quality_override : s32;
}
World :: struct { World :: struct {
name : string; name : string;
conf : World_Config; conf : World_Config;
chunks : Table(Chunk_Key, Chunk, chunk_key_hash, chunk_key_compare); chunks : Table(Chunk_Key, Chunk, chunk_key_hash, chunk_key_compare);
emitter_instances : [..]Particle_Emitter_Instance; emitter_instances : [..]Particle_Emitter_Instance;
notes : [..]Editor_Note; notes : [..]Editor_Note;
rdm_overrides : [..]Rdm_Instance_Override;
}
get_rdm_instance_override :: (world: *World, x: s32, y: s32, z: s32) -> (size_override: s32, quality_override: s32) {
for world.rdm_overrides {
if it.x == x && it.y == y && it.z == z then return it.size_override, it.quality_override;
}
return 0, 0;
}
set_rdm_instance_override :: (world: *World, x: s32, y: s32, z: s32, size_override: s32, quality_override: s32) {
for *world.rdm_overrides {
if it.x == x && it.y == y && it.z == z {
if size_override == 0 && quality_override == 0 {
array_ordered_remove_by_index(*world.rdm_overrides, it_index);
} else {
it.size_override = size_override;
it.quality_override = quality_override;
}
return;
}
}
if size_override != 0 || quality_override != 0 {
array_add(*world.rdm_overrides, .{x=x, y=y, z=z, size_override=size_override, quality_override=quality_override});
}
} }
// Convert a world-space integer position to chunk coordinate. // Convert a world-space integer position to chunk coordinate.
@ -191,12 +224,13 @@ WORLD_MAGIC :: u32.[0x4C575254][0]; // "TRWL" as little-endian u32
WORLD_VERSION :: cast(u16) 3; WORLD_VERSION :: cast(u16) 3;
World_Json :: struct { World_Json :: struct {
version : s32; version : s32;
name : string; name : string;
config : World_Json_Config; config : World_Json_Config;
chunks : [..]World_Json_Chunk; chunks : [..]World_Json_Chunk;
emitters : [..]World_Json_Emitter; emitters : [..]World_Json_Emitter;
notes : [..]World_Json_Note; notes : [..]World_Json_Note;
rdm_overrides : [..]World_Json_Rdm_Override;
} }
World_Json_Config :: struct { World_Json_Config :: struct {
@ -214,6 +248,8 @@ World_Json_Config :: struct {
animatePlaneHeight : s32; animatePlaneHeight : s32;
waterColor : [3]float; waterColor : [3]float;
deepColor : [3]float; deepColor : [3]float;
waterShininess : float;
rdmDiffSaturation : float;
} }
World_Json_Chunk :: struct { World_Json_Chunk :: struct {
@ -229,6 +265,7 @@ World_Json_Chunk :: struct {
World_Json_Emitter :: struct { World_Json_Emitter :: struct {
definition_name : string; definition_name : string;
position : [3]float; position : [3]float;
offset : [3]float;
} }
World_Json_Note :: struct { World_Json_Note :: struct {
@ -236,6 +273,14 @@ World_Json_Note :: struct {
position : [3]s32; position : [3]s32;
} }
World_Json_Rdm_Override :: struct {
x : s32;
y : s32;
z : s32;
size_override : s32;
quality_override : s32;
}
// World_Config serialized as a fixed-size binary blob. // World_Config serialized as a fixed-size binary blob.
// We serialize it field-by-field to avoid padding issues. // We serialize it field-by-field to avoid padding issues.
World_Config_Binary :: struct { World_Config_Binary :: struct {
@ -251,8 +296,10 @@ World_Config_Binary :: struct {
has_clouds: s32; has_clouds: s32;
plane_height: float; plane_height: float;
animate_plane_height: s32; animate_plane_height: s32;
water_color: [3]float; water_color: [3]float;
deep_color: [3]float; deep_color: [3]float;
water_shininess: float;
rdm_diff_saturation: float;
} }
world_config_to_binary :: (conf: *World_Config) -> World_Config_Binary { world_config_to_binary :: (conf: *World_Config) -> World_Config_Binary {
@ -269,8 +316,10 @@ world_config_to_binary :: (conf: *World_Config) -> World_Config_Binary {
b.has_clouds = conf.hasClouds; b.has_clouds = conf.hasClouds;
b.plane_height = conf.planeHeight; b.plane_height = conf.planeHeight;
b.animate_plane_height = conf.animatePlaneHeight; b.animate_plane_height = conf.animatePlaneHeight;
b.water_color = conf.waterColor.component; b.water_color = conf.waterColor.component;
b.deep_color = conf.deepColor.component; b.deep_color = conf.deepColor.component;
b.water_shininess = conf.waterShininess;
b.rdm_diff_saturation = conf.rdmDiffSaturation;
return b; return b;
} }
@ -290,6 +339,8 @@ world_config_from_binary :: (b: *World_Config_Binary) -> World_Config {
conf.animatePlaneHeight = b.animate_plane_height; conf.animatePlaneHeight = b.animate_plane_height;
conf.waterColor.component = b.water_color; conf.waterColor.component = b.water_color;
conf.deepColor.component = b.deep_color; conf.deepColor.component = b.deep_color;
conf.waterShininess = b.water_shininess;
conf.rdmDiffSaturation = b.rdm_diff_saturation;
return conf; return conf;
} }
@ -353,6 +404,8 @@ world_config_to_json :: (conf: *World_Config) -> World_Json_Config {
jc.animatePlaneHeight = conf.animatePlaneHeight; jc.animatePlaneHeight = conf.animatePlaneHeight;
jc.waterColor = conf.waterColor.component; jc.waterColor = conf.waterColor.component;
jc.deepColor = conf.deepColor.component; jc.deepColor = conf.deepColor.component;
jc.waterShininess = conf.waterShininess;
jc.rdmDiffSaturation = conf.rdmDiffSaturation;
return jc; return jc;
} }
@ -372,6 +425,8 @@ world_config_from_json :: (jc: *World_Json_Config) -> World_Config {
conf.animatePlaneHeight = jc.animatePlaneHeight; conf.animatePlaneHeight = jc.animatePlaneHeight;
conf.waterColor.component = jc.waterColor; conf.waterColor.component = jc.waterColor;
conf.deepColor.component = jc.deepColor; conf.deepColor.component = jc.deepColor;
conf.waterShininess = ifx jc.waterShininess > 0 then jc.waterShininess else 64.0;
conf.rdmDiffSaturation = ifx jc.rdmDiffSaturation > 0 then jc.rdmDiffSaturation else 1.0;
return conf; return conf;
} }
@ -449,6 +504,7 @@ save_world :: (world: *World) -> (json: string, chunks_bin: string) {
je: World_Json_Emitter; je: World_Json_Emitter;
je.definition_name = inst.definition_name; je.definition_name = inst.definition_name;
je.position = inst.position.component; je.position = inst.position.component;
je.offset = inst.offset.component;
array_add(*wj.emitters, je); array_add(*wj.emitters, je);
} }
@ -459,6 +515,10 @@ save_world :: (world: *World) -> (json: string, chunks_bin: string) {
array_add(*wj.notes, jn); array_add(*wj.notes, jn);
} }
for ov: world.rdm_overrides {
array_add(*wj.rdm_overrides, .{x=ov.x, y=ov.y, z=ov.z, size_override=ov.size_override, quality_override=ov.quality_override});
}
json_str := Jaison.json_write_string(wj, " "); json_str := Jaison.json_write_string(wj, " ");
return json_str, builder_to_string(*bin_builder); return json_str, builder_to_string(*bin_builder);
} }
@ -512,6 +572,7 @@ load_world_from_json :: (json_str: string, chunk_bin: []u8) -> (World, bool) {
inst: Particle_Emitter_Instance; inst: Particle_Emitter_Instance;
inst.definition_name = sprint("%", je.definition_name); inst.definition_name = sprint("%", je.definition_name);
inst.position.component = je.position; inst.position.component = je.position;
inst.offset.component = je.offset;
inst.active = true; inst.active = true;
array_add(*world.emitter_instances, inst); array_add(*world.emitter_instances, inst);
} }
@ -523,6 +584,10 @@ load_world_from_json :: (json_str: string, chunk_bin: []u8) -> (World, bool) {
array_add(*world.notes, note); array_add(*world.notes, note);
} }
for jov: wj.rdm_overrides {
array_add(*world.rdm_overrides, .{x=jov.x, y=jov.y, z=jov.z, size_override=jov.size_override, quality_override=jov.quality_override});
}
return world, true; return world, true;
} }
@ -651,6 +716,8 @@ World_Config :: struct {
animatePlaneHeight : s32 = 1; @Slider,0,1,1 animatePlaneHeight : s32 = 1; @Slider,0,1,1
waterColor : Vector3 = .{1.0, 1.0, 1.0}; @Color // @ToDo: sensible default values. waterColor : Vector3 = .{1.0, 1.0, 1.0}; @Color // @ToDo: sensible default values.
deepColor : Vector3 = .{1.0, 1.0, 1.0}; @Color // @ToDo: sensible default values. deepColor : Vector3 = .{1.0, 1.0, 1.0}; @Color // @ToDo: sensible default values.
waterShininess : float = 64.0; @Slider,1,512,8
rdmDiffSaturation : float = 1.0; @Slider,0,2,0.05
// ambientColor : Vector3 = .{1.0, 1.0, 1.0}; @Color // ambientColor : Vector3 = .{1.0, 1.0, 1.0}; @Color
// ambientIntensity : float = 0.3; @Slider,0,3,0.1 // ambientIntensity : float = 0.3; @Slider,0,3,0.1
@ -662,10 +729,16 @@ World_Config :: struct {
world_config_to_shader_type :: (wc: *World_Config, data: *$T) { world_config_to_shader_type :: (wc: *World_Config, data: *$T) {
generate_copy_code :: () -> string { generate_copy_code :: () -> string {
builder : String_Builder; builder : String_Builder;
ti := type_info(World_Config); ti_src := type_info(World_Config);
for ti.members { ti_dst := type_info(T);
if it.type == type_info(Vector3) then print_to_builder(*builder, "data.% = wc.%.component;\n", it.name, it.name); for src_member: ti_src.members {
else print_to_builder(*builder, "data.% = wc.%;\n", it.name, it.name); has_field := false;
for dst_member: ti_dst.members {
if dst_member.name == src_member.name { has_field = true; break; }
}
if !has_field continue;
if src_member.type == type_info(Vector3) then print_to_builder(*builder, "data.% = wc.%.component;\n", src_member.name, src_member.name);
else print_to_builder(*builder, "data.% = wc.%;\n", src_member.name, src_member.name);
} }
return builder_to_string(*builder); return builder_to_string(*builder);
} }