add trile AO

This commit is contained in:
Tuomas Katajisto 2026-10-03 00:01:24 +03:00
parent ff7787a4e0
commit b415b81584
5 changed files with 372 additions and 268 deletions

View File

@ -4,7 +4,7 @@
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc -i shaders.glsl -o jai/shaders.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
sokol-shdc -i src/renderer_sokol/shaders/shaders.glsl -o src/renderer_sokol/shaders/jai/shaders.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
Overview:
=========
@ -29,8 +29,9 @@
Attributes:
ATTR_trile_position => 0
ATTR_trile_swatch => 1
ATTR_trile_instance => 2
ATTR_trile_tint => 3
ATTR_trile_ao => 2
ATTR_trile_instance => 3
ATTR_trile_tint => 4
Shader program: 'ui':
Get shader desc: ui_shader_desc(sg_query_backend())
Vertex Shader: vs_ui
@ -118,8 +119,9 @@ ATTR_billboard_uv_rect :: 2;
ATTR_billboard_face :: 3;
ATTR_trile_position :: 0;
ATTR_trile_swatch :: 1;
ATTR_trile_instance :: 2;
ATTR_trile_tint :: 3;
ATTR_trile_ao :: 2;
ATTR_trile_instance :: 3;
ATTR_trile_tint :: 4;
ATTR_ui_position :: 0;
ATTR_ui_uv :: 1;
ATTR_ui_color0 :: 2;
@ -323,13 +325,15 @@ fs_composite_source_glsl430 := u8.[
uniform vec4 trile_params[72];
uniform vec4 view_params[6];
layout(location = 2) in vec4 instance;
layout(location = 3) in vec4 instance;
layout(location = 0) in vec3 position;
layout(location = 0) out float v_clip;
layout(location = 1) out float v_swatch;
layout(location = 1) in float swatch;
layout(location = 2) out float v_tint;
layout(location = 3) in float tint;
layout(location = 2) out float v_ao;
layout(location = 2) in float ao;
layout(location = 3) out float v_tint;
layout(location = 4) in float tint;
void main()
{
@ -339,6 +343,7 @@ fs_composite_source_glsl430 := u8.[
gl_Position = mat4(view_params[0], view_params[1], view_params[2], view_params[3]) * _84;
v_clip = dot(_84, view_params[5]);
v_swatch = swatch;
v_ao = ao;
v_tint = tint;
}
@ -349,7 +354,7 @@ vs_trile_source_glsl430 := u8.[
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x32,0x5d,0x3b,0x0a,0x75,0x6e,0x69,
0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,
0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,
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,0x33,0x20,0x70,0x6f,
@ -362,39 +367,45 @@ vs_trile_source_glsl430 := u8.[
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x77,0x61,0x74,0x63,0x68,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,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x74,
0x69,0x6e,0x74,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,0x66,0x6c,0x6f,
0x61,0x74,0x20,0x74,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,
0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,
0x5f,0x32,0x32,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x69,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x2e,0x77,0x20,0x2b,0x20,0x30,0x2e,0x35,0x29,0x20,0x2a,0x20,0x33,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2d,0x20,0x76,0x65,0x63,0x33,0x28,
0x30,0x2e,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,
0x38,0x34,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x76,0x65,0x63,0x33,0x28,
0x32,0x29,0x20,0x6f,0x75,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x61,
0x6f,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,0x66,0x6c,0x6f,0x61,0x74,
0x20,0x61,0x6f,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x6f,0x75,0x74,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x20,0x76,0x5f,0x74,0x69,0x6e,0x74,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,0x74,0x69,0x6e,0x74,0x3b,0x0a,
0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x32,0x32,0x20,0x3d,0x20,0x69,0x6e,0x74,
0x28,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x77,0x20,0x2b,0x20,0x30,0x2e,
0x35,0x29,0x20,0x2a,0x20,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,
0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,
0x2d,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x38,0x34,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,
0x28,0x28,0x76,0x65,0x63,0x33,0x28,0x64,0x6f,0x74,0x28,0x74,0x72,0x69,0x6c,0x65,
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x5f,0x32,0x32,0x20,0x2a,0x20,0x31,0x20,
0x2b,0x20,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,0x20,
0x64,0x6f,0x74,0x28,0x74,0x72,0x69,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x5f,0x32,0x32,0x20,0x2a,0x20,0x31,0x20,0x2b,0x20,0x30,0x5d,0x2e,0x78,0x79,
0x7a,0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x74,0x72,0x69,
0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x28,0x5f,0x32,0x32,0x20,0x2b,
0x20,0x31,0x29,0x20,0x2a,0x20,0x31,0x20,0x2b,0x20,0x30,0x5d,0x2e,0x78,0x79,0x7a,
0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x74,0x72,0x69,0x6c,
0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x28,0x5f,0x32,0x32,0x20,0x2b,0x20,
0x32,0x29,0x20,0x2a,0x20,0x31,0x20,0x2b,0x20,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,
0x20,0x5f,0x33,0x30,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,0x20,0x20,0x20,0x20,0x67,0x6c,
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,
0x28,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,
0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,
0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,
0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,
0x20,0x2a,0x20,0x5f,0x38,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x63,0x6c,
0x69,0x70,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x38,0x34,0x2c,0x20,0x76,0x69,
0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x5f,0x73,0x77,0x61,0x74,0x63,0x68,0x20,0x3d,0x20,0x73,0x77,
0x61,0x74,0x63,0x68,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x74,0x69,0x6e,0x74,
0x20,0x3d,0x20,0x74,0x69,0x6e,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
0x5b,0x28,0x5f,0x32,0x32,0x20,0x2b,0x20,0x31,0x29,0x20,0x2a,0x20,0x31,0x20,0x2b,
0x20,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,0x20,0x64,
0x6f,0x74,0x28,0x74,0x72,0x69,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
0x28,0x5f,0x32,0x32,0x20,0x2b,0x20,0x32,0x29,0x20,0x2a,0x20,0x31,0x20,0x2b,0x20,
0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,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,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,
0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,
0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,
0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,
0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x5f,0x38,0x34,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x5f,0x63,0x6c,0x69,0x70,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,
0x5f,0x38,0x34,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x35,0x5d,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x73,0x77,0x61,0x74,
0x63,0x68,0x20,0x3d,0x20,0x73,0x77,0x61,0x74,0x63,0x68,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x76,0x5f,0x61,0x6f,0x20,0x3d,0x20,0x61,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x3d,0x20,0x74,0x69,0x6e,0x74,0x3b,0x0a,0x7d,
0x0a,0x0a,0x00,
];
/*
#version 430
@ -403,7 +414,8 @@ vs_trile_source_glsl430 := u8.[
layout(location = 0) in float v_clip;
layout(location = 1) in float v_swatch;
layout(location = 2) in float v_tint;
layout(location = 2) in float v_ao;
layout(location = 3) in float v_tint;
layout(location = 0) out vec4 frag_color;
void main()
@ -412,7 +424,7 @@ vs_trile_source_glsl430 := u8.[
{
discard;
}
vec3 albedo = texelFetch(palette_palette_smp, ivec2(int(v_swatch + 0.5), 0), 0).xyz;
vec3 albedo = texelFetch(palette_palette_smp, ivec2(int(v_swatch + 0.5), 0), 0).xyz * mix(0.4000000059604644775390625, 1.0, v_ao);
if (v_tint > 1.5)
{
albedo = mix(albedo, vec3(1.0, 0.20000000298023223876953125, 0.20000000298023223876953125), vec3(0.5));
@ -440,43 +452,48 @@ fs_trile_source_glsl430 := u8.[
0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,
0x5f,0x73,0x77,0x61,0x74,0x63,0x68,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,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x74,0x69,0x6e,0x74,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,
0x76,0x5f,0x63,0x6c,0x69,0x70,0x20,0x3c,0x20,0x30,0x2e,0x30,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,0x76,
0x65,0x63,0x33,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,0x3d,0x20,0x74,0x65,0x78,
0x65,0x6c,0x46,0x65,0x74,0x63,0x68,0x28,0x70,0x61,0x6c,0x65,0x74,0x74,0x65,0x5f,
0x70,0x61,0x6c,0x65,0x74,0x74,0x65,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x69,0x76,0x65,
0x63,0x32,0x28,0x69,0x6e,0x74,0x28,0x76,0x5f,0x73,0x77,0x61,0x74,0x63,0x68,0x20,
0x2b,0x20,0x30,0x2e,0x35,0x29,0x2c,0x20,0x30,0x29,0x2c,0x20,0x30,0x29,0x2e,0x78,
0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x76,0x5f,0x74,0x69,
0x6e,0x74,0x20,0x3e,0x20,0x31,0x2e,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,0x3d,
0x20,0x6d,0x69,0x78,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x76,0x65,0x63,
0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x61,0x6f,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,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x74,0x69,0x6e,
0x74,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,0x76,0x5f,0x63,0x6c,0x69,0x70,0x20,0x3c,0x20,0x30,0x2e,0x30,
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,0x76,0x65,0x63,0x33,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,0x3d,
0x20,0x74,0x65,0x78,0x65,0x6c,0x46,0x65,0x74,0x63,0x68,0x28,0x70,0x61,0x6c,0x65,
0x74,0x74,0x65,0x5f,0x70,0x61,0x6c,0x65,0x74,0x74,0x65,0x5f,0x73,0x6d,0x70,0x2c,
0x20,0x69,0x76,0x65,0x63,0x32,0x28,0x69,0x6e,0x74,0x28,0x76,0x5f,0x73,0x77,0x61,
0x74,0x63,0x68,0x20,0x2b,0x20,0x30,0x2e,0x35,0x29,0x2c,0x20,0x30,0x29,0x2c,0x20,
0x30,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x6d,0x69,0x78,0x28,0x30,0x2e,0x34,
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x35,0x39,0x36,0x30,0x34,0x36,0x34,0x34,0x37,
0x37,0x35,0x33,0x39,0x30,0x36,0x32,0x35,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x76,
0x5f,0x61,0x6f,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x76,0x5f,
0x74,0x69,0x6e,0x74,0x20,0x3e,0x20,0x31,0x2e,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,
0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x76,
0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,
0x30,0x30,0x30,0x32,0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,
0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,
0x30,0x32,0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,
0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,
0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,
0x35,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,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,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x3e,0x20,0x30,0x2e,0x35,0x29,0x0a,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,0x3d,0x20,0x6d,0x69,
0x78,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,
0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x39,0x38,0x30,0x32,0x33,0x32,
0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x31,0x2e,0x30,
0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x39,0x38,0x30,
0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,0x35,0x29,0x2c,
0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29,0x29,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,0x76,0x65,
0x63,0x34,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,
0x0a,0x7d,0x0a,0x0a,0x00,
0x31,0x32,0x35,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,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,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x3e,0x20,0x30,0x2e,0x35,0x29,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,0x3d,0x20,
0x6d,0x69,0x78,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x76,0x65,0x63,0x33,
0x28,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x39,0x38,0x30,0x32,
0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x31,
0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x39,
0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,0x35,
0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29,0x29,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,
0x76,0x65,0x63,0x34,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x31,0x2e,0x30,
0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 430
@ -996,13 +1013,15 @@ fs_composite_source_glsl300es := u8.[
uniform vec4 trile_params[72];
uniform vec4 view_params[6];
layout(location = 2) in vec4 instance;
layout(location = 3) in vec4 instance;
layout(location = 0) in vec3 position;
out float v_clip;
out float v_swatch;
layout(location = 1) in float swatch;
out float v_ao;
layout(location = 2) in float ao;
out float v_tint;
layout(location = 3) in float tint;
layout(location = 4) in float tint;
void main()
{
@ -1012,6 +1031,7 @@ fs_composite_source_glsl300es := u8.[
gl_Position = mat4(view_params[0], view_params[1], view_params[2], view_params[3]) * _84;
v_clip = dot(_84, view_params[5]);
v_swatch = swatch;
v_ao = ao;
v_tint = tint;
}
@ -1022,7 +1042,7 @@ vs_trile_source_glsl300es := u8.[
0x69,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x32,0x5d,0x3b,0x0a,
0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x69,0x65,
0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x3b,0x0a,0x6c,0x61,0x79,
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,
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,0x33,
@ -1032,39 +1052,43 @@ vs_trile_source_glsl300es := u8.[
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,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,
0x77,0x61,0x74,0x63,0x68,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x20,0x76,0x5f,0x74,0x69,0x6e,0x74,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,0x66,0x6c,0x6f,0x61,0x74,0x20,0x74,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x69,0x6e,0x74,0x20,0x5f,0x32,0x32,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x69,0x6e,
0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x77,0x20,0x2b,0x20,0x30,0x2e,0x35,0x29,0x20,
0x2a,0x20,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x33,
0x30,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2d,0x20,0x76,
0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
0x63,0x34,0x20,0x5f,0x38,0x34,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x76,
0x65,0x63,0x33,0x28,0x64,0x6f,0x74,0x28,0x74,0x72,0x69,0x6c,0x65,0x5f,0x70,0x61,
0x72,0x61,0x6d,0x73,0x5b,0x5f,0x32,0x32,0x20,0x2a,0x20,0x31,0x20,0x2b,0x20,0x30,
0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,0x20,0x64,0x6f,0x74,
0x28,0x74,0x72,0x69,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x28,0x5f,
0x32,0x32,0x20,0x2b,0x20,0x31,0x29,0x20,0x2a,0x20,0x31,0x20,0x2b,0x20,0x30,0x5d,
0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,
0x74,0x72,0x69,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x28,0x5f,0x32,
0x32,0x20,0x2b,0x20,0x32,0x29,0x20,0x2a,0x20,0x31,0x20,0x2b,0x20,0x30,0x5d,0x2e,
0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,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,0x20,0x20,
0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x6d,0x61,0x74,0x34,0x28,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x30,0x5d,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x31,0x5d,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x32,0x5d,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x5f,0x38,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x76,0x5f,0x63,0x6c,0x69,0x70,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x38,0x34,
0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x73,0x77,0x61,0x74,0x63,0x68,0x20,
0x3d,0x20,0x73,0x77,0x61,0x74,0x63,0x68,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,
0x74,0x69,0x6e,0x74,0x20,0x3d,0x20,0x74,0x69,0x6e,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
0x20,0x76,0x5f,0x61,0x6f,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,0x66,
0x6c,0x6f,0x61,0x74,0x20,0x61,0x6f,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x20,0x76,0x5f,0x74,0x69,0x6e,0x74,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,0x74,0x69,0x6e,0x74,0x3b,0x0a,0x0a,
0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x32,0x32,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,
0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x77,0x20,0x2b,0x20,0x30,0x2e,0x35,
0x29,0x20,0x2a,0x20,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
0x5f,0x33,0x30,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2d,
0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x76,0x65,0x63,0x34,0x20,0x5f,0x38,0x34,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,
0x28,0x76,0x65,0x63,0x33,0x28,0x64,0x6f,0x74,0x28,0x74,0x72,0x69,0x6c,0x65,0x5f,
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x5f,0x32,0x32,0x20,0x2a,0x20,0x31,0x20,0x2b,
0x20,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,0x20,0x64,
0x6f,0x74,0x28,0x74,0x72,0x69,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
0x28,0x5f,0x32,0x32,0x20,0x2b,0x20,0x31,0x29,0x20,0x2a,0x20,0x31,0x20,0x2b,0x20,
0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,0x20,0x64,0x6f,
0x74,0x28,0x74,0x72,0x69,0x6c,0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x28,
0x5f,0x32,0x32,0x20,0x2b,0x20,0x32,0x29,0x20,0x2a,0x20,0x31,0x20,0x2b,0x20,0x30,
0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,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,
0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,
0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x5f,0x38,0x34,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x76,0x5f,0x63,0x6c,0x69,0x70,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,
0x38,0x34,0x2c,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
0x35,0x5d,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x73,0x77,0x61,0x74,0x63,
0x68,0x20,0x3d,0x20,0x73,0x77,0x61,0x74,0x63,0x68,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x76,0x5f,0x61,0x6f,0x20,0x3d,0x20,0x61,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,
0x5f,0x74,0x69,0x6e,0x74,0x20,0x3d,0x20,0x74,0x69,0x6e,0x74,0x3b,0x0a,0x7d,0x0a,
0x0a,0x00,
];
/*
#version 300 es
@ -1075,6 +1099,7 @@ vs_trile_source_glsl300es := u8.[
in highp float v_clip;
in highp float v_swatch;
in highp float v_ao;
in highp float v_tint;
layout(location = 0) out highp vec4 frag_color;
@ -1084,7 +1109,7 @@ vs_trile_source_glsl300es := u8.[
{
discard;
}
highp vec3 albedo = texelFetch(palette_palette_smp, ivec2(int(v_swatch + 0.5), 0), 0).xyz;
highp vec3 albedo = texelFetch(palette_palette_smp, ivec2(int(v_swatch + 0.5), 0), 0).xyz * mix(0.4000000059604644775390625, 1.0, v_ao);
if (v_tint > 1.5)
{
albedo = mix(albedo, vec3(1.0, 0.20000000298023223876953125, 0.20000000298023223876953125), vec3(0.5));
@ -1111,44 +1136,48 @@ fs_trile_source_glsl300es := u8.[
0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x63,0x6c,
0x69,0x70,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x20,0x76,0x5f,0x73,0x77,0x61,0x74,0x63,0x68,0x3b,0x0a,0x69,0x6e,0x20,
0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x74,0x69,
0x6e,0x74,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,0x76,0x5f,0x63,0x6c,0x69,
0x70,0x20,0x3c,0x20,0x30,0x2e,0x30,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,0x68,0x69,0x67,0x68,0x70,0x20,
0x76,0x65,0x63,0x33,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,0x3d,0x20,0x74,0x65,
0x78,0x65,0x6c,0x46,0x65,0x74,0x63,0x68,0x28,0x70,0x61,0x6c,0x65,0x74,0x74,0x65,
0x5f,0x70,0x61,0x6c,0x65,0x74,0x74,0x65,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x69,0x76,
0x65,0x63,0x32,0x28,0x69,0x6e,0x74,0x28,0x76,0x5f,0x73,0x77,0x61,0x74,0x63,0x68,
0x20,0x2b,0x20,0x30,0x2e,0x35,0x29,0x2c,0x20,0x30,0x29,0x2c,0x20,0x30,0x29,0x2e,
0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x76,0x5f,0x74,
0x69,0x6e,0x74,0x20,0x3e,0x20,0x31,0x2e,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,
0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x61,0x6f,
0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x20,0x76,0x5f,0x74,0x69,0x6e,0x74,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,
0x76,0x5f,0x63,0x6c,0x69,0x70,0x20,0x3c,0x20,0x30,0x2e,0x30,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,0x68,
0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,
0x20,0x3d,0x20,0x74,0x65,0x78,0x65,0x6c,0x46,0x65,0x74,0x63,0x68,0x28,0x70,0x61,
0x6c,0x65,0x74,0x74,0x65,0x5f,0x70,0x61,0x6c,0x65,0x74,0x74,0x65,0x5f,0x73,0x6d,
0x70,0x2c,0x20,0x69,0x76,0x65,0x63,0x32,0x28,0x69,0x6e,0x74,0x28,0x76,0x5f,0x73,
0x77,0x61,0x74,0x63,0x68,0x20,0x2b,0x20,0x30,0x2e,0x35,0x29,0x2c,0x20,0x30,0x29,
0x2c,0x20,0x30,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x6d,0x69,0x78,0x28,0x30,
0x2e,0x34,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x35,0x39,0x36,0x30,0x34,0x36,0x34,
0x34,0x37,0x37,0x35,0x33,0x39,0x30,0x36,0x32,0x35,0x2c,0x20,0x31,0x2e,0x30,0x2c,
0x20,0x76,0x5f,0x61,0x6f,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,
0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x3e,0x20,0x31,0x2e,0x35,0x29,0x0a,0x20,0x20,
0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,
0x64,0x6f,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,
0x20,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,
0x30,0x30,0x30,0x30,0x30,0x32,0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,
0x36,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,
0x30,0x30,0x30,0x32,0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,
0x35,0x33,0x31,0x32,0x35,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,
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,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x3e,0x20,0x30,0x2e,
0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,
0x3d,0x20,0x6d,0x69,0x78,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x76,0x65,
0x63,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,
0x30,0x30,0x32,0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,
0x33,0x31,0x32,0x35,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
0x63,0x33,0x28,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x39,0x38,
0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,
0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
0x32,0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,
0x32,0x35,0x29,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,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,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x3e,0x20,0x30,0x2e,0x35,0x29,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,0x3d,0x20,0x6d,
0x69,0x78,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,
0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x39,0x38,0x30,0x32,0x33,
0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,0x35,0x2c,0x20,0x31,0x2e,
0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x39,0x38,
0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,0x35,0x29,
0x2c,0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29,0x29,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,0x76,
0x65,0x63,0x34,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x31,0x2e,0x30,0x29,
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
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,0x76,0x65,0x63,0x34,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x31,
0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 300 es
@ -1794,7 +1823,8 @@ fs_composite_source_metal_macos := u8.[
{
float v_clip [[user(locn0)]];
float v_swatch [[user(locn1)]];
float v_tint [[user(locn2)]];
float v_ao [[user(locn2)]];
float v_tint [[user(locn3)]];
float4 gl_Position [[position]];
};
@ -1802,8 +1832,9 @@ fs_composite_source_metal_macos := u8.[
{
float3 position [[attribute(0)]];
float swatch [[attribute(1)]];
float4 instance [[attribute(2)]];
float tint [[attribute(3)]];
float ao [[attribute(2)]];
float4 instance [[attribute(3)]];
float tint [[attribute(4)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant trile_params& _36 [[buffer(0)]], constant view_params& _75 [[buffer(1)]])
@ -1815,6 +1846,7 @@ fs_composite_source_metal_macos := u8.[
out.gl_Position = _75.view_proj * _84;
out.v_clip = dot(_84, _75.clip);
out.v_swatch = in.swatch;
out.v_ao = in.ao;
out.v_tint = in.tint;
return out;
}
@ -1840,8 +1872,10 @@ vs_trile_source_metal_macos := u8.[
0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x20,0x76,0x5f,0x73,0x77,0x61,0x74,0x63,0x68,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,0x20,0x76,0x5f,0x61,0x6f,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,0x20,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x5b,0x5b,
0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,
0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x33,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,
@ -1850,48 +1884,52 @@ vs_trile_source_metal_macos := u8.[
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,0x20,0x73,0x77,0x61,0x74,0x63,0x68,
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,0x61,0x6e,0x63,0x65,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,0x20,0x74,0x69,0x6e,0x74,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,0x74,0x72,0x69,0x6c,0x65,0x5f,0x70,0x61,
0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x33,0x36,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,
0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,
0x74,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,
0x37,0x35,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,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,
0x69,0x6e,0x74,0x20,0x5f,0x32,0x32,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x69,0x6e,
0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x77,0x20,0x2b,0x20,0x30,0x2e,
0x35,0x29,0x20,0x2a,0x20,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,
0x74,0x69,0x6f,0x6e,0x20,0x2d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,
0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,
0x38,0x34,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x28,0x64,0x6f,0x74,0x28,0x5f,0x33,0x36,0x2e,0x6f,0x72,0x69,0x65,
0x6e,0x74,0x61,0x74,0x69,0x6f,0x6e,0x73,0x5b,0x5f,0x32,0x32,0x5d,0x2e,0x78,0x79,
0x7a,0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x36,
0x2e,0x6f,0x72,0x69,0x65,0x6e,0x74,0x61,0x74,0x69,0x6f,0x6e,0x73,0x5b,0x5f,0x32,
0x32,0x20,0x2b,0x20,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,0x29,
0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x36,0x2e,0x6f,0x72,0x69,0x65,0x6e,0x74,
0x61,0x74,0x69,0x6f,0x6e,0x73,0x5b,0x5f,0x32,0x32,0x20,0x2b,0x20,0x32,0x5d,0x2e,
0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,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,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x37,0x35,0x2e,0x76,0x69,0x65,
0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x2a,0x20,0x5f,0x38,0x34,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x63,0x6c,0x69,0x70,0x20,0x3d,0x20,0x64,
0x6f,0x74,0x28,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x37,0x35,0x2e,0x63,0x6c,0x69,0x70,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x73,0x77,0x61,
0x74,0x63,0x68,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x73,0x77,0x61,0x74,0x63,0x68,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,
0x3d,0x20,0x69,0x6e,0x2e,0x74,0x69,0x6e,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,
0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x6f,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,0x61,0x6e,0x63,0x65,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,0x74,0x69,0x6e,0x74,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,0x74,0x72,0x69,0x6c,0x65,0x5f,0x70,0x61,0x72,
0x61,0x6d,0x73,0x26,0x20,0x5f,0x33,0x36,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,
0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,
0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x37,
0x35,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,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,0x69,
0x6e,0x74,0x20,0x5f,0x32,0x32,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x69,0x6e,0x2e,
0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x77,0x20,0x2b,0x20,0x30,0x2e,0x35,
0x29,0x20,0x2a,0x20,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x33,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x20,0x2d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x35,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x38,
0x34,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x28,0x64,0x6f,0x74,0x28,0x5f,0x33,0x36,0x2e,0x6f,0x72,0x69,0x65,0x6e,
0x74,0x61,0x74,0x69,0x6f,0x6e,0x73,0x5b,0x5f,0x32,0x32,0x5d,0x2e,0x78,0x79,0x7a,
0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x36,0x2e,
0x6f,0x72,0x69,0x65,0x6e,0x74,0x61,0x74,0x69,0x6f,0x6e,0x73,0x5b,0x5f,0x32,0x32,
0x20,0x2b,0x20,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,0x29,0x2c,
0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x36,0x2e,0x6f,0x72,0x69,0x65,0x6e,0x74,0x61,
0x74,0x69,0x6f,0x6e,0x73,0x5b,0x5f,0x32,0x32,0x20,0x2b,0x20,0x32,0x5d,0x2e,0x78,
0x79,0x7a,0x2c,0x20,0x5f,0x33,0x30,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,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x37,0x35,0x2e,0x76,0x69,0x65,0x77,
0x5f,0x70,0x72,0x6f,0x6a,0x20,0x2a,0x20,0x5f,0x38,0x34,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x63,0x6c,0x69,0x70,0x20,0x3d,0x20,0x64,0x6f,
0x74,0x28,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x37,0x35,0x2e,0x63,0x6c,0x69,0x70,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x73,0x77,0x61,0x74,
0x63,0x68,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x73,0x77,0x61,0x74,0x63,0x68,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x61,0x6f,0x20,0x3d,0x20,0x69,
0x6e,0x2e,0x61,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,
0x74,0x69,0x6e,0x74,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x74,0x69,0x6e,0x74,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>
@ -1908,7 +1946,8 @@ vs_trile_source_metal_macos := u8.[
{
float v_clip [[user(locn0)]];
float v_swatch [[user(locn1)]];
float v_tint [[user(locn2)]];
float v_ao [[user(locn2)]];
float v_tint [[user(locn3)]];
};
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> palette [[texture(0)]], sampler palette_smp [[sampler(0)]])
@ -1918,7 +1957,7 @@ vs_trile_source_metal_macos := u8.[
{
discard_fragment();
}
float3 albedo = palette.read(uint2(int2(int(in.v_swatch + 0.5), 0)), 0).xyz;
float3 albedo = palette.read(uint2(int2(int(in.v_swatch + 0.5), 0)), 0).xyz * mix(0.4000000059604644775390625, 1.0, in.v_ao);
if (in.v_tint > 1.5)
{
albedo = mix(albedo, float3(1.0, 0.20000000298023223876953125, 0.20000000298023223876953125), float3(0.5));
@ -1950,8 +1989,10 @@ fs_trile_source_metal_macos := u8.[
0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x20,0x76,0x5f,0x73,0x77,0x61,0x74,0x63,0x68,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,0x20,0x76,0x5f,0x61,0x6f,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,0x20,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x5b,0x5b,0x75,0x73,
0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,
0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x33,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,
@ -1970,33 +2011,36 @@ fs_trile_source_metal_macos := u8.[
0x70,0x61,0x6c,0x65,0x74,0x74,0x65,0x2e,0x72,0x65,0x61,0x64,0x28,0x75,0x69,0x6e,
0x74,0x32,0x28,0x69,0x6e,0x74,0x32,0x28,0x69,0x6e,0x74,0x28,0x69,0x6e,0x2e,0x76,
0x5f,0x73,0x77,0x61,0x74,0x63,0x68,0x20,0x2b,0x20,0x30,0x2e,0x35,0x29,0x2c,0x20,
0x30,0x29,0x29,0x2c,0x20,0x30,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x69,0x66,0x20,0x28,0x69,0x6e,0x2e,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x3e,
0x20,0x31,0x2e,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,0x3d,0x20,0x6d,0x69,0x78,
0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,
0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,
0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,
0x35,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x39,0x38,
0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,0x35,0x29,
0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x35,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,0x69,0x6e,0x2e,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x3e,0x20,0x30,0x2e,0x35,
0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,0x3d,
0x20,0x6d,0x69,0x78,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x28,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x39,
0x30,0x29,0x29,0x2c,0x20,0x30,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x6d,0x69,
0x78,0x28,0x30,0x2e,0x34,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x35,0x39,0x36,0x30,
0x34,0x36,0x34,0x34,0x37,0x37,0x35,0x33,0x39,0x30,0x36,0x32,0x35,0x2c,0x20,0x31,
0x2e,0x30,0x2c,0x20,0x69,0x6e,0x2e,0x76,0x5f,0x61,0x6f,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x69,0x66,0x20,0x28,0x69,0x6e,0x2e,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,
0x3e,0x20,0x31,0x2e,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,0x3d,0x20,0x6d,0x69,
0x78,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
0x32,0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,
0x32,0x35,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,0x39,
0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,0x35,
0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,
0x30,0x32,0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,
0x31,0x32,0x35,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x35,
0x29,0x29,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,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
0x61,0x6c,0x62,0x65,0x64,0x6f,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,
0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x35,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,0x69,0x6e,0x2e,0x76,0x5f,0x74,0x69,0x6e,0x74,0x20,0x3e,0x20,0x30,0x2e,
0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x62,0x65,0x64,0x6f,0x20,
0x3d,0x20,0x6d,0x69,0x78,0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,0x2c,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x32,
0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,0x33,0x31,0x32,
0x35,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x30,0x30,0x30,0x30,0x30,
0x30,0x30,0x32,0x39,0x38,0x30,0x32,0x33,0x32,0x32,0x33,0x38,0x37,0x36,0x39,0x35,
0x33,0x31,0x32,0x35,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,
0x35,0x29,0x29,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,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x28,0x61,0x6c,0x62,0x65,0x64,0x6f,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,
];
/*
#pragma clang diagnostic ignored "-Wmissing-prototypes"
@ -2895,9 +2939,11 @@ trile_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc.attrs[1].base_type = .FLOAT;
desc.attrs[1].glsl_name = "swatch";
desc.attrs[2].base_type = .FLOAT;
desc.attrs[2].glsl_name = "instance";
desc.attrs[2].glsl_name = "ao";
desc.attrs[3].base_type = .FLOAT;
desc.attrs[3].glsl_name = "tint";
desc.attrs[3].glsl_name = "instance";
desc.attrs[4].base_type = .FLOAT;
desc.attrs[4].glsl_name = "tint";
desc.uniform_blocks[0].stage = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 96;
@ -2930,9 +2976,11 @@ trile_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc.attrs[1].base_type = .FLOAT;
desc.attrs[1].glsl_name = "swatch";
desc.attrs[2].base_type = .FLOAT;
desc.attrs[2].glsl_name = "instance";
desc.attrs[2].glsl_name = "ao";
desc.attrs[3].base_type = .FLOAT;
desc.attrs[3].glsl_name = "tint";
desc.attrs[3].glsl_name = "instance";
desc.attrs[4].base_type = .FLOAT;
desc.attrs[4].glsl_name = "tint";
desc.uniform_blocks[0].stage = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 96;
@ -2964,6 +3012,7 @@ trile_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
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 = 96;

View File

@ -7,11 +7,13 @@ layout(binding=1) uniform trile_params {
in vec3 position;
in float swatch;
in float ao;
in vec4 instance; // xyz = position, w = orientation
in float tint;
out float v_clip;
out float v_swatch;
out float v_ao;
out float v_tint;
void main() {
@ -23,6 +25,7 @@ void main() {
gl_Position = view_proj * vec4(world, 1.0);
v_clip = dot(vec4(world, 1.0), clip);
v_swatch = swatch;
v_ao = ao;
v_tint = tint;
}
@end
@ -30,6 +33,7 @@ void main() {
@fs fs_trile
in float v_clip;
in float v_swatch;
in float v_ao;
in float v_tint;
out vec4 frag_color;
@ -39,6 +43,7 @@ layout(binding=0) uniform sampler palette_smp;
void main() {
if (v_clip < 0.0) discard;
vec3 albedo = texelFetch(sampler2D(palette, palette_smp), ivec2(int(v_swatch + 0.5), 0), 0).rgb;
albedo *= mix(0.4, 1.0, v_ao);
if (v_tint > 1.5) albedo = mix(albedo, vec3(1.0, 0.2, 0.2), 0.5);
else if (v_tint > 0.5) albedo = mix(albedo, vec3(0.2, 1.0, 0.2), 0.5);
frag_color = vec4(albedo, 1.0);

View File

@ -3,8 +3,10 @@ triles_init :: (orientations: [ORIENTATION_COUNT]Matrix3) {
desc.layout.buffers[1].step_func = .PER_INSTANCE;
desc.layout.attrs[ATTR_trile_position] = .{ format = .FLOAT3 };
desc.layout.attrs[ATTR_trile_swatch] = .{ format = .FLOAT };
desc.layout.attrs[ATTR_trile_ao] = .{ format = .FLOAT };
desc.layout.attrs[ATTR_trile_instance] = .{ format = .FLOAT4, buffer_index = 1 };
desc.layout.attrs[ATTR_trile_tint] = .{ format = .FLOAT, buffer_index = 1 };
desc.index_type = .UINT16;
desc.cull_mode = .BACK;
desc.face_winding = .CCW;
triles.pipeline = sg_make_pipeline(*desc);
@ -15,16 +17,16 @@ triles_init :: (orientations: [ORIENTATION_COUNT]Matrix3) {
triles.palette_dirty = true;
}
renderer_trile_mesh_create :: (vertices: []Trile_Vertex) -> u32 {
renderer_trile_mesh_create :: (vertices: []Trile_Vertex, indices: []u16) -> u32 {
id, mesh := slot_add(*triles.meshes);
make_mesh(mesh, vertices);
make_mesh(mesh, vertices, indices);
return id;
}
renderer_trile_mesh_update :: (id: u32, vertices: []Trile_Vertex) {
renderer_trile_mesh_update :: (id: u32, vertices: []Trile_Vertex, indices: []u16) {
mesh := slot_get(*triles.meshes, id);
free_mesh(mesh);
make_mesh(mesh, vertices);
make_mesh(mesh, vertices, indices);
}
renderer_trile_mesh_destroy :: (id: u32) {
@ -78,24 +80,26 @@ triles_draw :: (pass: *Pass) {
for triles.batches {
if it.view_index != pass.view_index || (pass.reflection && it.key & PREVIEW_KEY) continue;
mesh := slot_get(*triles.meshes, xx (it.key & ~PREVIEW_KEY));
if !mesh || mesh.vertex_count == 0 continue;
if !mesh || mesh.index_count == 0 continue;
bind : sg_bindings;
bind.vertex_buffers[0] = mesh.vertices;
bind.index_buffer = mesh.indices;
bind.vertex_buffers[1] = triles.stream.buffer;
bind.vertex_buffer_offsets[1] = it.first * size_of(Instance);
bind.images[IMG_palette] = triles.palette_image;
bind.samplers[SMP_palette_smp] = samplers.nearest_clamp;
sg_apply_bindings(*bind);
sg_draw(0, mesh.vertex_count, it.count);
sg_draw(0, mesh.index_count, it.count);
}
}
#scope_file
Mesh :: struct {
vertices : sg_buffer;
vertex_count : s32;
vertices : sg_buffer;
indices : sg_buffer;
index_count : s32;
}
Instance :: struct {
@ -120,14 +124,18 @@ triles : struct {
stream : Stream_Buffer;
}
make_mesh :: (mesh: *Mesh, vertices: []Trile_Vertex) {
mesh.vertex_count = xx vertices.count;
if vertices.count {
make_mesh :: (mesh: *Mesh, vertices: []Trile_Vertex, indices: []u16) {
mesh.index_count = xx indices.count;
if indices.count {
mesh.vertices = sg_make_buffer(*(sg_buffer_desc.{ data = .{ vertices.data, xx (vertices.count * size_of(Trile_Vertex)) } }));
mesh.indices = sg_make_buffer(*(sg_buffer_desc.{ type = .INDEXBUFFER, data = .{ indices.data, xx (indices.count * size_of(u16)) } }));
}
}
free_mesh :: (mesh: *Mesh) {
if mesh.vertex_count sg_destroy_buffer(mesh.vertices);
if mesh.index_count {
sg_destroy_buffer(mesh.vertices);
sg_destroy_buffer(mesh.indices);
}
mesh.* = .{};
}

View File

@ -53,11 +53,13 @@ Ui_Vertex :: struct {
}
trile_mesh_create :: (trile: *Trile) -> Trile_Mesh {
return .{renderer_trile_mesh_create(mesh_trile(trile))};
vertices, indices := mesh_trile(trile);
return .{renderer_trile_mesh_create(vertices, indices)};
}
trile_mesh_update :: (mesh: Trile_Mesh, trile: *Trile) {
renderer_trile_mesh_update(mesh.id, mesh_trile(trile));
vertices, indices := mesh_trile(trile);
renderer_trile_mesh_update(mesh.id, vertices, indices);
}
trile_mesh_destroy :: (mesh: Trile_Mesh) {
@ -192,6 +194,7 @@ Scene_Ui :: struct {
Trile_Vertex :: struct {
position : Vector3;
swatch : float;
ao : float; // 0 = fully occluded, 1 = open
}
Scene :: struct {

View File

@ -1,53 +1,92 @@
mesh_trile :: (trile: *Trile) -> []Trile_Vertex {
mesh_trile :: (trile: *Trile) -> vertices: []Trile_Vertex, indices: []u16 {
vertices : [..]Trile_Vertex;
indices : [..]u16;
vertices.allocator = temp;
indices.allocator = temp;
for axis: 0..2 for sign: s32.[1, -1] {
u_axis := (axis + 1) % 3;
v_axis := (axis + 2) % 3;
for depth: 0..15 {
mask : [16][16]u8;
mask : [16][16]Face;
for u: 0..15 for v: 0..15 {
c : [3]s32;
c[axis] = xx depth; c[u_axis] = xx u; c[v_axis] = xx v;
swatch := trixel(trile, c);
c[axis] += sign;
if trixel(trile, c) == 0 mask[u][v] = swatch;
if !swatch || trixel(trile, c) continue;
face := *mask[u][v];
face.swatch = swatch;
for corner: 0..3 {
side_u := c; side_u[u_axis] += xx ifx corner == 1 || corner == 2 then 1 else -1;
side_v := c; side_v[v_axis] += xx ifx corner >= 2 then 1 else -1;
diagonal := side_u; diagonal[v_axis] = side_v[v_axis];
a := trixel(trile, side_u) != 0;
b := trixel(trile, side_v) != 0;
d := trixel(trile, diagonal) != 0;
face.ao[corner] = xx ifx a && b then 0 else 3 - cast(int) a - cast(int) b - cast(int) d;
}
}
for u0: 0..15 for v0: 0..15 {
swatch := mask[u0][v0];
if !swatch continue;
v1 := v0 + 1;
while v1 < 16 && mask[u0][v1] == swatch v1 += 1;
u1 := u0 + 1;
while u1 < 16 && row_matches(*mask, u1, v0, v1, swatch) u1 += 1;
for u: u0..u1-1 for v: v0..v1-1 mask[u][v] = 0;
face := mask[u0][v0];
if !face.swatch continue;
// A face with an AO gradient keeps its own quad, so the gradient isn't stretched.
u1, v1 := u0 + 1, v0 + 1;
if flat(face) {
while v1 < 16 && mask[u0][v1] == face v1 += 1;
while u1 < 16 && row_matches(*mask, u1, v0, v1, face) u1 += 1;
}
for u: u0..u1-1 for v: v0..v1-1 mask[u][v] = .{};
plane := cast(float)(depth + ifx sign > 0 then 1 else 0);
corner :: (axis: int, u_axis: int, v_axis: int, plane: float, u: int, v: int) -> Vector3 #expand {
corner :: (u: int, v: int, ao: u8) -> Trile_Vertex #expand {
p : Vector3;
p.component[axis] = plane * TRIXEL_SIZE;
p.component[u_axis] = u * TRIXEL_SIZE;
p.component[v_axis] = v * TRIXEL_SIZE;
return p;
p.component[`axis] = `plane * TRIXEL_SIZE;
p.component[`u_axis] = u * TRIXEL_SIZE;
p.component[`v_axis] = v * TRIXEL_SIZE;
return .{p, xx `face.swatch, ao / 3.0};
}
q := Trile_Vertex.[
corner(u0, v0, face.ao[0]),
corner(u1, v0, face.ao[1]),
corner(u1, v1, face.ao[2]),
corner(u0, v1, face.ao[3]),
];
if sign < 0 q[1], q[3] = q[3], q[1];
// Split along the brighter diagonal so AO interpolates evenly.
base := cast(u16) vertices.count;
array_add(*vertices, ..q);
if face.ao[0] + face.ao[2] < face.ao[1] + face.ao[3] {
for u16.[1, 2, 3, 1, 3, 0] array_add(*indices, base + it);
} else {
for u16.[0, 1, 2, 0, 2, 3] array_add(*indices, base + it);
}
p0 := corner(axis, u_axis, v_axis, plane, u0, v0);
p1 := corner(axis, u_axis, v_axis, plane, u1, v0);
p2 := corner(axis, u_axis, v_axis, plane, u1, v1);
p3 := corner(axis, u_axis, v_axis, plane, u0, v1);
if sign < 0 p1, p3 = p3, p1;
for Vector3.[p0, p1, p2, p0, p2, p3] array_add(*vertices, .{it, xx swatch});
}
}
}
return vertices;
return vertices, indices;
}
#scope_file
row_matches :: (mask: *[16][16]u8, u: int, v0: int, v1: int, swatch: u8) -> bool {
for v: v0..v1-1 if mask.*[u][v] != swatch return false;
// ao is per corner in the order (u0, v0), (u1, v0), (u1, v1), (u0, v1); 3 = open.
Face :: struct {
swatch : u8;
ao : [4]u8;
}
operator == :: (a: Face, b: Face) -> bool {
return a.swatch == b.swatch && a.ao[0] == b.ao[0] && a.ao[1] == b.ao[1] && a.ao[2] == b.ao[2] && a.ao[3] == b.ao[3];
}
flat :: (face: Face) -> bool {
return face.ao[0] == face.ao[1] && face.ao[1] == face.ao[2] && face.ao[2] == face.ao[3];
}
row_matches :: (mask: *[16][16]Face, u: int, v0: int, v1: int, face: Face) -> bool {
for v: v0..v1-1 if mask.*[u][v] != face return false;
return true;
}