get RDMs working

This commit is contained in:
Tuomas Katajisto 2026-02-24 22:40:52 +02:00
parent ddc892c13c
commit 9098550523
17 changed files with 4357 additions and 3938 deletions

View File

@ -44,9 +44,19 @@ Iprof :: #import "Iprof"(IMPORT_MODE = .METAPROGRAM);
make_directory_if_it_does_not_exist("dist", recursive = true);
{
process_result, output, error := run_command("cp", "-r", "./resources", "./dist/", working_directory=tprint("%", #filepath));
// Copy compiled packs (produced by create_pack above).
if is_directory("./packs") {
run_command("cp", "-r", "./packs", "./dist/", working_directory=tprint("%", #filepath));
}
// Copy only the worlds subtree — not the whole game dir (avoids .git etc.).
worlds_src := "./game/resources/worlds";
if is_directory(worlds_src) {
make_directory_if_it_does_not_exist("./dist/game/resources", recursive = true);
run_command("cp", "-r", worlds_src, "./dist/game/resources/", working_directory=tprint("%", #filepath));
}
w := compiler_create_workspace("Wasm");
options := get_build_options(w);

View File

@ -2217,7 +2217,7 @@ EM_JS(void, sfetch_js_send_get_request, (uint32_t slot_id, const char* path_cstr
response.arrayBuffer().then((data) => {
const u8_data = new Uint8Array(data);
if (u8_data.length <= buf_size) {
HEAPU8.set(u8_data, buf_ptr);
HEAPU8.set(u8_data, Number(buf_ptr)); // MEMORY64: buf_ptr is BigInt, typed array offset must be Number
__sfetch_emsc_get_response(slot_id, bytes_to_read, u8_data.length);
} else {
__sfetch_emsc_failed_buffer_too_small(slot_id);

View File

@ -5,64 +5,182 @@ hash :: #import "Hash";
#load "loaders.jai";
MAX_FILE_SIZE :: 200_000_000;
buf : [MAX_FILE_SIZE]u8;
world_buf : [MAX_FILE_SIZE]u8;
// Shared types and the global must be #scope_export so that rdm_loader.jai
// (a separate file, even when #load-ed) can access them.
#scope_export
Pack_Request :: struct {
name : string;
shouldBlock : bool;
loading : bool = false;
shouldBlockEngine : bool; // Means that the engine loop should do nothing while this is loading...
Fetch_Type :: enum {
PACK;
WORLD;
RDM_ATLAS;
RDM_LOOKUP;
}
World_Load_Request :: struct {
name : string;
pending : bool = false;
loading : bool = false;
Fetch_Request :: struct {
type : Fetch_Type;
path : string;
// Pack
pack_name : string;
should_block : bool;
should_block_engine : bool;
// World / RDM
world_name : string;
chunk_key : Chunk_Key;
// Atlas GPU image held between RDM_ATLAS and its paired RDM_LOOKUP fetch.
rdm_pending_atlas : sg_image;
}
Asset_Manager :: struct {
packQueue : [..]Pack_Request;
loadedPacks : [..]Loaded_Pack;
worldRequest : World_Load_Request;
fetch_queue : [..]Fetch_Request;
is_fetching : bool;
current_fetch : Fetch_Request;
loadedPacks : [..]Loaded_Pack;
}
g_asset_manager : Asset_Manager;
packcb :: (res: *sfetch_response_t) #c_call {
push_context,defer_pop default_context;
mem := NewArray(res.data.size.(s64), u8, false);
memcpy(mem.data, res.data.ptr, res.data.size.(s64));
#scope_file
pack: Loaded_Pack;
pack.nameHash = hash.get_hash(g_asset_manager.packQueue[0].name);
pack.name = g_asset_manager.packQueue[0].name;
success := init_from_memory(*pack.content, mem, sprint("%", g_asset_manager.packQueue[0].name));
if !success then print("Failed to load pack!!\n");
add_resources_from_pack(*pack);
array_add(*g_asset_manager.loadedPacks, pack);
array_unordered_remove_by_index(*g_asset_manager.packQueue, 0);
#load "rdm_loader.jai";
MAX_FILE_SIZE :: 200_000_000;
buf : [MAX_FILE_SIZE]u8;
world_buf : [MAX_FILE_SIZE]u8;
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);
rdm_atlas_buf : [RDM_ATLAS_MAX_BYTES]u8;
rdm_lookup_buf : [RDM_LOOKUP_MAX_BYTES]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 == .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;
}
worldcb :: (res: *sfetch_response_t) #c_call {
fetch_callback :: (res: *sfetch_response_t) #c_call {
push_context,defer_pop default_context;
if res.failed {
print("Failed to load world '%'\n", g_asset_manager.worldRequest.name);
g_asset_manager.worldRequest = .{};
return;
req := g_asset_manager.current_fetch;
g_asset_manager.is_fetching = false;
if req.type == {
case .PACK;
if res.failed {
print("Failed to load pack '%'\n", req.pack_name);
return;
}
mem := NewArray(res.data.size.(s64), u8, false);
memcpy(mem.data, res.data.ptr, res.data.size.(s64));
pack: Loaded_Pack;
pack.nameHash = hash.get_hash(req.pack_name);
pack.name = req.pack_name;
success := init_from_memory(*pack.content, mem, sprint("%", req.pack_name));
if !success { print("Failed to load pack!!\n"); return; }
add_resources_from_pack(*pack);
array_add(*g_asset_manager.loadedPacks, pack);
case .WORLD;
if res.failed {
print("Failed to load world '%'\n", req.world_name);
return;
}
data: []u8;
data.data = res.data.ptr;
data.count = res.data.size.(s64);
world, ok := load_world_from_data(data);
if ok {
set_loaded_world(world);
rdm_loader_enqueue_world(*get_current_world().world);
print("Loaded world: %\n", world.name);
} else {
print("Failed to parse world '%'\n", req.world_name);
}
case .RDM_ATLAS;
curworld := get_current_world();
if !curworld.valid || curworld.world.name != req.world_name then return;
if res.failed {
print("RDM: failed to load atlas for chunk %\n", req.chunk_key);
return;
}
header_size := cast(s64) size_of(RDM_File_Header);
if res.data.size < cast(u64) header_size {
print("RDM: atlas too small for chunk %\n", req.chunk_key);
return;
}
header := cast(*RDM_File_Header) res.data.ptr;
if header.magic != RDM_FILE_MAGIC {
print("RDM: bad atlas magic for chunk %\n", req.chunk_key);
return;
}
atlas_pixel_bytes := cast(u64) header.width * cast(u64) header.height * 4 * size_of(float);
atlas_imgdata : sg_image_data;
atlas_imgdata.subimage[0][0] = .{ res.data.ptr + header_size, atlas_pixel_bytes };
atlas_desc : sg_image_desc = .{
render_target = false,
width = header.width,
height = header.height,
pixel_format = sg_pixel_format.RGBA32F,
sample_count = 1,
data = atlas_imgdata,
};
// Enqueue the lookup with the atlas image embedded in the request.
lookup_req : Fetch_Request;
lookup_req.type = .RDM_LOOKUP;
lookup_req.world_name = req.world_name;
lookup_req.chunk_key = req.chunk_key;
lookup_req.path = rdm_chunk_filename(req.world_name, req.chunk_key, "rdm_lookup");
lookup_req.rdm_pending_atlas = sg_make_image(*atlas_desc);
array_add(*g_asset_manager.fetch_queue, lookup_req);
case .RDM_LOOKUP;
curworld := get_current_world();
world_ok := curworld.valid && curworld.world.name == req.world_name;
if res.failed || !world_ok {
if res.failed then print("RDM: failed to load lookup for chunk %\n", req.chunk_key);
if req.rdm_pending_atlas.id != 0 then sg_destroy_image(req.rdm_pending_atlas);
return;
}
header_size := cast(s64) size_of(RDM_File_Header);
if res.data.size < cast(u64) header_size {
print("RDM: lookup too small for chunk %\n", req.chunk_key);
sg_destroy_image(req.rdm_pending_atlas);
return;
}
header := cast(*RDM_File_Header) res.data.ptr;
if header.magic != RDM_FILE_MAGIC {
print("RDM: bad lookup magic for chunk %\n", req.chunk_key);
sg_destroy_image(req.rdm_pending_atlas);
return;
}
lookup_pixel_bytes := cast(u64) header.width * cast(u64) header.height * 4 * size_of(float);
lookup_imgdata : sg_image_data;
lookup_imgdata.subimage[0][0] = .{ res.data.ptr + header_size, lookup_pixel_bytes };
lookup_desc : sg_image_desc = .{
render_target = false,
width = header.width,
height = header.height,
pixel_format = sg_pixel_format.RGBA32F,
sample_count = 1,
data = lookup_imgdata,
};
chunk := table_find_pointer(*curworld.world.chunks, req.chunk_key);
if chunk != null {
chunk.rdm_atlas = req.rdm_pending_atlas;
chunk.rdm_lookup = sg_make_image(*lookup_desc);
chunk.rdm_valid = true;
print("RDM: loaded chunk %\n", req.chunk_key);
} else {
sg_destroy_image(req.rdm_pending_atlas);
}
}
data: []u8;
data.data = res.data.ptr;
data.count = res.data.size.(s64);
world, ok := load_world_from_data(data);
if ok {
set_loaded_world(world);
print("Loaded world: %\n", world.name);
} else {
print("Failed to parse world '%'\n", g_asset_manager.worldRequest.name);
}
g_asset_manager.worldRequest = .{};
}
Loaded_Pack :: struct {
@ -97,7 +215,7 @@ add_resources_from_pack :: (pack: *Loaded_Pack) {
img, w, h := create_texture_from_memory(v.data);
queuedSheet := table_find_pointer(*sheets_to_init, name);
if !queuedSheet {
table_set(*sheets_to_init, name, .{ name = name, image = img, sheet_w = w, sheet_h = h });
table_set(*sheets_to_init, name, .{ name = name, image = img, sheet_w = w, sheet_h = h });
} else {
queuedSheet.image = img;
queuedSheet.sheet_w = w;
@ -112,9 +230,9 @@ add_resources_from_pack :: (pack: *Loaded_Pack) {
}
queuedSheet := table_find_pointer(*sheets_to_init, name);
if !queuedSheet {
table_set(*sheets_to_init, name, .{ name = name, sheet = sheet });
table_set(*sheets_to_init, name, .{ name = name, sheet = sheet });
} else {
queuedSheet.sheet = sheet;
queuedSheet.sheet = sheet;
}
case "colorgrade.png";
img, x, y := create_texture_from_memory(v.data);
@ -150,7 +268,7 @@ add_resources_from_pack :: (pack: *Loaded_Pack) {
});
}
table_add(*pack.animations, anim.name, anim);
print("Added anim(%)\n", anim.name);
print("Added anim(%)\n", anim.name);
}
}
@ -159,7 +277,7 @@ add_resources_from_pack :: (pack: *Loaded_Pack) {
}
free_resources_from_pack :: (pack: *Loaded_Pack) {
}
find_pack_by_name :: (name: string) -> (bool, Loaded_Pack) {
@ -175,46 +293,40 @@ find_pack_by_name :: (name: string) -> (bool, Loaded_Pack) {
#scope_export
// Pack management:
mandatory_loads_done :: () -> bool {
for g_asset_manager.packQueue {
if it.shouldBlockEngine return false;
if g_asset_manager.is_fetching && g_asset_manager.current_fetch.should_block_engine then return false;
for g_asset_manager.fetch_queue {
if it.should_block_engine then return false;
}
return true;
}
show_loading_screen :: () -> bool {
if g_asset_manager.worldRequest.pending return true;
for g_asset_manager.packQueue {
if it.shouldBlock return true;
if g_asset_manager.is_fetching && g_asset_manager.current_fetch.should_block then return true;
for g_asset_manager.fetch_queue {
if it.should_block then return true;
}
return false;
}
asset_manager_tick :: () {
if g_asset_manager.packQueue.count > 0 && !g_asset_manager.packQueue[0].loading {
sfetch_send(*(sfetch_request_t.{
path = to_c_string(tprint("./packs/%.pack", g_asset_manager.packQueue[0].name)),
callback = packcb,
buffer = .{
ptr = buf.data,
size = buf.count
}
}));
g_asset_manager.packQueue[0].loading = true;
}
if !g_asset_manager.is_fetching && g_asset_manager.fetch_queue.count > 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;
if g_asset_manager.worldRequest.pending && !g_asset_manager.worldRequest.loading {
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(tprint("./game/resources/worlds/%/index.world", g_asset_manager.worldRequest.name)),
callback = worldcb,
buffer = .{
ptr = world_buf.data,
size = world_buf.count
}
path = to_c_string(req.path),
callback = fetch_callback,
buffer = .{ ptr = buf_ptr, size = buf_size },
}));
g_asset_manager.worldRequest.loading = true;
}
sfetch_dowork();
@ -222,18 +334,22 @@ asset_manager_tick :: () {
load_world :: (name: string) {
unload_current_world();
g_asset_manager.worldRequest = .{
name = name,
pending = true,
};
req : Fetch_Request;
req.type = .WORLD;
req.world_name = sprint("%", name);
req.path = sprint("./game/resources/worlds/%/index.world", name);
req.should_block = true;
array_add(*g_asset_manager.fetch_queue, req);
}
load_pack :: (name: string, shouldBlock: bool = true, shouldBlockEngine: bool = false) {
array_add(*g_asset_manager.packQueue, .{
name = name,
shouldBlock = shouldBlock,
shouldBlockEngine = shouldBlockEngine
});
req : Fetch_Request;
req.type = .PACK;
req.pack_name = sprint("%", name);
req.path = sprint("./packs/%.pack", name);
req.should_block = shouldBlock;
req.should_block_engine = shouldBlockEngine;
array_add(*g_asset_manager.fetch_queue, req);
}
// Asset management:
@ -251,7 +367,7 @@ get_texture_from_pack :: (pack: string, path: string) -> (sg_image) {
}
ok, img := table_find(*pack.textures, path);
if !ok {
print("[WARNING] Failed to find texture(%) from pack(%)\n", path, pack.name);
return invalid_img;
@ -289,7 +405,7 @@ load_string_from_pack :: (pack: string, path: string) -> string {
print("Warning: you are circumventing the asset management system....\n");
pack_ok, pack := find_pack_by_name(pack);
if !pack_ok return "";
ok, entry := table_find(*pack.content.lookup, path);
if !ok {
print("Failed to load string from pack: %\n", path);

64
src/assets/rdm_loader.jai Normal file
View File

@ -0,0 +1,64 @@
// RDM streaming helpers.
// The unified fetch queue lives in asset_manager.jai; these functions
// add and remove RDM entries from that shared queue.
#scope_export
rdm_loader_enqueue_world :: (world: *World) {
for *chunk: world.chunks {
if chunk.rdm_valid then continue;
// Skip if this chunk is already in-flight.
if g_asset_manager.is_fetching {
cf := g_asset_manager.current_fetch;
if (cf.type == .RDM_ATLAS || cf.type == .RDM_LOOKUP) &&
cf.world_name == world.name && cf.chunk_key == chunk.coord then continue;
}
// Skip if already queued (either as atlas or its follow-up lookup).
already_queued := false;
for g_asset_manager.fetch_queue {
if (it.type == .RDM_ATLAS || it.type == .RDM_LOOKUP) &&
it.world_name == world.name && it.chunk_key == chunk.coord {
already_queued = true;
break;
}
}
if already_queued then continue;
req : Fetch_Request;
req.type = .RDM_ATLAS;
req.world_name = world.name;
req.chunk_key = chunk.coord;
req.path = rdm_chunk_filename(world.name, chunk.coord, "rdm_atlas");
array_add(*g_asset_manager.fetch_queue, req);
}
}
// Remove all pending RDM fetches from the queue and invalidate any in-flight
// RDM fetch so its callback discards the result.
rdm_loader_cancel_all :: () {
// Filter out RDM items, destroying any atlas images stored inside them.
new_count := 0;
for i: 0..g_asset_manager.fetch_queue.count - 1 {
item := g_asset_manager.fetch_queue[i];
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;
// Blank the world name on the in-flight request so its callback discards.
if g_asset_manager.is_fetching &&
(g_asset_manager.current_fetch.type == .RDM_ATLAS ||
g_asset_manager.current_fetch.type == .RDM_LOOKUP) {
if g_asset_manager.current_fetch.rdm_pending_atlas.id != 0 {
sg_destroy_image(g_asset_manager.current_fetch.rdm_pending_atlas);
g_asset_manager.current_fetch.rdm_pending_atlas = .{};
}
g_asset_manager.current_fetch.world_name = "";
}
}

View File

@ -1,3 +1,4 @@
#load "rdm_disk.jai";
#if OS != .WASM {
#load "iprof.jai";
#load "picker.jai";
@ -67,6 +68,7 @@ draw_editor_ui :: (theme: *GR.Overall_Theme) {
draw_console(theme);
draw_texture_debugger(theme);
draw_postprocess_popup(theme);
draw_lighting_popup(theme);
GR.draw_popups();
immediate_flush();
}

14
src/editor/rdm_disk.jai Normal file
View File

@ -0,0 +1,14 @@
// RDM disk format helpers shared by the baking tool (tacoma) and the
// sfetch-based streaming loader (rdm_loader.jai).
RDM_File_Header :: struct {
magic: u32;
width: s32;
height: s32;
}
RDM_FILE_MAGIC :: u32.[0x4D445254][0]; // "TRDM" as little-endian u32
rdm_chunk_filename :: (world_name: string, chunk_key: Chunk_Key, suffix: string) -> string {
return sprint("./game/resources/worlds/%/%_%_%.%", world_name, chunk_key.x, chunk_key.y, chunk_key.z, suffix);
}

View File

@ -535,22 +535,8 @@ gen_rdm :: (quality: s32, include_water: bool, world: World) {
}
// --- RDM disk persistence ---
#if OS != .WASM {
rdm_file :: #import "File";
}
RDM_File_Header :: struct {
magic: u32;
width: s32;
height: s32;
}
RDM_FILE_MAGIC :: u32.[0x4D445254][0]; // "TRDM" as little-endian u32
rdm_chunk_filename :: (world_name: string, chunk_key: Chunk_Key, suffix: string) -> string {
return tprint("./game/resources/worlds/%/%_%_%.%", world_name, chunk_key.x, chunk_key.y, chunk_key.z, suffix);
}
// (RDM_File_Header, RDM_FILE_MAGIC, rdm_chunk_filename, rdm_load_from_disk
// are defined in rdm_disk.jai which is always loaded on non-WASM builds.)
rdm_save_image_to_file :: (path: string, data: *float, width: s32, height: s32) {
#if OS != .WASM {
@ -608,63 +594,4 @@ rdm_save_all_chunks_to_disk :: () {
}
}
rdm_load_from_disk :: () {
#if OS != .WASM {
curworld := get_current_world();
if !curworld.valid then return;
world_name := curworld.world.name;
for *chunk: curworld.world.chunks {
if chunk.rdm_valid then continue;
atlas_path := rdm_chunk_filename(world_name, chunk.coord, "rdm_atlas");
lookup_path := rdm_chunk_filename(world_name, chunk.coord, "rdm_lookup");
atlas_data, atlas_ok := rdm_file.read_entire_file(atlas_path);
if !atlas_ok then continue;
lookup_data, lookup_ok := rdm_file.read_entire_file(lookup_path);
if !lookup_ok then continue;
header_size := cast(s64) size_of(RDM_File_Header);
if atlas_data.count < header_size || lookup_data.count < header_size then continue;
atlas_header := cast(*RDM_File_Header) atlas_data.data;
lookup_header := cast(*RDM_File_Header) lookup_data.data;
if atlas_header.magic != RDM_FILE_MAGIC || lookup_header.magic != RDM_FILE_MAGIC then continue;
// Create atlas GPU image.
atlas_imgdata : sg_image_data;
atlas_pixel_bytes := cast(u64) atlas_header.width * cast(u64) atlas_header.height * 4 * size_of(float);
atlas_imgdata.subimage[0][0] = .{atlas_data.data + header_size, atlas_pixel_bytes};
atlas_desc : sg_image_desc = .{
render_target = false,
width = atlas_header.width,
height = atlas_header.height,
pixel_format = sg_pixel_format.RGBA32F,
sample_count = 1,
data = atlas_imgdata,
};
chunk.rdm_atlas = sg_make_image(*atlas_desc);
// Create lookup GPU image.
lookup_imgdata : sg_image_data;
lookup_pixel_bytes := cast(u64) lookup_header.width * cast(u64) lookup_header.height * 4 * size_of(float);
lookup_imgdata.subimage[0][0] = .{lookup_data.data + header_size, lookup_pixel_bytes};
lookup_desc : sg_image_desc = .{
render_target = false,
width = lookup_header.width,
height = lookup_header.height,
pixel_format = sg_pixel_format.RGBA32F,
sample_count = 1,
data = lookup_imgdata,
};
chunk.rdm_lookup = sg_make_image(*lookup_desc);
chunk.rdm_valid = true;
print("Loaded RDM data for chunk % from disk\n", chunk.coord);
}
}
}

View File

@ -5,6 +5,9 @@ subwindow_initted : bool = false;
pp_subwindow : GR.Subwindow_Info;
pp_subwindow_initted : bool = false;
lighting_subwindow : GR.Subwindow_Info;
lighting_subwindow_initted : bool = false;
// @Hack: This is probably kinda a bad idea, I don't really know atm how else to get the theme into the subwindow.
theme_ptr : GR.Overall_Theme;
@ -55,6 +58,11 @@ draw_subwindow_texture_debug :: (state: *GR.Subwindow_State, r: GR.Rect, data: *
immediate_flush();
}
draw_subwindow_lighting :: (state: *GR.Subwindow_State, r: GR.Rect, data: *void) {
ui_add_mouse_occluder(r);
autoedit(r, *current_lighting_config, *theme_ptr);
}
draw_subwindow_post_process :: (state: *GR.Subwindow_State, r: GR.Rect, data: *void) {
r2 := r;
ui_add_mouse_occluder(r);
@ -91,6 +99,10 @@ toggle_pp :: () {
pp_subwindow.open = !pp_subwindow.open;
} @Command
toggle_lighting :: () {
lighting_subwindow.open = !lighting_subwindow.open;
} @Command
draw_postprocess_popup :: (theme: *GR.Overall_Theme) {
if !pp_subwindow.open then return;
if !pp_subwindow_initted {
@ -107,6 +119,22 @@ draw_postprocess_popup :: (theme: *GR.Overall_Theme) {
}
}
draw_lighting_popup :: (theme: *GR.Overall_Theme) {
if !lighting_subwindow.open then return;
if !lighting_subwindow_initted {
theme_ptr = theme;
r := GR.get_rect(ui_w(55, 0), ui_w(40, 0), ui_h(50,0), ui_h(40,0));
lighting_subwindow.rect = r;
lighting_subwindow.draw = draw_subwindow_lighting;
lighting_subwindow.title_text = "Lighting";
lighting_subwindow.open = false;
lighting_subwindow_initted = true;
}
if lighting_subwindow.open {
GR.add_subwindow(*lighting_subwindow, *theme.subwindow_theme);
}
}
draw_texture_debugger :: (theme: *GR.Overall_Theme) {
if !subwindow.open then return;
if !subwindow_initted {

View File

@ -181,12 +181,18 @@ backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *
bindings.images[2] = g_rendertex_depth;
}
// Bind RDM textures for this chunk
// Bind RDM textures for this chunk. Fall back to a 1x1 black image when
// no baked data is available so sokol doesn't drop the draw call.
// The shader gates all RDM sampling on atlas_rect.z > 0, which the
// fallback texture returns as 0, so the ambient fallback path is taken.
curworld := get_current_world();
rdm_chunk := table_find_pointer(*curworld.world.chunks, chunk_key);
if rdm_chunk != null && rdm_chunk.rdm_valid {
bindings.images[3] = rdm_chunk.rdm_lookup;
bindings.images[4] = rdm_chunk.rdm_atlas;
} else {
bindings.images[3] = g_rdm_fallback;
bindings.images[4] = g_rdm_fallback;
}
bindings.images[5] = g_brdf_lut;
bindings.samplers[3] = gPipelines.trile.bind.samplers[3];
@ -197,6 +203,13 @@ backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *
w, h := get_render_size();
fs_params.screen_w = w;
fs_params.screen_h = h;
lc := *current_lighting_config;
fs_params.rdm_enabled = lc.rdm_enabled;
fs_params.ambient_intensity = lc.ambient_intensity;
fs_params.emissive_scale = lc.emissive_scale;
fs_params.rdm_diff_scale = lc.rdm_diff_scale;
fs_params.rdm_spec_scale = lc.rdm_spec_scale;
fs_params.ambient_color = lc.ambient_color.component;
sg_apply_bindings(*bindings);
sg_apply_uniforms(UB_trile_fs_params, *(sg_range.{ ptr = *fs_params, size = size_of(type_of(fs_params)) }));

View File

@ -9,6 +9,7 @@ Pipeline_Binding :: struct {
g_specular_lut : sg_image;
g_brdf_lut : sg_image;
g_rdm_fallback : sg_image; // 1x1 black image used when a chunk has no baked RDM data
g_shadowmap : sg_image;
g_shadowmap_img : sg_image;
@ -1088,6 +1089,22 @@ init_brdf_lut :: () {
};
g_brdf_lut = sg_make_image(*desc);
}
// 1x1 black image for RDM slots when no baked data is present.
// The lookup texture returning all zeros makes atlas_rect.z == 0,
// so the shader's fallback ambient path is taken.
{
pixels : [4]u8 = .[0, 0, 0, 0];
imgdata : sg_image_data;
imgdata.subimage[0][0] = .{ pixels.data, 4 };
desc := sg_image_desc.{
width = 1,
height = 1,
pixel_format = .RGBA8,
data = imgdata,
};
g_rdm_fallback = sg_make_image(*desc);
}
}
g_plane_gbuffer_vertex_buffer : sg_buffer;

View File

@ -33,6 +33,17 @@ Post_Process :: struct {
current_post_process : Post_Process;
Lighting_Config :: struct {
rdm_enabled : s32 = 1; @Slider,0,1,1
ambient_intensity : float = 0.35; @Slider,0,2,0.05
emissive_scale : float = 5.0; @Slider,0,20,0.5
rdm_diff_scale : float = 1.0; @Slider,0,3,0.1
rdm_spec_scale : float = 1.0; @Slider,0,3,0.1
ambient_color : Vector3 = .{0.3,0.3,0.4}; @Color
}
current_lighting_config : Lighting_Config;
Post_Process_Save :: struct {
#as using pp: Post_Process;
lut_name: string;

File diff suppressed because it is too large Load Diff

View File

@ -143,7 +143,7 @@ vs_trixel_source_glsl430 := u8.[
float time;
};
uniform trixel_world_config _200;
uniform trixel_world_config _205;
layout(location = 0) in vec4 color;
layout(location = 1) in vec4 fnormal;
@ -187,25 +187,25 @@ vs_trixel_source_glsl430 := u8.[
float _172 = max(float((_150 >> 5) & 7) * 0.14285714924335479736328125, 0.0500000007450580596923828125);
float _178 = float((_150 >> 3) & 3) * 0.3333333432674407958984375;
vec3 light = color.xyz * 0.300000011920928955078125;
vec3 _187 = normalize(fnormal.xyz);
vec3 _196 = normalize(cam - pos.xyz);
vec3 _205 = normalize(_200.sunPosition);
vec3 _210 = normalize(_196 + _205);
float param = max(dot(_210, _196), 0.0);
vec3 _192 = normalize(fnormal.xyz);
vec3 _201 = normalize(cam - pos.xyz);
vec3 _210 = normalize(_205.sunPosition);
vec3 _215 = normalize(_201 + _210);
float param = max(dot(_215, _201), 0.0);
vec3 param_1 = mix(vec3(0.039999999105930328369140625), color.xyz, vec3(_178));
vec3 _227 = fresnelSchlick(param, param_1);
vec3 param_2 = _187;
vec3 param_3 = _210;
vec3 _232 = fresnelSchlick(param, param_1);
vec3 param_2 = _192;
vec3 param_3 = _215;
float param_4 = _172;
vec3 param_5 = _187;
vec3 param_6 = _196;
vec3 param_7 = _205;
vec3 param_5 = _192;
vec3 param_6 = _201;
vec3 param_7 = _210;
float param_8 = _172;
float _262 = max(dot(_187, _205), 0.0);
vec3 _294 = light;
vec3 _295 = _294 + ((((((vec3(1.0) - _227) * (1.0 - _178)) * color.xyz) * vec3(0.3183410167694091796875)) + ((_227 * (DistributionGGX(param_2, param_3, param_4) * GeometrySmith(param_5, param_6, param_7, param_8))) / vec3(((4.0 * max(dot(_187, _196), 0.0)) * _262) + 9.9999997473787516355514526367188e-05))) * _262);
light = _295;
frag_color = vec4(_295, 1.0);
float _267 = max(dot(_192, _210), 0.0);
vec3 _299 = light;
vec3 _300 = _299 + ((((((vec3(1.0) - _232) * (1.0 - _178)) * color.xyz) * vec3(0.3183410167694091796875)) + ((_232 * (DistributionGGX(param_2, param_3, param_4) * GeometrySmith(param_5, param_6, param_7, param_8))) / vec3(((4.0 * max(dot(_192, _201), 0.0)) * _267) + 9.9999997473787516355514526367188e-05))) * _267);
light = _300;
frag_color = vec4(_300 + ((color.xyz * (float((_150 >> 1) & 3) * 0.3333333432674407958984375)) * 5.0), 1.0);
}
*/
@ -233,7 +233,7 @@ fs_trixel_source_glsl430 := u8.[
0x20,0x64,0x65,0x65,0x70,0x43,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x20,0x74,0x69,0x6d,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f,0x77,
0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x20,0x5f,0x32,0x30,0x30,
0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x20,0x5f,0x32,0x30,0x35,
0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
@ -319,67 +319,72 @@ fs_trixel_source_glsl430 := u8.[
0x69,0x67,0x68,0x74,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,
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,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x38,0x37,0x20,0x3d,0x20,0x6e,
0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x39,0x32,0x20,0x3d,0x20,0x6e,
0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
0x5f,0x31,0x39,0x36,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
0x5f,0x32,0x30,0x31,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
0x28,0x63,0x61,0x6d,0x20,0x2d,0x20,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x30,0x35,0x20,0x3d,
0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,0x30,0x30,0x2e,
0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x31,0x30,0x20,0x3d,
0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,0x30,0x35,0x2e,
0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x31,0x30,0x20,0x3d,0x20,0x6e,0x6f,
0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x31,0x39,0x36,0x20,0x2b,0x20,0x5f,
0x32,0x30,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x31,0x35,0x20,0x3d,0x20,0x6e,0x6f,
0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,0x30,0x31,0x20,0x2b,0x20,0x5f,
0x32,0x31,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,
0x5f,0x32,0x31,0x30,0x2c,0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,0x20,0x30,0x2e,0x30,
0x5f,0x32,0x31,0x35,0x2c,0x20,0x5f,0x32,0x30,0x31,0x29,0x2c,0x20,0x30,0x2e,0x30,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,
0x6d,0x5f,0x31,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x76,0x65,0x63,0x33,0x28,0x30,
0x2e,0x30,0x33,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x31,0x30,0x35,0x39,0x33,0x30,
0x33,0x32,0x38,0x33,0x36,0x39,0x31,0x34,0x30,0x36,0x32,0x35,0x29,0x2c,0x20,0x63,
0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,
0x31,0x37,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
0x5f,0x32,0x32,0x37,0x20,0x3d,0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,
0x5f,0x32,0x33,0x32,0x20,0x3d,0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,
0x68,0x6c,0x69,0x63,0x6b,0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,
0x61,0x6d,0x5f,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,0x0a,
0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31,0x39,0x32,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,
0x20,0x3d,0x20,0x5f,0x32,0x31,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x20,0x3d,0x20,0x5f,0x32,0x31,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x20,0x3d,0x20,0x5f,0x31,0x37,
0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,
0x6d,0x5f,0x35,0x20,0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x6d,0x5f,0x35,0x20,0x3d,0x20,0x5f,0x31,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x36,0x20,0x3d,0x20,0x5f,
0x31,0x39,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,
0x72,0x61,0x6d,0x5f,0x37,0x20,0x3d,0x20,0x5f,0x32,0x30,0x35,0x3b,0x0a,0x20,0x20,
0x32,0x30,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,
0x72,0x61,0x6d,0x5f,0x37,0x20,0x3d,0x20,0x5f,0x32,0x31,0x30,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x38,0x20,
0x3d,0x20,0x5f,0x31,0x37,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x20,0x5f,0x32,0x36,0x32,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,
0x28,0x5f,0x31,0x38,0x37,0x2c,0x20,0x5f,0x32,0x30,0x35,0x29,0x2c,0x20,0x30,0x2e,
0x74,0x20,0x5f,0x32,0x36,0x37,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,
0x28,0x5f,0x31,0x39,0x32,0x2c,0x20,0x5f,0x32,0x31,0x30,0x29,0x2c,0x20,0x30,0x2e,
0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x39,
0x34,0x20,0x3d,0x20,0x6c,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,
0x65,0x63,0x33,0x20,0x5f,0x32,0x39,0x35,0x20,0x3d,0x20,0x5f,0x32,0x39,0x34,0x20,
0x39,0x20,0x3d,0x20,0x6c,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,
0x65,0x63,0x33,0x20,0x5f,0x33,0x30,0x30,0x20,0x3d,0x20,0x5f,0x32,0x39,0x39,0x20,
0x2b,0x20,0x28,0x28,0x28,0x28,0x28,0x28,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,
0x29,0x20,0x2d,0x20,0x5f,0x32,0x32,0x37,0x29,0x20,0x2a,0x20,0x28,0x31,0x2e,0x30,
0x29,0x20,0x2d,0x20,0x5f,0x32,0x33,0x32,0x29,0x20,0x2a,0x20,0x28,0x31,0x2e,0x30,
0x20,0x2d,0x20,0x5f,0x31,0x37,0x38,0x29,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,
0x72,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,
0x33,0x31,0x38,0x33,0x34,0x31,0x30,0x31,0x36,0x37,0x36,0x39,0x34,0x30,0x39,0x31,
0x37,0x39,0x36,0x38,0x37,0x35,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x5f,0x32,0x32,
0x37,0x20,0x2a,0x20,0x28,0x44,0x69,0x73,0x74,0x72,0x69,0x62,0x75,0x74,0x69,0x6f,
0x37,0x39,0x36,0x38,0x37,0x35,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x5f,0x32,0x33,
0x32,0x20,0x2a,0x20,0x28,0x44,0x69,0x73,0x74,0x72,0x69,0x62,0x75,0x74,0x69,0x6f,
0x6e,0x47,0x47,0x58,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20,0x70,0x61,
0x72,0x61,0x6d,0x5f,0x33,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x29,0x20,
0x2a,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,0x79,0x53,0x6d,0x69,0x74,0x68,0x28,
0x70,0x61,0x72,0x61,0x6d,0x5f,0x35,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x36,
0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x37,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,
0x5f,0x38,0x29,0x29,0x29,0x20,0x2f,0x20,0x76,0x65,0x63,0x33,0x28,0x28,0x28,0x34,
0x2e,0x30,0x20,0x2a,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x38,
0x37,0x2c,0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x29,0x20,
0x2a,0x20,0x5f,0x32,0x36,0x32,0x29,0x20,0x2b,0x20,0x39,0x2e,0x39,0x39,0x39,0x39,
0x2e,0x30,0x20,0x2a,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x39,
0x32,0x2c,0x20,0x5f,0x32,0x30,0x31,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x29,0x20,
0x2a,0x20,0x5f,0x32,0x36,0x37,0x29,0x20,0x2b,0x20,0x39,0x2e,0x39,0x39,0x39,0x39,
0x39,0x39,0x37,0x34,0x37,0x33,0x37,0x38,0x37,0x35,0x31,0x36,0x33,0x35,0x35,0x35,
0x31,0x34,0x35,0x32,0x36,0x33,0x36,0x37,0x31,0x38,0x38,0x65,0x2d,0x30,0x35,0x29,
0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x6c,0x69,0x67,0x68,0x74,0x20,0x3d,0x20,0x5f,0x32,0x39,0x35,0x3b,0x0a,0x20,0x20,
0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x37,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x6c,0x69,0x67,0x68,0x74,0x20,0x3d,0x20,0x5f,0x33,0x30,0x30,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,
0x65,0x63,0x34,0x28,0x5f,0x32,0x39,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
0x7d,0x0a,0x0a,0x00,
0x65,0x63,0x34,0x28,0x5f,0x33,0x30,0x30,0x20,0x2b,0x20,0x28,0x28,0x63,0x6f,0x6c,
0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,
0x28,0x5f,0x31,0x35,0x30,0x20,0x3e,0x3e,0x20,0x31,0x29,0x20,0x26,0x20,0x33,0x29,
0x20,0x2a,0x20,0x30,0x2e,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x34,0x33,0x32,0x36,
0x37,0x34,0x34,0x30,0x37,0x39,0x35,0x38,0x39,0x38,0x34,0x33,0x37,0x35,0x29,0x29,
0x20,0x2a,0x20,0x35,0x2e,0x30,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,
0x0a,0x0a,0x00,
];
/*
#version 300 es
@ -461,7 +466,7 @@ vs_trixel_source_glsl300es := u8.[
highp float time;
};
uniform trixel_world_config _200;
uniform trixel_world_config _205;
in highp vec4 color;
in highp vec4 fnormal;
@ -505,25 +510,25 @@ vs_trixel_source_glsl300es := u8.[
highp float _172 = max(float((_150 >> 5) & 7) * 0.14285714924335479736328125, 0.0500000007450580596923828125);
highp float _178 = float((_150 >> 3) & 3) * 0.3333333432674407958984375;
highp vec3 light = color.xyz * 0.300000011920928955078125;
highp vec3 _187 = normalize(fnormal.xyz);
highp vec3 _196 = normalize(cam - pos.xyz);
highp vec3 _205 = normalize(_200.sunPosition);
highp vec3 _210 = normalize(_196 + _205);
highp float param = max(dot(_210, _196), 0.0);
highp vec3 _192 = normalize(fnormal.xyz);
highp vec3 _201 = normalize(cam - pos.xyz);
highp vec3 _210 = normalize(_205.sunPosition);
highp vec3 _215 = normalize(_201 + _210);
highp float param = max(dot(_215, _201), 0.0);
highp vec3 param_1 = mix(vec3(0.039999999105930328369140625), color.xyz, vec3(_178));
highp vec3 _227 = fresnelSchlick(param, param_1);
highp vec3 param_2 = _187;
highp vec3 param_3 = _210;
highp vec3 _232 = fresnelSchlick(param, param_1);
highp vec3 param_2 = _192;
highp vec3 param_3 = _215;
highp float param_4 = _172;
highp vec3 param_5 = _187;
highp vec3 param_6 = _196;
highp vec3 param_7 = _205;
highp vec3 param_5 = _192;
highp vec3 param_6 = _201;
highp vec3 param_7 = _210;
highp float param_8 = _172;
highp float _262 = max(dot(_187, _205), 0.0);
highp vec3 _294 = light;
highp vec3 _295 = _294 + ((((((vec3(1.0) - _227) * (1.0 - _178)) * color.xyz) * vec3(0.3183410167694091796875)) + ((_227 * (DistributionGGX(param_2, param_3, param_4) * GeometrySmith(param_5, param_6, param_7, param_8))) / vec3(((4.0 * max(dot(_187, _196), 0.0)) * _262) + 9.9999997473787516355514526367188e-05))) * _262);
light = _295;
frag_color = vec4(_295, 1.0);
highp float _267 = max(dot(_192, _210), 0.0);
highp vec3 _299 = light;
highp vec3 _300 = _299 + ((((((vec3(1.0) - _232) * (1.0 - _178)) * color.xyz) * vec3(0.3183410167694091796875)) + ((_232 * (DistributionGGX(param_2, param_3, param_4) * GeometrySmith(param_5, param_6, param_7, param_8))) / vec3(((4.0 * max(dot(_192, _201), 0.0)) * _267) + 9.9999997473787516355514526367188e-05))) * _267);
light = _300;
frag_color = vec4(_300 + ((color.xyz * (float((_150 >> 1) & 3) * 0.3333333432674407958984375)) * 5.0), 1.0);
}
*/
@ -559,7 +564,7 @@ fs_trixel_source_glsl300es := u8.[
0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x20,0x74,0x69,0x6d,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x75,
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f,0x77,0x6f,
0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x20,0x5f,0x32,0x30,0x30,0x3b,
0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x20,0x5f,0x32,0x30,0x35,0x3b,
0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
0x76,0x65,0x63,0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x69,0x6e,
@ -653,56 +658,56 @@ fs_trixel_source_glsl300es := u8.[
0x7a,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,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,
0x31,0x38,0x37,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,
0x31,0x39,0x32,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,
0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x39,
0x36,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x61,
0x6d,0x20,0x2d,0x20,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x30,
0x35,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,
0x30,0x30,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,
0x31,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x61,
0x6d,0x20,0x2d,0x20,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x31,
0x30,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,
0x30,0x35,0x2e,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,
0x5f,0x32,0x31,0x30,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
0x28,0x5f,0x31,0x39,0x36,0x20,0x2b,0x20,0x5f,0x32,0x30,0x35,0x29,0x3b,0x0a,0x20,
0x5f,0x32,0x31,0x35,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
0x28,0x5f,0x32,0x30,0x31,0x20,0x2b,0x20,0x5f,0x32,0x31,0x30,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,
0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,
0x32,0x31,0x30,0x2c,0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,
0x32,0x31,0x35,0x2c,0x20,0x5f,0x32,0x30,0x31,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,
0x3b,0x0a,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,0x6d,0x69,0x78,0x28,0x76,
0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x33,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x31,
0x30,0x35,0x39,0x33,0x30,0x33,0x32,0x38,0x33,0x36,0x39,0x31,0x34,0x30,0x36,0x32,
0x35,0x29,0x2c,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,
0x65,0x63,0x33,0x28,0x5f,0x31,0x37,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x32,0x37,0x20,
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x33,0x32,0x20,
0x3d,0x20,0x66,0x72,0x65,0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,
0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,
0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,
0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x5f,0x31,0x39,0x32,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,
0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x5f,0x32,0x31,0x30,0x3b,0x0a,
0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x5f,0x32,0x31,0x35,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x20,0x3d,0x20,0x5f,0x31,0x37,0x32,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,
0x61,0x72,0x61,0x6d,0x5f,0x35,0x20,0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,0x0a,0x20,
0x61,0x72,0x61,0x6d,0x5f,0x35,0x20,0x3d,0x20,0x5f,0x31,0x39,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,
0x72,0x61,0x6d,0x5f,0x36,0x20,0x3d,0x20,0x5f,0x31,0x39,0x36,0x3b,0x0a,0x20,0x20,
0x72,0x61,0x6d,0x5f,0x36,0x20,0x3d,0x20,0x5f,0x32,0x30,0x31,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,
0x61,0x6d,0x5f,0x37,0x20,0x3d,0x20,0x5f,0x32,0x30,0x35,0x3b,0x0a,0x20,0x20,0x20,
0x61,0x6d,0x5f,0x37,0x20,0x3d,0x20,0x5f,0x32,0x31,0x30,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,
0x61,0x6d,0x5f,0x38,0x20,0x3d,0x20,0x5f,0x31,0x37,0x32,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x36,
0x32,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x38,0x37,
0x2c,0x20,0x5f,0x32,0x30,0x35,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,
0x37,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x39,0x32,
0x2c,0x20,0x5f,0x32,0x31,0x30,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,
0x39,0x34,0x20,0x3d,0x20,0x6c,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x39,0x35,0x20,
0x3d,0x20,0x5f,0x32,0x39,0x34,0x20,0x2b,0x20,0x28,0x28,0x28,0x28,0x28,0x28,0x76,
0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x29,0x20,0x2d,0x20,0x5f,0x32,0x32,0x37,0x29,
0x39,0x39,0x20,0x3d,0x20,0x6c,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x33,0x30,0x30,0x20,
0x3d,0x20,0x5f,0x32,0x39,0x39,0x20,0x2b,0x20,0x28,0x28,0x28,0x28,0x28,0x28,0x76,
0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x29,0x20,0x2d,0x20,0x5f,0x32,0x33,0x32,0x29,
0x20,0x2a,0x20,0x28,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x31,0x37,0x38,0x29,0x29,
0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,
0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x33,0x31,0x38,0x33,0x34,0x31,0x30,0x31,0x36,
0x37,0x36,0x39,0x34,0x30,0x39,0x31,0x37,0x39,0x36,0x38,0x37,0x35,0x29,0x29,0x20,
0x2b,0x20,0x28,0x28,0x5f,0x32,0x32,0x37,0x20,0x2a,0x20,0x28,0x44,0x69,0x73,0x74,
0x2b,0x20,0x28,0x28,0x5f,0x32,0x33,0x32,0x20,0x2a,0x20,0x28,0x44,0x69,0x73,0x74,
0x72,0x69,0x62,0x75,0x74,0x69,0x6f,0x6e,0x47,0x47,0x58,0x28,0x70,0x61,0x72,0x61,
0x6d,0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x2c,0x20,0x70,0x61,
0x72,0x61,0x6d,0x5f,0x34,0x29,0x20,0x2a,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,
@ -710,15 +715,20 @@ fs_trixel_source_glsl300es := u8.[
0x70,0x61,0x72,0x61,0x6d,0x5f,0x36,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x37,
0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x38,0x29,0x29,0x29,0x20,0x2f,0x20,0x76,
0x65,0x63,0x33,0x28,0x28,0x28,0x34,0x2e,0x30,0x20,0x2a,0x20,0x6d,0x61,0x78,0x28,
0x64,0x6f,0x74,0x28,0x5f,0x31,0x38,0x37,0x2c,0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,
0x20,0x30,0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x32,0x29,0x20,0x2b,
0x64,0x6f,0x74,0x28,0x5f,0x31,0x39,0x32,0x2c,0x20,0x5f,0x32,0x30,0x31,0x29,0x2c,
0x20,0x30,0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x37,0x29,0x20,0x2b,
0x20,0x39,0x2e,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x34,0x37,0x33,0x37,0x38,0x37,
0x35,0x31,0x36,0x33,0x35,0x35,0x35,0x31,0x34,0x35,0x32,0x36,0x33,0x36,0x37,0x31,
0x38,0x38,0x65,0x2d,0x30,0x35,0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x32,
0x38,0x38,0x65,0x2d,0x30,0x35,0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x37,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6c,0x69,0x67,0x68,0x74,0x20,0x3d,0x20,0x5f,
0x32,0x39,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x32,0x39,0x35,0x2c,
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
0x33,0x30,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x33,0x30,0x30,0x20,
0x2b,0x20,0x28,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,
0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x28,0x5f,0x31,0x35,0x30,0x20,0x3e,0x3e,0x20,
0x31,0x29,0x20,0x26,0x20,0x33,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33,0x33,0x33,0x33,
0x33,0x33,0x33,0x34,0x33,0x32,0x36,0x37,0x34,0x34,0x30,0x37,0x39,0x35,0x38,0x39,
0x38,0x34,0x33,0x37,0x35,0x29,0x29,0x20,0x2a,0x20,0x35,0x2e,0x30,0x29,0x2c,0x20,
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#include <metal_stdlib>
@ -889,32 +899,32 @@ vs_trixel_source_metal_macos := u8.[
return GeometrySchlickGGX(param_2, param_3) * GeometrySchlickGGX(param, param_1);
}
fragment main0_out main0(main0_in in [[stage_in]], constant trixel_world_config& _200 [[buffer(0)]])
fragment main0_out main0(main0_in in [[stage_in]], constant trixel_world_config& _205 [[buffer(0)]])
{
main0_out out = {};
int _150 = int(round(in.color.w * 255.0));
float _172 = fast::max(float((_150 >> 5) & 7) * 0.14285714924335479736328125, 0.0500000007450580596923828125);
float _178 = float((_150 >> 3) & 3) * 0.3333333432674407958984375;
float3 light = in.color.xyz * 0.300000011920928955078125;
float3 _187 = fast::normalize(in.fnormal.xyz);
float3 _196 = fast::normalize(in.cam - in.pos.xyz);
float3 _205 = fast::normalize(float3(_200.sunPosition));
float3 _210 = fast::normalize(_196 + _205);
float param = fast::max(dot(_210, _196), 0.0);
float3 _192 = fast::normalize(in.fnormal.xyz);
float3 _201 = fast::normalize(in.cam - in.pos.xyz);
float3 _210 = fast::normalize(float3(_205.sunPosition));
float3 _215 = fast::normalize(_201 + _210);
float param = fast::max(dot(_215, _201), 0.0);
float3 param_1 = mix(float3(0.039999999105930328369140625), in.color.xyz, float3(_178));
float3 _227 = fresnelSchlick(param, param_1);
float3 param_2 = _187;
float3 param_3 = _210;
float3 _232 = fresnelSchlick(param, param_1);
float3 param_2 = _192;
float3 param_3 = _215;
float param_4 = _172;
float3 param_5 = _187;
float3 param_6 = _196;
float3 param_7 = _205;
float3 param_5 = _192;
float3 param_6 = _201;
float3 param_7 = _210;
float param_8 = _172;
float _262 = fast::max(dot(_187, _205), 0.0);
float3 _294 = light;
float3 _295 = _294 + ((((((float3(1.0) - _227) * (1.0 - _178)) * in.color.xyz) * float3(0.3183410167694091796875)) + ((_227 * (DistributionGGX(param_2, param_3, param_4) * GeometrySmith(param_5, param_6, param_7, param_8))) / float3(((4.0 * fast::max(dot(_187, _196), 0.0)) * _262) + 9.9999997473787516355514526367188e-05))) * _262);
light = _295;
out.frag_color = float4(_295, 1.0);
float _267 = fast::max(dot(_192, _210), 0.0);
float3 _299 = light;
float3 _300 = _299 + ((((((float3(1.0) - _232) * (1.0 - _178)) * in.color.xyz) * float3(0.3183410167694091796875)) + ((_232 * (DistributionGGX(param_2, param_3, param_4) * GeometrySmith(param_5, param_6, param_7, param_8))) / float3(((4.0 * fast::max(dot(_192, _201), 0.0)) * _267) + 9.9999997473787516355514526367188e-05))) * _267);
light = _300;
out.frag_color = float4(_300 + ((in.color.xyz * (float((_150 >> 1) & 3) * 0.3333333432674407958984375)) * 5.0), 1.0);
return out;
}
@ -1048,7 +1058,7 @@ fs_trixel_source_metal_macos := u8.[
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,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f,
0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x26,0x20,0x5f,0x32,
0x30,0x30,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,
0x30,0x35,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,
0x69,0x6e,0x74,0x20,0x5f,0x31,0x35,0x30,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x72,
@ -1070,56 +1080,56 @@ fs_trixel_source_metal_macos := u8.[
0x2e,0x78,0x79,0x7a,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,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x31,
0x38,0x37,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,
0x39,0x32,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,
0x6c,0x69,0x7a,0x65,0x28,0x69,0x6e,0x2e,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,
0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
0x20,0x5f,0x31,0x39,0x36,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,
0x20,0x5f,0x32,0x30,0x31,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,
0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x69,0x6e,0x2e,0x63,0x61,0x6d,0x20,0x2d,
0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x30,0x35,0x20,0x3d,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x31,0x30,0x20,0x3d,0x20,
0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,
0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x32,0x30,0x30,0x2e,0x73,0x75,0x6e,0x50,
0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x32,0x30,0x35,0x2e,0x73,0x75,0x6e,0x50,
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x31,0x30,0x20,0x3d,0x20,0x66,0x61,0x73,
0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x31,0x39,
0x36,0x20,0x2b,0x20,0x5f,0x32,0x30,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x31,0x35,0x20,0x3d,0x20,0x66,0x61,0x73,
0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x32,0x30,
0x31,0x20,0x2b,0x20,0x5f,0x32,0x31,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x66,0x61,0x73,
0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x32,0x31,0x30,0x2c,
0x20,0x5f,0x31,0x39,0x36,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,
0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x32,0x31,0x35,0x2c,
0x20,0x5f,0x32,0x30,0x31,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,
0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,
0x30,0x33,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x31,0x30,0x35,0x39,0x33,0x30,0x33,
0x32,0x38,0x33,0x36,0x39,0x31,0x34,0x30,0x36,0x32,0x35,0x29,0x2c,0x20,0x69,0x6e,
0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x28,0x5f,0x31,0x37,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x32,0x37,0x20,0x3d,0x20,0x66,0x72,0x65,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x33,0x32,0x20,0x3d,0x20,0x66,0x72,0x65,
0x73,0x6e,0x65,0x6c,0x53,0x63,0x68,0x6c,0x69,0x63,0x6b,0x28,0x70,0x61,0x72,0x61,
0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,
0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x3d,0x20,0x5f,0x31,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x5f,0x32,0x31,
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,
0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,
0x61,0x6d,0x5f,0x34,0x20,0x3d,0x20,0x5f,0x31,0x37,0x32,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x35,0x20,
0x3d,0x20,0x5f,0x31,0x38,0x37,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x36,0x20,0x3d,0x20,0x5f,0x31,0x39,
0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,
0x72,0x61,0x6d,0x5f,0x37,0x20,0x3d,0x20,0x5f,0x32,0x30,0x35,0x3b,0x0a,0x20,0x20,
0x3d,0x20,0x5f,0x31,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x36,0x20,0x3d,0x20,0x5f,0x32,0x30,
0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,
0x72,0x61,0x6d,0x5f,0x37,0x20,0x3d,0x20,0x5f,0x32,0x31,0x30,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x38,0x20,
0x3d,0x20,0x5f,0x31,0x37,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x20,0x5f,0x32,0x36,0x32,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,
0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x38,0x37,0x2c,0x20,0x5f,0x32,0x30,
0x35,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x39,0x34,0x20,0x3d,0x20,0x6c,0x69,0x67,0x68,
0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,
0x39,0x35,0x20,0x3d,0x20,0x5f,0x32,0x39,0x34,0x20,0x2b,0x20,0x28,0x28,0x28,0x28,
0x74,0x20,0x5f,0x32,0x36,0x37,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,
0x61,0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x39,0x32,0x2c,0x20,0x5f,0x32,0x31,
0x30,0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x39,0x39,0x20,0x3d,0x20,0x6c,0x69,0x67,0x68,
0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x33,
0x30,0x30,0x20,0x3d,0x20,0x5f,0x32,0x39,0x39,0x20,0x2b,0x20,0x28,0x28,0x28,0x28,
0x28,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x31,0x2e,0x30,0x29,0x20,0x2d,0x20,
0x5f,0x32,0x32,0x37,0x29,0x20,0x2a,0x20,0x28,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,
0x5f,0x32,0x33,0x32,0x29,0x20,0x2a,0x20,0x28,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,
0x31,0x37,0x38,0x29,0x29,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,
0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,
0x2e,0x33,0x31,0x38,0x33,0x34,0x31,0x30,0x31,0x36,0x37,0x36,0x39,0x34,0x30,0x39,
0x31,0x37,0x39,0x36,0x38,0x37,0x35,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x5f,0x32,
0x32,0x37,0x20,0x2a,0x20,0x28,0x44,0x69,0x73,0x74,0x72,0x69,0x62,0x75,0x74,0x69,
0x33,0x32,0x20,0x2a,0x20,0x28,0x44,0x69,0x73,0x74,0x72,0x69,0x62,0x75,0x74,0x69,
0x6f,0x6e,0x47,0x47,0x58,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20,0x70,
0x61,0x72,0x61,0x6d,0x5f,0x33,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x29,
0x20,0x2a,0x20,0x47,0x65,0x6f,0x6d,0x65,0x74,0x72,0x79,0x53,0x6d,0x69,0x74,0x68,
@ -1127,17 +1137,22 @@ fs_trixel_source_metal_macos := u8.[
0x36,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x37,0x2c,0x20,0x70,0x61,0x72,0x61,
0x6d,0x5f,0x38,0x29,0x29,0x29,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,
0x28,0x28,0x34,0x2e,0x30,0x20,0x2a,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,
0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x38,0x37,0x2c,0x20,0x5f,0x31,0x39,0x36,
0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x32,0x29,
0x78,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x39,0x32,0x2c,0x20,0x5f,0x32,0x30,0x31,
0x29,0x2c,0x20,0x30,0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x36,0x37,0x29,
0x20,0x2b,0x20,0x39,0x2e,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x34,0x37,0x33,0x37,
0x38,0x37,0x35,0x31,0x36,0x33,0x35,0x35,0x35,0x31,0x34,0x35,0x32,0x36,0x33,0x36,
0x37,0x31,0x38,0x38,0x65,0x2d,0x30,0x35,0x29,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,
0x36,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6c,0x69,0x67,0x68,0x74,0x20,0x3d,
0x20,0x5f,0x32,0x39,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,
0x36,0x37,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6c,0x69,0x67,0x68,0x74,0x20,0x3d,
0x20,0x5f,0x33,0x30,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x28,0x5f,0x32,0x39,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
0x0a,0x0a,0x00,
0x74,0x34,0x28,0x5f,0x33,0x30,0x30,0x20,0x2b,0x20,0x28,0x28,0x69,0x6e,0x2e,0x63,
0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x28,0x66,0x6c,0x6f,0x61,
0x74,0x28,0x28,0x5f,0x31,0x35,0x30,0x20,0x3e,0x3e,0x20,0x31,0x29,0x20,0x26,0x20,
0x33,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x34,0x33,
0x32,0x36,0x37,0x34,0x34,0x30,0x37,0x39,0x35,0x38,0x39,0x38,0x34,0x33,0x37,0x35,
0x29,0x29,0x20,0x2a,0x20,0x35,0x2e,0x30,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,
0x0a,0x7d,0x0a,0x0a,0x00,
];
trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc: sg_shader_desc;
@ -1167,49 +1182,49 @@ trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc.uniform_blocks[1].size = 160;
desc.uniform_blocks[1].glsl_uniforms[0].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_200.skyBase";
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_205.skyBase";
desc.uniform_blocks[1].glsl_uniforms[1].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_200.skyTop";
desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_205.skyTop";
desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_200.sunDisk";
desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_205.sunDisk";
desc.uniform_blocks[1].glsl_uniforms[3].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[3].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_200.horizonHalo";
desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_205.horizonHalo";
desc.uniform_blocks[1].glsl_uniforms[4].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[4].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[4].glsl_name = "_200.sunHalo";
desc.uniform_blocks[1].glsl_uniforms[4].glsl_name = "_205.sunHalo";
desc.uniform_blocks[1].glsl_uniforms[5].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[5].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[5].glsl_name = "_200.sunLightColor";
desc.uniform_blocks[1].glsl_uniforms[5].glsl_name = "_205.sunLightColor";
desc.uniform_blocks[1].glsl_uniforms[6].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[6].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[6].glsl_name = "_200.sunPosition";
desc.uniform_blocks[1].glsl_uniforms[6].glsl_name = "_205.sunPosition";
desc.uniform_blocks[1].glsl_uniforms[7].type = .FLOAT;
desc.uniform_blocks[1].glsl_uniforms[7].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[7].glsl_name = "_200.sunIntensity";
desc.uniform_blocks[1].glsl_uniforms[7].glsl_name = "_205.sunIntensity";
desc.uniform_blocks[1].glsl_uniforms[8].type = .FLOAT;
desc.uniform_blocks[1].glsl_uniforms[8].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[8].glsl_name = "_200.skyIntensity";
desc.uniform_blocks[1].glsl_uniforms[8].glsl_name = "_205.skyIntensity";
desc.uniform_blocks[1].glsl_uniforms[9].type = .INT;
desc.uniform_blocks[1].glsl_uniforms[9].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[9].glsl_name = "_200.hasClouds";
desc.uniform_blocks[1].glsl_uniforms[9].glsl_name = "_205.hasClouds";
desc.uniform_blocks[1].glsl_uniforms[10].type = .FLOAT;
desc.uniform_blocks[1].glsl_uniforms[10].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[10].glsl_name = "_200.planeHeight";
desc.uniform_blocks[1].glsl_uniforms[10].glsl_name = "_205.planeHeight";
desc.uniform_blocks[1].glsl_uniforms[11].type = .INT;
desc.uniform_blocks[1].glsl_uniforms[11].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[11].glsl_name = "_200.planeType";
desc.uniform_blocks[1].glsl_uniforms[11].glsl_name = "_205.planeType";
desc.uniform_blocks[1].glsl_uniforms[12].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[12].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[12].glsl_name = "_200.waterColor";
desc.uniform_blocks[1].glsl_uniforms[12].glsl_name = "_205.waterColor";
desc.uniform_blocks[1].glsl_uniforms[13].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[13].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[13].glsl_name = "_200.deepColor";
desc.uniform_blocks[1].glsl_uniforms[13].glsl_name = "_205.deepColor";
desc.uniform_blocks[1].glsl_uniforms[14].type = .FLOAT;
desc.uniform_blocks[1].glsl_uniforms[14].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[14].glsl_name = "_200.time";
desc.uniform_blocks[1].glsl_uniforms[14].glsl_name = "_205.time";
case .GLES3;
desc.vertex_func.source = xx *vs_trixel_source_glsl300es;
desc.vertex_func.entry = "main";
@ -1234,49 +1249,49 @@ trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc.uniform_blocks[1].size = 160;
desc.uniform_blocks[1].glsl_uniforms[0].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_200.skyBase";
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_205.skyBase";
desc.uniform_blocks[1].glsl_uniforms[1].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_200.skyTop";
desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_205.skyTop";
desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_200.sunDisk";
desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_205.sunDisk";
desc.uniform_blocks[1].glsl_uniforms[3].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[3].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_200.horizonHalo";
desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_205.horizonHalo";
desc.uniform_blocks[1].glsl_uniforms[4].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[4].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[4].glsl_name = "_200.sunHalo";
desc.uniform_blocks[1].glsl_uniforms[4].glsl_name = "_205.sunHalo";
desc.uniform_blocks[1].glsl_uniforms[5].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[5].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[5].glsl_name = "_200.sunLightColor";
desc.uniform_blocks[1].glsl_uniforms[5].glsl_name = "_205.sunLightColor";
desc.uniform_blocks[1].glsl_uniforms[6].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[6].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[6].glsl_name = "_200.sunPosition";
desc.uniform_blocks[1].glsl_uniforms[6].glsl_name = "_205.sunPosition";
desc.uniform_blocks[1].glsl_uniforms[7].type = .FLOAT;
desc.uniform_blocks[1].glsl_uniforms[7].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[7].glsl_name = "_200.sunIntensity";
desc.uniform_blocks[1].glsl_uniforms[7].glsl_name = "_205.sunIntensity";
desc.uniform_blocks[1].glsl_uniforms[8].type = .FLOAT;
desc.uniform_blocks[1].glsl_uniforms[8].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[8].glsl_name = "_200.skyIntensity";
desc.uniform_blocks[1].glsl_uniforms[8].glsl_name = "_205.skyIntensity";
desc.uniform_blocks[1].glsl_uniforms[9].type = .INT;
desc.uniform_blocks[1].glsl_uniforms[9].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[9].glsl_name = "_200.hasClouds";
desc.uniform_blocks[1].glsl_uniforms[9].glsl_name = "_205.hasClouds";
desc.uniform_blocks[1].glsl_uniforms[10].type = .FLOAT;
desc.uniform_blocks[1].glsl_uniforms[10].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[10].glsl_name = "_200.planeHeight";
desc.uniform_blocks[1].glsl_uniforms[10].glsl_name = "_205.planeHeight";
desc.uniform_blocks[1].glsl_uniforms[11].type = .INT;
desc.uniform_blocks[1].glsl_uniforms[11].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[11].glsl_name = "_200.planeType";
desc.uniform_blocks[1].glsl_uniforms[11].glsl_name = "_205.planeType";
desc.uniform_blocks[1].glsl_uniforms[12].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[12].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[12].glsl_name = "_200.waterColor";
desc.uniform_blocks[1].glsl_uniforms[12].glsl_name = "_205.waterColor";
desc.uniform_blocks[1].glsl_uniforms[13].type = .FLOAT3;
desc.uniform_blocks[1].glsl_uniforms[13].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[13].glsl_name = "_200.deepColor";
desc.uniform_blocks[1].glsl_uniforms[13].glsl_name = "_205.deepColor";
desc.uniform_blocks[1].glsl_uniforms[14].type = .FLOAT;
desc.uniform_blocks[1].glsl_uniforms[14].array_count = 0;
desc.uniform_blocks[1].glsl_uniforms[14].glsl_name = "_200.time";
desc.uniform_blocks[1].glsl_uniforms[14].glsl_name = "_205.time";
case .METAL_MACOS;
desc.vertex_func.source = xx *vs_trixel_source_metal_macos;
desc.vertex_func.entry = "main0";

View File

@ -68,6 +68,12 @@ layout(binding=3) uniform trile_fs_params {
int is_reflection;
int screen_h;
int screen_w;
int rdm_enabled;
float ambient_intensity;
float emissive_scale;
float rdm_diff_scale;
float rdm_spec_scale;
vec3 ambient_color;
};
layout(binding = 0) uniform texture2D triletex;
@ -504,29 +510,32 @@ void main() {
vec4 atlas_rect_check = rdm_get_atlas_rect(local, roughnessInt);
float ssao_sample = texture(sampler2D(ssaotex, trilesmp), vec2(gl_FragCoord.x / float(screen_w), gl_FragCoord.y / float(screen_h)), 0).r;
if (atlas_rect_check.z > 0.0) {
// Emissive — self-lit, not shadowed.
vec3 emissive = albedo * emittance * emissive_scale;
if (rdm_enabled == 1 && atlas_rect_check.z > 0.0) {
vec3 Frough = FresnelSchlickRoughness(max(dot(N, V), 0.0), F0, roughness);
// Indirect specular
vec3 indirectSpec = sample_rdm(N, -cv,
hemispherePos, vpos - hemispherePos, roughnessInt, local);
vec2 envBRDF = texture(sampler2D(brdf_lut, rdmsmp), vec2(max(dot(N, V), 0.0), roughness)).rg;
light += indirectSpec * (Frough * envBRDF.x + envBRDF.y);
light += indirectSpec * (Frough * envBRDF.x + envBRDF.y) * rdm_spec_scale;
// Indirect diffuse (interpolated from neighbor probes)
vec3 indirectDiff = sample_rdm_diff(N, vpos - hemispherePos, local);
vec3 kDiff = 1.0 - Frough;
kDiff *= 1.0 - metallic;
light += (kDiff * indirectDiff / PI * albedo) * ssao_sample;
light += (kDiff * indirectDiff / PI * albedo) * ssao_sample * rdm_diff_scale;
} else {
// Fallback: ambient + sky reflection when no RDM data
light += 0.35 * albedo * ssao_sample;
// Fallback: ambient + sky reflection when no RDM data (or RDM disabled).
light += ambient_color * ambient_intensity * albedo * ssao_sample;
vec3 R = reflect(-V, N);
if (R.y < 0.0) R = reflect(R, vec3(0.0, 1.0, 0.0));
light += F * sky(R, sunPosition) * 0.1;
}
frag_color = vec4(mix(deepColor, light, smoothstep(0.0, planeHeight, vpos.y)), 1.0);
frag_color = vec4(mix(deepColor, light + emissive, smoothstep(0.0, planeHeight, vpos.y)), 1.0);
}
@end

View File

@ -101,8 +101,8 @@ void main() {
// Ambient light.
vec3 light = 0.3 * albedo;
// // Make emitting things look bright.
// if(emittance > 0.01) return vec4(albedo, 1.0);
// Emissive — applied after lighting so emissive surfaces glow.
vec3 emissive = albedo * emittance * 5.0;
vec3 N = normalize(fnormal.xyz);
vec3 V = normalize(cam - pos.xyz);
@ -123,7 +123,7 @@ void main() {
light += (kD * albedo / PI + specular) * NdotL * vec3(1.0, 1.0, 1.0);
frag_color = vec4(vec3(light), 1.0);
frag_color = vec4(light + emissive, 1.0);
}
@end

View File

@ -5,8 +5,12 @@ get_apollo_time :: () -> Apollo_Time {
// since this could make a delta time negative and that would be bad.
return current_time_monotonic();
} else {
// Implement a WASM Apollo_Time backend here.
#assert false;
// stm_now() returns uint64 nanoseconds since sokol time init.
// Apollo_Time is S128 nanoseconds; we fill only the low word since
// the elapsed time will never overflow 64 bits.
result: Apollo_Time;
result.low = stm_now();
return result;
}
}

View File

@ -115,8 +115,16 @@ lworld :: (name: string) {
unload_current_world :: () {
if current_world.valid {
// Free chunk data.
rdm_loader_cancel_all();
for *chunk: current_world.world.chunks {
// Release RDM GPU resources.
if chunk.rdm_valid {
sg_destroy_image(chunk.rdm_atlas);
sg_destroy_image(chunk.rdm_lookup);
chunk.rdm_atlas = .{};
chunk.rdm_lookup = .{};
chunk.rdm_valid = false;
}
for *group: chunk.groups {
array_free(group.instances);
}
@ -134,7 +142,7 @@ set_loaded_world :: (world: World) {
unload_current_world();
current_world.world = world;
current_world.valid = true;
#if HAS_TACOMA { rdm_load_from_disk(); }
// RDM loading is kicked off by the asset manager after calling this.
}
clear_world :: () {