cleanup
This commit is contained in:
parent
28a4c44478
commit
897fbeea4b
4
build.sh
4
build.sh
@ -1,8 +1,4 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd src/shaders/
|
||||
./compile_shaders.sh
|
||||
cd ..
|
||||
cd ..
|
||||
jai -x64 first.jai
|
||||
./first
|
||||
|
||||
@ -124,8 +124,7 @@ beachgame/
|
||||
│ │ ├── helpers.jai create_world_rendering_tasks(), uniform helpers
|
||||
│ │ ├── arbtri.jai Immediate-mode triangle batch renderer (UI)
|
||||
│ │ ├── post_processing.jai Post-process config, LUT management
|
||||
│ │ ├── sky.jai Sky rendering helpers
|
||||
│ │ └── ssao.jai SSAO kernel/noise generation
|
||||
│ │ └── sky.jai Sky rendering helpers
|
||||
│ │
|
||||
│ ├── editor/
|
||||
│ │ ├── editor.jai Editor root: three views, F3 toggle
|
||||
@ -249,10 +248,8 @@ Sokol GFX draw calls
|
||||
| Setup | GPU position/uniform buffers | Uploads trile instance stream data |
|
||||
| Shadow | 1000×1000 depth texture | Orthographic sun directional light; PCF soft edges (Gaussian-weighted sampling) |
|
||||
| Reflection | Half-res RGBA32F texture | Planar water reflection: camera Y-flipped around water plane; handles dynamic objects that RDMs cannot |
|
||||
| G-Buffer | Position + Normal RGBA16F | Used by SSAO and deferred effects |
|
||||
| SSAO | Single-channel AO texture | Random sample kernel, 64 samples |
|
||||
| SSAO Blur | Blurred AO texture | Separable blur |
|
||||
| Main | RGBA32F HDR target | Forward render: sun direct + RDM indirect (specular + diffuse) + SSAO |
|
||||
| G-Buffer | Position + Normal RGBA16F | Used by SH irradiance and deferred effects |
|
||||
| Main | RGBA32F HDR target | Forward render: albedo-first trile shading with trixel AO and sky fog; RDM triles keep PBR |
|
||||
| Post chain | Bloom → DoF ping-pong | Between postprocess_a / postprocess_b |
|
||||
| Final | Swapchain | Tonemap, LUT grade, vignette, grain |
|
||||
|
||||
@ -371,12 +368,31 @@ handles dynamic objects (players, ball) that do not appear in the static RDMs, a
|
||||
sharp mirror-like reflections correct for large flat surfaces. Post-processing can add ripple
|
||||
distortion to the reflection texture.
|
||||
|
||||
#### SSAO
|
||||
#### Trixel AO
|
||||
|
||||
Screen-space ambient occlusion darkens cavities and contact areas. A geometry pass outputs
|
||||
world-space position and normal (RGBA16F G-buffer), then the SSAO pass samples 64 random
|
||||
offsets to estimate local occlusion. The result is blurred with a separable filter and applied to
|
||||
the ambient/diffuse contribution.
|
||||
Ambient occlusion is worked out per pixel in the trile shaders, voxel style, from the trile's
|
||||
16³ trixel grid: each corner of a trixel face is darkened by the trixels in front of it, and the
|
||||
four corners are blended across the face. It darkens all of a face's lighting, squared for crisp
|
||||
edges and scaled by `trixel_ao_strength` in the lighting config.
|
||||
|
||||
To carry across trile boundaries, every instance knows which of its 26 surrounding cells hold an
|
||||
opaque trile (`Chunk_Trile_Group.neighbours`, computed alongside `is_buried`). Those cells count
|
||||
as solid throughout. The mask is in the trile's own unrotated frame and is packed together with
|
||||
the orientation into the instance's `w` (`trile_instance_w`), so every shader that reads the
|
||||
orientation decodes it first.
|
||||
|
||||
#### Trile shading
|
||||
|
||||
Opaque triles are shaded albedo-first, after Fez: a sunlit face shows its colour, a shaded face
|
||||
that colour times `shadow_tint`, slightly more saturated. Top, x sides, z sides and bottom each
|
||||
get a fixed brightness (`face_shade_*`). Trixel colours are converted from sRGB to linear before
|
||||
lighting. Specular only appears on smooth materials: roughness 0..7 is read as gloss
|
||||
`1 - roughness/7`, so roughness 7 never shines. Fog takes the sky colour in the view direction,
|
||||
climbs to `fog_max` between `fog_start` and `fog_end`, then to fully fogged by the LOD cull
|
||||
distance so nothing pops. All of it lives in `Lighting_Config`, saved to
|
||||
`game_core/lighting.json` next to `postprocess.json`; `lighting_debug` shows colour × face shade
|
||||
(1), AO (2) or light only (3). Post adds `tonemap = 2`, a hue-preserving soft clip, and applies
|
||||
LUTs after gamma encoding.
|
||||
|
||||
#### Pre-bake pipeline
|
||||
|
||||
|
||||
29
first.jai
29
first.jai
@ -8,7 +8,6 @@ Trueno_Build_Options :: struct {
|
||||
release_build : bool;
|
||||
tacoma_enabled : bool;
|
||||
iprof_enabled : bool;
|
||||
demo_build : bool;
|
||||
test_engine : bool;
|
||||
test_game : bool;
|
||||
test_exe_engine : bool;
|
||||
@ -35,8 +34,6 @@ build_options_from_args :: (args: []string) -> Trueno_Build_Options {
|
||||
opts.release_build = true;
|
||||
case "iprof";
|
||||
opts.iprof_enabled = true;
|
||||
case "demo";
|
||||
opts.demo_build = true;
|
||||
case "test";
|
||||
opts.test_game = true;
|
||||
opts.test_engine = true;
|
||||
@ -77,20 +74,16 @@ add_asset_buffer_sizes_to_compiler_strings :: (trueno_opts: Trueno_Build_Options
|
||||
pack_dir := ifx use_test_game then "./test_packs" else "./packs";
|
||||
game_resources_dir := ifx use_test_game then "./test_game/resources" else "./game/resources";
|
||||
|
||||
sizes: [6]s64;
|
||||
sizes: [3]s64;
|
||||
sizes[0] = max_asset_file_size(pack_dir, ".pack", 1 * 1024 * 1024);
|
||||
sizes[1] = max(
|
||||
max_asset_file_size(game_resources_dir, "world.json", 64 * 1024),
|
||||
max_asset_file_size(game_resources_dir, "index.world", 64 * 1024)
|
||||
);
|
||||
sizes[2] = max_asset_file_size(game_resources_dir, "chunks.bin", 1 * 1024 * 1024);
|
||||
sizes[3] = max_asset_file_size(game_resources_dir, ".shgrid", 1 * 1024 * 1024);
|
||||
sizes[4] = max_asset_file_size(game_resources_dir, "rdm_atlas.rdm", 16 * 1024 * 1024);
|
||||
sizes[5] = max_asset_file_size(game_resources_dir, "rdm_manifest.json", 256 * 1024);
|
||||
|
||||
names :: string.["MAX_PACK_SIZE", "MAX_WORLD_SIZE", "MAX_CHUNKS_SIZE",
|
||||
"MAX_SHGRID_SIZE", "MAX_RDM_ATLAS_SIZE", "MAX_RDM_MANIFEST_SIZE"];
|
||||
for i: 0..5 {
|
||||
names :: string.["MAX_PACK_SIZE", "MAX_WORLD_SIZE", "MAX_CHUNKS_SIZE"];
|
||||
for i: 0..2 {
|
||||
add_build_string(tprint("% :: %;\n", names[i], sizes[i]), w);
|
||||
}
|
||||
}
|
||||
@ -110,17 +103,6 @@ add_trueno_opts_to_compiler_strings :: (trueno_opts : Trueno_Build_Options, w: W
|
||||
}
|
||||
}
|
||||
|
||||
compile_shaders :: () {
|
||||
process_result, output, error := run_command("bash", ifx OS == .MACOS then "./compile_shaders_mac.sh" else "./compile_shaders.sh", working_directory=tprint("%/src/shaders", #filepath));
|
||||
if process_result.exit_code != 0 {
|
||||
log_error("Shader compilation failed.");
|
||||
if output {
|
||||
log_error(output,, logger = runtime_support_default_logger);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
wasm_copy_assets :: () {
|
||||
if is_directory("./packs") {
|
||||
run_command("cp", "-r", "./packs", "./dist/", working_directory=tprint("%", #filepath));
|
||||
@ -178,7 +160,6 @@ native_build :: (opts: Build_Options, trueno_opts: Trueno_Build_Options) {
|
||||
add_trueno_opts_to_compiler_strings(trueno_opts, w);
|
||||
add_asset_buffer_sizes_to_compiler_strings(trueno_opts, w);
|
||||
add_build_file("src/platform_specific/main_native.jai", w);
|
||||
add_shaders_to_workspace(w);
|
||||
|
||||
metaprogramming_loop(trueno_opts, *w, iprof_plugin);
|
||||
|
||||
@ -230,13 +211,12 @@ wasm_build :: (opts: Build_Options, trueno_opts: Trueno_Build_Options) {
|
||||
add_trueno_opts_to_compiler_strings(trueno_opts, w);
|
||||
add_asset_buffer_sizes_to_compiler_strings(trueno_opts, w);
|
||||
add_build_file("src/platform_specific/main_web.jai", w);
|
||||
add_shaders_to_workspace(w);
|
||||
|
||||
metaprogramming_loop(trueno_opts, *w);
|
||||
|
||||
args := string.[
|
||||
"emcc",
|
||||
"src/platform_specific/main.c", "dist/main.o", "modules/sokol-jai/sokol/gfx/sokol_gfx_wasm_gl_release.a", "modules/sokol-jai/sokol/log/sokol_log_wasm_gl_release.a", "modules/sokol-jai/sokol/audio/sokol_audio_wasm_gl_release.a", "modules/sokol-jai/sokol/time/sokol_time_wasm_gl_release.a", "modules/sokol-jai/sokol/app/sokol_app_wasm_gl_release.a", "modules/sokol-jai/sokol/glue/sokol_glue_wasm_gl_release.a", "modules/sokol-jai/sokol/fetch/sokol_fetch_wasm_gl_release.a", "modules/sokol-jai/sokol/gl/sokol_gl_wasm_gl_release.a", "modules/sokol-jai/sokol/fontstash/sokol_fontstash_wasm_gl_release.a",
|
||||
"src/platform_specific/main.c", "dist/main.o", "modules/sokol-jai/sokol/gfx/sokol_gfx_wasm_gl_release.a", "modules/sokol-jai/sokol/log/sokol_log_wasm_gl_release.a", "modules/sokol-jai/sokol/audio/sokol_audio_wasm_gl_release.a", "modules/sokol-jai/sokol/time/sokol_time_wasm_gl_release.a", "modules/sokol-jai/sokol/app/sokol_app_wasm_gl_release.a", "modules/sokol-jai/sokol/glue/sokol_glue_wasm_gl_release.a", "modules/sokol-jai/sokol/fetch/sokol_fetch_wasm_gl_release.a", "modules/Fontstash/wasm/fontstash.a",
|
||||
"modules/sokol-jai/sokol/stbi/stb_image.a",
|
||||
"modules/sokol-jai/sokol/stbv/stb_vorbis.a",
|
||||
"-o", "dist/index.html",
|
||||
@ -262,7 +242,6 @@ wasm_build :: (opts: Build_Options, trueno_opts: Trueno_Build_Options) {
|
||||
#run {
|
||||
opt := get_build_options();
|
||||
trueno_opts := build_options_from_args(opt.compile_time_command_line);
|
||||
compile_shaders();
|
||||
use_test_game := uses_test_game(trueno_opts);
|
||||
create_pack(use_test_game, ifx use_test_game then "./test_packs" else "./packs");
|
||||
|
||||
|
||||
13
modules/Fontstash/build.sh
Executable file
13
modules/Fontstash/build.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
# Builds fontstash (with stb_truetype) as a plain static library, without the
|
||||
# sokol glue the sokol-jai version comes with. Run on each platform:
|
||||
# ./build.sh linux | macos | wasm
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
case "$1" in
|
||||
linux) cc -c -O2 -fPIC source/fontstash.c -o fontstash.o && mkdir -p linux && ar rcs linux/fontstash.a fontstash.o ;;
|
||||
macos) cc -c -O2 -arch arm64 -arch x86_64 source/fontstash.c -o fontstash.o && mkdir -p macos && ar rcs macos/fontstash.a fontstash.o ;;
|
||||
wasm) emcc -c -O2 -sMEMORY64 source/fontstash.c -o fontstash.o && mkdir -p wasm && emar rcs wasm/fontstash.a fontstash.o ;;
|
||||
*) echo "usage: $0 linux|macos|wasm"; exit 1 ;;
|
||||
esac
|
||||
rm fontstash.o
|
||||
BIN
modules/Fontstash/linux/fontstash.a
Normal file
BIN
modules/Fontstash/linux/fontstash.a
Normal file
Binary file not shown.
43
modules/Fontstash/module.jai
Normal file
43
modules/Fontstash/module.jai
Normal file
@ -0,0 +1,43 @@
|
||||
// Fontstash with stb_truetype, as a plain C library: no rendering backend,
|
||||
// glyphs reach the caller through FONSparams' render callbacks. Only the parts
|
||||
// the engine uses are bound. Libraries are built with build.sh.
|
||||
|
||||
FONScontext :: struct {}
|
||||
|
||||
FONS_ZERO_TOPLEFT :: 1;
|
||||
|
||||
FONSparams :: struct {
|
||||
width, height : s32;
|
||||
flags : u8;
|
||||
userPtr : *void;
|
||||
renderCreate : (uptr: *void, width: s32, height: s32) -> s32 #c_call;
|
||||
renderResize : (uptr: *void, width: s32, height: s32) -> s32 #c_call;
|
||||
renderUpdate : (uptr: *void, rect: *s32, data: *u8) #c_call;
|
||||
renderDraw : (uptr: *void, verts: *float, tcoords: *float, colors: *u32, nverts: s32) #c_call;
|
||||
renderDelete : (uptr: *void) #c_call;
|
||||
}
|
||||
|
||||
fonsCreateInternal :: (params: *FONSparams) -> *FONScontext #foreign fontstash;
|
||||
fonsResetAtlas :: (s: *FONScontext, width: s32, height: s32) -> s32 #foreign fontstash;
|
||||
fonsAddFontMem :: (s: *FONScontext, name: *u8, data: *u8, ndata: s32, free_data: s32) -> s32 #foreign fontstash;
|
||||
fonsClearState :: (s: *FONScontext) #foreign fontstash;
|
||||
fonsSetSize :: (s: *FONScontext, size: float) #foreign fontstash;
|
||||
fonsSetColor :: (s: *FONScontext, color: u32) #foreign fontstash;
|
||||
fonsSetFont :: (s: *FONScontext, font: s32) #foreign fontstash;
|
||||
fonsDrawText :: (s: *FONScontext, x: float, y: float, str: *u8, end: *u8) -> float #foreign fontstash;
|
||||
fonsTextBounds :: (s: *FONScontext, x: float, y: float, str: *u8, end: *u8, bounds: *float) -> float #foreign fontstash;
|
||||
fonsVertMetrics :: (s: *FONScontext, ascender: *float, descender: *float, line_height: *float) #foreign fontstash;
|
||||
fonsGetTextureData :: (s: *FONScontext, width: *s32, height: *s32) -> *u8 #foreign fontstash;
|
||||
|
||||
#scope_file
|
||||
|
||||
#if OS == .LINUX {
|
||||
fontstash :: #library,no_dll "linux/fontstash";
|
||||
#library,system,link_always "libm";
|
||||
} else #if OS == .MACOS {
|
||||
fontstash :: #library,no_dll "macos/fontstash";
|
||||
} else #if OS == .WASM {
|
||||
fontstash :: #library,no_dll "wasm/fontstash";
|
||||
} else {
|
||||
#assert false "Fontstash has no library for this OS; see build.sh.";
|
||||
}
|
||||
4
modules/Fontstash/source/fontstash.c
Normal file
4
modules/Fontstash/source/fontstash.c
Normal file
@ -0,0 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define FONTSTASH_IMPLEMENTATION
|
||||
#include "fontstash.h"
|
||||
1714
modules/Fontstash/source/fontstash.h
Normal file
1714
modules/Fontstash/source/fontstash.h
Normal file
File diff suppressed because it is too large
Load Diff
4548
modules/Fontstash/source/stb_truetype.h
Normal file
4548
modules/Fontstash/source/stb_truetype.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
master_volume 0
|
||||
master_volume 0.205032
|
||||
music_volume 1
|
||||
sfx_volume 1
|
||||
fullscreen 0
|
||||
|
||||
@ -6,8 +6,7 @@ Pool :: #import "Pool";
|
||||
|
||||
#load "loaders.jai";
|
||||
|
||||
// MAX_PACK_SIZE, MAX_WORLD_SIZE, MAX_CHUNKS_SIZE, MAX_SHGRID_SIZE,
|
||||
// MAX_RDM_ATLAS_SIZE, MAX_RDM_MANIFEST_SIZE are injected as build strings
|
||||
// MAX_PACK_SIZE, MAX_WORLD_SIZE and MAX_CHUNKS_SIZE are injected as build strings
|
||||
// by first.jai after scanning the actual asset files at compile time.
|
||||
|
||||
MAX_FETCH_SLOTS :: 16;
|
||||
@ -25,9 +24,6 @@ Fetch_Type :: enum {
|
||||
PACK;
|
||||
WORLD;
|
||||
WORLD_CHUNKS;
|
||||
RDM_ATLAS;
|
||||
RDM_MANIFEST;
|
||||
SHGRID;
|
||||
}
|
||||
|
||||
Fetch_Request :: struct {
|
||||
@ -38,9 +34,8 @@ Fetch_Request :: struct {
|
||||
// PACK
|
||||
pack_name : string;
|
||||
|
||||
// WORLD / RDM / SH
|
||||
// WORLD
|
||||
world_name : string;
|
||||
chunk_key : Chunk_Key;
|
||||
|
||||
// WORLD_CHUNKS: JSON carried forward from the WORLD fetch
|
||||
world_json_data : []u8;
|
||||
@ -66,17 +61,11 @@ g_asset_manager : Asset_Manager;
|
||||
|
||||
#scope_file
|
||||
|
||||
#load "rdm_loader.jai";
|
||||
#load "sh_loader.jai";
|
||||
|
||||
fetch_type_buffer_size :: (type: Fetch_Type) -> s64 {
|
||||
if #complete type == {
|
||||
case .PACK; return MAX_PACK_SIZE;
|
||||
case .WORLD; return MAX_WORLD_SIZE;
|
||||
case .WORLD_CHUNKS; return MAX_CHUNKS_SIZE;
|
||||
case .RDM_ATLAS; return MAX_RDM_ATLAS_SIZE;
|
||||
case .RDM_MANIFEST; return MAX_RDM_MANIFEST_SIZE;
|
||||
case .SHGRID; return MAX_SHGRID_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,15 +125,6 @@ handle_fetch_failed :: (req: *Fetch_Request) {
|
||||
free(req.world_json_data.data);
|
||||
log_error("Failed to load chunks.bin for world '%'", req.world_name);
|
||||
|
||||
case .RDM_ATLAS;
|
||||
log_info("RDM: no global atlas for world '%' (ok if none baked yet)", req.world_name);
|
||||
|
||||
case .RDM_MANIFEST;
|
||||
log_info("RDM: no manifest for world '%' (ok if none baked yet)", req.world_name);
|
||||
|
||||
case .SHGRID;
|
||||
sh_loader_handle_failed(req);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,61 +169,11 @@ process_completed_fetch :: (req: *Fetch_Request, data: []u8) {
|
||||
world, ok := load_world_from_json(json_str, data);
|
||||
if ok {
|
||||
set_loaded_world(world);
|
||||
rdm_loader_enqueue_world(*get_current_world().world);
|
||||
shgrid_loader_enqueue_world(*get_current_world().world);
|
||||
log_info("Loaded world: %", req.world_name);
|
||||
} else {
|
||||
log_error("Failed to parse world '%'", req.world_name);
|
||||
}
|
||||
|
||||
case .RDM_ATLAS;
|
||||
curworld := get_current_world();
|
||||
if !curworld.valid || curworld.world.name != req.world_name then return;
|
||||
|
||||
header_size := cast(s64) size_of(RDM_File_Header);
|
||||
if data.count < header_size {
|
||||
log_error("RDM: global atlas too small (world %)", req.world_name);
|
||||
return;
|
||||
}
|
||||
header := cast(*RDM_File_Header) data.data;
|
||||
if header.magic != RDM_FILE_MAGIC {
|
||||
log_error("RDM: bad atlas magic (world %)", req.world_name);
|
||||
return;
|
||||
}
|
||||
atlas_pixel_bytes := cast(u64) header.width * cast(u64) header.height * 4 * size_of(u16);
|
||||
atlas_imgdata: sg_image_data;
|
||||
atlas_imgdata.subimage[0][0] = .{ data.data + header_size, atlas_pixel_bytes };
|
||||
atlas_desc: sg_image_desc = .{
|
||||
render_target = false,
|
||||
width = header.width,
|
||||
height = header.height,
|
||||
pixel_format = sg_pixel_format.RGBA16F,
|
||||
sample_count = 1,
|
||||
data = atlas_imgdata,
|
||||
};
|
||||
if g_rdm_atlas.id != 0 then sg_destroy_image(g_rdm_atlas);
|
||||
g_rdm_atlas = sg_make_image(*atlas_desc);
|
||||
log_debug("RDM: loaded global atlas (%x%)", header.width, header.height);
|
||||
|
||||
case .RDM_MANIFEST;
|
||||
curworld := get_current_world();
|
||||
if !curworld.valid || curworld.world.name != req.world_name then return;
|
||||
|
||||
json_str : string;
|
||||
json_str.data = data.data;
|
||||
json_str.count = data.count;
|
||||
ok, entries := Jaison.json_parse_string(json_str, [..]Rdm_Atlas_Entry,, temp);
|
||||
if !ok {
|
||||
log_error("RDM: failed to parse manifest for world '%'", req.world_name);
|
||||
return;
|
||||
}
|
||||
array_reset_keeping_memory(*curworld.world.rdm_lookup);
|
||||
for e: entries array_add(*curworld.world.rdm_lookup, e);
|
||||
log_debug("RDM: loaded manifest (% entries)", entries.count);
|
||||
|
||||
case .SHGRID;
|
||||
sh_loader_handle_completed(req, data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,7 +182,7 @@ Loaded_Pack :: struct {
|
||||
nameHash : u32 = 0;
|
||||
data_buffer : []u8;
|
||||
content : Load_Package;
|
||||
textures : Table(string, sg_image);
|
||||
textures : Table(string, Texture);
|
||||
animations : Table(string, Animation);
|
||||
audio : Table(string, Audio_Data);
|
||||
pool : Pool.Pool;
|
||||
@ -263,7 +193,7 @@ add_resources_from_pack :: (pack: *Loaded_Pack) {
|
||||
|
||||
Queued_Sheet_File :: struct {
|
||||
name : string;
|
||||
image : sg_image;
|
||||
image : Texture;
|
||||
sheet_w : s32;
|
||||
sheet_h : s32;
|
||||
sheet : Aseprite_Sheet;
|
||||
@ -300,9 +230,6 @@ add_resources_from_pack :: (pack: *Loaded_Pack) {
|
||||
} else {
|
||||
queuedSheet.sheet = sheet;
|
||||
}
|
||||
case "colorgrade.png";
|
||||
img, x, y := create_texture_from_memory(v.data);
|
||||
add_image_to_lut_list(img, v.name);
|
||||
case "wav";
|
||||
audio := load_wav_from_memory(v.data);
|
||||
table_set(*pack.audio, name, audio);
|
||||
@ -421,7 +348,7 @@ dispatch_slots :: () {
|
||||
#scope_export
|
||||
|
||||
free_resources_from_pack :: (pack: *Loaded_Pack) {
|
||||
for pack.textures sg_destroy_image(it);
|
||||
for pack.textures texture_destroy(it);
|
||||
table_reset(*pack.textures);
|
||||
table_reset(*pack.audio);
|
||||
table_reset(*pack.animations);
|
||||
@ -499,9 +426,9 @@ load_pack :: (name: string, priority: Load_Priority = .LOADING_SCREEN) {
|
||||
#scope_file
|
||||
#scope_export
|
||||
|
||||
get_texture_from_pack :: (pack: string, path: string) -> (sg_image) {
|
||||
get_texture_from_pack :: (pack: string, path: string) -> (Texture) {
|
||||
found, pack := find_pack_by_name(pack);
|
||||
invalid_img : sg_image;
|
||||
invalid_img : Texture;
|
||||
|
||||
if !found {
|
||||
return invalid_img;
|
||||
@ -539,7 +466,16 @@ add_font_from_pack :: (pack: string, path: string) {
|
||||
log_error("Failed to find font % from pack", path);
|
||||
return;
|
||||
}
|
||||
state.font_default.fons_font = fonsAddFontMem(state.fons, "sans", entry.data.data, xx entry.data.count, 0);
|
||||
state.font_default.face = font_face_add("sans", entry.data);
|
||||
}
|
||||
|
||||
// For files that may legitimately be absent from a pack.
|
||||
get_raw_file_from_pack :: (pack: string, path: string) -> ([]u8, found: bool) {
|
||||
pack_ok, loaded := find_pack_by_name(pack);
|
||||
if !pack_ok return .[], false;
|
||||
ok, entry := table_find(*loaded.content.lookup, path);
|
||||
if !ok return .[], false;
|
||||
return entry.data, true;
|
||||
}
|
||||
|
||||
load_string_from_pack :: (pack: string, path: string) -> string {
|
||||
|
||||
@ -1,26 +1,9 @@
|
||||
create_texture_from_memory :: (data: []u8) -> (sg_image, s32, s32) {
|
||||
create_texture_from_memory :: (data: []u8) -> (Texture, s32, s32) {
|
||||
x, y, channels : s32;
|
||||
image := stbi.stbi_load_from_memory(data.data, xx data.count, *x, *y, *channels, 4);
|
||||
|
||||
subimg : [6][16]sg_range;
|
||||
subimg[0][0] = .{
|
||||
ptr = image,
|
||||
size = xx (x * y * 4)
|
||||
};
|
||||
|
||||
img := sg_alloc_image();
|
||||
|
||||
sg_init_image(img, *(sg_image_desc.{
|
||||
width = x,
|
||||
height = y,
|
||||
pixel_format = sg_pixel_format.RGBA8,
|
||||
data = .{
|
||||
subimage = subimg
|
||||
}
|
||||
}));
|
||||
|
||||
texture := texture_create(x, y, .{x * y * 4, image});
|
||||
stbi.stbi_image_free(image);
|
||||
return img, x, y;
|
||||
return texture, x, y;
|
||||
}
|
||||
|
||||
create_string_from_memory :: (data: []u8) -> string {
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
// RDM streaming helpers.
|
||||
// The unified fetch queue lives in asset_manager.jai; these functions
|
||||
// enqueue and cancel the world-level global RDM atlas + manifest.
|
||||
|
||||
#scope_export
|
||||
|
||||
rdm_loader_enqueue_world :: (world: *World) {
|
||||
already_atlas := false;
|
||||
already_manifest := false;
|
||||
|
||||
for g_asset_manager.slots {
|
||||
if !it.occupied continue;
|
||||
if it.req.world_name != world.name continue;
|
||||
if it.req.type == .RDM_ATLAS then already_atlas = true;
|
||||
if it.req.type == .RDM_MANIFEST then already_manifest = true;
|
||||
}
|
||||
for g_asset_manager.queue {
|
||||
if it.world_name != world.name continue;
|
||||
if it.type == .RDM_ATLAS then already_atlas = true;
|
||||
if it.type == .RDM_MANIFEST then already_manifest = true;
|
||||
}
|
||||
|
||||
if !already_atlas {
|
||||
req : Fetch_Request;
|
||||
req.type = .RDM_ATLAS;
|
||||
req.priority = .LOADING_SCREEN;
|
||||
req.world_name = world.name;
|
||||
req.path = rdm_global_atlas_filename(world.name);
|
||||
array_add(*g_asset_manager.queue, req);
|
||||
}
|
||||
if !already_manifest {
|
||||
req : Fetch_Request;
|
||||
req.type = .RDM_MANIFEST;
|
||||
req.priority = .LOADING_SCREEN;
|
||||
req.world_name = world.name;
|
||||
req.path = rdm_global_manifest_filename(world.name);
|
||||
array_add(*g_asset_manager.queue, req);
|
||||
}
|
||||
}
|
||||
|
||||
// Drain all pending RDM work.
|
||||
rdm_loader_cancel_all :: () {
|
||||
new_count := 0;
|
||||
for i: 0..g_asset_manager.queue.count - 1 {
|
||||
item := g_asset_manager.queue[i];
|
||||
if item.type != .RDM_ATLAS && item.type != .RDM_MANIFEST {
|
||||
g_asset_manager.queue[new_count] = item;
|
||||
new_count += 1;
|
||||
}
|
||||
}
|
||||
g_asset_manager.queue.count = new_count;
|
||||
|
||||
for *slot: g_asset_manager.slots {
|
||||
if !slot.occupied then continue;
|
||||
if slot.req.type != .RDM_ATLAS && slot.req.type != .RDM_MANIFEST then continue;
|
||||
slot.req.world_name = "";
|
||||
}
|
||||
}
|
||||
@ -1,119 +0,0 @@
|
||||
// SH probe grid streaming helpers.
|
||||
// The unified fetch queue lives in asset_manager.jai; these functions
|
||||
// add entries to that queue and handle completed/failed fetches.
|
||||
|
||||
#scope_export
|
||||
|
||||
shgrid_loader_enqueue_world :: (world: *World) {
|
||||
for *chunk: world.chunks {
|
||||
if chunk.sh_valid then continue;
|
||||
|
||||
already := false;
|
||||
for g_asset_manager.slots {
|
||||
if !it.occupied then continue;
|
||||
if it.req.type == .SHGRID &&
|
||||
it.req.world_name == world.name && it.req.chunk_key == chunk.coord {
|
||||
already = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if already then continue;
|
||||
|
||||
for g_asset_manager.queue {
|
||||
if it.type == .SHGRID &&
|
||||
it.world_name == world.name && it.chunk_key == chunk.coord {
|
||||
already = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if already then continue;
|
||||
|
||||
req : Fetch_Request;
|
||||
req.type = .SHGRID;
|
||||
req.priority = .LOADING_SCREEN;
|
||||
req.world_name = world.name;
|
||||
req.chunk_key = chunk.coord;
|
||||
req.path = shgrid_filename(world.name, chunk.coord);
|
||||
array_add(*g_asset_manager.queue, req);
|
||||
}
|
||||
}
|
||||
|
||||
sh_loader_handle_failed :: (req: *Fetch_Request) {
|
||||
log_error("SH: failed to load probe grid for chunk %", req.chunk_key);
|
||||
}
|
||||
|
||||
sh_loader_handle_completed :: (req: *Fetch_Request, data: []u8) {
|
||||
curworld := get_current_world();
|
||||
if !curworld.valid || curworld.world.name != req.world_name then return;
|
||||
|
||||
header_size := cast(s64) size_of(SH_Grid_File_Header);
|
||||
if data.count < header_size {
|
||||
log_error("SH: probe grid too small for chunk %", req.chunk_key);
|
||||
return;
|
||||
}
|
||||
sh_header := cast(*SH_Grid_File_Header) data.data;
|
||||
if sh_header.magic != SH_FILE_MAGIC {
|
||||
log_error("SH: bad magic for chunk %", req.chunk_key);
|
||||
return;
|
||||
}
|
||||
n := sh_header.probe_n;
|
||||
if n != SH_PROBE_N {
|
||||
log_error("SH: probe_n mismatch for chunk % (file=%, expected=%) — re-bake required", req.chunk_key, n, SH_PROBE_N);
|
||||
return;
|
||||
}
|
||||
total_values := cast(s64) n * n * n * 12;
|
||||
bytes_per_val := ifx sh_header.version >= 2 then size_of(u16) else size_of(float);
|
||||
if data.count < header_size + total_values * bytes_per_val {
|
||||
log_error("SH: probe grid data too short for chunk %", req.chunk_key);
|
||||
return;
|
||||
}
|
||||
|
||||
// Pack flat [n^3 * 12] coefficients → 3-RGBA16F-texels-per-probe 2D texture layout.
|
||||
// Texture dims: (n*3) x (n*n). Probe (px,py,pz) at row (pz*n+py), col (px*3+k).
|
||||
// Coefficient layout in 3 texels (12 slots):
|
||||
// t0: R.c0-3 t1: G.c0-3 t2: B.c0-3
|
||||
tex_w := n * 3;
|
||||
n_tex := cast(s64) tex_w * n * n;
|
||||
packed := NewArray(n_tex * 4, u16);
|
||||
if sh_header.version >= 2 {
|
||||
src := cast(*u16) (data.data + header_size);
|
||||
for pz: 0..n-1 for py: 0..n-1 for px: 0..n-1 {
|
||||
probe_idx := px + py * n + pz * n * n;
|
||||
s := src + probe_idx * 12;
|
||||
for k: 0..2 {
|
||||
tex_idx := (pz * n + py) * tex_w + (px * 3 + k);
|
||||
d := packed.data + tex_idx * 4;
|
||||
for ch: 0..3 d[ch] = (s + k * 4 + ch).*;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
src := cast(*float) (data.data + header_size);
|
||||
for pz: 0..n-1 for py: 0..n-1 for px: 0..n-1 {
|
||||
probe_idx := px + py * n + pz * n * n;
|
||||
s := src + probe_idx * 12;
|
||||
for k: 0..2 {
|
||||
tex_idx := (pz * n + py) * tex_w + (px * 3 + k);
|
||||
d := packed.data + tex_idx * 4;
|
||||
for ch: 0..3 d[ch] = f32_to_f16((s + k * 4 + ch).*);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sh_imgdata : sg_image_data;
|
||||
sh_imgdata.subimage[0][0] = .{ packed.data, cast(u64)(n_tex * 4 * size_of(u16)) };
|
||||
sh_desc : sg_image_desc = .{
|
||||
width = tex_w,
|
||||
height = n * n,
|
||||
pixel_format = sg_pixel_format.RGBA16F,
|
||||
sample_count = 1,
|
||||
data = sh_imgdata,
|
||||
};
|
||||
chunk := table_find_pointer(*curworld.world.chunks, req.chunk_key);
|
||||
if chunk != null {
|
||||
if chunk.sh_probe_grid.id != 0 then sg_destroy_image(chunk.sh_probe_grid);
|
||||
chunk.sh_probe_grid = sg_make_image(*sh_desc);
|
||||
chunk.sh_valid = true;
|
||||
log_debug("SH: loaded probe grid for chunk %", req.chunk_key);
|
||||
}
|
||||
free(packed.data);
|
||||
}
|
||||
@ -6,10 +6,10 @@
|
||||
#load "trile_editor.jai";
|
||||
#load "level_editor.jai";
|
||||
#load "particle_editor.jai";
|
||||
#load "material_studio.jai";
|
||||
}
|
||||
#if FLAG_TACOMA_ENABLED { #load "tacoma.jai"; }
|
||||
#load "console.jai";
|
||||
#load "textureDebugger.jai";
|
||||
|
||||
#scope_file
|
||||
|
||||
@ -18,6 +18,7 @@ Editor_View :: enum {
|
||||
Trile_Editor;
|
||||
Level_Editor;
|
||||
Particle_Editor;
|
||||
Material_Editor;
|
||||
};
|
||||
|
||||
current_editor_view : Editor_View = .Trile_Editor;
|
||||
@ -62,6 +63,8 @@ draw_editor_ui :: (theme: *GR.Overall_Theme) {
|
||||
if keybind_button(r, "Trile studio", .STUDIO_TRILE, *t_button_selectable(theme, current_editor_view == .Trile_Editor)) { clear_particles(); current_editor_view = .Trile_Editor; }
|
||||
r.x -= r.w;
|
||||
if keybind_button(r, "Particle studio", .STUDIO_MATERIAL, *t_button_selectable(theme, current_editor_view == .Particle_Editor)) { clear_particles(); current_editor_view = .Particle_Editor; }
|
||||
r.x -= r.w;
|
||||
if keybind_button(r, "Material studio", .STUDIO_SWATCHES, *t_button_selectable(theme, current_editor_view == .Material_Editor)) { clear_particles(); current_editor_view = .Material_Editor; }
|
||||
|
||||
if current_editor_view == {
|
||||
case .Trile_Editor;
|
||||
@ -70,23 +73,19 @@ draw_editor_ui :: (theme: *GR.Overall_Theme) {
|
||||
draw_level_editor_ui(theme);
|
||||
case .Particle_Editor;
|
||||
draw_particle_editor_ui(theme);
|
||||
case .Material_Editor;
|
||||
draw_material_studio_ui(theme);
|
||||
}
|
||||
}
|
||||
draw_profiler();
|
||||
}
|
||||
draw_texture_debugger(theme);
|
||||
draw_postprocess_popup(theme);
|
||||
draw_lighting_popup(theme);
|
||||
GR.draw_popups();
|
||||
immediate_flush();
|
||||
}
|
||||
|
||||
draw_editor :: () {
|
||||
#if OS != .WASM {
|
||||
disable_dof_post_process = false;
|
||||
if !in_editor_view then return;
|
||||
disable_dof_post_process = true;
|
||||
|
||||
|
||||
if current_editor_view == {
|
||||
case .Trile_Editor;
|
||||
|
||||
@ -36,14 +36,7 @@ draw_line :: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2, color: Vector4
|
||||
}
|
||||
|
||||
text_width :: (text: string) -> float {
|
||||
if text.count < 1 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
fonsSetFont(state.fons, state.font_default.fons_font);
|
||||
fonsSetSize(state.fons, xx iprof_font.character_height);
|
||||
w := fonsTextBounds(state.fons, 0.0, 0.0, text.data, text.data + text.count, null);
|
||||
return cast(float) w;
|
||||
return text_measure(state.font_default.face, xx iprof_font.character_height, text);
|
||||
}
|
||||
|
||||
draw_rectangle_prof :: (x0: float, y0: float, x1: float, y1: float, color: Vector4) {
|
||||
|
||||
@ -56,7 +56,6 @@ inspector_x : s32;
|
||||
inspector_y : s32;
|
||||
inspector_z : s32;
|
||||
inspector_emitter_def : s32 = -1;
|
||||
inspector_rdm_roughness : int = 0;
|
||||
inspector_note_deactivate : bool;
|
||||
inspector_note_activate_next : bool;
|
||||
|
||||
@ -131,11 +130,7 @@ get_level_editor_camera :: () -> Camera {
|
||||
camera.position = camera.target;
|
||||
camera.position += cameraDir * cameraDist;
|
||||
|
||||
if is_in_reflection_pass {
|
||||
camera.position.y *= -1;
|
||||
camera.target.y *= -1;
|
||||
}
|
||||
|
||||
|
||||
return camera;
|
||||
}
|
||||
|
||||
@ -487,7 +482,6 @@ add_trile :: (name: string, x: s32, y: s32, z: s32, orientation: u8 = 0) {
|
||||
for *group: chunk.groups {
|
||||
if group.trile_name == name {
|
||||
array_add(*group.instances, inst);
|
||||
recompute_group_bounds(group);
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
@ -496,10 +490,9 @@ add_trile :: (name: string, x: s32, y: s32, z: s32, orientation: u8 = 0) {
|
||||
group: Chunk_Trile_Group;
|
||||
group.trile_name = sprint("%", name);
|
||||
array_add(*group.instances, inst);
|
||||
recompute_group_bounds(*group);
|
||||
array_add(*chunk.groups, group);
|
||||
}
|
||||
invalidate_buried_around(*curworld.world, x, y, z);
|
||||
upload_chunk(chunk);
|
||||
trile, ok := get_trile(name);
|
||||
if !ok || trile.skip_collision then return;
|
||||
chunk_set_occupancy_mask_at(chunk, lx, ly, lz, occupancy_state_for(trile, orientation));
|
||||
@ -519,17 +512,13 @@ remove_trile :: (x: s32, y: s32, z: s32) {
|
||||
for inst, idx: group.instances {
|
||||
if inst.x == lx && inst.y == ly && inst.z == lz {
|
||||
array_unordered_remove_by_index(*group.instances, idx);
|
||||
if group.is_buried.count > idx {
|
||||
array_unordered_remove_by_index(*group.is_buried, idx);
|
||||
}
|
||||
recompute_group_bounds(group);
|
||||
removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if removed break;
|
||||
}
|
||||
if removed invalidate_buried_around(*curworld.world, x, y, z);
|
||||
if removed upload_chunk(chunk);
|
||||
chunk_set_occupancy_mask_at(chunk, lx, ly, lz, .FREE);
|
||||
} @Command
|
||||
|
||||
@ -790,7 +779,7 @@ tick_level_editor :: () {
|
||||
}
|
||||
}
|
||||
|
||||
create_level_editor_preview_tasks :: () {
|
||||
draw_level_editor_preview :: (view: View_Id) {
|
||||
curworld := get_current_world();
|
||||
if !curworld.valid then return;
|
||||
|
||||
@ -802,20 +791,8 @@ create_level_editor_preview_tasks :: () {
|
||||
if current_tool_mode == .INSPECTOR {
|
||||
name, orientation, found := get_trile_at(*curworld.world, xx px, xx py, xx pz);
|
||||
cursor_trile := ifx found then name else (ifx editor_current_trile then editor_current_trile.name else "");
|
||||
if cursor_trile != "" {
|
||||
ck := world_to_chunk_coord(xx px, xx py, xx pz);
|
||||
lx, ly, lz := world_to_local(xx px, xx py, xx pz);
|
||||
positions: [..]Trile_Instance;
|
||||
positions.allocator = temp;
|
||||
array_add(*positions, Trile_Instance.{lx, ly, lz, xx orientation});
|
||||
task: Rendering_Task_Trile;
|
||||
task.trile = cursor_trile;
|
||||
task.positions = positions;
|
||||
task.worldConf = *curworld.world.conf;
|
||||
task.preview_mode = 1;
|
||||
task.chunk_key = ck;
|
||||
add_rendering_task(task);
|
||||
}
|
||||
mesh, ok := get_trile_mesh(cursor_trile);
|
||||
if ok draw_trile(view, mesh, .{xx px, xx py, xx pz}, orientation, .ADD_PREVIEW);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -880,37 +857,10 @@ create_level_editor_preview_tasks :: () {
|
||||
is_delete := (current_tool_mode == .AREA && area_active && area_delete)
|
||||
|| (current_tool_mode == .LINE && line_active && line_delete);
|
||||
|
||||
chunk_groups: [..] struct { key: Chunk_Key; instances: [..]Trile_Instance; };
|
||||
chunk_groups.allocator = temp;
|
||||
for pos : positions {
|
||||
wx := cast(s32) pos.x; wy := cast(s32) pos.y; wz := cast(s32) pos.z;
|
||||
ck := world_to_chunk_coord(wx, wy, wz);
|
||||
lx, ly, lz := world_to_local(wx, wy, wz);
|
||||
found := false;
|
||||
for *grp : chunk_groups {
|
||||
if grp.key == ck {
|
||||
array_add(*grp.instances, Trile_Instance.{lx, ly, lz, ori_u8});
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
instances: [..]Trile_Instance;
|
||||
instances.allocator = temp;
|
||||
array_add(*instances, Trile_Instance.{lx, ly, lz, ori_u8});
|
||||
array_add(*chunk_groups, .{ck, instances});
|
||||
}
|
||||
}
|
||||
|
||||
for grp : chunk_groups {
|
||||
task: Rendering_Task_Trile;
|
||||
task.trile = editor_current_trile.name;
|
||||
task.positions = grp.instances;
|
||||
task.worldConf = *curworld.world.conf;
|
||||
task.chunk_key = grp.key;
|
||||
task.preview_mode = ifx is_delete then cast(s32)2 else cast(s32)1;
|
||||
add_rendering_task(task);
|
||||
}
|
||||
mesh, ok := get_trile_mesh(editor_current_trile.name);
|
||||
if !ok then return;
|
||||
tint := ifx is_delete then Trile_Tint.DELETE_PREVIEW else .ADD_PREVIEW;
|
||||
for positions draw_trile(view, mesh, it.xyz, ori_u8, tint);
|
||||
}
|
||||
|
||||
get_trile_at :: (world: *World, wx: s32, wy: s32, wz: s32) -> (name: string, orientation: u8, found: bool) {
|
||||
@ -958,36 +908,6 @@ draw_inspector_panel :: (r: *GR.Rect, theme: *GR.Overall_Theme) {
|
||||
if has_trile {
|
||||
GR.label(r.*, tprint("Trile: % orient: %", trile_name, orientation), *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
r.h = ui_h(3, 2);
|
||||
GR.label(r.*, "-- RDM --", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
r.h = ui_h(4, 0);
|
||||
rdm_on := is_rdm_instance_enabled(world, inspector_x, inspector_y, inspector_z);
|
||||
label := ifx rdm_on then "RDM: ON (sharp specular)" else "RDM: OFF (sky reflection)";
|
||||
if GR.button(r.*, label, *theme.button_theme, 300) {
|
||||
set_rdm_instance_enabled(world, inspector_x, inspector_y, inspector_z, !rdm_on);
|
||||
}
|
||||
r.y += r.h;
|
||||
|
||||
if rdm_on {
|
||||
cur_size := get_rdm_instance_size(world, inspector_x, inspector_y, inspector_z);
|
||||
tile_w := 2 * cur_size;
|
||||
tile_h := 3 * cur_size;
|
||||
size_label := tprint("Size: % (% x % px)", cur_size, tile_w, tile_h);
|
||||
GR.label(r.*, size_label, *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
|
||||
r2 := r.*;
|
||||
r2.w = r.w / 2;
|
||||
if GR.button(r2, "- size", *theme.button_theme, 304) {
|
||||
set_rdm_instance_size(world, inspector_x, inspector_y, inspector_z, rdm_cycle_size(cur_size, -1));
|
||||
}
|
||||
r2.x += r2.w;
|
||||
if GR.button(r2, "+ size", *theme.button_theme, 305) {
|
||||
set_rdm_instance_size(world, inspector_x, inspector_y, inspector_z, rdm_cycle_size(cur_size, +1));
|
||||
}
|
||||
r.y += r.h;
|
||||
}
|
||||
} else {
|
||||
GR.label(r.*, "Trile: (empty)", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
@ -1081,60 +1001,6 @@ draw_inspector_panel :: (r: *GR.Rect, theme: *GR.Overall_Theme) {
|
||||
r.y += r.h;
|
||||
}
|
||||
|
||||
r.h = ui_h(3, 2);
|
||||
r.y += r.h * 0.5;
|
||||
GR.label(r.*, "-- RDM --", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
|
||||
rdm_flagged := is_rdm_instance_enabled(world, inspector_x, inspector_y, inspector_z);
|
||||
if rdm_flagged {
|
||||
GR.label(r.*, "RDM: flagged", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
|
||||
rect, has_rect := rdm_get_atlas_rect(world, inspector_x, inspector_y, inspector_z);
|
||||
if has_rect {
|
||||
GR.label(r.*, tprint("Rect: %.2,%.2 %.2x%.2", rect.x, rect.y, rect.z, rect.w), *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
|
||||
r.y += r.h * 0.5;
|
||||
tex_size := r.w * 0.9;
|
||||
tex_r : GR.Rect;
|
||||
tex_r.x = r.x + (r.w - tex_size) * 0.5;
|
||||
tex_r.y = r.y;
|
||||
tex_r.w = tex_size;
|
||||
tex_r.h = tex_size * 1.5;
|
||||
|
||||
fy0 := 1.0 - rect.y;
|
||||
fy1 := 1.0 - (rect.y + rect.w);
|
||||
uv0 := Vector2.{rect.x, fy0};
|
||||
uv1 := Vector2.{rect.x + rect.z, fy0};
|
||||
uv2 := Vector2.{rect.x + rect.z, fy1};
|
||||
uv3 := Vector2.{rect.x, fy1};
|
||||
|
||||
uiTex := New(Ui_Texture,, temp);
|
||||
uiTex.tex = g_rdm_atlas;
|
||||
if uiTex.tex.id != INVALID_ID {
|
||||
set_shader_for_images(uiTex);
|
||||
immediate_quad(
|
||||
.{tex_r.x, tex_r.y},
|
||||
.{tex_r.x + tex_r.w, tex_r.y},
|
||||
.{tex_r.x + tex_r.w, tex_r.y + tex_r.h},
|
||||
.{tex_r.x, tex_r.y + tex_r.h},
|
||||
.{1,1,1,1},
|
||||
uv0, uv1, uv2, uv3
|
||||
);
|
||||
set_shader_for_color();
|
||||
immediate_flush();
|
||||
}
|
||||
r.y += tex_r.h + r.h * 0.5;
|
||||
} else {
|
||||
GR.label(r.*, "RDM: not yet baked", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
}
|
||||
} else {
|
||||
GR.label(r.*, "RDM: not flagged", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
}
|
||||
}
|
||||
|
||||
draw_entity_tool_panel :: (r: *GR.Rect, theme: *GR.Overall_Theme) {
|
||||
@ -1245,7 +1111,7 @@ entity_autoedit :: (rect: GR.Rect, e: *Entity, theme: *GR.Overall_Theme) {
|
||||
#insert #run,stallable gen_entity_dispatch("autoedit(rect, cast(*%)e, theme, 400)");
|
||||
}
|
||||
|
||||
add_editor_billboards :: () {
|
||||
draw_editor_billboards :: (view: View_Id) {
|
||||
if !editor_billboards_visible then return;
|
||||
curworld := get_current_world();
|
||||
if !curworld.valid then return;
|
||||
@ -1255,45 +1121,31 @@ add_editor_billboards :: () {
|
||||
for e: curworld.world.entities {
|
||||
marker := entity_marker_animation(e);
|
||||
if marker == null then continue;
|
||||
task : Rendering_Task_Billboard;
|
||||
task.position = e.position + ENTITY_PIVOT;
|
||||
task.animation = marker;
|
||||
task.frame = 0;
|
||||
add_rendering_task(task);
|
||||
draw_animation_frame(view, marker, 0, e.position + ENTITY_PIVOT);
|
||||
}
|
||||
|
||||
anim := get_animation_from_string("game_core.ball");
|
||||
if anim == null then return;
|
||||
|
||||
for inst: curworld.world.emitter_instances {
|
||||
task : Rendering_Task_Billboard;
|
||||
task.position = inst.position;
|
||||
task.animation = anim;
|
||||
task.frame = 0;
|
||||
add_rendering_task(task);
|
||||
draw_animation_frame(view, anim, 0, inst.position);
|
||||
}
|
||||
|
||||
for note: curworld.world.notes {
|
||||
task : Rendering_Task_Billboard;
|
||||
task.position = .{cast(float)note.position.x + 0.5, cast(float)note.position.y + 0.5, cast(float)note.position.z + 0.5};
|
||||
task.animation = anim;
|
||||
task.frame = 0;
|
||||
add_rendering_task(task);
|
||||
draw_animation_frame(view, anim, 0, .{cast(float)note.position.x + 0.5, cast(float)note.position.y + 0.5, cast(float)note.position.z + 0.5});
|
||||
}
|
||||
}
|
||||
|
||||
draw_level_editor :: () {
|
||||
curworld := get_current_world();
|
||||
if !curworld.valid then return;
|
||||
cam := get_level_editor_camera();
|
||||
ph := effective_plane_height(*curworld.world.conf);
|
||||
create_set_cam_rendering_task(cam, ph);
|
||||
create_world_rendering_tasks(*curworld.world, cam, ph);
|
||||
add_entity_render_tasks(*curworld.world);
|
||||
view := add_view(.{camera = get_level_editor_camera(), environment = *curworld.world.environment});
|
||||
draw_entities(view, *curworld.world);
|
||||
draw_live_particles(view);
|
||||
if show_trile_preview && !trile_preview_disabled {
|
||||
create_level_editor_preview_tasks();
|
||||
draw_level_editor_preview(view);
|
||||
}
|
||||
add_editor_billboards();
|
||||
draw_editor_billboards(view);
|
||||
debug_grid(floor(cameraCenter.x), editor_edit_y(), floor(cameraCenter.y), 20, .{0.3, 0.3, 0.35, 0.7});
|
||||
}
|
||||
|
||||
|
||||
78
src/editor/material_studio.jai
Normal file
78
src/editor/material_studio.jai
Normal file
@ -0,0 +1,78 @@
|
||||
#scope_file
|
||||
|
||||
ms_selected : u8;
|
||||
ms_scroll : float;
|
||||
ms_name_input : string;
|
||||
|
||||
#scope_export
|
||||
|
||||
draw_material_studio_ui :: (theme: *GR.Overall_Theme) {
|
||||
panel := GR.get_rect(0, ui_h(5,0), ui_w(20, 20), ui_h(95, 0));
|
||||
ui_add_mouse_occluder(panel);
|
||||
draw_bg_rectangle(panel, theme);
|
||||
row_h := ui_h(4, 0);
|
||||
|
||||
r := panel;
|
||||
r.h = row_h;
|
||||
if GR.button(r, "New material", *theme.button_theme) {
|
||||
id, ok := swatch_add("new", u8.[255, 255, 255]);
|
||||
if ok {
|
||||
ms_selected = id;
|
||||
ms_name_input = copy_string(g_swatches[id].name);
|
||||
}
|
||||
}
|
||||
r.y += row_h;
|
||||
|
||||
grid := r;
|
||||
grid.h = ui_h(25, 0);
|
||||
previous := ms_selected;
|
||||
region, inside := GR.begin_scrollable_region(grid, *theme.scrollable_region_theme);
|
||||
end_y := draw_swatch_grid(inside, *ms_scroll, *ms_selected, theme);
|
||||
GR.end_scrollable_region(region, inside.x + inside.w, end_y, *ms_scroll);
|
||||
if ms_selected != previous ms_name_input = copy_string(g_swatches[ms_selected].name);
|
||||
r.y += grid.h + row_h * 0.5;
|
||||
|
||||
if ms_selected == 0 || !g_swatches[ms_selected].used return;
|
||||
swatch := *g_swatches[ms_selected];
|
||||
|
||||
a, new_text := GR.text_input(r, ms_name_input, *theme.text_input_theme, 128);
|
||||
if a & .ENTERED {
|
||||
ms_name_input = copy_string(new_text);
|
||||
swatch.name = copy_string(new_text);
|
||||
}
|
||||
r.y += row_h;
|
||||
|
||||
r.h = ui_h(30, 0);
|
||||
color := swatch_color(ms_selected);
|
||||
GR.color_picker(r, *color, *theme.color_picker_theme);
|
||||
for 0..2 swatch.color[it] = cast(u8) clamp(color.component[it] * 255 + 0.5, 0, 255);
|
||||
r.y += r.h;
|
||||
|
||||
r.h = ui_h(3, 2);
|
||||
GR.label(r, "Roughness", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
GR.slider(r, *swatch.roughness, 0, 7, 1, *theme.slider_theme);
|
||||
r.y += r.h;
|
||||
GR.label(r, "Metallic", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
GR.slider(r, *swatch.metallic, 0, 3, 1, *theme.slider_theme);
|
||||
r.y += r.h;
|
||||
GR.label(r, "Emittance", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
GR.slider(r, *swatch.emittance, 0, 127, 1, *theme.slider_theme);
|
||||
r.y += r.h * 2;
|
||||
|
||||
r.h = row_h;
|
||||
if GR.button(r, "Save", *theme.button_theme) {
|
||||
striles();
|
||||
for trile: get_trile_table_ptr() update_trile_thumbnail(trile.name);
|
||||
}
|
||||
r.y += row_h;
|
||||
|
||||
if swatch_in_use(ms_selected) {
|
||||
GR.label(r, "In use, can't delete", *t_label_left(theme));
|
||||
} else if GR.button(r, "Delete", *theme.button_theme) {
|
||||
swatch.* = .{};
|
||||
ms_selected = 0;
|
||||
}
|
||||
}
|
||||
@ -184,7 +184,8 @@ draw_particle_editor_ui :: (theme: *GR.Overall_Theme) {
|
||||
}
|
||||
|
||||
draw_particle_editor :: () {
|
||||
create_set_cam_rendering_task(pe_cam, 0.0);
|
||||
view := add_view(.{camera = pe_cam, environment = New(Environment,, temp), draw_world = false});
|
||||
draw_live_particles(view);
|
||||
|
||||
if pe_selected_index >= 0 && pe_selected_index < cast(s32)g_emitter_defs.count {
|
||||
def := *g_emitter_defs[pe_selected_index];
|
||||
|
||||
@ -59,7 +59,7 @@ draw_trile_picker :: (r_in: GR.Rect, theme: *GR.Overall_Theme) {
|
||||
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;
|
||||
atlas_valid := g_thumbnail_atlas.tex.id != 0;
|
||||
|
||||
region, inside := GR.begin_scrollable_region(r, *theme.scrollable_region_theme);
|
||||
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
// 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_global_atlas_filename :: (world_name: string) -> string {
|
||||
return sprint("%/worlds/%/rdm_atlas.rdm", GAME_RESOURCES_DIR, world_name);
|
||||
}
|
||||
|
||||
rdm_global_manifest_filename :: (world_name: string) -> string {
|
||||
return sprint("%/worlds/%/rdm_manifest.json", GAME_RESOURCES_DIR, world_name);
|
||||
}
|
||||
|
||||
// SH probe grid (1 probe per trile per axis = 32x32x32 per 32x32x32 chunk)
|
||||
|
||||
SH_FILE_MAGIC :: u32.[0x44475348][0]; // "SHGD" as little-endian u32
|
||||
SH_PROBE_N :: 32; // probes per axis (1 per trile in a 32-trile chunk)
|
||||
SH_TEX_W :: SH_PROBE_N * 3; // 96 — 3 RGBA texels per probe along X
|
||||
|
||||
SH_Grid_File_Header :: struct {
|
||||
magic: u32;
|
||||
version: u16;
|
||||
probe_n: s32;
|
||||
}
|
||||
|
||||
shgrid_filename :: (world_name: string, chunk_key: Chunk_Key) -> string {
|
||||
return sprint("%/worlds/%/%_%_%.shgrid", GAME_RESOURCES_DIR, world_name, chunk_key.x, chunk_key.y, chunk_key.z);
|
||||
}
|
||||
|
||||
f32_to_f16 :: (f: float) -> u16 {
|
||||
b := (cast(*u32) *f).*;
|
||||
sign := (b >> 31) & 0x1;
|
||||
exp := cast(s32)((b >> 23) & 0xFF) - 127;
|
||||
mant := b & 0x7FFFFF;
|
||||
if exp >= 16 return cast(u16)((sign << 15) | 0x7C00); // clamp to inf
|
||||
if exp >= -14 return cast(u16)((sign << 15) | (cast(u32)(exp + 15) << 10) | (mant >> 13));
|
||||
if exp >= -24 {
|
||||
shift := cast(u32)(-exp - 1);
|
||||
return cast(u16)((sign << 15) | ((mant | 0x800000) >> shift));
|
||||
}
|
||||
return cast(u16)(sign << 15); // underflow → ±0
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
test_f32_to_f16 :: () {
|
||||
s := begin_suite("f32_to_f16");
|
||||
|
||||
check(*s, "0.0 → 0x0000", f32_to_f16(0.0) == 0x0000);
|
||||
check(*s, "-0.0 → 0x8000", f32_to_f16(-0.0) == 0x8000);
|
||||
check(*s, "1.0 → 0x3C00", f32_to_f16(1.0) == 0x3C00);
|
||||
check(*s, "-1.0 → 0xBC00", f32_to_f16(-1.0) == 0xBC00);
|
||||
check(*s, "0.5 → 0x3800", f32_to_f16(0.5) == 0x3800);
|
||||
check(*s, "2.0 → 0x4000", f32_to_f16(2.0) == 0x4000);
|
||||
check(*s, "1.5 → 0x3E00", f32_to_f16(1.5) == 0x3E00);
|
||||
|
||||
// Max normal f16 = 65504
|
||||
check(*s, "65504.0 → 0x7BFF", f32_to_f16(65504.0) == 0x7BFF);
|
||||
|
||||
// Min normal f16 = 2^-14
|
||||
check(*s, "2^-14 → 0x0400", f32_to_f16(cast(float)(1.0 / 16384.0)) == 0x0400);
|
||||
|
||||
// Overflow clamps to infinity
|
||||
check(*s, "65536.0 → 0x7C00 (inf)", f32_to_f16(65536.0) == 0x7C00);
|
||||
check(*s, "1e10 → 0x7C00 (inf)", f32_to_f16(1.0e10) == 0x7C00);
|
||||
check(*s, "-65536.0 → 0xFC00 (-inf)", f32_to_f16(-65536.0) == 0xFC00);
|
||||
|
||||
// Denormals: 2^-15 is the largest f16 denormal base
|
||||
check(*s, "2^-15 → 0x0200", f32_to_f16(cast(float)(1.0 / 32768.0)) == 0x0200);
|
||||
// Smallest representable f16 denormal = 2^-24
|
||||
check(*s, "2^-24 → 0x0001", f32_to_f16(cast(float)(1.0 / 16777216.0)) == 0x0001);
|
||||
|
||||
// Underflow to zero
|
||||
check(*s, "2^-25 → 0x0000", f32_to_f16(cast(float)(1.0 / 33554432.0)) == 0x0000);
|
||||
check(*s, "-2^-25 → 0x8000", f32_to_f16(cast(float)(-1.0 / 33554432.0)) == 0x8000);
|
||||
|
||||
end_suite(s);
|
||||
}
|
||||
|
||||
#run test_f32_to_f16();
|
||||
@ -1,145 +0,0 @@
|
||||
#scope_file
|
||||
|
||||
subwindow : GR.Subwindow_Info;
|
||||
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;
|
||||
|
||||
current_pipeline : s32 = 0;
|
||||
current_slot : s32 = 0;
|
||||
pipeline_names : []string = .["shadowmap", "reflection", "main", "position", "normal", "ssao", "bloom", "dof", "rdm_atlas"];
|
||||
|
||||
draw_subwindow_texture_debug :: (state: *GR.Subwindow_State, r: GR.Rect, data: *void) {
|
||||
r2 := r;
|
||||
r2.h = ui_h(5,0);
|
||||
r2.w = r.w;
|
||||
GR.dropdown(r2, pipeline_names, *current_pipeline, *theme_ptr.dropdown_theme);
|
||||
|
||||
r2.y = r.y + r2.h;
|
||||
r2.h = r.h - r2.h;
|
||||
r2.x = r.x;
|
||||
r2.w = r.w;
|
||||
|
||||
uiTex := New(Ui_Texture ,,temp);
|
||||
|
||||
image : sg_image;
|
||||
if current_pipeline == {
|
||||
case 0; image = g_shadowmap_img;
|
||||
case 1; image = gPipelines.plane.bind.images[0];
|
||||
case 2; image = g_rendertex;
|
||||
case 3; image = g_gbuf_position;
|
||||
case 4; image = g_gbuf_normal;
|
||||
case 5; image = g_ssaobuf;
|
||||
case 6; image = g_bloom_up_1;
|
||||
case 7; image = g_dof_tex;
|
||||
case 8; image = g_rdm_atlas;
|
||||
}
|
||||
|
||||
uiTex.tex = image;
|
||||
|
||||
if uiTex.tex.id != INVALID_ID {
|
||||
set_shader_for_images(uiTex);
|
||||
immediate_quad(.{r2.x, r2.y}, .{r2.x + r2.w, r2.y}, .{r2.x + r2.w, r2.y + r2.h}, .{r2.x, r2.y + r2.h});
|
||||
set_shader_for_color();
|
||||
}
|
||||
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);
|
||||
r3 := r;
|
||||
r3.h = ui_h(5,0);
|
||||
r2.h -= r3.h;
|
||||
r2.y += r3.h;
|
||||
if GR.button(r3, "Save postprocessing", *theme_ptr.button_theme) {
|
||||
#if OS != .WASM {
|
||||
file :: #import "File";
|
||||
save_post_process();
|
||||
}
|
||||
}
|
||||
r3.y += r3.h;
|
||||
r2.h -= r3.h;
|
||||
r2.y += r3.h;
|
||||
|
||||
|
||||
GR.dropdown(r3, LUT_name_list, *g_current_lut_texture_index, *theme_ptr.dropdown_theme);
|
||||
|
||||
autoedit(r2, *current_post_process, *theme_ptr);
|
||||
}
|
||||
|
||||
#scope_export
|
||||
|
||||
draw_texture_debug :: () {
|
||||
}
|
||||
|
||||
toggle_texdebug :: () {
|
||||
subwindow.open = !subwindow.open;
|
||||
} @Command
|
||||
|
||||
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 {
|
||||
theme_ptr = theme;
|
||||
r := GR.get_rect(ui_w(40, 0), ui_w(40, 0), ui_h(50,0), ui_h(50,0));
|
||||
pp_subwindow.rect = r;
|
||||
pp_subwindow.draw = draw_subwindow_post_process;
|
||||
pp_subwindow.title_text = "Post Process";
|
||||
pp_subwindow.open = false;
|
||||
pp_subwindow_initted = true;
|
||||
}
|
||||
if pp_subwindow.open { // The Subwindow starts open, but pressing the Close button can close it.
|
||||
pp_subwindow_state := GR.add_subwindow(*pp_subwindow, *theme.subwindow_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 {
|
||||
theme_ptr = theme;
|
||||
r := GR.get_rect(ui_w(40, 0), ui_w(40, 0), ui_h(50,0), ui_h(50,0));
|
||||
subwindow.rect = r;
|
||||
subwindow.draw = draw_subwindow_texture_debug;
|
||||
subwindow.title_text = "Texture Debugger";
|
||||
subwindow.open = false;
|
||||
subwindow_initted = true;
|
||||
}
|
||||
if subwindow.open { // The Subwindow starts open, but pressing the Close button can close it.
|
||||
subwindow_state := GR.add_subwindow(*subwindow, *theme.subwindow_theme);
|
||||
}
|
||||
}
|
||||
@ -5,10 +5,6 @@ zoom : float = 3.0;
|
||||
|
||||
brush_radius : int = 5;
|
||||
|
||||
roughness : u8 = 0;
|
||||
metallic : u8 = 0;
|
||||
emittance : u8 = 0;
|
||||
|
||||
hovered_trixel_x : int = -1;
|
||||
hovered_trixel_y : int = -1;
|
||||
hovered_trixel_z : int = -1;
|
||||
@ -39,7 +35,6 @@ current_tab : Trile_Editor_Tab = .TOOLSET;
|
||||
current_tool : Trile_Editor_Tool = .PAINT;
|
||||
current_mode : Trile_Editor_Tool_Mode = .AREA;
|
||||
|
||||
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)
|
||||
@ -47,10 +42,10 @@ tiling_neighbor_trile_name : string;
|
||||
tiling_neighbor_trile_input : string;
|
||||
|
||||
UNDO_MAX :: 32;
|
||||
undo_trixels : [UNDO_MAX][16][16][16] Trixel;
|
||||
undo_trixels : [UNDO_MAX][16][16][16]u8;
|
||||
undo_count : int = 0;
|
||||
undo_head : int = 0;
|
||||
redo_trixels : [UNDO_MAX][16][16][16] Trixel;
|
||||
redo_trixels : [UNDO_MAX][16][16][16]u8;
|
||||
redo_count : int = 0;
|
||||
redo_head : int = 0;
|
||||
|
||||
@ -59,7 +54,7 @@ meta_name_input : string;
|
||||
#scope_export
|
||||
|
||||
ntrile :: (name: string) {
|
||||
set_trile_gfx(editor_current_trile.name, generate_trile_gfx_matias(editor_current_trile));
|
||||
trile_changed(editor_current_trile);
|
||||
newt : Trile;
|
||||
newt.name = sprint("%", name);
|
||||
set_trile(newt.name, newt);
|
||||
@ -68,7 +63,7 @@ ntrile :: (name: string) {
|
||||
} @Command
|
||||
|
||||
cpytrile :: (trile: string, destination: string) {
|
||||
set_trile_gfx(editor_current_trile.name, generate_trile_gfx_matias(editor_current_trile));
|
||||
trile_changed(editor_current_trile);
|
||||
newt : Trile;
|
||||
newt.name = sprint("%", destination);
|
||||
newt.trixels = get_trile(trile).trixels;
|
||||
@ -78,7 +73,7 @@ cpytrile :: (trile: string, destination: string) {
|
||||
} @Command
|
||||
|
||||
ltrile :: (name: string) {
|
||||
set_trile_gfx(editor_current_trile.name, generate_trile_gfx_matias(editor_current_trile));
|
||||
trile_changed(editor_current_trile);
|
||||
nt := get_trile(name);
|
||||
if !nt {
|
||||
console_add_output_line("Failed to load a trile with that name...");
|
||||
@ -108,6 +103,7 @@ do_undo :: () {
|
||||
undo_count -= 1;
|
||||
editor_current_trile.trixels = undo_trixels[undo_head];
|
||||
trile_gen_heightmap(editor_current_trile);
|
||||
trile_changed(editor_current_trile);
|
||||
}
|
||||
|
||||
do_redo :: () {
|
||||
@ -119,20 +115,15 @@ do_redo :: () {
|
||||
redo_count -= 1;
|
||||
editor_current_trile.trixels = redo_trixels[redo_head];
|
||||
trile_gen_heightmap(editor_current_trile);
|
||||
trile_changed(editor_current_trile);
|
||||
}
|
||||
|
||||
apply_tool_to_trixel :: (x: s64, y: s64, z: s64) {
|
||||
if current_tool == .PAINT {
|
||||
editor_current_trile.trixels[x][y][z].material.color = current_color;
|
||||
editor_current_trile.trixels[x][y][z].material.metallic = metallic;
|
||||
editor_current_trile.trixels[x][y][z].material.roughness = roughness;
|
||||
editor_current_trile.trixels[x][y][z].material.emittance = emittance;
|
||||
}
|
||||
if current_tool == .ADD {
|
||||
editor_current_trile.trixels[x][y][z].empty = false;
|
||||
}
|
||||
if current_tool == .REMOVE {
|
||||
editor_current_trile.trixels[x][y][z].empty = true;
|
||||
trixel := *editor_current_trile.trixels[x][y][z];
|
||||
if current_tool == {
|
||||
case .PAINT; if trixel.* != 0 trixel.* = current_swatch;
|
||||
case .ADD; if trixel.* == 0 trixel.* = current_swatch;
|
||||
case .REMOVE; trixel.* = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,13 +188,13 @@ handle_tool_click :: () {
|
||||
|
||||
#scope_export
|
||||
|
||||
current_color : Vector3 = .{1.0, 0.0, 0.0};
|
||||
current_swatch : u8 = 1;
|
||||
|
||||
reset_trile :: () {
|
||||
for x: 0..15 {
|
||||
for y: 0..15 {
|
||||
for z: 0..15 {
|
||||
editor_current_trile.trixels[x][y][z].empty = false;
|
||||
editor_current_trile.trixels[x][y][z] = current_swatch;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -229,6 +220,7 @@ tick_trile_editor :: () {
|
||||
|
||||
if input_button_states[Key_Code.MOUSE_BUTTON_LEFT] & .START {
|
||||
handle_tool_click();
|
||||
trile_changed(editor_current_trile);
|
||||
}
|
||||
|
||||
mindist : float = 999999;
|
||||
@ -239,8 +231,7 @@ tick_trile_editor :: () {
|
||||
for x: 0..15 {
|
||||
for y: 0..15 {
|
||||
for z: 0..15 {
|
||||
t := editor_current_trile.trixels[x][y][z];
|
||||
if t.empty then continue;
|
||||
if editor_current_trile.trixels[x][y][z] == 0 then continue;
|
||||
|
||||
cube : Collision_Cube;
|
||||
cube.position = Vector3.{cast(float) x, cast(float) y, cast(float) z} * TRIXEL_SIZE;
|
||||
@ -259,25 +250,18 @@ tick_trile_editor :: () {
|
||||
}
|
||||
}
|
||||
|
||||
for x: 0..15 {
|
||||
for y: 0..15 {
|
||||
for z: 0..15 {
|
||||
highlighted := false;
|
||||
if hovered_trixel_x >= 0 {
|
||||
if current_mode == .BRUSH {
|
||||
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};
|
||||
}
|
||||
if hovered_trixel_x >= 0 {
|
||||
lo := Vector3.{xx hovered_trixel_x, xx hovered_trixel_y, xx hovered_trixel_z};
|
||||
hi := lo;
|
||||
if current_mode == .BRUSH {
|
||||
lo -= Vector3.{1, 1, 1} * cast(float) brush_radius;
|
||||
hi += Vector3.{1, 1, 1} * cast(float) brush_radius;
|
||||
} else if current_mode == .AREA && area_active {
|
||||
corner := Vector3.{xx area_start_x, xx area_start_y, xx area_start_z};
|
||||
lo = min(lo, corner);
|
||||
hi = max(hi, corner);
|
||||
}
|
||||
debug_aabb_3d_overlay(lo * TRIXEL_SIZE, (hi + Vector3.{1, 1, 1}) * TRIXEL_SIZE, .{0.9, 0.1, 0.1, 1});
|
||||
}
|
||||
|
||||
if !input_button_states[Key_Code.CTRL] & .DOWN {
|
||||
@ -324,10 +308,7 @@ get_trile_editor_camera :: () -> Camera {
|
||||
return camera;
|
||||
}
|
||||
|
||||
global_palette_scroll : float = 0.0;
|
||||
trile_palette_scroll : float = 0.0;
|
||||
use_color_picker : bool = false;
|
||||
selected_palette : s32 = 0;
|
||||
swatch_scroll : float = 0.0;
|
||||
|
||||
draw_tool_tab :: (theme: *GR.Overall_Theme, area: GR.Rect) {
|
||||
r := area;
|
||||
@ -348,126 +329,34 @@ draw_tool_tab :: (theme: *GR.Overall_Theme, area: GR.Rect) {
|
||||
GR.slider(r, *brush_radius, 0, 12, 1, *theme.slider_theme);
|
||||
r.y += r.h * 2;
|
||||
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));
|
||||
trile_changed(editor_current_trile);
|
||||
striles();
|
||||
update_trile_thumbnail(editor_current_trile.name);
|
||||
};
|
||||
}
|
||||
|
||||
draw_swatches :: (entries: []Palette_Entry, inside: GR.Rect, block: float, scroll: *float, id_offset: s32, theme: *GR.Overall_Theme) -> (end_y: float) {
|
||||
cols := max(1, cast(int)(inside.w / block));
|
||||
for entry, idx: entries {
|
||||
er : GR.Rect;
|
||||
er.x = inside.x + (idx % cols) * block;
|
||||
er.y = inside.y - scroll.* + (idx / cols) * block;
|
||||
er.w = block; er.h = block;
|
||||
btn := theme.button_theme;
|
||||
btn.surface_color = .{entry.r, entry.g, entry.b, 1.0};
|
||||
if GR.button(er, "", *btn, id_offset + cast(s32)idx) {
|
||||
current_color = .{entry.r, entry.g, entry.b};
|
||||
roughness = xx entry.roughness;
|
||||
metallic = xx entry.metallic;
|
||||
emittance = xx entry.emittance;
|
||||
}
|
||||
}
|
||||
rows := ifx entries.count > 0 then (entries.count + cols - 1) / cols else 0;
|
||||
return inside.y + rows * block;
|
||||
}
|
||||
|
||||
draw_material_tab :: (theme: *GR.Overall_Theme, area: GR.Rect) {
|
||||
r := area;
|
||||
row_h := ui_h(4, 0);
|
||||
block := ui_h(3, 2);
|
||||
bottom := area.y + area.h;
|
||||
sliders_h := ui_h(18, 0);
|
||||
|
||||
r.h = row_h;
|
||||
half := r.w / 2;
|
||||
r.w = half;
|
||||
if GR.button(r, "Palette", *t_button_selectable(theme, !use_color_picker)) then use_color_picker = false;
|
||||
r.x += half;
|
||||
if GR.button(r, "Color Picker", *t_button_selectable(theme, use_color_picker)) then use_color_picker = true;
|
||||
r.x = area.x; r.w = area.w;
|
||||
r.y += row_h;
|
||||
|
||||
available := bottom - r.y - sliders_h;
|
||||
top_h := ifx use_color_picker then ui_h(42, 0) else available / 2;
|
||||
bot_h := available - top_h;
|
||||
|
||||
r.h = top_h;
|
||||
if use_color_picker {
|
||||
GR.color_picker(r, *current_color, *theme.color_picker_theme);
|
||||
} else {
|
||||
if g_palettes.count > 1 {
|
||||
r.h = row_h;
|
||||
pal_w := r.w / cast(float)g_palettes.count;
|
||||
for pal, idx: g_palettes {
|
||||
pr := r;
|
||||
pr.x = area.x + idx * pal_w;
|
||||
pr.w = pal_w;
|
||||
if GR.button(pr, pal.name, *t_button_selectable(theme, cast(s32)idx == selected_palette), cast(s32)idx + 20000) {
|
||||
selected_palette = cast(s32)idx;
|
||||
global_palette_scroll = 0;
|
||||
}
|
||||
}
|
||||
r.y += row_h;
|
||||
top_h -= row_h;
|
||||
r.h = top_h;
|
||||
}
|
||||
entries : []Palette_Entry;
|
||||
if g_palettes.count > 0 {
|
||||
selected_palette = clamp(selected_palette, 0, cast(s32)g_palettes.count - 1);
|
||||
entries = g_palettes[selected_palette].entries;
|
||||
}
|
||||
region, inside := GR.begin_scrollable_region(r, *theme.scrollable_region_theme);
|
||||
end_y := draw_swatches(entries, inside, block, *global_palette_scroll, 0, theme);
|
||||
GR.end_scrollable_region(region, inside.x + inside.w, end_y, *global_palette_scroll);
|
||||
}
|
||||
r.y += top_h;
|
||||
|
||||
unique_mats : [..]Material;
|
||||
unique_mats.allocator = temp;
|
||||
for x: 0..15 for y: 0..15 for z: 0..15 {
|
||||
trix := editor_current_trile.trixels[x][y][z];
|
||||
if trix.empty then continue;
|
||||
mr, mg, mb, ma := material_to_rgba(trix.material);
|
||||
key := (cast(u32)mr << 24) | (cast(u32)mg << 16) | (cast(u32)mb << 8) | cast(u32)ma;
|
||||
already := false;
|
||||
for um: unique_mats {
|
||||
ur, ug, ub, ua := material_to_rgba(um);
|
||||
if ((cast(u32)ur << 24) | (cast(u32)ug << 16) | (cast(u32)ub << 8) | cast(u32)ua) == key { already = true; break; }
|
||||
}
|
||||
if !already array_add(*unique_mats, trix.material);
|
||||
}
|
||||
as_entries : [..]Palette_Entry;
|
||||
as_entries.allocator = temp;
|
||||
for mat: unique_mats {
|
||||
e : Palette_Entry;
|
||||
e.r = mat.color.x; e.g = mat.color.y; e.b = mat.color.z;
|
||||
e.roughness = mat.roughness; e.metallic = mat.metallic; e.emittance = mat.emittance;
|
||||
array_add(*as_entries, e);
|
||||
}
|
||||
|
||||
r.h = bot_h * 0.75;
|
||||
region2, inside2 := GR.begin_scrollable_region(r, *theme.scrollable_region_theme);
|
||||
end_y2 := draw_swatches(as_entries, inside2, block, *trile_palette_scroll, 10000, theme);
|
||||
GR.end_scrollable_region(region2, inside2.x + inside2.w, end_y2, *trile_palette_scroll);
|
||||
r.y += bot_h * 0.75;
|
||||
|
||||
r.h = ui_h(3, 2);
|
||||
GR.label(r, "Roughness", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
GR.slider(r, *roughness, 0, 7, 1, *theme.slider_theme);
|
||||
r.y += r.h;
|
||||
GR.label(r, "Metallic", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
GR.slider(r, *metallic, 0, 3, 1, *theme.slider_theme);
|
||||
r.y += r.h;
|
||||
GR.label(r, "Emittance", *t_label_left(theme));
|
||||
r.y += r.h;
|
||||
GR.slider(r, *emittance, 0, 127, 1, *theme.slider_theme);
|
||||
region, inside := GR.begin_scrollable_region(area, *theme.scrollable_region_theme);
|
||||
end_y := draw_swatch_grid(inside, *swatch_scroll, *current_swatch, theme);
|
||||
GR.end_scrollable_region(region, inside.x + inside.w, end_y, *swatch_scroll);
|
||||
}
|
||||
|
||||
// Shared with the material studio. Returns the bottom of the grid.
|
||||
draw_swatch_grid :: (inside: GR.Rect, scroll: *float, selected: *u8, theme: *GR.Overall_Theme) -> float {
|
||||
block := ui_h(3, 2);
|
||||
cols := max(1, cast(int)(inside.w / block));
|
||||
n := 0;
|
||||
for g_swatches {
|
||||
if !it.used continue;
|
||||
r := GR.Rect.{inside.x + (n % cols) * block, inside.y - scroll.* + (n / cols) * block, block, block};
|
||||
btn := t_button_selectable(theme, selected.* == it_index);
|
||||
c := swatch_color(cast(u8) it_index);
|
||||
btn.surface_color = .{c.x, c.y, c.z, 1};
|
||||
if GR.button(r, "", *btn, cast(s32) it_index) selected.* = cast(u8) it_index;
|
||||
n += 1;
|
||||
}
|
||||
return inside.y + ((n + cols - 1) / cols) * block;
|
||||
}
|
||||
|
||||
TILING_AXIS_NAMES :: string.["+ X", "+ Z", "- X", "- Z", "+ Y", "- Y"];
|
||||
|
||||
@ -485,53 +374,6 @@ get_tiling_camera_target :: () -> Vector3 {
|
||||
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);
|
||||
@ -541,13 +383,17 @@ get_tiling_neighbor_trile :: () -> *Trile {
|
||||
}
|
||||
|
||||
draw_trile_editor :: () {
|
||||
create_set_cam_rendering_task(get_trile_editor_camera(), 0.0);
|
||||
w := New(World,, temp);
|
||||
create_sky_rendering_task(*w.conf);
|
||||
create_trixel_rendering_task(editor_current_trile, *colorMuls);
|
||||
// A trile is drawn in the light of the world it will sit in.
|
||||
environment := New(Environment,, temp);
|
||||
curworld := get_current_world();
|
||||
if curworld.valid environment = *curworld.world.environment;
|
||||
|
||||
view := add_view(.{camera = get_trile_editor_camera(), environment = environment, draw_world = false});
|
||||
mesh, ok := get_trile_mesh(editor_current_trile.name);
|
||||
if ok draw_trile(view, mesh, .{}, 0);
|
||||
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);
|
||||
neighbor, neighbor_ok := get_trile_mesh(get_tiling_neighbor_trile().name);
|
||||
if neighbor_ok draw_trile(view, neighbor, get_tiling_world_offset(), xx tiling_orientation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -643,7 +489,7 @@ draw_trile_editor_ui :: (theme: *GR.Overall_Theme) {
|
||||
// View mode buttons — bottom center of the 3D viewport.
|
||||
btn_w := 11.0 * vw;
|
||||
btn_h := cast(float) ui_h(4, 0);
|
||||
bar_w := btn_w * 5.0;
|
||||
bar_w := btn_w * 3.0;
|
||||
bar_x := 100.0 * vw / 2.0 - bar_w / 2.0;
|
||||
bar_y := 100.0 * vh - btn_h - 1.5 * vh;
|
||||
|
||||
@ -653,14 +499,6 @@ draw_trile_editor_ui :: (theme: *GR.Overall_Theme) {
|
||||
|
||||
r2 : GR.Rect;
|
||||
r2.x = bar_x; r2.y = bar_y; r2.w = btn_w; r2.h = btn_h;
|
||||
if keybind_button(r2, "Lit", .TRIXEL_VIEW_LIT, *t_button_selectable(theme, trixel_view_mode == 0)) then trixel_view_mode = 0;
|
||||
r2.x += btn_w;
|
||||
if keybind_button(r2, "Normals", .TRIXEL_VIEW_NORMALS, *t_button_selectable(theme, trixel_view_mode == 1)) then trixel_view_mode = 1;
|
||||
r2.x += btn_w;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -65,9 +65,9 @@ render_thumbnail :: (trile: *Trile, out: *[THUMB_SIZE * THUMB_SIZE * 4] u8) {
|
||||
|
||||
for 0..199 {
|
||||
if ix >= 0 && ix < 16 && iy >= 0 && iy < 16 && iz >= 0 && iz < 16 {
|
||||
if !trile.trixels[ix][iy][iz].empty {
|
||||
if trile.trixels[ix][iy][iz] != 0 {
|
||||
hit = true;
|
||||
hc = trile.trixels[ix][iy][iz].material.color;
|
||||
hc = swatch_color(trile.trixels[ix][iy][iz]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -106,9 +106,7 @@ render_thumbnail :: (trile: *Trile, out: *[THUMB_SIZE * THUMB_SIZE * 4] u8) {
|
||||
}
|
||||
|
||||
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);
|
||||
texture_update(g_thumbnail_atlas.tex, g_thumbnail_atlas_buf);
|
||||
}
|
||||
|
||||
#scope_export
|
||||
@ -147,7 +145,7 @@ update_trile_thumbnail :: (name: string) {
|
||||
render_thumbnail(trile, *thumb);
|
||||
blit_slot(*thumb, slot);
|
||||
|
||||
if g_thumbnail_atlas.tex.id != INVALID_ID {
|
||||
if g_thumbnail_atlas.tex.id != 0 {
|
||||
upload_atlas();
|
||||
}
|
||||
}
|
||||
@ -167,12 +165,5 @@ init_trile_thumbnails :: () {
|
||||
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();
|
||||
g_thumbnail_atlas.tex = texture_create(xx ATLAS_SIZE, xx ATLAS_SIZE, g_thumbnail_atlas_buf);
|
||||
}
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
// EDITOR_MARKER :: "pack.animation"; // optional, editor-only billboard
|
||||
// } @Entity
|
||||
// entity_tick :: (using foo: *Foo, dt: float) {} // optional
|
||||
// entity_draw :: (foo: *Foo) {} // optional
|
||||
// entity_draw :: (foo: *Foo, view: View_Id) {} // optional
|
||||
//
|
||||
// Fields of type float, s32, bool, string or Vector3 are editable and saved;
|
||||
// @Slider / @Color notes pick the editor widget.
|
||||
//
|
||||
// Each frame the game calls tick_entities, then tick_entity_emitters, then
|
||||
// add_entity_render_tasks. The level editor calls the last two only: it shows
|
||||
// draw_entities. The level editor calls the last two only: it shows
|
||||
// entities and their particles without running their game logic.
|
||||
|
||||
#scope_export
|
||||
@ -131,7 +131,7 @@ free_all_entities :: (world: *World) {
|
||||
|
||||
// Concrete per-type overloads in game code take precedence over these.
|
||||
entity_tick :: (e: *$T/Entity, dt: float) {}
|
||||
entity_draw :: (e: *$T/Entity) { draw_entity_parts(e); }
|
||||
entity_draw :: (e: *$T/Entity, view: View_Id) { draw_entity_parts(e, view); }
|
||||
|
||||
tick_entities :: (world: *World, dt: float) {
|
||||
for e: world.entities entity_dispatch_tick(e, dt);
|
||||
@ -141,8 +141,8 @@ entity_dispatch_tick :: (e: *Entity, dt: float) {
|
||||
#insert #run,stallable gen_entity_dispatch("entity_tick(cast(*%)e, dt)");
|
||||
}
|
||||
|
||||
entity_dispatch_draw :: (e: *Entity) {
|
||||
#insert #run,stallable gen_entity_dispatch("entity_draw(cast(*%)e)");
|
||||
entity_dispatch_draw :: (e: *Entity, view: View_Id) {
|
||||
#insert #run,stallable gen_entity_dispatch("entity_draw(cast(*%)e, view)");
|
||||
}
|
||||
|
||||
// Dispatches a call on the entity's concrete type. '%' in 'call' becomes the type
|
||||
@ -182,56 +182,28 @@ tick_entity_emitters :: (world: *World, dt: float) {
|
||||
}
|
||||
}
|
||||
|
||||
// Once per frame, from the game and from the editor. Trile draws are batched per
|
||||
// (trile, chunk) and flushed as TRILE_DYNAMIC tasks at the end.
|
||||
add_entity_render_tasks :: (world: *World) {
|
||||
array_reset_keeping_memory(*entity_trile_batches);
|
||||
for e: world.entities entity_dispatch_draw(e);
|
||||
for *batch: entity_trile_batches {
|
||||
task : Rendering_Task_Trile_Dynamic;
|
||||
task.trile = batch.trile;
|
||||
task.positions = batch.positions;
|
||||
task.chunk_key = batch.chunk_key;
|
||||
task.worldConf = *world.conf;
|
||||
add_rendering_task(task);
|
||||
}
|
||||
// Once per frame, from the game and from the editor.
|
||||
draw_entities :: (view: View_Id, world: *World) {
|
||||
for e: world.entities entity_dispatch_draw(e, view);
|
||||
}
|
||||
|
||||
entity_draw_trile :: (e: *Entity, trile: string, offset: Vector3, orientation: u8 = 0) {
|
||||
pos := entity_trile_point(e, offset);
|
||||
ori := compose_orientations(e.orientation, orientation);
|
||||
key := world_to_chunk_coord(cast(s32) floor(pos.x), cast(s32) floor(pos.y), cast(s32) floor(pos.z));
|
||||
instance := Vector4.{pos.x, pos.y, pos.z, cast(float) ori};
|
||||
|
||||
for *batch: entity_trile_batches {
|
||||
if batch.trile == trile && batch.chunk_key == key {
|
||||
array_add(*batch.positions, instance);
|
||||
return;
|
||||
}
|
||||
}
|
||||
batch : Entity_Trile_Batch;
|
||||
batch.trile = trile;
|
||||
batch.chunk_key = key;
|
||||
batch.positions.allocator = temp;
|
||||
array_add(*batch.positions, instance);
|
||||
array_add(*entity_trile_batches, batch);
|
||||
entity_draw_trile :: (e: *Entity, view: View_Id, trile: string, offset: Vector3, orientation: u8 = 0) {
|
||||
mesh, ok := get_trile_mesh(trile);
|
||||
if !ok return;
|
||||
draw_trile(view, mesh, entity_trile_point(e, offset), compose_orientations(e.orientation, orientation));
|
||||
}
|
||||
|
||||
entity_draw_billboard :: (e: *Entity, animation: string, offset: Vector3, frame: s32 = 0) {
|
||||
entity_draw_billboard :: (e: *Entity, view: View_Id, animation: string, offset: Vector3, frame: s32 = 0) {
|
||||
anim := get_animation_from_string(animation);
|
||||
if anim == null return;
|
||||
task : Rendering_Task_Billboard;
|
||||
task.position = entity_point(e, offset);
|
||||
task.animation = anim;
|
||||
task.frame = frame;
|
||||
add_rendering_task(task);
|
||||
draw_animation_frame(view, anim, frame, entity_point(e, offset));
|
||||
}
|
||||
|
||||
draw_entity_parts :: (e: *Entity) {
|
||||
draw_entity_parts :: (e: *Entity, view: View_Id) {
|
||||
for part: get_entity_parts(e.type) {
|
||||
if part.kind == {
|
||||
case .TRILE; entity_draw_trile(e, part.trile, part.offset, part.orientation);
|
||||
case .BILLBOARD; entity_draw_billboard(e, part.animation, part.offset);
|
||||
case .TRILE; entity_draw_trile(e, view, part.trile, part.offset, part.orientation);
|
||||
case .BILLBOARD; entity_draw_billboard(e, view, part.animation, part.offset);
|
||||
case .EMITTER; // tick_entity_emitters handles these
|
||||
}
|
||||
}
|
||||
@ -308,14 +280,6 @@ entity_saved_members :: (type: Type) -> []Type_Info_Struct_Member {
|
||||
return result;
|
||||
}
|
||||
|
||||
Entity_Trile_Batch :: struct {
|
||||
trile : string;
|
||||
chunk_key : Chunk_Key;
|
||||
positions : [..]Vector4;
|
||||
}
|
||||
|
||||
entity_trile_batches : [..]Entity_Trile_Batch;
|
||||
|
||||
#if FLAG_TEST_ENGINE {
|
||||
// The two placement helpers use different pivots, and getting them the wrong
|
||||
// way round only shows up as parts drifting off a rotated entity, so both are
|
||||
|
||||
@ -39,11 +39,8 @@ Editor_Action :: enum {
|
||||
STUDIO_TRILE;
|
||||
STUDIO_LEVEL;
|
||||
STUDIO_MATERIAL;
|
||||
STUDIO_SWATCHES;
|
||||
// Trile editor — view modes
|
||||
TRIXEL_VIEW_LIT;
|
||||
TRIXEL_VIEW_NORMALS;
|
||||
TRIXEL_VIEW_ALBEDO;
|
||||
TRIXEL_VIEW_MIXED;
|
||||
TRIXEL_VIEW_TILE;
|
||||
// Trile editor — tiling controls
|
||||
TRIXEL_TILING_AXIS;
|
||||
@ -214,10 +211,7 @@ set_default_bindings :: () {
|
||||
set(.STUDIO_TRILE, cast(Key_Code) #char "1", ctrl = true);
|
||||
set(.STUDIO_LEVEL, cast(Key_Code) #char "2", ctrl = true);
|
||||
set(.STUDIO_MATERIAL, cast(Key_Code) #char "3", ctrl = true);
|
||||
set(.TRIXEL_VIEW_LIT, cast(Key_Code) #char "5");
|
||||
set(.TRIXEL_VIEW_NORMALS, cast(Key_Code) #char "6");
|
||||
set(.TRIXEL_VIEW_ALBEDO, cast(Key_Code) #char "7");
|
||||
set(.TRIXEL_VIEW_MIXED, cast(Key_Code) #char "8");
|
||||
set(.STUDIO_SWATCHES, cast(Key_Code) #char "4", ctrl = true);
|
||||
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");
|
||||
|
||||
39
src/main.jai
39
src/main.jai
@ -35,7 +35,6 @@ FLAG_USE_TEST_GAME :: FLAG_TEST_ENGINE || FLAG_TEST_EXE_ENGINE;
|
||||
#load "rendering/rendering.jai";
|
||||
#load "input/hotkeys.jai";
|
||||
#load "ui/ui.jai";
|
||||
#load "editor/rdm_disk.jai";
|
||||
#if !FLAG_RELEASE_BUILD { #load "editor/editor.jai"; }
|
||||
#load "time.jai";
|
||||
#load "events.jai";
|
||||
@ -51,7 +50,6 @@ FLAG_USE_TEST_GAME :: FLAG_TEST_ENGINE || FLAG_TEST_EXE_ENGINE;
|
||||
#load "assets/asset_manager.jai";
|
||||
#load "settings_menu.jai";
|
||||
#load "loading_screen.jai";
|
||||
#load "ui/demo.jai";
|
||||
|
||||
#if FLAG_USE_TEST_GAME {
|
||||
#load "../test_game/game.jai";
|
||||
@ -68,11 +66,7 @@ V_MAJOR :: 0;
|
||||
V_MINOR :: 7;
|
||||
|
||||
state: struct {
|
||||
pass_action_clear : sg_pass_action;
|
||||
pass_action_clear_gbuf : sg_pass_action;
|
||||
pass_action : sg_pass_action;
|
||||
dpi_scale : float;
|
||||
fons : *FONScontext;
|
||||
font_default : Ui_Font;
|
||||
};
|
||||
|
||||
@ -102,15 +96,6 @@ round_pow2 :: (v: float) -> s32 {
|
||||
debug_font : *Font;
|
||||
|
||||
init :: () {
|
||||
sg_setup(*(sg_desc.{
|
||||
environment = cast,force(sg_environment) sglue_environment(),
|
||||
logger = .{ func = slog_func },
|
||||
attachments_pool_size = 64,
|
||||
buffer_pool_size = 1024,
|
||||
}));
|
||||
sgl_setup(*(sgl_desc_t.{
|
||||
logger = .{ func = slog_func },
|
||||
}));
|
||||
sfetch_setup(*(sfetch_desc_t.{
|
||||
max_requests = 128,
|
||||
num_channels = 2,
|
||||
@ -128,18 +113,7 @@ init :: () {
|
||||
stm_setup();
|
||||
state.dpi_scale = sapp_dpi_scale();
|
||||
atlas_dim := round_pow2(1024.0 * state.dpi_scale);
|
||||
fons_context := sfons_create(*(sfons_desc_t.{
|
||||
width = atlas_dim,
|
||||
height = atlas_dim,
|
||||
}));
|
||||
state.fons = fons_context;
|
||||
state.font_default.fons_font = FONS_INVALID;
|
||||
create_pipelines();
|
||||
|
||||
state.pass_action_clear.colors[0] = .{ load_action = .CLEAR, clear_value = .{ r = 0, g = 0, b = 0, a = 0 } };
|
||||
state.pass_action_clear_gbuf.colors[0] = .{ load_action = .CLEAR, clear_value = .{ r = 0, g = 0, b = 1000, a = 0 } };
|
||||
state.pass_action_clear_gbuf.colors[2] = .{ load_action = .CLEAR, clear_value = .{ r = 0, g = 0, b = 0, a = 0 } };
|
||||
state.pass_action.colors[0] = .{ load_action = .LOAD };
|
||||
text_init(atlas_dim);
|
||||
|
||||
g_mixer.paused = true;
|
||||
|
||||
@ -159,9 +133,6 @@ init :: () {
|
||||
}
|
||||
|
||||
init_after_core :: () {
|
||||
init_plane_textures();
|
||||
init_brdf_lut();
|
||||
|
||||
add_font_from_pack("boot", "DroidSerif-Regular.ttf");
|
||||
ui_init_font_fields(*state.font_default);
|
||||
init_ui();
|
||||
@ -182,8 +153,6 @@ init_after_core :: () {
|
||||
init_keybinds();
|
||||
init_settings_menu();
|
||||
}
|
||||
init_rendering();
|
||||
load_post_process_from_pack();
|
||||
|
||||
audio_init();
|
||||
|
||||
@ -197,7 +166,6 @@ init_after_core :: () {
|
||||
// #if UNCAPPED_FRAMES then sapp_glx_swapinterval(0);
|
||||
}
|
||||
|
||||
is_in_reflection_pass : bool = false;
|
||||
|
||||
delta_time_accumulator : float64 = 0;
|
||||
|
||||
@ -219,7 +187,6 @@ frame :: () {
|
||||
if show_loading_screen() {
|
||||
input_per_frame_event_and_flag_update();
|
||||
if init_after_core_done {
|
||||
fonsClearState(state.fons);
|
||||
draw_loading_screen();
|
||||
tick_ui();
|
||||
ui_pass();
|
||||
@ -238,7 +205,6 @@ frame :: () {
|
||||
g_mixer.paused = false;
|
||||
}
|
||||
|
||||
fonsClearState(state.fons);
|
||||
|
||||
add_frame_profiling_point("After loading logic");
|
||||
|
||||
@ -266,7 +232,6 @@ frame :: () {
|
||||
delta_time_accumulator -= (1.0/480.0);
|
||||
}
|
||||
}
|
||||
fonsClearState(state.fons);
|
||||
for event: Input.events_this_frame {
|
||||
GR.getrect_handle_event(event);
|
||||
}
|
||||
@ -289,7 +254,6 @@ frame :: () {
|
||||
draw_editor();
|
||||
}
|
||||
|
||||
add_particle_render_tasks();
|
||||
add_frame_profiling_point("After editor draw");
|
||||
render();
|
||||
add_frame_profiling_point("After rendering");
|
||||
@ -308,7 +272,6 @@ frame :: () {
|
||||
cleanup :: () {
|
||||
log_info("Cleanup called....");
|
||||
audio_cleanup();
|
||||
sg_shutdown();
|
||||
}
|
||||
|
||||
get_window_size :: () -> (s32, s32) {
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
#load "hacks.jai";
|
||||
#load "console_commands.jai";
|
||||
#load "entity_types.jai";
|
||||
#load "shaderload.jai";
|
||||
|
||||
endframe_modified := false;
|
||||
pointerimage_modified := false;
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
#scope_file
|
||||
|
||||
get_shader_paths :: () -> []string {
|
||||
util :: #import "File_Utilities";
|
||||
return util.file_list("./src/shaders/jai");
|
||||
}
|
||||
|
||||
#scope_export
|
||||
|
||||
add_shaders_to_workspace :: (w: Workspace) {
|
||||
file :: #import "File";
|
||||
paths := get_shader_paths();
|
||||
for paths {
|
||||
add_build_file(file.get_absolute_path(it), w);
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,7 @@
|
||||
// The 24 axis-aligned cube rotations, encoded as 'face * 4 + twist' exactly as
|
||||
// the trile shaders decode them (see get_orientation_matrix in
|
||||
// shader_trile_shadow.glsl). Everything here mirrors that decode, so a rotation
|
||||
// applied to a position on the CPU lines up with the geometry the GPU draws.
|
||||
//
|
||||
// Note the shaders build their mat3s from columns, which makes each of their
|
||||
// rot_* helpers the transpose of the usual form. The matrices below are the
|
||||
// effective row-major operators (v' = M * v), so they match what the shader
|
||||
// actually does rather than what its helper names suggest.
|
||||
// The 24 axis-aligned cube rotations, encoded as 'face * 4 + twist'. These
|
||||
// matrices are the reference: the renderer has to turn an orientation into
|
||||
// exactly this rotation, so that placement on the CPU lines up with what is
|
||||
// drawn. They are row-major operators (v' = M * v).
|
||||
|
||||
ORIENTATION_COUNT :: 24;
|
||||
|
||||
|
||||
@ -97,16 +97,14 @@ tick_emitter_instance :: (inst: *Particle_Emitter_Instance, dt: float) {
|
||||
}
|
||||
}
|
||||
|
||||
add_particle_render_tasks :: () {
|
||||
// Live particles are global, so the game and each editor view draw them into
|
||||
// their own view.
|
||||
draw_live_particles :: (view: View_Id) {
|
||||
Batch :: struct {
|
||||
anim_name : string;
|
||||
blend_mode : Particle_Blend_Mode;
|
||||
anim : *Animation;
|
||||
sheet : sg_image;
|
||||
count : s32;
|
||||
pos_size : *[MAX_PARTICLES]Vector4;
|
||||
uv_rects : *[MAX_PARTICLES]Vector4;
|
||||
colors : *[MAX_PARTICLES]Vector4;
|
||||
particles : [..]Particle_Instance;
|
||||
}
|
||||
|
||||
batches : [..] Batch;
|
||||
@ -133,67 +131,33 @@ add_particle_render_tasks :: () {
|
||||
anim := get_animation_from_string(def.animation_name);
|
||||
if anim == null then continue;
|
||||
if anim.frames.count == 0 then continue;
|
||||
array_add(*batches, .{
|
||||
anim_name = def.animation_name,
|
||||
blend_mode = def.blend_mode,
|
||||
anim = anim,
|
||||
sheet = anim.sheet,
|
||||
pos_size = New([MAX_PARTICLES]Vector4,, temp),
|
||||
uv_rects = New([MAX_PARTICLES]Vector4,, temp),
|
||||
colors = New([MAX_PARTICLES]Vector4,, temp),
|
||||
});
|
||||
batch = *batches[batches.count - 1];
|
||||
batch = array_add(*batches);
|
||||
batch.anim_name = def.animation_name;
|
||||
batch.blend_mode = def.blend_mode;
|
||||
batch.anim = anim;
|
||||
batch.particles.allocator = temp;
|
||||
}
|
||||
|
||||
if batch.count >= MAX_PARTICLES then continue;
|
||||
|
||||
t := p.age / p.lifetime;
|
||||
size := def.size_start + (def.size_end - def.size_start) * t;
|
||||
col := lerp_color(def.color_start, def.color_end, t);
|
||||
|
||||
idx := batch.count;
|
||||
batch.pos_size.*[idx] = .{p.position.x, p.position.y, p.position.z, size};
|
||||
|
||||
anim := batch.anim;
|
||||
frame_count := anim.frames.count;
|
||||
frame := cast(s32)(t * cast(float)frame_count);
|
||||
if frame < 0 then frame = 0;
|
||||
if frame >= frame_count then frame = cast(s32)(frame_count - 1);
|
||||
frame := clamp(cast(s32)(t * cast(float)anim.frames.count), 0, cast(s32)(anim.frames.count - 1));
|
||||
f := anim.frames[frame];
|
||||
batch.uv_rects.*[idx] = .{
|
||||
cast(float)f.x / cast(float)anim.sheet_w,
|
||||
cast(float)f.y / cast(float)anim.sheet_h,
|
||||
cast(float)f.w / cast(float)anim.sheet_w,
|
||||
cast(float)f.h / cast(float)anim.sheet_h,
|
||||
};
|
||||
|
||||
batch.colors.*[idx] = col;
|
||||
batch.count += 1;
|
||||
array_add(*batch.particles, .{
|
||||
position = p.position,
|
||||
size = def.size_start + (def.size_end - def.size_start) * t,
|
||||
uv_rect = .{
|
||||
cast(float)f.x / cast(float)anim.sheet_w,
|
||||
cast(float)f.y / cast(float)anim.sheet_h,
|
||||
cast(float)f.w / cast(float)anim.sheet_w,
|
||||
cast(float)f.h / cast(float)anim.sheet_h,
|
||||
},
|
||||
color = lerp_color(def.color_start, def.color_end, t),
|
||||
});
|
||||
}
|
||||
|
||||
buf_task := New(Rendering_Task_Particles_Buffer,, temp);
|
||||
total_count : s32 = 0;
|
||||
|
||||
for *b: batches {
|
||||
if b.count <= 0 then continue;
|
||||
|
||||
instance_offset := total_count;
|
||||
memcpy(*buf_task.pos_size[instance_offset], cast(*void)b.pos_size, b.count * size_of(Vector4));
|
||||
memcpy(*buf_task.uv_rects[instance_offset], cast(*void)b.uv_rects, b.count * size_of(Vector4));
|
||||
memcpy(*buf_task.colors[instance_offset], cast(*void)b.colors, b.count * size_of(Vector4));
|
||||
total_count += b.count;
|
||||
|
||||
draw_task : Rendering_Task_Particles;
|
||||
draw_task.count = b.count;
|
||||
draw_task.instance_offset = instance_offset;
|
||||
draw_task.blend_mode = b.blend_mode;
|
||||
draw_task.sheet = b.sheet;
|
||||
add_rendering_task(draw_task);
|
||||
}
|
||||
|
||||
if total_count > 0 {
|
||||
buf_task.total_count = total_count;
|
||||
add_rendering_task(buf_task.*);
|
||||
for batches {
|
||||
blend := ifx it.blend_mode == .ADDITIVE then Blend_Mode.ADDITIVE else .ALPHA;
|
||||
draw_particles(view, it.anim.sheet, blend, it.particles);
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +166,7 @@ particle_water_height :: () -> (has_water: bool, height: float) {
|
||||
if in_editor_view && !editor_shows_water() return false, 0;
|
||||
}
|
||||
curworld := get_current_world();
|
||||
if !curworld.valid return false, 0;
|
||||
if !curworld.valid || curworld.world.conf.indoor return false, 0;
|
||||
return true, effective_plane_height(*curworld.world.conf);
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
#import,dir "../../modules/sokol-jai/sokol/app"(DEBUG = !FLAG_RELEASE_BUILD);
|
||||
#import,dir "../../modules/sokol-jai/sokol/gfx"(DEBUG = !FLAG_RELEASE_BUILD);
|
||||
#import,dir "../../modules/sokol-jai/sokol/gl"(DEBUG = !FLAG_RELEASE_BUILD);
|
||||
#import,dir "../../modules/sokol-jai/sokol/glue"(DEBUG = !FLAG_RELEASE_BUILD);
|
||||
#import,dir "../../modules/sokol-jai/sokol/shape"(DEBUG = !FLAG_RELEASE_BUILD);
|
||||
#import,dir "../../modules/sokol-jai/sokol/fontstash";
|
||||
#import,dir "../../modules/sokol-jai/sokol/log"(DEBUG = !FLAG_RELEASE_BUILD);
|
||||
#import,dir "../../modules/sokol-jai/sokol/time"(DEBUG = !FLAG_RELEASE_BUILD);
|
||||
#import,dir "../../modules/sokol-jai/sokol/fetch"(DEBUG = !FLAG_RELEASE_BUILD);
|
||||
|
||||
@ -33,10 +33,26 @@ animation_player_tick :: (player: *Animation_Player) {
|
||||
}
|
||||
}
|
||||
|
||||
animation_draw :: (player: *Animation_Player, position: Vector3, flipX: bool = false, flipY: bool = false, faceDir : Vector3 = .{-100, -100, -100}) {
|
||||
animation_draw :: (view: View_Id, player: *Animation_Player, position: Vector3, flip_x := false, face := BILLBOARD_FACE_CAMERA) {
|
||||
animation_player_tick(player);
|
||||
if player.current_animation == null then return;
|
||||
create_billboard_rendering_task(position, player.current_animation, player.current_frame, flipX, flipY, faceDir);
|
||||
draw_animation_frame(view, player.current_animation, player.current_frame, position, flip_x, face);
|
||||
}
|
||||
|
||||
// Sprites are 16 pixels to a world unit.
|
||||
draw_animation_frame :: (view: View_Id, anim: *Animation, frame_index: s32, position: Vector3, flip_x := false, face := BILLBOARD_FACE_CAMERA) {
|
||||
frame := anim.frames[frame_index];
|
||||
uv := Vector4.{
|
||||
cast(float) frame.x / anim.sheet_w,
|
||||
cast(float) frame.y / anim.sheet_h,
|
||||
cast(float) frame.w / anim.sheet_w,
|
||||
cast(float) frame.h / anim.sheet_h,
|
||||
};
|
||||
if flip_x {
|
||||
uv.x += uv.z;
|
||||
uv.z = -uv.z;
|
||||
}
|
||||
draw_billboard(view, anim.sheet, uv, .{cast(float)(frame.w / 16), cast(float)(frame.h / 16)}, position, face);
|
||||
}
|
||||
|
||||
animation_set :: (player: *Animation_Player, animation: string) {
|
||||
@ -70,7 +86,7 @@ Frame :: struct {
|
||||
|
||||
Animation :: struct {
|
||||
name : string;
|
||||
sheet : sg_image;
|
||||
sheet : Texture;
|
||||
sheet_w : s32;
|
||||
sheet_h : s32;
|
||||
frames : [..]Frame;
|
||||
|
||||
@ -1,147 +0,0 @@
|
||||
Arb_Tri :: struct {
|
||||
pos : [3]Vector3;
|
||||
col : [3]Vector4;
|
||||
uv : [3]Vector2;
|
||||
}
|
||||
|
||||
Arb_Draw_Command_Type :: enum {
|
||||
INVALID;
|
||||
DRAW_TEXT;
|
||||
FLUSH_TRI;
|
||||
SET_TEXTURE;
|
||||
PREPARE_TEXT;
|
||||
FONT_BOUNDARY;
|
||||
QUAD_OCCLUDER;
|
||||
REMOVE_TEXTURE;
|
||||
SET_SCISSOR;
|
||||
REMOVE_SCISSOR;
|
||||
}
|
||||
|
||||
Arb_Draw_Command :: struct {
|
||||
type : Arb_Draw_Command_Type = .INVALID;
|
||||
|
||||
// for triangles
|
||||
tri_offset : int = 0;
|
||||
tri_count : int = 0;
|
||||
texture : *Ui_Texture;
|
||||
|
||||
// for text
|
||||
layer: s32 = 0;
|
||||
|
||||
scissor: Ui_Rect;
|
||||
|
||||
}
|
||||
|
||||
Arb_Tri_State :: struct {
|
||||
active : bool = false;
|
||||
trilist : [..]Arb_Tri;
|
||||
command_list : [..]Arb_Draw_Command;
|
||||
latest_flush : int = 0;
|
||||
}
|
||||
|
||||
arbTriState : Arb_Tri_State;
|
||||
|
||||
init_arb_state :: () {
|
||||
gPipelines.arbtri.bind.images[0] = default_texture.tex;
|
||||
array_reset_keeping_memory(*arbTriState.trilist);
|
||||
array_reset_keeping_memory(*arbTriState.command_list);
|
||||
arbTriState.active = true;
|
||||
arbTriState.latest_flush = 0;
|
||||
}
|
||||
|
||||
arb_tri_command_add :: (command: Arb_Draw_Command) {
|
||||
if !arbTriState.active {
|
||||
init_arb_state();
|
||||
}
|
||||
|
||||
array_add(*arbTriState.command_list, command);
|
||||
}
|
||||
|
||||
arb_tri_add :: (tri: Arb_Tri) {
|
||||
if !arbTriState.active {
|
||||
init_arb_state();
|
||||
}
|
||||
|
||||
array_add(*arbTriState.trilist, tri);
|
||||
}
|
||||
|
||||
transform_to_screen_x :: (coord: float) -> float {
|
||||
w, h := get_window_size();
|
||||
return (coord / cast(float) w) * 2.0 - 1.0;
|
||||
}
|
||||
|
||||
transform_to_screen_y :: (coord: float) -> float {
|
||||
w, h := get_window_size();
|
||||
return (coord / cast(float) h) * 2.0 - 1.0;
|
||||
}
|
||||
|
||||
arb_tri_flush :: () {
|
||||
if !arbTriState.active {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
arbTriState.active = false;
|
||||
|
||||
w, h := get_window_size();
|
||||
inv_w := 2.0 / cast(float) w;
|
||||
inv_h := 2.0 / cast(float) h;
|
||||
|
||||
for tri, i : arbTriState.trilist {
|
||||
bgn := i * 3 * 9;
|
||||
for 0..2 {
|
||||
gArbtriMem[bgn + it * 9 + 0] = tri.pos[it].x * inv_w - 1.0;
|
||||
gArbtriMem[bgn + it * 9 + 1] = -(tri.pos[it].y * inv_h - 1.0);
|
||||
gArbtriMem[bgn + it * 9 + 2] = 0;
|
||||
gArbtriMem[bgn + it * 9 + 3] = tri.col[it].x;
|
||||
gArbtriMem[bgn + it * 9 + 4] = tri.col[it].y;
|
||||
gArbtriMem[bgn + it * 9 + 5] = tri.col[it].z;
|
||||
gArbtriMem[bgn + it * 9 + 6] = tri.col[it].w;
|
||||
gArbtriMem[bgn + it * 9 + 7] = tri.uv[it].x;
|
||||
gArbtriMem[bgn + it * 9 + 8] = tri.uv[it].y;
|
||||
}
|
||||
}
|
||||
|
||||
upload_size := arbTriState.trilist.count * 3 * 9 * size_of(float);
|
||||
if upload_size > 0 {
|
||||
sg_update_buffer(gPipelines.arbtri.bind.vertex_buffers[0], *(sg_range.{ ptr = gArbtriMem.data, size = xx upload_size }));
|
||||
}
|
||||
|
||||
flush_arb_commands();
|
||||
}
|
||||
|
||||
debug_arb_flush : bool : false;
|
||||
|
||||
layer : s32 = 0;
|
||||
|
||||
flush_arb_commands :: () {
|
||||
sfons_flush(state.fons); // All the text has been drawn, now flush it to the atlas.
|
||||
layer = 0;
|
||||
if debug_arb_flush then print(" --- !BEGIN FLUSH! ---- \n");
|
||||
for arbTriState.command_list {
|
||||
if debug_arb_flush then print("[command] %\n", it.type);
|
||||
if it.type == {
|
||||
case .SET_TEXTURE;
|
||||
gPipelines.arbtri.bind.images[0] = it.texture.tex;
|
||||
gCurrentTexture = it.texture;
|
||||
case .REMOVE_TEXTURE;
|
||||
gCurrentTexture = null;
|
||||
case .FLUSH_TRI;
|
||||
sg_apply_pipeline(gPipelines.arbtri.pipeline);
|
||||
sg_apply_bindings(*gPipelines.arbtri.bind);
|
||||
sg_draw(xx (it.tri_offset * 3), xx (it.tri_count * 3), 1);
|
||||
case .PREPARE_TEXT;
|
||||
case .SET_SCISSOR;
|
||||
s := it.scissor;
|
||||
w,h := get_window_size();
|
||||
sgl_viewport(0,0,w,h,true);
|
||||
sg_apply_scissor_rect(s.x, s.y, s.w, s.h, true);
|
||||
case .REMOVE_SCISSOR;
|
||||
w,h := get_window_size();
|
||||
sg_apply_scissor_rect(0, 0, w, h, true);
|
||||
case .DRAW_TEXT;
|
||||
sgl_draw_layer(it.layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,155 +0,0 @@
|
||||
#scope_export
|
||||
|
||||
Render_Command_Buckets :: struct {
|
||||
setup : [..]*Render_Command;
|
||||
shadow : [..]*Render_Command;
|
||||
reflection : [..]*Render_Command;
|
||||
main : [..]*Render_Command;
|
||||
gbuffer : [..]*Render_Command;
|
||||
ui : [..]*Render_Command;
|
||||
}
|
||||
|
||||
render_command_buckets : Render_Command_Buckets;
|
||||
|
||||
Render_Command_Type :: enum {
|
||||
INVALID;
|
||||
DRAW_SKY;
|
||||
SET_CAMERA;
|
||||
DRAW_GROUND;
|
||||
ADD_TRILE_POSITIONS;
|
||||
ADD_TRILE_POSITIONS_F32;
|
||||
DRAW_TRILE_POSITIONS;
|
||||
ADD_TRILE_RDM_POSITION;
|
||||
DRAW_TRILE_RDM;
|
||||
UPDATE_TRIXELS;
|
||||
DRAW_TRIXELS;
|
||||
SET_LIGHT;
|
||||
DRAW_BILLBOARD;
|
||||
UPDATE_PARTICLES;
|
||||
DRAW_PARTICLES;
|
||||
}
|
||||
|
||||
Render_Command :: struct {
|
||||
type: Render_Command_Type = .INVALID;
|
||||
}
|
||||
|
||||
Render_Command_Sky :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .DRAW_SKY;
|
||||
worldConfig : *World_Config;
|
||||
}
|
||||
|
||||
Render_Command_Set_Light :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .SET_LIGHT;
|
||||
worldConfig : *World_Config;
|
||||
}
|
||||
|
||||
Render_Command_Add_Trile_Positions :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .ADD_TRILE_POSITIONS;
|
||||
positions : []Trile_Instance;
|
||||
chunk : Chunk_Key;
|
||||
}
|
||||
|
||||
// Like Add_Trile_Positions, but takes float world-space positions directly
|
||||
// (xyz = position, w = orientation 0..23). Appends into the same instance
|
||||
// buffer / offset list, so draws go through Render_Command_Draw_Trile_Positions.
|
||||
Render_Command_Add_Trile_Positions_F32 :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .ADD_TRILE_POSITIONS_F32;
|
||||
positions : []Vector4;
|
||||
}
|
||||
|
||||
Render_Command_Draw_Trile_Positions :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .DRAW_TRILE_POSITIONS;
|
||||
trile : string;
|
||||
chunk_key : Chunk_Key;
|
||||
amount : s32;
|
||||
conf : *World_Config;
|
||||
preview_mode : s32 = 0; // 0=normal, 1=add preview (blue), 2=delete preview (red)
|
||||
offset_index : s32 = 0; // index into trile_offsets, assigned at task-conversion time
|
||||
lod_index : s32 = 0;
|
||||
}
|
||||
|
||||
Render_Command_Add_Trile_RDM_Position :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .ADD_TRILE_RDM_POSITION;
|
||||
position : Vector4;
|
||||
}
|
||||
|
||||
Render_Command_Draw_Trile_RDM :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .DRAW_TRILE_RDM;
|
||||
trile : string;
|
||||
conf : *World_Config;
|
||||
atlas_rect : Vector4;
|
||||
offset_index : s32 = 0;
|
||||
}
|
||||
|
||||
Render_Command_Update_Trixels :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .UPDATE_TRIXELS;
|
||||
trile : *Trile;
|
||||
colMultipliers : *[16][16][16]Vector3;
|
||||
is_secondary : bool;
|
||||
}
|
||||
|
||||
Render_Command_Draw_Billboard :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .DRAW_BILLBOARD;
|
||||
position : Vector3;
|
||||
animation : *Animation;
|
||||
frame : s32;
|
||||
flipX : bool;
|
||||
flipY : bool;
|
||||
faceDir : Vector3 = .{-100, -100, -100};
|
||||
}
|
||||
|
||||
Render_Command_Draw_Trixels :: struct {
|
||||
#as using c : Render_Command;
|
||||
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_Update_Particles :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .UPDATE_PARTICLES;
|
||||
total_count : s32;
|
||||
pos_size : [MAX_PARTICLES]Vector4;
|
||||
uv_rects : [MAX_PARTICLES]Vector4;
|
||||
colors : [MAX_PARTICLES]Vector4;
|
||||
}
|
||||
|
||||
Render_Command_Draw_Particles :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .DRAW_PARTICLES;
|
||||
count : s32;
|
||||
instance_offset : s32;
|
||||
blend_mode : Particle_Blend_Mode;
|
||||
sheet : sg_image;
|
||||
}
|
||||
|
||||
Render_Command_Draw_Ground :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .DRAW_GROUND;
|
||||
worldConfig : *World_Config;
|
||||
}
|
||||
|
||||
Render_Command_Set_Camera :: struct {
|
||||
#as using c : Render_Command;
|
||||
c.type = .SET_CAMERA;
|
||||
camera: Camera;
|
||||
}
|
||||
|
||||
process_command_buckets :: () {
|
||||
backend_process_command_buckets();
|
||||
}
|
||||
|
||||
#scope_file
|
||||
#load "backend_sokol.jai";
|
||||
|
||||
@ -1,775 +0,0 @@
|
||||
camera: Camera;
|
||||
|
||||
trixel_count : s32 = 0;
|
||||
trixel_secondary_count : s32 = 0;
|
||||
trixel_secondary_vbuf : sg_buffer;
|
||||
trixel_view_mode : s32 = 0;
|
||||
bypass_postprocess : bool = false;
|
||||
bypass_shadows : bool = false;
|
||||
bypass_reflections : bool = false;
|
||||
|
||||
trile_offsets : [..]s32;
|
||||
trile_rdm_offsets : [..]s32;
|
||||
|
||||
current_world_config : *World_Config = null;
|
||||
in_shadowmap_pass : bool = false;
|
||||
in_reflection_pass : bool = false;
|
||||
in_gbuffer_pass : bool = false;
|
||||
shadow_mvp : Matrix4;
|
||||
|
||||
backend_handle_command :: (cmd: *Render_Command) {
|
||||
if cmd.type == {
|
||||
case .ADD_TRILE_POSITIONS;
|
||||
add_command := cast(*Render_Command_Add_Trile_Positions)cmd;
|
||||
backend_add_trile_positions(add_command.positions, add_command.chunk);
|
||||
case .ADD_TRILE_POSITIONS_F32;
|
||||
add_f32_command := cast(*Render_Command_Add_Trile_Positions_F32)cmd;
|
||||
backend_add_trile_positions_f32(add_f32_command.positions);
|
||||
case .DRAW_TRILE_POSITIONS;
|
||||
draw_command := cast(*Render_Command_Draw_Trile_Positions)cmd;
|
||||
backend_draw_trile_positions(draw_command.trile, draw_command.amount, draw_command.conf, draw_command.chunk_key, draw_command.preview_mode, draw_command.offset_index, draw_command.lod_index);
|
||||
case .ADD_TRILE_RDM_POSITION;
|
||||
add_command := cast(*Render_Command_Add_Trile_RDM_Position)cmd;
|
||||
backend_add_trile_rdm_position(add_command.position);
|
||||
case .DRAW_TRILE_RDM;
|
||||
draw_command := cast(*Render_Command_Draw_Trile_RDM)cmd;
|
||||
backend_draw_trile_rdm(draw_command.trile, draw_command.conf, draw_command.atlas_rect, draw_command.offset_index);
|
||||
case .DRAW_SKY;
|
||||
sky_command := cast(*Render_Command_Sky)cmd;
|
||||
backend_draw_sky(sky_command.worldConfig);
|
||||
case .SET_CAMERA;
|
||||
camera_command := cast(*Render_Command_Set_Camera)cmd;
|
||||
camera = camera_command.camera;
|
||||
case .DRAW_GROUND;
|
||||
ground_command := cast(*Render_Command_Draw_Ground)cmd;
|
||||
if in_gbuffer_pass {
|
||||
backend_draw_ground_gbuf(ground_command.worldConfig);
|
||||
} else {
|
||||
backend_draw_ground(ground_command.worldConfig);
|
||||
}
|
||||
case .UPDATE_TRIXELS;
|
||||
trixel_update_command := cast(*Render_Command_Update_Trixels)cmd;
|
||||
backend_update_trixels(trixel_update_command);
|
||||
case .DRAW_TRIXELS;
|
||||
draw_trixels_cmd := cast(*Render_Command_Draw_Trixels)cmd;
|
||||
backend_draw_trixels(draw_trixels_cmd.*);
|
||||
case .SET_LIGHT;
|
||||
set_light_command := cast(*Render_Command_Set_Light)cmd;
|
||||
current_world_config = set_light_command.worldConfig;
|
||||
case .DRAW_BILLBOARD;
|
||||
command := cast(*Render_Command_Draw_Billboard)cmd;
|
||||
if !in_gbuffer_pass {
|
||||
backend_draw_billboard(command.position, command.animation, command.frame, command.flipX, command.faceDir);
|
||||
} else {
|
||||
backend_gbuffer_draw_billboard(command.position, command.animation, command.frame, command.flipX, command.faceDir);
|
||||
}
|
||||
case .UPDATE_PARTICLES;
|
||||
update_cmd := cast(*Render_Command_Update_Particles)cmd;
|
||||
backend_update_particle_buffers(update_cmd);
|
||||
case .DRAW_PARTICLES;
|
||||
particles_cmd := cast(*Render_Command_Draw_Particles)cmd;
|
||||
backend_draw_particles(particles_cmd);
|
||||
}
|
||||
}
|
||||
|
||||
backend_update_trixels :: (cmd: Render_Command_Update_Trixels) {
|
||||
if cmd.trile == null then return;
|
||||
|
||||
trixels : [4096]Position_Color;
|
||||
count : s32 = 0;
|
||||
|
||||
for x: 0..15 {
|
||||
for y: 0..15 {
|
||||
for z: 0..15 {
|
||||
if cmd.trile.trixels[x][y][z].empty then continue;
|
||||
|
||||
trixels[count].pos.x = x * (1.0 / 16.0) + TRIXEL_SIZE_HALF;
|
||||
trixels[count].pos.y = y * (1.0 / 16.0) + TRIXEL_SIZE_HALF;
|
||||
trixels[count].pos.z = z * (1.0 / 16.0) + TRIXEL_SIZE_HALF;
|
||||
cm : Vector3 = .{1, 1, 1};
|
||||
if cmd.colMultipliers cm = (cmd.colMultipliers.*)[x][y][z];
|
||||
trixels[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;
|
||||
trixels[count].col = .{trixel_color.x, trixel_color.y, trixel_color.z, material_encode_to_float(cmd.trile.trixels[x][y][z].material)};
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
range := sg_range.{ ptr = trixels.data, size = size_of(type_of(trixels)) };
|
||||
if cmd.is_secondary {
|
||||
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 :: (cmd: Render_Command_Draw_Trixels) {
|
||||
count := ifx cmd.is_secondary then trixel_secondary_count else trixel_count;
|
||||
if count == 0 then return;
|
||||
|
||||
mvp := create_viewproj(*camera);
|
||||
vs_params : Vs_Params;
|
||||
vs_params.mvp = mvp.floats;
|
||||
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;
|
||||
wc : *World_Config = *(World_Config.{});
|
||||
world_config_to_shader_type(wc, *world_conf);
|
||||
|
||||
fs_params : Trixel_Fs_Params;
|
||||
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_bindings(*bind);
|
||||
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_fs_params, *(sg_range.{ ptr = *fs_params, size = size_of(type_of(fs_params)) }));
|
||||
sg_draw(0, 36, count);
|
||||
}
|
||||
|
||||
// @Note: We store these as Trile_Instances in the loaded world,
|
||||
// and we need to transform them to Vector4 at some point, and
|
||||
// this seems like the most convinient place to do that without
|
||||
// having to constantly allocate.
|
||||
trile_position_staging : [..]Vector4;
|
||||
|
||||
backend_add_trile_positions :: (positions : []Trile_Instance, chunk: Chunk_Key) {
|
||||
array_reset_keeping_memory(*trile_position_staging);
|
||||
for position : positions {
|
||||
array_add(*trile_position_staging, Vector4.{
|
||||
cast(float)(position.x + chunk.x * 32.0),
|
||||
cast(float)(position.y + chunk.y * 32.0),
|
||||
cast(float)(position.z + chunk.z * 32.0),
|
||||
cast(float)(position.orientation)
|
||||
});
|
||||
}
|
||||
|
||||
offset := sg_append_buffer(gPipelines.trile.bind.vertex_buffers[3], *(sg_range.{
|
||||
ptr = trile_position_staging.data,
|
||||
size = size_of(Vector4) * cast(u64)trile_position_staging.count,
|
||||
}));
|
||||
array_add(*trile_offsets, offset);
|
||||
}
|
||||
|
||||
backend_add_trile_positions_f32 :: (positions : []Vector4) {
|
||||
offset := sg_append_buffer(gPipelines.trile.bind.vertex_buffers[3], *(sg_range.{
|
||||
ptr = positions.data,
|
||||
size = size_of(Vector4) * cast(u64)positions.count,
|
||||
}));
|
||||
array_add(*trile_offsets, offset);
|
||||
}
|
||||
|
||||
backend_draw_trile_positions :: (trile : string, amount : s32, worldConf: *World_Config, chunk_key: Chunk_Key, preview_mode: s32 = 0, offset_index: s32 = 0, lod_index: s32 = 0) {
|
||||
if in_gbuffer_pass {
|
||||
backend_draw_trile_positions_gbuffer(trile, amount, worldConf, offset_index, lod_index);
|
||||
} else {
|
||||
backend_draw_trile_positions_main(trile, amount, worldConf, chunk_key, preview_mode, offset_index, lod_index);
|
||||
}
|
||||
}
|
||||
|
||||
backend_draw_trile_positions_gbuffer :: (trile : string, amount : s32, worldConf: *World_Config, offset_index: s32, lod_index: s32 = 0) {
|
||||
if offset_index >= trile_offsets.count then return;
|
||||
mvp := create_viewproj(*camera);
|
||||
view := create_lookat(*camera);
|
||||
vs_params : Gbuffer_Vs_Params;
|
||||
vs_params.mvp = mvp.floats;
|
||||
vs_params.view_matrix = view.floats;
|
||||
sg_apply_pipeline(gPipelines.gbuffer.pipeline);
|
||||
world_conf : Trile_World_Config;
|
||||
world_config_to_shader_type(worldConf, *world_conf);
|
||||
|
||||
offset := trile_offsets[offset_index];
|
||||
|
||||
trilegfx, success := get_trile_gfx(trile);
|
||||
if !success {
|
||||
log_warn("Failed to get trile: %\n", trile);
|
||||
return;
|
||||
}
|
||||
|
||||
vbuf, nbuf, cbuf : sg_buffer;
|
||||
vcount : s64;
|
||||
if lod_index == 0 {
|
||||
vbuf = trilegfx.vertex_buffer;
|
||||
nbuf = trilegfx.normal_buffer;
|
||||
cbuf = trilegfx.centre_buffer;
|
||||
vcount = trilegfx.vertex_count;
|
||||
} else {
|
||||
lod := ifx lod_index == 1 then *trilegfx.lod_4 else *trilegfx.lod_2;
|
||||
if lod.vertex_count == 0 return;
|
||||
vbuf = lod.vertex_buffer;
|
||||
nbuf = lod.normal_buffer;
|
||||
cbuf = lod.color_buffer; // unused by gbuffer shader; bound to satisfy pipeline layout
|
||||
vcount = lod.vertex_count;
|
||||
}
|
||||
|
||||
bindings : sg_bindings;
|
||||
bindings.vertex_buffers[0] = vbuf;
|
||||
bindings.vertex_buffers[1] = nbuf;
|
||||
bindings.vertex_buffers[2] = cbuf;
|
||||
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
|
||||
bindings.vertex_buffer_offsets[3] = offset;
|
||||
bindings.samplers[0] = gPipelines.trile.bind.samplers[0];
|
||||
bindings.images[0] = trilegfx.trixel_colors;
|
||||
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_gbuffer_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params))}));
|
||||
sg_draw(0, cast(s32) vcount, amount);
|
||||
}
|
||||
|
||||
backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *World_Config, chunk_key: Chunk_Key, preview_mode: s32 = 0, offset_index: s32 = 0, lod_index: s32 = 0) {
|
||||
start_frame_profiling_group("Draw trile positions");
|
||||
if offset_index >= trile_offsets.count {
|
||||
end_frame_profiling_group("Draw trile positions");
|
||||
return;
|
||||
}
|
||||
|
||||
trilegfx, success := get_trile_gfx(trile);
|
||||
if !success {
|
||||
log_warn("Failed to get trile: %\n", trile);
|
||||
return;
|
||||
}
|
||||
|
||||
offset := trile_offsets[offset_index];
|
||||
|
||||
// Pick mesh source based on LOD level. For shadow + gbuffer we keep the original pipeline
|
||||
// and just swap which buffers feed it; the shader's centre attribute is unused so we bind
|
||||
// the LOD color buffer as a placeholder to satisfy the pipeline layout.
|
||||
vbuf, nbuf, cbuf : sg_buffer;
|
||||
vcount : s64;
|
||||
if lod_index == 0 {
|
||||
vbuf = trilegfx.vertex_buffer;
|
||||
nbuf = trilegfx.normal_buffer;
|
||||
cbuf = trilegfx.centre_buffer;
|
||||
vcount = trilegfx.vertex_count;
|
||||
} else {
|
||||
lod := ifx lod_index == 1 then *trilegfx.lod_4 else *trilegfx.lod_2;
|
||||
if lod.vertex_count == 0 {
|
||||
end_frame_profiling_group("Draw trile positions");
|
||||
return;
|
||||
}
|
||||
vbuf = lod.vertex_buffer;
|
||||
nbuf = lod.normal_buffer;
|
||||
cbuf = lod.color_buffer;
|
||||
vcount = lod.vertex_count;
|
||||
}
|
||||
|
||||
if in_shadowmap_pass {
|
||||
vs_params : Trile_Shadow_Vs_Params;
|
||||
vs_params.mvp = shadow_mvp.floats;
|
||||
bindings : sg_bindings;
|
||||
bindings.vertex_buffers[0] = vbuf;
|
||||
bindings.vertex_buffers[1] = nbuf;
|
||||
bindings.vertex_buffers[2] = cbuf;
|
||||
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
|
||||
bindings.vertex_buffer_offsets[3] = offset;
|
||||
sg_apply_pipeline(gPipelines.trile_shadow.pipeline);
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_trile_shadow_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_draw(0, cast(s32) vcount, amount);
|
||||
end_frame_profiling_group("Draw trile positions");
|
||||
return;
|
||||
}
|
||||
|
||||
mvp := create_viewproj(*camera);
|
||||
|
||||
if lod_index >= 1 {
|
||||
// LOD path: dedicated shader, vertex color, no ray-march/SSAO/shadow/SH/BRDF.
|
||||
sg_apply_pipeline(gPipelines.trile_lod.pipeline);
|
||||
|
||||
lod_vs : Trile_Lod_Vs_Params;
|
||||
lod_vs.mvp = mvp.floats;
|
||||
lod_vs.camera = camera.position.component;
|
||||
|
||||
lod_fs : Trile_Lod_Fs_Params;
|
||||
lod_fs.skyBase = worldConf.skyBase.component;
|
||||
lod_fs.sunPosition = worldConf.sunPosition.component;
|
||||
lod_fs.sunLightColor = worldConf.sunLightColor.component;
|
||||
lod_fs.sunIntensity = worldConf.sunIntensity;
|
||||
lc := *current_lighting_config;
|
||||
lod_fs.ambient_color = lc.ambient_color.component;
|
||||
lod_fs.ambient_intensity = lc.ambient_intensity;
|
||||
lod_fs.planeHeight = effective_plane_height(worldConf);
|
||||
lod_fs.deepColor = worldConf.deepColor.component;
|
||||
lod_fs.is_reflection = ifx in_reflection_pass then cast(s32)1 else cast(s32)0;
|
||||
lod_fs.fog_start = FOG_START;
|
||||
lod_fs.fog_end = FOG_END;
|
||||
|
||||
bindings : sg_bindings;
|
||||
bindings.vertex_buffers[0] = vbuf;
|
||||
bindings.vertex_buffers[1] = nbuf;
|
||||
bindings.vertex_buffers[2] = cbuf;
|
||||
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
|
||||
bindings.vertex_buffer_offsets[3] = offset;
|
||||
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_trile_lod_vs_params, *(sg_range.{ ptr = *lod_vs, size = size_of(type_of(lod_vs)) }));
|
||||
sg_apply_uniforms(UB_trile_lod_fs_params, *(sg_range.{ ptr = *lod_fs, size = size_of(type_of(lod_fs)) }));
|
||||
sg_draw(0, cast(s32) vcount, amount);
|
||||
end_frame_profiling_group("Draw trile positions");
|
||||
return;
|
||||
}
|
||||
|
||||
vs_params : Trile_Vs_Params;
|
||||
vs_params.mvp = mvp.floats;
|
||||
vs_params.mvp_shadow = shadow_mvp.floats;
|
||||
vs_params.camera = camera.position.component;
|
||||
sg_apply_pipeline(gPipelines.trile.pipeline);
|
||||
world_conf : Trile_World_Config;
|
||||
world_config_to_shader_type(worldConf, *world_conf);
|
||||
world_conf.planeHeight = effective_plane_height(worldConf);
|
||||
|
||||
bindings : sg_bindings;
|
||||
bindings.vertex_buffers[0] = vbuf;
|
||||
bindings.vertex_buffers[1] = nbuf;
|
||||
bindings.vertex_buffers[2] = cbuf;
|
||||
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
|
||||
bindings.vertex_buffer_offsets[3] = offset;
|
||||
bindings.samplers[0] = gPipelines.trile.bind.samplers[0];
|
||||
bindings.images[0] = trilegfx.trixel_colors;
|
||||
bindings.images[1] = g_ssaobuf;
|
||||
bindings.samplers[2] = g_shadowmap_sampler;
|
||||
bindings.images[2] = g_shadowmap;
|
||||
bindings.images[3] = g_brdf_lut;
|
||||
bindings.images[4] = g_sh_irradiance;
|
||||
bindings.samplers[3] = gPipelines.trile.bind.samplers[3];
|
||||
|
||||
curworld := get_current_world();
|
||||
chunk := table_find_pointer(*curworld.world.chunks, chunk_key);
|
||||
|
||||
fs_params : Trile_Fs_Params;
|
||||
fs_params.mvp_shadow = shadow_mvp.floats;
|
||||
fs_params.is_reflection = ifx in_reflection_pass then cast(s32)1 else cast(s32)0;
|
||||
w, h := get_render_size();
|
||||
fs_params.screen_w = w;
|
||||
fs_params.screen_h = h;
|
||||
lc := *current_lighting_config;
|
||||
fs_params.ambient_intensity = lc.ambient_intensity;
|
||||
fs_params.emissive_scale = lc.emissive_scale;
|
||||
fs_params.indirect_diff_scale = lc.indirect_diff_scale;
|
||||
fs_params.indirect_spec_scale = lc.indirect_spec_scale;
|
||||
fs_params.ambient_color = lc.ambient_color.component;
|
||||
fs_params.is_preview = preview_mode;
|
||||
fs_params.indirect_tint = lc.indirect_tint.component;
|
||||
fs_params.sh_enabled = ifx (chunk != null && chunk.sh_valid && !in_reflection_pass) then cast(s32)1 else cast(s32)0;
|
||||
fs_params.fog_start = FOG_START;
|
||||
fs_params.fog_end = FOG_END;
|
||||
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_trile_fs_params, *(sg_range.{ ptr = *fs_params, size = size_of(type_of(fs_params)) }));
|
||||
sg_apply_uniforms(UB_trile_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params))}));
|
||||
sg_apply_uniforms(UB_trile_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
|
||||
add_frame_profiling_point("After drawing setup");
|
||||
sg_draw(0, cast(s32) vcount, amount);
|
||||
end_frame_profiling_group("Draw trile positions");
|
||||
}
|
||||
backend_add_trile_rdm_position :: (position: Vector4) {
|
||||
pos := position;
|
||||
offset := sg_append_buffer(gPipelines.trile_rdm.bind.vertex_buffers[3], *(sg_range.{
|
||||
ptr = *pos,
|
||||
size = size_of(Vector4),
|
||||
}));
|
||||
array_add(*trile_rdm_offsets, offset);
|
||||
}
|
||||
|
||||
backend_draw_trile_rdm :: (trile: string, worldConf: *World_Config, atlas_rect: Vector4, offset_index: s32) {
|
||||
if offset_index >= trile_rdm_offsets.count then return;
|
||||
|
||||
trilegfx, success := get_trile_gfx(trile);
|
||||
if !success {
|
||||
log_warn("Failed to get trile: %\n", trile);
|
||||
return;
|
||||
}
|
||||
offset := trile_rdm_offsets[offset_index];
|
||||
|
||||
mvp := create_viewproj(*camera);
|
||||
vs_params : Trile_Rdm_Vs_Params;
|
||||
vs_params.mvp = mvp.floats;
|
||||
vs_params.mvp_shadow = shadow_mvp.floats;
|
||||
vs_params.camera = camera.position.component;
|
||||
|
||||
sg_apply_pipeline(gPipelines.trile_rdm.pipeline);
|
||||
world_conf : Trile_Rdm_World_Config;
|
||||
world_config_to_shader_type(worldConf, *world_conf);
|
||||
world_conf.planeHeight = effective_plane_height(worldConf);
|
||||
|
||||
bindings : sg_bindings;
|
||||
bindings.vertex_buffers[0] = trilegfx.vertex_buffer;
|
||||
bindings.vertex_buffers[1] = trilegfx.normal_buffer;
|
||||
bindings.vertex_buffers[2] = trilegfx.centre_buffer;
|
||||
bindings.vertex_buffers[3] = gPipelines.trile_rdm.bind.vertex_buffers[3];
|
||||
bindings.vertex_buffer_offsets[3] = offset;
|
||||
bindings.samplers[SMP_rdm_trilesmp] = gPipelines.trile_rdm.bind.samplers[SMP_rdm_trilesmp];
|
||||
bindings.samplers[SMP_rdm_shadowsmp] = g_shadowmap_sampler;
|
||||
bindings.samplers[SMP_rdm_linsmp] = gPipelines.trile_rdm.bind.samplers[SMP_rdm_linsmp];
|
||||
bindings.images[IMG_rdm_triletex] = trilegfx.trixel_colors;
|
||||
bindings.images[IMG_rdm_ssaotex] = g_ssaobuf;
|
||||
bindings.images[IMG_rdm_shadowtex] = g_shadowmap;
|
||||
bindings.images[IMG_rdm_brdflut] = g_brdf_lut;
|
||||
bindings.images[IMG_rdm_shirradiance] = g_sh_irradiance;
|
||||
bindings.images[IMG_rdm_atlas] = g_rdm_atlas;
|
||||
|
||||
curworld := get_current_world();
|
||||
fs_params : Trile_Rdm_Fs_Params;
|
||||
fs_params.mvp_shadow = shadow_mvp.floats;
|
||||
fs_params.is_reflection = 0;
|
||||
w, h := get_render_size();
|
||||
fs_params.screen_w = w;
|
||||
fs_params.screen_h = h;
|
||||
lc := *current_lighting_config;
|
||||
fs_params.ambient_intensity = lc.ambient_intensity;
|
||||
fs_params.emissive_scale = lc.emissive_scale;
|
||||
fs_params.indirect_diff_scale = lc.indirect_diff_scale;
|
||||
fs_params.indirect_spec_scale = lc.indirect_spec_scale;
|
||||
fs_params.ambient_color = lc.ambient_color.component;
|
||||
fs_params.is_preview = 0;
|
||||
fs_params.indirect_tint = lc.indirect_tint.component;
|
||||
fs_params.sh_enabled = ifx curworld.valid then cast(s32)1 else cast(s32)0;
|
||||
fs_params.atlas_rect = atlas_rect.component;
|
||||
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_trile_rdm_fs_params, *(sg_range.{ ptr = *fs_params, size = size_of(type_of(fs_params)) }));
|
||||
sg_apply_uniforms(UB_trile_rdm_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_apply_uniforms(UB_trile_rdm_world_config, *(sg_range.{ ptr = *world_conf, size = size_of(type_of(world_conf)) }));
|
||||
sg_draw(0, cast(s32) trilegfx.vertex_count, 1);
|
||||
}
|
||||
|
||||
backend_draw_sky :: (wc: *World_Config) {
|
||||
mvp := create_viewproj(*camera);
|
||||
vs_params : Sky_Vs_Params;
|
||||
|
||||
world_conf : Sky_World_Config;
|
||||
|
||||
world_config_to_shader_type(wc, *world_conf);
|
||||
|
||||
vs_params.mvp = mvp.floats;
|
||||
sg_apply_pipeline(gPipelines.sky.pipeline);
|
||||
sg_apply_bindings(*gPipelines.sky.bind);
|
||||
sg_apply_uniforms(UB_sky_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_apply_uniforms(UB_sky_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
|
||||
sg_draw(0, 36, 1);
|
||||
}
|
||||
|
||||
backend_draw_ground :: (wc: *World_Config) {
|
||||
mvp := create_viewproj(*camera);
|
||||
vs_params : Plane_Vs_Params;
|
||||
world_conf : Plane_World_Config;
|
||||
plane_data : Plane_Data;
|
||||
w, h := get_render_size();
|
||||
plane_data.mvp_shadow = shadow_mvp.floats;
|
||||
plane_data.screen_w = w;
|
||||
plane_data.screen_h = h;
|
||||
plane_data.cameraPosition = camera.position.component;
|
||||
plane_data.reflectionDistortion = wc.waterDistortion;
|
||||
plane_data.shininess = wc.waterShininess;
|
||||
|
||||
world_config_to_shader_type(wc, *world_conf);
|
||||
|
||||
vs_params.mvp = mvp.floats;
|
||||
vs_params.planeHeight = effective_plane_height(wc);
|
||||
sg_apply_pipeline(gPipelines.plane.pipeline);
|
||||
gPipelines.plane.bind.samplers[1] = g_shadowmap_sampler;
|
||||
gPipelines.plane.bind.images[1] = g_shadowmap;
|
||||
sg_apply_bindings(*gPipelines.plane.bind);
|
||||
sg_apply_uniforms(UB_plane_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_apply_uniforms(UB_plane_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
|
||||
sg_apply_uniforms(UB_plane_data, *(sg_range.{ptr = *plane_data, size = size_of(type_of(plane_data))}));
|
||||
sg_draw(0, 6, 2);
|
||||
}
|
||||
|
||||
backend_draw_billboard :: (position: Vector3, anim: *Animation, frame_idx: s32, flipX: bool, faceDir: Vector3) {
|
||||
if !anim then return;
|
||||
mvp := create_viewproj(*camera);
|
||||
vs_params : Billboard_Vs_Params;
|
||||
gPipelines.billboard.bind.images[0] = anim.sheet;
|
||||
frame := anim.frames[frame_idx];
|
||||
vs_params.uvs = Vector4.{
|
||||
cast(float) frame.x / cast(float)anim.sheet_w,
|
||||
cast(float) frame.y / cast(float)anim.sheet_h,
|
||||
cast(float) frame.w / cast(float)anim.sheet_w,
|
||||
cast(float) frame.h / cast(float)anim.sheet_h,
|
||||
}.component;
|
||||
if flipX {
|
||||
vs_params.uvs[0] += vs_params.uvs[2];
|
||||
vs_params.uvs[2] *= -1.0;
|
||||
}
|
||||
vs_params.size = Vector2.{cast(float)(frame.w / 16), cast(float)(frame.h / 16)}.component;
|
||||
vs_params.cam = camera.position.component;
|
||||
vs_params.faceDir = faceDir.component;
|
||||
if !in_shadowmap_pass {
|
||||
vs_params.mvp = mvp.floats;
|
||||
} else {
|
||||
vs_params.mvp = shadow_mvp.floats;
|
||||
}
|
||||
vs_params.offset = position.component;
|
||||
sg_apply_pipeline(gPipelines.billboard.pipeline);
|
||||
sg_apply_bindings(*gPipelines.billboard.bind);
|
||||
sg_apply_uniforms(UB_billboard_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_draw(0, 6, 1);
|
||||
}
|
||||
|
||||
backend_gbuffer_draw_billboard :: (position: Vector3, anim: *Animation, frame_idx: s32, flipX: bool, faceDir: Vector3) {
|
||||
if !anim then return;
|
||||
mvp := create_viewproj(*camera);
|
||||
view := create_lookat(*camera);
|
||||
vs_params : Gbuffer_Billboard_Vs_Params;
|
||||
vs_params.view_matrix = view.floats;
|
||||
gPipelines.gbuffer_billboard.bind.images[0] = anim.sheet;
|
||||
frame := anim.frames[frame_idx];
|
||||
vs_params.uvs = Vector4.{
|
||||
cast(float) frame.x / cast(float)anim.sheet_w,
|
||||
cast(float) frame.y / cast(float)anim.sheet_h,
|
||||
cast(float) frame.w / cast(float)anim.sheet_w,
|
||||
cast(float) frame.h / cast(float)anim.sheet_h,
|
||||
}.component;
|
||||
if flipX {
|
||||
vs_params.uvs[0] += vs_params.uvs[2];
|
||||
vs_params.uvs[2] *= -1.0;
|
||||
}
|
||||
vs_params.size = Vector2.{cast(float)(frame.w / 16), cast(float)(frame.h / 16)}.component;
|
||||
vs_params.cam = camera.position.component;
|
||||
vs_params.faceDir = faceDir.component;
|
||||
if !in_shadowmap_pass {
|
||||
vs_params.mvp = mvp.floats;
|
||||
} else {
|
||||
vs_params.mvp = shadow_mvp.floats;
|
||||
}
|
||||
vs_params.offset = position.component;
|
||||
sg_apply_pipeline(gPipelines.gbuffer_billboard.pipeline);
|
||||
sg_apply_bindings(*gPipelines.gbuffer_billboard.bind);
|
||||
sg_apply_uniforms(UB_gbuffer_billboard_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_draw(0, 6, 1);
|
||||
}
|
||||
|
||||
backend_update_particle_buffers :: (cmd: *Render_Command_Update_Particles) {
|
||||
if cmd.total_count <= 0 then return;
|
||||
byte_size := cast(u64)(cmd.total_count * size_of(Vector4));
|
||||
inst_buf1 := gPipelines.particle_additive.bind.vertex_buffers[1];
|
||||
inst_buf2 := gPipelines.particle_additive.bind.vertex_buffers[2];
|
||||
inst_buf3 := gPipelines.particle_additive.bind.vertex_buffers[3];
|
||||
sg_update_buffer(inst_buf1, *(sg_range.{ ptr = cmd.pos_size.data, size = byte_size }));
|
||||
sg_update_buffer(inst_buf2, *(sg_range.{ ptr = cmd.uv_rects.data, size = byte_size }));
|
||||
sg_update_buffer(inst_buf3, *(sg_range.{ ptr = cmd.colors.data, size = byte_size }));
|
||||
}
|
||||
|
||||
backend_draw_particles :: (cmd: *Render_Command_Draw_Particles) {
|
||||
if cmd.count <= 0 then return;
|
||||
|
||||
pip := ifx cmd.blend_mode == .ALPHA then *gPipelines.particle_alpha else *gPipelines.particle_additive;
|
||||
|
||||
byte_offset := cmd.instance_offset * size_of(Vector4);
|
||||
bind := pip.bind;
|
||||
bind.vertex_buffer_offsets[1] = byte_offset;
|
||||
bind.vertex_buffer_offsets[2] = byte_offset;
|
||||
bind.vertex_buffer_offsets[3] = byte_offset;
|
||||
|
||||
mvp := create_viewproj(*camera);
|
||||
vs_params : Particle_Vs_Params;
|
||||
vs_params.mvp = mvp.floats;
|
||||
vs_params.cam = camera.position.component;
|
||||
|
||||
sg_apply_pipeline(pip.pipeline);
|
||||
bind.images[IMG_particle_sprite] = cmd.sheet;
|
||||
sg_apply_bindings(*bind);
|
||||
sg_apply_uniforms(UB_particle_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_draw(0, 6, cmd.count);
|
||||
}
|
||||
|
||||
backend_draw_ground_gbuf :: (wc: *World_Config) {
|
||||
mvp := create_viewproj(*camera);
|
||||
view := create_lookat(*camera);
|
||||
vs_params : Gbuffer_Vs_Params;
|
||||
vs_params.mvp = mvp.floats;
|
||||
vs_params.view_matrix = view.floats;
|
||||
vs_params.isGround = 1;
|
||||
vs_params.planeHeight = effective_plane_height(wc);
|
||||
sg_apply_pipeline(gPipelines.gbuffer.pipeline);
|
||||
|
||||
bindings : sg_bindings;
|
||||
bindings.vertex_buffers[0] = g_plane_gbuffer_vertex_buffer;
|
||||
bindings.vertex_buffers[1] = g_plane_gbuffer_normal_buffer;
|
||||
bindings.vertex_buffers[2] = g_plane_gbuffer_center_buffer;
|
||||
bindings.vertex_buffers[3] = g_plane_gbuffer_instance_buffer;
|
||||
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_gbuffer_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params))}));
|
||||
sg_draw(0, 6, 1);
|
||||
}
|
||||
|
||||
draw_sh_irradiance_pass :: () {
|
||||
curworld := get_current_world();
|
||||
if !curworld.valid then return;
|
||||
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_sh_irradiance_attach }));
|
||||
sg_apply_pipeline(gPipelines.sh_irradiance.pipeline);
|
||||
|
||||
view := create_lookat(*camera);
|
||||
inv_view := isometry_inverse(view);
|
||||
|
||||
lc := *current_lighting_config;
|
||||
|
||||
params : Sh_Deferred_Params;
|
||||
params.inv_view = inv_view.floats;
|
||||
params.ambient = .[lc.ambient_color.x, lc.ambient_color.y, lc.ambient_color.z, lc.ambient_intensity];
|
||||
|
||||
for *chunk: curworld.world.chunks {
|
||||
if !chunk.sh_valid then continue;
|
||||
|
||||
gPipelines.sh_irradiance.bind.images[0] = g_gbuf_worldpos;
|
||||
gPipelines.sh_irradiance.bind.images[1] = g_gbuf_normal;
|
||||
gPipelines.sh_irradiance.bind.images[2] = chunk.sh_probe_grid;
|
||||
sg_apply_bindings(*gPipelines.sh_irradiance.bind);
|
||||
|
||||
ck := chunk.coord;
|
||||
params.chunk_origin = .[cast(float)(ck.x * 32), cast(float)(ck.y * 32), cast(float)(ck.z * 32), 0];
|
||||
sg_apply_uniforms(UB_sh_deferred_params, *(sg_range.{ ptr = *params, size = size_of(type_of(params)) }));
|
||||
sg_draw(0, 6, 1);
|
||||
}
|
||||
|
||||
sg_end_pass();
|
||||
}
|
||||
|
||||
backend_process_command_buckets :: () {
|
||||
// 1. Set up textures and buffers.
|
||||
start_frame_profiling_group("Setup");
|
||||
for render_command_buckets.setup {
|
||||
backend_handle_command(it);
|
||||
}
|
||||
end_frame_profiling_group("Setup");
|
||||
|
||||
start_frame_profiling_group("Shadow pass");
|
||||
// 2. Shadow pass
|
||||
if current_world_config != null {
|
||||
shadow_mvp = create_shadow_viewproj(*camera, current_world_config);
|
||||
in_shadowmap_pass = true;
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_shadowmap_attachments}));
|
||||
if !bypass_shadows {
|
||||
for render_command_buckets.shadow {
|
||||
backend_handle_command(it);
|
||||
}
|
||||
}
|
||||
sg_end_pass();
|
||||
in_shadowmap_pass = false;
|
||||
}
|
||||
end_frame_profiling_group("Shadow pass");
|
||||
|
||||
start_frame_profiling_group("Reflection pass");
|
||||
// 3. Reflection pass
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = gPipelines.plane.attachments}));
|
||||
if !bypass_reflections {
|
||||
in_reflection_pass = true;
|
||||
for render_command_buckets.reflection {
|
||||
backend_handle_command(it);
|
||||
}
|
||||
in_reflection_pass = false;
|
||||
}
|
||||
sg_end_pass();
|
||||
end_frame_profiling_group("Reflection pass");
|
||||
|
||||
// 4. G-Buffer pass
|
||||
start_frame_profiling_group("G-Buffer pass");
|
||||
in_gbuffer_pass = true;
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear_gbuf, attachments = g_gbuf_attachments}));
|
||||
for render_command_buckets.gbuffer {
|
||||
backend_handle_command(it);
|
||||
}
|
||||
sg_end_pass();
|
||||
in_gbuffer_pass = false;
|
||||
end_frame_profiling_group("G-Buffer pass");
|
||||
|
||||
start_frame_profiling_group("SSAO pass");
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_ssao_attachments }));
|
||||
sg_apply_pipeline(gPipelines.ssao.pipeline);
|
||||
gPipelines.ssao.bind.images[0] = g_gbuf_position;
|
||||
gPipelines.ssao.bind.images[1] = g_gbuf_normal;
|
||||
gPipelines.ssao.bind.images[2] = g_ssao_noise_buf;
|
||||
sg_apply_bindings(*gPipelines.ssao.bind);
|
||||
ssao_fs_uniform : Ssao_Fs_Params;
|
||||
mvp := create_perspective(*camera);
|
||||
ssao_fs_uniform.projection = mvp.floats;
|
||||
ssao_fs_uniform.samples = g_ssao_samples;
|
||||
ssao_fs_uniform.ssao_power = current_post_process.ssao;
|
||||
sg_apply_uniforms(UB_ssao_fs_params, *(sg_range.{ ptr = *ssao_fs_uniform, size = size_of(type_of(ssao_fs_uniform)) }));
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
end_frame_profiling_group("SSAO pass");
|
||||
|
||||
start_frame_profiling_group("SH irradiance pass");
|
||||
draw_sh_irradiance_pass();
|
||||
end_frame_profiling_group("SH irradiance pass");
|
||||
|
||||
// 5. Main pass
|
||||
start_frame_profiling_group("Main pass");
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_rendertex_attachments}));
|
||||
for render_command_buckets.main {
|
||||
backend_handle_command(it);
|
||||
}
|
||||
debug_draw_flush_gpu();
|
||||
sg_end_pass();
|
||||
end_frame_profiling_group("Main pass");
|
||||
|
||||
start_frame_profiling_group("Postprocess pass");
|
||||
if !bypass_postprocess {
|
||||
bloom_process();
|
||||
dof_downsample_process();
|
||||
dof_bokeh_process();
|
||||
}
|
||||
|
||||
end_frame_profiling_group("Postprocess pass");
|
||||
|
||||
start_frame_profiling_group("Final pass");
|
||||
// Begin drawing to swapchain
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, swapchain = cast,force(sg_swapchain) sglue_swapchain() }));
|
||||
|
||||
// Draw the render texture and do post processing:
|
||||
sg_apply_pipeline(gPipelines.postprocess.pipeline);
|
||||
gPipelines.postprocess.bind.images[0] = g_rendertex;
|
||||
gPipelines.postprocess.bind.images[1] = LUT_list[g_current_lut_texture_index].image;
|
||||
gPipelines.postprocess.bind.images[2] = g_bloom_up_1;
|
||||
gPipelines.postprocess.bind.images[3] = g_dof_tex;
|
||||
gPipelines.postprocess.bind.images[4] = g_gbuf_position;
|
||||
sg_apply_bindings(*gPipelines.postprocess.bind);
|
||||
post_process_config_uniform : Post_Process_Config;
|
||||
if bypass_postprocess {
|
||||
neutral : Post_Process;
|
||||
neutral.tonemap = current_post_process.tonemap;
|
||||
fill_uniform_with_engine_data(*post_process_config_uniform, *neutral);
|
||||
} else {
|
||||
fill_uniform_with_engine_data(*post_process_config_uniform, *current_post_process);
|
||||
}
|
||||
sg_apply_uniforms(UB_post_process_config, *(sg_range.{ ptr = *post_process_config_uniform, size = size_of(type_of(post_process_config_uniform)) }));
|
||||
dof_config_uniform : Dof_Config;
|
||||
dof_config_uniform.dof_disabled = ifx disable_dof_post_process then cast(s32)1 else cast(s32)0;
|
||||
dof_config_uniform.dof_max = current_post_process.dof_max;
|
||||
dof_config_uniform.dof_point = current_post_process.dof_point;
|
||||
sg_apply_uniforms(UB_dof_config, *(sg_range.{ ptr = *dof_config_uniform, size = size_of(type_of(dof_config_uniform)) }));
|
||||
sg_draw(0, 6, 1);
|
||||
|
||||
sgl_defaults();
|
||||
sgl_matrix_mode_projection();
|
||||
sgl_ortho(0.0, sapp_widthf(), sapp_heightf(), 0.0, -1.0, +1.0);
|
||||
arb_tri_flush();
|
||||
|
||||
sg_end_pass();
|
||||
end_frame_profiling_group("Final pass");
|
||||
|
||||
sg_commit();
|
||||
|
||||
array_reset_keeping_memory(*render_command_buckets.setup);
|
||||
array_reset_keeping_memory(*render_command_buckets.shadow);
|
||||
array_reset_keeping_memory(*render_command_buckets.reflection);
|
||||
array_reset_keeping_memory(*render_command_buckets.main);
|
||||
array_reset_keeping_memory(*render_command_buckets.gbuffer);
|
||||
array_reset_keeping_memory(*render_command_buckets.ui);
|
||||
array_reset_keeping_memory(*trile_offsets);
|
||||
array_reset_keeping_memory(*trile_rdm_offsets);
|
||||
current_world_config = null;
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
bloom_process :: () {
|
||||
w, h := get_render_size();
|
||||
fw := cast(float)w;
|
||||
fh := cast(float)h;
|
||||
|
||||
// Prefilter: threshold + downsample full-res → down_1 (w/2)
|
||||
{
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_bloom_down_1_attach }));
|
||||
sg_apply_pipeline(gPipelines.bloom_prefilter.pipeline);
|
||||
p : Bloom_Prefilter_Params;
|
||||
p.src_texel_x = 1.0 / fw;
|
||||
p.src_texel_y = 1.0 / fh;
|
||||
p.threshold = current_post_process.bloom_treshold;
|
||||
gPipelines.bloom_prefilter.bind.images[IMG_bloom_prefilter_src] = g_rendertex;
|
||||
sg_apply_uniforms(UB_bloom_prefilter_params, *(sg_range.{ ptr = *p, size = size_of(type_of(p)) }));
|
||||
sg_apply_bindings(*gPipelines.bloom_prefilter.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
}
|
||||
|
||||
// Downsample chain
|
||||
bloom_downsample :: (src: sg_image, dst_attach: sg_attachments, src_w: float, src_h: float) {
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = dst_attach }));
|
||||
sg_apply_pipeline(gPipelines.bloom_downsample.pipeline);
|
||||
p : Bloom_Downsample_Params;
|
||||
p.src_texel_x = 1.0 / src_w;
|
||||
p.src_texel_y = 1.0 / src_h;
|
||||
gPipelines.bloom_downsample.bind.images[IMG_bloom_downsample_src] = src;
|
||||
sg_apply_uniforms(UB_bloom_downsample_params, *(sg_range.{ ptr = *p, size = size_of(type_of(p)) }));
|
||||
sg_apply_bindings(*gPipelines.bloom_downsample.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
}
|
||||
bloom_downsample(g_bloom_down_1, g_bloom_down_2_attach, fw/2, fh/2);
|
||||
bloom_downsample(g_bloom_down_2, g_bloom_down_3_attach, fw/4, fh/4);
|
||||
bloom_downsample(g_bloom_down_3, g_bloom_down_4_attach, fw/8, fh/8);
|
||||
|
||||
// Upsample chain: tent(small) + large → dest
|
||||
bloom_upsample :: (small: sg_image, large: sg_image, dst_attach: sg_attachments, small_w: float, small_h: float) {
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = dst_attach }));
|
||||
sg_apply_pipeline(gPipelines.bloom_upsample.pipeline);
|
||||
p : Bloom_Upsample_Params;
|
||||
p.src_texel_x = 1.0 / small_w;
|
||||
p.src_texel_y = 1.0 / small_h;
|
||||
gPipelines.bloom_upsample.bind.images[IMG_bloom_upsample_small] = small;
|
||||
gPipelines.bloom_upsample.bind.images[IMG_bloom_upsample_large] = large;
|
||||
sg_apply_uniforms(UB_bloom_upsample_params, *(sg_range.{ ptr = *p, size = size_of(type_of(p)) }));
|
||||
sg_apply_bindings(*gPipelines.bloom_upsample.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
}
|
||||
bloom_upsample(g_bloom_down_4, g_bloom_down_3, g_bloom_up_3_attach, fw/16, fh/16);
|
||||
bloom_upsample(g_bloom_up_3, g_bloom_down_2, g_bloom_up_2_attach, fw/8, fh/8);
|
||||
bloom_upsample(g_bloom_up_2, g_bloom_down_1, g_bloom_up_1_attach, fw/4, fh/4);
|
||||
}
|
||||
|
||||
dof_downsample_process :: () {
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_dof_downsample_attach }));
|
||||
sg_apply_pipeline(gPipelines.dof_downsample.pipeline);
|
||||
gPipelines.dof_downsample.bind.images[IMG_dof_downsample_src] = g_rendertex;
|
||||
sg_apply_bindings(*gPipelines.dof_downsample.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
}
|
||||
|
||||
dof_bokeh_process :: () {
|
||||
w, h := get_render_size();
|
||||
half_w := cast(float)(w / 2);
|
||||
half_h := cast(float)(h / 2);
|
||||
radius := current_post_process.dof_blur_size * 3.0;
|
||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_dof_attach }));
|
||||
sg_apply_pipeline(gPipelines.dof_blur.pipeline);
|
||||
params : Dof_Blur_Params;
|
||||
params.bokeh_radius_x = radius / half_w;
|
||||
params.bokeh_radius_y = radius / half_h;
|
||||
gPipelines.dof_blur.bind.images[IMG_dof_blur_src] = g_dof_downsample_tex;
|
||||
sg_apply_uniforms(UB_dof_blur_params, *(sg_range.{ ptr = *params, size = size_of(type_of(params)) }));
|
||||
sg_apply_bindings(*gPipelines.dof_blur.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
sg_end_pass();
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
#scope_export
|
||||
|
||||
#load "backend.jai";
|
||||
|
||||
init_rendering :: () {
|
||||
init_ssao();
|
||||
}
|
||||
|
||||
// Core rendering function, runs several passes.
|
||||
render :: () {
|
||||
tasks_to_commands();
|
||||
add_frame_profiling_point("After task->command conversion");
|
||||
start_frame_profiling_group("Rendering command bucket processing");
|
||||
process_command_buckets();
|
||||
end_frame_profiling_group("Rendering command bucket processing");
|
||||
}
|
||||
|
||||
#scope_file
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
DEBUG_LINE_MAX :: 65536;
|
||||
DEBUG_OVERLAY_LINE_MAX :: 8192;
|
||||
|
||||
// One record per line, uploaded as instance data: the line pipeline expands each
|
||||
// into a screen-space quad so lines can have a real pixel width.
|
||||
// Debug lines are the one draw without a view: they are collected globally and
|
||||
// drawn in every view that renders to the screen, then cleared by render().
|
||||
Debug_Line :: struct {
|
||||
a : Vector3;
|
||||
b : Vector3;
|
||||
@ -151,35 +151,3 @@ debug_aabb_3d :: (mn: Vector3, mx: Vector3, col: Vector4) {
|
||||
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);
|
||||
}
|
||||
|
||||
flush_debug_lines :: (pipe: *Pipeline_Binding, lines: []Debug_Line, count: *int, params: *Debugline_Vs_Params) {
|
||||
if count.* == 0 then return;
|
||||
// Buffer 0 is the shared static quad; buffer 1 is this pipeline's instances.
|
||||
sg_update_buffer(
|
||||
pipe.bind.vertex_buffers[1],
|
||||
*(sg_range.{
|
||||
ptr = lines.data,
|
||||
size = cast(u64)(count.* * size_of(Debug_Line)),
|
||||
})
|
||||
);
|
||||
sg_apply_pipeline(pipe.pipeline);
|
||||
sg_apply_bindings(*pipe.bind);
|
||||
sg_apply_uniforms(UB_debugline_vs_params, *(sg_range.{ ptr = params, size = size_of(Debugline_Vs_Params) }));
|
||||
sg_draw(0, 6, xx count.*);
|
||||
count.* = 0;
|
||||
}
|
||||
|
||||
debug_draw_flush_gpu :: () {
|
||||
if g_debug_line_count == 0 && g_overlay_line_count == 0 then return;
|
||||
|
||||
w, h := get_window_size();
|
||||
mvp := create_viewproj(*camera);
|
||||
params : Debugline_Vs_Params;
|
||||
params.mvp = mvp.floats;
|
||||
params.viewport = .[cast(float)w, cast(float)h, 0, 0];
|
||||
|
||||
flush_debug_lines(*gPipelines.debugline, g_debug_lines, *g_debug_line_count, *params);
|
||||
flush_debug_lines(*gPipelines.debugline_overlay, g_overlay_lines, *g_overlay_line_count, *params);
|
||||
}
|
||||
|
||||
#assert size_of(Debug_Line) == 44 "Debug_Line must stay tightly packed: the pipeline layout hardcodes its field offsets.";
|
||||
|
||||
@ -1,207 +0,0 @@
|
||||
fill_uniform_with_engine_data :: (uniform: *$A, enginedata: *$B) {
|
||||
generate_copy_code :: () -> string {
|
||||
builder : String_Builder;
|
||||
ti := type_info(A);
|
||||
for ti.members {
|
||||
if it.name == "_" then continue; // skip padding
|
||||
if it.type == type_info(Vector3) then print_to_builder(*builder, "uniform.% = enginedata.%.component;\n", it.name, it.name);
|
||||
else print_to_builder(*builder, "uniform.% = enginedata.%;\n", it.name, it.name);
|
||||
}
|
||||
return builder_to_string(*builder);
|
||||
}
|
||||
#insert #run,stallable generate_copy_code();
|
||||
}
|
||||
|
||||
extract_frustum_planes :: (mvp: Matrix4) -> [6]Vector4 {
|
||||
planes : [6]Vector4;
|
||||
m := mvp;
|
||||
planes[0] = .{m._14+m._11, m._24+m._21, m._34+m._31, m._44+m._41}; // left
|
||||
planes[1] = .{m._14-m._11, m._24-m._21, m._34-m._31, m._44-m._41}; // right
|
||||
planes[2] = .{m._14+m._12, m._24+m._22, m._34+m._32, m._44+m._42}; // bottom
|
||||
planes[3] = .{m._14-m._12, m._24-m._22, m._34-m._32, m._44-m._42}; // top
|
||||
planes[4] = .{m._14+m._13, m._24+m._23, m._34+m._33, m._44+m._43}; // near
|
||||
planes[5] = .{m._14-m._13, m._24-m._23, m._34-m._33, m._44-m._43}; // far
|
||||
return planes;
|
||||
}
|
||||
|
||||
aabb_in_frustum :: inline (planes: [6]Vector4, bmin: Vector3, bmax: Vector3) -> bool {
|
||||
for plane: planes {
|
||||
px := ifx plane.x >= 0 then bmax.x else bmin.x;
|
||||
py := ifx plane.y >= 0 then bmax.y else bmin.y;
|
||||
pz := ifx plane.z >= 0 then bmax.z else bmin.z;
|
||||
if plane.x*px + plane.y*py + plane.z*pz + plane.w < 0 return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
LOD_NEAR_DIST :: 40.0;
|
||||
LOD_FAR_DIST :: 80.0;
|
||||
|
||||
// 3-band LOD selection: instances closer than LOD_DISTANCES[i] use LOD level i.
|
||||
// i = 0 → full detail
|
||||
// i = 1 → 4^3 cube grid
|
||||
// i = 2 → 2^3 cube grid
|
||||
// beyond LOD_DISTANCES[2] → culled.
|
||||
LOD_DISTANCES :: float.[50.0, 100.0, 200.0];
|
||||
FOG_START :: 60.0;
|
||||
FOG_END :: 195.0;
|
||||
|
||||
|
||||
shad_gathered : [..]Gathered_Positions;
|
||||
rdm_extra : [..]Gathered_Positions;
|
||||
rdm_main : [..]Gathered_Rdm_Position;
|
||||
gathered_per_lod : [3][..]Gathered_Positions;
|
||||
|
||||
Gathered_Positions :: struct {
|
||||
trile : string;
|
||||
chunk_key : Chunk_Key;
|
||||
positions : [..]Vector4;
|
||||
}
|
||||
|
||||
Gathered_Rdm_Position :: struct {
|
||||
name: string;
|
||||
position: Vector4;
|
||||
}
|
||||
|
||||
gathered_chunk_tasks : [..]Gathered_Positions;
|
||||
|
||||
create_world_rendering_tasks :: (world: *World, camera: Camera, plane_height: float = 0) {
|
||||
create_sky_rendering_task(*world.conf);
|
||||
create_set_light_rendering_task(*world.conf);
|
||||
|
||||
cam_mvp := create_viewproj(*camera);
|
||||
shadow_mvp := create_shadow_viewproj(*camera, *world.conf);
|
||||
cam_planes := extract_frustum_planes(cam_mvp);
|
||||
shadow_planes := extract_frustum_planes(shadow_mvp);
|
||||
|
||||
reflect_cam := camera;
|
||||
reflect_cam.position *= .{1, -1, 1};
|
||||
reflect_cam.position.y += plane_height * 2;
|
||||
reflect_cam.target *= .{1, -1, 1};
|
||||
reflect_cam.target.y += plane_height * 2;
|
||||
reflect_mvp := create_viewproj(*reflect_cam);
|
||||
reflect_planes := extract_frustum_planes(reflect_mvp);
|
||||
|
||||
for chunk: world.chunks {
|
||||
// Skip chunks that are completely out of view.
|
||||
bmin := Vector3.{
|
||||
chunk.coord.x * 32.0,
|
||||
chunk.coord.y * 32.0,
|
||||
chunk.coord.z * 32.0
|
||||
};
|
||||
bmax := bmin + .{32, 32, 32};
|
||||
in_cam := aabb_in_frustum(cam_planes, bmin, bmax);
|
||||
in_reflect := aabb_in_frustum(reflect_planes, bmin, bmax);
|
||||
in_shad := aabb_in_frustum(shadow_planes, bmin, bmax);
|
||||
vis := in_cam || in_reflect || in_shad;
|
||||
if !vis then continue;
|
||||
|
||||
for group : chunk.groups {
|
||||
if group.instances.count < 1 then continue;
|
||||
|
||||
|
||||
gmin := group.bounding_min;
|
||||
gmax := group.bounding_max;
|
||||
|
||||
gmin += Vector3.{cast(float)chunk.coord.x * 32, cast(float)chunk.coord.y * 32, cast(float)chunk.coord.z * 32};
|
||||
gmax += Vector3.{cast(float)chunk.coord.x * 32, cast(float)chunk.coord.y * 32, cast(float)chunk.coord.z * 32};
|
||||
in_cam := aabb_in_frustum(cam_planes, gmin, gmax);
|
||||
in_reflect := aabb_in_frustum(reflect_planes, gmin, gmax);
|
||||
in_shad := aabb_in_frustum(shadow_planes, gmin, gmax);
|
||||
vis := in_cam || in_reflect || in_shad;
|
||||
|
||||
if !vis then continue;
|
||||
|
||||
diff := group.average_pos - camera.position;
|
||||
dist := length(diff);
|
||||
lod_index : s32 = 0;
|
||||
for lod_dist : LOD_DISTANCES {
|
||||
if dist < lod_dist then break;
|
||||
lod_index += 1;
|
||||
}
|
||||
|
||||
task := Rendering_Task_Trile.{
|
||||
trile = group.trile_name,
|
||||
chunk_key = chunk.coord,
|
||||
positions = group.instances,
|
||||
worldConf = *world.conf,
|
||||
lod_index = lod_index
|
||||
};
|
||||
add_rendering_task(task);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
create_ground_rendering_task(world);
|
||||
}
|
||||
|
||||
create_sky_rendering_task :: (conf: *World_Config) {
|
||||
skytask := Rendering_Task_Sky.{type = .SKY, worldConfig = conf};
|
||||
add_rendering_task(skytask);
|
||||
}
|
||||
|
||||
create_set_light_rendering_task :: (conf: *World_Config) {
|
||||
lighttask := Rendering_Task_Set_Light.{type = .SET_LIGHT, worldConfig = conf};
|
||||
add_rendering_task(lighttask);
|
||||
}
|
||||
|
||||
TRIXEL_IDENTITY : Matrix4 : .{_11=1, _22=1, _33=1, _44=1};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
create_ground_rendering_task :: (world: *World) {
|
||||
groundtask := Rendering_Task_Ground.{type = .GROUND, world = world};
|
||||
add_rendering_task(groundtask);
|
||||
}
|
||||
|
||||
create_billboard_rendering_task :: (position: Vector3, animation: *Animation, frame: s32, flipX: bool, flipY: bool, faceDir : Vector3 = .{-100, -100, -100}) {
|
||||
billboardtask := Rendering_Task_Billboard.{type = .BILLBOARD, position = position, animation = animation, frame = frame, flipX = flipX, flipY = flipY, faceDir = faceDir };
|
||||
add_rendering_task(billboardtask);
|
||||
}
|
||||
|
||||
create_set_cam_rendering_task :: (cam: Camera, planeHeight: float) {
|
||||
camtask := Rendering_Task_Set_Camera.{type = .SET_CAMERA, camera = cam, planeHeight = planeHeight};
|
||||
add_rendering_task(camtask);
|
||||
}
|
||||
|
||||
get_low_res :: (width: s32, height: s32, max_dimension: s32 = 720) -> (s32, s32) {
|
||||
if width == 0 || height == 0 {
|
||||
return 0, 0;
|
||||
}
|
||||
aspect_ratio := cast(float)width / cast(float)height;
|
||||
w: s32;
|
||||
h: s32;
|
||||
if width > height {
|
||||
w = max_dimension;
|
||||
h = cast(s32)floor(cast(float)w / aspect_ratio);
|
||||
} else {
|
||||
h = max_dimension;
|
||||
w = cast(s32)floor(cast(float)h * aspect_ratio);
|
||||
}
|
||||
|
||||
return w, h;
|
||||
}
|
||||
|
||||
get_render_size :: () -> (s32, s32) {
|
||||
w,h := get_window_size();
|
||||
// w, h = get_low_res(w,h, 480);
|
||||
return w, h;
|
||||
}
|
||||
|
||||
flip_y_if_plat :: inline (v: Vector2) -> Vector2 {
|
||||
return .{v.x, flip_if_plat(v.y)};
|
||||
}
|
||||
|
||||
// Some platforms draw UVs in weird reverse way
|
||||
// so this function here does the flip on those platforms
|
||||
// so we don't need to do the platform check in many places.
|
||||
flip_if_plat :: inline (n: float) -> float {
|
||||
#if OS == .MACOS {
|
||||
return 1 - n;
|
||||
} else {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
@ -1,153 +0,0 @@
|
||||
// LOD bake for triles. Independent of meshgen.jai's quad-mesh path.
|
||||
//
|
||||
// Approach:
|
||||
// 1. Downsample the 16^3 source trixels into a smaller N^3 grid of LOD voxels
|
||||
// (avg color across non-empty source trixels in each block, empty if all empty).
|
||||
// 2. Bake a cube-grid mesh: one cube per non-empty LOD voxel, only emit faces whose
|
||||
// neighbor in the LOD grid is empty (or out of bounds). Color is baked into the
|
||||
// vertex color buffer.
|
||||
// 3. The result feeds a separate trile_lod pipeline that uses vertex color and skips
|
||||
// texture sampling, ray-march, SSAO, shadow, SH, etc.
|
||||
|
||||
LOD_Voxel :: struct {
|
||||
color : Vector3;
|
||||
empty : bool;
|
||||
}
|
||||
|
||||
downsample_trile :: (src: *Trile, target_size: int) -> []LOD_Voxel {
|
||||
block := 16 / target_size; // source trixels per LOD voxel along one axis
|
||||
out := NewArray(target_size * target_size * target_size, LOD_Voxel,, temp);
|
||||
for lx: 0..target_size-1 {
|
||||
for ly: 0..target_size-1 {
|
||||
for lz: 0..target_size-1 {
|
||||
sum_r, sum_g, sum_b : float;
|
||||
count : int = 0;
|
||||
for dx: 0..block-1 {
|
||||
for dy: 0..block-1 {
|
||||
for dz: 0..block-1 {
|
||||
sx := lx * block + dx;
|
||||
sy := ly * block + dy;
|
||||
sz := lz * block + dz;
|
||||
if src.trixels[sx][sy][sz].empty continue;
|
||||
c := src.trixels[sx][sy][sz].material.color;
|
||||
sum_r += c.x;
|
||||
sum_g += c.y;
|
||||
sum_b += c.z;
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
idx := (lx * target_size + ly) * target_size + lz;
|
||||
if count == 0 {
|
||||
out[idx].empty = true;
|
||||
} else {
|
||||
out[idx].color = .{ sum_r / count, sum_g / count, sum_b / count };
|
||||
out[idx].empty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bake_lod_cube_mesh :: (lod: []LOD_Voxel, target_size: int) -> Trile_GFX_LOD {
|
||||
inv_n := 1.0 / cast(float)target_size;
|
||||
|
||||
verts : [..]float;
|
||||
norms : [..]float;
|
||||
colors : [..]float;
|
||||
verts.allocator = temp;
|
||||
norms.allocator = temp;
|
||||
colors.allocator = temp;
|
||||
|
||||
voxel_at :: (lod: []LOD_Voxel, n: int, x: int, y: int, z: int) -> LOD_Voxel #expand {
|
||||
idx := (x * n + y) * n + z;
|
||||
return lod[idx];
|
||||
}
|
||||
|
||||
// Each face: 4 corners (offsets in [0,1] within a unit voxel) + outward normal.
|
||||
Face :: struct {
|
||||
nx, ny, nz : float;
|
||||
ax, ay, az : float;
|
||||
bx, by, bz : float;
|
||||
cx, cy, cz : float;
|
||||
dx, dy, dz : float;
|
||||
}
|
||||
// Order: -X, +X, -Y, +Y, -Z, +Z. CCW winding when viewed from outside.
|
||||
faces :: Face.[
|
||||
.{ -1, 0, 0, 0,0,0, 0,0,1, 0,1,1, 0,1,0 },
|
||||
.{ 1, 0, 0, 1,0,0, 1,1,0, 1,1,1, 1,0,1 },
|
||||
.{ 0,-1, 0, 0,0,0, 1,0,0, 1,0,1, 0,0,1 },
|
||||
.{ 0, 1, 0, 0,1,0, 0,1,1, 1,1,1, 1,1,0 },
|
||||
.{ 0, 0,-1, 0,0,0, 0,1,0, 1,1,0, 1,0,0 },
|
||||
.{ 0, 0, 1, 1,0,1, 1,1,1, 0,1,1, 0,0,1 },
|
||||
];
|
||||
neighbor_offsets :: int.[ -1, 1, -1, 1, -1, 1 ];
|
||||
neighbor_axes :: int.[ 0, 0, 1, 1, 2, 2 ]; // 0=x, 1=y, 2=z
|
||||
|
||||
for lx: 0..target_size-1 {
|
||||
for ly: 0..target_size-1 {
|
||||
for lz: 0..target_size-1 {
|
||||
v := voxel_at(lod, target_size, lx, ly, lz);
|
||||
if v.empty continue;
|
||||
|
||||
base_x := cast(float)lx * inv_n;
|
||||
base_y := cast(float)ly * inv_n;
|
||||
base_z := cast(float)lz * inv_n;
|
||||
|
||||
for f: 0..5 {
|
||||
nx, ny, nz := lx, ly, lz;
|
||||
if neighbor_axes[f] == 0 nx += neighbor_offsets[f];
|
||||
else if neighbor_axes[f] == 1 ny += neighbor_offsets[f];
|
||||
else nz += neighbor_offsets[f];
|
||||
|
||||
visible := false;
|
||||
if nx < 0 || nx >= target_size || ny < 0 || ny >= target_size || nz < 0 || nz >= target_size {
|
||||
visible = true;
|
||||
} else {
|
||||
if voxel_at(lod, target_size, nx, ny, nz).empty visible = true;
|
||||
}
|
||||
if !visible continue;
|
||||
|
||||
face := faces[f];
|
||||
push_vert :: (px: float, py: float, pz: float) #expand {
|
||||
array_add(*verts, base_x + px * inv_n);
|
||||
array_add(*verts, base_y + py * inv_n);
|
||||
array_add(*verts, base_z + pz * inv_n);
|
||||
array_add(*norms, face.nx);
|
||||
array_add(*norms, face.ny);
|
||||
array_add(*norms, face.nz);
|
||||
array_add(*colors, v.color.x);
|
||||
array_add(*colors, v.color.y);
|
||||
array_add(*colors, v.color.z);
|
||||
}
|
||||
// tri 1: a b c
|
||||
push_vert(face.ax, face.ay, face.az);
|
||||
push_vert(face.bx, face.by, face.bz);
|
||||
push_vert(face.cx, face.cy, face.cz);
|
||||
// tri 2: a c d
|
||||
push_vert(face.ax, face.ay, face.az);
|
||||
push_vert(face.cx, face.cy, face.cz);
|
||||
push_vert(face.dx, face.dy, face.dz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out : Trile_GFX_LOD;
|
||||
out.vertex_count = verts.count / 3;
|
||||
if out.vertex_count == 0 return out;
|
||||
|
||||
out.vertex_buffer = sg_make_buffer(*(sg_buffer_desc.{ data = .{ ptr = verts.data, size = xx (verts.count * 4) } }));
|
||||
out.normal_buffer = sg_make_buffer(*(sg_buffer_desc.{ data = .{ ptr = norms.data, size = xx (norms.count * 4) } }));
|
||||
out.color_buffer = sg_make_buffer(*(sg_buffer_desc.{ data = .{ ptr = colors.data, size = xx (colors.count * 4) } }));
|
||||
return out;
|
||||
}
|
||||
|
||||
destroy_trile_gfx_lod :: (lod: *Trile_GFX_LOD) {
|
||||
if lod.vertex_count == 0 return;
|
||||
sg_destroy_buffer(lod.vertex_buffer);
|
||||
sg_destroy_buffer(lod.normal_buffer);
|
||||
sg_destroy_buffer(lod.color_buffer);
|
||||
lod.vertex_count = 0;
|
||||
}
|
||||
@ -1,509 +0,0 @@
|
||||
Trile_Side :: enum_flags u8 {
|
||||
TOP :: 0x1; // Larger Y
|
||||
LEFT :: 0x2; // Larger Z
|
||||
RIGHT :: 0x4; // Smaller Z
|
||||
FRONT :: 0x8; // Larger X
|
||||
BACK :: 0x10; // Smaller X
|
||||
BOTTOM :: 0x20; // Smaller Ys
|
||||
}
|
||||
|
||||
trileSideValues : [6]Trile_Side = .[.TOP, .LEFT, .RIGHT, .FRONT, .BACK, .BOTTOM];
|
||||
|
||||
sides_with_air_exposure :: (trileptr: *Trile, x: int, y: int, z: int) -> u8 {
|
||||
res : u8 = 0;
|
||||
if trileptr.trixels[x][y][z].empty then return res;
|
||||
|
||||
// Top
|
||||
if y == 15 || trileptr.trixels[x][y+1][z].empty then res |= xx Trile_Side.TOP;
|
||||
// Bottom
|
||||
if y == 0 || trileptr.trixels[x][y-1][z].empty then res |= xx Trile_Side.BOTTOM;
|
||||
// Left
|
||||
if z == 15 || trileptr.trixels[x][y][z+1].empty then res |= xx Trile_Side.LEFT;
|
||||
// Right
|
||||
if z == 0 || trileptr.trixels[x][y][z-1].empty then res |= xx Trile_Side.RIGHT;
|
||||
// Front
|
||||
if x == 15 || trileptr.trixels[x+1][y][z].empty then res |= xx Trile_Side.FRONT;
|
||||
// Back
|
||||
if x == 0 || trileptr.trixels[x-1][y][z].empty then res |= xx Trile_Side.BACK;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
draw_trile_side_triangles :: (vecs: *[]float, normals: *[]float, index: *int, side: Trile_Side, x: int, y: int, z: int) {
|
||||
points : [4][3]float;
|
||||
normal : [3]float;
|
||||
|
||||
if side == Trile_Side.TOP {
|
||||
points[0][0] = 1; points[0][1] = 1; points[0][2] = 1;
|
||||
points[1][0] = 1; points[1][1] = 1; points[1][2] = 0;
|
||||
points[2][0] = 0; points[2][1] = 1; points[2][2] = 1;
|
||||
points[3][0] = 0; points[3][1] = 1; points[3][2] = 0;
|
||||
normal[0] = 0; normal[1] = 1; normal[2] = 0;
|
||||
}
|
||||
if side == Trile_Side.BOTTOM {
|
||||
points[0][0] = 1; points[0][1] = 0; points[0][2] = 1;
|
||||
points[2][0] = 1; points[2][1] = 0; points[2][2] = 0;
|
||||
points[1][0] = 0; points[1][1] = 0; points[1][2] = 1;
|
||||
points[3][0] = 0; points[3][1] = 0; points[3][2] = 0;
|
||||
normal[0] = 0; normal[1] = -1; normal[2] = 0;
|
||||
}
|
||||
if side == Trile_Side.FRONT {
|
||||
points[0][0] = 1; points[0][1] = 1; points[0][2] = 1;
|
||||
points[2][0] = 1; points[2][1] = 1; points[2][2] = 0;
|
||||
points[1][0] = 1; points[1][1] = 0; points[1][2] = 1;
|
||||
points[3][0] = 1; points[3][1] = 0; points[3][2] = 0;
|
||||
normal[0] = 1; normal[1] = 0; normal[2] = 0;
|
||||
}
|
||||
if side == Trile_Side.BACK {
|
||||
points[0][0] = 0; points[0][1] = 1; points[0][2] = 1;
|
||||
points[1][0] = 0; points[1][1] = 1; points[1][2] = 0;
|
||||
points[2][0] = 0; points[2][1] = 0; points[2][2] = 1;
|
||||
points[3][0] = 0; points[3][1] = 0; points[3][2] = 0;
|
||||
normal[0] = -1; normal[1] = 0; normal[2] = 0;
|
||||
}
|
||||
if side == Trile_Side.LEFT {
|
||||
points[0][0] = 1; points[0][1] = 1; points[0][2] = 1;
|
||||
points[2][0] = 1; points[2][1] = 0; points[2][2] = 1;
|
||||
points[1][0] = 0; points[1][1] = 1; points[1][2] = 1;
|
||||
points[3][0] = 0; points[3][1] = 0; points[3][2] = 1;
|
||||
normal[0] = 0; normal[1] = 0; normal[2] = 1;
|
||||
}
|
||||
if side == Trile_Side.RIGHT {
|
||||
points[0][0] = 1; points[0][1] = 1; points[0][2] = 0;
|
||||
points[1][0] = 1; points[1][1] = 0; points[1][2] = 0;
|
||||
points[2][0] = 0; points[2][1] = 1; points[2][2] = 0;
|
||||
points[3][0] = 0; points[3][1] = 0; points[3][2] = 0;
|
||||
normal[0] = 0; normal[1] = 0; normal[2] = -1;
|
||||
}
|
||||
|
||||
for 0..2 {
|
||||
vecs.*[index.*] = (x + points[it][0]) * TRIXEL_SIZE;
|
||||
vecs.*[index.*+1] = (y + points[it][1]) * TRIXEL_SIZE;
|
||||
vecs.*[index.*+2] = (z + points[it][2]) * TRIXEL_SIZE;
|
||||
normals.*[index.*] = normal[0];
|
||||
normals.*[index.*+1] = normal[1];
|
||||
normals.*[index.*+2] = normal[2];
|
||||
index.* = index.* + 3;
|
||||
}
|
||||
|
||||
for < 0..2 {
|
||||
vecs.*[index.*] = (x + points[it][0]) * TRIXEL_SIZE;
|
||||
vecs.*[index.*+1] = (y + points[it][1]) * TRIXEL_SIZE;
|
||||
vecs.*[index.*+2] = (z + points[it][2]) * TRIXEL_SIZE;
|
||||
normals.*[index.*] = normal[0];
|
||||
normals.*[index.*+1] = normal[1];
|
||||
normals.*[index.*+2] = normal[2];
|
||||
index.* = index.* + 3;
|
||||
}
|
||||
}
|
||||
|
||||
draw_trile_side_quad :: (vecs: *[..]float, norms: *[..]float, side: Trile_Side, x: int, y: int, z: int) {
|
||||
points : [4][3]float;
|
||||
normal : [3]float;
|
||||
|
||||
if side == {
|
||||
case Trile_Side.TOP;
|
||||
points[0][0] = 1; points[0][1] = 1; points[0][2] = 1;
|
||||
points[1][0] = 1; points[1][1] = 1; points[1][2] = 0;
|
||||
points[2][0] = 0; points[2][1] = 1; points[2][2] = 1;
|
||||
points[3][0] = 0; points[3][1] = 1; points[3][2] = 0;
|
||||
normal[0] = 0; normal[1] = 1; normal[2] = 0;
|
||||
case Trile_Side.BOTTOM;
|
||||
points[0][0] = 1; points[0][1] = 0; points[0][2] = 1;
|
||||
points[2][0] = 1; points[2][1] = 0; points[2][2] = 0;
|
||||
points[1][0] = 0; points[1][1] = 0; points[1][2] = 1;
|
||||
points[3][0] = 0; points[3][1] = 0; points[3][2] = 0;
|
||||
normal[0] = 0; normal[1] = -1; normal[2] = 0;
|
||||
case Trile_Side.FRONT;
|
||||
points[0][0] = 1; points[0][1] = 1; points[0][2] = 1;
|
||||
points[2][0] = 1; points[2][1] = 1; points[2][2] = 0;
|
||||
points[1][0] = 1; points[1][1] = 0; points[1][2] = 1;
|
||||
points[3][0] = 1; points[3][1] = 0; points[3][2] = 0;
|
||||
normal[0] = 1; normal[1] = 0; normal[2] = 0;
|
||||
case Trile_Side.BACK;
|
||||
points[0][0] = 0; points[0][1] = 1; points[0][2] = 1;
|
||||
points[1][0] = 0; points[1][1] = 1; points[1][2] = 0;
|
||||
points[2][0] = 0; points[2][1] = 0; points[2][2] = 1;
|
||||
points[3][0] = 0; points[3][1] = 0; points[3][2] = 0;
|
||||
normal[0] = -1; normal[1] = 0; normal[2] = 0;
|
||||
case Trile_Side.LEFT;
|
||||
points[0][0] = 1; points[0][1] = 1; points[0][2] = 1;
|
||||
points[2][0] = 1; points[2][1] = 0; points[2][2] = 1;
|
||||
points[1][0] = 0; points[1][1] = 1; points[1][2] = 1;
|
||||
points[3][0] = 0; points[3][1] = 0; points[3][2] = 1;
|
||||
normal[0] = 0; normal[1] = 0; normal[2] = 1;
|
||||
case Trile_Side.RIGHT;
|
||||
points[0][0] = 1; points[0][1] = 1; points[0][2] = 0;
|
||||
points[1][0] = 1; points[1][1] = 0; points[1][2] = 0;
|
||||
points[2][0] = 0; points[2][1] = 1; points[2][2] = 0;
|
||||
points[3][0] = 0; points[3][1] = 0; points[3][2] = 0;
|
||||
normal[0] = 0; normal[1] = 0; normal[2] = -1;
|
||||
}
|
||||
|
||||
order : [4]int = .[0,1,3,2];
|
||||
coords : [3]int = .[x,y,z];
|
||||
for i: 0..3 {
|
||||
for j: 0..2 {
|
||||
array_add(vecs, (coords[j]+points[order[i]][j])*TRIXEL_SIZE);
|
||||
array_add(norms, normal[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generate_basic_quad_mesh :: (trileptr: *Trile, vecs: *[..]float, norms: *[..]float) {
|
||||
for x: 0..15 {
|
||||
for y: 0..15 {
|
||||
for z: 0..15 {
|
||||
exposure: u8 = sides_with_air_exposure(trileptr, x, y, z);
|
||||
for trileSideValues {
|
||||
if (cast(u8)it) & exposure then draw_trile_side_quad(vecs, norms, it, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
quads_to_triangles :: (quadVecs: *[..]float, triangleVecs: *[..]float, quadNorms: *[..]float, triangleNorms: *[..]float) {
|
||||
assert(quadVecs.count % (3*4) == 0);
|
||||
assert(quadVecs.count == quadNorms.count);
|
||||
i := 0;
|
||||
while i < quadVecs.count {
|
||||
quadStart : *float = *(quadVecs.*[i]);
|
||||
normStart : *float = *(quadNorms.*[i]);
|
||||
for j : 0..4 {
|
||||
for k : 0..2 {
|
||||
array_add(triangleVecs, quadStart[(j%4)*3+k]);
|
||||
array_add(triangleNorms, normStart[(j%4)*3+k]);
|
||||
}
|
||||
if j == 2 {
|
||||
for k : 0..2 {
|
||||
//add the third point twice to get 2 triangles
|
||||
array_add(triangleVecs, quadStart[(j%4)*3+k]);
|
||||
array_add(triangleNorms, normStart[(j%4)*3+k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
i += 3*4;
|
||||
}
|
||||
}
|
||||
|
||||
Quad :: struct {
|
||||
topRight : Vector2;
|
||||
bottomLeft : Vector2;
|
||||
};
|
||||
|
||||
operator < :: (a: Quad, b: Quad) -> bool {
|
||||
if a.topRight.x == b.topRight.x then return a.topRight.y < b.topRight.y;
|
||||
return a.topRight.x < b.topRight.x;
|
||||
}
|
||||
|
||||
quad_comp :: (a: Quad, b: Quad) -> bool {
|
||||
if a.topRight != b.topRight then return false;
|
||||
if a.bottomLeft != b.bottomLeft then return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
quad_hash :: (q: Quad) -> u32 {
|
||||
return sdbm_hash(*q, size_of(Quad));
|
||||
}
|
||||
|
||||
Quad_Set :: Table(Quad, bool, quad_hash, quad_comp);
|
||||
Quads :: [6][..]Quad_Set;
|
||||
|
||||
side_to_quad_list_index :: (side: Trile_Side) -> s32 {
|
||||
if #complete side == {
|
||||
case Trile_Side.TOP;
|
||||
return 0;
|
||||
case Trile_Side.BOTTOM;
|
||||
return 1;
|
||||
case Trile_Side.FRONT;
|
||||
return 2;
|
||||
case Trile_Side.BACK;
|
||||
return 3;
|
||||
case Trile_Side.LEFT;
|
||||
return 4;
|
||||
case Trile_Side.RIGHT;
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
init_quads :: (quads: *Quads) { // NOTE: unsure about if this is correctly ported.
|
||||
for side : trileSideValues {
|
||||
idx := side_to_quad_list_index(side);
|
||||
for i : 0..15 {
|
||||
quadset : Quad_Set;
|
||||
table_add(*quadset, .{.{16,16}, .{0,0}}, true);
|
||||
array_add(*(quads.*[idx]), quadset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Looking at the side, what axis should be used as x,y and z,
|
||||
// so that x and z are parallel to the side.
|
||||
// (And not all of it seems to work when the used x and y and normal of the side abide by the left hand rule)
|
||||
change_perspective :: (x: *$T, y: *T, z: *T, side: Trile_Side) -> (*T,*T,*T) {
|
||||
if #complete side == {
|
||||
case Trile_Side.TOP;
|
||||
return x, z, y;
|
||||
case Trile_Side.BOTTOM;
|
||||
return z, x, y;
|
||||
case Trile_Side.FRONT;
|
||||
return z, y, x;
|
||||
case Trile_Side.BACK;
|
||||
return y, z, x;
|
||||
case Trile_Side.LEFT;
|
||||
return y, x, z;
|
||||
case Trile_Side.RIGHT;
|
||||
return x, y, z;
|
||||
}
|
||||
}
|
||||
|
||||
quad2d_add_to_quads3d :: (quads2d: *[..]Vector2, quads3d: *[..]Vector3, side: Trile_Side, depth: int, normals: *[..]float) {
|
||||
x, y, z : float;
|
||||
normal : [3]float;
|
||||
offset : float = 0.0;
|
||||
|
||||
ux, uy, uz := change_perspective(*x, *y, *z, side);
|
||||
|
||||
if side == {
|
||||
case Trile_Side.TOP;
|
||||
normal[0] = 0;
|
||||
normal[1] = 1;
|
||||
normal[2] = 0;
|
||||
offset = 1;
|
||||
case Trile_Side.BOTTOM;
|
||||
normal[0] = 0;
|
||||
normal[1] = -1;
|
||||
normal[2] = 0;
|
||||
case Trile_Side.FRONT;
|
||||
normal[0] = 1;
|
||||
normal[1] = 0;
|
||||
normal[2] = 0;
|
||||
offset = 1;
|
||||
case Trile_Side.BACK;
|
||||
normal[0] = -1;
|
||||
normal[1] = 0;
|
||||
normal[2] = 0;
|
||||
case Trile_Side.LEFT;
|
||||
normal[0] = 0;
|
||||
normal[1] = 0;
|
||||
normal[2] = 1;
|
||||
offset = 1;
|
||||
case Trile_Side.RIGHT;
|
||||
normal[0] = 0;
|
||||
normal[1] = 0;
|
||||
normal[2] = -1;
|
||||
}
|
||||
|
||||
for quad : quads2d.* {
|
||||
uz.* = (depth + offset) * TRIXEL_SIZE;
|
||||
ux.* = quad.x * TRIXEL_SIZE;
|
||||
uy.* = quad.y * TRIXEL_SIZE;
|
||||
|
||||
array_add(quads3d, .{x,y,z});
|
||||
array_add(normals, normal[0]);
|
||||
array_add(normals, normal[1]);
|
||||
array_add(normals, normal[2]);
|
||||
}
|
||||
}
|
||||
|
||||
quads_to_vecs :: (quads: *Quads, vecs: *[..]float, normals: *[..]float) {
|
||||
quads3d : [..]Vector3;
|
||||
|
||||
for side : trileSideValues {
|
||||
idx := side_to_quad_list_index(side);
|
||||
for 0..quads.*[idx].count-1 {
|
||||
quads2d : [..]Vector2;
|
||||
table := *(quads.*[idx][it]);
|
||||
for k, v : table {
|
||||
array_add(*quads2d, v.bottomLeft);
|
||||
array_add(*quads2d, .{v.bottomLeft.x, v.topRight.y});
|
||||
array_add(*quads2d, v.topRight);
|
||||
array_add(*quads2d, .{v.topRight.x, v.bottomLeft.y});
|
||||
}
|
||||
quad2d_add_to_quads3d(*quads2d, *quads3d, side, it, normals);
|
||||
}
|
||||
}
|
||||
for quad : quads3d {
|
||||
array_add(vecs, quad.x);
|
||||
array_add(vecs, quad.y);
|
||||
array_add(vecs, quad.z);
|
||||
}
|
||||
}
|
||||
|
||||
a_is_inside_b :: (a: Quad, b: Quad) -> bool {
|
||||
if (b.topRight.x >= a.topRight.x) && (b.topRight.y >= a.topRight.y) {
|
||||
if (b.bottomLeft.x <= a.bottomLeft.x) && (b.bottomLeft.y <= a.bottomLeft.y) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
remove_quad :: (quad: Quad, quadSet: *Quad_Set) {
|
||||
parent : Quad;
|
||||
|
||||
for v, k : quadSet {
|
||||
if k < quad then continue;
|
||||
if a_is_inside_b(quad, k) {
|
||||
parent = k;
|
||||
table_remove(quadSet, k);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
topLeft : Vector2 = .{quad.bottomLeft.x,quad.topRight.y};
|
||||
bottomRight : Vector2 = .{quad.topRight.x,quad.bottomLeft.y};
|
||||
|
||||
if quad.topRight.x != parent.topRight.x {
|
||||
table_add(quadSet, .{parent.topRight,bottomRight}, true);
|
||||
}
|
||||
|
||||
if quad.topRight.y != parent.topRight.y {
|
||||
table_add(quadSet, .{.{quad.topRight.x,parent.topRight.y},.{parent.bottomLeft.x,quad.topRight.y}}, true);
|
||||
}
|
||||
if quad.bottomLeft.y != parent.bottomLeft.y {
|
||||
table_add(quadSet, .{.{parent.topRight.x,quad.bottomLeft.y},.{quad.bottomLeft.x,parent.bottomLeft.y}}, true);
|
||||
}
|
||||
if quad.bottomLeft.x != parent.bottomLeft.x {
|
||||
table_add(quadSet, .{topLeft,parent.bottomLeft}, true);
|
||||
}
|
||||
}
|
||||
|
||||
remove_not_seen :: (trilept: *Trile, quads: *Quads) {
|
||||
for x: 0..15 {
|
||||
for y: 0..15 {
|
||||
for z: 0..15 {
|
||||
exposure: u8 = sides_with_air_exposure(trilept, x, y, z);
|
||||
for side: trileSideValues {
|
||||
if !((cast(u8)side) & exposure) {
|
||||
ux, uy, uz := change_perspective(*x, *y, *z, side);
|
||||
remove_quad(.{.{cast(float)ux.*+1, cast(float)uy.*+1}, .{cast(float)ux.*, cast(float)uy.*}}, *quads.*[side_to_quad_list_index(side)][uz.*]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generate_optimized_quad_mesh :: (trilept: *Trile, vecs: *[..]float, normals: *[..]float) {
|
||||
quads : Quads;
|
||||
init_quads(*quads);
|
||||
remove_not_seen(trilept, *quads);
|
||||
quads_to_vecs(*quads, vecs, normals);
|
||||
}
|
||||
|
||||
Pool :: #import "Pool";
|
||||
meshgenpool : Pool.Pool;
|
||||
|
||||
generate_trile_gfx_matias :: (trileptr : *Trile) -> Trile_GFX {
|
||||
// @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;
|
||||
new_context := context;
|
||||
new_context.allocator = .{Pool.pool_allocator_proc, *meshgenpool};
|
||||
push_context new_context {
|
||||
triangleVecs : [..]float;
|
||||
triangleNorms : [..]float;
|
||||
quadVecs : [..]float;
|
||||
quadNorms : [..]float;
|
||||
|
||||
generate_optimized_quad_mesh(trileptr,*quadVecs,*quadNorms);
|
||||
|
||||
quads_to_triangles(*quadVecs, *triangleVecs,*quadNorms, *triangleNorms);
|
||||
|
||||
trile_vert_buffer_info := sg_buffer_desc.{ data = .{ ptr = triangleVecs.data, size = xx (triangleVecs.count * 4) } };
|
||||
trile_vert_buffer := sg_make_buffer(*trile_vert_buffer_info);
|
||||
|
||||
trile_normal_buffer_info := sg_buffer_desc.{ data = .{ ptr = triangleNorms.data, size = xx (triangleNorms.count * 4) } };
|
||||
trile_normal_buffer := sg_make_buffer(*trile_normal_buffer_info);
|
||||
|
||||
log_debug("Successfully generated mesh for trile with % triangles.", triangleVecs.count / 3 / 3);
|
||||
|
||||
centres : [..]float;
|
||||
|
||||
// Generate triangle centers.
|
||||
for 0..(triangleVecs.count/3/3)-1 {
|
||||
x1 := triangleVecs[it * 9 + 0];
|
||||
x2 := triangleVecs[it * 9 + 3];
|
||||
x3 := triangleVecs[it * 9 + 6];
|
||||
xr := (x1+x2+x3) / 3.0;
|
||||
|
||||
y1 := triangleVecs[it * 9 + 1];
|
||||
y2 := triangleVecs[it * 9 + 4];
|
||||
y3 := triangleVecs[it * 9 + 7];
|
||||
yr := (y1+y2+y3) / 3.0;
|
||||
|
||||
z1 := triangleVecs[it * 9 + 2];
|
||||
z2 := triangleVecs[it * 9 + 5];
|
||||
z3 := triangleVecs[it * 9 + 8];
|
||||
zr := (z1+z2+z3) / 3.0;
|
||||
|
||||
for 0..2 {
|
||||
array_add(*centres, xr);
|
||||
array_add(*centres, yr);
|
||||
array_add(*centres, zr);
|
||||
}
|
||||
}
|
||||
|
||||
trile_centre_buffer_info := sg_buffer_desc.{ data = .{ ptr = centres.data, size = xx (centres.count * 4) } };
|
||||
trile_centre_buffer := sg_make_buffer(*trile_centre_buffer_info);
|
||||
|
||||
// Create the texture for the trile, from which it gets it's colors for trixels.
|
||||
|
||||
materialdata : [16*16*16*4]u8;
|
||||
counter : int = 0;
|
||||
|
||||
for x: 0..15 {
|
||||
for y: 0..15 {
|
||||
for z: 0..15 {
|
||||
if trileptr.trixels[x][y][z].empty {
|
||||
// @ToDo: add some null pattern here to help in shader side.
|
||||
materialdata[counter + 0] = 0;
|
||||
materialdata[counter + 1] = 0;
|
||||
materialdata[counter + 2] = 0;
|
||||
materialdata[counter + 3] = 0;
|
||||
counter += 4;
|
||||
} else {
|
||||
r,g,b,a := material_to_rgba(trileptr.trixels[x][y][z].material);
|
||||
materialdata[counter + 0] = r;
|
||||
materialdata[counter + 1] = g;
|
||||
materialdata[counter + 2] = b;
|
||||
materialdata[counter + 3] = a;
|
||||
counter += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imgdata : sg_image_data;
|
||||
imgdata.subimage[0][0] = .{materialdata.data, materialdata.count};
|
||||
|
||||
texdesc : sg_image_desc = .{
|
||||
render_target = false,
|
||||
width = 16,
|
||||
height = 16*16,
|
||||
pixel_format = sg_pixel_format.RGBA8,
|
||||
sample_count = 1,
|
||||
data = imgdata
|
||||
};
|
||||
|
||||
img := sg_make_image(*texdesc);
|
||||
|
||||
state := sg_query_image_state(img);
|
||||
log_debug("IMG: %", state);
|
||||
|
||||
context.allocator = old_alloc;
|
||||
vecsCopy := array_copy(triangleVecs);
|
||||
Pool.reset(*meshgenpool);
|
||||
|
||||
lod4_voxels := downsample_trile(trileptr, 4);
|
||||
lod_4 := bake_lod_cube_mesh(lod4_voxels, 4);
|
||||
lod2_voxels := downsample_trile(trileptr, 2);
|
||||
lod_2 := bake_lod_cube_mesh(lod2_voxels, 2);
|
||||
|
||||
return .{ img, trile_vert_buffer, trile_normal_buffer, trile_centre_buffer, vecsCopy, triangleVecs.count / 3, lod_4, lod_2 };
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
Trile_Side :: enum_flags u8 {
|
||||
TOP :: 0x1; // Larger Y
|
||||
LEFT :: 0x2; // Larger Z
|
||||
RIGHT :: 0x4; // Smaller Z
|
||||
FRONT :: 0x8; // Larger X
|
||||
BACK :: 0x10; // Smaller X
|
||||
BOTTOM :: 0x20; // Smaller Ys
|
||||
}
|
||||
|
||||
trileSideValues : [6]Trile_Side = .[.TOP, .LEFT, .RIGHT, .FRONT, .BACK, .BOTTOM];
|
||||
|
||||
swap_xyz_for_side :: (x: int, y: int, z: int, Trile_Side) -> (int, int, int) {
|
||||
|
||||
}
|
||||
|
||||
sides_with_air_exposure :: (trileptr: *Trile, x: int, y: int, z: int) -> u8 {
|
||||
res : u8 = 0;
|
||||
if trileptr.trixels[x][y][z].empty then return res;
|
||||
|
||||
if y == 15 || trileptr.trixels[x][y+1][z].empty then res |= xx Trile_Side.TOP;
|
||||
if y == 0 || trileptr.trixels[x][y-1][z].empty then res |= xx Trile_Side.BOTTOM;
|
||||
if z == 15 || trileptr.trixels[x][y][z+1].empty then res |= xx Trile_Side.LEFT;
|
||||
if z == 0 || trileptr.trixels[x][y][z-1].empty then res |= xx Trile_Side.RIGHT;
|
||||
if x == 15 || trileptr.trixels[x+1][y][z].empty then res |= xx Trile_Side.FRONT;
|
||||
if x == 0 || trileptr.trixels[x-1][y][z].empty then res |= xx Trile_Side.BACK;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
meshgen :: (trile: *Trile) {
|
||||
for trileSideValues {
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,107 +0,0 @@
|
||||
disable_dof_post_process : bool = false;
|
||||
|
||||
Post_Process :: struct {
|
||||
exposure : float = 1.0; @Slider,0,3,0.1;
|
||||
contrast : float = 1.0; @Slider,0,3,0.1;
|
||||
saturation : float = 1.0; @Slider,0.0,5.0,0.1;
|
||||
gamma : float = 1.0; @Slider,0.3,3.0,0.1;
|
||||
tonemap : float = 0.0; @Slider,0,1,1;
|
||||
ssao : float = 0.0; @Slider,0,5,0.1;
|
||||
ssao_size : s32 = 1; @Slider,0,5,1;
|
||||
dilate_separation : float = 1.0; @Slider,0,6,0.1;
|
||||
dilate_size : s32 = 0; @Slider,0,10,1;
|
||||
dilate_min : float = 0.1; @Slider,0,1,0.1;
|
||||
dilate_max : float = 0.3; @Slider,0,1,0.1;
|
||||
dof_blur_size : float = 1.0; @Slider,0.0,2.0,0.1;
|
||||
dof_min : float = 1.0; @Slider,0,10,1;
|
||||
dof_max : float = 3.0; @Slider,0,50,1;
|
||||
dof_point : float = 5.0; @Slider,0,30,1;
|
||||
bloom_treshold : float = 0.4; @Slider,0,1,0.1;
|
||||
bloom_amount : float = 0.0; @Slider,0,5,0.1;
|
||||
|
||||
vignette_intensity: float = 0.0; @Slider,0,1,0.1;
|
||||
vignette_radius : float = 0.5; @Slider,0,1,0.1;
|
||||
scanlines_intensity: float = 0.0; @Slider,0,1,0.1;
|
||||
scanlines_density : float = 1.0; @Slider,0,10,0.1;
|
||||
chromatic_aberration_intensity: float = 0.0; @Slider,0,0.05,0.001;
|
||||
film_grain_intensity: float = 0.0; @Slider,0,0.5,0.001;
|
||||
barrel_distortion_intensity: float = 0.0; @Slider,-2,2,0.1;
|
||||
lut_mode: s32 = 0; @Slider,0,2,1; // 0 -> no LUT, 1 -> LUT with interpolation 2 -> LUT no iterpolate
|
||||
dither_intensity: float = 0.0; @Slider,0,1,0.05;
|
||||
}
|
||||
|
||||
|
||||
current_post_process : Post_Process;
|
||||
|
||||
Lighting_Config :: struct {
|
||||
ambient_intensity : float = 0.35; @Slider,0,2,0.05
|
||||
emissive_scale : float = 5.0; @Slider,0,20,0.5
|
||||
indirect_diff_scale : float = 1.0; @Slider,0,3,0.1
|
||||
indirect_spec_scale : float = 1.0; @Slider,0,3,0.1
|
||||
ambient_color : Vector3 = .{0.3,0.3,0.4}; @Color
|
||||
indirect_tint : Vector3 = .{1.05,1.0,0.9}; @Color
|
||||
}
|
||||
|
||||
current_lighting_config : Lighting_Config;
|
||||
|
||||
Post_Process_Save :: struct {
|
||||
#as using pp: Post_Process;
|
||||
lut_name: string;
|
||||
}
|
||||
|
||||
load_post_process_from_pack :: () {
|
||||
s := load_string_from_pack("game_core", "postprocess.json");
|
||||
success, save := Jaison.json_parse_string(s, Post_Process_Save,, temp);
|
||||
if success {
|
||||
current_post_process = save.pp;
|
||||
// Restore LUT selection by name.
|
||||
if save.lut_name.count > 0 {
|
||||
for LUT_list {
|
||||
if it.name == save.lut_name {
|
||||
g_current_lut_texture_index = cast(s32) it_index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
save_post_process :: () {
|
||||
#if OS != .WASM {
|
||||
file :: #import "File";
|
||||
save: Post_Process_Save;
|
||||
save.pp = current_post_process;
|
||||
if g_current_lut_texture_index >= 0 && g_current_lut_texture_index < LUT_list.count {
|
||||
save.lut_name = LUT_list[g_current_lut_texture_index].name;
|
||||
}
|
||||
json := Jaison.json_write_string(save, " ");
|
||||
file.write_entire_file(tprint("%/game_core/postprocess.json", GAME_RESOURCES_DIR), json);
|
||||
}
|
||||
}
|
||||
|
||||
reset_post_process :: () {
|
||||
load_post_process_from_pack();
|
||||
} @Command
|
||||
|
||||
Color_LUT :: struct {
|
||||
name: string;
|
||||
image: sg_image;
|
||||
}
|
||||
|
||||
LUT_list : [..]Color_LUT;
|
||||
LUT_name_list : [..]string;
|
||||
g_current_lut_texture_index : s32 = 0;
|
||||
|
||||
|
||||
add_image_to_lut_list :: (img: sg_image, name: string) {
|
||||
for LUT_list {
|
||||
if it.name == name then return;
|
||||
}
|
||||
|
||||
newSheet := Color_LUT.{
|
||||
name = sprint("%", name),
|
||||
image = img,
|
||||
};
|
||||
array_add(*LUT_list, newSheet);
|
||||
array_add(*LUT_name_list, newSheet.name);
|
||||
}
|
||||
@ -1,49 +1,21 @@
|
||||
/*
|
||||
// Rendering. Everything outside this directory goes through the Scene API in
|
||||
// scene.jai and text.jai.
|
||||
|
||||
The rendering pipeline.
|
||||
|
||||
@ToDo: Write something smart about our rendering
|
||||
architecture.
|
||||
|
||||
*/
|
||||
|
||||
#load "sky.jai";
|
||||
#load "ssao.jai";
|
||||
#load "core.jai";
|
||||
#load "tasks.jai";
|
||||
#load "scene.jai";
|
||||
#load "text.jai";
|
||||
#load "camera.jai";
|
||||
#load "arbtri.jai";
|
||||
#load "debug_draw.jai";
|
||||
#load "meshgen.jai";
|
||||
#load "lodgen.jai";
|
||||
#load "helpers.jai";
|
||||
#load "animation.jai";
|
||||
#load "pipelines.jai";
|
||||
#load "post_processing.jai";
|
||||
#load "backend_sokol_helpers.jai";
|
||||
|
||||
#scope_file
|
||||
|
||||
initted : bool;
|
||||
old_w : int;
|
||||
old_h : int;
|
||||
|
||||
on_window_resize :: () {
|
||||
// Recreate textures that are rendering targets and dependent on window size.
|
||||
create_plane_pipeline_reflection_images();
|
||||
create_final_image();
|
||||
create_ssao_images();
|
||||
create_sh_irradiance_image();
|
||||
// Reset glyph cache so stale sizes from resizing don't fill the atlas.
|
||||
w, h : s32;
|
||||
fonsGetAtlasSize(state.fons, *w, *h);
|
||||
fonsResetAtlas(state.fons, w, h);
|
||||
render :: () {
|
||||
text_end_frame();
|
||||
scene_end_frame();
|
||||
g_debug_line_count = 0;
|
||||
g_overlay_line_count = 0;
|
||||
}
|
||||
|
||||
#scope_export
|
||||
|
||||
check_and_handle_window_resize :: () {
|
||||
w,h := get_window_size();
|
||||
w, h := get_window_size();
|
||||
if !initted {
|
||||
old_w = w;
|
||||
old_h = h;
|
||||
@ -52,6 +24,13 @@ check_and_handle_window_resize :: () {
|
||||
}
|
||||
if w != old_w || h != old_h {
|
||||
old_w = w; old_h = h;
|
||||
on_window_resize();
|
||||
// UI font sizes follow the window, so stale sizes would fill the atlas.
|
||||
text_reset_atlas();
|
||||
}
|
||||
}
|
||||
|
||||
#scope_file
|
||||
|
||||
initted : bool;
|
||||
old_w : int;
|
||||
old_h : int;
|
||||
|
||||
200
src/rendering/scene.jai
Normal file
200
src/rendering/scene.jai
Normal file
@ -0,0 +1,200 @@
|
||||
// The Scene API. Game, editor and UI code say what to draw through this file;
|
||||
// how it gets drawn is the renderer's business. The world is persistent: chunks
|
||||
// are uploaded when loaded or edited. Everything else is submitted every frame
|
||||
// and dropped by render().
|
||||
|
||||
Trile_Mesh :: struct { id: u32; }
|
||||
Texture :: struct { id: u32; }
|
||||
Font_Face :: struct { id: s32; }
|
||||
View_Id :: struct { index: s32; }
|
||||
|
||||
// Grows as each part of the renderer comes back: sky, sun, fog, water, post.
|
||||
Environment :: struct {
|
||||
}
|
||||
|
||||
View :: struct {
|
||||
camera : Camera;
|
||||
environment : *Environment;
|
||||
draw_world : bool = true;
|
||||
}
|
||||
|
||||
Trile_Tint :: enum u8 {
|
||||
NONE;
|
||||
ADD_PREVIEW;
|
||||
DELETE_PREVIEW;
|
||||
}
|
||||
|
||||
// A billboard with this face direction turns to face the camera.
|
||||
BILLBOARD_FACE_CAMERA :: Vector3.{-100, -100, -100};
|
||||
|
||||
Blend_Mode :: enum u8 {
|
||||
ALPHA;
|
||||
ADDITIVE;
|
||||
}
|
||||
|
||||
Particle_Instance :: struct {
|
||||
position : Vector3;
|
||||
size : float;
|
||||
uv_rect : Vector4; // x, y, w, h in the sheet, normalized
|
||||
color : Vector4;
|
||||
}
|
||||
|
||||
// Screen-space, in pixels from the top left.
|
||||
Ui_Vertex :: struct {
|
||||
position : Vector2;
|
||||
uv : Vector2;
|
||||
color : Vector4;
|
||||
}
|
||||
|
||||
// --- Persistent resources -------------------------------------------------
|
||||
|
||||
trile_mesh_create :: (trile: *Trile) -> Trile_Mesh {
|
||||
scene.trile_mesh_count += 1;
|
||||
return .{scene.trile_mesh_count};
|
||||
}
|
||||
|
||||
trile_mesh_update :: (mesh: Trile_Mesh, trile: *Trile) {
|
||||
}
|
||||
|
||||
trile_mesh_destroy :: (mesh: Trile_Mesh) {
|
||||
}
|
||||
|
||||
// Pixels are RGBA8.
|
||||
texture_create :: (width: s32, height: s32, pixels: []u8) -> Texture {
|
||||
scene.texture_count += 1;
|
||||
return .{scene.texture_count};
|
||||
}
|
||||
|
||||
texture_update :: (texture: Texture, pixels: []u8) {
|
||||
}
|
||||
|
||||
texture_destroy :: (texture: Texture) {
|
||||
}
|
||||
|
||||
// --- Persistent world -----------------------------------------------------
|
||||
|
||||
World_Group :: struct {
|
||||
mesh : Trile_Mesh;
|
||||
instances : []Trile_Instance;
|
||||
}
|
||||
|
||||
// Replaces whatever the chunk held before. The groups are copied.
|
||||
world_set_chunk :: (key: Chunk_Key, groups: []World_Group) {
|
||||
chunk := find_or_add(*scene.chunks, key);
|
||||
for chunk.groups array_free(it.instances);
|
||||
array_reset_keeping_memory(*chunk.groups);
|
||||
for groups {
|
||||
group := array_add(*chunk.groups);
|
||||
group.mesh = it.mesh;
|
||||
group.instances = array_copy(it.instances);
|
||||
}
|
||||
}
|
||||
|
||||
world_remove_chunk :: (key: Chunk_Key) {
|
||||
chunk := table_find_pointer(*scene.chunks, key);
|
||||
if !chunk return;
|
||||
for chunk.groups array_free(it.instances);
|
||||
array_free(chunk.groups);
|
||||
table_remove(*scene.chunks, key);
|
||||
}
|
||||
|
||||
world_clear :: () {
|
||||
for chunk: scene.chunks {
|
||||
for chunk.groups array_free(it.instances);
|
||||
array_free(chunk.groups);
|
||||
}
|
||||
table_reset(*scene.chunks);
|
||||
}
|
||||
|
||||
// --- Per frame ------------------------------------------------------------
|
||||
|
||||
add_view :: (view: View) -> View_Id {
|
||||
array_add(*scene.views, view);
|
||||
return .{xx (scene.views.count - 1)};
|
||||
}
|
||||
|
||||
draw_trile :: (view: View_Id, mesh: Trile_Mesh, position: Vector3, orientation: u8, tint := Trile_Tint.NONE) {
|
||||
array_add(*scene.triles, .{view, mesh, position, orientation, tint});
|
||||
}
|
||||
|
||||
// uv_rect is x, y, w, h in the sheet, normalized; a negative w mirrors it.
|
||||
draw_billboard :: (view: View_Id, sheet: Texture, uv_rect: Vector4, size: Vector2, position: Vector3, face := BILLBOARD_FACE_CAMERA) {
|
||||
array_add(*scene.billboards, .{view, sheet, uv_rect, size, position, face});
|
||||
}
|
||||
|
||||
draw_particles :: (view: View_Id, sheet: Texture, blend: Blend_Mode, particles: []Particle_Instance) {
|
||||
array_add(*scene.particles, .{view, sheet, blend, array_copy(particles,, temp)});
|
||||
}
|
||||
|
||||
// Untextured triangles pass a zero texture.
|
||||
ui_triangles :: (vertices: []Ui_Vertex, texture: Texture) {
|
||||
array_add(*scene.ui, .{texture = texture, vertices = array_copy(vertices,, temp)});
|
||||
}
|
||||
|
||||
ui_scissor :: (x: s32, y: s32, w: s32, h: s32) {
|
||||
array_add(*scene.ui, .{scissor = .{x, y, w, h}, set_scissor = true});
|
||||
}
|
||||
|
||||
ui_scissor_clear :: () {
|
||||
array_add(*scene.ui, .{clear_scissor = true});
|
||||
}
|
||||
|
||||
// --- Renderer side: only src/rendering reads these -------------------------
|
||||
|
||||
Scene_Chunk :: struct {
|
||||
groups : [..]World_Group;
|
||||
}
|
||||
|
||||
Scene_Trile :: struct {
|
||||
view : View_Id;
|
||||
mesh : Trile_Mesh;
|
||||
position : Vector3;
|
||||
orientation : u8;
|
||||
tint : Trile_Tint;
|
||||
}
|
||||
|
||||
Scene_Billboard :: struct {
|
||||
view : View_Id;
|
||||
sheet : Texture;
|
||||
uv_rect : Vector4;
|
||||
size : Vector2;
|
||||
position : Vector3;
|
||||
face : Vector3;
|
||||
}
|
||||
|
||||
Scene_Particles :: struct {
|
||||
view : View_Id;
|
||||
sheet : Texture;
|
||||
blend : Blend_Mode;
|
||||
particles : []Particle_Instance;
|
||||
}
|
||||
|
||||
// One entry of the UI stream: either a batch of triangles or a scissor change.
|
||||
Scene_Ui :: struct {
|
||||
texture : Texture;
|
||||
vertices : []Ui_Vertex;
|
||||
scissor : Ui_Rect;
|
||||
set_scissor : bool;
|
||||
clear_scissor : bool;
|
||||
}
|
||||
|
||||
scene : struct {
|
||||
trile_mesh_count : u32;
|
||||
texture_count : u32;
|
||||
|
||||
chunks : Table(Chunk_Key, Scene_Chunk, chunk_key_hash, chunk_key_compare);
|
||||
|
||||
views : [..]View;
|
||||
triles : [..]Scene_Trile;
|
||||
billboards : [..]Scene_Billboard;
|
||||
particles : [..]Scene_Particles;
|
||||
ui : [..]Scene_Ui;
|
||||
}
|
||||
|
||||
scene_end_frame :: () {
|
||||
array_reset_keeping_memory(*scene.views);
|
||||
array_reset_keeping_memory(*scene.triles);
|
||||
array_reset_keeping_memory(*scene.billboards);
|
||||
array_reset_keeping_memory(*scene.particles);
|
||||
array_reset_keeping_memory(*scene.ui);
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
draw_sky :: (cam: *Camera, worldConfig: *World_Config = null) {
|
||||
mvp := create_viewproj(cam);
|
||||
vs_params : Sky_Vs_Params;
|
||||
|
||||
world_conf : Sky_World_Config;
|
||||
|
||||
wc : *World_Config = ifx worldConfig == null then *(World_Config.{}) else worldConfig;
|
||||
|
||||
world_config_to_shader_type(wc, *world_conf);
|
||||
|
||||
vs_params.mvp = mvp.floats;
|
||||
sg_apply_pipeline(gPipelines.sky.pipeline);
|
||||
sg_apply_bindings(*gPipelines.sky.bind);
|
||||
sg_apply_uniforms(UB_sky_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_apply_uniforms(UB_sky_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
|
||||
sg_draw(0, 36, 1);
|
||||
}
|
||||
|
||||
get_frustum_corners :: (cam: *Camera) -> [8]Vector3 {
|
||||
mat_view := create_lookat(cam);
|
||||
mat_proj := create_perspective(cam);
|
||||
|
||||
corners : [8]Vector3;
|
||||
corners[0] = unproject(Vector3.{-1, -1, -1}, mat_proj, mat_view);
|
||||
corners[1] = unproject(Vector3.{1, -1, -1}, mat_proj, mat_view);
|
||||
corners[2] = unproject(Vector3.{1, 1, -1}, mat_proj, mat_view);
|
||||
corners[3] = unproject(Vector3.{-1, 1, -1}, mat_proj, mat_view);
|
||||
corners[4] = unproject(Vector3.{-1, -1, 1}, mat_proj, mat_view);
|
||||
corners[5] = unproject(Vector3.{1, -1, 1}, mat_proj, mat_view);
|
||||
corners[6] = unproject(Vector3.{1, 1, 1}, mat_proj, mat_view);
|
||||
corners[7] = unproject(Vector3.{-1, 1, 1}, mat_proj, mat_view);
|
||||
return corners;
|
||||
}
|
||||
|
||||
create_shadow_viewproj :: (cam: *Camera, conf: *World_Config) -> Matrix4 {
|
||||
up: Vector3 = .{0, 1, 0};
|
||||
targetToPos := conf.sunPosition;
|
||||
A := normalize(targetToPos);
|
||||
B := normalize(cross(up, A));
|
||||
C := cross(A, B);
|
||||
|
||||
camcpy := cam.*;
|
||||
camcpy.far = 50;
|
||||
camcpy.near = 0.5;
|
||||
|
||||
frustum_corners := get_frustum_corners(*camcpy);
|
||||
|
||||
avg : Vector3;
|
||||
for frustum_corners {
|
||||
avg += it;
|
||||
}
|
||||
avg /= 8.0;
|
||||
sunCameraPosition := -targetToPos * 50.0;
|
||||
|
||||
view := Matrix4.{
|
||||
B.x, C.x, A.x, 0,
|
||||
B.y, C.y, A.y, 0,
|
||||
B.z, C.z, A.z, 0,
|
||||
-dot(B, sunCameraPosition), -dot(C, sunCameraPosition), -dot(A, sunCameraPosition), 1
|
||||
};
|
||||
proj := matrix_ortho(-30, 30, -30, 30, 0, 100);
|
||||
return view*proj;
|
||||
}
|
||||
|
||||
// taken from raymath.h
|
||||
matrix_ortho :: (left: float, right: float, bottom: float, top: float, near: float, far: float) -> Matrix4 {
|
||||
rl := right - left;
|
||||
tb := top - bottom;
|
||||
fn := far - near;
|
||||
|
||||
return Matrix4.{
|
||||
2.0/rl,0,0,0,
|
||||
0,2.0/tb,0,0,
|
||||
0,0,-2/fn,0,
|
||||
-(left + right)/rl, -(top+bottom)/tb, (far+near)/fn, 1
|
||||
};
|
||||
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
#scope_file
|
||||
|
||||
Random :: #import "Random";
|
||||
|
||||
#scope_export
|
||||
|
||||
g_ssao_samples : [64][4]float;
|
||||
g_ssao_noise : [16*4]float;
|
||||
|
||||
init_ssao :: () {
|
||||
for 0..63 {
|
||||
vec := Vector3.{
|
||||
Random.random_get_zero_to_one() * 2 - 1,
|
||||
Random.random_get_zero_to_one() * 2 - 1,
|
||||
Random.random_get_zero_to_one(),
|
||||
};
|
||||
vec = normalize(vec);
|
||||
vec *= Random.random_get_zero_to_one();
|
||||
scale := cast(float)it/64.0;
|
||||
scale = lerp(0.1, 1.0, scale*scale);
|
||||
vec *= scale;
|
||||
g_ssao_samples[it][0] = vec.x;
|
||||
g_ssao_samples[it][1] = vec.y;
|
||||
g_ssao_samples[it][2] = vec.z;
|
||||
g_ssao_samples[it][3] = 0;
|
||||
}
|
||||
for 0..15 {
|
||||
g_ssao_noise[it*4+0] = Random.random_get_zero_to_one() * 2 - 1;
|
||||
g_ssao_noise[it*4+1] = Random.random_get_zero_to_one() * 2 - 1;
|
||||
g_ssao_noise[it*4+2] = 0.0;
|
||||
g_ssao_noise[it*4+3] = 0.0;
|
||||
}
|
||||
}
|
||||
@ -1,278 +0,0 @@
|
||||
#scope_export
|
||||
|
||||
Rendering_Task_Type :: enum {
|
||||
INVALID;
|
||||
GROUND; // We need to add an ability to invalidate buffer here too.
|
||||
SKY;
|
||||
SET_CAMERA;
|
||||
SET_LIGHT;
|
||||
TRILE; // We need to add an ability to invalidate buffer instead of updating it constantly. Also probably have a buffer for static world triles and one for moving ones.
|
||||
TRILE_DYNAMIC;
|
||||
TRILE_RDM;
|
||||
TRIXELS;
|
||||
BILLBOARD;
|
||||
PARTICLES;
|
||||
PARTICLES_BUFFER;
|
||||
};
|
||||
|
||||
Rendering_Task :: struct {
|
||||
type : Rendering_Task_Type = .INVALID;
|
||||
};
|
||||
|
||||
Rendering_Task_World :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
world : *World;
|
||||
}
|
||||
|
||||
Rendering_Task_Sky :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
t.type = .SKY;
|
||||
worldConfig : *World_Config;
|
||||
}
|
||||
|
||||
Rendering_Task_Set_Light :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
t.type = .SET_LIGHT;
|
||||
worldConfig : *World_Config;
|
||||
}
|
||||
|
||||
Rendering_Task_Ground :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
t.type = .GROUND;
|
||||
world : *World;
|
||||
}
|
||||
|
||||
Rendering_Task_Billboard :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
t.type = .BILLBOARD;
|
||||
position : Vector3;
|
||||
animation : *Animation;
|
||||
frame : s32;
|
||||
flipX : bool;
|
||||
flipY : bool;
|
||||
faceDir : Vector3 = .{-100, -100, -100};
|
||||
}
|
||||
|
||||
Rendering_Task_Trile :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
t.type = .TRILE;
|
||||
trile : string;
|
||||
chunk_key : Chunk_Key;
|
||||
positions : []Trile_Instance;
|
||||
worldConf : *World_Config;
|
||||
preview_mode : s32 = 0; // 0=normal, 1=add preview (blue), 2=delete preview (red)
|
||||
shadow_only : bool = false; // only submit to shadow bucket (frustum-culled from camera)
|
||||
skip_main : bool = false; // RDM-flagged instances still cast shadows / write gbuffer / reflect, but main pass uses the RDM pipeline
|
||||
lod_index : s32 = 0; // 0 = full detail, 1 = 4^3 LOD, 2 = 2^3 LOD
|
||||
}
|
||||
|
||||
// Triles at arbitrary float world positions (entities, moving things).
|
||||
// Shares the instance buffer and pipelines with the static TRILE path, so it
|
||||
// participates in main/gbuffer/shadow/reflection just like world triles.
|
||||
// chunk_key is the enclosing chunk, used only for SH probe lookup.
|
||||
Rendering_Task_Trile_Dynamic :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
t.type = .TRILE_DYNAMIC;
|
||||
trile : string;
|
||||
positions : []Vector4; // xyz = world position, w = orientation 0..23
|
||||
chunk_key : Chunk_Key;
|
||||
worldConf : *World_Config;
|
||||
}
|
||||
|
||||
Rendering_Task_Trile_RDM :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
t.type = .TRILE_RDM;
|
||||
trile : string;
|
||||
position : Vector4; // xyz=world position, w=orientation
|
||||
atlas_rect : Vector4; // global atlas UV rect (zeros until Step 6 wires the manifest)
|
||||
worldConf : *World_Config;
|
||||
}
|
||||
|
||||
Rendering_Task_Trixels :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
t.type = .TRIXELS;
|
||||
colMultipliers : *[16][16][16]Vector3;
|
||||
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 {
|
||||
#as using t : Rendering_Task;
|
||||
t.type = .PARTICLES;
|
||||
count : s32;
|
||||
instance_offset : s32;
|
||||
blend_mode : Particle_Blend_Mode;
|
||||
sheet : sg_image;
|
||||
}
|
||||
|
||||
Rendering_Task_Particles_Buffer :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
t.type = .PARTICLES_BUFFER;
|
||||
total_count : s32;
|
||||
pos_size : [MAX_PARTICLES]Vector4;
|
||||
uv_rects : [MAX_PARTICLES]Vector4;
|
||||
colors : [MAX_PARTICLES]Vector4;
|
||||
}
|
||||
|
||||
Rendering_Task_Set_Camera :: struct {
|
||||
#as using t : Rendering_Task;
|
||||
camera : Camera;
|
||||
planeHeight : float;
|
||||
}
|
||||
|
||||
rendering_tasklist_clear :: () {
|
||||
array_reset_keeping_memory(*rendering_tasklist);
|
||||
}
|
||||
|
||||
add_rendering_task :: (task: $T) {
|
||||
task_ptr := New(T,, temp);
|
||||
task_ptr.* = task;
|
||||
array_add(*rendering_tasklist, task_ptr);
|
||||
}
|
||||
|
||||
rendering_tasklist : [..]*Rendering_Task;
|
||||
|
||||
tasks_to_commands :: () {
|
||||
trile_add_counter: s32 = 0;
|
||||
trile_rdm_add_counter: s32 = 0;
|
||||
for rendering_tasklist {
|
||||
if it.type == {
|
||||
case .SET_LIGHT;
|
||||
lighttask := (cast(*Rendering_Task_Set_Light)it);
|
||||
lightcmd := New(Render_Command_Set_Light,, temp);
|
||||
lightcmd.worldConfig = lighttask.worldConfig;
|
||||
array_add(*render_command_buckets.setup, lightcmd);
|
||||
case .TRIXELS;
|
||||
trixelsTask := (cast(*Rendering_Task_Trixels)it);
|
||||
updateCommand := New(Render_Command_Update_Trixels,, temp);
|
||||
updateCommand.trile = trixelsTask.trile;
|
||||
updateCommand.colMultipliers = trixelsTask.colMultipliers;
|
||||
updateCommand.is_secondary = trixelsTask.is_secondary;
|
||||
array_add(*render_command_buckets.setup, updateCommand);
|
||||
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);
|
||||
// Currently no need to draw trixels anywhere but the editor so no
|
||||
// need for drawing them in the planar reflection pass...
|
||||
// array_add(*render_command_buckets.reflection, drawCommand);
|
||||
|
||||
case .TRILE;
|
||||
trileTask := (cast(*Rendering_Task_Trile)it);
|
||||
addPositionsCmd := New(Render_Command_Add_Trile_Positions,, temp);
|
||||
addPositionsCmd.positions = trileTask.positions;
|
||||
addPositionsCmd.chunk = trileTask.chunk_key;
|
||||
array_add(*render_command_buckets.setup, addPositionsCmd);
|
||||
drawPositionsCmd := New(Render_Command_Draw_Trile_Positions,, temp);
|
||||
drawPositionsCmd.trile = trileTask.trile;
|
||||
drawPositionsCmd.chunk_key = trileTask.chunk_key;
|
||||
drawPositionsCmd.amount = cast(s32)trileTask.positions.count;
|
||||
drawPositionsCmd.conf = trileTask.worldConf;
|
||||
drawPositionsCmd.preview_mode = trileTask.preview_mode;
|
||||
drawPositionsCmd.offset_index = trile_add_counter;
|
||||
drawPositionsCmd.lod_index = trileTask.lod_index;
|
||||
trile_add_counter += 1;
|
||||
if trileTask.shadow_only {
|
||||
array_add(*render_command_buckets.shadow, drawPositionsCmd);
|
||||
} else if trileTask.preview_mode != 0 {
|
||||
array_add(*render_command_buckets.main, drawPositionsCmd);
|
||||
} else if trileTask.skip_main {
|
||||
array_add(*render_command_buckets.reflection, drawPositionsCmd);
|
||||
array_add(*render_command_buckets.gbuffer, drawPositionsCmd);
|
||||
array_add(*render_command_buckets.shadow, drawPositionsCmd);
|
||||
} else {
|
||||
array_add(*render_command_buckets.reflection, drawPositionsCmd);
|
||||
array_add(*render_command_buckets.main, drawPositionsCmd);
|
||||
array_add(*render_command_buckets.gbuffer, drawPositionsCmd);
|
||||
array_add(*render_command_buckets.shadow, drawPositionsCmd);
|
||||
}
|
||||
case .TRILE_DYNAMIC;
|
||||
dynTask := (cast(*Rendering_Task_Trile_Dynamic)it);
|
||||
addF32Cmd := New(Render_Command_Add_Trile_Positions_F32,, temp);
|
||||
addF32Cmd.positions = dynTask.positions;
|
||||
array_add(*render_command_buckets.setup, addF32Cmd);
|
||||
drawDynCmd := New(Render_Command_Draw_Trile_Positions,, temp);
|
||||
drawDynCmd.trile = dynTask.trile;
|
||||
drawDynCmd.chunk_key = dynTask.chunk_key;
|
||||
drawDynCmd.amount = cast(s32)dynTask.positions.count;
|
||||
drawDynCmd.conf = dynTask.worldConf;
|
||||
drawDynCmd.offset_index = trile_add_counter;
|
||||
trile_add_counter += 1;
|
||||
array_add(*render_command_buckets.reflection, drawDynCmd);
|
||||
array_add(*render_command_buckets.main, drawDynCmd);
|
||||
array_add(*render_command_buckets.gbuffer, drawDynCmd);
|
||||
array_add(*render_command_buckets.shadow, drawDynCmd);
|
||||
case .TRILE_RDM;
|
||||
rdmTask := (cast(*Rendering_Task_Trile_RDM)it);
|
||||
addCmd := New(Render_Command_Add_Trile_RDM_Position,, temp);
|
||||
addCmd.position = rdmTask.position;
|
||||
array_add(*render_command_buckets.setup, addCmd);
|
||||
drawCmd := New(Render_Command_Draw_Trile_RDM,, temp);
|
||||
drawCmd.trile = rdmTask.trile;
|
||||
drawCmd.conf = rdmTask.worldConf;
|
||||
drawCmd.atlas_rect = rdmTask.atlas_rect;
|
||||
drawCmd.offset_index = trile_rdm_add_counter;
|
||||
trile_rdm_add_counter += 1;
|
||||
array_add(*render_command_buckets.main, drawCmd);
|
||||
case .SKY;
|
||||
command := New(Render_Command_Sky,, temp);
|
||||
command.worldConfig = (cast(*Rendering_Task_Sky)it).worldConfig;
|
||||
array_add(*render_command_buckets.reflection, command);
|
||||
array_add(*render_command_buckets.main, command);
|
||||
case .GROUND;
|
||||
commandDrawGround := New(Render_Command_Draw_Ground,, temp);
|
||||
commandDrawGround.worldConfig = *(cast(*Rendering_Task_Ground)it).world.conf;
|
||||
array_add(*render_command_buckets.main, commandDrawGround);
|
||||
array_add(*render_command_buckets.gbuffer, commandDrawGround);
|
||||
case .BILLBOARD;
|
||||
billboardTask := (cast(*Rendering_Task_Billboard)it);
|
||||
commandDrawBillboard := New(Render_Command_Draw_Billboard,, temp);
|
||||
commandDrawBillboard.position = billboardTask.position;
|
||||
commandDrawBillboard.frame = billboardTask.frame;
|
||||
commandDrawBillboard.flipX = billboardTask.flipX;
|
||||
commandDrawBillboard.flipY = billboardTask.flipY;
|
||||
commandDrawBillboard.faceDir = billboardTask.faceDir;
|
||||
commandDrawBillboard.animation = billboardTask.animation;
|
||||
array_add(*render_command_buckets.gbuffer, commandDrawBillboard);
|
||||
array_add(*render_command_buckets.main, commandDrawBillboard);
|
||||
array_add(*render_command_buckets.shadow, commandDrawBillboard);
|
||||
array_add(*render_command_buckets.reflection, commandDrawBillboard);
|
||||
case .PARTICLES_BUFFER;
|
||||
bufTask := cast(*Rendering_Task_Particles_Buffer)it;
|
||||
uploadCmd := New(Render_Command_Update_Particles,, temp);
|
||||
uploadCmd.total_count = bufTask.total_count;
|
||||
memcpy(uploadCmd.pos_size.data, bufTask.pos_size.data, bufTask.total_count * size_of(Vector4));
|
||||
memcpy(uploadCmd.uv_rects.data, bufTask.uv_rects.data, bufTask.total_count * size_of(Vector4));
|
||||
memcpy(uploadCmd.colors.data, bufTask.colors.data, bufTask.total_count * size_of(Vector4));
|
||||
array_add(*render_command_buckets.setup, uploadCmd);
|
||||
case .PARTICLES;
|
||||
particleTask := cast(*Rendering_Task_Particles)it;
|
||||
drawCmd := New(Render_Command_Draw_Particles,, temp);
|
||||
drawCmd.count = particleTask.count;
|
||||
drawCmd.instance_offset = particleTask.instance_offset;
|
||||
drawCmd.blend_mode = particleTask.blend_mode;
|
||||
drawCmd.sheet = particleTask.sheet;
|
||||
array_add(*render_command_buckets.main, drawCmd);
|
||||
array_add(*render_command_buckets.reflection, drawCmd);
|
||||
case .SET_CAMERA;
|
||||
task := (cast(*Rendering_Task_Set_Camera)it);
|
||||
command := New(Render_Command_Set_Camera,, temp);
|
||||
command.camera = task.camera;
|
||||
array_add(*render_command_buckets.main, command);
|
||||
array_add(*render_command_buckets.gbuffer, command);
|
||||
commandReflected := New(Render_Command_Set_Camera,, temp);
|
||||
commandReflected.camera = task.camera;
|
||||
commandReflected.camera.target *= Vector3.{1, -1, 1};
|
||||
commandReflected.camera.position *= Vector3.{1, -1, 1};
|
||||
commandReflected.camera.target.y += task.planeHeight * 2;
|
||||
commandReflected.camera.position.y += task.planeHeight * 2;
|
||||
array_add(*render_command_buckets.reflection, commandReflected);
|
||||
}
|
||||
}
|
||||
rendering_tasklist_clear();
|
||||
}
|
||||
117
src/rendering/text.jai
Normal file
117
src/rendering/text.jai
Normal file
@ -0,0 +1,117 @@
|
||||
// Text, as part of the Scene API. Fontstash lays out and rasterizes glyphs on
|
||||
// the CPU into an atlas; the atlas is an ordinary Texture and the glyphs go into
|
||||
// the UI stream as triangles, so nothing below the Scene API knows about fonts.
|
||||
|
||||
font_face_add :: (name: string, ttf: []u8) -> Font_Face {
|
||||
return .{fonsAddFontMem(text.fons, temp_c_string(name), ttf.data, xx ttf.count, 0)};
|
||||
}
|
||||
|
||||
text_measure :: (face: Font_Face, size: float, s: string) -> float {
|
||||
if s.count < 1 return 0;
|
||||
fonsSetFont(text.fons, face.id);
|
||||
fonsSetSize(text.fons, size);
|
||||
return fonsTextBounds(text.fons, 0, 0, s.data, s.data + s.count, null);
|
||||
}
|
||||
|
||||
text_vertical_metrics :: (face: Font_Face, size: float) -> (ascender: float, descender: float, line_height: float) {
|
||||
ascender, descender, line_height: float;
|
||||
fonsSetFont(text.fons, face.id);
|
||||
fonsSetSize(text.fons, size);
|
||||
fonsVertMetrics(text.fons, *ascender, *descender, *line_height);
|
||||
return ascender, descender, line_height;
|
||||
}
|
||||
|
||||
// x, y is the left end of the baseline, in pixels from the top left.
|
||||
ui_text :: (face: Font_Face, size: float, x: float, y: float, color: Vector4, s: string) {
|
||||
if s.count < 1 return;
|
||||
fonsSetFont(text.fons, face.id);
|
||||
fonsSetSize(text.fons, size);
|
||||
fonsSetColor(text.fons, pack_rgba8(color));
|
||||
fonsDrawText(text.fons, x, y, s.data, s.data + s.count);
|
||||
}
|
||||
|
||||
text_init :: (atlas_size: s32) {
|
||||
params := FONSparams.{
|
||||
width = atlas_size,
|
||||
height = atlas_size,
|
||||
flags = FONS_ZERO_TOPLEFT,
|
||||
renderCreate = atlas_create,
|
||||
renderResize = atlas_create,
|
||||
renderUpdate = atlas_mark_dirty,
|
||||
renderDraw = glyphs_draw,
|
||||
};
|
||||
text.fons = fonsCreateInternal(*params);
|
||||
}
|
||||
|
||||
// Drops every rasterized glyph, e.g. when UI font sizes change with the window.
|
||||
text_reset_atlas :: () {
|
||||
fonsResetAtlas(text.fons, text.atlas_w, text.atlas_h);
|
||||
}
|
||||
|
||||
// Before the UI stream is consumed: upload the atlas if glyphs were added.
|
||||
text_end_frame :: () {
|
||||
fonsClearState(text.fons);
|
||||
if !text.atlas_dirty return;
|
||||
text.atlas_dirty = false;
|
||||
|
||||
w, h: s32;
|
||||
alpha := fonsGetTextureData(text.fons, *w, *h);
|
||||
for i: 0..w*h-1 {
|
||||
text.atlas_pixels[i*4 + 0] = 255;
|
||||
text.atlas_pixels[i*4 + 1] = 255;
|
||||
text.atlas_pixels[i*4 + 2] = 255;
|
||||
text.atlas_pixels[i*4 + 3] = alpha[i];
|
||||
}
|
||||
texture_update(text.atlas, text.atlas_pixels);
|
||||
}
|
||||
|
||||
#scope_file
|
||||
|
||||
#import "Fontstash";
|
||||
|
||||
text : struct {
|
||||
fons : *FONScontext;
|
||||
atlas : Texture;
|
||||
atlas_w : s32;
|
||||
atlas_h : s32;
|
||||
atlas_pixels : []u8;
|
||||
atlas_dirty : bool;
|
||||
}
|
||||
|
||||
pack_rgba8 :: (c: Vector4) -> u32 {
|
||||
byte :: (f: float) -> u32 { return cast(u32) clamp(f * 255 + 0.5, 0, 255); }
|
||||
return byte(c.x) | (byte(c.y) << 8) | (byte(c.z) << 16) | (byte(c.w) << 24);
|
||||
}
|
||||
|
||||
atlas_create :: (uptr: *void, width: s32, height: s32) -> s32 #c_call {
|
||||
push_context,defer_pop default_context;
|
||||
if text.atlas.id texture_destroy(text.atlas);
|
||||
array_free(text.atlas_pixels);
|
||||
text.atlas_w = width;
|
||||
text.atlas_h = height;
|
||||
text.atlas_pixels = NewArray(width * height * 4, u8);
|
||||
text.atlas = texture_create(width, height, text.atlas_pixels);
|
||||
text.atlas_dirty = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
atlas_mark_dirty :: (uptr: *void, rect: *s32, data: *u8) #c_call {
|
||||
text.atlas_dirty = true;
|
||||
}
|
||||
|
||||
glyphs_draw :: (uptr: *void, verts: *float, tcoords: *float, colors: *u32, nverts: s32) #c_call {
|
||||
push_context,defer_pop default_context;
|
||||
vertices := NewArray(nverts, Ui_Vertex,, temp);
|
||||
for *v, i: vertices {
|
||||
c := colors[i];
|
||||
v.position = .{verts[i*2], verts[i*2 + 1]};
|
||||
v.uv = .{tcoords[i*2], tcoords[i*2 + 1]};
|
||||
v.color = .{
|
||||
cast(float)( c & 0xFF) / 255,
|
||||
cast(float)((c >> 8) & 0xFF) / 255,
|
||||
cast(float)((c >> 16) & 0xFF) / 255,
|
||||
cast(float)((c >> 24) & 0xFF) / 255,
|
||||
};
|
||||
}
|
||||
ui_triangles(vertices, text.atlas);
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
rm -rf jai
|
||||
mkdir jai
|
||||
|
||||
for filename in *.glsl; do
|
||||
if [ -f "$filename" ]; then
|
||||
./sokol-shdc -i "$filename" -o "./jai/${filename/.glsl/.jai}" -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
fi
|
||||
done
|
||||
@ -1,7 +0,0 @@
|
||||
rm -rf .jai
|
||||
|
||||
for filename in *.glsl; do
|
||||
if [ -f "$filename" ]; then
|
||||
./sokol-shdc-mac -i "$filename" -o "./jai/${filename/.glsl/.jai}" -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
fi
|
||||
done
|
||||
@ -1,548 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_billboard.glsl -o ./jai/shader_billboard.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'billboard':
|
||||
Get shader desc: billboard_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_billboard
|
||||
Fragment Shader: fs_billboard
|
||||
Attributes:
|
||||
ATTR_billboard_position => 0
|
||||
Bindings:
|
||||
Uniform block 'billboard_vs_params':
|
||||
Jai struct: Billboard_Vs_Params
|
||||
Bind slot: UB_billboard_vs_params => 0
|
||||
Image 'sprite':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_sprite => 0
|
||||
Sampler 'spritesmp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_spritesmp => 0
|
||||
*/
|
||||
ATTR_billboard_position :: 0;
|
||||
UB_billboard_vs_params :: 0;
|
||||
IMG_sprite :: 0;
|
||||
SMP_spritesmp :: 0;
|
||||
Billboard_Vs_Params :: struct {
|
||||
mvp: [16]float;
|
||||
uvs: [4]float;
|
||||
offset: [3]float;
|
||||
_: [4]u8;
|
||||
size: [2]float;
|
||||
_: [8]u8;
|
||||
cam: [3]float;
|
||||
_: [4]u8;
|
||||
faceDir: [3]float;
|
||||
_: [4]u8;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 billboard_vs_params[9];
|
||||
layout(location = 0) in vec3 position;
|
||||
layout(location = 0) out vec2 uv_in;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 _53 = billboard_vs_params[5].xyz - billboard_vs_params[7].xyz;
|
||||
_53.y = 0.0;
|
||||
vec3 look_dir = normalize(_53);
|
||||
if (billboard_vs_params[8].x > (-10.0))
|
||||
{
|
||||
look_dir = billboard_vs_params[8].xyz;
|
||||
}
|
||||
gl_Position = mat4(billboard_vs_params[0], billboard_vs_params[1], billboard_vs_params[2], billboard_vs_params[3]) * vec4((billboard_vs_params[5].xyz + (normalize(cross(vec3(0.0, 1.0, 0.0), look_dir)) * ((position.x - 0.5) * billboard_vs_params[6].x))) + (vec3(0.0, 1.0, 0.0) * (position.y * billboard_vs_params[6].y)), 1.0);
|
||||
uv_in = vec2(billboard_vs_params[4].x + (position.x * billboard_vs_params[4].z), billboard_vs_params[4].y + (position.y * billboard_vs_params[4].w));
|
||||
}
|
||||
|
||||
*/
|
||||
vs_billboard_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e,
|
||||
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x69,0x6c,0x6c,0x62,
|
||||
0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x39,
|
||||
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,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,
|
||||
0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,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,0x5f,0x35,0x33,0x20,0x3d,0x20,0x62,0x69,0x6c,
|
||||
0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x35,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,
|
||||
0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,
|
||||
0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,
|
||||
0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
|
||||
0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,
|
||||
0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,
|
||||
0x66,0x20,0x28,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x2e,0x78,0x20,0x3e,0x20,0x28,0x2d,
|
||||
0x31,0x30,0x2e,0x30,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,
|
||||
0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x73,0x5b,0x38,0x5d,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7d,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,
|
||||
0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,
|
||||
0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,
|
||||
0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,
|
||||
0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,
|
||||
0x28,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x6e,
|
||||
0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x76,
|
||||
0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,
|
||||
0x30,0x29,0x2c,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x29,0x29,0x20,0x2a,
|
||||
0x20,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,
|
||||
0x30,0x2e,0x35,0x29,0x20,0x2a,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2e,0x78,0x29,
|
||||
0x29,0x29,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,
|
||||
0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,0x2a,0x20,0x28,0x70,0x6f,0x73,
|
||||
0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,
|
||||
0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,
|
||||
0x2e,0x79,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x75,0x76,0x5f,0x69,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x62,0x69,0x6c,
|
||||
0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x34,0x5d,0x2e,0x78,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x2e,0x78,0x20,0x2a,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,
|
||||
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x7a,0x29,0x2c,
|
||||
0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x79,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,
|
||||
0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,
|
||||
0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,
|
||||
0x2e,0x77,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(binding = 16) uniform sampler2D sprite_spritesmp;
|
||||
|
||||
layout(location = 0) in vec2 uv_in;
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 _12 = uv_in;
|
||||
_12.y = 1.0 - _12.y;
|
||||
vec4 _35 = texture(sprite_spritesmp, _12);
|
||||
if (_35.w < 0.00999999977648258209228515625)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
color = vec4(_35.xyz * 0.5, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_billboard_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,
|
||||
0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x72,0x32,0x44,0x20,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x73,0x70,0x72,0x69,
|
||||
0x74,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
||||
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,
|
||||
0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
|
||||
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,
|
||||
0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,
|
||||
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x31,0x32,0x20,0x3d,0x20,0x75,
|
||||
0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,
|
||||
0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x33,0x35,0x20,0x3d,0x20,0x74,0x65,
|
||||
0x78,0x74,0x75,0x72,0x65,0x28,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x73,0x70,0x72,
|
||||
0x69,0x74,0x65,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x35,0x2e,0x77,0x20,0x3c,0x20,0x30,0x2e,
|
||||
0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,
|
||||
0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,
|
||||
0x63,0x61,0x72,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x33,0x35,
|
||||
0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
uniform vec4 billboard_vs_params[9];
|
||||
layout(location = 0) in vec3 position;
|
||||
out vec2 uv_in;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 _53 = billboard_vs_params[5].xyz - billboard_vs_params[7].xyz;
|
||||
_53.y = 0.0;
|
||||
vec3 look_dir = normalize(_53);
|
||||
if (billboard_vs_params[8].x > (-10.0))
|
||||
{
|
||||
look_dir = billboard_vs_params[8].xyz;
|
||||
}
|
||||
gl_Position = mat4(billboard_vs_params[0], billboard_vs_params[1], billboard_vs_params[2], billboard_vs_params[3]) * vec4((billboard_vs_params[5].xyz + (normalize(cross(vec3(0.0, 1.0, 0.0), look_dir)) * ((position.x - 0.5) * billboard_vs_params[6].x))) + (vec3(0.0, 1.0, 0.0) * (position.y * billboard_vs_params[6].y)), 1.0);
|
||||
uv_in = vec2(billboard_vs_params[4].x + (position.x * billboard_vs_params[4].z), billboard_vs_params[4].y + (position.y * billboard_vs_params[4].w));
|
||||
}
|
||||
|
||||
*/
|
||||
vs_billboard_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,0x62,0x69,
|
||||
0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x73,0x5b,0x39,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,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,
|
||||
0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,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,0x5f,0x35,0x33,0x20,0x3d,0x20,0x62,0x69,0x6c,0x6c,0x62,
|
||||
0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,
|
||||
0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,
|
||||
0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x2e,0x78,
|
||||
0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,
|
||||
0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x6c,0x6f,
|
||||
0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,
|
||||
0x7a,0x65,0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,
|
||||
0x28,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x2e,0x78,0x20,0x3e,0x20,0x28,0x2d,0x31,0x30,
|
||||
0x2e,0x30,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x62,0x69,
|
||||
0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x73,0x5b,0x38,0x5d,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,
|
||||
0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x62,
|
||||
0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x62,
|
||||
0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x62,
|
||||
0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x35,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x6e,0x6f,0x72,
|
||||
0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x76,0x65,0x63,
|
||||
0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,
|
||||
0x2c,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x29,0x29,0x20,0x2a,0x20,0x28,
|
||||
0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30,0x2e,
|
||||
0x35,0x29,0x20,0x2a,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,
|
||||
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2e,0x78,0x29,0x29,0x29,
|
||||
0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,
|
||||
0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,0x2a,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,
|
||||
0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2e,0x79,
|
||||
0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,
|
||||
0x5f,0x69,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x62,0x69,0x6c,0x6c,0x62,
|
||||
0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,
|
||||
0x5d,0x2e,0x78,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,
|
||||
0x78,0x20,0x2a,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x7a,0x29,0x2c,0x20,0x62,
|
||||
0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x79,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,
|
||||
0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x77,
|
||||
0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp sampler2D sprite_spritesmp;
|
||||
|
||||
in highp vec2 uv_in;
|
||||
layout(location = 0) out highp vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec2 _12 = uv_in;
|
||||
_12.y = 1.0 - _12.y;
|
||||
highp vec4 _35 = texture(sprite_spritesmp, _12);
|
||||
if (_35.w < 0.00999999977648258209228515625)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
color = vec4(_35.xyz * 0.5, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_billboard_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x73,0x70,
|
||||
0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,
|
||||
0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,
|
||||
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,
|
||||
0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,
|
||||
0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x31,0x32,0x20,0x3d,0x20,0x75,0x76,
|
||||
0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,0x3d,
|
||||
0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x33,0x35,
|
||||
0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x73,0x70,0x72,0x69,0x74,
|
||||
0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x35,0x2e,0x77,
|
||||
0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,
|
||||
0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,
|
||||
0x32,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x5f,0x33,0x35,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x35,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct billboard_vs_params
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 uvs;
|
||||
float3 offset;
|
||||
float2 size;
|
||||
float3 cam;
|
||||
float3 faceDir;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float2 uv_in [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float3 position [[attribute(0)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant billboard_vs_params& _24 [[buffer(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float3 _53 = _24.offset - _24.cam;
|
||||
_53.y = 0.0;
|
||||
float3 look_dir = fast::normalize(_53);
|
||||
if (_24.faceDir.x > (-10.0))
|
||||
{
|
||||
look_dir = _24.faceDir;
|
||||
}
|
||||
out.gl_Position = _24.mvp * float4((_24.offset + (fast::normalize(cross(float3(0.0, 1.0, 0.0), look_dir)) * ((in.position.x - 0.5) * _24.size.x))) + (float3(0.0, 1.0, 0.0) * (in.position.y * _24.size.y)), 1.0);
|
||||
out.uv_in = float2(_24.uvs.x + (in.position.x * _24.uvs.z), _24.uvs.y + (in.position.y * _24.uvs.w));
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_billboard_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x62,
|
||||
0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,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,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x34,0x20,0x75,0x76,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x33,0x20,0x6f,0x66,0x66,0x73,0x65,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x20,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x20,0x63,0x61,0x6d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x20,0x66,0x61,0x63,0x65,0x44,0x69,0x72,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,0x32,
|
||||
0x20,0x75,0x76,0x5f,0x69,0x6e,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,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,
|
||||
0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,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,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x34,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,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x33,0x20,0x5f,0x35,0x33,0x20,0x3d,0x20,0x5f,0x32,0x34,0x2e,0x6f,0x66,
|
||||
0x66,0x73,0x65,0x74,0x20,0x2d,0x20,0x5f,0x32,0x34,0x2e,0x63,0x61,0x6d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x6c,0x6f,0x6f,0x6b,
|
||||
0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,
|
||||
0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x69,0x66,0x20,0x28,0x5f,0x32,0x34,0x2e,0x66,0x61,0x63,0x65,0x44,0x69,0x72,
|
||||
0x2e,0x78,0x20,0x3e,0x20,0x28,0x2d,0x31,0x30,0x2e,0x30,0x29,0x29,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,
|
||||
0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x5f,0x32,0x34,0x2e,0x66,0x61,0x63,0x65,0x44,
|
||||
0x69,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,
|
||||
0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x5f,0x32,0x34,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||
0x28,0x28,0x5f,0x32,0x34,0x2e,0x6f,0x66,0x66,0x73,0x65,0x74,0x20,0x2b,0x20,0x28,
|
||||
0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,
|
||||
0x63,0x72,0x6f,0x73,0x73,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,
|
||||
0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x6c,0x6f,0x6f,
|
||||
0x6b,0x5f,0x64,0x69,0x72,0x29,0x29,0x20,0x2a,0x20,0x28,0x28,0x69,0x6e,0x2e,0x70,
|
||||
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30,0x2e,0x35,0x29,
|
||||
0x20,0x2a,0x20,0x5f,0x32,0x34,0x2e,0x73,0x69,0x7a,0x65,0x2e,0x78,0x29,0x29,0x29,
|
||||
0x20,0x2b,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,
|
||||
0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,0x2a,0x20,0x28,0x69,0x6e,0x2e,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x5f,0x32,0x34,
|
||||
0x2e,0x73,0x69,0x7a,0x65,0x2e,0x79,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x75,0x76,0x5f,0x69,0x6e,0x20,0x3d,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x32,0x34,0x2e,0x75,0x76,0x73,0x2e,
|
||||
0x78,0x20,0x2b,0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
||||
0x2e,0x78,0x20,0x2a,0x20,0x5f,0x32,0x34,0x2e,0x75,0x76,0x73,0x2e,0x7a,0x29,0x2c,
|
||||
0x20,0x5f,0x32,0x34,0x2e,0x75,0x76,0x73,0x2e,0x79,0x20,0x2b,0x20,0x28,0x69,0x6e,
|
||||
0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x5f,0x32,
|
||||
0x34,0x2e,0x75,0x76,0x73,0x2e,0x77,0x29,0x29,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 color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 uv_in [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> sprite [[texture(0)]], sampler spritesmp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 _12 = in.uv_in;
|
||||
_12.y = 1.0 - _12.y;
|
||||
float4 _35 = sprite.sample(spritesmp, _12);
|
||||
if (_35.w < 0.00999999977648258209228515625)
|
||||
{
|
||||
discard_fragment();
|
||||
}
|
||||
out.color = float4(_35.xyz * 0.5, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_billboard_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,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,
|
||||
0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,
|
||||
0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,
|
||||
0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,
|
||||
0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,
|
||||
0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x73,0x70,0x72,0x69,0x74,0x65,
|
||||
0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,
|
||||
0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x73,0x70,0x72,0x69,0x74,0x65,0x73,
|
||||
0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,
|
||||
0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,
|
||||
0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x31,0x32,0x20,0x3d,0x20,0x69,0x6e,
|
||||
0x2e,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,
|
||||
0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x33,0x35,0x20,
|
||||
0x3d,0x20,0x73,0x70,0x72,0x69,0x74,0x65,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,
|
||||
0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x35,0x2e,0x77,0x20,0x3c,
|
||||
0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,
|
||||
0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,
|
||||
0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x5f,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,
|
||||
0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,
|
||||
0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||
0x28,0x5f,0x33,0x35,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,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,
|
||||
];
|
||||
billboard_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "billboard_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_billboard_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_billboard_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 144;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 9;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "billboard_vs_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "sprite_spritesmp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_billboard_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_billboard_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 144;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 9;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "billboard_vs_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "sprite_spritesmp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_billboard_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_billboard_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 144;
|
||||
desc.uniform_blocks[0].msl_buffer_n = 0;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -1,491 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_bloom_downsample.glsl -o ./jai/shader_bloom_downsample.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'bloom_downsample':
|
||||
Get shader desc: bloom_downsample_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_bloom_downsample
|
||||
Fragment Shader: fs_bloom_downsample
|
||||
Attributes:
|
||||
ATTR_bloom_downsample_position => 0
|
||||
ATTR_bloom_downsample_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'bloom_downsample_params':
|
||||
Jai struct: Bloom_Downsample_Params
|
||||
Bind slot: UB_bloom_downsample_params => 0
|
||||
Image 'bloom_downsample_src':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_bloom_downsample_src => 0
|
||||
Sampler 'bloom_downsample_src_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_bloom_downsample_src_smp => 0
|
||||
*/
|
||||
ATTR_bloom_downsample_position :: 0;
|
||||
ATTR_bloom_downsample_uv :: 1;
|
||||
UB_bloom_downsample_params :: 0;
|
||||
IMG_bloom_downsample_src :: 0;
|
||||
SMP_bloom_downsample_src_smp :: 0;
|
||||
Bloom_Downsample_Params :: struct {
|
||||
src_texel_x: float;
|
||||
src_texel_y: float;
|
||||
_: [8]u8;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
layout(location = 0) out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_bloom_downsample_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,
|
||||
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,
|
||||
0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,
|
||||
0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 bloom_downsample_params[1];
|
||||
layout(binding = 16) uniform sampler2D bloom_downsample_src_bloom_downsample_src_smp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 _23 = vec2(bloom_downsample_params[0].x, bloom_downsample_params[0].y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
frag_color = vec4((((texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + _23).xyz) * 0.25, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_downsample_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e,
|
||||
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,
|
||||
0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x36,0x29,0x20,0x75,0x6e,0x69,0x66,
|
||||
0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,
|
||||
0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x32,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,0x20,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
||||
0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x20,
|
||||
0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x34,0x39,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,
|
||||
0x76,0x65,0x63,0x34,0x28,0x28,0x28,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,
|
||||
0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,
|
||||
0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,
|
||||
0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,
|
||||
0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,
|
||||
0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,
|
||||
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,
|
||||
0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,
|
||||
0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,
|
||||
0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x32,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_bloom_downsample_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,
|
||||
0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,
|
||||
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp vec4 bloom_downsample_params[1];
|
||||
uniform highp sampler2D bloom_downsample_src_bloom_downsample_src_smp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec2 _23 = vec2(bloom_downsample_params[0].x, bloom_downsample_params[0].y) * 0.5;
|
||||
highp float _44 = _23.x;
|
||||
highp float _45 = -_44;
|
||||
highp float _48 = _23.y;
|
||||
highp float _49 = -_48;
|
||||
frag_color = vec4((((texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_downsample_src_bloom_downsample_src_smp, texcoord + _23).xyz) * 0.25, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_downsample_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||
0x34,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,
|
||||
0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x72,0x32,0x44,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,
|
||||
0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,
|
||||
0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||
0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x32,0x33,0x20,
|
||||
0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,
|
||||
0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,
|
||||
0x5d,0x2e,0x78,0x2c,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,
|
||||
0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,
|
||||
0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,
|
||||
0x5f,0x32,0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,
|
||||
0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
||||
0x5f,0x34,0x39,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x28,0x28,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x35,0x2c,
|
||||
0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,
|
||||
0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,
|
||||
0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,
|
||||
0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x35,
|
||||
0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,
|
||||
0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,
|
||||
0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,
|
||||
0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,
|
||||
0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,0x2e,0x32,
|
||||
0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 position [[attribute(0)]];
|
||||
float2 uv [[attribute(1)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = float4(in.position, 0.5, 1.0);
|
||||
out.texcoord = in.uv;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_bloom_downsample_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,
|
||||
0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,
|
||||
0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct bloom_downsample_params
|
||||
{
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], constant bloom_downsample_params& _12 [[buffer(0)]], texture2d<float> bloom_downsample_src [[texture(0)]], sampler bloom_downsample_src_smp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 _23 = float2(_12.src_texel_x, _12.src_texel_y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
out.frag_color = float4((((bloom_downsample_src.sample(bloom_downsample_src_smp, (in.texcoord + float2(_45, _49))).xyz + bloom_downsample_src.sample(bloom_downsample_src_smp, (in.texcoord + float2(_44, _49))).xyz) + bloom_downsample_src.sample(bloom_downsample_src_smp, (in.texcoord + float2(_45, _48))).xyz) + bloom_downsample_src.sample(bloom_downsample_src_smp, (in.texcoord + _23)).xyz) * 0.25, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_downsample_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,0x5f,0x78,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x72,0x63,0x5f,0x74,0x65,
|
||||
0x78,0x65,0x6c,0x5f,0x79,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,
|
||||
0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,
|
||||
0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,
|
||||
0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,
|
||||
0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,0x5b,0x75,0x73,
|
||||
0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,
|
||||
0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
||||
0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
||||
0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
|
||||
0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,0x32,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,
|
||||
0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x20,0x5b,
|
||||
0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,
|
||||
0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x20,
|
||||
0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,
|
||||
0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x32,0x28,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,0x5f,
|
||||
0x78,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,
|
||||
0x5f,0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x78,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x20,
|
||||
0x3d,0x20,0x2d,0x5f,0x34,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x39,0x20,0x3d,0x20,0x2d,
|
||||
0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,
|
||||
0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||
0x28,0x28,0x28,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,
|
||||
0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,
|
||||
0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,
|
||||
0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x34,
|
||||
0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,
|
||||
0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x34,0x35,
|
||||
0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,
|
||||
0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,
|
||||
0x72,0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,
|
||||
0x2a,0x20,0x30,0x2e,0x32,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,
|
||||
0x0a,0x00,
|
||||
];
|
||||
bloom_downsample_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "bloom_downsample_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_bloom_downsample_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_downsample_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 1;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "bloom_downsample_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "bloom_downsample_src_bloom_downsample_src_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_bloom_downsample_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_downsample_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 1;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "bloom_downsample_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "bloom_downsample_src_bloom_downsample_src_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_bloom_downsample_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_bloom_downsample_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].msl_buffer_n = 0;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -1,552 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_bloom_prefilter.glsl -o ./jai/shader_bloom_prefilter.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'bloom_prefilter':
|
||||
Get shader desc: bloom_prefilter_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_bloom_prefilter
|
||||
Fragment Shader: fs_bloom_prefilter
|
||||
Attributes:
|
||||
ATTR_bloom_prefilter_position => 0
|
||||
ATTR_bloom_prefilter_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'bloom_prefilter_params':
|
||||
Jai struct: Bloom_Prefilter_Params
|
||||
Bind slot: UB_bloom_prefilter_params => 0
|
||||
Image 'bloom_prefilter_src':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_bloom_prefilter_src => 0
|
||||
Sampler 'bloom_prefilter_src_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_bloom_prefilter_src_smp => 0
|
||||
*/
|
||||
ATTR_bloom_prefilter_position :: 0;
|
||||
ATTR_bloom_prefilter_uv :: 1;
|
||||
UB_bloom_prefilter_params :: 0;
|
||||
IMG_bloom_prefilter_src :: 0;
|
||||
SMP_bloom_prefilter_src_smp :: 0;
|
||||
Bloom_Prefilter_Params :: struct {
|
||||
src_texel_x: float;
|
||||
src_texel_y: float;
|
||||
threshold: float;
|
||||
_: [4]u8;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
layout(location = 0) out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_bloom_prefilter_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,
|
||||
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,
|
||||
0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,
|
||||
0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 bloom_prefilter_params[1];
|
||||
layout(binding = 16) uniform sampler2D bloom_prefilter_src_bloom_prefilter_src_smp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 _23 = vec2(bloom_prefilter_params[0].x, bloom_prefilter_params[0].y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
vec3 _105 = (((texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + _23).xyz) * 0.25;
|
||||
vec3 color = _105;
|
||||
if (dot(_105, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)) < bloom_prefilter_params[0].z)
|
||||
{
|
||||
color = vec3(0.0);
|
||||
}
|
||||
frag_color = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_prefilter_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e,
|
||||
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,
|
||||
0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,
|
||||
0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,
|
||||
0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,
|
||||
0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,
|
||||
0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,
|
||||
0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,
|
||||
0x65,0x63,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,0x20,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,
|
||||
0x5f,0x32,0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,
|
||||
0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,
|
||||
0x39,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
|
||||
0x63,0x33,0x20,0x5f,0x31,0x30,0x35,0x20,0x3d,0x20,0x28,0x28,0x28,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,
|
||||
0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,
|
||||
0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,
|
||||
0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,
|
||||
0x32,0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,
|
||||
0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,
|
||||
0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,
|
||||
0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,
|
||||
0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,
|
||||
0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,
|
||||
0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,
|
||||
0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,
|
||||
0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,
|
||||
0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,0x2e,0x32,
|
||||
0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x3d,0x20,0x5f,0x31,0x30,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,
|
||||
0x20,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x30,0x35,0x2c,0x20,0x76,0x65,0x63,0x33,
|
||||
0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,0x39,0x39,0x39,0x32,0x37,0x35,0x32,0x30,
|
||||
0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,
|
||||
0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,0x31,0x38,0x32,0x32,0x35,0x30,0x39,0x37,
|
||||
0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x37,0x32,0x32,0x30,0x30,0x30,
|
||||
0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,
|
||||
0x35,0x29,0x29,0x20,0x3c,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,
|
||||
0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,
|
||||
0x7a,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,
|
||||
0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,
|
||||
0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||
0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_bloom_prefilter_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,
|
||||
0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,
|
||||
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp vec4 bloom_prefilter_params[1];
|
||||
uniform highp sampler2D bloom_prefilter_src_bloom_prefilter_src_smp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec2 _23 = vec2(bloom_prefilter_params[0].x, bloom_prefilter_params[0].y) * 0.5;
|
||||
highp float _44 = _23.x;
|
||||
highp float _45 = -_44;
|
||||
highp float _48 = _23.y;
|
||||
highp float _49 = -_48;
|
||||
highp vec3 _105 = (((texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_prefilter_src_bloom_prefilter_src_smp, texcoord + _23).xyz) * 0.25;
|
||||
highp vec3 color = _105;
|
||||
if (dot(_105, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)) < bloom_prefilter_params[0].z)
|
||||
{
|
||||
color = vec3(0.0);
|
||||
}
|
||||
frag_color = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_prefilter_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||
0x34,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,
|
||||
0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,0x69,
|
||||
0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x72,0x32,0x44,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,
|
||||
0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,
|
||||
0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,
|
||||
0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,
|
||||
0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,
|
||||
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,
|
||||
0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,
|
||||
0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,
|
||||
0x65,0x63,0x32,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,
|
||||
0x74,0x65,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,
|
||||
0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x78,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,
|
||||
0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,
|
||||
0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x39,0x20,0x3d,
|
||||
0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x30,0x35,0x20,0x3d,0x20,0x28,0x28,0x28,
|
||||
0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,
|
||||
0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,
|
||||
0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,
|
||||
0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,
|
||||
0x78,0x79,0x7a,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,
|
||||
0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,
|
||||
0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,
|
||||
0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,
|
||||
0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,
|
||||
0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,
|
||||
0x32,0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,
|
||||
0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,
|
||||
0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x76,0x65,0x63,0x33,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x31,0x30,
|
||||
0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x64,0x6f,0x74,0x28,0x5f,
|
||||
0x31,0x30,0x35,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,
|
||||
0x39,0x39,0x39,0x39,0x32,0x37,0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,
|
||||
0x32,0x35,0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,
|
||||
0x36,0x31,0x38,0x32,0x32,0x35,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,
|
||||
0x30,0x2e,0x30,0x37,0x32,0x32,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,
|
||||
0x32,0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x20,0x3c,0x20,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x7a,0x29,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||
0x3d,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2c,0x20,
|
||||
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 position [[attribute(0)]];
|
||||
float2 uv [[attribute(1)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = float4(in.position, 0.5, 1.0);
|
||||
out.texcoord = in.uv;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_bloom_prefilter_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,
|
||||
0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,
|
||||
0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct bloom_prefilter_params
|
||||
{
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
float threshold;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], constant bloom_prefilter_params& _12 [[buffer(0)]], texture2d<float> bloom_prefilter_src [[texture(0)]], sampler bloom_prefilter_src_smp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 _23 = float2(_12.src_texel_x, _12.src_texel_y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
float3 _105 = (((bloom_prefilter_src.sample(bloom_prefilter_src_smp, (in.texcoord + float2(_45, _49))).xyz + bloom_prefilter_src.sample(bloom_prefilter_src_smp, (in.texcoord + float2(_44, _49))).xyz) + bloom_prefilter_src.sample(bloom_prefilter_src_smp, (in.texcoord + float2(_45, _48))).xyz) + bloom_prefilter_src.sample(bloom_prefilter_src_smp, (in.texcoord + _23)).xyz) * 0.25;
|
||||
float3 color = _105;
|
||||
if (dot(_105, float3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)) < _12.threshold)
|
||||
{
|
||||
color = float3(0.0);
|
||||
}
|
||||
out.frag_color = float4(color, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_prefilter_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,0x5f,0x78,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,
|
||||
0x65,0x6c,0x5f,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
||||
0x74,0x68,0x72,0x65,0x73,0x68,0x6f,0x6c,0x64,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,
|
||||
0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,
|
||||
0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,
|
||||
0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
|
||||
0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,
|
||||
0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,
|
||||
0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,
|
||||
0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,
|
||||
0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,
|
||||
0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,0x32,0x20,0x5b,0x5b,0x62,
|
||||
0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,
|
||||
0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x62,0x6c,0x6f,
|
||||
0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,
|
||||
0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,
|
||||
0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,
|
||||
0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,
|
||||
0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,
|
||||
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,
|
||||
0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x32,0x28,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,
|
||||
0x5f,0x78,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,
|
||||
0x6c,0x5f,0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,
|
||||
0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,
|
||||
0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x39,0x20,0x3d,0x20,
|
||||
0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
|
||||
0x20,0x5f,0x31,0x30,0x35,0x20,0x3d,0x20,0x28,0x28,0x28,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x2e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,
|
||||
0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,
|
||||
0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,
|
||||
0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,
|
||||
0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,
|
||||
0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,
|
||||
0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,
|
||||
0x29,0x20,0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,
|
||||
0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x34,
|
||||
0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,
|
||||
0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,
|
||||
0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x70,0x72,0x65,0x66,0x69,0x6c,0x74,0x65,0x72,0x5f,0x73,0x72,0x63,0x5f,
|
||||
0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,
|
||||
0x20,0x30,0x2e,0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x33,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x31,0x30,0x35,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x30,0x35,
|
||||
0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,
|
||||
0x39,0x39,0x39,0x32,0x37,0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,
|
||||
0x35,0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,
|
||||
0x31,0x38,0x32,0x32,0x35,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,
|
||||
0x2e,0x30,0x37,0x32,0x32,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,
|
||||
0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x20,0x3c,0x20,0x5f,0x31,
|
||||
0x32,0x2e,0x74,0x68,0x72,0x65,0x73,0x68,0x6f,0x6c,0x64,0x29,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,
|
||||
0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x34,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
];
|
||||
bloom_prefilter_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "bloom_prefilter_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_bloom_prefilter_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_prefilter_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 1;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "bloom_prefilter_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "bloom_prefilter_src_bloom_prefilter_src_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_bloom_prefilter_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_prefilter_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 1;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "bloom_prefilter_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "bloom_prefilter_src_bloom_prefilter_src_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_bloom_prefilter_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_bloom_prefilter_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].msl_buffer_n = 0;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -1,563 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_bloom_upsample.glsl -o ./jai/shader_bloom_upsample.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'bloom_upsample':
|
||||
Get shader desc: bloom_upsample_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_bloom_upsample
|
||||
Fragment Shader: fs_bloom_upsample
|
||||
Attributes:
|
||||
ATTR_bloom_upsample_position => 0
|
||||
ATTR_bloom_upsample_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'bloom_upsample_params':
|
||||
Jai struct: Bloom_Upsample_Params
|
||||
Bind slot: UB_bloom_upsample_params => 0
|
||||
Image 'bloom_upsample_small':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_bloom_upsample_small => 0
|
||||
Image 'bloom_upsample_large':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_bloom_upsample_large => 1
|
||||
Sampler 'bloom_upsample_small_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_bloom_upsample_small_smp => 0
|
||||
Sampler 'bloom_upsample_large_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_bloom_upsample_large_smp => 1
|
||||
*/
|
||||
ATTR_bloom_upsample_position :: 0;
|
||||
ATTR_bloom_upsample_uv :: 1;
|
||||
UB_bloom_upsample_params :: 0;
|
||||
IMG_bloom_upsample_small :: 0;
|
||||
IMG_bloom_upsample_large :: 1;
|
||||
SMP_bloom_upsample_small_smp :: 0;
|
||||
SMP_bloom_upsample_large_smp :: 1;
|
||||
Bloom_Upsample_Params :: struct {
|
||||
src_texel_x: float;
|
||||
src_texel_y: float;
|
||||
_: [8]u8;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
layout(location = 0) out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_bloom_upsample_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,
|
||||
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,
|
||||
0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,
|
||||
0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 bloom_upsample_params[1];
|
||||
layout(binding = 16) uniform sampler2D bloom_upsample_small_bloom_upsample_small_smp;
|
||||
layout(binding = 17) uniform sampler2D bloom_upsample_large_bloom_upsample_large_smp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 _23 = vec2(bloom_upsample_params[0].x, bloom_upsample_params[0].y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
frag_color = vec4(((((texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + _23).xyz) * 0.25) + texture(bloom_upsample_large_bloom_upsample_large_smp, texcoord).xyz, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_upsample_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e,
|
||||
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,
|
||||
0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,
|
||||
0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,
|
||||
0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x37,0x29,0x20,
|
||||
0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,
|
||||
0x44,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,0x73,0x6d,0x70,0x3b,
|
||||
0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,
|
||||
0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,
|
||||
0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,
|
||||
0x20,0x76,0x65,0x63,0x32,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,
|
||||
0x2c,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
||||
0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x20,
|
||||
0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x34,0x39,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,
|
||||
0x76,0x65,0x63,0x34,0x28,0x28,0x28,0x28,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,
|
||||
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,
|
||||
0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,
|
||||
0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,
|
||||
0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,
|
||||
0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,
|
||||
0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,
|
||||
0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,
|
||||
0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,
|
||||
0x72,0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,
|
||||
0x20,0x30,0x2e,0x32,0x35,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x6c,0x61,0x72,0x67,0x65,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,0x73,0x6d,0x70,0x2c,0x20,
|
||||
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_bloom_upsample_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,
|
||||
0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,
|
||||
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp vec4 bloom_upsample_params[1];
|
||||
uniform highp sampler2D bloom_upsample_small_bloom_upsample_small_smp;
|
||||
uniform highp sampler2D bloom_upsample_large_bloom_upsample_large_smp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec2 _23 = vec2(bloom_upsample_params[0].x, bloom_upsample_params[0].y) * 0.5;
|
||||
highp float _44 = _23.x;
|
||||
highp float _45 = -_44;
|
||||
highp float _48 = _23.y;
|
||||
highp float _49 = -_48;
|
||||
frag_color = vec4(((((texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_45, _49)).xyz + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_44, _49)).xyz) + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + vec2(_45, _48)).xyz) + texture(bloom_upsample_small_bloom_upsample_small_smp, texcoord + _23).xyz) * 0.25) + texture(bloom_upsample_large_bloom_upsample_large_smp, texcoord).xyz, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_upsample_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||
0x34,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,0x69,0x66,
|
||||
0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x72,0x32,0x44,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,
|
||||
0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,
|
||||
0x70,0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,
|
||||
0x61,0x72,0x67,0x65,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,
|
||||
0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
|
||||
0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,
|
||||
0x2e,0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,
|
||||
0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,
|
||||
0x20,0x5f,0x32,0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,
|
||||
0x34,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x5f,0x34,0x39,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,
|
||||
0x63,0x34,0x28,0x28,0x28,0x28,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,
|
||||
0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,
|
||||
0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,
|
||||
0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x74,
|
||||
0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,
|
||||
0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,
|
||||
0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,
|
||||
0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,
|
||||
0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2b,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,
|
||||
0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,
|
||||
0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,
|
||||
0x2e,0x32,0x35,0x29,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,
|
||||
0x72,0x67,0x65,0x5f,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,
|
||||
0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,
|
||||
0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 position [[attribute(0)]];
|
||||
float2 uv [[attribute(1)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = float4(in.position, 0.5, 1.0);
|
||||
out.texcoord = in.uv;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_bloom_upsample_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,
|
||||
0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,
|
||||
0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct bloom_upsample_params
|
||||
{
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], constant bloom_upsample_params& _12 [[buffer(0)]], texture2d<float> bloom_upsample_small [[texture(0)]], texture2d<float> bloom_upsample_large [[texture(1)]], sampler bloom_upsample_small_smp [[sampler(0)]], sampler bloom_upsample_large_smp [[sampler(1)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 _23 = float2(_12.src_texel_x, _12.src_texel_y) * 0.5;
|
||||
float _44 = _23.x;
|
||||
float _45 = -_44;
|
||||
float _48 = _23.y;
|
||||
float _49 = -_48;
|
||||
out.frag_color = float4(((((bloom_upsample_small.sample(bloom_upsample_small_smp, (in.texcoord + float2(_45, _49))).xyz + bloom_upsample_small.sample(bloom_upsample_small_smp, (in.texcoord + float2(_44, _49))).xyz) + bloom_upsample_small.sample(bloom_upsample_small_smp, (in.texcoord + float2(_45, _48))).xyz) + bloom_upsample_small.sample(bloom_upsample_small_smp, (in.texcoord + _23)).xyz) * 0.25) + bloom_upsample_large.sample(bloom_upsample_large_smp, in.texcoord).xyz, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_bloom_upsample_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x62,
|
||||
0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,0x6c,0x5f,0x78,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x65,
|
||||
0x6c,0x5f,0x79,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,
|
||||
0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,
|
||||
0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,
|
||||
0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
|
||||
0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,
|
||||
0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,
|
||||
0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x62,0x6c,0x6f,0x6f,0x6d,
|
||||
0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x26,0x20,0x5f,0x31,0x32,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,
|
||||
0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x3e,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x20,0x5b,0x5b,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,
|
||||
0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x62,0x6c,0x6f,0x6f,
|
||||
0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,
|
||||
0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x31,0x29,0x5d,0x5d,0x2c,
|
||||
0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,
|
||||
0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,
|
||||
0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,
|
||||
0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,
|
||||
0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,0x73,
|
||||
0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x31,0x29,0x5d,
|
||||
0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,
|
||||
0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x28,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,
|
||||
0x65,0x6c,0x5f,0x78,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x73,0x72,0x63,0x5f,0x74,0x65,
|
||||
0x78,0x65,0x6c,0x5f,0x79,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x34,0x20,0x3d,0x20,0x5f,0x32,
|
||||
0x33,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
||||
0x34,0x35,0x20,0x3d,0x20,0x2d,0x5f,0x34,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x79,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x39,0x20,
|
||||
0x3d,0x20,0x2d,0x5f,0x34,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,
|
||||
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x34,0x28,0x28,0x28,0x28,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x2e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,
|
||||
0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x32,0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,0x2e,
|
||||
0x78,0x79,0x7a,0x20,0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x2e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,
|
||||
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x32,0x28,0x5f,0x34,0x34,0x2c,0x20,0x5f,0x34,0x39,0x29,0x29,0x29,0x2e,0x78,0x79,
|
||||
0x7a,0x29,0x20,0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,
|
||||
0x73,0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,
|
||||
0x28,0x5f,0x34,0x35,0x2c,0x20,0x5f,0x34,0x38,0x29,0x29,0x29,0x2e,0x78,0x79,0x7a,
|
||||
0x29,0x20,0x2b,0x20,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x6d,0x61,0x6c,0x6c,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,
|
||||
0x62,0x6c,0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,
|
||||
0x6d,0x61,0x6c,0x6c,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,0x74,0x65,
|
||||
0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x5f,0x32,0x33,0x29,0x29,0x2e,0x78,
|
||||
0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,0x2e,0x32,0x35,0x29,0x20,0x2b,0x20,0x62,0x6c,
|
||||
0x6f,0x6f,0x6d,0x5f,0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,
|
||||
0x67,0x65,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x62,0x6c,0x6f,0x6f,0x6d,0x5f,
|
||||
0x75,0x70,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x6c,0x61,0x72,0x67,0x65,0x5f,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,
|
||||
0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
];
|
||||
bloom_upsample_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "bloom_upsample_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_bloom_upsample_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_upsample_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 1;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "bloom_upsample_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[1].stage = .FRAGMENT;
|
||||
desc.samplers[1].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "bloom_upsample_small_bloom_upsample_small_smp";
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 1;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 1;
|
||||
desc.image_sampler_pairs[1].glsl_name = "bloom_upsample_large_bloom_upsample_large_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_bloom_upsample_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_bloom_upsample_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 1;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "bloom_upsample_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[1].stage = .FRAGMENT;
|
||||
desc.samplers[1].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "bloom_upsample_small_bloom_upsample_small_smp";
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 1;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 1;
|
||||
desc.image_sampler_pairs[1].glsl_name = "bloom_upsample_large_bloom_upsample_large_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_bloom_upsample_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_bloom_upsample_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].msl_buffer_n = 0;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.images[1].msl_texture_n = 1;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.samplers[1].stage = .FRAGMENT;
|
||||
desc.samplers[1].sampler_type = .FILTERING;
|
||||
desc.samplers[1].msl_sampler_n = 1;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 1;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 1;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -1,538 +0,0 @@
|
||||
/*
|
||||
#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_corner => 0
|
||||
ATTR_debugline_a_pos_a => 1
|
||||
ATTR_debugline_a_pos_b => 2
|
||||
ATTR_debugline_a_col => 3
|
||||
ATTR_debugline_a_width => 4
|
||||
Bindings:
|
||||
Uniform block 'debugline_vs_params':
|
||||
Jai struct: Debugline_Vs_Params
|
||||
Bind slot: UB_debugline_vs_params => 0
|
||||
*/
|
||||
ATTR_debugline_a_corner :: 0;
|
||||
ATTR_debugline_a_pos_a :: 1;
|
||||
ATTR_debugline_a_pos_b :: 2;
|
||||
ATTR_debugline_a_col :: 3;
|
||||
ATTR_debugline_a_width :: 4;
|
||||
UB_debugline_vs_params :: 0;
|
||||
Debugline_Vs_Params :: struct {
|
||||
mvp: [16]float;
|
||||
viewport: [4]float;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 debugline_vs_params[5];
|
||||
layout(location = 1) in vec3 a_pos_a;
|
||||
layout(location = 2) in vec3 a_pos_b;
|
||||
layout(location = 0) in vec2 a_corner;
|
||||
layout(location = 4) in float a_width;
|
||||
layout(location = 0) out vec4 v_col;
|
||||
layout(location = 3) in vec4 a_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 _18 = mat4(debugline_vs_params[0], debugline_vs_params[1], debugline_vs_params[2], debugline_vs_params[3]);
|
||||
vec4 _28 = _18 * vec4(a_pos_a, 1.0);
|
||||
vec4 _38 = _18 * vec4(a_pos_b, 1.0);
|
||||
vec2 _78 = ((_38.xy / vec2(max(_38.w, 9.9999997473787516355514526367188e-05))) * debugline_vs_params[4].xy) - ((_28.xy / vec2(max(_28.w, 9.9999997473787516355514526367188e-05))) * debugline_vs_params[4].xy);
|
||||
float _81 = length(_78);
|
||||
vec2 _86;
|
||||
if (_81 > 9.9999997473787516355514526367188e-05)
|
||||
{
|
||||
_86 = _78 / vec2(_81);
|
||||
}
|
||||
else
|
||||
{
|
||||
_86 = vec2(1.0, 0.0);
|
||||
}
|
||||
vec4 _115 = mix(_28, _38, vec4(a_corner.y));
|
||||
gl_Position = _115 + vec4((((vec2(-_86.y, _86.x) * a_corner.x) * ((a_width * 0.5) + 0.5)) / debugline_vs_params[4].xy) * _115.w, 0.0, 0.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,0x35,
|
||||
0x5d,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,0x33,0x20,
|
||||
0x61,0x5f,0x70,0x6f,0x73,0x5f,0x61,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,
|
||||
0x20,0x76,0x65,0x63,0x33,0x20,0x61,0x5f,0x70,0x6f,0x73,0x5f,0x62,0x3b,0x0a,0x6c,
|
||||
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x61,0x5f,0x63,0x6f,
|
||||
0x72,0x6e,0x65,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
|
||||
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x34,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x20,0x61,0x5f,0x77,0x69,0x64,0x74,0x68,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,0x33,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,0x6d,0x61,0x74,0x34,0x20,0x5f,0x31,
|
||||
0x38,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,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
|
||||
0x63,0x34,0x20,0x5f,0x32,0x38,0x20,0x3d,0x20,0x5f,0x31,0x38,0x20,0x2a,0x20,0x76,
|
||||
0x65,0x63,0x34,0x28,0x61,0x5f,0x70,0x6f,0x73,0x5f,0x61,0x2c,0x20,0x31,0x2e,0x30,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x33,0x38,0x20,
|
||||
0x3d,0x20,0x5f,0x31,0x38,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x61,0x5f,0x70,
|
||||
0x6f,0x73,0x5f,0x62,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x76,0x65,0x63,0x32,0x20,0x5f,0x37,0x38,0x20,0x3d,0x20,0x28,0x28,0x5f,0x33,0x38,
|
||||
0x2e,0x78,0x79,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x6d,0x61,0x78,0x28,0x5f,
|
||||
0x33,0x38,0x2e,0x77,0x2c,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,0x64,0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,0x29,0x20,0x2d,0x20,0x28,0x28,
|
||||
0x5f,0x32,0x38,0x2e,0x78,0x79,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x6d,0x61,
|
||||
0x78,0x28,0x5f,0x32,0x38,0x2e,0x77,0x2c,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,0x64,0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x38,0x31,0x20,0x3d,0x20,
|
||||
0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x5f,0x37,0x38,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x38,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,
|
||||
0x66,0x20,0x28,0x5f,0x38,0x31,0x20,0x3e,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,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x38,
|
||||
0x36,0x20,0x3d,0x20,0x5f,0x37,0x38,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,
|
||||
0x38,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,
|
||||
0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x5f,0x38,0x36,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x31,0x2e,0x30,
|
||||
0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x31,0x31,0x35,0x20,0x3d,0x20,0x6d,0x69,
|
||||
0x78,0x28,0x5f,0x32,0x38,0x2c,0x20,0x5f,0x33,0x38,0x2c,0x20,0x76,0x65,0x63,0x34,
|
||||
0x28,0x61,0x5f,0x63,0x6f,0x72,0x6e,0x65,0x72,0x2e,0x79,0x29,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x5f,0x31,0x31,0x35,0x20,0x2b,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x28,0x28,
|
||||
0x76,0x65,0x63,0x32,0x28,0x2d,0x5f,0x38,0x36,0x2e,0x79,0x2c,0x20,0x5f,0x38,0x36,
|
||||
0x2e,0x78,0x29,0x20,0x2a,0x20,0x61,0x5f,0x63,0x6f,0x72,0x6e,0x65,0x72,0x2e,0x78,
|
||||
0x29,0x20,0x2a,0x20,0x28,0x28,0x61,0x5f,0x77,0x69,0x64,0x74,0x68,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x35,0x29,0x20,0x2b,0x20,0x30,0x2e,0x35,0x29,0x29,0x20,0x2f,0x20,0x64,
|
||||
0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,0x29,0x20,0x2a,0x20,0x5f,0x31,0x31,0x35,
|
||||
0x2e,0x77,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,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[5];
|
||||
layout(location = 1) in vec3 a_pos_a;
|
||||
layout(location = 2) in vec3 a_pos_b;
|
||||
layout(location = 0) in vec2 a_corner;
|
||||
layout(location = 4) in float a_width;
|
||||
out vec4 v_col;
|
||||
layout(location = 3) in vec4 a_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 _18 = mat4(debugline_vs_params[0], debugline_vs_params[1], debugline_vs_params[2], debugline_vs_params[3]);
|
||||
vec4 _28 = _18 * vec4(a_pos_a, 1.0);
|
||||
vec4 _38 = _18 * vec4(a_pos_b, 1.0);
|
||||
vec2 _78 = ((_38.xy / vec2(max(_38.w, 9.9999997473787516355514526367188e-05))) * debugline_vs_params[4].xy) - ((_28.xy / vec2(max(_28.w, 9.9999997473787516355514526367188e-05))) * debugline_vs_params[4].xy);
|
||||
float _81 = length(_78);
|
||||
vec2 _86;
|
||||
if (_81 > 9.9999997473787516355514526367188e-05)
|
||||
{
|
||||
_86 = _78 / vec2(_81);
|
||||
}
|
||||
else
|
||||
{
|
||||
_86 = vec2(1.0, 0.0);
|
||||
}
|
||||
vec4 _115 = mix(_28, _38, vec4(a_corner.y));
|
||||
gl_Position = _115 + vec4((((vec2(-_86.y, _86.x) * a_corner.x) * ((a_width * 0.5) + 0.5)) / debugline_vs_params[4].xy) * _115.w, 0.0, 0.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,0x35,0x5d,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,0x33,0x20,0x61,0x5f,0x70,0x6f,0x73,0x5f,0x61,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
|
||||
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,
|
||||
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x61,0x5f,0x70,0x6f,0x73,0x5f,0x62,
|
||||
0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,
|
||||
0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x61,
|
||||
0x5f,0x63,0x6f,0x72,0x6e,0x65,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x34,0x29,0x20,0x69,0x6e,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x5f,0x77,0x69,0x64,0x74,0x68,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,0x33,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,0x6d,0x61,0x74,0x34,0x20,0x5f,0x31,0x38,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,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,
|
||||
0x20,0x5f,0x32,0x38,0x20,0x3d,0x20,0x5f,0x31,0x38,0x20,0x2a,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x61,0x5f,0x70,0x6f,0x73,0x5f,0x61,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x33,0x38,0x20,0x3d,0x20,
|
||||
0x5f,0x31,0x38,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x61,0x5f,0x70,0x6f,0x73,
|
||||
0x5f,0x62,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
|
||||
0x63,0x32,0x20,0x5f,0x37,0x38,0x20,0x3d,0x20,0x28,0x28,0x5f,0x33,0x38,0x2e,0x78,
|
||||
0x79,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x6d,0x61,0x78,0x28,0x5f,0x33,0x38,
|
||||
0x2e,0x77,0x2c,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,0x64,
|
||||
0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,0x29,0x20,0x2d,0x20,0x28,0x28,0x5f,0x32,
|
||||
0x38,0x2e,0x78,0x79,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x6d,0x61,0x78,0x28,
|
||||
0x5f,0x32,0x38,0x2e,0x77,0x2c,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,0x64,0x65,0x62,0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x38,0x31,0x20,0x3d,0x20,0x6c,0x65,
|
||||
0x6e,0x67,0x74,0x68,0x28,0x5f,0x37,0x38,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,
|
||||
0x65,0x63,0x32,0x20,0x5f,0x38,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,
|
||||
0x28,0x5f,0x38,0x31,0x20,0x3e,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,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x38,0x36,0x20,
|
||||
0x3d,0x20,0x5f,0x37,0x38,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x38,0x31,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,
|
||||
0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x5f,0x38,0x36,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x31,0x2e,0x30,0x2c,0x20,
|
||||
0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x5f,0x31,0x31,0x35,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,
|
||||
0x5f,0x32,0x38,0x2c,0x20,0x5f,0x33,0x38,0x2c,0x20,0x76,0x65,0x63,0x34,0x28,0x61,
|
||||
0x5f,0x63,0x6f,0x72,0x6e,0x65,0x72,0x2e,0x79,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,
|
||||
0x31,0x31,0x35,0x20,0x2b,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x28,0x28,0x76,0x65,
|
||||
0x63,0x32,0x28,0x2d,0x5f,0x38,0x36,0x2e,0x79,0x2c,0x20,0x5f,0x38,0x36,0x2e,0x78,
|
||||
0x29,0x20,0x2a,0x20,0x61,0x5f,0x63,0x6f,0x72,0x6e,0x65,0x72,0x2e,0x78,0x29,0x20,
|
||||
0x2a,0x20,0x28,0x28,0x61,0x5f,0x77,0x69,0x64,0x74,0x68,0x20,0x2a,0x20,0x30,0x2e,
|
||||
0x35,0x29,0x20,0x2b,0x20,0x30,0x2e,0x35,0x29,0x29,0x20,0x2f,0x20,0x64,0x65,0x62,
|
||||
0x75,0x67,0x6c,0x69,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x34,0x5d,0x2e,0x78,0x79,0x29,0x20,0x2a,0x20,0x5f,0x31,0x31,0x35,0x2e,0x77,
|
||||
0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,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;
|
||||
float4 viewport;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 v_col [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 a_corner [[attribute(0)]];
|
||||
float3 a_pos_a [[attribute(1)]];
|
||||
float3 a_pos_b [[attribute(2)]];
|
||||
float4 a_col [[attribute(3)]];
|
||||
float a_width [[attribute(4)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant debugline_vs_params& _13 [[buffer(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float4 _28 = _13.mvp * float4(in.a_pos_a, 1.0);
|
||||
float4 _38 = _13.mvp * float4(in.a_pos_b, 1.0);
|
||||
float2 _78 = ((_38.xy / float2(fast::max(_38.w, 9.9999997473787516355514526367188e-05))) * _13.viewport.xy) - ((_28.xy / float2(fast::max(_28.w, 9.9999997473787516355514526367188e-05))) * _13.viewport.xy);
|
||||
float _81 = length(_78);
|
||||
float2 _86;
|
||||
if (_81 > 9.9999997473787516355514526367188e-05)
|
||||
{
|
||||
_86 = _78 / float2(_81);
|
||||
}
|
||||
else
|
||||
{
|
||||
_86 = float2(1.0, 0.0);
|
||||
}
|
||||
float4 _115 = mix(_28, _38, float4(in.a_corner.y));
|
||||
out.gl_Position = _115 + float4((((float2(-_86.y, _86.x) * in.a_corner.x) * ((in.a_width * 0.5) + 0.5)) / _13.viewport.xy) * _115.w, 0.0, 0.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,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x34,0x20,0x76,0x69,0x65,0x77,0x70,0x6f,0x72,0x74,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,0x32,0x20,0x61,0x5f,0x63,0x6f,0x72,
|
||||
0x6e,0x65,0x72,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,0x33,
|
||||
0x20,0x61,0x5f,0x70,0x6f,0x73,0x5f,0x61,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,
|
||||
0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x20,0x61,0x5f,0x70,0x6f,0x73,0x5f,0x62,0x20,0x5b,0x5b,
|
||||
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x32,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,0x33,0x29,0x5d,
|
||||
0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x5f,0x77,
|
||||
0x69,0x64,0x74,0x68,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,
|
||||
0x28,0x34,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,0x33,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,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x34,0x20,0x5f,0x32,0x38,0x20,0x3d,0x20,0x5f,0x31,0x33,0x2e,0x6d,0x76,0x70,0x20,
|
||||
0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x61,0x5f,0x70,0x6f,
|
||||
0x73,0x5f,0x61,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x33,0x38,0x20,0x3d,0x20,0x5f,0x31,0x33,0x2e,
|
||||
0x6d,0x76,0x70,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,
|
||||
0x61,0x5f,0x70,0x6f,0x73,0x5f,0x62,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x37,0x38,0x20,0x3d,0x20,
|
||||
0x28,0x28,0x5f,0x33,0x38,0x2e,0x78,0x79,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x32,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x5f,0x33,0x38,0x2e,
|
||||
0x77,0x2c,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,0x31,
|
||||
0x33,0x2e,0x76,0x69,0x65,0x77,0x70,0x6f,0x72,0x74,0x2e,0x78,0x79,0x29,0x20,0x2d,
|
||||
0x20,0x28,0x28,0x5f,0x32,0x38,0x2e,0x78,0x79,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x32,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x5f,0x32,0x38,
|
||||
0x2e,0x77,0x2c,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,
|
||||
0x31,0x33,0x2e,0x76,0x69,0x65,0x77,0x70,0x6f,0x72,0x74,0x2e,0x78,0x79,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x38,0x31,0x20,0x3d,
|
||||
0x20,0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x5f,0x37,0x38,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x38,0x36,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x38,0x31,0x20,0x3e,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,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x5f,0x38,0x36,0x20,0x3d,0x20,0x5f,0x37,0x38,0x20,0x2f,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x32,0x28,0x5f,0x38,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x38,0x36,0x20,0x3d,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x32,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
||||
0x5f,0x31,0x31,0x35,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f,0x32,0x38,0x2c,0x20,
|
||||
0x5f,0x33,0x38,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x61,
|
||||
0x5f,0x63,0x6f,0x72,0x6e,0x65,0x72,0x2e,0x79,0x29,0x29,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,0x31,0x35,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||
0x28,0x28,0x28,0x28,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x2d,0x5f,0x38,0x36,0x2e,
|
||||
0x79,0x2c,0x20,0x5f,0x38,0x36,0x2e,0x78,0x29,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x61,
|
||||
0x5f,0x63,0x6f,0x72,0x6e,0x65,0x72,0x2e,0x78,0x29,0x20,0x2a,0x20,0x28,0x28,0x69,
|
||||
0x6e,0x2e,0x61,0x5f,0x77,0x69,0x64,0x74,0x68,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,
|
||||
0x20,0x2b,0x20,0x30,0x2e,0x35,0x29,0x29,0x20,0x2f,0x20,0x5f,0x31,0x33,0x2e,0x76,
|
||||
0x69,0x65,0x77,0x70,0x6f,0x72,0x74,0x2e,0x78,0x79,0x29,0x20,0x2a,0x20,0x5f,0x31,
|
||||
0x31,0x35,0x2e,0x77,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,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_corner";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "a_pos_a";
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[2].glsl_name = "a_pos_b";
|
||||
desc.attrs[3].base_type = .FLOAT;
|
||||
desc.attrs[3].glsl_name = "a_col";
|
||||
desc.attrs[4].base_type = .FLOAT;
|
||||
desc.attrs[4].glsl_name = "a_width";
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 80;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 5;
|
||||
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_corner";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "a_pos_a";
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[2].glsl_name = "a_pos_b";
|
||||
desc.attrs[3].base_type = .FLOAT;
|
||||
desc.attrs[3].glsl_name = "a_col";
|
||||
desc.attrs[4].base_type = .FLOAT;
|
||||
desc.attrs[4].glsl_name = "a_width";
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 80;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 5;
|
||||
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.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[3].base_type = .FLOAT;
|
||||
desc.attrs[4].base_type = .FLOAT;
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 80;
|
||||
desc.uniform_blocks[0].msl_buffer_n = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -1,566 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_dof_blur.glsl -o ./jai/shader_dof_blur.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'dof_blur':
|
||||
Get shader desc: dof_blur_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_dof_blur
|
||||
Fragment Shader: fs_dof_blur
|
||||
Attributes:
|
||||
ATTR_dof_blur_position => 0
|
||||
ATTR_dof_blur_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'dof_blur_params':
|
||||
Jai struct: Dof_Blur_Params
|
||||
Bind slot: UB_dof_blur_params => 0
|
||||
Image 'dof_blur_src':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_dof_blur_src => 0
|
||||
Sampler 'dof_blur_src_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_dof_blur_src_smp => 0
|
||||
*/
|
||||
ATTR_dof_blur_position :: 0;
|
||||
ATTR_dof_blur_uv :: 1;
|
||||
UB_dof_blur_params :: 0;
|
||||
IMG_dof_blur_src :: 0;
|
||||
SMP_dof_blur_src_smp :: 0;
|
||||
Dof_Blur_Params :: struct {
|
||||
bokeh_radius_x: float;
|
||||
bokeh_radius_y: float;
|
||||
_: [8]u8;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
layout(location = 0) out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_dof_blur_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,
|
||||
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,
|
||||
0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,
|
||||
0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 dof_blur_params[1];
|
||||
layout(binding = 16) uniform sampler2D dof_blur_src_dof_blur_src_smp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 _24 = texture(dof_blur_src_dof_blur_src_smp, texcoord);
|
||||
vec4 best = _24;
|
||||
float best_lum = dot(_24.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
float _50 = float(i);
|
||||
float _52 = _50 * 2.3999631404876708984375;
|
||||
vec4 _88 = texture(dof_blur_src_dof_blur_src_smp, texcoord + ((vec2(cos(_52), sin(_52)) * sqrt((_50 * 0.0322580635547637939453125) + 0.001000000047497451305389404296875)) * vec2(dof_blur_params[0].x, dof_blur_params[0].y)));
|
||||
float _92 = dot(_88.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
if (_92 > best_lum)
|
||||
{
|
||||
best = _88;
|
||||
best_lum = _92;
|
||||
}
|
||||
}
|
||||
frag_color = best;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_blur_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e,
|
||||
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,
|
||||
0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,
|
||||
0x31,0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x72,0x32,0x44,0x20,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,
|
||||
0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,
|
||||
0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
|
||||
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,
|
||||
0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,
|
||||
0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,
|
||||
0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,
|
||||
0x32,0x34,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x64,0x6f,0x66,
|
||||
0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x62,0x6c,
|
||||
0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||
0x62,0x65,0x73,0x74,0x20,0x3d,0x20,0x5f,0x32,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x20,0x3d,
|
||||
0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x34,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,
|
||||
0x63,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,0x39,0x39,0x39,0x32,0x37,0x35,
|
||||
0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x37,
|
||||
0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,0x31,0x38,0x32,0x32,0x35,0x30,
|
||||
0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x37,0x32,0x32,0x30,
|
||||
0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,0x32,0x31,
|
||||
0x38,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,
|
||||
0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,0x20,0x33,
|
||||
0x32,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x30,0x20,
|
||||
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x32,0x20,0x3d,0x20,
|
||||
0x5f,0x35,0x30,0x20,0x2a,0x20,0x32,0x2e,0x33,0x39,0x39,0x39,0x36,0x33,0x31,0x34,
|
||||
0x30,0x34,0x38,0x37,0x36,0x37,0x30,0x38,0x39,0x38,0x34,0x33,0x37,0x35,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x38,0x38,
|
||||
0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,
|
||||
0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,
|
||||
0x72,0x64,0x20,0x2b,0x20,0x28,0x28,0x76,0x65,0x63,0x32,0x28,0x63,0x6f,0x73,0x28,
|
||||
0x5f,0x35,0x32,0x29,0x2c,0x20,0x73,0x69,0x6e,0x28,0x5f,0x35,0x32,0x29,0x29,0x20,
|
||||
0x2a,0x20,0x73,0x71,0x72,0x74,0x28,0x28,0x5f,0x35,0x30,0x20,0x2a,0x20,0x30,0x2e,
|
||||
0x30,0x33,0x32,0x32,0x35,0x38,0x30,0x36,0x33,0x35,0x35,0x34,0x37,0x36,0x33,0x37,
|
||||
0x39,0x33,0x39,0x34,0x35,0x33,0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x30,0x2e,0x30,
|
||||
0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x34,0x37,0x34,0x39,0x37,0x34,0x35,
|
||||
0x31,0x33,0x30,0x35,0x33,0x38,0x39,0x34,0x30,0x34,0x32,0x39,0x36,0x38,0x37,0x35,
|
||||
0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28,0x64,0x6f,0x66,0x5f,0x62,0x6c,
|
||||
0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,0x20,
|
||||
0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
|
||||
0x30,0x5d,0x2e,0x79,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x39,0x32,0x20,0x3d,0x20,0x64,0x6f,0x74,
|
||||
0x28,0x5f,0x38,0x38,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,
|
||||
0x2e,0x32,0x31,0x32,0x35,0x39,0x39,0x39,0x39,0x32,0x37,0x35,0x32,0x30,0x37,0x35,
|
||||
0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,0x32,0x30,
|
||||
0x30,0x30,0x30,0x36,0x39,0x36,0x31,0x38,0x32,0x32,0x35,0x30,0x39,0x37,0x36,0x35,
|
||||
0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x37,0x32,0x32,0x30,0x30,0x30,0x30,0x30,
|
||||
0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,
|
||||
0x39,0x32,0x20,0x3e,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x29,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x62,0x65,0x73,0x74,0x20,0x3d,0x20,0x5f,0x38,0x38,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x65,0x73,
|
||||
0x74,0x5f,0x6c,0x75,0x6d,0x20,0x3d,0x20,0x5f,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x62,0x65,
|
||||
0x73,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_dof_blur_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,
|
||||
0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,
|
||||
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp vec4 dof_blur_params[1];
|
||||
uniform highp sampler2D dof_blur_src_dof_blur_src_smp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec4 _24 = texture(dof_blur_src_dof_blur_src_smp, texcoord);
|
||||
highp vec4 best = _24;
|
||||
highp float best_lum = dot(_24.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
highp float _50 = float(i);
|
||||
highp float _52 = _50 * 2.3999631404876708984375;
|
||||
highp vec4 _88 = texture(dof_blur_src_dof_blur_src_smp, texcoord + ((vec2(cos(_52), sin(_52)) * sqrt((_50 * 0.0322580635547637939453125) + 0.001000000047497451305389404296875)) * vec2(dof_blur_params[0].x, dof_blur_params[0].y)));
|
||||
highp float _92 = dot(_88.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
if (_92 > best_lum)
|
||||
{
|
||||
best = _88;
|
||||
best_lum = _92;
|
||||
}
|
||||
}
|
||||
frag_color = best;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_blur_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||
0x34,0x20,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,
|
||||
0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x64,0x6f,
|
||||
0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,
|
||||
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
|
||||
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,
|
||||
0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,
|
||||
0x65,0x63,0x34,0x20,0x5f,0x32,0x34,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,
|
||||
0x65,0x28,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x64,
|
||||
0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x65,0x73,0x74,0x20,
|
||||
0x3d,0x20,0x5f,0x32,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x20,
|
||||
0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x34,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,
|
||||
0x65,0x63,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,0x39,0x39,0x39,0x32,0x37,
|
||||
0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,
|
||||
0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,0x31,0x38,0x32,0x32,0x35,
|
||||
0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x37,0x32,0x32,
|
||||
0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,0x32,
|
||||
0x31,0x38,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,
|
||||
0x28,0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,0x20,
|
||||
0x33,0x32,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x35,0x30,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x32,0x20,0x3d,0x20,0x5f,0x35,0x30,
|
||||
0x20,0x2a,0x20,0x32,0x2e,0x33,0x39,0x39,0x39,0x36,0x33,0x31,0x34,0x30,0x34,0x38,
|
||||
0x37,0x36,0x37,0x30,0x38,0x39,0x38,0x34,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||
0x5f,0x38,0x38,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x64,0x6f,
|
||||
0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x28,0x28,0x76,0x65,0x63,0x32,0x28,0x63,
|
||||
0x6f,0x73,0x28,0x5f,0x35,0x32,0x29,0x2c,0x20,0x73,0x69,0x6e,0x28,0x5f,0x35,0x32,
|
||||
0x29,0x29,0x20,0x2a,0x20,0x73,0x71,0x72,0x74,0x28,0x28,0x5f,0x35,0x30,0x20,0x2a,
|
||||
0x20,0x30,0x2e,0x30,0x33,0x32,0x32,0x35,0x38,0x30,0x36,0x33,0x35,0x35,0x34,0x37,
|
||||
0x36,0x33,0x37,0x39,0x33,0x39,0x34,0x35,0x33,0x31,0x32,0x35,0x29,0x20,0x2b,0x20,
|
||||
0x30,0x2e,0x30,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x34,0x37,0x34,0x39,
|
||||
0x37,0x34,0x35,0x31,0x33,0x30,0x35,0x33,0x38,0x39,0x34,0x30,0x34,0x32,0x39,0x36,
|
||||
0x38,0x37,0x35,0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28,0x64,0x6f,0x66,
|
||||
0x5f,0x62,0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,
|
||||
0x78,0x2c,0x20,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
||||
0x5f,0x39,0x32,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x38,0x38,0x2e,0x78,0x79,
|
||||
0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,0x39,
|
||||
0x39,0x39,0x32,0x37,0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,0x35,
|
||||
0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,0x31,
|
||||
0x38,0x32,0x32,0x35,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,
|
||||
0x30,0x37,0x32,0x32,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,
|
||||
0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x39,0x32,0x20,0x3e,0x20,0x62,0x65,
|
||||
0x73,0x74,0x5f,0x6c,0x75,0x6d,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x65,
|
||||
0x73,0x74,0x20,0x3d,0x20,0x5f,0x38,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x20,0x3d,
|
||||
0x20,0x5f,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x62,0x65,0x73,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||
0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 position [[attribute(0)]];
|
||||
float2 uv [[attribute(1)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = float4(in.position, 0.5, 1.0);
|
||||
out.texcoord = in.uv;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_dof_blur_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,
|
||||
0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,
|
||||
0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct dof_blur_params
|
||||
{
|
||||
float bokeh_radius_x;
|
||||
float bokeh_radius_y;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], constant dof_blur_params& _72 [[buffer(0)]], texture2d<float> dof_blur_src [[texture(0)]], sampler dof_blur_src_smp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float4 _24 = dof_blur_src.sample(dof_blur_src_smp, in.texcoord);
|
||||
float4 best = _24;
|
||||
float best_lum = dot(_24.xyz, float3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
float _50 = float(i);
|
||||
float _52 = _50 * 2.3999631404876708984375;
|
||||
float4 _88 = dof_blur_src.sample(dof_blur_src_smp, (in.texcoord + ((float2(cos(_52), sin(_52)) * sqrt((_50 * 0.0322580635547637939453125) + 0.001000000047497451305389404296875)) * float2(_72.bokeh_radius_x, _72.bokeh_radius_y))));
|
||||
float _92 = dot(_88.xyz, float3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
|
||||
if (_92 > best_lum)
|
||||
{
|
||||
best = _88;
|
||||
best_lum = _92;
|
||||
}
|
||||
}
|
||||
out.frag_color = best;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_blur_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x64,
|
||||
0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x6f,0x6b,0x65,0x68,
|
||||
0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x5f,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x62,0x6f,0x6b,0x65,0x68,0x5f,0x72,0x61,0x64,0x69,0x75,
|
||||
0x73,0x5f,0x79,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,
|
||||
0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,
|
||||
0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,
|
||||
0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
|
||||
0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,
|
||||
0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,
|
||||
0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x37,0x32,0x20,
|
||||
0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,
|
||||
0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,
|
||||
0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x20,0x5b,0x5b,0x74,
|
||||
0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x20,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,
|
||||
0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x34,0x20,0x3d,
|
||||
0x20,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x28,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,
|
||||
0x72,0x64,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
||||
0x62,0x65,0x73,0x74,0x20,0x3d,0x20,0x5f,0x32,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x20,0x3d,
|
||||
0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x34,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,0x39,0x39,0x39,0x32,
|
||||
0x37,0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,
|
||||
0x2e,0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,0x31,0x38,0x32,0x32,
|
||||
0x35,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x37,0x32,
|
||||
0x32,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,0x32,0x39,0x34,0x39,
|
||||
0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,
|
||||
0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,
|
||||
0x20,0x33,0x32,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,
|
||||
0x30,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x32,0x20,
|
||||
0x3d,0x20,0x5f,0x35,0x30,0x20,0x2a,0x20,0x32,0x2e,0x33,0x39,0x39,0x39,0x36,0x33,
|
||||
0x31,0x34,0x30,0x34,0x38,0x37,0x36,0x37,0x30,0x38,0x39,0x38,0x34,0x33,0x37,0x35,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||
0x20,0x5f,0x38,0x38,0x20,0x3d,0x20,0x64,0x6f,0x66,0x5f,0x62,0x6c,0x75,0x72,0x5f,
|
||||
0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x64,0x6f,0x66,0x5f,0x62,
|
||||
0x6c,0x75,0x72,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,
|
||||
0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x28,0x28,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x28,0x63,0x6f,0x73,0x28,0x5f,0x35,0x32,0x29,0x2c,0x20,0x73,
|
||||
0x69,0x6e,0x28,0x5f,0x35,0x32,0x29,0x29,0x20,0x2a,0x20,0x73,0x71,0x72,0x74,0x28,
|
||||
0x28,0x5f,0x35,0x30,0x20,0x2a,0x20,0x30,0x2e,0x30,0x33,0x32,0x32,0x35,0x38,0x30,
|
||||
0x36,0x33,0x35,0x35,0x34,0x37,0x36,0x33,0x37,0x39,0x33,0x39,0x34,0x35,0x33,0x31,
|
||||
0x32,0x35,0x29,0x20,0x2b,0x20,0x30,0x2e,0x30,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x34,0x37,0x34,0x39,0x37,0x34,0x35,0x31,0x33,0x30,0x35,0x33,0x38,0x39,
|
||||
0x34,0x30,0x34,0x32,0x39,0x36,0x38,0x37,0x35,0x29,0x29,0x20,0x2a,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x28,0x5f,0x37,0x32,0x2e,0x62,0x6f,0x6b,0x65,0x68,0x5f,0x72,
|
||||
0x61,0x64,0x69,0x75,0x73,0x5f,0x78,0x2c,0x20,0x5f,0x37,0x32,0x2e,0x62,0x6f,0x6b,
|
||||
0x65,0x68,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x5f,0x79,0x29,0x29,0x29,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
||||
0x39,0x32,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x38,0x38,0x2e,0x78,0x79,0x7a,
|
||||
0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x32,0x31,0x32,0x35,0x39,
|
||||
0x39,0x39,0x39,0x32,0x37,0x35,0x32,0x30,0x37,0x35,0x31,0x39,0x35,0x33,0x31,0x32,
|
||||
0x35,0x2c,0x20,0x30,0x2e,0x37,0x31,0x35,0x32,0x30,0x30,0x30,0x30,0x36,0x39,0x36,
|
||||
0x31,0x38,0x32,0x32,0x35,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,
|
||||
0x2e,0x30,0x37,0x32,0x32,0x30,0x30,0x30,0x30,0x30,0x32,0x38,0x36,0x31,0x30,0x32,
|
||||
0x32,0x39,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x39,0x32,0x20,0x3e,0x20,0x62,
|
||||
0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,
|
||||
0x65,0x73,0x74,0x20,0x3d,0x20,0x5f,0x38,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x65,0x73,0x74,0x5f,0x6c,0x75,0x6d,0x20,
|
||||
0x3d,0x20,0x5f,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,
|
||||
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x62,0x65,0x73,0x74,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,
|
||||
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
dof_blur_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "dof_blur_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_dof_blur_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_dof_blur_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 1;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "dof_blur_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "dof_blur_src_dof_blur_src_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_dof_blur_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_dof_blur_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 1;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "dof_blur_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "dof_blur_src_dof_blur_src_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_dof_blur_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_dof_blur_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.uniform_blocks[0].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 16;
|
||||
desc.uniform_blocks[0].msl_buffer_n = 0;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -1,339 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_dof_downsample.glsl -o ./jai/shader_dof_downsample.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'dof_downsample':
|
||||
Get shader desc: dof_downsample_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_dof_downsample
|
||||
Fragment Shader: fs_dof_downsample
|
||||
Attributes:
|
||||
ATTR_dof_downsample_position => 0
|
||||
ATTR_dof_downsample_uv => 1
|
||||
Bindings:
|
||||
Image 'dof_downsample_src':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_dof_downsample_src => 0
|
||||
Sampler 'dof_downsample_src_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_dof_downsample_src_smp => 0
|
||||
*/
|
||||
ATTR_dof_downsample_position :: 0;
|
||||
ATTR_dof_downsample_uv :: 1;
|
||||
IMG_dof_downsample_src :: 0;
|
||||
SMP_dof_downsample_src_smp :: 0;
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
layout(location = 0) out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_dof_downsample_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,
|
||||
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,
|
||||
0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,
|
||||
0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(binding = 16) uniform sampler2D dof_downsample_src_dof_downsample_src_smp;
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(texture(dof_downsample_src_dof_downsample_src_smp, texcoord).xyz, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_downsample_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,
|
||||
0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x72,0x32,0x44,0x20,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x3b,0x0a,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,
|
||||
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,
|
||||
0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||
0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x64,
|
||||
0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,
|
||||
0x63,0x5f,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,
|
||||
0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_dof_downsample_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,
|
||||
0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,
|
||||
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp sampler2D dof_downsample_src_dof_downsample_src_smp;
|
||||
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
in highp vec2 texcoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(texture(dof_downsample_src_dof_downsample_src_smp, texcoord).xyz, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_downsample_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x64,0x6f,
|
||||
0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,
|
||||
0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
|
||||
0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,
|
||||
0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,
|
||||
0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,
|
||||
0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x64,0x6f,0x66,0x5f,0x64,
|
||||
0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,
|
||||
0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,
|
||||
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 position [[attribute(0)]];
|
||||
float2 uv [[attribute(1)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = float4(in.position, 0.5, 1.0);
|
||||
out.texcoord = in.uv;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_dof_downsample_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,
|
||||
0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,
|
||||
0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> dof_downsample_src [[texture(0)]], sampler dof_downsample_src_smp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.frag_color = float4(dof_downsample_src.sample(dof_downsample_src_smp, in.texcoord).xyz, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_dof_downsample_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,
|
||||
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
||||
0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,
|
||||
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,
|
||||
0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,
|
||||
0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,
|
||||
0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,
|
||||
0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x3e,0x20,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x5f,0x73,0x72,0x63,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,
|
||||
0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x64,0x6f,0x66,
|
||||
0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,
|
||||
0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,
|
||||
0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
||||
0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x64,0x6f,0x66,0x5f,0x64,0x6f,
|
||||
0x77,0x6e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x73,0x72,0x63,0x2e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x28,0x64,0x6f,0x66,0x5f,0x64,0x6f,0x77,0x6e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x5f,0x73,0x72,0x63,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,
|
||||
0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,
|
||||
0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
dof_downsample_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "dof_downsample_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_dof_downsample_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_dof_downsample_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "dof_downsample_src_dof_downsample_src_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_dof_downsample_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_dof_downsample_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "dof_downsample_src_dof_downsample_src_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_dof_downsample_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_dof_downsample_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,696 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_gbuffer_billboard.glsl -o ./jai/shader_gbuffer_billboard.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'gbuffer_billboard':
|
||||
Get shader desc: gbuffer_billboard_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_gbuffer_billboard
|
||||
Fragment Shader: fs_gbuffer_billboard
|
||||
Attributes:
|
||||
ATTR_gbuffer_billboard_position => 0
|
||||
Bindings:
|
||||
Uniform block 'gbuffer_billboard_vs_params':
|
||||
Jai struct: Gbuffer_Billboard_Vs_Params
|
||||
Bind slot: UB_gbuffer_billboard_vs_params => 0
|
||||
Image 'gsprite':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_gsprite => 0
|
||||
Sampler 'gspritesmp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_gspritesmp => 0
|
||||
*/
|
||||
ATTR_gbuffer_billboard_position :: 0;
|
||||
UB_gbuffer_billboard_vs_params :: 0;
|
||||
IMG_gsprite :: 0;
|
||||
SMP_gspritesmp :: 0;
|
||||
Gbuffer_Billboard_Vs_Params :: struct {
|
||||
mvp: [16]float;
|
||||
uvs: [4]float;
|
||||
offset: [3]float;
|
||||
_: [4]u8;
|
||||
size: [2]float;
|
||||
_: [8]u8;
|
||||
cam: [3]float;
|
||||
_: [4]u8;
|
||||
view_matrix: [16]float;
|
||||
faceDir: [3]float;
|
||||
_: [4]u8;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 gbuffer_billboard_vs_params[13];
|
||||
layout(location = 0) in vec3 position;
|
||||
layout(location = 1) out vec3 view_space_pos;
|
||||
layout(location = 2) out vec3 view_space_normal;
|
||||
layout(location = 0) out vec2 uv_in;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 _53 = gbuffer_billboard_vs_params[5].xyz - gbuffer_billboard_vs_params[7].xyz;
|
||||
_53.y = 0.0;
|
||||
vec3 look_dir = normalize(_53);
|
||||
if (gbuffer_billboard_vs_params[12].x > (-10.0))
|
||||
{
|
||||
look_dir = gbuffer_billboard_vs_params[12].xyz;
|
||||
}
|
||||
vec4 _98 = vec4((gbuffer_billboard_vs_params[5].xyz + (normalize(cross(vec3(0.0, 1.0, 0.0), look_dir)) * ((position.x - 0.5) * gbuffer_billboard_vs_params[6].x))) + (vec3(0.0, 1.0, 0.0) * (position.y * gbuffer_billboard_vs_params[6].y)), 1.0);
|
||||
gl_Position = mat4(gbuffer_billboard_vs_params[0], gbuffer_billboard_vs_params[1], gbuffer_billboard_vs_params[2], gbuffer_billboard_vs_params[3]) * _98;
|
||||
mat4 _106 = mat4(gbuffer_billboard_vs_params[8], gbuffer_billboard_vs_params[9], gbuffer_billboard_vs_params[10], gbuffer_billboard_vs_params[11]);
|
||||
view_space_pos = (_106 * _98).xyz;
|
||||
view_space_normal = mat3(_106[0].xyz, _106[1].xyz, _106[2].xyz) * vec3(0.0, 1.0, 0.0);
|
||||
uv_in = vec2(gbuffer_billboard_vs_params[4].x + (position.x * gbuffer_billboard_vs_params[4].z), gbuffer_billboard_vs_params[4].y + (position.y * gbuffer_billboard_vs_params[4].w));
|
||||
}
|
||||
|
||||
*/
|
||||
vs_gbuffer_billboard_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,0x67,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x33,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,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
|
||||
0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,
|
||||
0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x3b,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x32,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76,
|
||||
0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,
|
||||
0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,
|
||||
0x75,0x76,0x5f,0x69,0x6e,0x3b,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,0x5f,
|
||||
0x35,0x33,0x20,0x3d,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,
|
||||
0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x35,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x67,0x62,0x75,0x66,0x66,0x65,
|
||||
0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,
|
||||
0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x33,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x67,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x32,0x5d,0x2e,0x78,0x20,0x3e,0x20,0x28,
|
||||
0x2d,0x31,0x30,0x2e,0x30,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,
|
||||
0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,
|
||||
0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x32,0x5d,
|
||||
0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x5f,0x39,0x38,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,
|
||||
0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,
|
||||
0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2e,
|
||||
0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
|
||||
0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x6c,0x6f,0x6f,0x6b,
|
||||
0x5f,0x64,0x69,0x72,0x29,0x29,0x20,0x2a,0x20,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30,0x2e,0x35,0x29,0x20,0x2a,0x20,0x67,
|
||||
0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2e,0x78,0x29,
|
||||
0x29,0x29,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,
|
||||
0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,0x2a,0x20,0x28,0x70,0x6f,0x73,
|
||||
0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,
|
||||
0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2e,0x79,0x29,0x29,0x2c,0x20,0x31,0x2e,
|
||||
0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x67,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x5f,0x39,0x38,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x74,0x34,0x20,0x5f,0x31,0x30,0x36,0x20,
|
||||
0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,
|
||||
0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x38,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,
|
||||
0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x39,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,
|
||||
0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x31,0x30,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,
|
||||
0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x73,0x5b,0x31,0x31,0x5d,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x69,
|
||||
0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x20,0x3d,0x20,0x28,
|
||||
0x5f,0x31,0x30,0x36,0x20,0x2a,0x20,0x5f,0x39,0x38,0x29,0x2e,0x78,0x79,0x7a,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,
|
||||
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x6d,0x61,0x74,0x33,0x28,0x5f,0x31,
|
||||
0x30,0x36,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,0x30,0x36,0x5b,
|
||||
0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,0x30,0x36,0x5b,0x32,0x5d,0x2e,
|
||||
0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x75,0x76,0x5f,0x69,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x67,0x62,0x75,
|
||||
0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,
|
||||
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x20,0x2b,0x20,
|
||||
0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,0x67,0x62,
|
||||
0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,
|
||||
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x7a,0x29,0x2c,
|
||||
0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,
|
||||
0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,
|
||||
0x79,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,
|
||||
0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,
|
||||
0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,
|
||||
0x2e,0x77,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(binding = 16) uniform sampler2D gsprite_gspritesmp;
|
||||
|
||||
layout(location = 0) in vec2 uv_in;
|
||||
layout(location = 0) out vec4 out_position;
|
||||
layout(location = 1) in vec3 view_space_pos;
|
||||
layout(location = 1) out vec4 out_normal;
|
||||
layout(location = 2) in vec3 view_space_normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 _12 = uv_in;
|
||||
_12.y = 1.0 - _12.y;
|
||||
if (texture(gsprite_gspritesmp, _12).w < 0.00999999977648258209228515625)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
out_position = vec4(view_space_pos, 1.0);
|
||||
out_normal = vec4(normalize(view_space_normal), 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_gbuffer_billboard_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,
|
||||
0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x72,0x32,0x44,0x20,0x67,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x67,0x73,0x70,
|
||||
0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,
|
||||
0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,
|
||||
0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,
|
||||
0x65,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
|
||||
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x69,
|
||||
0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,
|
||||
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x31,0x32,0x20,0x3d,0x20,0x75,
|
||||
0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,
|
||||
0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x67,
|
||||
0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x67,0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,
|
||||
0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x2e,0x77,0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,
|
||||
0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,
|
||||
0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,
|
||||
0x72,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,
|
||||
0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,
|
||||
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,
|
||||
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x6e,0x6f,
|
||||
0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,
|
||||
0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
uniform vec4 gbuffer_billboard_vs_params[13];
|
||||
layout(location = 0) in vec3 position;
|
||||
out vec3 view_space_pos;
|
||||
out vec3 view_space_normal;
|
||||
out vec2 uv_in;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 _53 = gbuffer_billboard_vs_params[5].xyz - gbuffer_billboard_vs_params[7].xyz;
|
||||
_53.y = 0.0;
|
||||
vec3 look_dir = normalize(_53);
|
||||
if (gbuffer_billboard_vs_params[12].x > (-10.0))
|
||||
{
|
||||
look_dir = gbuffer_billboard_vs_params[12].xyz;
|
||||
}
|
||||
vec4 _98 = vec4((gbuffer_billboard_vs_params[5].xyz + (normalize(cross(vec3(0.0, 1.0, 0.0), look_dir)) * ((position.x - 0.5) * gbuffer_billboard_vs_params[6].x))) + (vec3(0.0, 1.0, 0.0) * (position.y * gbuffer_billboard_vs_params[6].y)), 1.0);
|
||||
gl_Position = mat4(gbuffer_billboard_vs_params[0], gbuffer_billboard_vs_params[1], gbuffer_billboard_vs_params[2], gbuffer_billboard_vs_params[3]) * _98;
|
||||
mat4 _106 = mat4(gbuffer_billboard_vs_params[8], gbuffer_billboard_vs_params[9], gbuffer_billboard_vs_params[10], gbuffer_billboard_vs_params[11]);
|
||||
view_space_pos = (_106 * _98).xyz;
|
||||
view_space_normal = mat3(_106[0].xyz, _106[1].xyz, _106[2].xyz) * vec3(0.0, 1.0, 0.0);
|
||||
uv_in = vec2(gbuffer_billboard_vs_params[4].x + (position.x * gbuffer_billboard_vs_params[4].z), gbuffer_billboard_vs_params[4].y + (position.y * gbuffer_billboard_vs_params[4].w));
|
||||
}
|
||||
|
||||
*/
|
||||
vs_gbuffer_billboard_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,0x67,0x62,
|
||||
0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,
|
||||
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x33,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,0x70,0x6f,0x73,0x69,
|
||||
0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76,
|
||||
0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x6f,
|
||||
0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,
|
||||
0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,
|
||||
0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,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,0x5f,0x35,0x33,0x20,0x3d,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,
|
||||
0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x67,0x62,
|
||||
0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,
|
||||
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x2e,0x78,0x79,0x7a,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,0x2e,
|
||||
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x6c,0x6f,0x6f,0x6b,
|
||||
0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
|
||||
0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x67,
|
||||
0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x32,0x5d,0x2e,0x78,
|
||||
0x20,0x3e,0x20,0x28,0x2d,0x31,0x30,0x2e,0x30,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,
|
||||
0x69,0x72,0x20,0x3d,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,
|
||||
0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x31,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x39,0x38,0x20,0x3d,0x20,0x76,
|
||||
0x65,0x63,0x34,0x28,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,
|
||||
0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x35,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x6e,0x6f,0x72,0x6d,0x61,
|
||||
0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x76,0x65,0x63,0x33,0x28,
|
||||
0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,
|
||||
0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x29,0x29,0x20,0x2a,0x20,0x28,0x28,0x70,
|
||||
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30,0x2e,0x35,0x29,
|
||||
0x20,0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,
|
||||
0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,
|
||||
0x5d,0x2e,0x78,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x33,0x28,0x30,
|
||||
0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,0x2a,0x20,
|
||||
0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x67,0x62,
|
||||
0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,
|
||||
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2e,0x79,0x29,0x29,
|
||||
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,
|
||||
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x67,
|
||||
0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x67,
|
||||
0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x67,
|
||||
0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x67,
|
||||
0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,
|
||||
0x20,0x5f,0x39,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x74,0x34,0x20,0x5f,
|
||||
0x31,0x30,0x36,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x67,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x39,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,
|
||||
0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x30,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,
|
||||
0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x31,0x5d,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,
|
||||
0x20,0x3d,0x20,0x28,0x5f,0x31,0x30,0x36,0x20,0x2a,0x20,0x5f,0x39,0x38,0x29,0x2e,
|
||||
0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,
|
||||
0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x6d,0x61,0x74,
|
||||
0x33,0x28,0x5f,0x31,0x30,0x36,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,
|
||||
0x31,0x30,0x36,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,0x30,0x36,
|
||||
0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,
|
||||
0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x75,0x76,0x5f,0x69,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,
|
||||
0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,
|
||||
0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,
|
||||
0x78,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,
|
||||
0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,
|
||||
0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,
|
||||
0x2e,0x7a,0x29,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,
|
||||
0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x34,0x5d,0x2e,0x79,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x2e,0x79,0x20,0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,
|
||||
0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x73,0x5b,0x34,0x5d,0x2e,0x77,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp sampler2D gsprite_gspritesmp;
|
||||
|
||||
in highp vec2 uv_in;
|
||||
layout(location = 0) out highp vec4 out_position;
|
||||
in highp vec3 view_space_pos;
|
||||
layout(location = 1) out highp vec4 out_normal;
|
||||
in highp vec3 view_space_normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec2 _12 = uv_in;
|
||||
_12.y = 1.0 - _12.y;
|
||||
if (texture(gsprite_gspritesmp, _12).w < 0.00999999977648258209228515625)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
out_position = vec4(view_space_pos, 1.0);
|
||||
out_normal = vec4(normalize(view_space_normal), 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_gbuffer_billboard_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x67,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x67,
|
||||
0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,
|
||||
0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,
|
||||
0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x3b,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,
|
||||
0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x76,
|
||||
0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,
|
||||
0x5f,0x31,0x32,0x20,0x3d,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,
|
||||
0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x74,0x65,
|
||||
0x78,0x74,0x75,0x72,0x65,0x28,0x67,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x67,0x73,
|
||||
0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x2e,0x77,
|
||||
0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,
|
||||
0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,
|
||||
0x32,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,
|
||||
0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,
|
||||
0x76,0x65,0x63,0x34,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x76,
|
||||
0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct gbuffer_billboard_vs_params
|
||||
{
|
||||
float4x4 mvp;
|
||||
float4 uvs;
|
||||
float3 offset;
|
||||
float2 size;
|
||||
float3 cam;
|
||||
float4x4 view_matrix;
|
||||
float3 faceDir;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float2 uv_in [[user(locn0)]];
|
||||
float3 view_space_pos [[user(locn1)]];
|
||||
float3 view_space_normal [[user(locn2)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float3 position [[attribute(0)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant gbuffer_billboard_vs_params& _24 [[buffer(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float3 _53 = _24.offset - _24.cam;
|
||||
_53.y = 0.0;
|
||||
float3 look_dir = fast::normalize(_53);
|
||||
if (_24.faceDir.x > (-10.0))
|
||||
{
|
||||
look_dir = _24.faceDir;
|
||||
}
|
||||
float4 _98 = float4((_24.offset + (fast::normalize(cross(float3(0.0, 1.0, 0.0), look_dir)) * ((in.position.x - 0.5) * _24.size.x))) + (float3(0.0, 1.0, 0.0) * (in.position.y * _24.size.y)), 1.0);
|
||||
out.gl_Position = _24.mvp * _98;
|
||||
out.view_space_pos = (_24.view_matrix * _98).xyz;
|
||||
out.view_space_normal = float3x3(_24.view_matrix[0].xyz, _24.view_matrix[1].xyz, _24.view_matrix[2].xyz) * float3(0.0, 1.0, 0.0);
|
||||
out.uv_in = float2(_24.uvs.x + (in.position.x * _24.uvs.z), _24.uvs.y + (in.position.y * _24.uvs.w));
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_gbuffer_billboard_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,0x67,
|
||||
0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x75,0x76,0x73,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x6f,0x66,0x66,0x73,0x65,0x74,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x73,0x69,0x7a,
|
||||
0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x63,0x61,
|
||||
0x6d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,
|
||||
0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x66,0x61,0x63,0x65,0x44,0x69,0x72,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,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,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,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,
|
||||
0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,
|
||||
0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,
|
||||
0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,
|
||||
0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x32,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,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,
|
||||
0x5d,0x5d,0x3b,0x0a,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,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,
|
||||
0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,
|
||||
0x32,0x34,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,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x35,0x33,0x20,0x3d,0x20,0x5f,0x32,0x34,
|
||||
0x2e,0x6f,0x66,0x66,0x73,0x65,0x74,0x20,0x2d,0x20,0x5f,0x32,0x34,0x2e,0x63,0x61,
|
||||
0x6d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,
|
||||
0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x6c,
|
||||
0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,
|
||||
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x32,0x34,0x2e,0x66,0x61,0x63,0x65,
|
||||
0x44,0x69,0x72,0x2e,0x78,0x20,0x3e,0x20,0x28,0x2d,0x31,0x30,0x2e,0x30,0x29,0x29,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6c,
|
||||
0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x5f,0x32,0x34,0x2e,0x66,0x61,
|
||||
0x63,0x65,0x44,0x69,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x39,0x38,0x20,0x3d,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x34,0x28,0x28,0x5f,0x32,0x34,0x2e,0x6f,0x66,0x66,0x73,0x65,0x74,
|
||||
0x20,0x2b,0x20,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,
|
||||
0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,
|
||||
0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x29,0x29,0x20,0x2a,0x20,0x28,0x28,
|
||||
0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,
|
||||
0x30,0x2e,0x35,0x29,0x20,0x2a,0x20,0x5f,0x32,0x34,0x2e,0x73,0x69,0x7a,0x65,0x2e,
|
||||
0x78,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,
|
||||
0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,0x2a,0x20,
|
||||
0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,
|
||||
0x20,0x5f,0x32,0x34,0x2e,0x73,0x69,0x7a,0x65,0x2e,0x79,0x29,0x29,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,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,0x32,0x34,0x2e,0x6d,
|
||||
0x76,0x70,0x20,0x2a,0x20,0x5f,0x39,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,
|
||||
0x74,0x2e,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,
|
||||
0x20,0x3d,0x20,0x28,0x5f,0x32,0x34,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,
|
||||
0x72,0x69,0x78,0x20,0x2a,0x20,0x5f,0x39,0x38,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,
|
||||
0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x33,0x78,0x33,0x28,0x5f,0x32,0x34,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,
|
||||
0x74,0x72,0x69,0x78,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x32,0x34,
|
||||
0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x31,0x5d,0x2e,
|
||||
0x78,0x79,0x7a,0x2c,0x20,0x5f,0x32,0x34,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,
|
||||
0x74,0x72,0x69,0x78,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,
|
||||
0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x75,0x76,
|
||||
0x5f,0x69,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x32,0x34,
|
||||
0x2e,0x75,0x76,0x73,0x2e,0x78,0x20,0x2b,0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,
|
||||
0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,0x5f,0x32,0x34,0x2e,0x75,0x76,
|
||||
0x73,0x2e,0x7a,0x29,0x2c,0x20,0x5f,0x32,0x34,0x2e,0x75,0x76,0x73,0x2e,0x79,0x20,
|
||||
0x2b,0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,
|
||||
0x20,0x2a,0x20,0x5f,0x32,0x34,0x2e,0x75,0x76,0x73,0x2e,0x77,0x29,0x29,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 out_position [[color(0)]];
|
||||
float4 out_normal [[color(1)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 uv_in [[user(locn0)]];
|
||||
float3 view_space_pos [[user(locn1)]];
|
||||
float3 view_space_normal [[user(locn2)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> gsprite [[texture(0)]], sampler gspritesmp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 _12 = in.uv_in;
|
||||
_12.y = 1.0 - _12.y;
|
||||
if (gsprite.sample(gspritesmp, _12).w < 0.00999999977648258209228515625)
|
||||
{
|
||||
discard_fragment();
|
||||
}
|
||||
out.out_position = float4(in.view_space_pos, 1.0);
|
||||
out.out_normal = float4(fast::normalize(in.view_space_normal), 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_gbuffer_billboard_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,0x6f,0x75,0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f,
|
||||
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x31,
|
||||
0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,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,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,
|
||||
0x63,0x65,0x5f,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,
|
||||
0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,
|
||||
0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
|
||||
0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,
|
||||
0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,
|
||||
0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,
|
||||
0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x67,0x73,
|
||||
0x70,0x72,0x69,0x74,0x65,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,
|
||||
0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x67,0x73,
|
||||
0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,
|
||||
0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x31,
|
||||
0x32,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,
|
||||
0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x67,
|
||||
0x73,0x70,0x72,0x69,0x74,0x65,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x67,0x73,
|
||||
0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x2e,0x77,
|
||||
0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,
|
||||
0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,
|
||||
0x32,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x5f,0x66,0x72,0x61,0x67,0x6d,0x65,
|
||||
0x6e,0x74,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x6f,0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x76,0x69,0x65,
|
||||
0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x2c,0x20,0x31,0x2e,0x30,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,0x6e,
|
||||
0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x66,
|
||||
0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x69,
|
||||
0x6e,0x2e,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,
|
||||
0x6d,0x61,0x6c,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,
|
||||
|
||||
];
|
||||
gbuffer_billboard_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "gbuffer_billboard_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_gbuffer_billboard_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_gbuffer_billboard_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 208;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 13;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "gbuffer_billboard_vs_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "gsprite_gspritesmp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_gbuffer_billboard_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_gbuffer_billboard_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 208;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 13;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "gbuffer_billboard_vs_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "gsprite_gspritesmp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_gbuffer_billboard_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_gbuffer_billboard_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 208;
|
||||
desc.uniform_blocks[0].msl_buffer_n = 0;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -1,608 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_mix.glsl -o ./jai/shader_mix.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'mix':
|
||||
Get shader desc: mix_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_mix
|
||||
Fragment Shader: fs_mix
|
||||
Attributes:
|
||||
ATTR_mix_position => 0
|
||||
ATTR_mix_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'mix_fs_params':
|
||||
Jai struct: Mix_Fs_Params
|
||||
Bind slot: UB_mix_fs_params => 1
|
||||
Image 'mixtex_a':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_mixtex_a => 0
|
||||
Image 'mixtex_b':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_mixtex_b => 1
|
||||
Image 'mixtex_c':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_mixtex_c => 2
|
||||
Sampler 'mixsmp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_mixsmp => 0
|
||||
*/
|
||||
ATTR_mix_position :: 0;
|
||||
ATTR_mix_uv :: 1;
|
||||
UB_mix_fs_params :: 1;
|
||||
IMG_mixtex_a :: 0;
|
||||
IMG_mixtex_b :: 1;
|
||||
IMG_mixtex_c :: 2;
|
||||
SMP_mixsmp :: 0;
|
||||
Mix_Fs_Params :: struct {
|
||||
op: s32;
|
||||
dof_min: float;
|
||||
dof_max: float;
|
||||
dof_point: float;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
layout(location = 0) out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_mix_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,
|
||||
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,
|
||||
0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,
|
||||
0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
struct mix_fs_params
|
||||
{
|
||||
int op;
|
||||
float dof_min;
|
||||
float dof_max;
|
||||
float dof_point;
|
||||
};
|
||||
|
||||
uniform mix_fs_params _10;
|
||||
|
||||
layout(binding = 16) uniform sampler2D mixtex_b_mixsmp;
|
||||
layout(binding = 17) uniform sampler2D mixtex_a_mixsmp;
|
||||
layout(binding = 18) uniform sampler2D mixtex_c_mixsmp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (_10.op == 0)
|
||||
{
|
||||
frag_color = vec4(mix(texture(mixtex_b_mixsmp, texcoord).xyz, texture(mixtex_a_mixsmp, texcoord).xyz, vec3(smoothstep(_10.dof_min, _10.dof_max, abs(texture(mixtex_c_mixsmp, texcoord).z + _10.dof_point)))), 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_10.op == 1)
|
||||
{
|
||||
frag_color = vec4(texture(mixtex_b_mixsmp, texcoord).xyz + texture(mixtex_a_mixsmp, texcoord).xyz, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
fs_mix_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
|
||||
0x72,0x75,0x63,0x74,0x20,0x6d,0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x6f,0x70,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x6d,
|
||||
0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,
|
||||
0x66,0x5f,0x6d,0x61,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x64,0x6f,0x66,0x5f,0x70,0x6f,0x69,0x6e,0x74,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
|
||||
0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x6d,0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x20,0x5f,0x31,0x30,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,
|
||||
0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x36,0x29,
|
||||
0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,
|
||||
0x32,0x44,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x5f,0x6d,0x69,0x78,0x73,
|
||||
0x6d,0x70,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,
|
||||
0x6e,0x67,0x20,0x3d,0x20,0x31,0x37,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,
|
||||
0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x6d,0x69,0x78,0x74,0x65,
|
||||
0x78,0x5f,0x61,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
|
||||
0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x38,0x29,
|
||||
0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,
|
||||
0x32,0x44,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x5f,0x6d,0x69,0x78,0x73,
|
||||
0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,
|
||||
0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
|
||||
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,
|
||||
0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x30,
|
||||
0x2e,0x6f,0x70,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
|
||||
0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x6d,0x69,0x78,0x28,0x74,0x65,
|
||||
0x78,0x74,0x75,0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x5f,0x6d,
|
||||
0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,
|
||||
0x2e,0x78,0x79,0x7a,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6d,0x69,
|
||||
0x78,0x74,0x65,0x78,0x5f,0x61,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,
|
||||
0x63,0x33,0x28,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x5f,0x31,
|
||||
0x30,0x2e,0x64,0x6f,0x66,0x5f,0x6d,0x69,0x6e,0x2c,0x20,0x5f,0x31,0x30,0x2e,0x64,
|
||||
0x6f,0x66,0x5f,0x6d,0x61,0x78,0x2c,0x20,0x61,0x62,0x73,0x28,0x74,0x65,0x78,0x74,
|
||||
0x75,0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x5f,0x6d,0x69,0x78,
|
||||
0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x7a,
|
||||
0x20,0x2b,0x20,0x5f,0x31,0x30,0x2e,0x64,0x6f,0x66,0x5f,0x70,0x6f,0x69,0x6e,0x74,
|
||||
0x29,0x29,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x30,
|
||||
0x2e,0x6f,0x70,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,
|
||||
0x5f,0x62,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,
|
||||
0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x61,0x5f,0x6d,0x69,0x78,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,
|
||||
0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
out vec2 texcoord;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_mix_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,
|
||||
0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,
|
||||
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||
0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
struct mix_fs_params
|
||||
{
|
||||
int op;
|
||||
highp float dof_min;
|
||||
highp float dof_max;
|
||||
highp float dof_point;
|
||||
};
|
||||
|
||||
uniform mix_fs_params _10;
|
||||
|
||||
uniform highp sampler2D mixtex_b_mixsmp;
|
||||
uniform highp sampler2D mixtex_a_mixsmp;
|
||||
uniform highp sampler2D mixtex_c_mixsmp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (_10.op == 0)
|
||||
{
|
||||
frag_color = vec4(mix(texture(mixtex_b_mixsmp, texcoord).xyz, texture(mixtex_a_mixsmp, texcoord).xyz, vec3(smoothstep(_10.dof_min, _10.dof_max, abs(texture(mixtex_c_mixsmp, texcoord).z + _10.dof_point)))), 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_10.op == 1)
|
||||
{
|
||||
frag_color = vec4(texture(mixtex_b_mixsmp, texcoord).xyz + texture(mixtex_a_mixsmp, texcoord).xyz, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
fs_mix_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x73,
|
||||
0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x6f,0x70,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x64,0x6f,0x66,0x5f,0x6d,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,
|
||||
0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x6d,
|
||||
0x61,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x70,0x6f,0x69,0x6e,0x74,0x3b,0x0a,0x7d,
|
||||
0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x6d,0x69,0x78,0x5f,0x66,
|
||||
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x5f,0x31,0x30,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x5f,
|
||||
0x6d,0x69,0x78,0x73,0x6d,0x70,0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,
|
||||
0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,
|
||||
0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x61,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x3b,
|
||||
0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,
|
||||
0x63,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,
|
||||
0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
|
||||
0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x30,0x2e,0x6f,0x70,
|
||||
0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||
0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x6d,0x69,0x78,0x28,0x74,0x65,0x78,0x74,0x75,
|
||||
0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x5f,0x6d,0x69,0x78,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,
|
||||
0x7a,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,
|
||||
0x78,0x5f,0x61,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,
|
||||
0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x5f,0x31,0x30,0x2e,0x64,
|
||||
0x6f,0x66,0x5f,0x6d,0x69,0x6e,0x2c,0x20,0x5f,0x31,0x30,0x2e,0x64,0x6f,0x66,0x5f,
|
||||
0x6d,0x61,0x78,0x2c,0x20,0x61,0x62,0x73,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,
|
||||
0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x7a,0x20,0x2b,0x20,
|
||||
0x5f,0x31,0x30,0x2e,0x64,0x6f,0x66,0x5f,0x70,0x6f,0x69,0x6e,0x74,0x29,0x29,0x29,
|
||||
0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x30,0x2e,0x6f,0x70,
|
||||
0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,
|
||||
0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x74,
|
||||
0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x5f,
|
||||
0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,
|
||||
0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x61,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,
|
||||
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 position [[attribute(0)]];
|
||||
float2 uv [[attribute(1)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = float4(in.position, 0.5, 1.0);
|
||||
out.texcoord = in.uv;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_mix_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,
|
||||
0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,
|
||||
0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct mix_fs_params
|
||||
{
|
||||
int op;
|
||||
float dof_min;
|
||||
float dof_max;
|
||||
float dof_point;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], constant mix_fs_params& _10 [[buffer(0)]], texture2d<float> mixtex_a [[texture(0)]], texture2d<float> mixtex_b [[texture(1)]], texture2d<float> mixtex_c [[texture(2)]], sampler mixsmp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
if (_10.op == 0)
|
||||
{
|
||||
out.frag_color = float4(mix(mixtex_b.sample(mixsmp, in.texcoord).xyz, mixtex_a.sample(mixsmp, in.texcoord).xyz, float3(smoothstep(_10.dof_min, _10.dof_max, abs(mixtex_c.sample(mixsmp, in.texcoord).z + _10.dof_point)))), 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_10.op == 1)
|
||||
{
|
||||
out.frag_color = float4(mixtex_b.sample(mixsmp, in.texcoord).xyz + mixtex_a.sample(mixsmp, in.texcoord).xyz, 1.0);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_mix_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x6d,0x69,0x6e,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x6d,0x61,0x78,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x70,
|
||||
0x6f,0x69,0x6e,0x74,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
|
||||
0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
|
||||
0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,
|
||||
0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
|
||||
0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,
|
||||
0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,
|
||||
0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,
|
||||
0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x6d,0x69,0x78,0x5f,
|
||||
0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,0x30,0x20,0x5b,
|
||||
0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,
|
||||
0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x6d,
|
||||
0x69,0x78,0x74,0x65,0x78,0x5f,0x61,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,
|
||||
0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,
|
||||
0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,
|
||||
0x62,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x31,0x29,0x5d,0x5d,
|
||||
0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x3e,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x20,0x5b,0x5b,0x74,0x65,
|
||||
0x78,0x74,0x75,0x72,0x65,0x28,0x32,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x72,0x20,0x6d,0x69,0x78,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,
|
||||
0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x30,
|
||||
0x2e,0x6f,0x70,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,
|
||||
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
|
||||
0x6d,0x69,0x78,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x2e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x28,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x6d,0x69,
|
||||
0x78,0x74,0x65,0x78,0x5f,0x61,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x6d,0x69,
|
||||
0x78,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x73,
|
||||
0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x5f,0x31,0x30,0x2e,0x64,0x6f,
|
||||
0x66,0x5f,0x6d,0x69,0x6e,0x2c,0x20,0x5f,0x31,0x30,0x2e,0x64,0x6f,0x66,0x5f,0x6d,
|
||||
0x61,0x78,0x2c,0x20,0x61,0x62,0x73,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,
|
||||
0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,
|
||||
0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x7a,0x20,0x2b,
|
||||
0x20,0x5f,0x31,0x30,0x2e,0x64,0x6f,0x66,0x5f,0x70,0x6f,0x69,0x6e,0x74,0x29,0x29,
|
||||
0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x30,0x2e,0x6f,
|
||||
0x70,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x75,
|
||||
0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x2e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x28,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,
|
||||
0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2b,
|
||||
0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x61,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,
|
||||
0x28,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,
|
||||
0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
mix_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "mix_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_mix_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_mix_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[1].layout = .STD140;
|
||||
desc.uniform_blocks[1].size = 16;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].type = .INT;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_10.op";
|
||||
desc.uniform_blocks[1].glsl_uniforms[1].type = .FLOAT;
|
||||
desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0;
|
||||
desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_10.dof_min";
|
||||
desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT;
|
||||
desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0;
|
||||
desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_10.dof_max";
|
||||
desc.uniform_blocks[1].glsl_uniforms[3].type = .FLOAT;
|
||||
desc.uniform_blocks[1].glsl_uniforms[3].array_count = 0;
|
||||
desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_10.dof_point";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.images[2].stage = .FRAGMENT;
|
||||
desc.images[2].multisampled = false;
|
||||
desc.images[2].image_type = ._2D;
|
||||
desc.images[2].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 1;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "mixtex_b_mixsmp";
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 0;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[1].glsl_name = "mixtex_a_mixsmp";
|
||||
desc.image_sampler_pairs[2].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[2].image_slot = 2;
|
||||
desc.image_sampler_pairs[2].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[2].glsl_name = "mixtex_c_mixsmp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_mix_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_mix_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[1].layout = .STD140;
|
||||
desc.uniform_blocks[1].size = 16;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].type = .INT;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_10.op";
|
||||
desc.uniform_blocks[1].glsl_uniforms[1].type = .FLOAT;
|
||||
desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0;
|
||||
desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_10.dof_min";
|
||||
desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT;
|
||||
desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0;
|
||||
desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_10.dof_max";
|
||||
desc.uniform_blocks[1].glsl_uniforms[3].type = .FLOAT;
|
||||
desc.uniform_blocks[1].glsl_uniforms[3].array_count = 0;
|
||||
desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_10.dof_point";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.images[2].stage = .FRAGMENT;
|
||||
desc.images[2].multisampled = false;
|
||||
desc.images[2].image_type = ._2D;
|
||||
desc.images[2].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 1;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "mixtex_b_mixsmp";
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 0;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[1].glsl_name = "mixtex_a_mixsmp";
|
||||
desc.image_sampler_pairs[2].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[2].image_slot = 2;
|
||||
desc.image_sampler_pairs[2].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[2].glsl_name = "mixtex_c_mixsmp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_mix_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_mix_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[1].layout = .STD140;
|
||||
desc.uniform_blocks[1].size = 16;
|
||||
desc.uniform_blocks[1].msl_buffer_n = 0;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.images[1].msl_texture_n = 1;
|
||||
desc.images[2].stage = .FRAGMENT;
|
||||
desc.images[2].multisampled = false;
|
||||
desc.images[2].image_type = ._2D;
|
||||
desc.images[2].sample_type = .FLOAT;
|
||||
desc.images[2].msl_texture_n = 2;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 1;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 0;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[2].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[2].image_slot = 2;
|
||||
desc.image_sampler_pairs[2].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,637 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_particle.glsl -o ./jai/shader_particle.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'particle':
|
||||
Get shader desc: particle_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_particle
|
||||
Fragment Shader: fs_particle
|
||||
Attributes:
|
||||
ATTR_particle_position => 0
|
||||
ATTR_particle_inst_pos_size => 1
|
||||
ATTR_particle_inst_uv_rect => 2
|
||||
ATTR_particle_inst_color => 3
|
||||
Bindings:
|
||||
Uniform block 'particle_vs_params':
|
||||
Jai struct: Particle_Vs_Params
|
||||
Bind slot: UB_particle_vs_params => 0
|
||||
Image 'particle_sprite':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_particle_sprite => 0
|
||||
Sampler 'particle_spritesmp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_particle_spritesmp => 0
|
||||
*/
|
||||
ATTR_particle_position :: 0;
|
||||
ATTR_particle_inst_pos_size :: 1;
|
||||
ATTR_particle_inst_uv_rect :: 2;
|
||||
ATTR_particle_inst_color :: 3;
|
||||
UB_particle_vs_params :: 0;
|
||||
IMG_particle_sprite :: 0;
|
||||
SMP_particle_spritesmp :: 0;
|
||||
Particle_Vs_Params :: struct {
|
||||
mvp: [16]float;
|
||||
cam: [3]float;
|
||||
_: [4]u8;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 particle_vs_params[5];
|
||||
layout(location = 1) in vec4 inst_pos_size;
|
||||
layout(location = 0) in vec3 position;
|
||||
layout(location = 0) out vec2 uv_in;
|
||||
layout(location = 2) in vec4 inst_uv_rect;
|
||||
layout(location = 1) out vec4 color_in;
|
||||
layout(location = 3) in vec4 inst_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 _53 = inst_pos_size.xyz - particle_vs_params[4].xyz;
|
||||
_53.y = 0.0;
|
||||
vec3 look_dir = _53;
|
||||
if (length(_53) < 9.9999997473787516355514526367188e-05)
|
||||
{
|
||||
look_dir = vec3(1.0, 0.0, 0.0);
|
||||
}
|
||||
vec3 _63 = look_dir;
|
||||
vec3 _64 = normalize(_63);
|
||||
look_dir = _64;
|
||||
gl_Position = mat4(particle_vs_params[0], particle_vs_params[1], particle_vs_params[2], particle_vs_params[3]) * vec4((inst_pos_size.xyz + (normalize(cross(vec3(0.0, 1.0, 0.0), _64)) * ((position.x - 0.5) * inst_pos_size.w))) + (vec3(0.0, 1.0, 0.0) * (position.y * inst_pos_size.w)), 1.0);
|
||||
uv_in = vec2(inst_uv_rect.x + (position.x * inst_uv_rect.z), inst_uv_rect.y + (position.y * inst_uv_rect.w));
|
||||
color_in = inst_color;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_particle_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,0x70,0x61,0x72,0x74,0x69,
|
||||
0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,
|
||||
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,0x69,
|
||||
0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,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,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,
|
||||
0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,
|
||||
0x65,0x63,0x74,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,
|
||||
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x35,
|
||||
0x33,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,
|
||||
0x65,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,
|
||||
0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,
|
||||
0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x6c,0x6f,0x6f,
|
||||
0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x5f,0x35,0x33,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x69,0x66,0x20,0x28,0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x5f,0x35,0x33,0x29,
|
||||
0x20,0x3c,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,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,
|
||||
0x20,0x3d,0x20,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,
|
||||
0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x36,0x33,0x20,0x3d,0x20,0x6c,0x6f,0x6f,
|
||||
0x6b,0x5f,0x64,0x69,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
|
||||
0x5f,0x36,0x34,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,
|
||||
0x5f,0x36,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,
|
||||
0x69,0x72,0x20,0x3d,0x20,0x5f,0x36,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,
|
||||
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,
|
||||
0x28,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x70,
|
||||
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x73,0x5b,0x32,0x5d,0x2c,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,
|
||||
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,
|
||||
0x65,0x63,0x34,0x28,0x28,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,
|
||||
0x7a,0x65,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x76,0x65,0x63,0x33,0x28,0x30,
|
||||
0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x5f,
|
||||
0x36,0x34,0x29,0x29,0x20,0x2a,0x20,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30,0x2e,0x35,0x29,0x20,0x2a,0x20,0x69,0x6e,0x73,
|
||||
0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,0x77,0x29,0x29,0x29,0x20,
|
||||
0x2b,0x20,0x28,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,
|
||||
0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,0x2a,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,
|
||||
0x73,0x69,0x7a,0x65,0x2e,0x77,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x75,0x76,0x5f,0x69,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,
|
||||
0x28,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x78,0x20,
|
||||
0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,
|
||||
0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x7a,0x29,0x2c,
|
||||
0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x79,0x20,
|
||||
0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,
|
||||
0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x77,0x29,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x20,0x3d,
|
||||
0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||
0x00,
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(binding = 16) uniform sampler2D particle_sprite_particle_spritesmp;
|
||||
|
||||
layout(location = 0) in vec2 uv_in;
|
||||
layout(location = 0) out vec4 color;
|
||||
layout(location = 1) in vec4 color_in;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 _12 = uv_in;
|
||||
_12.y = 1.0 - _12.y;
|
||||
vec4 _35 = texture(particle_sprite_particle_spritesmp, _12);
|
||||
if (_35.w < 0.00999999977648258209228515625)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
color = _35 * color_in;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_particle_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,
|
||||
0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x72,0x32,0x44,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,
|
||||
0x72,0x69,0x74,0x65,0x5f,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,
|
||||
0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,
|
||||
0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,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,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,
|
||||
0x32,0x20,0x5f,0x31,0x32,0x20,0x3d,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,
|
||||
0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,
|
||||
0x20,0x5f,0x33,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x70,
|
||||
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x70,
|
||||
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,
|
||||
0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,
|
||||
0x28,0x5f,0x33,0x35,0x2e,0x77,0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,
|
||||
0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,
|
||||
0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x3d,0x20,0x5f,0x33,0x35,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x69,
|
||||
0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
uniform vec4 particle_vs_params[5];
|
||||
layout(location = 1) in vec4 inst_pos_size;
|
||||
layout(location = 0) in vec3 position;
|
||||
out vec2 uv_in;
|
||||
layout(location = 2) in vec4 inst_uv_rect;
|
||||
out vec4 color_in;
|
||||
layout(location = 3) in vec4 inst_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 _53 = inst_pos_size.xyz - particle_vs_params[4].xyz;
|
||||
_53.y = 0.0;
|
||||
vec3 look_dir = _53;
|
||||
if (length(_53) < 9.9999997473787516355514526367188e-05)
|
||||
{
|
||||
look_dir = vec3(1.0, 0.0, 0.0);
|
||||
}
|
||||
vec3 _63 = look_dir;
|
||||
vec3 _64 = normalize(_63);
|
||||
look_dir = _64;
|
||||
gl_Position = mat4(particle_vs_params[0], particle_vs_params[1], particle_vs_params[2], particle_vs_params[3]) * vec4((inst_pos_size.xyz + (normalize(cross(vec3(0.0, 1.0, 0.0), _64)) * ((position.x - 0.5) * inst_pos_size.w))) + (vec3(0.0, 1.0, 0.0) * (position.y * inst_pos_size.w)), 1.0);
|
||||
uv_in = vec2(inst_uv_rect.x + (position.x * inst_uv_rect.z), inst_uv_rect.y + (position.y * inst_uv_rect.w));
|
||||
color_in = inst_color;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_particle_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,0x70,0x61,
|
||||
0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x35,0x5d,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,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,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,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
||||
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,
|
||||
0x74,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
|
||||
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,
|
||||
0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,
|
||||
0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x35,0x33,0x20,0x3d,0x20,0x69,0x6e,0x73,
|
||||
0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,0x78,0x79,0x7a,0x20,0x2d,
|
||||
0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x76,0x65,0x63,0x33,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,
|
||||
0x20,0x5f,0x35,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x6c,0x65,
|
||||
0x6e,0x67,0x74,0x68,0x28,0x5f,0x35,0x33,0x29,0x20,0x3c,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,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x33,
|
||||
0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
|
||||
0x5f,0x36,0x33,0x20,0x3d,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x36,0x34,0x20,0x3d,0x20,0x6e,
|
||||
0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x36,0x33,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x5f,0x36,
|
||||
0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x70,0x61,0x72,0x74,0x69,0x63,
|
||||
0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,
|
||||
0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x70,
|
||||
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x69,0x6e,
|
||||
0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,0x78,0x79,0x7a,0x20,
|
||||
0x2b,0x20,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,
|
||||
0x73,0x73,0x28,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,
|
||||
0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x5f,0x36,0x34,0x29,0x29,0x20,0x2a,0x20,
|
||||
0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30,
|
||||
0x2e,0x35,0x29,0x20,0x2a,0x20,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,
|
||||
0x69,0x7a,0x65,0x2e,0x77,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x33,
|
||||
0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,
|
||||
0x2a,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,
|
||||
0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,0x77,0x29,
|
||||
0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x5f,
|
||||
0x69,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x69,0x6e,0x73,0x74,0x5f,0x75,
|
||||
0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x78,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,
|
||||
0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,
|
||||
0x5f,0x72,0x65,0x63,0x74,0x2e,0x7a,0x29,0x2c,0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,
|
||||
0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x79,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,
|
||||
0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,
|
||||
0x5f,0x72,0x65,0x63,0x74,0x2e,0x77,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp sampler2D particle_sprite_particle_spritesmp;
|
||||
|
||||
in highp vec2 uv_in;
|
||||
layout(location = 0) out highp vec4 color;
|
||||
in highp vec4 color_in;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec2 _12 = uv_in;
|
||||
_12.y = 1.0 - _12.y;
|
||||
highp vec4 _35 = texture(particle_sprite_particle_spritesmp, _12);
|
||||
if (_35.w < 0.00999999977648258209228515625)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
color = _35 * color_in;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_particle_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,
|
||||
0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,
|
||||
0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,
|
||||
0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,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,0x63,0x6f,0x6c,0x6f,0x72,0x5f,
|
||||
0x69,0x6e,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,
|
||||
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||
0x32,0x20,0x5f,0x31,0x32,0x20,0x3d,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,
|
||||
0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x33,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x28,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,
|
||||
0x72,0x69,0x74,0x65,0x5f,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,
|
||||
0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x35,0x2e,0x77,0x20,0x3c,0x20,0x30,
|
||||
0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,
|
||||
0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,
|
||||
0x73,0x63,0x61,0x72,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x33,0x35,0x20,0x2a,0x20,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct particle_vs_params
|
||||
{
|
||||
float4x4 mvp;
|
||||
float3 cam;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float2 uv_in [[user(locn0)]];
|
||||
float4 color_in [[user(locn1)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float3 position [[attribute(0)]];
|
||||
float4 inst_pos_size [[attribute(1)]];
|
||||
float4 inst_uv_rect [[attribute(2)]];
|
||||
float4 inst_color [[attribute(3)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant particle_vs_params& _47 [[buffer(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float3 _53 = in.inst_pos_size.xyz - _47.cam;
|
||||
_53.y = 0.0;
|
||||
float3 look_dir = _53;
|
||||
if (length(_53) < 9.9999997473787516355514526367188e-05)
|
||||
{
|
||||
look_dir = float3(1.0, 0.0, 0.0);
|
||||
}
|
||||
float3 _63 = look_dir;
|
||||
float3 _64 = fast::normalize(_63);
|
||||
look_dir = _64;
|
||||
out.gl_Position = _47.mvp * float4((in.inst_pos_size.xyz + (fast::normalize(cross(float3(0.0, 1.0, 0.0), _64)) * ((in.position.x - 0.5) * in.inst_pos_size.w))) + (float3(0.0, 1.0, 0.0) * (in.position.y * in.inst_pos_size.w)), 1.0);
|
||||
out.uv_in = float2(in.inst_uv_rect.x + (in.position.x * in.inst_uv_rect.z), in.inst_uv_rect.y + (in.position.y * in.inst_uv_rect.w));
|
||||
out.color_in = in.inst_color;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_particle_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,0x70,
|
||||
0x61,0x72,0x74,0x69,0x63,0x6c,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,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
|
||||
0x20,0x63,0x61,0x6d,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,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,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,0x63,0x6f,0x6c,0x6f,0x72,0x5f,
|
||||
0x69,0x6e,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,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,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,
|
||||
0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
||||
0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x20,0x5b,0x5b,
|
||||
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,
|
||||
0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,
|
||||
0x75,0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||
0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x33,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,
|
||||
0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x26,0x20,0x5f,0x34,0x37,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,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x35,0x33,0x20,
|
||||
0x3d,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,
|
||||
0x7a,0x65,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x5f,0x34,0x37,0x2e,0x63,0x61,0x6d,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,0x2e,
|
||||
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x6c,0x6f,
|
||||
0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x5f,0x35,0x33,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x69,0x66,0x20,0x28,0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x5f,0x35,0x33,
|
||||
0x29,0x20,0x3c,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,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,
|
||||
0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,
|
||||
0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x36,0x33,0x20,
|
||||
0x3d,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x36,0x34,0x20,0x3d,0x20,0x66,0x61,0x73,
|
||||
0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x36,0x33,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,
|
||||
0x3d,0x20,0x5f,0x36,0x34,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,0x34,0x37,
|
||||
0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x69,
|
||||
0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,
|
||||
0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,
|
||||
0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,
|
||||
0x30,0x29,0x2c,0x20,0x5f,0x36,0x34,0x29,0x29,0x20,0x2a,0x20,0x28,0x28,0x69,0x6e,
|
||||
0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30,0x2e,
|
||||
0x35,0x29,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,
|
||||
0x5f,0x73,0x69,0x7a,0x65,0x2e,0x77,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,
|
||||
0x2e,0x30,0x29,0x20,0x2a,0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x70,
|
||||
0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,0x77,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x75,0x76,0x5f,0x69,0x6e,
|
||||
0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x69,0x6e,0x2e,0x69,0x6e,0x73,
|
||||
0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x78,0x20,0x2b,0x20,0x28,0x69,
|
||||
0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,0x69,
|
||||
0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x7a,
|
||||
0x29,0x2c,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,
|
||||
0x63,0x74,0x2e,0x79,0x20,0x2b,0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,
|
||||
0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x77,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x20,0x3d,0x20,
|
||||
0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,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 color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 uv_in [[user(locn0)]];
|
||||
float4 color_in [[user(locn1)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> particle_sprite [[texture(0)]], sampler particle_spritesmp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 _12 = in.uv_in;
|
||||
_12.y = 1.0 - _12.y;
|
||||
float4 _35 = particle_sprite.sample(particle_spritesmp, _12);
|
||||
if (_35.w < 0.00999999977648258209228515625)
|
||||
{
|
||||
discard_fragment();
|
||||
}
|
||||
out.color = _35 * in.color_in;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_particle_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,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,
|
||||
0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,
|
||||
0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,
|
||||
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,0x63,0x6f,0x6c,
|
||||
0x6f,0x72,0x5f,0x69,0x6e,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,
|
||||
0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,
|
||||
0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,
|
||||
0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,
|
||||
0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65,
|
||||
0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x70,
|
||||
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x20,0x5b,
|
||||
0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,
|
||||
0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,
|
||||
0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,
|
||||
0x31,0x32,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,
|
||||
0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x34,0x20,0x5f,0x33,0x35,0x20,0x3d,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,
|
||||
0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,
|
||||
0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,
|
||||
0x20,0x28,0x5f,0x33,0x35,0x2e,0x77,0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,
|
||||
0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,
|
||||
0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,
|
||||
0x5f,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x3d,0x20,0x5f,0x33,0x35,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,
|
||||
0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
particle_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "particle_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_particle_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_particle_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "inst_pos_size";
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[2].glsl_name = "inst_uv_rect";
|
||||
desc.attrs[3].base_type = .FLOAT;
|
||||
desc.attrs[3].glsl_name = "inst_color";
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 80;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 5;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "particle_vs_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "particle_sprite_particle_spritesmp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_particle_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_particle_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "inst_pos_size";
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[2].glsl_name = "inst_uv_rect";
|
||||
desc.attrs[3].base_type = .FLOAT;
|
||||
desc.attrs[3].glsl_name = "inst_color";
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 80;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 5;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "particle_vs_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "particle_sprite_particle_spritesmp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_particle_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_particle_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[3].base_type = .FLOAT;
|
||||
desc.uniform_blocks[0].stage = .VERTEX;
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 80;
|
||||
desc.uniform_blocks[0].msl_buffer_n = 0;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,821 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_sky.glsl -o ./jai/shader_sky.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'sky':
|
||||
Get shader desc: sky_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_sky
|
||||
Fragment Shader: fs_sky
|
||||
Attributes:
|
||||
ATTR_sky_position => 0
|
||||
Bindings:
|
||||
Uniform block 'sky_vs_params':
|
||||
Jai struct: Sky_Vs_Params
|
||||
Bind slot: UB_sky_vs_params => 0
|
||||
Uniform block 'sky_world_config':
|
||||
Jai struct: Sky_World_Config
|
||||
Bind slot: UB_sky_world_config => 1
|
||||
*/
|
||||
ATTR_sky_position :: 0;
|
||||
UB_sky_vs_params :: 0;
|
||||
UB_sky_world_config :: 1;
|
||||
Sky_Vs_Params :: struct {
|
||||
mvp: [16]float;
|
||||
};
|
||||
Sky_World_Config :: struct {
|
||||
skyBase: [3]float;
|
||||
_: [4]u8;
|
||||
skyTop: [3]float;
|
||||
_: [4]u8;
|
||||
sunDisk: [3]float;
|
||||
_: [4]u8;
|
||||
horizonHalo: [3]float;
|
||||
_: [4]u8;
|
||||
sunHalo: [3]float;
|
||||
_: [4]u8;
|
||||
sunLightColor: [3]float;
|
||||
_: [4]u8;
|
||||
sunPosition: [3]float;
|
||||
sunIntensity: float;
|
||||
skyIntensity: float;
|
||||
hasClouds: s32;
|
||||
planeHeight: float;
|
||||
animatePlaneHeight: s32;
|
||||
waterColor: [3]float;
|
||||
_: [4]u8;
|
||||
deepColor: [3]float;
|
||||
time: float;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 sky_vs_params[4];
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 0) out vec4 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mat4(sky_vs_params[0], sky_vs_params[1], sky_vs_params[2], sky_vs_params[3]) * vec4(position.xyz * 1000.0, 1.0);
|
||||
pos = position;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_sky_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,0x73,0x6b,0x79,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,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,
|
||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,
|
||||
0x34,0x20,0x70,0x6f,0x73,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,0x73,0x6b,0x79,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x73,
|
||||
0x6b,0x79,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,
|
||||
0x20,0x73,0x6b,0x79,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,
|
||||
0x5d,0x2c,0x20,0x73,0x6b,0x79,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,
|
||||
0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x31,0x30,0x30,0x30,0x2e,
|
||||
0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,
|
||||
0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||
0x00,
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
struct sky_world_config
|
||||
{
|
||||
vec3 skyBase;
|
||||
vec3 skyTop;
|
||||
vec3 sunDisk;
|
||||
vec3 horizonHalo;
|
||||
vec3 sunHalo;
|
||||
vec3 sunLightColor;
|
||||
vec3 sunPosition;
|
||||
float sunIntensity;
|
||||
float skyIntensity;
|
||||
int hasClouds;
|
||||
float planeHeight;
|
||||
int animatePlaneHeight;
|
||||
vec3 waterColor;
|
||||
vec3 deepColor;
|
||||
float time;
|
||||
};
|
||||
|
||||
uniform sky_world_config _18;
|
||||
|
||||
layout(location = 0) in vec4 pos;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
vec3 sky(vec3 skypos, vec3 sunpos)
|
||||
{
|
||||
vec3 _57 = normalize(sunpos);
|
||||
vec3 _63 = normalize(cross(_57, vec3(0.0, 1.0, 0.0)));
|
||||
vec3 _75 = normalize(skypos) - (_57 * dot(normalize(skypos), normalize(sunpos)));
|
||||
float _89 = max(abs(dot(_75, _63)), abs(dot(_75, normalize(cross(_63, _57)))));
|
||||
float _98 = clamp((0.25 - _89) * 6.0, 0.0, 1.0);
|
||||
vec3 final = mix(_18.skyBase, _18.skyTop, vec3(clamp(skypos.y * 2.0, 0.0, 0.699999988079071044921875))) + ((_18.sunHalo * _98) * _98);
|
||||
if (_89 < 0.0320000015199184417724609375)
|
||||
{
|
||||
final = _18.sunDisk * 3.0;
|
||||
}
|
||||
vec3 _132 = final;
|
||||
vec3 _133 = _132 + (mix(_18.horizonHalo, vec3(0.0), vec3(clamp(abs(normalize(skypos).y) * 20.0, 0.0, 1.0))) * 0.800000011920928955078125);
|
||||
final = _133;
|
||||
return _133;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 param = normalize(pos.xyz);
|
||||
vec3 param_1 = _18.sunPosition;
|
||||
frag_color = vec4(sky(param, param_1) * _18.skyIntensity, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_sky_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
|
||||
0x72,0x75,0x63,0x74,0x20,0x73,0x6b,0x79,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63,
|
||||
0x6f,0x6e,0x66,0x69,0x67,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,
|
||||
0x20,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
|
||||
0x63,0x33,0x20,0x73,0x6b,0x79,0x54,0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,
|
||||
0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x76,0x65,0x63,0x33,0x20,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,
|
||||
0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x48,
|
||||
0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,
|
||||
0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x75,0x6e,
|
||||
0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,
|
||||
0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x68,0x61,0x73,0x43,0x6c,
|
||||
0x6f,0x75,0x64,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
||||
0x70,0x6c,0x61,0x6e,0x65,0x48,0x65,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x69,0x6e,0x74,0x20,0x61,0x6e,0x69,0x6d,0x61,0x74,0x65,0x50,0x6c,0x61,0x6e,
|
||||
0x65,0x48,0x65,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,
|
||||
0x33,0x20,0x77,0x61,0x74,0x65,0x72,0x43,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x76,0x65,0x63,0x33,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,0x73,0x6b,
|
||||
0x79,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x20,0x5f,
|
||||
0x31,0x38,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,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,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,
|
||||
0x0a,0x0a,0x76,0x65,0x63,0x33,0x20,0x73,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,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
|
||||
0x5f,0x35,0x37,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,0x76,0x65,0x63,
|
||||
0x33,0x20,0x5f,0x36,0x33,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,
|
||||
0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x5f,0x35,0x37,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,0x76,0x65,0x63,0x33,0x20,0x5f,0x37,0x35,
|
||||
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,0x35,0x37,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,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,
|
||||
0x75,0x6e,0x70,0x6f,0x73,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x20,0x5f,0x38,0x39,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x61,0x62,
|
||||
0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,0x37,0x35,0x2c,0x20,0x5f,0x36,0x33,0x29,0x29,
|
||||
0x2c,0x20,0x61,0x62,0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,0x37,0x35,0x2c,0x20,0x6e,
|
||||
0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x5f,
|
||||
0x36,0x33,0x2c,0x20,0x5f,0x35,0x37,0x29,0x29,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x39,0x38,0x20,0x3d,0x20,0x63,0x6c,
|
||||
0x61,0x6d,0x70,0x28,0x28,0x30,0x2e,0x32,0x35,0x20,0x2d,0x20,0x5f,0x38,0x39,0x29,
|
||||
0x20,0x2a,0x20,0x36,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x66,0x69,0x6e,0x61,
|
||||
0x6c,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f,0x31,0x38,0x2e,0x73,0x6b,0x79,0x42,
|
||||
0x61,0x73,0x65,0x2c,0x20,0x5f,0x31,0x38,0x2e,0x73,0x6b,0x79,0x54,0x6f,0x70,0x2c,
|
||||
0x20,0x76,0x65,0x63,0x33,0x28,0x63,0x6c,0x61,0x6d,0x70,0x28,0x73,0x6b,0x79,0x70,
|
||||
0x6f,0x73,0x2e,0x79,0x20,0x2a,0x20,0x32,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,
|
||||
0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,
|
||||
0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x29,0x20,0x2b,
|
||||
0x20,0x28,0x28,0x5f,0x31,0x38,0x2e,0x73,0x75,0x6e,0x48,0x61,0x6c,0x6f,0x20,0x2a,
|
||||
0x20,0x5f,0x39,0x38,0x29,0x20,0x2a,0x20,0x5f,0x39,0x38,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x38,0x39,0x20,0x3c,0x20,0x30,0x2e,0x30,0x33,
|
||||
0x32,0x30,0x30,0x30,0x30,0x30,0x31,0x35,0x31,0x39,0x39,0x31,0x38,0x34,0x34,0x31,
|
||||
0x37,0x37,0x32,0x34,0x36,0x30,0x39,0x33,0x37,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,
|
||||
0x3d,0x20,0x5f,0x31,0x38,0x2e,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x20,0x2a,0x20,
|
||||
0x33,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x76,
|
||||
0x65,0x63,0x33,0x20,0x5f,0x31,0x33,0x32,0x20,0x3d,0x20,0x66,0x69,0x6e,0x61,0x6c,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x33,0x33,0x20,
|
||||
0x3d,0x20,0x5f,0x31,0x33,0x32,0x20,0x2b,0x20,0x28,0x6d,0x69,0x78,0x28,0x5f,0x31,
|
||||
0x38,0x2e,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x2c,0x20,0x76,
|
||||
0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x63,
|
||||
0x6c,0x61,0x6d,0x70,0x28,0x61,0x62,0x73,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,
|
||||
0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,0x2e,0x79,0x29,0x20,0x2a,0x20,
|
||||
0x32,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x29,
|
||||
0x29,0x20,0x2a,0x20,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,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x5f,0x31,0x33,
|
||||
0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x31,
|
||||
0x33,0x33,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,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,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
|
||||
|
||||
uniform vec4 sky_vs_params[4];
|
||||
layout(location = 0) in vec4 position;
|
||||
out vec4 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mat4(sky_vs_params[0], sky_vs_params[1], sky_vs_params[2], sky_vs_params[3]) * vec4(position.xyz * 1000.0, 1.0);
|
||||
pos = position;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_sky_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,0x73,0x6b,
|
||||
0x79,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,0x34,0x20,0x70,0x6f,0x73,
|
||||
0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||
0x70,0x6f,0x73,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,0x73,0x6b,0x79,0x5f,0x76,
|
||||
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x73,0x6b,0x79,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x73,
|
||||
0x6b,0x79,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,
|
||||
0x20,0x73,0x6b,0x79,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,
|
||||
0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x31,0x30,0x30,0x30,0x2e,0x30,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,
|
||||
0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
struct sky_world_config
|
||||
{
|
||||
highp vec3 skyBase;
|
||||
highp vec3 skyTop;
|
||||
highp vec3 sunDisk;
|
||||
highp vec3 horizonHalo;
|
||||
highp vec3 sunHalo;
|
||||
highp vec3 sunLightColor;
|
||||
highp vec3 sunPosition;
|
||||
highp float sunIntensity;
|
||||
highp float skyIntensity;
|
||||
int hasClouds;
|
||||
highp float planeHeight;
|
||||
int animatePlaneHeight;
|
||||
highp vec3 waterColor;
|
||||
highp vec3 deepColor;
|
||||
highp float time;
|
||||
};
|
||||
|
||||
uniform sky_world_config _18;
|
||||
|
||||
in highp vec4 pos;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
highp vec3 sky(highp vec3 skypos, highp vec3 sunpos)
|
||||
{
|
||||
highp vec3 _57 = normalize(sunpos);
|
||||
highp vec3 _63 = normalize(cross(_57, vec3(0.0, 1.0, 0.0)));
|
||||
highp vec3 _75 = normalize(skypos) - (_57 * dot(normalize(skypos), normalize(sunpos)));
|
||||
highp float _89 = max(abs(dot(_75, _63)), abs(dot(_75, normalize(cross(_63, _57)))));
|
||||
highp float _98 = clamp((0.25 - _89) * 6.0, 0.0, 1.0);
|
||||
highp vec3 final = mix(_18.skyBase, _18.skyTop, vec3(clamp(skypos.y * 2.0, 0.0, 0.699999988079071044921875))) + ((_18.sunHalo * _98) * _98);
|
||||
if (_89 < 0.0320000015199184417724609375)
|
||||
{
|
||||
final = _18.sunDisk * 3.0;
|
||||
}
|
||||
highp vec3 _132 = final;
|
||||
highp vec3 _133 = _132 + (mix(_18.horizonHalo, vec3(0.0), vec3(clamp(abs(normalize(skypos).y) * 20.0, 0.0, 1.0))) * 0.800000011920928955078125);
|
||||
final = _133;
|
||||
return _133;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec3 param = normalize(pos.xyz);
|
||||
highp vec3 param_1 = _18.sunPosition;
|
||||
frag_color = vec4(sky(param, param_1) * _18.skyIntensity, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_sky_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,0x73,
|
||||
0x74,0x72,0x75,0x63,0x74,0x20,0x73,0x6b,0x79,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,
|
||||
0x63,0x6f,0x6e,0x66,0x69,0x67,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,
|
||||
0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,
|
||||
0x73,0x6b,0x79,0x54,0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x68,
|
||||
0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x48,0x61,
|
||||
0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,
|
||||
0x63,0x33,0x20,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,
|
||||
0x20,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x75,
|
||||
0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x6b,0x79,0x49,
|
||||
0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,
|
||||
0x74,0x20,0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64,0x73,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x6c,0x61,
|
||||
0x6e,0x65,0x48,0x65,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,
|
||||
0x74,0x20,0x61,0x6e,0x69,0x6d,0x61,0x74,0x65,0x50,0x6c,0x61,0x6e,0x65,0x48,0x65,
|
||||
0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x76,0x65,0x63,0x33,0x20,0x77,0x61,0x74,0x65,0x72,0x43,0x6f,0x6c,0x6f,0x72,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,
|
||||
0x64,0x65,0x65,0x70,0x43,0x6f,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,0x73,0x6b,0x79,
|
||||
0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x20,0x5f,0x31,
|
||||
0x38,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||
0x34,0x20,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,
|
||||
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x68,0x69,0x67,0x68,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,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,0x76,0x65,0x63,0x33,0x20,0x5f,0x35,
|
||||
0x37,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,0x36,0x33,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,
|
||||
0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x5f,0x35,0x37,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,0x37,0x35,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,0x35,0x37,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,0x20,0x6e,
|
||||
0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x75,0x6e,0x70,0x6f,0x73,0x29,
|
||||
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x20,0x5f,0x38,0x39,0x20,0x3d,0x20,0x6d,0x61,0x78,0x28,0x61,0x62,
|
||||
0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,0x37,0x35,0x2c,0x20,0x5f,0x36,0x33,0x29,0x29,
|
||||
0x2c,0x20,0x61,0x62,0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,0x37,0x35,0x2c,0x20,0x6e,
|
||||
0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x5f,
|
||||
0x36,0x33,0x2c,0x20,0x5f,0x35,0x37,0x29,0x29,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x39,
|
||||
0x38,0x20,0x3d,0x20,0x63,0x6c,0x61,0x6d,0x70,0x28,0x28,0x30,0x2e,0x32,0x35,0x20,
|
||||
0x2d,0x20,0x5f,0x38,0x39,0x29,0x20,0x2a,0x20,0x36,0x2e,0x30,0x2c,0x20,0x30,0x2e,
|
||||
0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,
|
||||
0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,
|
||||
0x6d,0x69,0x78,0x28,0x5f,0x31,0x38,0x2e,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x2c,
|
||||
0x20,0x5f,0x31,0x38,0x2e,0x73,0x6b,0x79,0x54,0x6f,0x70,0x2c,0x20,0x76,0x65,0x63,
|
||||
0x33,0x28,0x63,0x6c,0x61,0x6d,0x70,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2e,0x79,
|
||||
0x20,0x2a,0x20,0x32,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x36,
|
||||
0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,
|
||||
0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x5f,
|
||||
0x31,0x38,0x2e,0x73,0x75,0x6e,0x48,0x61,0x6c,0x6f,0x20,0x2a,0x20,0x5f,0x39,0x38,
|
||||
0x29,0x20,0x2a,0x20,0x5f,0x39,0x38,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,
|
||||
0x20,0x28,0x5f,0x38,0x39,0x20,0x3c,0x20,0x30,0x2e,0x30,0x33,0x32,0x30,0x30,0x30,
|
||||
0x30,0x30,0x31,0x35,0x31,0x39,0x39,0x31,0x38,0x34,0x34,0x31,0x37,0x37,0x32,0x34,
|
||||
0x36,0x30,0x39,0x33,0x37,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x5f,0x31,
|
||||
0x38,0x2e,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x20,0x2a,0x20,0x33,0x2e,0x30,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x33,0x32,0x20,0x3d,0x20,0x66,0x69,0x6e,
|
||||
0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,
|
||||
0x63,0x33,0x20,0x5f,0x31,0x33,0x33,0x20,0x3d,0x20,0x5f,0x31,0x33,0x32,0x20,0x2b,
|
||||
0x20,0x28,0x6d,0x69,0x78,0x28,0x5f,0x31,0x38,0x2e,0x68,0x6f,0x72,0x69,0x7a,0x6f,
|
||||
0x6e,0x48,0x61,0x6c,0x6f,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x29,
|
||||
0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x63,0x6c,0x61,0x6d,0x70,0x28,0x61,0x62,0x73,
|
||||
0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x73,0x6b,0x79,0x70,0x6f,
|
||||
0x73,0x29,0x2e,0x79,0x29,0x20,0x2a,0x20,0x32,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,
|
||||
0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x29,0x29,0x20,0x2a,0x20,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,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x69,0x6e,
|
||||
0x61,0x6c,0x20,0x3d,0x20,0x5f,0x31,0x33,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,
|
||||
0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x31,0x33,0x33,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,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,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,
|
||||
0x20,0x5f,0x31,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,
|
||||
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 <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct sky_vs_params
|
||||
{
|
||||
float4x4 mvp;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 pos [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 position [[attribute(0)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant sky_vs_params& _19 [[buffer(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = _19.mvp * float4(in.position.xyz * 1000.0, 1.0);
|
||||
out.pos = in.position;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_sky_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,0x73,
|
||||
0x6b,0x79,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,0x70,0x6f,0x73,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,0x34,0x20,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,
|
||||
0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,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,0x73,0x6b,0x79,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,0x70,0x6f,0x73,
|
||||
0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x31,0x30,0x30,0x30,
|
||||
0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,
|
||||
0x74,0x2e,0x70,0x6f,0x73,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,
|
||||
0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct sky_world_config
|
||||
{
|
||||
float3 skyBase;
|
||||
float3 skyTop;
|
||||
float3 sunDisk;
|
||||
float3 horizonHalo;
|
||||
float3 sunHalo;
|
||||
float3 sunLightColor;
|
||||
packed_float3 sunPosition;
|
||||
float sunIntensity;
|
||||
float skyIntensity;
|
||||
int hasClouds;
|
||||
float planeHeight;
|
||||
int animatePlaneHeight;
|
||||
float3 waterColor;
|
||||
packed_float3 deepColor;
|
||||
float time;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 pos [[user(locn0)]];
|
||||
};
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
float3 sky(thread const float3& skypos, thread const float3& sunpos, constant sky_world_config& _18)
|
||||
{
|
||||
float3 _57 = fast::normalize(sunpos);
|
||||
float3 _63 = fast::normalize(cross(_57, float3(0.0, 1.0, 0.0)));
|
||||
float3 _75 = fast::normalize(skypos) - (_57 * dot(fast::normalize(skypos), fast::normalize(sunpos)));
|
||||
float _89 = fast::max(abs(dot(_75, _63)), abs(dot(_75, fast::normalize(cross(_63, _57)))));
|
||||
float _98 = fast::clamp((0.25 - _89) * 6.0, 0.0, 1.0);
|
||||
float3 final = mix(_18.skyBase, _18.skyTop, float3(fast::clamp(skypos.y * 2.0, 0.0, 0.699999988079071044921875))) + ((_18.sunHalo * _98) * _98);
|
||||
if (_89 < 0.0320000015199184417724609375)
|
||||
{
|
||||
final = _18.sunDisk * 3.0;
|
||||
}
|
||||
float3 _132 = final;
|
||||
float3 _133 = _132 + (mix(_18.horizonHalo, float3(0.0), float3(fast::clamp(abs(fast::normalize(skypos).y) * 20.0, 0.0, 1.0))) * 0.800000011920928955078125);
|
||||
final = _133;
|
||||
return _133;
|
||||
}
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], constant sky_world_config& _18 [[buffer(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float3 param = fast::normalize(in.pos.xyz);
|
||||
float3 param_1 = float3(_18.sunPosition);
|
||||
out.frag_color = float4(sky(param, param_1, _18) * _18.skyIntensity, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_sky_source_metal_macos := u8.[
|
||||
0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x63,0x6c,0x61,0x6e,0x67,0x20,0x64,0x69,
|
||||
0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x20,0x69,0x67,0x6e,0x6f,0x72,0x65,0x64,
|
||||
0x20,0x22,0x2d,0x57,0x6d,0x69,0x73,0x73,0x69,0x6e,0x67,0x2d,0x70,0x72,0x6f,0x74,
|
||||
0x6f,0x74,0x79,0x70,0x65,0x73,0x22,0x0a,0x0a,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,0x73,0x6b,0x79,0x5f,0x77,0x6f,0x72,0x6c,
|
||||
0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x6b,0x79,0x54,0x6f,0x70,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x75,0x6e,
|
||||
0x44,0x69,0x73,0x6b,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
|
||||
0x20,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x75,0x6e,0x48,0x61,0x6c,0x6f,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x75,0x6e,
|
||||
0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x70,0x61,0x63,0x6b,0x65,0x64,0x5f,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x75,
|
||||
0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,
|
||||
0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x6b,0x79,
|
||||
0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,
|
||||
0x6e,0x74,0x20,0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64,0x73,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x48,0x65,0x69,
|
||||
0x67,0x68,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x61,0x6e,0x69,
|
||||
0x6d,0x61,0x74,0x65,0x50,0x6c,0x61,0x6e,0x65,0x48,0x65,0x69,0x67,0x68,0x74,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x77,0x61,0x74,0x65,
|
||||
0x72,0x43,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x70,0x61,0x63,0x6b,
|
||||
0x65,0x64,0x5f,0x66,0x6c,0x6f,0x61,0x74,0x33,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,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,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
|
||||
0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,
|
||||
0x20,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,
|
||||
0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x61,0x6c,0x77,0x61,0x79,0x73,0x5f,0x69,0x6e,
|
||||
0x6c,0x69,0x6e,0x65,0x29,0x29,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x6b,
|
||||
0x79,0x28,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x26,0x20,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2c,0x20,0x74,
|
||||
0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,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,0x6f,0x72,0x6c,0x64,0x5f,0x63,
|
||||
0x6f,0x6e,0x66,0x69,0x67,0x26,0x20,0x5f,0x31,0x38,0x29,0x0a,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x35,0x37,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,0x36,0x33,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,
|
||||
0x35,0x37,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,0x37,0x35,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,0x35,0x37,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,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,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x5f,0x38,0x39,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,
|
||||
0x28,0x61,0x62,0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,0x37,0x35,0x2c,0x20,0x5f,0x36,
|
||||
0x33,0x29,0x29,0x2c,0x20,0x61,0x62,0x73,0x28,0x64,0x6f,0x74,0x28,0x5f,0x37,0x35,
|
||||
0x2c,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,
|
||||
0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x5f,0x36,0x33,0x2c,0x20,0x5f,0x35,0x37,
|
||||
0x29,0x29,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x5f,0x39,0x38,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x63,0x6c,0x61,
|
||||
0x6d,0x70,0x28,0x28,0x30,0x2e,0x32,0x35,0x20,0x2d,0x20,0x5f,0x38,0x39,0x29,0x20,
|
||||
0x2a,0x20,0x36,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x66,0x69,0x6e,
|
||||
0x61,0x6c,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f,0x31,0x38,0x2e,0x73,0x6b,0x79,
|
||||
0x42,0x61,0x73,0x65,0x2c,0x20,0x5f,0x31,0x38,0x2e,0x73,0x6b,0x79,0x54,0x6f,0x70,
|
||||
0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x63,
|
||||
0x6c,0x61,0x6d,0x70,0x28,0x73,0x6b,0x79,0x70,0x6f,0x73,0x2e,0x79,0x20,0x2a,0x20,
|
||||
0x32,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,0x39,
|
||||
0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,
|
||||
0x31,0x38,0x37,0x35,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x5f,0x31,0x38,0x2e,
|
||||
0x73,0x75,0x6e,0x48,0x61,0x6c,0x6f,0x20,0x2a,0x20,0x5f,0x39,0x38,0x29,0x20,0x2a,
|
||||
0x20,0x5f,0x39,0x38,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,
|
||||
0x38,0x39,0x20,0x3c,0x20,0x30,0x2e,0x30,0x33,0x32,0x30,0x30,0x30,0x30,0x30,0x31,
|
||||
0x35,0x31,0x39,0x39,0x31,0x38,0x34,0x34,0x31,0x37,0x37,0x32,0x34,0x36,0x30,0x39,
|
||||
0x33,0x37,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x5f,0x31,0x38,0x2e,0x73,
|
||||
0x75,0x6e,0x44,0x69,0x73,0x6b,0x20,0x2a,0x20,0x33,0x2e,0x30,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,
|
||||
0x31,0x33,0x32,0x20,0x3d,0x20,0x66,0x69,0x6e,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x31,0x33,0x33,0x20,0x3d,0x20,0x5f,
|
||||
0x31,0x33,0x32,0x20,0x2b,0x20,0x28,0x6d,0x69,0x78,0x28,0x5f,0x31,0x38,0x2e,0x68,
|
||||
0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x2c,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x33,0x28,0x30,0x2e,0x30,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,
|
||||
0x66,0x61,0x73,0x74,0x3a,0x3a,0x63,0x6c,0x61,0x6d,0x70,0x28,0x61,0x62,0x73,0x28,
|
||||
0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,
|
||||
0x73,0x6b,0x79,0x70,0x6f,0x73,0x29,0x2e,0x79,0x29,0x20,0x2a,0x20,0x32,0x30,0x2e,
|
||||
0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x29,0x29,0x20,0x2a,
|
||||
0x20,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,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x69,0x6e,0x61,0x6c,0x20,0x3d,0x20,0x5f,0x31,0x33,0x33,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x31,0x33,0x33,0x3b,
|
||||
0x0a,0x7d,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,
|
||||
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,
|
||||
0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,
|
||||
0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,
|
||||
0x73,0x6b,0x79,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,
|
||||
0x26,0x20,0x5f,0x31,0x38,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,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,
|
||||
0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,
|
||||
0x65,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,
|
||||
0x31,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x38,0x2e,0x73,
|
||||
0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x73,0x6b,0x79,0x28,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x2c,0x20,0x5f,0x31,0x38,
|
||||
0x29,0x20,0x2a,0x20,0x5f,0x31,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 {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "sky_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_sky_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_sky_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
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 = "sky_vs_params";
|
||||
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[1].layout = .STD140;
|
||||
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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.animatePlaneHeight";
|
||||
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 = "_18.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 = "_18.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 = "_18.time";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_sky_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_sky_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
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 = "sky_vs_params";
|
||||
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[1].layout = .STD140;
|
||||
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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.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 = "_18.animatePlaneHeight";
|
||||
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 = "_18.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 = "_18.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 = "_18.time";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_sky_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_sky_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].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;
|
||||
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[1].layout = .STD140;
|
||||
desc.uniform_blocks[1].size = 160;
|
||||
desc.uniform_blocks[1].msl_buffer_n = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -1,798 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_ssao.glsl -o ./jai/shader_ssao.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'ssao':
|
||||
Get shader desc: ssao_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_ssao
|
||||
Fragment Shader: fs_ssao
|
||||
Attributes:
|
||||
ATTR_ssao_position => 0
|
||||
ATTR_ssao_uv => 1
|
||||
Bindings:
|
||||
Uniform block 'ssao_fs_params':
|
||||
Jai struct: Ssao_Fs_Params
|
||||
Bind slot: UB_ssao_fs_params => 1
|
||||
Image 'g_position':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_g_position => 0
|
||||
Image 'g_normal':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_g_normal => 1
|
||||
Image 'tex_noise':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_tex_noise => 2
|
||||
Sampler 'ssao_smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_ssao_smp => 0
|
||||
*/
|
||||
ATTR_ssao_position :: 0;
|
||||
ATTR_ssao_uv :: 1;
|
||||
UB_ssao_fs_params :: 1;
|
||||
IMG_g_position :: 0;
|
||||
IMG_g_normal :: 1;
|
||||
IMG_tex_noise :: 2;
|
||||
SMP_ssao_smp :: 0;
|
||||
Ssao_Fs_Params :: struct {
|
||||
projection: [16]float;
|
||||
samples: [64][4]float;
|
||||
ssao_power: float;
|
||||
_: [12]u8;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
layout(location = 0) out vec2 quad_uv;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
quad_uv = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_ssao_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x32,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
|
||||
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,
|
||||
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,
|
||||
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,
|
||||
0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,
|
||||
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x71,0x75,0x61,0x64,
|
||||
0x5f,0x75,0x76,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
vec4 _222;
|
||||
|
||||
uniform vec4 ssao_fs_params[69];
|
||||
layout(binding = 16) uniform sampler2D g_position_ssao_smp;
|
||||
layout(binding = 17) uniform sampler2D g_normal_ssao_smp;
|
||||
layout(binding = 18) uniform sampler2D tex_noise_ssao_smp;
|
||||
|
||||
layout(location = 0) in vec2 quad_uv;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 _26 = texture(g_position_ssao_smp, quad_uv).xyz;
|
||||
vec3 _35 = normalize(texture(g_normal_ssao_smp, quad_uv).xyz);
|
||||
vec3 _51 = normalize(texture(tex_noise_ssao_smp, quad_uv * vec2(480.0, 270.0)).xyz);
|
||||
vec3 _60 = normalize(_51 - (_35 * dot(_51, _35)));
|
||||
mat3 _85 = mat3(_60, cross(_35, _60), _35);
|
||||
float occlusion = 0.0;
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
vec3 _121 = _26 + ((_85 * ssao_fs_params[i * 1 + 4].xyz) * 0.5);
|
||||
vec4 _133 = mat4(ssao_fs_params[0], ssao_fs_params[1], ssao_fs_params[2], ssao_fs_params[3]) * vec4(_121, 1.0);
|
||||
vec3 _140 = _133.xyz / vec3(_133.w);
|
||||
vec4 _206;
|
||||
_206.x = _140.x;
|
||||
_206.y = _140.y;
|
||||
vec3 _154 = (_206.xyz * 0.5) + vec3(0.5);
|
||||
vec4 _212;
|
||||
_212.x = _154.x;
|
||||
_212.y = _154.y;
|
||||
float occluded = 0.0;
|
||||
if ((_121.z + 0.00999999977648258209228515625) <= texture(g_position_ssao_smp, _212.xy).z)
|
||||
{
|
||||
occluded = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
occluded = 0.0;
|
||||
}
|
||||
occlusion += occluded;
|
||||
}
|
||||
float _187 = occlusion;
|
||||
float _190 = 1.0 - (_187 * 0.015625);
|
||||
occlusion = _190;
|
||||
float _198 = pow(_190, ssao_fs_params[68].x);
|
||||
out_color = vec4(_198, _198, _198, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_ssao_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x76,0x65,
|
||||
0x63,0x34,0x20,0x5f,0x32,0x32,0x32,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,
|
||||
0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x73,0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x39,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x36,0x29,0x20,
|
||||
0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,
|
||||
0x44,0x20,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x73,0x73,0x61,
|
||||
0x6f,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,
|
||||
0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x37,0x29,0x20,0x75,0x6e,0x69,0x66,
|
||||
0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x67,0x5f,
|
||||
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x3b,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,
|
||||
0x3d,0x20,0x31,0x38,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,
|
||||
0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x5f,0x6e,0x6f,0x69,0x73,
|
||||
0x65,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,
|
||||
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,
|
||||
0x76,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,0x6f,0x75,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,
|
||||
0x65,0x63,0x33,0x20,0x5f,0x32,0x36,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,
|
||||
0x65,0x28,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x73,0x73,0x61,
|
||||
0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,
|
||||
0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x33,
|
||||
0x35,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x74,0x65,
|
||||
0x78,0x74,0x75,0x72,0x65,0x28,0x67,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x5f,0x73,
|
||||
0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,
|
||||
0x29,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,
|
||||
0x20,0x5f,0x35,0x31,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
|
||||
0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x5f,0x6e,0x6f,0x69,
|
||||
0x73,0x65,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,0x61,
|
||||
0x64,0x5f,0x75,0x76,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28,0x34,0x38,0x30,0x2e,
|
||||
0x30,0x2c,0x20,0x32,0x37,0x30,0x2e,0x30,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x36,0x30,0x20,0x3d,0x20,
|
||||
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x31,0x20,0x2d,0x20,
|
||||
0x28,0x5f,0x33,0x35,0x20,0x2a,0x20,0x64,0x6f,0x74,0x28,0x5f,0x35,0x31,0x2c,0x20,
|
||||
0x5f,0x33,0x35,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x74,0x33,
|
||||
0x20,0x5f,0x38,0x35,0x20,0x3d,0x20,0x6d,0x61,0x74,0x33,0x28,0x5f,0x36,0x30,0x2c,
|
||||
0x20,0x63,0x72,0x6f,0x73,0x73,0x28,0x5f,0x33,0x35,0x2c,0x20,0x5f,0x36,0x30,0x29,
|
||||
0x2c,0x20,0x5f,0x33,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x2e,
|
||||
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,
|
||||
0x69,0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,0x20,0x31,0x36,0x3b,0x20,0x69,
|
||||
0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x32,0x31,0x20,0x3d,0x20,0x5f,0x32,
|
||||
0x36,0x20,0x2b,0x20,0x28,0x28,0x5f,0x38,0x35,0x20,0x2a,0x20,0x73,0x73,0x61,0x6f,
|
||||
0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x69,0x20,0x2a,0x20,0x31,
|
||||
0x20,0x2b,0x20,0x34,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||
0x5f,0x31,0x33,0x33,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x73,0x73,0x61,0x6f,
|
||||
0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x73,
|
||||
0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,
|
||||
0x2c,0x20,0x73,0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x32,0x5d,0x2c,0x20,0x73,0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,
|
||||
0x31,0x32,0x31,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x34,0x30,0x20,0x3d,0x20,0x5f,
|
||||
0x31,0x33,0x33,0x2e,0x78,0x79,0x7a,0x20,0x2f,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,
|
||||
0x31,0x33,0x33,0x2e,0x77,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x5f,0x32,0x30,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x5f,0x32,0x30,0x36,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x34,0x30,
|
||||
0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x30,0x36,
|
||||
0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,0x34,0x30,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x35,0x34,0x20,0x3d,
|
||||
0x20,0x28,0x5f,0x32,0x30,0x36,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,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,0x76,0x65,0x63,0x34,0x20,0x5f,0x32,0x31,0x32,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x31,0x32,0x2e,0x78,
|
||||
0x20,0x3d,0x20,0x5f,0x31,0x35,0x34,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x5f,0x32,0x31,0x32,0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,0x35,0x34,
|
||||
0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x6f,0x63,0x63,0x6c,0x75,0x64,0x65,0x64,0x20,0x3d,0x20,0x30,0x2e,0x30,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x28,0x5f,
|
||||
0x31,0x32,0x31,0x2e,0x7a,0x20,0x2b,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,
|
||||
0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,
|
||||
0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x20,0x3c,0x3d,0x20,0x74,0x65,0x78,0x74,
|
||||
0x75,0x72,0x65,0x28,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x73,
|
||||
0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x32,0x31,0x32,0x2e,0x78,0x79,
|
||||
0x29,0x2e,0x7a,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,
|
||||
0x64,0x65,0x64,0x20,0x3d,0x20,0x31,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,
|
||||
0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x64,0x65,0x64,
|
||||
0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,
|
||||
0x69,0x6f,0x6e,0x20,0x2b,0x3d,0x20,0x6f,0x63,0x63,0x6c,0x75,0x64,0x65,0x64,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x5f,0x31,0x38,0x37,0x20,0x3d,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,
|
||||
0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x39,
|
||||
0x30,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,0x31,0x38,0x37,0x20,
|
||||
0x2a,0x20,0x30,0x2e,0x30,0x31,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,0x39,
|
||||
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x39,
|
||||
0x38,0x20,0x3d,0x20,0x70,0x6f,0x77,0x28,0x5f,0x31,0x39,0x30,0x2c,0x20,0x73,0x73,
|
||||
0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x38,0x5d,
|
||||
0x2e,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x63,0x6f,0x6c,
|
||||
0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x31,0x39,0x38,0x2c,0x20,
|
||||
0x5f,0x31,0x39,0x38,0x2c,0x20,0x5f,0x31,0x39,0x38,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
out vec2 quad_uv;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
quad_uv = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_ssao_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
|
||||
0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,
|
||||
0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,
|
||||
0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,
|
||||
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,
|
||||
0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,
|
||||
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,
|
||||
0x76,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
vec4 _222;
|
||||
|
||||
uniform highp vec4 ssao_fs_params[69];
|
||||
uniform highp sampler2D g_position_ssao_smp;
|
||||
uniform highp sampler2D g_normal_ssao_smp;
|
||||
uniform highp sampler2D tex_noise_ssao_smp;
|
||||
|
||||
in highp vec2 quad_uv;
|
||||
layout(location = 0) out highp vec4 out_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec3 _26 = texture(g_position_ssao_smp, quad_uv).xyz;
|
||||
highp vec3 _35 = normalize(texture(g_normal_ssao_smp, quad_uv).xyz);
|
||||
highp vec3 _51 = normalize(texture(tex_noise_ssao_smp, quad_uv * vec2(480.0, 270.0)).xyz);
|
||||
highp vec3 _60 = normalize(_51 - (_35 * dot(_51, _35)));
|
||||
highp mat3 _85 = mat3(_60, cross(_35, _60), _35);
|
||||
highp float occlusion = 0.0;
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
highp vec3 _121 = _26 + ((_85 * ssao_fs_params[i * 1 + 4].xyz) * 0.5);
|
||||
highp vec4 _133 = mat4(ssao_fs_params[0], ssao_fs_params[1], ssao_fs_params[2], ssao_fs_params[3]) * vec4(_121, 1.0);
|
||||
highp vec3 _140 = _133.xyz / vec3(_133.w);
|
||||
highp vec4 _206;
|
||||
_206.x = _140.x;
|
||||
_206.y = _140.y;
|
||||
highp vec3 _154 = (_206.xyz * 0.5) + vec3(0.5);
|
||||
highp vec4 _212;
|
||||
_212.x = _154.x;
|
||||
_212.y = _154.y;
|
||||
highp float occluded = 0.0;
|
||||
if ((_121.z + 0.00999999977648258209228515625) <= texture(g_position_ssao_smp, _212.xy).z)
|
||||
{
|
||||
occluded = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
occluded = 0.0;
|
||||
}
|
||||
occlusion += occluded;
|
||||
}
|
||||
highp float _187 = occlusion;
|
||||
highp float _190 = 1.0 - (_187 * 0.015625);
|
||||
occlusion = _190;
|
||||
highp float _198 = pow(_190, ssao_fs_params[68].x);
|
||||
out_color = vec4(_198, _198, _198, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_ssao_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,0x76,
|
||||
0x65,0x63,0x34,0x20,0x5f,0x32,0x32,0x32,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,
|
||||
0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x73,0x73,
|
||||
0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x39,0x5d,
|
||||
0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x67,0x5f,0x70,0x6f,0x73,0x69,
|
||||
0x74,0x69,0x6f,0x6e,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x67,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x5f,
|
||||
0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,
|
||||
0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,
|
||||
0x44,0x20,0x74,0x65,0x78,0x5f,0x6e,0x6f,0x69,0x73,0x65,0x5f,0x73,0x73,0x61,0x6f,
|
||||
0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x76,0x65,0x63,0x32,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x3b,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||
0x34,0x20,0x6f,0x75,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,
|
||||
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x36,0x20,0x3d,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,
|
||||
0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x33,0x35,0x20,0x3d,
|
||||
0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x74,0x65,0x78,0x74,0x75,
|
||||
0x72,0x65,0x28,0x67,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x5f,0x73,0x73,0x61,0x6f,
|
||||
0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,0x78,
|
||||
0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,
|
||||
0x65,0x63,0x33,0x20,0x5f,0x35,0x31,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x69,0x7a,0x65,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x5f,
|
||||
0x6e,0x6f,0x69,0x73,0x65,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,
|
||||
0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28,0x34,
|
||||
0x38,0x30,0x2e,0x30,0x2c,0x20,0x32,0x37,0x30,0x2e,0x30,0x29,0x29,0x2e,0x78,0x79,
|
||||
0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,
|
||||
0x63,0x33,0x20,0x5f,0x36,0x30,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,
|
||||
0x7a,0x65,0x28,0x5f,0x35,0x31,0x20,0x2d,0x20,0x28,0x5f,0x33,0x35,0x20,0x2a,0x20,
|
||||
0x64,0x6f,0x74,0x28,0x5f,0x35,0x31,0x2c,0x20,0x5f,0x33,0x35,0x29,0x29,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x6d,0x61,0x74,0x33,0x20,
|
||||
0x5f,0x38,0x35,0x20,0x3d,0x20,0x6d,0x61,0x74,0x33,0x28,0x5f,0x36,0x30,0x2c,0x20,
|
||||
0x63,0x72,0x6f,0x73,0x73,0x28,0x5f,0x33,0x35,0x2c,0x20,0x5f,0x36,0x30,0x29,0x2c,
|
||||
0x20,0x5f,0x33,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,
|
||||
0x28,0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,0x20,
|
||||
0x31,0x36,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||
0x33,0x20,0x5f,0x31,0x32,0x31,0x20,0x3d,0x20,0x5f,0x32,0x36,0x20,0x2b,0x20,0x28,
|
||||
0x28,0x5f,0x38,0x35,0x20,0x2a,0x20,0x73,0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x69,0x20,0x2a,0x20,0x31,0x20,0x2b,0x20,0x34,0x5d,
|
||||
0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,
|
||||
0x20,0x5f,0x31,0x33,0x33,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x73,0x73,0x61,
|
||||
0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,
|
||||
0x73,0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,
|
||||
0x5d,0x2c,0x20,0x73,0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x73,0x5b,0x32,0x5d,0x2c,0x20,0x73,0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,
|
||||
0x5f,0x31,0x32,0x31,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,
|
||||
0x31,0x34,0x30,0x20,0x3d,0x20,0x5f,0x31,0x33,0x33,0x2e,0x78,0x79,0x7a,0x20,0x2f,
|
||||
0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x31,0x33,0x33,0x2e,0x77,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||
0x34,0x20,0x5f,0x32,0x30,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x5f,0x32,0x30,0x36,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x34,0x30,0x2e,0x78,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x30,0x36,0x2e,0x79,0x20,
|
||||
0x3d,0x20,0x5f,0x31,0x34,0x30,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x35,
|
||||
0x34,0x20,0x3d,0x20,0x28,0x5f,0x32,0x30,0x36,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,
|
||||
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,
|
||||
0x76,0x65,0x63,0x34,0x20,0x5f,0x32,0x31,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x5f,0x32,0x31,0x32,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x35,0x34,
|
||||
0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x31,0x32,
|
||||
0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,0x35,0x34,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x6f,0x63,0x63,0x6c,0x75,0x64,0x65,0x64,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x28,0x5f,0x31,
|
||||
0x32,0x31,0x2e,0x7a,0x20,0x2b,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,
|
||||
0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,
|
||||
0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x20,0x3c,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,
|
||||
0x72,0x65,0x28,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x73,0x73,
|
||||
0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x32,0x31,0x32,0x2e,0x78,0x79,0x29,
|
||||
0x2e,0x7a,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x64,
|
||||
0x65,0x64,0x20,0x3d,0x20,0x31,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x64,0x65,0x64,0x20,
|
||||
0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x2b,0x3d,0x20,0x6f,0x63,0x63,0x6c,0x75,0x64,0x65,0x64,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x38,0x37,0x20,0x3d,0x20,0x6f,0x63,0x63,
|
||||
0x6c,0x75,0x73,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x39,0x30,0x20,0x3d,0x20,0x31,
|
||||
0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,0x31,0x38,0x37,0x20,0x2a,0x20,0x30,0x2e,0x30,
|
||||
0x31,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,
|
||||
0x75,0x73,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,0x39,0x30,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,
|
||||
0x39,0x38,0x20,0x3d,0x20,0x70,0x6f,0x77,0x28,0x5f,0x31,0x39,0x30,0x2c,0x20,0x73,
|
||||
0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x38,
|
||||
0x5d,0x2e,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x63,0x6f,
|
||||
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x31,0x39,0x38,0x2c,
|
||||
0x20,0x5f,0x31,0x39,0x38,0x2c,0x20,0x5f,0x31,0x39,0x38,0x2c,0x20,0x31,0x2e,0x30,
|
||||
0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float2 quad_uv [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 position [[attribute(0)]];
|
||||
float2 uv [[attribute(1)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = float4(in.position, 0.0, 1.0);
|
||||
out.quad_uv = in.uv;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_ssao_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x32,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x20,0x5b,0x5b,
|
||||
0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
|
||||
0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
||||
0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,
|
||||
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,0x5b,
|
||||
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||
0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,
|
||||
0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,
|
||||
0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,
|
||||
0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,
|
||||
0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x70,
|
||||
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,
|
||||
0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x71,0x75,0x61,0x64,
|
||||
0x5f,0x75,0x76,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||
0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct ssao_fs_params
|
||||
{
|
||||
float4x4 projection;
|
||||
float4 samples[64];
|
||||
float ssao_power;
|
||||
};
|
||||
|
||||
constant float4 _229 = {};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 out_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 quad_uv [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], constant ssao_fs_params& _109 [[buffer(0)]], texture2d<float> g_position [[texture(0)]], texture2d<float> g_normal [[texture(1)]], texture2d<float> tex_noise [[texture(2)]], sampler ssao_smp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float3 _26 = g_position.sample(ssao_smp, in.quad_uv).xyz;
|
||||
float3 _35 = fast::normalize(g_normal.sample(ssao_smp, in.quad_uv).xyz);
|
||||
float3 _51 = fast::normalize(tex_noise.sample(ssao_smp, (in.quad_uv * float2(480.0, 270.0))).xyz);
|
||||
float3 _60 = fast::normalize(_51 - (_35 * dot(_51, _35)));
|
||||
float3x3 _85 = float3x3(_60, cross(_35, _60), _35);
|
||||
float occlusion = 0.0;
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
float3 _121 = _26 + ((_85 * _109.samples[i].xyz) * 0.5);
|
||||
float4 _133 = _109.projection * float4(_121, 1.0);
|
||||
float3 _140 = _133.xyz / float3(_133.w);
|
||||
float4 _210;
|
||||
_210.x = _140.x;
|
||||
_210.y = _140.y;
|
||||
float3 _154 = (_210.xyz * 0.5) + float3(0.5);
|
||||
float4 _216;
|
||||
_216.x = _154.x;
|
||||
_216.y = 1.0 - _154.y;
|
||||
float occluded = 0.0;
|
||||
if ((_121.z + 0.00999999977648258209228515625) <= g_position.sample(ssao_smp, _216.xy).z)
|
||||
{
|
||||
occluded = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
occluded = 0.0;
|
||||
}
|
||||
occlusion += occluded;
|
||||
}
|
||||
float _191 = occlusion;
|
||||
float _194 = 1.0 - (_191 * 0.015625);
|
||||
occlusion = _194;
|
||||
float _202 = powr(_194, _109.ssao_power);
|
||||
out.out_color = float4(_202, _202, _202, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_ssao_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,0x73,
|
||||
0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x70,0x72,0x6f,
|
||||
0x6a,0x65,0x63,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x34,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x73,0x5b,0x36,0x34,0x5d,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x73,0x61,0x6f,0x5f,
|
||||
0x70,0x6f,0x77,0x65,0x72,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x63,0x6f,0x6e,0x73,0x74,
|
||||
0x61,0x6e,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x32,0x39,0x20,
|
||||
0x3d,0x20,0x7b,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,0x6f,0x75,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,
|
||||
0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,
|
||||
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,
|
||||
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x71,0x75,
|
||||
0x61,0x64,0x5f,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,
|
||||
0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,
|
||||
0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,
|
||||
0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,
|
||||
0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,
|
||||
0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x73,0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,0x30,0x39,0x20,0x5b,0x5b,0x62,0x75,
|
||||
0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,
|
||||
0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x67,0x5f,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,
|
||||
0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x67,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x31,0x29,0x5d,0x5d,0x2c,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x3e,0x20,0x74,0x65,0x78,0x5f,0x6e,0x6f,0x69,0x73,0x65,0x20,0x5b,0x5b,0x74,0x65,
|
||||
0x78,0x74,0x75,0x72,0x65,0x28,0x32,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x72,0x20,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,
|
||||
0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x33,0x20,0x5f,0x32,0x36,0x20,0x3d,0x20,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x73,0x73,0x61,0x6f,0x5f,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,
|
||||
0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,
|
||||
0x5f,0x33,0x35,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,
|
||||
0x61,0x6c,0x69,0x7a,0x65,0x28,0x67,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x28,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,
|
||||
0x69,0x6e,0x2e,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,0x78,0x79,0x7a,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x35,0x31,
|
||||
0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,
|
||||
0x7a,0x65,0x28,0x74,0x65,0x78,0x5f,0x6e,0x6f,0x69,0x73,0x65,0x2e,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x28,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,
|
||||
0x6e,0x2e,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x32,0x28,0x34,0x38,0x30,0x2e,0x30,0x2c,0x20,0x32,0x37,0x30,0x2e,0x30,0x29,
|
||||
0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x33,0x20,0x5f,0x36,0x30,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,
|
||||
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x31,0x20,0x2d,0x20,
|
||||
0x28,0x5f,0x33,0x35,0x20,0x2a,0x20,0x64,0x6f,0x74,0x28,0x5f,0x35,0x31,0x2c,0x20,
|
||||
0x5f,0x33,0x35,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x33,0x78,0x33,0x20,0x5f,0x38,0x35,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x33,0x78,0x33,0x28,0x5f,0x36,0x30,0x2c,0x20,0x63,0x72,0x6f,0x73,0x73,0x28,0x5f,
|
||||
0x33,0x35,0x2c,0x20,0x5f,0x36,0x30,0x29,0x2c,0x20,0x5f,0x33,0x35,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,
|
||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,
|
||||
0x20,0x3c,0x20,0x31,0x36,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
|
||||
0x20,0x5f,0x31,0x32,0x31,0x20,0x3d,0x20,0x5f,0x32,0x36,0x20,0x2b,0x20,0x28,0x28,
|
||||
0x5f,0x38,0x35,0x20,0x2a,0x20,0x5f,0x31,0x30,0x39,0x2e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x73,0x5b,0x69,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x34,0x20,0x5f,0x31,0x33,0x33,0x20,0x3d,0x20,0x5f,0x31,0x30,0x39,0x2e,0x70,0x72,
|
||||
0x6f,0x6a,0x65,0x63,0x74,0x69,0x6f,0x6e,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x34,0x28,0x5f,0x31,0x32,0x31,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x31,0x34,
|
||||
0x30,0x20,0x3d,0x20,0x5f,0x31,0x33,0x33,0x2e,0x78,0x79,0x7a,0x20,0x2f,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x33,0x33,0x2e,0x77,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,
|
||||
0x31,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x31,0x30,
|
||||
0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x34,0x30,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x31,0x30,0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,
|
||||
0x34,0x30,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x33,0x20,0x5f,0x31,0x35,0x34,0x20,0x3d,0x20,0x28,0x5f,0x32,0x31,
|
||||
0x30,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x20,0x2b,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x31,0x36,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x31,0x36,0x2e,0x78,0x20,
|
||||
0x3d,0x20,0x5f,0x31,0x35,0x34,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x5f,0x32,0x31,0x36,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,
|
||||
0x20,0x5f,0x31,0x35,0x34,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x6f,0x63,0x63,0x6c,0x75,0x64,0x65,0x64,0x20,
|
||||
0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,
|
||||
0x66,0x20,0x28,0x28,0x5f,0x31,0x32,0x31,0x2e,0x7a,0x20,0x2b,0x20,0x30,0x2e,0x30,
|
||||
0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,
|
||||
0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x20,0x3c,0x3d,
|
||||
0x20,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x73,0x61,0x6d,0x70,
|
||||
0x6c,0x65,0x28,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x32,0x31,
|
||||
0x36,0x2e,0x78,0x79,0x29,0x2e,0x7a,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,
|
||||
0x63,0x63,0x6c,0x75,0x64,0x65,0x64,0x20,0x3d,0x20,0x31,0x2e,0x30,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,
|
||||
0x75,0x64,0x65,0x64,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,
|
||||
0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x2b,0x3d,0x20,0x6f,0x63,0x63,0x6c,0x75,
|
||||
0x64,0x65,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x39,0x31,0x20,0x3d,0x20,0x6f,0x63,0x63,0x6c,
|
||||
0x75,0x73,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x5f,0x31,0x39,0x34,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,
|
||||
0x31,0x39,0x31,0x20,0x2a,0x20,0x30,0x2e,0x30,0x31,0x35,0x36,0x32,0x35,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x5f,0x31,0x39,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x5f,0x32,0x30,0x32,0x20,0x3d,0x20,0x70,0x6f,0x77,0x72,0x28,0x5f,0x31,0x39,
|
||||
0x34,0x2c,0x20,0x5f,0x31,0x30,0x39,0x2e,0x73,0x73,0x61,0x6f,0x5f,0x70,0x6f,0x77,
|
||||
0x65,0x72,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x6f,0x75,0x74,
|
||||
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
|
||||
0x5f,0x32,0x30,0x32,0x2c,0x20,0x5f,0x32,0x30,0x32,0x2c,0x20,0x5f,0x32,0x30,0x32,
|
||||
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,
|
||||
];
|
||||
ssao_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "ssao_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_ssao_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_ssao_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[1].layout = .STD140;
|
||||
desc.uniform_blocks[1].size = 1104;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 69;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "ssao_fs_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.images[2].stage = .FRAGMENT;
|
||||
desc.images[2].multisampled = false;
|
||||
desc.images[2].image_type = ._2D;
|
||||
desc.images[2].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "g_position_ssao_smp";
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 1;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[1].glsl_name = "g_normal_ssao_smp";
|
||||
desc.image_sampler_pairs[2].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[2].image_slot = 2;
|
||||
desc.image_sampler_pairs[2].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[2].glsl_name = "tex_noise_ssao_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_ssao_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_ssao_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "uv";
|
||||
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[1].layout = .STD140;
|
||||
desc.uniform_blocks[1].size = 1104;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 69;
|
||||
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "ssao_fs_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.images[2].stage = .FRAGMENT;
|
||||
desc.images[2].multisampled = false;
|
||||
desc.images[2].image_type = ._2D;
|
||||
desc.images[2].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "g_position_ssao_smp";
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 1;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[1].glsl_name = "g_normal_ssao_smp";
|
||||
desc.image_sampler_pairs[2].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[2].image_slot = 2;
|
||||
desc.image_sampler_pairs[2].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[2].glsl_name = "tex_noise_ssao_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_ssao_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_ssao_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||
desc.uniform_blocks[1].layout = .STD140;
|
||||
desc.uniform_blocks[1].size = 1104;
|
||||
desc.uniform_blocks[1].msl_buffer_n = 0;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.images[1].stage = .FRAGMENT;
|
||||
desc.images[1].multisampled = false;
|
||||
desc.images[1].image_type = ._2D;
|
||||
desc.images[1].sample_type = .FLOAT;
|
||||
desc.images[1].msl_texture_n = 1;
|
||||
desc.images[2].stage = .FRAGMENT;
|
||||
desc.images[2].multisampled = false;
|
||||
desc.images[2].image_type = ._2D;
|
||||
desc.images[2].sample_type = .FLOAT;
|
||||
desc.images[2].msl_texture_n = 2;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[1].image_slot = 1;
|
||||
desc.image_sampler_pairs[1].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[2].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[2].image_slot = 2;
|
||||
desc.image_sampler_pairs[2].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -1,562 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_triangle.glsl -o ./jai/shader_triangle.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'triangle':
|
||||
Get shader desc: triangle_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs
|
||||
Fragment Shader: fs
|
||||
Attributes:
|
||||
ATTR_triangle_position => 0
|
||||
ATTR_triangle_color0 => 1
|
||||
ATTR_triangle_uv => 2
|
||||
Bindings:
|
||||
Image 'tex':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_tex => 0
|
||||
Sampler 'smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_smp => 0
|
||||
*/
|
||||
ATTR_triangle_position :: 0;
|
||||
ATTR_triangle_color0 :: 1;
|
||||
ATTR_triangle_uv :: 2;
|
||||
IMG_tex :: 0;
|
||||
SMP_smp :: 0;
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 0) out vec4 color;
|
||||
layout(location = 1) in vec4 color0;
|
||||
layout(location = 1) out vec4 texcoord;
|
||||
layout(location = 2) in vec4 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = position;
|
||||
gl_Position.y += (float(gl_InstanceID) * 0.100000001490116119384765625);
|
||||
color = color0;
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||
0x63,0x34,0x20,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,0x31,0x29,0x20,0x69,
|
||||
0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x6c,
|
||||
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
|
||||
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,
|
||||
0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,
|
||||
0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x2e,0x79,0x20,0x2b,0x3d,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x67,
|
||||
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x29,0x20,0x2a,0x20,
|
||||
0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,
|
||||
0x36,0x31,0x31,0x39,0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(binding = 16) uniform sampler2D tex_smp;
|
||||
|
||||
layout(location = 1) in vec4 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
layout(location = 0) in vec4 color;
|
||||
|
||||
bool is_near(float a, float b)
|
||||
{
|
||||
return abs(a - b) < 0.00999999977648258209228515625;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
float param = texcoord.x;
|
||||
float param_1 = -4.0;
|
||||
bool _33 = is_near(param, param_1);
|
||||
bool _43;
|
||||
if (_33)
|
||||
{
|
||||
float param_2 = texcoord.y;
|
||||
float param_3 = -2.0;
|
||||
_43 = is_near(param_2, param_3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_43 = _33;
|
||||
}
|
||||
if (_43)
|
||||
{
|
||||
frag_color = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
frag_color = texture(tex_smp, texcoord.xy) * color;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
fs_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,
|
||||
0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,
|
||||
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
|
||||
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,
|
||||
0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,
|
||||
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,0x0a,0x62,0x6f,0x6f,0x6c,0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,
|
||||
0x72,0x28,0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x62,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,
|
||||
0x20,0x61,0x62,0x73,0x28,0x61,0x20,0x2d,0x20,0x62,0x29,0x20,0x3c,0x20,0x30,0x2e,
|
||||
0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,
|
||||
0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,
|
||||
0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,
|
||||
0x3d,0x20,0x2d,0x34,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,0x6f,0x6c,
|
||||
0x20,0x5f,0x33,0x33,0x20,0x3d,0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,0x72,0x28,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x62,0x6f,0x6f,0x6c,0x20,0x5f,0x34,0x33,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x2d,0x32,0x2e,
|
||||
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,0x33,0x20,0x3d,
|
||||
0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,0x72,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,
|
||||
0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,0x33,0x20,0x3d,0x20,0x5f,
|
||||
0x33,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,
|
||||
0x20,0x28,0x5f,0x34,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||
0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x5f,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x29,
|
||||
0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
layout(location = 0) in vec4 position;
|
||||
out vec4 color;
|
||||
layout(location = 1) in vec4 color0;
|
||||
out vec4 texcoord;
|
||||
layout(location = 2) in vec4 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = position;
|
||||
gl_Position.y += (float(gl_InstanceID) * 0.100000001490116119384765625);
|
||||
color = color0;
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,
|
||||
0x20,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,0x31,0x29,0x20,0x69,0x6e,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x6f,0x75,0x74,
|
||||
0x20,0x76,0x65,0x63,0x34,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,
|
||||
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,
|
||||
0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,
|
||||
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,
|
||||
0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2b,0x3d,
|
||||
0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,
|
||||
0x6e,0x63,0x65,0x49,0x44,0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34,
|
||||
0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,
|
||||
0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,
|
||||
0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp sampler2D tex_smp;
|
||||
|
||||
in highp vec4 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
in highp vec4 color;
|
||||
|
||||
bool is_near(highp float a, highp float b)
|
||||
{
|
||||
return abs(a - b) < 0.00999999977648258209228515625;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
highp float param = texcoord.x;
|
||||
highp float param_1 = -4.0;
|
||||
bool _33 = is_near(param, param_1);
|
||||
bool _43;
|
||||
if (_33)
|
||||
{
|
||||
highp float param_2 = texcoord.y;
|
||||
highp float param_3 = -2.0;
|
||||
_43 = is_near(param_2, param_3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_43 = _33;
|
||||
}
|
||||
if (_43)
|
||||
{
|
||||
frag_color = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
frag_color = texture(tex_smp, texcoord.xy) * color;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
fs_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,0x3b,0x0a,
|
||||
0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,
|
||||
0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,
|
||||
0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x62,
|
||||
0x6f,0x6f,0x6c,0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,0x72,0x28,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x2c,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x61,0x62,0x73,0x28,0x61,0x20,0x2d,0x20,0x62,
|
||||
0x29,0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,
|
||||
0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,
|
||||
0x36,0x32,0x35,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,
|
||||
0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x74,0x65,
|
||||
0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,
|
||||
0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,
|
||||
0x31,0x20,0x3d,0x20,0x2d,0x34,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,
|
||||
0x6f,0x6c,0x20,0x5f,0x33,0x33,0x20,0x3d,0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,0x72,
|
||||
0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,0x6f,0x6c,0x20,0x5f,0x34,0x33,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x33,0x29,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x2d,0x32,0x2e,0x30,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,0x33,0x20,0x3d,0x20,0x69,
|
||||
0x73,0x5f,0x6e,0x65,0x61,0x72,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,0x33,0x20,0x3d,0x20,0x5f,0x33,0x33,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,
|
||||
0x5f,0x34,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,
|
||||
0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x29,0x20,0x2a,
|
||||
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,
|
||||
0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 color [[user(locn0)]];
|
||||
float4 texcoord [[user(locn1)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 position [[attribute(0)]];
|
||||
float4 color0 [[attribute(1)]];
|
||||
float4 uv [[attribute(2)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], uint gl_InstanceIndex [[instance_id]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = in.position;
|
||||
out.gl_Position.y += (float(int(gl_InstanceIndex)) * 0.100000001490116119384765625);
|
||||
out.color = in.color0;
|
||||
out.texcoord = in.uv;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_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,0x63,0x6f,0x6c,0x6f,0x72,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,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
|
||||
0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,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,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
||||
0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,
|
||||
0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,
|
||||
0x6c,0x6f,0x72,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,
|
||||
0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x34,0x20,0x75,0x76,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,
|
||||
0x28,0x32,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,0x75,0x69,0x6e,0x74,
|
||||
0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,
|
||||
0x78,0x20,0x5b,0x5b,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x5f,0x69,0x64,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,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2b,0x3d,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,
|
||||
0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
|
||||
0x6e,0x64,0x65,0x78,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34,
|
||||
0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
|
||||
0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,
|
||||
0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 color [[user(locn0)]];
|
||||
float4 texcoord [[user(locn1)]];
|
||||
};
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
bool is_near(thread const float& a, thread const float& b)
|
||||
{
|
||||
return abs(a - b) < 0.00999999977648258209228515625;
|
||||
}
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler smp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float param = in.texcoord.x;
|
||||
float param_1 = -4.0;
|
||||
bool _33 = is_near(param, param_1);
|
||||
bool _43;
|
||||
if (_33)
|
||||
{
|
||||
float param_2 = in.texcoord.y;
|
||||
float param_3 = -2.0;
|
||||
_43 = is_near(param_2, param_3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_43 = _33;
|
||||
}
|
||||
if (_43)
|
||||
{
|
||||
out.frag_color = in.color;
|
||||
}
|
||||
else
|
||||
{
|
||||
out.frag_color = tex.sample(smp, in.texcoord.xy) * in.color;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_source_metal_macos := u8.[
|
||||
0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x63,0x6c,0x61,0x6e,0x67,0x20,0x64,0x69,
|
||||
0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x20,0x69,0x67,0x6e,0x6f,0x72,0x65,0x64,
|
||||
0x20,0x22,0x2d,0x57,0x6d,0x69,0x73,0x73,0x69,0x6e,0x67,0x2d,0x70,0x72,0x6f,0x74,
|
||||
0x6f,0x74,0x79,0x70,0x65,0x73,0x22,0x0a,0x0a,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,0x63,0x6f,0x6c,0x6f,0x72,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,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,
|
||||
0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,
|
||||
0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,
|
||||
0x74,0x65,0x5f,0x5f,0x28,0x28,0x61,0x6c,0x77,0x61,0x79,0x73,0x5f,0x69,0x6e,0x6c,
|
||||
0x69,0x6e,0x65,0x29,0x29,0x0a,0x62,0x6f,0x6f,0x6c,0x20,0x69,0x73,0x5f,0x6e,0x65,
|
||||
0x61,0x72,0x28,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x26,0x20,0x61,0x2c,0x20,0x74,0x68,0x72,0x65,0x61,0x64,
|
||||
0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x26,0x20,0x62,0x29,
|
||||
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x61,0x62,
|
||||
0x73,0x28,0x61,0x20,0x2d,0x20,0x62,0x29,0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,
|
||||
0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,
|
||||
0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x3b,0x0a,0x7d,0x0a,0x0a,0x66,
|
||||
0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
|
||||
0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,
|
||||
0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,
|
||||
0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x3e,0x20,0x74,0x65,0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x73,
|
||||
0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,
|
||||
0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,
|
||||
0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x69,
|
||||
0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,
|
||||
0x3d,0x20,0x2d,0x34,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,0x6f,0x6c,
|
||||
0x20,0x5f,0x33,0x33,0x20,0x3d,0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,0x72,0x28,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x62,0x6f,0x6f,0x6c,0x20,0x5f,0x34,0x33,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,
|
||||
0x2d,0x32,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,
|
||||
0x33,0x20,0x3d,0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,0x72,0x28,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x5f,0x32,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,0x33,0x20,
|
||||
0x3d,0x20,0x5f,0x33,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x69,0x66,0x20,0x28,0x5f,0x34,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,
|
||||
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,
|
||||
0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
|
||||
0x20,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x73,0x6d,0x70,0x2c,
|
||||
0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x29,
|
||||
0x20,0x2a,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,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,
|
||||
];
|
||||
triangle_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "triangle_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "color0";
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[2].glsl_name = "uv";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "tex_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "color0";
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[2].glsl_name = "uv";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "tex_smp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,907 +0,0 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_trile_shadow.glsl -o ./jai/shader_trile_shadow.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'trile_shadow':
|
||||
Get shader desc: trile_shadow_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_trile_shadow
|
||||
Fragment Shader: fs_trile_shadow
|
||||
Attributes:
|
||||
ATTR_trile_shadow_position => 0
|
||||
ATTR_trile_shadow_normal => 1
|
||||
ATTR_trile_shadow_centre => 2
|
||||
ATTR_trile_shadow_instance => 3
|
||||
Bindings:
|
||||
Uniform block 'trile_shadow_vs_params':
|
||||
Jai struct: Trile_Shadow_Vs_Params
|
||||
Bind slot: UB_trile_shadow_vs_params => 0
|
||||
*/
|
||||
ATTR_trile_shadow_position :: 0;
|
||||
ATTR_trile_shadow_normal :: 1;
|
||||
ATTR_trile_shadow_centre :: 2;
|
||||
ATTR_trile_shadow_instance :: 3;
|
||||
UB_trile_shadow_vs_params :: 0;
|
||||
Trile_Shadow_Vs_Params :: struct {
|
||||
mvp: [16]float;
|
||||
};
|
||||
/*
|
||||
#version 430
|
||||
|
||||
uniform vec4 trile_shadow_vs_params[4];
|
||||
layout(location = 3) in vec4 instance;
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 1) in vec4 normal;
|
||||
layout(location = 2) in vec4 centre;
|
||||
|
||||
mat3 rot_x(float a)
|
||||
{
|
||||
float _28 = cos(a);
|
||||
float _31 = sin(a);
|
||||
return mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, _28, -_31), vec3(0.0, _31, _28));
|
||||
}
|
||||
|
||||
mat3 rot_z(float a)
|
||||
{
|
||||
float _47 = cos(a);
|
||||
float _50 = sin(a);
|
||||
return mat3(vec3(_47, -_50, 0.0), vec3(_50, _47, 0.0), vec3(0.0, 0.0, 1.0));
|
||||
}
|
||||
|
||||
mat3 rot_y(float a)
|
||||
{
|
||||
float _64 = cos(a);
|
||||
float _67 = sin(a);
|
||||
return mat3(vec3(_64, 0.0, _67), vec3(0.0, 1.0, 0.0), vec3(-_67, 0.0, _64));
|
||||
}
|
||||
|
||||
mat3 get_orientation_matrix(int ori)
|
||||
{
|
||||
int _82 = ori / 4;
|
||||
mat3 base;
|
||||
if (_82 == 0)
|
||||
{
|
||||
base = mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 1)
|
||||
{
|
||||
float param = 3.1415927410125732421875;
|
||||
base = rot_x(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 2)
|
||||
{
|
||||
float param_1 = -1.57079637050628662109375;
|
||||
base = rot_z(param_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 3)
|
||||
{
|
||||
float param_2 = 1.57079637050628662109375;
|
||||
base = rot_z(param_2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 4)
|
||||
{
|
||||
float param_3 = 1.57079637050628662109375;
|
||||
base = rot_x(param_3);
|
||||
}
|
||||
else
|
||||
{
|
||||
float param_4 = -1.57079637050628662109375;
|
||||
base = rot_x(param_4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float param_5 = float(ori % 4) * 1.57079637050628662109375;
|
||||
return base * rot_y(param_5);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
int param = int(round(instance.w));
|
||||
gl_Position = mat4(trile_shadow_vs_params[0], trile_shadow_vs_params[1], trile_shadow_vs_params[2], trile_shadow_vs_params[3]) * vec4(((get_orientation_matrix(param) * (position.xyz - vec3(0.5))) + vec3(0.5)) + instance.xyz, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
vs_trile_shadow_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,0x74,0x72,0x69,0x6c,0x65,
|
||||
0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,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,0x33,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,
|
||||
0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,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,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,
|
||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,
|
||||
0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,
|
||||
0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x65,0x6e,0x74,0x72,0x65,0x3b,0x0a,0x0a,0x6d,
|
||||
0x61,0x74,0x33,0x20,0x72,0x6f,0x74,0x5f,0x78,0x28,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
||||
0x61,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
||||
0x32,0x38,0x20,0x3d,0x20,0x63,0x6f,0x73,0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x31,0x20,0x3d,0x20,0x73,0x69,0x6e,
|
||||
0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,
|
||||
0x6d,0x61,0x74,0x33,0x28,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,
|
||||
0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,
|
||||
0x2e,0x30,0x2c,0x20,0x5f,0x32,0x38,0x2c,0x20,0x2d,0x5f,0x33,0x31,0x29,0x2c,0x20,
|
||||
0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x33,0x31,0x2c,0x20,0x5f,
|
||||
0x32,0x38,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x6d,0x61,0x74,0x33,0x20,0x72,0x6f,
|
||||
0x74,0x5f,0x7a,0x28,0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x29,0x0a,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x37,0x20,0x3d,0x20,0x63,
|
||||
0x6f,0x73,0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x5f,0x35,0x30,0x20,0x3d,0x20,0x73,0x69,0x6e,0x28,0x61,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6d,0x61,0x74,0x33,0x28,0x76,
|
||||
0x65,0x63,0x33,0x28,0x5f,0x34,0x37,0x2c,0x20,0x2d,0x5f,0x35,0x30,0x2c,0x20,0x30,
|
||||
0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x35,0x30,0x2c,0x20,0x5f,
|
||||
0x34,0x37,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,
|
||||
0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x29,0x3b,0x0a,
|
||||
0x7d,0x0a,0x0a,0x6d,0x61,0x74,0x33,0x20,0x72,0x6f,0x74,0x5f,0x79,0x28,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x20,0x61,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x5f,0x36,0x34,0x20,0x3d,0x20,0x63,0x6f,0x73,0x28,0x61,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,0x37,0x20,0x3d,
|
||||
0x20,0x73,0x69,0x6e,0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,
|
||||
0x75,0x72,0x6e,0x20,0x6d,0x61,0x74,0x33,0x28,0x76,0x65,0x63,0x33,0x28,0x5f,0x36,
|
||||
0x34,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x36,0x37,0x29,0x2c,0x20,0x76,0x65,
|
||||
0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,
|
||||
0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x2d,0x5f,0x36,0x37,0x2c,0x20,0x30,0x2e,
|
||||
0x30,0x2c,0x20,0x5f,0x36,0x34,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x6d,0x61,0x74,
|
||||
0x33,0x20,0x67,0x65,0x74,0x5f,0x6f,0x72,0x69,0x65,0x6e,0x74,0x61,0x74,0x69,0x6f,
|
||||
0x6e,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x28,0x69,0x6e,0x74,0x20,0x6f,0x72,0x69,
|
||||
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x38,0x32,0x20,
|
||||
0x3d,0x20,0x6f,0x72,0x69,0x20,0x2f,0x20,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6d,
|
||||
0x61,0x74,0x33,0x20,0x62,0x61,0x73,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,
|
||||
0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,0x65,0x20,0x3d,
|
||||
0x20,0x6d,0x61,0x74,0x33,0x28,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,
|
||||
0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,
|
||||
0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,
|
||||
0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x31,0x29,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x20,0x3d,0x20,0x33,0x2e,0x31,0x34,0x31,0x35,0x39,0x32,0x37,0x34,0x31,
|
||||
0x30,0x31,0x32,0x35,0x37,0x33,0x32,0x34,0x32,0x31,0x38,0x37,0x35,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,0x65,0x20,
|
||||
0x3d,0x20,0x72,0x6f,0x74,0x5f,0x78,0x28,0x70,0x61,0x72,0x61,0x6d,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,
|
||||
0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x32,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x2d,0x31,0x2e,0x35,0x37,0x30,0x37,
|
||||
0x39,0x36,0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,0x31,0x30,0x39,
|
||||
0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,0x65,0x20,0x3d,0x20,0x72,0x6f,0x74,0x5f,
|
||||
0x7a,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x38,0x32,
|
||||
0x20,0x3d,0x3d,0x20,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x31,0x2e,0x35,
|
||||
0x37,0x30,0x37,0x39,0x36,0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,
|
||||
0x31,0x30,0x39,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,0x65,
|
||||
0x20,0x3d,0x20,0x72,0x6f,0x74,0x5f,0x7a,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x69,0x66,0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x34,0x29,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x31,0x2e,0x35,0x37,
|
||||
0x30,0x37,0x39,0x36,0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,0x31,
|
||||
0x30,0x39,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,
|
||||
0x61,0x73,0x65,0x20,0x3d,0x20,0x72,0x6f,0x74,0x5f,0x78,0x28,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,
|
||||
0x20,0x3d,0x20,0x2d,0x31,0x2e,0x35,0x37,0x30,0x37,0x39,0x36,0x33,0x37,0x30,0x35,
|
||||
0x30,0x36,0x32,0x38,0x36,0x36,0x32,0x31,0x30,0x39,0x33,0x37,0x35,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,0x65,0x20,0x3d,0x20,0x72,0x6f,
|
||||
0x74,0x5f,0x78,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x5f,0x35,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x6f,0x72,
|
||||
0x69,0x20,0x25,0x20,0x34,0x29,0x20,0x2a,0x20,0x31,0x2e,0x35,0x37,0x30,0x37,0x39,
|
||||
0x36,0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,0x31,0x30,0x39,0x33,
|
||||
0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x62,
|
||||
0x61,0x73,0x65,0x20,0x2a,0x20,0x72,0x6f,0x74,0x5f,0x79,0x28,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x5f,0x35,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,
|
||||
0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x72,0x6f,0x75,0x6e,0x64,
|
||||
0x28,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x77,0x29,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x6d,0x61,0x74,0x34,0x28,0x74,0x72,0x69,0x6c,0x65,0x5f,0x73,0x68,0x61,0x64,
|
||||
0x6f,0x77,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,
|
||||
0x20,0x74,0x72,0x69,0x6c,0x65,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x5f,0x76,0x73,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x74,0x72,0x69,0x6c,
|
||||
0x65,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x74,0x72,0x69,0x6c,0x65,0x5f,0x73,0x68,0x61,
|
||||
0x64,0x6f,0x77,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,
|
||||
0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x28,0x67,0x65,0x74,0x5f,0x6f,
|
||||
0x72,0x69,0x65,0x6e,0x74,0x61,0x74,0x69,0x6f,0x6e,0x5f,0x6d,0x61,0x74,0x72,0x69,
|
||||
0x78,0x28,0x70,0x61,0x72,0x61,0x6d,0x29,0x20,0x2a,0x20,0x28,0x70,0x6f,0x73,0x69,
|
||||
0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x76,0x65,0x63,0x33,0x28,
|
||||
0x30,0x2e,0x35,0x29,0x29,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,
|
||||
0x35,0x29,0x29,0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x78,
|
||||
0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(0.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_trile_shadow_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,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,
|
||||
0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x30,0x2e,0x30,
|
||||
0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
uniform vec4 trile_shadow_vs_params[4];
|
||||
layout(location = 3) in vec4 instance;
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 1) in vec4 normal;
|
||||
layout(location = 2) in vec4 centre;
|
||||
|
||||
mat3 rot_x(float a)
|
||||
{
|
||||
float _28 = cos(a);
|
||||
float _31 = sin(a);
|
||||
return mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, _28, -_31), vec3(0.0, _31, _28));
|
||||
}
|
||||
|
||||
mat3 rot_z(float a)
|
||||
{
|
||||
float _47 = cos(a);
|
||||
float _50 = sin(a);
|
||||
return mat3(vec3(_47, -_50, 0.0), vec3(_50, _47, 0.0), vec3(0.0, 0.0, 1.0));
|
||||
}
|
||||
|
||||
mat3 rot_y(float a)
|
||||
{
|
||||
float _64 = cos(a);
|
||||
float _67 = sin(a);
|
||||
return mat3(vec3(_64, 0.0, _67), vec3(0.0, 1.0, 0.0), vec3(-_67, 0.0, _64));
|
||||
}
|
||||
|
||||
mat3 get_orientation_matrix(int ori)
|
||||
{
|
||||
int _82 = ori / 4;
|
||||
mat3 base;
|
||||
if (_82 == 0)
|
||||
{
|
||||
base = mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 1)
|
||||
{
|
||||
float param = 3.1415927410125732421875;
|
||||
base = rot_x(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 2)
|
||||
{
|
||||
float param_1 = -1.57079637050628662109375;
|
||||
base = rot_z(param_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 3)
|
||||
{
|
||||
float param_2 = 1.57079637050628662109375;
|
||||
base = rot_z(param_2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 4)
|
||||
{
|
||||
float param_3 = 1.57079637050628662109375;
|
||||
base = rot_x(param_3);
|
||||
}
|
||||
else
|
||||
{
|
||||
float param_4 = -1.57079637050628662109375;
|
||||
base = rot_x(param_4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float param_5 = float(ori % 4) * 1.57079637050628662109375;
|
||||
return base * rot_y(param_5);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
int param = int(round(instance.w));
|
||||
gl_Position = mat4(trile_shadow_vs_params[0], trile_shadow_vs_params[1], trile_shadow_vs_params[2], trile_shadow_vs_params[3]) * vec4(((get_orientation_matrix(param) * (position.xyz - vec3(0.5))) + vec3(0.5)) + instance.xyz, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
vs_trile_shadow_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,0x74,0x72,
|
||||
0x69,0x6c,0x65,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,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,0x33,0x29,0x20,0x69,0x6e,
|
||||
0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,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,0x70,0x6f,0x73,
|
||||
0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
|
||||
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,
|
||||
0x65,0x63,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
|
||||
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,
|
||||
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x65,0x6e,0x74,0x72,0x65,0x3b,
|
||||
0x0a,0x0a,0x6d,0x61,0x74,0x33,0x20,0x72,0x6f,0x74,0x5f,0x78,0x28,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x61,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x5f,0x32,0x38,0x20,0x3d,0x20,0x63,0x6f,0x73,0x28,0x61,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x31,0x20,0x3d,0x20,
|
||||
0x73,0x69,0x6e,0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,
|
||||
0x72,0x6e,0x20,0x6d,0x61,0x74,0x33,0x28,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,
|
||||
0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,
|
||||
0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x32,0x38,0x2c,0x20,0x2d,0x5f,0x33,0x31,
|
||||
0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x33,0x31,
|
||||
0x2c,0x20,0x5f,0x32,0x38,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x6d,0x61,0x74,0x33,
|
||||
0x20,0x72,0x6f,0x74,0x5f,0x7a,0x28,0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x29,0x0a,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x37,0x20,
|
||||
0x3d,0x20,0x63,0x6f,0x73,0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x20,0x5f,0x35,0x30,0x20,0x3d,0x20,0x73,0x69,0x6e,0x28,0x61,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6d,0x61,0x74,
|
||||
0x33,0x28,0x76,0x65,0x63,0x33,0x28,0x5f,0x34,0x37,0x2c,0x20,0x2d,0x5f,0x35,0x30,
|
||||
0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x35,0x30,
|
||||
0x2c,0x20,0x5f,0x34,0x37,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,
|
||||
0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||
0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x6d,0x61,0x74,0x33,0x20,0x72,0x6f,0x74,0x5f,0x79,
|
||||
0x28,0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,0x34,0x20,0x3d,0x20,0x63,0x6f,0x73,0x28,
|
||||
0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,
|
||||
0x37,0x20,0x3d,0x20,0x73,0x69,0x6e,0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6d,0x61,0x74,0x33,0x28,0x76,0x65,0x63,0x33,
|
||||
0x28,0x5f,0x36,0x34,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x36,0x37,0x29,0x2c,
|
||||
0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,
|
||||
0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x2d,0x5f,0x36,0x37,0x2c,
|
||||
0x20,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x36,0x34,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||
0x6d,0x61,0x74,0x33,0x20,0x67,0x65,0x74,0x5f,0x6f,0x72,0x69,0x65,0x6e,0x74,0x61,
|
||||
0x74,0x69,0x6f,0x6e,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x28,0x69,0x6e,0x74,0x20,
|
||||
0x6f,0x72,0x69,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,
|
||||
0x38,0x32,0x20,0x3d,0x20,0x6f,0x72,0x69,0x20,0x2f,0x20,0x34,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x6d,0x61,0x74,0x33,0x20,0x62,0x61,0x73,0x65,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x69,0x66,0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,
|
||||
0x65,0x20,0x3d,0x20,0x6d,0x61,0x74,0x33,0x28,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,
|
||||
0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x76,0x65,
|
||||
0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,
|
||||
0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,
|
||||
0x2c,0x20,0x31,0x2e,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,
|
||||
0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x33,0x2e,0x31,0x34,0x31,0x35,0x39,0x32,
|
||||
0x37,0x34,0x31,0x30,0x31,0x32,0x35,0x37,0x33,0x32,0x34,0x32,0x31,0x38,0x37,0x35,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,
|
||||
0x73,0x65,0x20,0x3d,0x20,0x72,0x6f,0x74,0x5f,0x78,0x28,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x69,0x66,0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x32,0x29,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x2d,0x31,0x2e,0x35,
|
||||
0x37,0x30,0x37,0x39,0x36,0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,
|
||||
0x31,0x30,0x39,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,0x65,0x20,0x3d,0x20,0x72,
|
||||
0x6f,0x74,0x5f,0x7a,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,
|
||||
0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,
|
||||
0x31,0x2e,0x35,0x37,0x30,0x37,0x39,0x36,0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,
|
||||
0x36,0x36,0x32,0x31,0x30,0x39,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,
|
||||
0x61,0x73,0x65,0x20,0x3d,0x20,0x72,0x6f,0x74,0x5f,0x7a,0x28,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x5f,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x34,0x29,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x31,
|
||||
0x2e,0x35,0x37,0x30,0x37,0x39,0x36,0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,
|
||||
0x36,0x32,0x31,0x30,0x39,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x62,0x61,0x73,0x65,0x20,0x3d,0x20,0x72,0x6f,0x74,0x5f,0x78,0x28,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x5f,0x34,0x20,0x3d,0x20,0x2d,0x31,0x2e,0x35,0x37,0x30,0x37,0x39,0x36,0x33,
|
||||
0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,0x31,0x30,0x39,0x33,0x37,0x35,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,0x65,0x20,0x3d,
|
||||
0x20,0x72,0x6f,0x74,0x5f,0x78,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x35,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x28,0x6f,0x72,0x69,0x20,0x25,0x20,0x34,0x29,0x20,0x2a,0x20,0x31,0x2e,0x35,0x37,
|
||||
0x30,0x37,0x39,0x36,0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,0x31,
|
||||
0x30,0x39,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
|
||||
0x6e,0x20,0x62,0x61,0x73,0x65,0x20,0x2a,0x20,0x72,0x6f,0x74,0x5f,0x79,0x28,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x5f,0x35,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,
|
||||
0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,
|
||||
0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x72,0x6f,
|
||||
0x75,0x6e,0x64,0x28,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x77,0x29,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x74,0x72,0x69,0x6c,0x65,0x5f,0x73,
|
||||
0x68,0x61,0x64,0x6f,0x77,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
|
||||
0x30,0x5d,0x2c,0x20,0x74,0x72,0x69,0x6c,0x65,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,
|
||||
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x74,
|
||||
0x72,0x69,0x6c,0x65,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x5f,0x76,0x73,0x5f,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x74,0x72,0x69,0x6c,0x65,0x5f,
|
||||
0x73,0x68,0x61,0x64,0x6f,0x77,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
||||
0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x28,0x67,0x65,
|
||||
0x74,0x5f,0x6f,0x72,0x69,0x65,0x6e,0x74,0x61,0x74,0x69,0x6f,0x6e,0x5f,0x6d,0x61,
|
||||
0x74,0x72,0x69,0x78,0x28,0x70,0x61,0x72,0x61,0x6d,0x29,0x20,0x2a,0x20,0x28,0x70,
|
||||
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x76,0x65,
|
||||
0x63,0x33,0x28,0x30,0x2e,0x35,0x29,0x29,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,
|
||||
0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,
|
||||
0x65,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||
0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(0.0);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_trile_shadow_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,0x0a,
|
||||
0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,
|
||||
0x65,0x63,0x34,0x28,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct trile_shadow_vs_params
|
||||
{
|
||||
float4x4 mvp;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 position [[attribute(0)]];
|
||||
float4 instance [[attribute(3)]];
|
||||
};
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
float3x3 rot_x(thread const float& a)
|
||||
{
|
||||
float _28 = cos(a);
|
||||
float _31 = sin(a);
|
||||
return float3x3(float3(1.0, 0.0, 0.0), float3(0.0, _28, -_31), float3(0.0, _31, _28));
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
float3x3 rot_z(thread const float& a)
|
||||
{
|
||||
float _47 = cos(a);
|
||||
float _50 = sin(a);
|
||||
return float3x3(float3(_47, -_50, 0.0), float3(_50, _47, 0.0), float3(0.0, 0.0, 1.0));
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
float3x3 rot_y(thread const float& a)
|
||||
{
|
||||
float _64 = cos(a);
|
||||
float _67 = sin(a);
|
||||
return float3x3(float3(_64, 0.0, _67), float3(0.0, 1.0, 0.0), float3(-_67, 0.0, _64));
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
float3x3 get_orientation_matrix(thread const int& ori)
|
||||
{
|
||||
int _82 = ori / 4;
|
||||
float3x3 base;
|
||||
if (_82 == 0)
|
||||
{
|
||||
base = float3x3(float3(1.0, 0.0, 0.0), float3(0.0, 1.0, 0.0), float3(0.0, 0.0, 1.0));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 1)
|
||||
{
|
||||
float param = 3.1415927410125732421875;
|
||||
base = rot_x(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 2)
|
||||
{
|
||||
float param_1 = -1.57079637050628662109375;
|
||||
base = rot_z(param_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 3)
|
||||
{
|
||||
float param_2 = 1.57079637050628662109375;
|
||||
base = rot_z(param_2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_82 == 4)
|
||||
{
|
||||
float param_3 = 1.57079637050628662109375;
|
||||
base = rot_x(param_3);
|
||||
}
|
||||
else
|
||||
{
|
||||
float param_4 = -1.57079637050628662109375;
|
||||
base = rot_x(param_4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float param_5 = float(ori % 4) * 1.57079637050628662109375;
|
||||
return base * rot_y(param_5);
|
||||
}
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant trile_shadow_vs_params& _193 [[buffer(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
int param = int(round(in.instance.w));
|
||||
out.gl_Position = _193.mvp * float4(((get_orientation_matrix(param) * (in.position.xyz - float3(0.5))) + float3(0.5)) + in.instance.xyz, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
vs_trile_shadow_source_metal_macos := u8.[
|
||||
0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x63,0x6c,0x61,0x6e,0x67,0x20,0x64,0x69,
|
||||
0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x20,0x69,0x67,0x6e,0x6f,0x72,0x65,0x64,
|
||||
0x20,0x22,0x2d,0x57,0x6d,0x69,0x73,0x73,0x69,0x6e,0x67,0x2d,0x70,0x72,0x6f,0x74,
|
||||
0x6f,0x74,0x79,0x70,0x65,0x73,0x22,0x0a,0x0a,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,0x74,0x72,0x69,0x6c,0x65,0x5f,0x73,0x68,
|
||||
0x61,0x64,0x6f,0x77,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,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,0x34,0x20,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,
|
||||
0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x5b,
|
||||
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x33,0x29,0x5d,0x5d,0x3b,
|
||||
0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x69,0x6e,0x6c,0x69,
|
||||
0x6e,0x65,0x20,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,
|
||||
0x28,0x28,0x61,0x6c,0x77,0x61,0x79,0x73,0x5f,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x29,
|
||||
0x29,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,0x20,0x72,0x6f,0x74,0x5f,0x78,
|
||||
0x28,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x26,0x20,0x61,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x20,0x5f,0x32,0x38,0x20,0x3d,0x20,0x63,0x6f,0x73,0x28,0x61,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x31,0x20,
|
||||
0x3d,0x20,0x73,0x69,0x6e,0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,
|
||||
0x74,0x75,0x72,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,0x28,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,
|
||||
0x2e,0x30,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,
|
||||
0x20,0x5f,0x32,0x38,0x2c,0x20,0x2d,0x5f,0x33,0x31,0x29,0x2c,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x33,0x31,0x2c,0x20,0x5f,0x32,
|
||||
0x38,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x69,
|
||||
0x6e,0x6c,0x69,0x6e,0x65,0x20,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,
|
||||
0x65,0x5f,0x5f,0x28,0x28,0x61,0x6c,0x77,0x61,0x79,0x73,0x5f,0x69,0x6e,0x6c,0x69,
|
||||
0x6e,0x65,0x29,0x29,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,0x20,0x72,0x6f,
|
||||
0x74,0x5f,0x7a,0x28,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x26,0x20,0x61,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x34,0x37,0x20,0x3d,0x20,0x63,0x6f,0x73,
|
||||
0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
||||
0x35,0x30,0x20,0x3d,0x20,0x73,0x69,0x6e,0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,
|
||||
0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x34,0x37,0x2c,0x20,0x2d,0x5f,0x35,
|
||||
0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,
|
||||
0x5f,0x35,0x30,0x2c,0x20,0x5f,0x34,0x37,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,
|
||||
0x63,0x20,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,
|
||||
0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x61,0x6c,0x77,0x61,0x79,0x73,0x5f,0x69,
|
||||
0x6e,0x6c,0x69,0x6e,0x65,0x29,0x29,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,
|
||||
0x20,0x72,0x6f,0x74,0x5f,0x79,0x28,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63,0x6f,
|
||||
0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x26,0x20,0x61,0x29,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,0x34,0x20,0x3d,0x20,
|
||||
0x63,0x6f,0x73,0x28,0x61,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x20,0x5f,0x36,0x37,0x20,0x3d,0x20,0x73,0x69,0x6e,0x28,0x61,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x33,0x78,0x33,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x36,0x34,0x2c,0x20,
|
||||
0x30,0x2e,0x30,0x2c,0x20,0x5f,0x36,0x37,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,
|
||||
0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x2d,0x5f,0x36,0x37,0x2c,0x20,0x30,
|
||||
0x2e,0x30,0x2c,0x20,0x5f,0x36,0x34,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x73,0x74,
|
||||
0x61,0x74,0x69,0x63,0x20,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x5f,0x5f,0x61,0x74,
|
||||
0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x61,0x6c,0x77,0x61,0x79,
|
||||
0x73,0x5f,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x29,0x29,0x0a,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x33,0x78,0x33,0x20,0x67,0x65,0x74,0x5f,0x6f,0x72,0x69,0x65,0x6e,0x74,0x61,0x74,
|
||||
0x69,0x6f,0x6e,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x28,0x74,0x68,0x72,0x65,0x61,
|
||||
0x64,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x69,0x6e,0x74,0x26,0x20,0x6f,0x72,0x69,
|
||||
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x38,0x32,0x20,
|
||||
0x3d,0x20,0x6f,0x72,0x69,0x20,0x2f,0x20,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,0x20,0x62,0x61,0x73,0x65,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,
|
||||
0x73,0x65,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,0x28,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,
|
||||
0x2e,0x30,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,
|
||||
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,
|
||||
0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x69,0x66,0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,
|
||||
0x20,0x3d,0x20,0x33,0x2e,0x31,0x34,0x31,0x35,0x39,0x32,0x37,0x34,0x31,0x30,0x31,
|
||||
0x32,0x35,0x37,0x33,0x32,0x34,0x32,0x31,0x38,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,0x65,0x20,0x3d,0x20,
|
||||
0x72,0x6f,0x74,0x5f,0x78,0x28,0x70,0x61,0x72,0x61,0x6d,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,
|
||||
0x38,0x32,0x20,0x3d,0x3d,0x20,0x32,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,
|
||||
0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x2d,0x31,0x2e,0x35,0x37,0x30,0x37,0x39,0x36,
|
||||
0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,0x31,0x30,0x39,0x33,0x37,
|
||||
0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x62,0x61,0x73,0x65,0x20,0x3d,0x20,0x72,0x6f,0x74,0x5f,0x7a,0x28,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,
|
||||
0x3d,0x20,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x31,0x2e,0x35,0x37,0x30,
|
||||
0x37,0x39,0x36,0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,0x31,0x30,
|
||||
0x39,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,0x65,0x20,0x3d,
|
||||
0x20,0x72,0x6f,0x74,0x5f,0x7a,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x29,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,
|
||||
0x20,0x28,0x5f,0x38,0x32,0x20,0x3d,0x3d,0x20,0x34,0x29,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x31,0x2e,0x35,0x37,0x30,0x37,
|
||||
0x39,0x36,0x33,0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,0x31,0x30,0x39,
|
||||
0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,
|
||||
0x65,0x20,0x3d,0x20,0x72,0x6f,0x74,0x5f,0x78,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,
|
||||
0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x6c,
|
||||
0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x20,0x3d,
|
||||
0x20,0x2d,0x31,0x2e,0x35,0x37,0x30,0x37,0x39,0x36,0x33,0x37,0x30,0x35,0x30,0x36,
|
||||
0x32,0x38,0x36,0x36,0x32,0x31,0x30,0x39,0x33,0x37,0x35,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x73,0x65,0x20,0x3d,0x20,0x72,0x6f,0x74,0x5f,
|
||||
0x78,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,
|
||||
0x6d,0x5f,0x35,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x6f,0x72,0x69,0x20,
|
||||
0x25,0x20,0x34,0x29,0x20,0x2a,0x20,0x31,0x2e,0x35,0x37,0x30,0x37,0x39,0x36,0x33,
|
||||
0x37,0x30,0x35,0x30,0x36,0x32,0x38,0x36,0x36,0x32,0x31,0x30,0x39,0x33,0x37,0x35,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x62,0x61,0x73,
|
||||
0x65,0x20,0x2a,0x20,0x72,0x6f,0x74,0x5f,0x79,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,
|
||||
0x35,0x29,0x3b,0x0a,0x7d,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,0x74,0x72,0x69,0x6c,0x65,0x5f,0x73,0x68,0x61,0x64,0x6f,0x77,0x5f,0x76,0x73,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,0x39,0x33,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,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x72,0x6f,0x75,0x6e,0x64,
|
||||
0x28,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x77,0x29,0x29,
|
||||
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,0x33,0x2e,0x6d,0x76,0x70,
|
||||
0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x28,0x67,0x65,0x74,0x5f,
|
||||
0x6f,0x72,0x69,0x65,0x6e,0x74,0x61,0x74,0x69,0x6f,0x6e,0x5f,0x6d,0x61,0x74,0x72,
|
||||
0x69,0x78,0x28,0x70,0x61,0x72,0x61,0x6d,0x29,0x20,0x2a,0x20,0x28,0x69,0x6e,0x2e,
|
||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x35,0x29,0x29,0x29,0x20,0x2b,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2b,0x20,0x69,0x6e,
|
||||
0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,
|
||||
0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0()
|
||||
{
|
||||
main0_out out = {};
|
||||
out.frag_color = float4(0.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_trile_shadow_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,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,0x29,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,
|
||||
0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,
|
||||
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x34,0x28,0x30,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,
|
||||
];
|
||||
trile_shadow_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "trile_shadow_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_trile_shadow_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_trile_shadow_source_glsl430;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "normal";
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[2].glsl_name = "centre";
|
||||
desc.attrs[3].base_type = .FLOAT;
|
||||
desc.attrs[3].glsl_name = "instance";
|
||||
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 = "trile_shadow_vs_params";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_trile_shadow_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_trile_shadow_source_glsl300es;
|
||||
desc.fragment_func.entry = "main";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[0].glsl_name = "position";
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[1].glsl_name = "normal";
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[2].glsl_name = "centre";
|
||||
desc.attrs[3].base_type = .FLOAT;
|
||||
desc.attrs[3].glsl_name = "instance";
|
||||
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 = "trile_shadow_vs_params";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_trile_shadow_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_trile_shadow_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[3].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;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,48 +0,0 @@
|
||||
@vs vs_billboard
|
||||
|
||||
in vec3 position;
|
||||
|
||||
layout(binding=0) uniform billboard_vs_params {
|
||||
mat4 mvp;
|
||||
vec4 uvs;
|
||||
vec3 offset;
|
||||
vec2 size;
|
||||
vec3 cam;
|
||||
vec3 faceDir;
|
||||
};
|
||||
|
||||
out vec2 uv_in;
|
||||
|
||||
void main() {
|
||||
vec3 local_pos = vec3((position.x - 0.5) * size.x, (position.y) * size.y, position.z);
|
||||
vec3 world_up = vec3(0.0, 1.0, 0.0);
|
||||
vec3 look_dir = offset - cam;
|
||||
look_dir.y = 0.0;
|
||||
look_dir = normalize(look_dir);
|
||||
if(faceDir.x > -10) look_dir = faceDir;
|
||||
vec3 world_right = normalize(cross(world_up, look_dir));
|
||||
vec3 world_pos = offset + (world_right * local_pos.x) + (world_up * local_pos.y);
|
||||
gl_Position = mvp * vec4(world_pos, 1.0);
|
||||
uv_in = vec2(uvs.x + position.x * uvs.z, uvs.y + position.y * uvs.w);
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_billboard
|
||||
|
||||
in vec2 uv_in;
|
||||
out vec4 color;
|
||||
|
||||
layout(binding = 0) uniform texture2D sprite;
|
||||
layout(binding = 0) uniform sampler spritesmp;
|
||||
|
||||
void main() {
|
||||
vec2 uv = uv_in;
|
||||
uv.y = 1.0 - uv.y;
|
||||
vec4 sampled = texture(sampler2D(sprite, spritesmp), uv);
|
||||
if(sampled.a < 0.01) discard;
|
||||
color = vec4(sampled.rgb * 0.5, 1.0);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@program billboard vs_billboard fs_billboard
|
||||
@ -1,35 +0,0 @@
|
||||
@vs vs_bloom_downsample
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_bloom_downsample
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=0) uniform bloom_downsample_params {
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D bloom_downsample_src;
|
||||
layout(binding = 0) uniform sampler bloom_downsample_src_smp;
|
||||
|
||||
void main() {
|
||||
vec2 ts = vec2(src_texel_x, src_texel_y) * 0.5;
|
||||
vec3 a = texture(sampler2D(bloom_downsample_src, bloom_downsample_src_smp), texcoord + vec2(-ts.x, -ts.y)).rgb;
|
||||
vec3 b = texture(sampler2D(bloom_downsample_src, bloom_downsample_src_smp), texcoord + vec2( ts.x, -ts.y)).rgb;
|
||||
vec3 c = texture(sampler2D(bloom_downsample_src, bloom_downsample_src_smp), texcoord + vec2(-ts.x, ts.y)).rgb;
|
||||
vec3 d = texture(sampler2D(bloom_downsample_src, bloom_downsample_src_smp), texcoord + vec2( ts.x, ts.y)).rgb;
|
||||
frag_color = vec4((a + b + c + d) * 0.25, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program bloom_downsample vs_bloom_downsample fs_bloom_downsample
|
||||
@ -1,39 +0,0 @@
|
||||
@vs vs_bloom_prefilter
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_bloom_prefilter
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=0) uniform bloom_prefilter_params {
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
float threshold;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D bloom_prefilter_src;
|
||||
layout(binding = 0) uniform sampler bloom_prefilter_src_smp;
|
||||
|
||||
void main() {
|
||||
vec2 ts = vec2(src_texel_x, src_texel_y) * 0.5;
|
||||
vec3 a = texture(sampler2D(bloom_prefilter_src, bloom_prefilter_src_smp), texcoord + vec2(-ts.x, -ts.y)).rgb;
|
||||
vec3 b = texture(sampler2D(bloom_prefilter_src, bloom_prefilter_src_smp), texcoord + vec2( ts.x, -ts.y)).rgb;
|
||||
vec3 c = texture(sampler2D(bloom_prefilter_src, bloom_prefilter_src_smp), texcoord + vec2(-ts.x, ts.y)).rgb;
|
||||
vec3 d = texture(sampler2D(bloom_prefilter_src, bloom_prefilter_src_smp), texcoord + vec2( ts.x, ts.y)).rgb;
|
||||
vec3 color = (a + b + c + d) * 0.25;
|
||||
float lum = dot(color, vec3(0.2126, 0.7152, 0.0722));
|
||||
if (lum < threshold) color = vec3(0.0);
|
||||
frag_color = vec4(color, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program bloom_prefilter vs_bloom_prefilter fs_bloom_prefilter
|
||||
@ -1,39 +0,0 @@
|
||||
@vs vs_bloom_upsample
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_bloom_upsample
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=0) uniform bloom_upsample_params {
|
||||
float src_texel_x;
|
||||
float src_texel_y;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D bloom_upsample_small;
|
||||
layout(binding = 0) uniform sampler bloom_upsample_small_smp;
|
||||
layout(binding = 1) uniform texture2D bloom_upsample_large;
|
||||
layout(binding = 1) uniform sampler bloom_upsample_large_smp;
|
||||
|
||||
void main() {
|
||||
vec2 ts = vec2(src_texel_x, src_texel_y) * 0.5;
|
||||
vec3 tent =
|
||||
texture(sampler2D(bloom_upsample_small, bloom_upsample_small_smp), texcoord + vec2(-ts.x, -ts.y)).rgb +
|
||||
texture(sampler2D(bloom_upsample_small, bloom_upsample_small_smp), texcoord + vec2( ts.x, -ts.y)).rgb +
|
||||
texture(sampler2D(bloom_upsample_small, bloom_upsample_small_smp), texcoord + vec2(-ts.x, ts.y)).rgb +
|
||||
texture(sampler2D(bloom_upsample_small, bloom_upsample_small_smp), texcoord + vec2( ts.x, ts.y)).rgb;
|
||||
vec3 large = texture(sampler2D(bloom_upsample_large, bloom_upsample_large_smp), texcoord).rgb;
|
||||
frag_color = vec4(tent * 0.25 + large, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program bloom_upsample vs_bloom_upsample fs_bloom_upsample
|
||||
@ -1,58 +0,0 @@
|
||||
@vs vs_debugline
|
||||
|
||||
// Lines are drawn as camera-facing quads rather than GL lines, so they can have
|
||||
// a real pixel width. Buffer 0 holds the six corners of a unit quad, buffer 1
|
||||
// one instance per line.
|
||||
in vec2 a_corner; // x = which side (-1 / +1), y = which end (0 = a, 1 = b)
|
||||
in vec3 a_pos_a;
|
||||
in vec3 a_pos_b;
|
||||
in vec4 a_col;
|
||||
in float a_width; // in pixels
|
||||
|
||||
layout(binding=0) uniform debugline_vs_params {
|
||||
mat4 mvp;
|
||||
vec4 viewport; // xy = size in pixels, zw = unused
|
||||
};
|
||||
|
||||
out vec4 v_col;
|
||||
|
||||
void main() {
|
||||
vec4 clip_a = mvp * vec4(a_pos_a, 1.0);
|
||||
vec4 clip_b = mvp * vec4(a_pos_b, 1.0);
|
||||
|
||||
// Widen in screen space so the line keeps its pixel width at any depth.
|
||||
// Guard against w <= 0: an endpoint behind the eye has no screen position,
|
||||
// so fall back to the other end's and let clipping handle the rest.
|
||||
float wa = max(clip_a.w, 0.0001);
|
||||
float wb = max(clip_b.w, 0.0001);
|
||||
vec2 screen_a = (clip_a.xy / wa) * viewport.xy;
|
||||
vec2 screen_b = (clip_b.xy / wb) * viewport.xy;
|
||||
|
||||
vec2 delta = screen_b - screen_a;
|
||||
float len = length(delta);
|
||||
vec2 dir = (len > 0.0001) ? delta / len : vec2(1.0, 0.0);
|
||||
vec2 normal = vec2(-dir.y, dir.x);
|
||||
|
||||
vec4 clip = mix(clip_a, clip_b, a_corner.y);
|
||||
// Half a pixel of extra width keeps thin lines from disappearing between
|
||||
// sample points.
|
||||
vec2 offset = normal * a_corner.x * (a_width * 0.5 + 0.5) / viewport.xy;
|
||||
gl_Position = clip + vec4(offset * clip.w, 0.0, 0.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
|
||||
@ -1,48 +0,0 @@
|
||||
@vs vs_dof_blur
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_dof_blur
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=0) uniform dof_blur_params {
|
||||
float bokeh_radius_x;
|
||||
float bokeh_radius_y;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D dof_blur_src;
|
||||
layout(binding = 0) uniform sampler dof_blur_src_smp;
|
||||
|
||||
void main() {
|
||||
const int NUM_SAMPLES = 32;
|
||||
const float GOLDEN_ANGLE = 2.39996323;
|
||||
|
||||
vec4 best = texture(sampler2D(dof_blur_src, dof_blur_src_smp), texcoord);
|
||||
float best_lum = dot(best.rgb, vec3(0.2126, 0.7152, 0.0722));
|
||||
|
||||
for (int i = 0; i < NUM_SAMPLES; i++) {
|
||||
float theta = float(i) * GOLDEN_ANGLE;
|
||||
float r = sqrt(float(i) / float(NUM_SAMPLES - 1) + 0.001);
|
||||
vec2 offset = vec2(cos(theta), sin(theta)) * r * vec2(bokeh_radius_x, bokeh_radius_y);
|
||||
vec4 s = texture(sampler2D(dof_blur_src, dof_blur_src_smp), texcoord + offset);
|
||||
float lum = dot(s.rgb, vec3(0.2126, 0.7152, 0.0722));
|
||||
if (lum > best_lum) {
|
||||
best = s;
|
||||
best_lum = lum;
|
||||
}
|
||||
}
|
||||
|
||||
frag_color = best;
|
||||
}
|
||||
@end
|
||||
|
||||
@program dof_blur vs_dof_blur fs_dof_blur
|
||||
@ -1,25 +0,0 @@
|
||||
@vs vs_dof_downsample
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_dof_downsample
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding = 0) uniform texture2D dof_downsample_src;
|
||||
layout(binding = 0) uniform sampler dof_downsample_src_smp;
|
||||
|
||||
void main() {
|
||||
frag_color = vec4(texture(sampler2D(dof_downsample_src, dof_downsample_src_smp), texcoord).rgb, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program dof_downsample vs_dof_downsample fs_dof_downsample
|
||||
@ -1,76 +0,0 @@
|
||||
@vs vs_g
|
||||
layout(binding=0) uniform gbuffer_vs_params {
|
||||
mat4 mvp;
|
||||
mat4 view_matrix;
|
||||
int isGround;
|
||||
float planeHeight;
|
||||
};
|
||||
|
||||
in vec4 position;
|
||||
in vec4 normal;
|
||||
in vec4 centre;
|
||||
in vec4 instance;
|
||||
|
||||
out vec3 view_space_pos;
|
||||
out vec3 view_space_normal;
|
||||
out vec3 v_world_pos;
|
||||
|
||||
mat3 gbuf_rot_x(float a) { float c=cos(a),s=sin(a); return mat3(1,0,0, 0,c,-s, 0,s,c); }
|
||||
mat3 gbuf_rot_z(float a) { float c=cos(a),s=sin(a); return mat3(c,-s,0, s,c,0, 0,0,1); }
|
||||
mat3 gbuf_rot_y(float a) { float c=cos(a),s=sin(a); return mat3(c,0,s, 0,1,0, -s,0,c); }
|
||||
|
||||
mat3 gbuf_get_orientation_matrix(int ori) {
|
||||
int face = ori / 4;
|
||||
int twist = ori % 4;
|
||||
float PI = 3.1415927;
|
||||
mat3 base;
|
||||
if (face == 0) base = mat3(1.0);
|
||||
else if (face == 1) base = gbuf_rot_x(PI);
|
||||
else if (face == 2) base = gbuf_rot_z(-PI*0.5);
|
||||
else if (face == 3) base = gbuf_rot_z( PI*0.5);
|
||||
else if (face == 4) base = gbuf_rot_x( PI*0.5);
|
||||
else base = gbuf_rot_x(-PI*0.5);
|
||||
return base * gbuf_rot_y(float(twist) * PI * 0.5);
|
||||
}
|
||||
|
||||
void main() {
|
||||
if (isGround == 1) {
|
||||
vec4 world_pos = vec4(position.x * 100.0, planeHeight, position.z * 100.0, 1.0);
|
||||
vec4 view_pos_4 = view_matrix * world_pos;
|
||||
gl_Position = mvp * world_pos;
|
||||
view_space_pos = view_pos_4.xyz;
|
||||
view_space_normal = mat3(view_matrix) * normal.xyz;
|
||||
v_world_pos = world_pos.xyz;
|
||||
} else {
|
||||
int ori = int(round(instance.w));
|
||||
mat3 rot = gbuf_get_orientation_matrix(ori);
|
||||
vec3 local = position.xyz - 0.5;
|
||||
vec3 rotated = rot * local + 0.5;
|
||||
vec4 world_pos = vec4(rotated + instance.xyz, 1.0);
|
||||
vec4 view_pos_4 = view_matrix * world_pos;
|
||||
gl_Position = mvp * world_pos;
|
||||
view_space_pos = view_pos_4.xyz;
|
||||
view_space_normal = mat3(view_matrix) * (rot * normal.xyz);
|
||||
v_world_pos = world_pos.xyz;
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_g
|
||||
|
||||
in vec3 view_space_pos;
|
||||
in vec3 view_space_normal;
|
||||
in vec3 v_world_pos;
|
||||
|
||||
layout(location=0) out vec4 out_position;
|
||||
layout(location=1) out vec4 out_normal;
|
||||
layout(location=2) out vec4 out_worldpos;
|
||||
|
||||
void main() {
|
||||
out_position = vec4(view_space_pos, 1.0);
|
||||
out_normal = vec4(normalize(view_space_normal), 1.0);
|
||||
out_worldpos = vec4(v_world_pos, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program gbuffer vs_g fs_g
|
||||
@ -1,59 +0,0 @@
|
||||
@vs vs_gbuffer_billboard
|
||||
|
||||
in vec3 position;
|
||||
|
||||
layout(binding=0) uniform gbuffer_billboard_vs_params {
|
||||
mat4 mvp;
|
||||
vec4 uvs;
|
||||
vec3 offset;
|
||||
vec2 size;
|
||||
vec3 cam;
|
||||
mat4 view_matrix;
|
||||
vec3 faceDir;
|
||||
};
|
||||
|
||||
out vec2 uv_in;
|
||||
out vec3 view_space_pos;
|
||||
out vec3 view_space_normal;
|
||||
|
||||
void main() {
|
||||
vec3 local_pos = vec3((position.x - 0.5) * size.x, (position.y) * size.y, position.z);
|
||||
vec3 world_up = vec3(0.0, 1.0, 0.0);
|
||||
vec3 look_dir = offset - cam;
|
||||
look_dir.y = 0.0;
|
||||
look_dir = normalize(look_dir);
|
||||
if(faceDir.x > -10) look_dir = faceDir;
|
||||
vec3 world_right = normalize(cross(world_up, look_dir));
|
||||
vec3 world_pos = offset + (world_right * local_pos.x) + (world_up * local_pos.y);
|
||||
gl_Position = mvp * vec4(world_pos, 1.0);
|
||||
vec4 view_pos_4 = view_matrix * vec4(world_pos, 1.0);
|
||||
view_space_pos = view_pos_4.xyz;
|
||||
view_space_normal = mat3(view_matrix) * vec3(0,1,0);
|
||||
uv_in = vec2(uvs.x + position.x * uvs.z, uvs.y + position.y * uvs.w);
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_gbuffer_billboard
|
||||
|
||||
in vec2 uv_in;
|
||||
in vec3 view_space_pos;
|
||||
in vec3 view_space_normal;
|
||||
|
||||
layout(binding = 0) uniform texture2D gsprite;
|
||||
layout(binding = 0) uniform sampler gspritesmp;
|
||||
|
||||
layout(location=0) out vec4 out_position;
|
||||
layout(location=1) out vec4 out_normal;
|
||||
|
||||
void main() {
|
||||
vec2 uv = uv_in;
|
||||
uv.y = 1.0 - uv.y;
|
||||
vec4 sampled = texture(sampler2D(gsprite, gspritesmp), uv);
|
||||
if(sampled.a < 0.01) discard;
|
||||
out_position = vec4(view_space_pos, 1.0);
|
||||
out_normal = vec4(normalize(view_space_normal), 1.0);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@program gbuffer_billboard vs_gbuffer_billboard fs_gbuffer_billboard
|
||||
@ -1,50 +0,0 @@
|
||||
@vs vs_mix
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_mix
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=1) uniform mix_fs_params {
|
||||
int op;
|
||||
float dof_min;
|
||||
float dof_max;
|
||||
float dof_point;
|
||||
/*
|
||||
List of mixs:
|
||||
0. DOF
|
||||
1. Add
|
||||
*/
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D mixtex_a;
|
||||
layout(binding = 1) uniform texture2D mixtex_b;
|
||||
layout(binding = 2) uniform texture2D mixtex_c;
|
||||
layout(binding = 0) uniform sampler mixsmp;
|
||||
|
||||
void main() {
|
||||
if(op == 0) {
|
||||
vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(mixtex_a, mixsmp), 0));
|
||||
vec3 in_focus = texture(sampler2D(mixtex_b, mixsmp), texcoord).rgb;
|
||||
vec3 out_focus = texture(sampler2D(mixtex_a, mixsmp), texcoord).rgb;
|
||||
vec4 position = texture(sampler2D(mixtex_c, mixsmp), texcoord);
|
||||
float blur = smoothstep(dof_min, dof_max, abs(position.z + dof_point));
|
||||
frag_color = vec4(mix(in_focus, out_focus, blur), 1.0);
|
||||
} else if(op == 1) {
|
||||
vec3 a = texture(sampler2D(mixtex_b, mixsmp), texcoord).rgb;
|
||||
vec3 b = texture(sampler2D(mixtex_a, mixsmp), texcoord).rgb;
|
||||
frag_color = vec4(a+b, 1.0);
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@program mix vs_mix fs_mix
|
||||
@ -1,112 +0,0 @@
|
||||
@vs vs_op
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_op
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=1) uniform op_fs_params {
|
||||
/*
|
||||
List of ops:
|
||||
0. blur for ssao
|
||||
1. dilate.
|
||||
2. normal blur
|
||||
3. bloom
|
||||
*/
|
||||
int op;
|
||||
|
||||
// Common
|
||||
int blur_size;
|
||||
float separation;
|
||||
|
||||
// DOF
|
||||
float dilate_min;
|
||||
float dilate_max;
|
||||
|
||||
// Bloom
|
||||
float bloom_amount;
|
||||
float bloom_treshold;
|
||||
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D optex;
|
||||
layout(binding = 0) uniform sampler opsmp;
|
||||
|
||||
void main() {
|
||||
if(op == 3) {
|
||||
vec2 texSize = vec2(textureSize(sampler2D(optex, opsmp), 0));
|
||||
float value = 0.0;
|
||||
float count = 0.0;
|
||||
|
||||
vec4 result = vec4(0.0);
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
for(int i = -blur_size ; i <= blur_size; ++i) {
|
||||
for(int j = -blur_size; j <= blur_size; ++j) {
|
||||
color = texture(sampler2D(optex, opsmp), (gl_FragCoord.xy + vec2(i,j) * separation) / texSize);
|
||||
value = max(color.r, max(color.g, color.b));
|
||||
if(value < bloom_treshold) { color = vec4(0); }
|
||||
result += color;
|
||||
count += 1.0;
|
||||
}
|
||||
}
|
||||
result /= count;
|
||||
frag_color = vec4(result.xyz * bloom_amount, 1.0);
|
||||
} else if(op == 2) {
|
||||
vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(optex, opsmp), 0));
|
||||
vec3 result = vec3(0.0);
|
||||
for (int x = -blur_size; x < blur_size; ++x)
|
||||
{
|
||||
for (int y = -blur_size; y < blur_size; ++y)
|
||||
{
|
||||
vec2 offset = vec2(float(x), float(y)) * texelSize;
|
||||
result += texture(sampler2D(optex, opsmp), texcoord + offset).xyz;
|
||||
}
|
||||
}
|
||||
frag_color = vec4((result / (blur_size*2 * blur_size*2)), 1.0);
|
||||
}
|
||||
else if(op == 1) {
|
||||
float minThreshold = dilate_min;
|
||||
float maxThreshold = dilate_max;
|
||||
vec2 texSize = textureSize(sampler2D(optex, opsmp), 0).xy;
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
frag_color = texture(sampler2D(optex, opsmp), fragCoord / texSize);
|
||||
if (blur_size <= 0) { return; }
|
||||
float mx = 0.0;
|
||||
vec4 cmx = frag_color;
|
||||
for (int i = -blur_size; i <= blur_size; ++i) {
|
||||
for (int j = -blur_size; j <= blur_size; ++j) {
|
||||
if (!(distance(vec2(i, j), vec2(0, 0)) <= blur_size)) { continue; }
|
||||
vec4 c = texture(sampler2D(optex,opsmp),(gl_FragCoord.xy + (vec2(i, j) * separation)) / texSize);
|
||||
float mxt = dot(c.rgb, vec3(0.3, 0.59, 0.11));
|
||||
if (mxt > mx) {
|
||||
mx = mxt;
|
||||
cmx = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
frag_color.rgb = mix(frag_color.rgb, cmx.rgb, smoothstep(minThreshold, maxThreshold, mx));
|
||||
} else {
|
||||
vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(optex, opsmp), 0));
|
||||
float result = 0.0;
|
||||
for (int x = -blur_size; x < blur_size; ++x) {
|
||||
for (int y = -blur_size; y < blur_size; ++y) {
|
||||
vec2 offset = vec2(float(x), float(y)) * texelSize;
|
||||
result += texture(sampler2D(optex, opsmp), texcoord + offset).r;
|
||||
}
|
||||
}
|
||||
frag_color = vec4(vec3(result / (blur_size*2 * blur_size*2)), 1.0);
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@program op vs_op fs_op
|
||||
@ -1,54 +0,0 @@
|
||||
@vs vs_particle
|
||||
|
||||
in vec3 position;
|
||||
in vec4 inst_pos_size;
|
||||
in vec4 inst_uv_rect;
|
||||
in vec4 inst_color;
|
||||
|
||||
layout(binding=0) uniform particle_vs_params {
|
||||
mat4 mvp;
|
||||
vec3 cam;
|
||||
};
|
||||
|
||||
out vec2 uv_in;
|
||||
out vec4 color_in;
|
||||
|
||||
void main() {
|
||||
float size = inst_pos_size.w;
|
||||
vec3 inst_pos = inst_pos_size.xyz;
|
||||
vec3 local_pos = vec3((position.x - 0.5) * size, position.y * size, 0.0);
|
||||
vec3 world_up = vec3(0.0, 1.0, 0.0);
|
||||
vec3 look_dir = inst_pos - cam;
|
||||
look_dir.y = 0.0;
|
||||
if (length(look_dir) < 0.0001) look_dir = vec3(1.0, 0.0, 0.0);
|
||||
look_dir = normalize(look_dir);
|
||||
vec3 world_right = normalize(cross(world_up, look_dir));
|
||||
vec3 world_pos = inst_pos + world_right * local_pos.x + world_up * local_pos.y;
|
||||
gl_Position = mvp * vec4(world_pos, 1.0);
|
||||
uv_in = vec2(inst_uv_rect.x + position.x * inst_uv_rect.z,
|
||||
inst_uv_rect.y + position.y * inst_uv_rect.w);
|
||||
color_in = inst_color;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@fs fs_particle
|
||||
|
||||
in vec2 uv_in;
|
||||
in vec4 color_in;
|
||||
out vec4 color;
|
||||
|
||||
layout(binding = 0) uniform texture2D particle_sprite;
|
||||
layout(binding = 0) uniform sampler particle_spritesmp;
|
||||
|
||||
void main() {
|
||||
vec2 uv = uv_in;
|
||||
uv.y = 1.0 - uv.y;
|
||||
vec4 sampled = texture(sampler2D(particle_sprite, particle_spritesmp), uv);
|
||||
if (sampled.a < 0.01) discard;
|
||||
color = sampled * color_in;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@program particle vs_particle fs_particle
|
||||
@ -1,161 +0,0 @@
|
||||
@vs vs_plane
|
||||
// @glsl_options fixup_clipspace
|
||||
|
||||
in vec4 position;
|
||||
|
||||
layout(binding=0) uniform plane_vs_params {
|
||||
mat4 mvp;
|
||||
float planeHeight;
|
||||
};
|
||||
|
||||
out vec4 pos;
|
||||
out flat int idx;
|
||||
out float depth;
|
||||
|
||||
void main() {
|
||||
vec3 multisize = vec3(position.xyz * 1000.0);
|
||||
multisize.y += float(gl_InstanceIndex) * planeHeight;
|
||||
gl_Position = mvp * vec4(multisize, 1.0);
|
||||
depth = gl_Position.z;
|
||||
pos = vec4(multisize, 1.0);
|
||||
idx = gl_InstanceIndex;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_plane
|
||||
|
||||
in vec4 pos;
|
||||
in flat int idx;
|
||||
in float depth;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=1) uniform plane_world_config {
|
||||
vec3 skyBase;
|
||||
vec3 skyTop;
|
||||
vec3 sunDisk;
|
||||
vec3 horizonHalo;
|
||||
vec3 sunHalo;
|
||||
vec3 sunLightColor;
|
||||
vec3 sunPosition;
|
||||
float sunIntensity;
|
||||
float skyIntensity;
|
||||
int hasClouds;
|
||||
float planeHeight;
|
||||
int animatePlaneHeight;
|
||||
vec3 waterColor;
|
||||
vec3 deepColor;
|
||||
float time;
|
||||
float waterReflectivity;
|
||||
};
|
||||
|
||||
layout(binding=2) uniform plane_data {
|
||||
mat4 mvp_shadow;
|
||||
int screen_w;
|
||||
int screen_h;
|
||||
int is_reflection_pass;
|
||||
vec3 cameraPosition;
|
||||
float shininess; // Controls the size of the sun's glint, e.g., 64.0
|
||||
float reflectionDistortion; // Controls how much waves distort reflections, e.g., 0.05
|
||||
};
|
||||
|
||||
// Texture bindings
|
||||
layout(binding = 0) uniform texture2D reftex;
|
||||
layout(binding = 1) uniform texture2D shadow;
|
||||
layout(binding = 2) uniform texture2D normal_map;
|
||||
|
||||
// Sampler bindings
|
||||
layout(binding = 0) uniform sampler refsmp;
|
||||
layout(binding = 1) uniform sampler plane_shadowsmp;
|
||||
layout(binding = 2) uniform sampler normalsmp;
|
||||
|
||||
vec3 fresnelSchlick(float cosTheta) {
|
||||
vec3 F0 = vec3(0.02);
|
||||
return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0);
|
||||
}
|
||||
|
||||
float hash(vec2 p) {
|
||||
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
|
||||
}
|
||||
|
||||
float noise(vec2 p) {
|
||||
vec2 i = floor(p);
|
||||
vec2 f = fract(p);
|
||||
vec2 u = f * f * (3.0 - 2.0 * f);
|
||||
return mix(mix(hash(i + vec2(0.0, 0.0)),
|
||||
hash(i + vec2(1.0, 0.0)), u.x),
|
||||
mix(hash(i + vec2(0.0, 1.0)),
|
||||
hash(i + vec2(1.0, 1.0)), u.x), u.y);
|
||||
}
|
||||
|
||||
float fbm(vec2 p) {
|
||||
float value = 0.0;
|
||||
float amplitude = 0.5;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
value += amplitude * noise(p);
|
||||
p *= 2.0; // Double the frequency
|
||||
amplitude *= 0.5; // Halve the amplitude
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
vec3 sky(vec3 skypos, vec3 sunpos) {
|
||||
vec3 skyGradient = mix(skyBase, skyTop, clamp(skypos.y * 2.0, 0.0, 0.7));
|
||||
vec3 final = skyGradient;
|
||||
return final;
|
||||
}
|
||||
|
||||
void main() {
|
||||
if(idx == 1) { // Second instance of the plane is the actual water surface.
|
||||
vec2 uv1 = pos.xz * 0.4 + time * vec2(-0.005, -0.012) * 1.5;
|
||||
vec2 uv2 = pos.xz * 0.1 + time * vec2(-0.005, -0.012) * 1.7;
|
||||
vec2 uv3 = pos.xz * 1.0 + time * vec2(-0.005, -0.012) * 2.7;
|
||||
vec2 uv4 = pos.xz * 0.02 + time * vec2(-0.005, -0.012) * 0.1;
|
||||
|
||||
vec3 normal1 = texture(sampler2D(normal_map, normalsmp), uv1).xzy * 2.0 - 1.0;
|
||||
vec3 normal2 = texture(sampler2D(normal_map, normalsmp), uv2).xzy * 2.0 - 1.0;
|
||||
vec3 normal3 = texture(sampler2D(normal_map, normalsmp), uv3).xzy * 2.0 - 1.0;
|
||||
vec3 normal4 = texture(sampler2D(normal_map, normalsmp), uv4).xzy * 2.0 - 1.0;
|
||||
|
||||
vec3 normal = normalize(normal1 + normal2 + normal3 + normal4);
|
||||
|
||||
vec3 view_dir = normalize(cameraPosition - pos.xyz);
|
||||
vec3 light_dir = normalize(sunPosition);
|
||||
vec3 halfway_dir = normalize(light_dir + view_dir);
|
||||
|
||||
float diffuse = max(0.0, dot(normal, light_dir));
|
||||
float spec = pow(max(0.0, dot(halfway_dir, normal)), max(shininess, 1.0));
|
||||
float fresnel = min(1.0, fresnelSchlick(max(0.0, dot(view_dir, normal))).x + 0.45);
|
||||
|
||||
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;
|
||||
shadow_pos = shadow_pos * 0.5 + 0.5;
|
||||
shadow_pos.z -= 0.001;
|
||||
float shadowp = texture(sampler2DShadow(shadow, plane_shadowsmp), shadow_pos);
|
||||
|
||||
vec3 refracted_color = waterColor * diffuse * sunLightColor * sunIntensity * shadowp;
|
||||
vec3 specular_highlight = sunLightColor * sunIntensity * spec * fresnel * shadowp;
|
||||
|
||||
vec2 screen_uv = gl_FragCoord.xy / vec2(screen_w, screen_h);
|
||||
screen_uv.y = 1.0 - screen_uv.y;
|
||||
vec2 distortion = normal.xz * reflectionDistortion;
|
||||
vec3 reflected_color = texture(sampler2D(reftex, refsmp), screen_uv + distortion).rgb;
|
||||
|
||||
vec3 surface_color = mix(refracted_color, reflected_color, mix(fresnel, 1.0, waterReflectivity));
|
||||
vec3 final_color = surface_color + specular_highlight;
|
||||
float alpha = mix(mix(0.3, 0.5, fresnel), 1.0, waterReflectivity);
|
||||
|
||||
vec3 fog = skyIntensity * sky(normalize(pos.xyz), sunPosition);
|
||||
float fogFactor = smoothstep(750.0, 1000.0, length(pos.xz));
|
||||
|
||||
frag_color = vec4(mix(final_color, fog, fogFactor), mix(alpha, 1.0, fogFactor));
|
||||
|
||||
} else { // Deep water plane
|
||||
vec2 noise_uv = pos.xz * 0.05 + time * 0.01;
|
||||
float noise_value = fbm(noise_uv);
|
||||
vec3 noisy_deep_color = deepColor * mix(0.8, 1.2, noise_value);
|
||||
frag_color = vec4(noisy_deep_color, 1.0);
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@program plane vs_plane fs_plane
|
||||
@ -1,207 +0,0 @@
|
||||
@vs vs_pp
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_pp
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding = 0) uniform texture2D pptex;
|
||||
layout(binding = 0) uniform sampler ppsmp;
|
||||
layout(binding = 1) uniform texture2D lut;
|
||||
layout(binding = 1) uniform sampler lut_linear;
|
||||
layout(binding = 2) uniform texture2D bloom_tex;
|
||||
layout(binding = 2) uniform sampler bloom_smp;
|
||||
layout(binding = 3) uniform texture2D dof_tex;
|
||||
layout(binding = 3) uniform sampler dof_smp;
|
||||
layout(binding = 4) uniform texture2D pos_buf;
|
||||
layout(binding = 4) uniform sampler pos_smp;
|
||||
|
||||
layout(binding=1) uniform dof_config {
|
||||
int dof_disabled;
|
||||
float dof_max;
|
||||
float dof_point;
|
||||
};
|
||||
|
||||
layout(binding=0) uniform post_process_config {
|
||||
float exposure;
|
||||
float contrast;
|
||||
float saturation;
|
||||
float gamma;
|
||||
float tonemap;
|
||||
float vignette_intensity;
|
||||
float vignette_radius;
|
||||
float scanlines_intensity;
|
||||
float scanlines_density;
|
||||
float chromatic_aberration_intensity;
|
||||
float film_grain_intensity;
|
||||
float barrel_distortion_intensity;
|
||||
int lut_mode;
|
||||
float dither_intensity;
|
||||
float bloom_amount;
|
||||
};
|
||||
|
||||
vec3 aces(vec3 x) {
|
||||
const float a = 2.51;
|
||||
const float b = 0.03;
|
||||
const float c = 2.43;
|
||||
const float d = 0.59;
|
||||
const float e = 0.14;
|
||||
return clamp((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0);
|
||||
}
|
||||
|
||||
float rand(vec2 co){
|
||||
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
||||
}
|
||||
|
||||
float bayer8(vec2 pos) {
|
||||
ivec2 p = ivec2(pos) % 8;
|
||||
int index = p.x + p.y * 8;
|
||||
// Bayer 8x8 matrix, normalized to [0,1]
|
||||
const int bayer[64] = int[64](
|
||||
0, 32, 8, 40, 2, 34, 10, 42,
|
||||
48, 16, 56, 24, 50, 18, 58, 26,
|
||||
12, 44, 4, 36, 14, 46, 6, 38,
|
||||
60, 28, 52, 20, 62, 30, 54, 22,
|
||||
3, 35, 11, 43, 1, 33, 9, 41,
|
||||
51, 19, 59, 27, 49, 17, 57, 25,
|
||||
15, 47, 7, 39, 13, 45, 5, 37,
|
||||
63, 31, 55, 23, 61, 29, 53, 21
|
||||
);
|
||||
return (float(bayer[index]) / 64.0) - 0.5;
|
||||
}
|
||||
|
||||
vec3 texture_bicubic(texture2D tex, sampler smp, vec2 uv, vec2 tex_size) {
|
||||
vec2 pixel = uv * tex_size - 0.5;
|
||||
vec2 f = fract(pixel);
|
||||
vec2 pixel_floor = (floor(pixel) + 0.5) / tex_size;
|
||||
|
||||
vec2 w0 = f * (-0.5 + f * (1.0 - 0.5 * f));
|
||||
vec2 w1 = 1.0 + f * f * (-2.5 + 1.5 * f);
|
||||
vec2 w2 = f * (0.5 + f * (2.0 - 1.5 * f));
|
||||
vec2 w3 = f * f * (-0.5 + 0.5 * f);
|
||||
|
||||
vec2 w12 = w1 + w2;
|
||||
vec2 offset0 = -1.0 / tex_size;
|
||||
vec2 offset12 = (w2 / w12) / tex_size;
|
||||
vec2 offset3 = 2.0 / tex_size;
|
||||
|
||||
vec3 result =
|
||||
texture(sampler2D(tex, smp), pixel_floor + vec2(offset0.x, offset0.y)).rgb * w0.x * w0.y +
|
||||
texture(sampler2D(tex, smp), pixel_floor + vec2(offset12.x, offset0.y)).rgb * w12.x * w0.y +
|
||||
texture(sampler2D(tex, smp), pixel_floor + vec2(offset3.x, offset0.y)).rgb * w3.x * w0.y +
|
||||
texture(sampler2D(tex, smp), pixel_floor + vec2(offset0.x, offset12.y)).rgb * w0.x * w12.y +
|
||||
texture(sampler2D(tex, smp), pixel_floor + vec2(offset12.x, offset12.y)).rgb * w12.x * w12.y +
|
||||
texture(sampler2D(tex, smp), pixel_floor + vec2(offset3.x, offset12.y)).rgb * w3.x * w12.y +
|
||||
texture(sampler2D(tex, smp), pixel_floor + vec2(offset0.x, offset3.y)).rgb * w0.x * w3.y +
|
||||
texture(sampler2D(tex, smp), pixel_floor + vec2(offset12.x, offset3.y)).rgb * w12.x * w3.y +
|
||||
texture(sampler2D(tex, smp), pixel_floor + vec2(offset3.x, offset3.y)).rgb * w3.x * w3.y;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 distorted_texcoord = texcoord;
|
||||
float barrel_dist = length(texcoord - 0.5);
|
||||
distorted_texcoord -= 0.5;
|
||||
distorted_texcoord *= 1.0 + barrel_dist * barrel_distortion_intensity;
|
||||
distorted_texcoord += 0.5;
|
||||
|
||||
if (barrel_distortion_intensity > 0.0) {
|
||||
if (distorted_texcoord.x < 0.0 || distorted_texcoord.x > 1.0 || distorted_texcoord.y < 0.0 || distorted_texcoord.y > 1.0) {
|
||||
frag_color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vec3 sampled_color_hdr;
|
||||
if(chromatic_aberration_intensity > 0.01) {
|
||||
float r = texture(sampler2D(pptex, ppsmp), distorted_texcoord + vec2(chromatic_aberration_intensity, 0.0)).r;
|
||||
float g = texture(sampler2D(pptex, ppsmp), distorted_texcoord).g;
|
||||
float b = texture(sampler2D(pptex, ppsmp), distorted_texcoord - vec2(chromatic_aberration_intensity, 0.0)).b;
|
||||
sampled_color_hdr = vec3(r,g,b);
|
||||
} else {
|
||||
sampled_color_hdr = texture(sampler2D(pptex, ppsmp), distorted_texcoord).rgb;
|
||||
}
|
||||
|
||||
if(dof_disabled == 0) {
|
||||
float view_z = texture(sampler2D(pos_buf, pos_smp), distorted_texcoord).z;
|
||||
float depth = abs(view_z);
|
||||
float coc = smoothstep(0.0, 1.0, abs(depth - dof_point) / max(dof_max, 0.0001));
|
||||
vec3 dof_blurred = texture(sampler2D(dof_tex, dof_smp), distorted_texcoord).rgb;
|
||||
sampled_color_hdr = mix(sampled_color_hdr, dof_blurred, coc);
|
||||
}
|
||||
|
||||
vec3 bloom_color = texture(sampler2D(bloom_tex, bloom_smp), distorted_texcoord).rgb;
|
||||
vec3 color_hdr = (sampled_color_hdr + bloom_color * bloom_amount) * exposure;
|
||||
|
||||
vec3 color_ldr_linear;
|
||||
if(tonemap > 0.5) {
|
||||
color_ldr_linear = aces(color_hdr);
|
||||
} else {
|
||||
color_ldr_linear = color_hdr;
|
||||
}
|
||||
|
||||
color_ldr_linear = ((color_ldr_linear - 0.5f) * max(contrast, 0)) + 0.5f;
|
||||
|
||||
float lum = dot(color_ldr_linear, vec3(0.2125, 0.7154, 0.0721));
|
||||
vec3 brtColor = vec3(lum, lum, lum);
|
||||
color_ldr_linear = mix(brtColor, color_ldr_linear, saturation);
|
||||
|
||||
color_ldr_linear = clamp(color_ldr_linear, 0.0, 1.0);
|
||||
|
||||
if(dither_intensity > 0.0) {
|
||||
float dither = bayer8(gl_FragCoord.xy) * dither_intensity * (1.0 / 15.0);
|
||||
color_ldr_linear = clamp(color_ldr_linear + dither, 0.0, 1.0);
|
||||
}
|
||||
|
||||
if(lut_mode != 0) {
|
||||
if(lut_mode == 2) {
|
||||
float u = floor(color_ldr_linear.b * 15.0) * (1.0/16.0);
|
||||
u = u + floor(color_ldr_linear.r * 15.0) * (1.0/256.0);
|
||||
float v = floor(color_ldr_linear.g * 15.0) * (1.0 / 16.0);
|
||||
vec3 left = texture(sampler2D(lut, ppsmp), vec2(u, v)).rgb;
|
||||
color_ldr_linear = left;
|
||||
} else {
|
||||
float b_scaled = color_ldr_linear.b * 15.0;
|
||||
float b_floor = floor(b_scaled);
|
||||
float b_fract = b_scaled - b_floor; // fract(b_scaled)
|
||||
|
||||
float v = (color_ldr_linear.g * 15.0 + 0.5) / 16.0;
|
||||
|
||||
float u1 = (b_floor * 16.0 + color_ldr_linear.r * 15.0 + 0.5) / 256.0;
|
||||
vec3 sample1 = texture(sampler2D(lut, lut_linear), vec2(u1, v)).rgb;
|
||||
|
||||
float b_ceil = min(b_floor + 1.0, 15.0); // Clamp to last slice
|
||||
float u2 = (b_ceil * 16.0 + color_ldr_linear.r * 15.0 + 0.5) / 256.0;
|
||||
vec3 sample2 = texture(sampler2D(lut, lut_linear), vec2(u2, v)).rgb;
|
||||
|
||||
color_ldr_linear = mix(sample1, sample2, b_fract);
|
||||
}
|
||||
}
|
||||
|
||||
vec3 color_srgb = pow(color_ldr_linear, vec3(1.0 / gamma));
|
||||
|
||||
float vignette = 1.0 - smoothstep(0.0, vignette_radius, length(texcoord - vec2(0.5))) * vignette_intensity;
|
||||
color_srgb *= vignette;
|
||||
|
||||
float scanline = 1.0 - (sin(gl_FragCoord.y * scanlines_density) * 0.5 + 0.5) * scanlines_intensity;
|
||||
|
||||
color_srgb *= scanline;
|
||||
|
||||
float grain = (rand(texcoord) - 0.5) * film_grain_intensity;
|
||||
color_srgb += grain;
|
||||
|
||||
frag_color = vec4(clamp(color_srgb, 0.0, 1.0), 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program postprocess vs_pp fs_pp
|
||||
@ -1,102 +0,0 @@
|
||||
@vs vs_sh_deferred
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
out vec2 quad_uv;
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
quad_uv = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_sh_deferred
|
||||
|
||||
layout(binding=0) uniform texture2D gbuf_worldpos;
|
||||
layout(binding=1) uniform texture2D gbuf_norm;
|
||||
layout(binding=2) uniform texture2D sh_chunk;
|
||||
layout(binding=0) uniform sampler sh_smp;
|
||||
|
||||
layout(binding=0) uniform sh_deferred_params {
|
||||
mat4 inv_view;
|
||||
vec4 chunk_origin;
|
||||
vec4 ambient; // rgb = ambient color, a = ambient intensity
|
||||
};
|
||||
|
||||
in vec2 quad_uv;
|
||||
out vec4 frag_color;
|
||||
|
||||
const float PI = 3.14159265359;
|
||||
|
||||
vec3 sh_eval(ivec3 probe, vec3 N) {
|
||||
int base = probe.x * 3;
|
||||
int row = probe.z * 32 + probe.y;
|
||||
vec4 t0 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base, row), 0);
|
||||
vec4 t1 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base+1, row), 0);
|
||||
vec4 t2 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base+2, row), 0);
|
||||
float x = N.x, y = N.y, z = N.z;
|
||||
float r = 0.886227*t0.x + 1.023327*(t0.w*x + t0.y*y + t0.z*z);
|
||||
float g = 0.886227*t1.x + 1.023327*(t1.w*x + t1.y*y + t1.z*z);
|
||||
float b = 0.886227*t2.x + 1.023327*(t2.w*x + t2.y*y + t2.z*z);
|
||||
return max(vec3(r, g, b) / PI, vec3(0.0));
|
||||
}
|
||||
|
||||
float sh_probe_energy(ivec3 probe) {
|
||||
int base = probe.x * 3;
|
||||
int row = probe.z * 32 + probe.y;
|
||||
vec4 t0 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base, row), 0);
|
||||
vec4 t1 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base+1, row), 0);
|
||||
vec4 t2 = texelFetch(sampler2D(sh_chunk, sh_smp), ivec2(base+2, row), 0);
|
||||
return max(0.886227 * (t0.x + t1.x + t2.x), 0.0);
|
||||
}
|
||||
|
||||
vec3 sh_eval_trilinear(ivec3 p0, ivec3 p1, vec3 t, vec3 N) {
|
||||
float wx[2] = float[2](1.0 - t.x, t.x);
|
||||
float wy[2] = float[2](1.0 - t.y, t.y);
|
||||
float wz[2] = float[2](1.0 - t.z, t.z);
|
||||
vec3 result = vec3(0.0);
|
||||
vec3 unweighted = vec3(0.0);
|
||||
float total_w = 0.0;
|
||||
for (int iz = 0; iz < 2; iz++) {
|
||||
for (int iy = 0; iy < 2; iy++) {
|
||||
for (int ix = 0; ix < 2; ix++) {
|
||||
ivec3 probe = ivec3(
|
||||
ix == 0 ? p0.x : p1.x,
|
||||
iy == 0 ? p0.y : p1.y,
|
||||
iz == 0 ? p0.z : p1.z
|
||||
);
|
||||
vec3 sh = sh_eval(probe, N);
|
||||
float triw = wx[ix] * wy[iy] * wz[iz];
|
||||
float w = triw * sh_probe_energy(probe);
|
||||
result += sh * w;
|
||||
unweighted += sh * triw;
|
||||
total_w += w;
|
||||
}
|
||||
}
|
||||
}
|
||||
vec3 amb = ambient.rgb * ambient.a;
|
||||
return total_w > 0.001 ? result / total_w : max(unweighted, amb);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 wp_sample = texture(sampler2D(gbuf_worldpos, sh_smp), quad_uv);
|
||||
if (wp_sample.a < 0.5) discard;
|
||||
|
||||
vec3 world_pos = wp_sample.xyz;
|
||||
|
||||
vec3 cmin = chunk_origin.xyz;
|
||||
vec3 cmax = cmin + vec3(32.0);
|
||||
if (any(lessThan(world_pos, cmin)) || any(greaterThanEqual(world_pos, cmax))) discard;
|
||||
|
||||
vec3 view_norm = normalize(texture(sampler2D(gbuf_norm, sh_smp), quad_uv).xyz);
|
||||
vec3 world_norm = normalize(mat3(inv_view) * view_norm);
|
||||
|
||||
const float SH_PAD = 2.0;
|
||||
const float SH_SPACING = (32.0 + 2.0 * SH_PAD) / 32.0;
|
||||
vec3 probe_f = clamp((world_pos - (cmin - vec3(SH_PAD))) / SH_SPACING, vec3(0.0), vec3(31.0));
|
||||
ivec3 p0 = ivec3(floor(probe_f));
|
||||
ivec3 p1 = min(p0 + ivec3(1), ivec3(31));
|
||||
|
||||
frag_color = vec4(sh_eval_trilinear(p0, p1, fract(probe_f), world_norm), 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program sh_deferred vs_sh_deferred fs_sh_deferred
|
||||
@ -1,114 +0,0 @@
|
||||
@vs vs_sky
|
||||
|
||||
in vec4 position;
|
||||
|
||||
layout(binding=0) uniform sky_vs_params {
|
||||
mat4 mvp;
|
||||
};
|
||||
|
||||
|
||||
|
||||
out vec4 pos;
|
||||
|
||||
void main() {
|
||||
gl_Position = mvp * (vec4(position.xyz * 1000.0, 1.0));
|
||||
pos = position;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_sky
|
||||
|
||||
layout(binding=1) uniform sky_world_config {
|
||||
vec3 skyBase;
|
||||
vec3 skyTop;
|
||||
vec3 sunDisk;
|
||||
vec3 horizonHalo;
|
||||
vec3 sunHalo;
|
||||
vec3 sunLightColor;
|
||||
vec3 sunPosition;
|
||||
float sunIntensity;
|
||||
float skyIntensity;
|
||||
|
||||
int hasClouds;
|
||||
|
||||
float planeHeight;
|
||||
int animatePlaneHeight;
|
||||
vec3 waterColor;
|
||||
vec3 deepColor;
|
||||
|
||||
float time;
|
||||
};
|
||||
|
||||
in vec4 pos;
|
||||
out vec4 frag_color;
|
||||
|
||||
const float cirrus = 0.5;
|
||||
const float cumulus = 20.0;
|
||||
|
||||
// ----- SKY SHADER -------
|
||||
|
||||
float hash(float n)
|
||||
{
|
||||
return fract(sin(n) * 43758.5453123);
|
||||
}
|
||||
|
||||
float noise(vec3 x)
|
||||
{
|
||||
vec3 f = fract(x);
|
||||
float n = dot(floor(x), vec3(1.0, 157.0, 113.0));
|
||||
return mix(mix(mix(hash(n + 0.0), hash(n + 1.0), f.x),
|
||||
mix(hash(n + 157.0), hash(n + 158.0), f.x), f.y),
|
||||
mix(mix(hash(n + 113.0), hash(n + 114.0), f.x),
|
||||
mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z);
|
||||
}
|
||||
|
||||
vec3 sky(vec3 skypos, vec3 sunpos) {
|
||||
|
||||
vec3 sunCol = sunDisk.xyz;
|
||||
vec3 baseSky = skyBase.xyz;
|
||||
vec3 topSky = skyTop.xyz;
|
||||
|
||||
float sDist = dot(normalize(skypos), normalize(sunpos));
|
||||
|
||||
vec3 npos = normalize(skypos);
|
||||
|
||||
|
||||
vec3 skyGradient = mix(baseSky, topSky, clamp(skypos.y * 2.0, 0.0, 0.7));
|
||||
|
||||
// Sun local frame — used for both halo and disk
|
||||
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));
|
||||
|
||||
vec3 final = skyGradient;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Horizon halo
|
||||
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);
|
||||
return final;
|
||||
}
|
||||
|
||||
// --- END SKY ----
|
||||
|
||||
void main() {
|
||||
vec3 dir = normalize(pos.xyz);
|
||||
vec3 color = skyIntensity * sky(dir, sunPosition);
|
||||
frag_color = vec4(color, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program sky vs_sky fs_sky
|
||||
@ -1,69 +0,0 @@
|
||||
@vs vs_ssao
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 quad_uv;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
quad_uv = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_ssao
|
||||
|
||||
layout(binding=0) uniform texture2D g_position;
|
||||
layout(binding=1) uniform texture2D g_normal;
|
||||
layout(binding=2) uniform texture2D tex_noise;
|
||||
|
||||
layout(binding=0) uniform sampler ssao_smp;
|
||||
|
||||
layout(binding=1) uniform ssao_fs_params {
|
||||
mat4 projection;
|
||||
vec4 samples[64];
|
||||
float ssao_power;
|
||||
};
|
||||
|
||||
in vec2 quad_uv;
|
||||
out vec4 out_color;
|
||||
|
||||
void main() {
|
||||
vec3 frag_pos = texture(sampler2D(g_position, ssao_smp), quad_uv).xyz;
|
||||
vec3 normal = normalize(texture(sampler2D(g_normal, ssao_smp), quad_uv).rgb);
|
||||
vec2 noise_scale = vec2(1920.0/4.0, 1080.0/4.0); // @Incomplete: get screen size
|
||||
vec3 random_vec = normalize(texture(sampler2D(tex_noise, ssao_smp), quad_uv * noise_scale).xyz);
|
||||
|
||||
vec3 tangent = normalize(random_vec - normal * dot(random_vec, normal));
|
||||
vec3 bitangent = cross(normal, tangent);
|
||||
mat3 tbn = mat3(tangent, bitangent, normal);
|
||||
|
||||
float occlusion = 0.0;
|
||||
for(int i = 0; i < 16; i++) {
|
||||
vec3 sample_pos = tbn * samples[i].xyz;
|
||||
sample_pos = frag_pos + sample_pos * 0.5;
|
||||
|
||||
vec4 offset = vec4(sample_pos, 1.0);
|
||||
offset = projection * offset;
|
||||
offset.xyz /= offset.w;
|
||||
offset.xyz = offset.xyz * 0.5 + 0.5;
|
||||
|
||||
#if !SOKOL_GLSL
|
||||
offset.y = 1.0 - offset.y;
|
||||
#endif
|
||||
|
||||
float bias = 0.01;
|
||||
|
||||
vec3 psample = texture(sampler2D(g_position, ssao_smp), offset.xy).xyz;
|
||||
float occluded = 0.0;
|
||||
if(sample_pos.z + bias <= psample.z) { occluded = 1; } else { occluded = 0; }
|
||||
// float intensity = smoothstep(0.0, 1.0, 0.5 / abs(frag_pos.z - offset.z));
|
||||
// occluded *= intensity;
|
||||
occlusion += occluded;
|
||||
|
||||
}
|
||||
occlusion = 1.0 - (occlusion / 64.0);
|
||||
out_color = vec4(vec3(pow(occlusion, ssao_power)), 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program ssao vs_ssao fs_ssao
|
||||
@ -1,39 +0,0 @@
|
||||
@vs vs
|
||||
in vec4 position;
|
||||
in vec4 color0;
|
||||
in vec4 uv;
|
||||
|
||||
out vec4 color;
|
||||
out vec4 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = position;
|
||||
gl_Position.y += float(gl_InstanceIndex) * 0.1;
|
||||
color = color0;
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs
|
||||
in vec4 color;
|
||||
in vec4 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding = 0) uniform texture2D tex;
|
||||
layout(binding = 0) uniform sampler smp;
|
||||
|
||||
bool is_near(float a, float b) {
|
||||
return abs(a-b) < 0.01;
|
||||
}
|
||||
|
||||
void main() {
|
||||
if(is_near(texcoord.x, -4) && is_near(texcoord.y, -2)) {
|
||||
frag_color = color;
|
||||
} else {
|
||||
vec4 sampled = texture(sampler2D(tex, smp), texcoord.xy) * color;
|
||||
frag_color = sampled;
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@program triangle vs fs
|
||||
@ -1,288 +0,0 @@
|
||||
@vs vs_trile
|
||||
|
||||
in vec4 position;
|
||||
in vec4 normal;
|
||||
in vec4 centre;
|
||||
in vec4 instance;
|
||||
|
||||
layout(binding=0) uniform trile_vs_params {
|
||||
mat4 mvp;
|
||||
mat4 mvp_shadow;
|
||||
vec3 camera;
|
||||
};
|
||||
|
||||
out vec3 cam;
|
||||
out vec3 to_center;
|
||||
out vec3 vpos;
|
||||
out vec3 ipos;
|
||||
out vec4 fnormal;
|
||||
out vec3 orig_normal;
|
||||
out vec3 cv;
|
||||
|
||||
mat3 rot_x(float a) { float c=cos(a),s=sin(a); return mat3(1,0,0, 0,c,-s, 0,s,c); }
|
||||
mat3 rot_y(float a) { float c=cos(a),s=sin(a); return mat3(c,0,s, 0,1,0, -s,0,c); }
|
||||
mat3 rot_z(float a) { float c=cos(a),s=sin(a); return mat3(c,-s,0, s,c,0, 0,0,1); }
|
||||
|
||||
mat3 get_orientation_matrix(int ori) {
|
||||
int face = ori / 4;
|
||||
int twist = ori % 4;
|
||||
float PI = 3.1415927;
|
||||
mat3 base;
|
||||
if (face == 0) base = mat3(1.0);
|
||||
else if (face == 1) base = rot_x(PI);
|
||||
else if (face == 2) base = rot_z(-PI*0.5);
|
||||
else if (face == 3) base = rot_z( PI*0.5);
|
||||
else if (face == 4) base = rot_x( PI*0.5);
|
||||
else base = rot_x(-PI*0.5);
|
||||
return base * rot_y(float(twist) * PI * 0.5);
|
||||
}
|
||||
|
||||
void main() {
|
||||
int ori = int(round(instance.w));
|
||||
mat3 rot = get_orientation_matrix(ori);
|
||||
vec3 local = position.xyz - 0.5;
|
||||
vec3 rotated = rot * local + 0.5;
|
||||
|
||||
gl_Position = mvp * vec4(rotated + instance.xyz, 1.0);
|
||||
fnormal = vec4(rot * normal.xyz, 0.0);
|
||||
orig_normal = normal.xyz;
|
||||
to_center = centre.xyz - position.xyz;
|
||||
vpos = rotated + instance.xyz;
|
||||
ipos = position.xyz;
|
||||
cam = camera;
|
||||
cv = normalize(camera - vpos);
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_trile
|
||||
|
||||
layout(binding=1) uniform trile_world_config {
|
||||
vec3 skyBase;
|
||||
vec3 skyTop;
|
||||
vec3 sunDisk;
|
||||
vec3 horizonHalo;
|
||||
vec3 sunHalo;
|
||||
vec3 sunLightColor;
|
||||
vec3 sunPosition;
|
||||
float sunIntensity;
|
||||
float skyIntensity;
|
||||
|
||||
int hasClouds;
|
||||
|
||||
float planeHeight;
|
||||
int animatePlaneHeight;
|
||||
vec3 waterColor;
|
||||
vec3 deepColor;
|
||||
|
||||
float time;
|
||||
int hsv_lighting;
|
||||
};
|
||||
|
||||
in vec3 cam;
|
||||
in vec3 to_center;
|
||||
in vec3 vpos;
|
||||
in vec3 ipos;
|
||||
in vec4 fnormal;
|
||||
in vec3 orig_normal;
|
||||
in vec3 cv;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=3) uniform trile_fs_params {
|
||||
mat4 mvp_shadow;
|
||||
int is_reflection;
|
||||
int screen_h;
|
||||
int screen_w;
|
||||
float ambient_intensity;
|
||||
float emissive_scale;
|
||||
float indirect_diff_scale;
|
||||
float indirect_spec_scale;
|
||||
vec3 ambient_color;
|
||||
int is_preview;
|
||||
vec3 indirect_tint;
|
||||
int sh_enabled;
|
||||
float fog_start;
|
||||
float fog_end;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D triletex;
|
||||
layout(binding = 0) uniform sampler trilesmp;
|
||||
layout(binding = 1) uniform texture2D ssaotex;
|
||||
layout(binding = 2) uniform texture2D shadowtex;
|
||||
layout(binding = 2) uniform sampler shadowsmp;
|
||||
layout(binding = 3) uniform texture2D brdf_lut;
|
||||
layout(binding = 4) uniform texture2D sh_irradiance;
|
||||
layout(binding = 3) uniform sampler linsmp;
|
||||
|
||||
const float PI = 3.1415927;
|
||||
const float ROUGHNESS_SPEC_CUTOFF = 0.7;
|
||||
|
||||
const float cirrus = 0.5;
|
||||
|
||||
float hash(float n) {
|
||||
return fract(sin(n) * 43758.5453123);
|
||||
}
|
||||
|
||||
float noise(vec3 x) {
|
||||
vec3 f = fract(x);
|
||||
float n = dot(floor(x), vec3(1.0, 157.0, 113.0));
|
||||
return mix(mix(mix(hash(n + 0.0), hash(n + 1.0), f.x),
|
||||
mix(hash(n + 157.0), hash(n + 158.0), f.x), f.y),
|
||||
mix(mix(hash(n + 113.0), hash(n + 114.0), f.x),
|
||||
mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z);
|
||||
}
|
||||
|
||||
const mat3 fbm_m = mat3(0.0, 1.60, 1.20, -1.6, 0.72, -0.96, -1.2, -0.96, 1.28);
|
||||
|
||||
vec3 sky(vec3 skypos, vec3 sunpos) {
|
||||
vec3 npos = normalize(skypos);
|
||||
float sDist = dot(npos, normalize(sunpos));
|
||||
|
||||
vec3 skyGradient = mix(skyBase, skyTop, clamp(npos.y * 2.0, 0.0, 0.7));
|
||||
vec3 result = skyGradient;
|
||||
|
||||
result += sunHalo * clamp((sDist - 0.95) * 10.0, 0.0, 0.8) * 0.2;
|
||||
|
||||
if (sDist > 0.9999)
|
||||
result = sunDisk;
|
||||
|
||||
result += mix(horizonHalo, vec3(0.0), clamp(abs(npos.y) * 80.0, 0.0, 1.0)) * 0.1;
|
||||
return result;
|
||||
}
|
||||
|
||||
vec3 sky_reflect(vec3 R, vec3 sunpos) {
|
||||
if (R.y < 0.0) R = reflect(R, vec3(0.0, 1.0, 0.0));
|
||||
return sky(R, sunpos);
|
||||
}
|
||||
|
||||
float DistributionGGX(vec3 N, vec3 H, float roughness) {
|
||||
float a = roughness * roughness;
|
||||
float a2 = a * a;
|
||||
float NdotH = max(dot(N, H), 0.0);
|
||||
float denom = NdotH * NdotH * (a2 - 1.0) + 1.0;
|
||||
return a2 / (PI * denom * denom);
|
||||
}
|
||||
|
||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness) {
|
||||
float r = roughness + 1.0;
|
||||
float k = (r * r) / 8.0;
|
||||
float NdotV = max(dot(N, V), 0.0);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
float ggx1 = NdotL / (NdotL * (1.0 - k) + k);
|
||||
float ggx2 = NdotV / (NdotV * (1.0 - k) + k);
|
||||
return ggx1 * ggx2;
|
||||
}
|
||||
|
||||
vec3 fresnelSchlick(float cosTheta, vec3 F0) {
|
||||
return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
||||
}
|
||||
|
||||
vec3 FresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness) {
|
||||
return F0 + (max(vec3(1.0 - roughness), F0) - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
if (vpos.y < planeHeight - 0.01 && is_reflection == 1) discard;
|
||||
|
||||
vec3 sample_pos = ipos - orig_normal * 0.02;
|
||||
vec4 trixel_material;
|
||||
int maxSteps = is_reflection == 1 ? 1 : 3;
|
||||
for (int i = 0; i < maxSteps; i++) {
|
||||
ivec2 texel = ivec2(
|
||||
int(clamp(sample_pos.z, 0.0001, 0.99999) * 16.0),
|
||||
int(clamp(sample_pos.y, 0.0001, 0.99999) * 16.0) +
|
||||
int(clamp(sample_pos.x, 0.0001, 0.99999) * 16.0) * 16
|
||||
);
|
||||
trixel_material = texelFetch(sampler2D(triletex, trilesmp), texel, 0);
|
||||
if (dot(trixel_material, trixel_material) > 0.0001) break;
|
||||
sample_pos += to_center * 0.1;
|
||||
}
|
||||
|
||||
vec3 albedo = trixel_material.xyz;
|
||||
|
||||
int packed = int(round(trixel_material.w * 255.0));
|
||||
float emittance = 0.0;
|
||||
int roughnessInt = 0;
|
||||
float roughness = 0.0;
|
||||
float metallic = 0.0;
|
||||
|
||||
if ((packed & 0x1) != 0) {
|
||||
emittance = float((packed >> 1) & 0x7F) / 127.0;
|
||||
} else {
|
||||
roughnessInt = (packed >> 5) & 0x7;
|
||||
roughness = max(float(roughnessInt) / 7.0, 0.05);
|
||||
metallic = float((packed >> 3) & 0x3) / 3.0;
|
||||
}
|
||||
|
||||
vec3 absN = abs(fnormal.xyz);
|
||||
vec3 N;
|
||||
if (absN.x >= absN.y && absN.x >= absN.z) N = vec3(sign(fnormal.x), 0.0, 0.0);
|
||||
else if (absN.y >= absN.x && absN.y >= absN.z) N = vec3(0.0, sign(fnormal.y), 0.0);
|
||||
else N = vec3(0.0, 0.0, sign(fnormal.z));
|
||||
|
||||
if (is_reflection == 1) {
|
||||
vec3 L = normalize(sunPosition);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
frag_color = vec4(albedo * (NdotL * sunLightColor * sunIntensity + 0.1), 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 V = normalize(cam - vpos);
|
||||
vec3 L = normalize(sunPosition);
|
||||
vec3 H = normalize(V + L);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
float NdotV = max(dot(N, V), 0.0);
|
||||
float HdotV = max(dot(H, V), 0.0);
|
||||
|
||||
vec3 F0 = mix(vec3(0.04), albedo, metallic);
|
||||
vec3 F = fresnelSchlick(HdotV, F0);
|
||||
float NDF = DistributionGGX(N, H, roughness);
|
||||
float G = GeometrySmith(N, V, L, roughness);
|
||||
vec3 kD = (1.0 - F) * (1.0 - metallic);
|
||||
|
||||
vec4 light_proj = mvp_shadow * vec4(floor(vpos * 16.0) / 16.0, 1.0);
|
||||
vec3 light_ndc = light_proj.xyz / light_proj.w * 0.5 + 0.5;
|
||||
light_ndc.z -= 0.001;
|
||||
float shadow = texture(sampler2DShadow(shadowtex, shadowsmp), light_ndc);
|
||||
|
||||
vec3 direct_specular = (NDF * G * F) / (4.0 * NdotV * NdotL + 0.0001);
|
||||
vec3 light = shadow * (kD * albedo / PI + direct_specular) * NdotL * sunLightColor * sunIntensity;
|
||||
|
||||
float ssao = texture(sampler2D(ssaotex, linsmp),
|
||||
gl_FragCoord.xy / vec2(float(screen_w), float(screen_h))).r;
|
||||
vec3 emissive = albedo * emittance * emissive_scale;
|
||||
|
||||
vec3 Frough = FresnelSchlickRoughness(NdotV, F0, roughness);
|
||||
|
||||
if (roughness < ROUGHNESS_SPEC_CUTOFF) {
|
||||
vec3 R = reflect(-V, N);
|
||||
vec2 envBRDF = texture(sampler2D(brdf_lut, linsmp), vec2(NdotV, roughness)).rg;
|
||||
float specRoughFd = 1.0 - clamp((roughness - 0.5) / 0.3, 0.0, 1.0);
|
||||
light += sky_reflect(R, sunPosition) * (Frough * envBRDF.x + envBRDF.y)
|
||||
* indirect_spec_scale * specRoughFd;
|
||||
}
|
||||
|
||||
vec3 indirectDiff;
|
||||
if (sh_enabled == 1) {
|
||||
vec2 sh_uv = gl_FragCoord.xy / vec2(float(screen_w), float(screen_h));
|
||||
indirectDiff = texture(sampler2D(sh_irradiance, linsmp), sh_uv).rgb * indirect_tint;
|
||||
} else {
|
||||
indirectDiff = ambient_color * ambient_intensity;
|
||||
}
|
||||
|
||||
light += (1.0 - Frough) * (1.0 - metallic) * indirectDiff / PI * albedo * ssao * indirect_diff_scale;
|
||||
|
||||
vec3 final_color = light + emissive;
|
||||
final_color = mix(deepColor, final_color, smoothstep(0.0, planeHeight, vpos.y));
|
||||
|
||||
float fog_dist = length(vpos - cam);
|
||||
float fog_factor = smoothstep(fog_start, fog_end, fog_dist);
|
||||
final_color = mix(final_color, skyBase, fog_factor);
|
||||
|
||||
frag_color = vec4(final_color, 1.0);
|
||||
|
||||
if (is_preview == 1) frag_color.rgb = mix(frag_color.rgb, vec3(0.3, 0.7, 1.0), 0.5);
|
||||
else if (is_preview == 2) frag_color.rgb = mix(frag_color.rgb, vec3(1.0, 0.3, 0.2), 0.5);
|
||||
}
|
||||
@end
|
||||
|
||||
@program trile vs_trile fs_trile
|
||||
@ -1,97 +0,0 @@
|
||||
@vs vs_trile_lod
|
||||
|
||||
in vec4 position;
|
||||
in vec4 normal;
|
||||
in vec4 color;
|
||||
in vec4 instance;
|
||||
|
||||
layout(binding=0) uniform trile_lod_vs_params {
|
||||
mat4 mvp;
|
||||
vec3 camera;
|
||||
};
|
||||
|
||||
out vec3 vpos;
|
||||
out vec3 cam;
|
||||
out vec3 vcolor;
|
||||
out vec3 vnorm;
|
||||
|
||||
mat3 rot_x(float a) { float c=cos(a),s=sin(a); return mat3(1,0,0, 0,c,-s, 0,s,c); }
|
||||
mat3 rot_y(float a) { float c=cos(a),s=sin(a); return mat3(c,0,s, 0,1,0, -s,0,c); }
|
||||
mat3 rot_z(float a) { float c=cos(a),s=sin(a); return mat3(c,-s,0, s,c,0, 0,0,1); }
|
||||
|
||||
mat3 get_orientation_matrix(int ori) {
|
||||
int face = ori / 4;
|
||||
int twist = ori % 4;
|
||||
float PI = 3.1415927;
|
||||
mat3 base;
|
||||
if (face == 0) base = mat3(1.0);
|
||||
else if (face == 1) base = rot_x(PI);
|
||||
else if (face == 2) base = rot_z(-PI*0.5);
|
||||
else if (face == 3) base = rot_z( PI*0.5);
|
||||
else if (face == 4) base = rot_x( PI*0.5);
|
||||
else base = rot_x(-PI*0.5);
|
||||
return base * rot_y(float(twist) * PI * 0.5);
|
||||
}
|
||||
|
||||
void main() {
|
||||
int ori = int(round(instance.w));
|
||||
mat3 rot = get_orientation_matrix(ori);
|
||||
vec3 local = position.xyz - 0.5;
|
||||
vec3 rotated = rot * local + 0.5;
|
||||
|
||||
gl_Position = mvp * vec4(rotated + instance.xyz, 1.0);
|
||||
vpos = rotated + instance.xyz;
|
||||
cam = camera;
|
||||
vcolor = color.xyz;
|
||||
vnorm = rot * normal.xyz;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_trile_lod
|
||||
|
||||
layout(binding=1) uniform trile_lod_fs_params {
|
||||
vec3 skyBase;
|
||||
vec3 sunPosition;
|
||||
vec3 sunLightColor;
|
||||
float sunIntensity;
|
||||
vec3 ambient_color;
|
||||
float ambient_intensity;
|
||||
float planeHeight;
|
||||
vec3 deepColor;
|
||||
int is_reflection;
|
||||
float fog_start;
|
||||
float fog_end;
|
||||
};
|
||||
|
||||
in vec3 vpos;
|
||||
in vec3 cam;
|
||||
in vec3 vcolor;
|
||||
in vec3 vnorm;
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
if (vpos.y < planeHeight - 0.01 && is_reflection == 1) discard;
|
||||
|
||||
const float PI = 3.1415927;
|
||||
vec3 N = normalize(vnorm);
|
||||
vec3 L = normalize(sunPosition);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
|
||||
vec3 lit;
|
||||
if (is_reflection == 1) {
|
||||
lit = vcolor * (NdotL * sunLightColor * sunIntensity + 0.1) / PI;
|
||||
} else {
|
||||
lit = vcolor * (NdotL * sunLightColor * sunIntensity + ambient_color * ambient_intensity) / PI;
|
||||
}
|
||||
|
||||
vec3 final_color = mix(deepColor, lit, smoothstep(0.0, planeHeight, vpos.y));
|
||||
|
||||
float fog_dist = length(vpos - cam);
|
||||
float fog_factor = smoothstep(fog_start, fog_end, fog_dist);
|
||||
final_color = mix(final_color, skyBase, fog_factor);
|
||||
|
||||
frag_color = vec4(final_color, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program trile_lod vs_trile_lod fs_trile_lod
|
||||
@ -1,346 +0,0 @@
|
||||
@vs vs_trile_rdm
|
||||
|
||||
in vec4 position;
|
||||
in vec4 normal;
|
||||
in vec4 centre;
|
||||
in vec4 instance;
|
||||
|
||||
layout(binding=0) uniform trile_rdm_vs_params {
|
||||
mat4 mvp;
|
||||
mat4 mvp_shadow;
|
||||
vec3 camera;
|
||||
};
|
||||
|
||||
out vec3 cam;
|
||||
out vec3 to_center;
|
||||
out vec3 vpos;
|
||||
out vec3 ipos;
|
||||
out vec4 fnormal;
|
||||
out vec3 orig_normal;
|
||||
out vec3 trileCenter;
|
||||
out vec3 cv;
|
||||
|
||||
mat3 rot_x(float a) { float c=cos(a),s=sin(a); return mat3(1,0,0, 0,c,-s, 0,s,c); }
|
||||
mat3 rot_y(float a) { float c=cos(a),s=sin(a); return mat3(c,0,s, 0,1,0, -s,0,c); }
|
||||
mat3 rot_z(float a) { float c=cos(a),s=sin(a); return mat3(c,-s,0, s,c,0, 0,0,1); }
|
||||
|
||||
mat3 get_orientation_matrix(int ori) {
|
||||
int face = ori / 4;
|
||||
int twist = ori % 4;
|
||||
float PI = 3.1415927;
|
||||
mat3 base;
|
||||
if (face == 0) base = mat3(1.0);
|
||||
else if (face == 1) base = rot_x(PI);
|
||||
else if (face == 2) base = rot_z(-PI*0.5);
|
||||
else if (face == 3) base = rot_z( PI*0.5);
|
||||
else if (face == 4) base = rot_x( PI*0.5);
|
||||
else base = rot_x(-PI*0.5);
|
||||
return base * rot_y(float(twist) * PI * 0.5);
|
||||
}
|
||||
|
||||
void main() {
|
||||
int ori = int(round(instance.w));
|
||||
mat3 rot = get_orientation_matrix(ori);
|
||||
vec3 local = position.xyz - 0.5;
|
||||
vec3 rotated = rot * local + 0.5;
|
||||
|
||||
gl_Position = mvp * vec4(rotated + instance.xyz, 1.0);
|
||||
fnormal = vec4(rot * normal.xyz, 0.0);
|
||||
orig_normal = normal.xyz;
|
||||
to_center = centre.xyz - position.xyz;
|
||||
vpos = rotated + instance.xyz;
|
||||
ipos = position.xyz;
|
||||
cam = camera;
|
||||
cv = normalize(camera - vpos);
|
||||
trileCenter = instance.xyz + vec3(0.5);
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_trile_rdm
|
||||
|
||||
layout(binding=1) uniform trile_rdm_world_config {
|
||||
vec3 skyBase;
|
||||
vec3 skyTop;
|
||||
vec3 sunDisk;
|
||||
vec3 horizonHalo;
|
||||
vec3 sunHalo;
|
||||
vec3 sunLightColor;
|
||||
vec3 sunPosition;
|
||||
float sunIntensity;
|
||||
float skyIntensity;
|
||||
|
||||
int hasClouds;
|
||||
|
||||
float planeHeight;
|
||||
int animatePlaneHeight;
|
||||
vec3 waterColor;
|
||||
vec3 deepColor;
|
||||
|
||||
float time;
|
||||
int hsv_lighting;
|
||||
};
|
||||
|
||||
in vec3 cam;
|
||||
in vec3 to_center;
|
||||
in vec3 vpos;
|
||||
in vec3 ipos;
|
||||
in vec4 fnormal;
|
||||
in vec3 orig_normal;
|
||||
in vec3 trileCenter;
|
||||
in vec3 cv;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding=3) uniform trile_rdm_fs_params {
|
||||
mat4 mvp_shadow;
|
||||
int is_reflection;
|
||||
int screen_h;
|
||||
int screen_w;
|
||||
float ambient_intensity;
|
||||
float emissive_scale;
|
||||
float indirect_diff_scale;
|
||||
float indirect_spec_scale;
|
||||
vec3 ambient_color;
|
||||
int is_preview;
|
||||
vec3 indirect_tint;
|
||||
int sh_enabled;
|
||||
vec4 atlas_rect;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform texture2D rdm_triletex;
|
||||
layout(binding = 0) uniform sampler rdm_trilesmp;
|
||||
layout(binding = 1) uniform texture2D rdm_ssaotex;
|
||||
layout(binding = 2) uniform texture2D rdm_shadowtex;
|
||||
layout(binding = 2) uniform sampler rdm_shadowsmp;
|
||||
layout(binding = 3) uniform texture2D rdm_brdflut;
|
||||
layout(binding = 4) uniform texture2D rdm_shirradiance;
|
||||
layout(binding = 5) uniform texture2D rdm_atlas;
|
||||
layout(binding = 3) uniform sampler rdm_linsmp;
|
||||
|
||||
const float PI = 3.1415927;
|
||||
const float ROUGHNESS_SPEC_CUTOFF = 0.7;
|
||||
const float ROUGHNESS_RAYMARCH_MAX = 0.2;
|
||||
|
||||
vec3 sky(vec3 skypos, vec3 sunpos) {
|
||||
vec3 npos = normalize(skypos);
|
||||
float sDist = dot(npos, normalize(sunpos));
|
||||
|
||||
vec3 skyGradient = mix(skyBase, skyTop, clamp(npos.y * 2.0, 0.0, 0.7));
|
||||
vec3 result = skyGradient;
|
||||
|
||||
result += sunHalo * clamp((sDist - 0.95) * 10.0, 0.0, 0.8) * 0.2;
|
||||
|
||||
if (sDist > 0.9999)
|
||||
result = sunDisk;
|
||||
|
||||
result += mix(horizonHalo, vec3(0.0), clamp(abs(npos.y) * 80.0, 0.0, 1.0)) * 0.1;
|
||||
return result;
|
||||
}
|
||||
|
||||
vec3 sky_reflect(vec3 R, vec3 sunpos) {
|
||||
if (R.y < 0.0) R = reflect(R, vec3(0.0, 1.0, 0.0));
|
||||
return sky(R, sunpos);
|
||||
}
|
||||
|
||||
float DistributionGGX(vec3 N, vec3 H, float roughness) {
|
||||
float a = roughness * roughness;
|
||||
float a2 = a * a;
|
||||
float NdotH = max(dot(N, H), 0.0);
|
||||
float denom = NdotH * NdotH * (a2 - 1.0) + 1.0;
|
||||
return a2 / (PI * denom * denom);
|
||||
}
|
||||
|
||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness) {
|
||||
float r = roughness + 1.0;
|
||||
float k = (r * r) / 8.0;
|
||||
float NdotV = max(dot(N, V), 0.0);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
float ggx1 = NdotL / (NdotL * (1.0 - k) + k);
|
||||
float ggx2 = NdotV / (NdotV * (1.0 - k) + k);
|
||||
return ggx1 * ggx2;
|
||||
}
|
||||
|
||||
vec3 fresnelSchlick(float cosTheta, vec3 F0) {
|
||||
return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
||||
}
|
||||
|
||||
vec3 FresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness) {
|
||||
return F0 + (max(vec3(1.0 - roughness), F0) - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
||||
}
|
||||
|
||||
vec2 rdm_hemioct(vec3 v, int face) {
|
||||
vec3 vc = v;
|
||||
if (face / 2 == 0) { vc.z = v.y; vc.y = v.z; }
|
||||
if (face / 2 == 2) { vc.z = v.x; vc.x = v.z; }
|
||||
if (face % 2 == 1) { vc.z *= -1.0; }
|
||||
|
||||
vec2 p = vc.xy * (1.0 / (abs(vc.x) + abs(vc.y) + vc.z));
|
||||
return vec2(p.x + p.y, p.x - p.y) * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
int rdm_face_from_normal(vec3 N) {
|
||||
vec3 a = abs(N);
|
||||
if (a.y >= a.x && a.y >= a.z) return N.y >= 0.0 ? 0 : 1;
|
||||
if (a.z >= a.x && a.z >= a.y) return N.z >= 0.0 ? 2 : 3;
|
||||
return N.x >= 0.0 ? 4 : 5;
|
||||
}
|
||||
|
||||
ivec2 rdm_face_offset(vec4 rect, int face, int rdmSize, ivec2 atlasSize) {
|
||||
int col = face % 2;
|
||||
int row = face / 2;
|
||||
return ivec2(int(rect.x * float(atlasSize.x)) + col * rdmSize,
|
||||
int(rect.y * float(atlasSize.y)) + row * rdmSize);
|
||||
}
|
||||
|
||||
vec3 rdm_spec_raymarch(vec3 N, vec3 V, vec3 diff, int face, ivec2 faceOffset, int rdmSize, vec2 atlasInvSize) {
|
||||
vec3 reflected = reflect(V, N);
|
||||
float maxDist = 20.0;
|
||||
int steps = 40;
|
||||
float stepSize = maxDist / float(steps);
|
||||
|
||||
for (int i = 0; i < steps; i++) {
|
||||
float t = stepSize * float(i + 1);
|
||||
vec3 samplePos = diff + t * reflected;
|
||||
if (dot(samplePos, N) < 0.0) continue;
|
||||
|
||||
vec3 dir = normalize(samplePos);
|
||||
vec2 hemiUV = rdm_hemioct(dir, face);
|
||||
vec2 texCoord = (vec2(faceOffset) + hemiUV * float(rdmSize)) * atlasInvSize;
|
||||
vec4 s = texture(sampler2D(rdm_atlas, rdm_linsmp), texCoord, 0);
|
||||
|
||||
float dist = length(samplePos);
|
||||
if (s.a > 0.0 && s.a < dist && s.a + stepSize > dist)
|
||||
return s.rgb;
|
||||
}
|
||||
|
||||
return sky_reflect(reflected, sunPosition);
|
||||
}
|
||||
|
||||
vec3 rdm_spec_single(vec3 N, vec3 V, vec3 diff, int face, ivec2 faceOffset, int rdmSize, vec2 atlasInvSize) {
|
||||
vec3 reflected = reflect(V, N);
|
||||
vec3 sampleDir = normalize(diff + 2.0 * reflected);
|
||||
vec2 hemiUV = rdm_hemioct(sampleDir, face);
|
||||
vec2 texCoord = (vec2(faceOffset) + hemiUV * float(rdmSize)) * atlasInvSize;
|
||||
return texture(sampler2D(rdm_atlas, rdm_linsmp), texCoord).rgb;
|
||||
}
|
||||
|
||||
void main() {
|
||||
if (vpos.y < planeHeight - 0.01 && is_reflection == 1) discard;
|
||||
|
||||
vec3 sample_pos = ipos - orig_normal * 0.02;
|
||||
vec4 trixel_material;
|
||||
int maxSteps = is_reflection == 1 ? 1 : 3;
|
||||
for (int i = 0; i < maxSteps; i++) {
|
||||
ivec2 texel = ivec2(
|
||||
int(clamp(sample_pos.z, 0.0001, 0.99999) * 16.0),
|
||||
int(clamp(sample_pos.y, 0.0001, 0.99999) * 16.0) +
|
||||
int(clamp(sample_pos.x, 0.0001, 0.99999) * 16.0) * 16
|
||||
);
|
||||
trixel_material = texelFetch(sampler2D(rdm_triletex, rdm_trilesmp), texel, 0);
|
||||
if (dot(trixel_material, trixel_material) > 0.0001) break;
|
||||
sample_pos += to_center * 0.1;
|
||||
}
|
||||
|
||||
vec3 albedo = trixel_material.xyz;
|
||||
|
||||
int packed = int(round(trixel_material.w * 255.0));
|
||||
float emittance = 0.0;
|
||||
int roughnessInt = 0;
|
||||
float roughness = 0.0;
|
||||
float metallic = 0.0;
|
||||
|
||||
if ((packed & 0x1) != 0) {
|
||||
emittance = float((packed >> 1) & 0x7F) / 127.0;
|
||||
} else {
|
||||
roughnessInt = (packed >> 5) & 0x7;
|
||||
roughness = max(float(roughnessInt) / 7.0, 0.05);
|
||||
metallic = float((packed >> 3) & 0x3) / 3.0;
|
||||
}
|
||||
|
||||
vec3 absN = abs(fnormal.xyz);
|
||||
vec3 N;
|
||||
if (absN.x >= absN.y && absN.x >= absN.z) N = vec3(sign(fnormal.x), 0.0, 0.0);
|
||||
else if (absN.y >= absN.x && absN.y >= absN.z) N = vec3(0.0, sign(fnormal.y), 0.0);
|
||||
else N = vec3(0.0, 0.0, sign(fnormal.z));
|
||||
|
||||
if (is_reflection == 1) {
|
||||
vec3 L = normalize(sunPosition);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
frag_color = vec4(albedo * (NdotL * sunLightColor * sunIntensity + 0.1), 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 V = normalize(cam - vpos);
|
||||
vec3 L = normalize(sunPosition);
|
||||
vec3 H = normalize(V + L);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
float NdotV = max(dot(N, V), 0.0);
|
||||
float HdotV = max(dot(H, V), 0.0);
|
||||
|
||||
vec3 F0 = mix(vec3(0.04), albedo, metallic);
|
||||
vec3 F = fresnelSchlick(HdotV, F0);
|
||||
float NDF = DistributionGGX(N, H, roughness);
|
||||
float G = GeometrySmith(N, V, L, roughness);
|
||||
vec3 kD = (1.0 - F) * (1.0 - metallic);
|
||||
|
||||
vec4 light_proj = mvp_shadow * vec4(floor(vpos * 16.0) / 16.0, 1.0);
|
||||
vec3 light_ndc = light_proj.xyz / light_proj.w * 0.5 + 0.5;
|
||||
light_ndc.z -= 0.001;
|
||||
float shadow = texture(sampler2DShadow(rdm_shadowtex, rdm_shadowsmp), light_ndc);
|
||||
|
||||
vec3 direct_specular = (NDF * G * F) / (4.0 * NdotV * NdotL + 0.0001);
|
||||
vec3 light = shadow * (kD * albedo / PI + direct_specular) * NdotL * sunLightColor * sunIntensity;
|
||||
|
||||
float ssao = texture(sampler2D(rdm_ssaotex, rdm_linsmp),
|
||||
gl_FragCoord.xy / vec2(float(screen_w), float(screen_h))).r;
|
||||
vec3 emissive = albedo * emittance * emissive_scale;
|
||||
|
||||
vec3 Frough = FresnelSchlickRoughness(NdotV, F0, roughness);
|
||||
|
||||
vec3 hemispherePos = trileCenter + N * 0.49;
|
||||
vec3 diff = vpos - hemispherePos;
|
||||
|
||||
if (roughnessInt <= 1) {
|
||||
int face = rdm_face_from_normal(N);
|
||||
ivec2 atlasSize = textureSize(sampler2D(rdm_atlas, rdm_linsmp), 0);
|
||||
vec2 atlasInvSz = 1.0 / vec2(atlasSize);
|
||||
int rdmSize = int(atlas_rect.z * float(atlasSize.x)) / 2;
|
||||
ivec2 fOff = rdm_face_offset(atlas_rect, face, rdmSize, atlasSize);
|
||||
|
||||
vec3 indirectSpec = roughness < ROUGHNESS_RAYMARCH_MAX
|
||||
? rdm_spec_raymarch(N, -cv, diff, face, fOff, rdmSize, atlasInvSz)
|
||||
: rdm_spec_single (N, -cv, diff, face, fOff, rdmSize, atlasInvSz);
|
||||
|
||||
vec2 envBRDF = texture(sampler2D(rdm_brdflut, rdm_linsmp), vec2(NdotV, roughness)).rg;
|
||||
float roughnessBell = 1.0 - 0.7 * sin(roughness * PI);
|
||||
float grazingSuppr = 1.0 - 0.9 * roughness * sin(roughness * PI) * pow(1.0 - NdotV, 2.0);
|
||||
float specRoughFade = 1.0 - clamp((roughness - 0.5) / 0.3, 0.0, 1.0);
|
||||
|
||||
light += indirectSpec * (Frough * envBRDF.x + envBRDF.y)
|
||||
* indirect_spec_scale * roughnessBell * grazingSuppr * specRoughFade;
|
||||
} else if (roughness < ROUGHNESS_SPEC_CUTOFF) {
|
||||
vec3 R = reflect(-V, N);
|
||||
vec2 envBRDF = texture(sampler2D(rdm_brdflut, rdm_linsmp), vec2(NdotV, roughness)).rg;
|
||||
float specRoughFd = 1.0 - clamp((roughness - 0.5) / 0.3, 0.0, 1.0);
|
||||
light += sky_reflect(R, sunPosition) * (Frough * envBRDF.x + envBRDF.y)
|
||||
* indirect_spec_scale * specRoughFd;
|
||||
}
|
||||
|
||||
vec3 indirectDiff;
|
||||
if (sh_enabled == 1) {
|
||||
vec2 sh_uv = gl_FragCoord.xy / vec2(float(screen_w), float(screen_h));
|
||||
indirectDiff = texture(sampler2D(rdm_shirradiance, rdm_linsmp), sh_uv).rgb * indirect_tint;
|
||||
} else {
|
||||
indirectDiff = ambient_color * ambient_intensity;
|
||||
}
|
||||
|
||||
light += (1.0 - Frough) * (1.0 - metallic) * indirectDiff / PI * albedo * ssao * indirect_diff_scale;
|
||||
|
||||
vec3 final_color = light + emissive;
|
||||
frag_color = vec4(mix(deepColor, final_color, smoothstep(0.0, planeHeight, vpos.y)), 1.0);
|
||||
|
||||
if (is_preview == 1) frag_color.rgb = mix(frag_color.rgb, vec3(0.3, 0.7, 1.0), 0.5);
|
||||
else if (is_preview == 2) frag_color.rgb = mix(frag_color.rgb, vec3(1.0, 0.3, 0.2), 0.5);
|
||||
}
|
||||
@end
|
||||
|
||||
@program trile_rdm vs_trile_rdm fs_trile_rdm
|
||||
@ -1,46 +0,0 @@
|
||||
@vs vs_trile_shadow
|
||||
|
||||
layout(location=0) in vec4 position;
|
||||
layout(location=1) in vec4 normal; // same slot as shader_trile; not used
|
||||
layout(location=2) in vec4 centre; // same slot as shader_trile; not used
|
||||
layout(location=3) in vec4 instance; // xyz=world_pos, w=orientation
|
||||
|
||||
layout(binding=0) uniform trile_shadow_vs_params {
|
||||
mat4 mvp;
|
||||
};
|
||||
|
||||
mat3 rot_x(float a) { float c=cos(a),s=sin(a); return mat3(1,0,0, 0,c,-s, 0,s,c); }
|
||||
mat3 rot_z(float a) { float c=cos(a),s=sin(a); return mat3(c,-s,0, s,c,0, 0,0,1); }
|
||||
mat3 rot_y(float a) { float c=cos(a),s=sin(a); return mat3(c,0,s, 0,1,0, -s,0,c); }
|
||||
|
||||
mat3 get_orientation_matrix(int ori) {
|
||||
int face = ori / 4;
|
||||
int twist = ori % 4;
|
||||
float PI = 3.1415927;
|
||||
mat3 base;
|
||||
if (face == 0) base = mat3(1.0);
|
||||
else if (face == 1) base = rot_x(PI);
|
||||
else if (face == 2) base = rot_z(-PI*0.5);
|
||||
else if (face == 3) base = rot_z( PI*0.5);
|
||||
else if (face == 4) base = rot_x( PI*0.5);
|
||||
else base = rot_x(-PI*0.5);
|
||||
return base * rot_y(float(twist) * PI * 0.5);
|
||||
}
|
||||
|
||||
void main() {
|
||||
int ori = int(round(instance.w));
|
||||
mat3 rot = get_orientation_matrix(ori);
|
||||
vec3 local = position.xyz - 0.5;
|
||||
vec3 rotated = rot * local + 0.5;
|
||||
gl_Position = mvp * vec4(rotated + instance.xyz, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_trile_shadow
|
||||
out vec4 frag_color;
|
||||
void main() {
|
||||
frag_color = vec4(0.0);
|
||||
}
|
||||
@end
|
||||
|
||||
@program trile_shadow vs_trile_shadow fs_trile_shadow
|
||||
@ -1,172 +0,0 @@
|
||||
@vs vs_trixel
|
||||
|
||||
in vec4 position;
|
||||
in vec4 normal;
|
||||
in vec4 inst;
|
||||
in vec4 inst_col;
|
||||
|
||||
layout(binding=0) uniform vs_params {
|
||||
mat4 mvp;
|
||||
vec3 camera;
|
||||
vec3 world_offset;
|
||||
mat4 tile_rotation;
|
||||
};
|
||||
|
||||
out vec4 color;
|
||||
out vec4 fnormal;
|
||||
out vec4 pos;
|
||||
out vec3 cam;
|
||||
out float vtrixel_state;
|
||||
|
||||
void main() {
|
||||
vec3 instancepos = inst.xyz;
|
||||
vec3 local = position.xyz + instancepos;
|
||||
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;
|
||||
pos = gl_Position;
|
||||
cam = camera;
|
||||
vtrixel_state = inst.w;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_trixel
|
||||
|
||||
layout(binding=2) uniform trixel_fs_params {
|
||||
int view_mode;
|
||||
float brightness;
|
||||
};
|
||||
|
||||
layout(binding=1) uniform trixel_world_config {
|
||||
vec3 skyBase;
|
||||
vec3 skyTop;
|
||||
vec3 sunDisk;
|
||||
vec3 horizonHalo;
|
||||
vec3 sunHalo;
|
||||
vec3 sunLightColor;
|
||||
vec3 sunPosition;
|
||||
float sunIntensity;
|
||||
float skyIntensity;
|
||||
|
||||
int hasClouds;
|
||||
|
||||
float planeHeight;
|
||||
int animatePlaneHeight;
|
||||
vec3 waterColor;
|
||||
vec3 deepColor;
|
||||
|
||||
float time;
|
||||
};
|
||||
|
||||
in vec4 color;
|
||||
in vec4 fnormal;
|
||||
in vec4 pos;
|
||||
in vec3 cam;
|
||||
in float vtrixel_state;
|
||||
out vec4 frag_color;
|
||||
|
||||
const float PI = 3.1412854;
|
||||
|
||||
|
||||
float DistributionGGX(vec3 N, vec3 H, float roughness) {
|
||||
float a = roughness*roughness;
|
||||
float a2 = a*a;
|
||||
float NdotH = max(dot(N, H), 0.0);
|
||||
float NdotH2 = NdotH*NdotH;
|
||||
float num = a2;
|
||||
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
|
||||
denom = PI * denom * denom;
|
||||
return num / denom;
|
||||
}
|
||||
|
||||
float GeometrySchlickGGX(float NdotV, float roughness) {
|
||||
float r = (roughness + 1.0);
|
||||
float k = (r*r) / 8.0;
|
||||
float num = NdotV;
|
||||
float denom = NdotV * (1.0 - k) + k;
|
||||
return num / denom;
|
||||
}
|
||||
|
||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness) {
|
||||
float NdotV = max(dot(N, V), 0.0);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
|
||||
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
|
||||
return ggx1 * ggx2;
|
||||
}
|
||||
|
||||
|
||||
vec3 fresnelSchlick(float cosTheta, vec3 F0) {
|
||||
return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Get the material info.
|
||||
vec3 albedo = color.xyz;
|
||||
int packedMaterial = int(round(color.w*255.0));
|
||||
float emittance = 0.0;
|
||||
int roughnessInt = 0;
|
||||
float roughness = 0.05;
|
||||
float metallic = 0.0;
|
||||
if ((packedMaterial & 0x1) != 0) {
|
||||
emittance = float((packedMaterial >> 1) & 0x7F) / 127.0;
|
||||
} else {
|
||||
roughnessInt = (packedMaterial >> 5) & 0x7;
|
||||
roughness = max(float(roughnessInt) / 7.0, 0.05);
|
||||
metallic = float((packedMaterial >> 3) & 0x3) / 3.0;
|
||||
}
|
||||
|
||||
// Ambient light.
|
||||
vec3 light = 0.3 * albedo;
|
||||
|
||||
// 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);
|
||||
vec3 L = normalize(sunPosition);
|
||||
vec3 H = normalize(V + L);
|
||||
|
||||
vec3 F0 = vec3(0.04);
|
||||
F0 = mix(F0, albedo, metallic);
|
||||
vec3 F = fresnelSchlick(max(dot(H,V), 0.0), F0);
|
||||
float NDF = DistributionGGX(N, H, roughness);
|
||||
float G = GeometrySmith(N, V, L, roughness);
|
||||
vec3 numerator = NDF * G * F;
|
||||
float denominator = 4.0 * max(dot(N, V), 0.0) * max(dot(N, L), 0.0) + 0.0001;
|
||||
vec3 specular = numerator / denominator;
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
vec3 kD = vec3(1.0) - F;
|
||||
kD *= 1.0 - metallic;
|
||||
|
||||
light += (kD * albedo / PI + specular) * NdotL * vec3(1.0, 1.0, 1.0);
|
||||
|
||||
if (view_mode == 1) {
|
||||
// Normals: map face normals to RGB so each axis gets a distinct color.
|
||||
frag_color = vec4(N * 0.5 + 0.5, 1.0);
|
||||
} else if (view_mode == 2) {
|
||||
// Albedo: simple diffuse shading, no specular/roughness/metallic eval.
|
||||
float diffuse = max(dot(N, L), 0.0) * 0.6 + 0.4;
|
||||
frag_color = vec4(albedo * diffuse + emissive, 1.0);
|
||||
} else if (view_mode == 3) {
|
||||
// Normal+Albedo: normal color used as a per-face tint on the albedo.
|
||||
// Shows paint color and face orientation simultaneously.
|
||||
vec3 normal_tint = N * 0.5 + 0.5;
|
||||
float diffuse = max(dot(N, L), 0.0) * 0.4 + 0.6;
|
||||
frag_color = vec4(albedo * normal_tint * diffuse + emissive, 1.0);
|
||||
} else {
|
||||
frag_color = vec4(light + emissive, 1.0);
|
||||
}
|
||||
|
||||
frag_color.rgb *= brightness;
|
||||
|
||||
// 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.
|
||||
if (vtrixel_state > 0.5) {
|
||||
frag_color.rgb = mix(frag_color.rgb, vec3(1.0, 1.0, 0.5), 0.5);
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@program trixel vs_trixel fs_trixel
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user