integrate ssao into main render pass and make it adjustable

This commit is contained in:
Tuomas Katajisto 2025-10-20 21:40:50 +03:00
parent e3fa3031fa
commit a59b2d5a5f
10 changed files with 1431 additions and 1311 deletions

View File

@ -3,5 +3,6 @@
"contrast": 1.075945,
"saturation": 1.202777,
"gamma": 1.019477,
"tonemap": 1
"tonemap": 1,
"ssao": 2.603531
}

View File

@ -159,7 +159,7 @@
"sunIntensity": 2,
"skyIntensity": 1,
"hasClouds": 1,
"planeHeight": 0,
"planeHeight": 2.642177,
"planeType": 1,
"waterColor": {
"x": 0.113144,
@ -214,17 +214,16 @@
},{
"trileName": "pillar_top",
"positions": [
0,2,2,1,0,1,-1,1,-3,2,-1,1,-3,2,2,1
0,2,2,1,0,1,-1,1,-3,2,-1,1,-3,3,2,1
]
},{
"trileName": "test",
"positions": [
-3,1,-1,1,0,1,2,1,-3,1,2,1
-3,1,-1,1,0,1,2,1,-3,1,2,1,0,0,2,1,-3,0,2,1,-3,0,-1,1,0,0,-1,1,-3,2,2,1
]
},{
"trileName": "plat",
"positions": [
-4,0,-1,1,-4,0,0,1,-4,0,2,1,-1,0,-1,1,-3,0,1,1,-3,0,0,1,0,0,0,1,-2,0,-1,1,-2,0,1,1,-2,0,2,1,-1,0,2,1,-1,0,1,1,-2,0,0,1,-1,0,0,1,0,0,1,1
]
},{
"trileName": "deck",
@ -233,7 +232,6 @@
},{
"trileName": "aaa",
"positions": [
-3,0,2,1,-4,0,1,1,-3,0,-1,1,0,0,-1,1,0,0,2,1
]
}
],

View File

@ -161,6 +161,7 @@ backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *
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;
fs_params : Trile_Fs_Params;
fs_params.mvp_shadow = shadow_mvp.floats;
@ -266,6 +267,7 @@ backend_process_command_buckets :: () {
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();

View File

@ -128,6 +128,7 @@ create_pipelines :: () {
create_shadowmap_image();
create_final_image();
create_ssao_images();
}
create_gbuffer_images :: () {
@ -677,6 +678,34 @@ create_postprocess_pipeline :: () {
}
create_ssao_images :: () {
if g_ssaobuf.id != INVALID_ID then sg_destroy_image(g_ssaobuf);
if g_ssaobuf_depth.id != INVALID_ID then sg_destroy_image(g_ssaobuf_depth);
w,h := get_render_size();
img_desc := sg_image_desc.{
width = w,
height = h,
render_target = true,
};
img_desc.sample_count = 1;
g_ssaobuf = sg_make_image(*img_desc);
img_desc = sg_image_desc.{
width = w,
height = h,
pixel_format = .DEPTH,
render_target = true,
};
img_desc.sample_count = 1;
g_ssaobuf_depth = sg_make_image(*img_desc);
attachmentsDesc := sg_attachments_desc.{
colors[0].image = g_ssaobuf,
depth_stencil.image = g_ssaobuf_depth
};
sg_destroy_attachments(g_ssao_attachments);
g_ssao_attachments = sg_make_attachments(*attachmentsDesc);
}
create_ssao_pipeline :: () {
init_ssao();
platconf := get_plat_conf();
@ -736,29 +765,6 @@ create_ssao_pipeline :: () {
mag_filter = .NEAREST,
}));
w,h := get_render_size();
img_desc := sg_image_desc.{
width = w,
height = h,
render_target = true,
};
img_desc.sample_count = 1;
g_ssaobuf = sg_make_image(*img_desc);
img_desc = sg_image_desc.{
width = w,
height = h,
pixel_format = .DEPTH,
render_target = true,
};
img_desc.sample_count = 1;
g_ssaobuf_depth = sg_make_image(*img_desc);
attachmentsDesc := sg_attachments_desc.{
colors[0].image = g_ssaobuf,
depth_stencil.image = g_ssaobuf_depth
};
sg_destroy_attachments(g_ssao_attachments);
g_ssao_attachments = sg_make_attachments(*attachmentsDesc);
imgdata : sg_image_data;
imgdata.subimage[0][0] = .{g_ssao_noise.data, cast(u64) (16*4*4)};

View File

@ -4,6 +4,7 @@ Post_Process :: struct {
saturation : float = 1.0; @Slider,0.0,2.0,0.1;
gamma : float = 1.0; @Slider,0.3,3.0,0.1;
tonemap : float = 1.0; @Slider,0,1,1;
ssao : float = 1.0; @Slider,0,5,0.1;
}
current_post_process : Post_Process;

View File

@ -28,6 +28,7 @@ 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();
}
#scope_export

View File

@ -48,6 +48,8 @@ SMP_ssao_smp :: 0;
Ssao_Fs_Params :: struct {
projection: [16]float;
samples: [64][4]float;
ssao_power: float;
_: [12]u8;
};
/*
#version 430
@ -81,9 +83,9 @@ vs_ssao_source_glsl430 := u8.[
/*
#version 430
vec4 _208;
vec4 _220;
uniform vec4 ssao_fs_params[68];
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;
@ -101,30 +103,35 @@ vs_ssao_source_glsl430 := u8.[
float occlusion = 0.0;
for (int i = 0; i < 64; i++)
{
vec3 _121 = _26 + ((_85 * ssao_fs_params[i * 1 + 4].xyz) * 0.20000000298023223876953125);
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 _193;
_193.x = _140.x;
_193.y = _140.y;
vec3 _155 = (_193.xyz * 0.5) + vec3(0.5);
vec4 _199;
_199.x = _155.x;
_199.y = _155.y;
occlusion += float(texture(g_position_ssao_smp, _199.xy).z >= _121.z);
vec4 _204;
_204.x = _140.x;
_204.y = _140.y;
vec3 _154 = (_204.xyz * 0.5) + vec3(0.5);
vec4 _210;
_210.x = _154.x;
_210.y = _154.y;
vec4 _167 = texture(g_position_ssao_smp, _210.xy);
if (length(_167.xyz) > 0.00999999977648258209228515625)
{
occlusion += float(_167.z >= _121.z);
}
}
float _179 = occlusion;
float _182 = 1.0 - (_179 * 0.015625);
occlusion = _182;
out_color = vec4(_182, _182, _182, 1.0);
float _185 = occlusion;
float _188 = 1.0 - (_185 * 0.015625);
occlusion = _188;
float _196 = pow(_188, ssao_fs_params[68].x);
out_color = vec4(_196, _196, _196, 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,0x30,0x38,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,
0x63,0x34,0x20,0x5f,0x32,0x32,0x30,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,0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
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,
@ -169,45 +176,54 @@ fs_ssao_source_glsl430 := u8.[
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,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,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,0x31,
0x39,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x33,
0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x34,0x30,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x33,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,0x35,0x20,0x3d,0x20,0x28,0x5f,0x31,0x39,0x33,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,0x31,0x39,0x39,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x5f,0x31,0x39,0x39,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x35,0x35,
0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x39,
0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,0x35,0x35,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x2b,
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,
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,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x5f,0x32,0x30,0x34,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x34,0x30,
0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x30,0x34,
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,0x34,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,0x30,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x31,0x30,0x2e,0x78,
0x20,0x3d,0x20,0x5f,0x31,0x35,0x34,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x5f,0x32,0x31,0x30,0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,0x35,0x34,
0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,
0x20,0x5f,0x31,0x36,0x37,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,0x5f,0x31,0x39,0x39,0x2e,0x78,0x79,0x29,0x2e,0x7a,0x20,
0x3e,0x3d,0x20,0x5f,0x31,0x32,0x31,0x2e,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x37,0x39,
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,0x38,0x32,0x20,0x3d,0x20,0x31,
0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,0x31,0x37,0x39,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,0x38,0x32,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,0x38,0x32,0x2c,0x20,0x5f,0x31,0x38,0x32,0x2c,0x20,0x5f,
0x31,0x38,0x32,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
0x73,0x6d,0x70,0x2c,0x20,0x5f,0x32,0x31,0x30,0x2e,0x78,0x79,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x6c,0x65,0x6e,0x67,0x74,
0x68,0x28,0x5f,0x31,0x36,0x37,0x2e,0x78,0x79,0x7a,0x29,0x20,0x3e,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,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x2b,
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x36,0x37,0x2e,0x7a,0x20,0x3e,
0x3d,0x20,0x5f,0x31,0x32,0x31,0x2e,0x7a,0x29,0x3b,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,0x5f,0x31,0x38,0x35,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,0x38,0x38,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,
0x31,0x38,0x35,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,0x38,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x20,0x5f,0x31,0x39,0x36,0x20,0x3d,0x20,0x70,0x6f,0x77,0x28,0x5f,0x31,0x38,0x38,
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,0x36,0x2c,0x20,0x5f,0x31,0x39,0x36,0x2c,0x20,0x5f,0x31,0x39,0x36,0x2c,0x20,
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 300 es
@ -242,9 +258,9 @@ vs_ssao_source_glsl300es := u8.[
precision mediump float;
precision highp int;
vec4 _208;
vec4 _220;
uniform highp vec4 ssao_fs_params[68];
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;
@ -262,22 +278,27 @@ vs_ssao_source_glsl300es := u8.[
highp float occlusion = 0.0;
for (int i = 0; i < 64; i++)
{
highp vec3 _121 = _26 + ((_85 * ssao_fs_params[i * 1 + 4].xyz) * 0.20000000298023223876953125);
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 _193;
_193.x = _140.x;
_193.y = _140.y;
highp vec3 _155 = (_193.xyz * 0.5) + vec3(0.5);
highp vec4 _199;
_199.x = _155.x;
_199.y = _155.y;
occlusion += float(texture(g_position_ssao_smp, _199.xy).z >= _121.z);
highp vec4 _204;
_204.x = _140.x;
_204.y = _140.y;
highp vec3 _154 = (_204.xyz * 0.5) + vec3(0.5);
highp vec4 _210;
_210.x = _154.x;
_210.y = _154.y;
highp vec4 _167 = texture(g_position_ssao_smp, _210.xy);
if (length(_167.xyz) > 0.00999999977648258209228515625)
{
occlusion += float(_167.z >= _121.z);
}
}
highp float _179 = occlusion;
highp float _182 = 1.0 - (_179 * 0.015625);
occlusion = _182;
out_color = vec4(_182, _182, _182, 1.0);
highp float _185 = occlusion;
highp float _188 = 1.0 - (_185 * 0.015625);
occlusion = _188;
highp float _196 = pow(_188, ssao_fs_params[68].x);
out_color = vec4(_196, _196, _196, 1.0);
}
*/
@ -286,9 +307,9 @@ fs_ssao_source_glsl300es := u8.[
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,0x30,0x38,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,
0x65,0x63,0x34,0x20,0x5f,0x32,0x32,0x30,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,0x38,0x5d,
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,
@ -333,48 +354,57 @@ fs_ssao_source_glsl300es := u8.[
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,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,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,0x31,0x39,0x33,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x33,0x2e,0x78,0x20,
0x3d,0x20,0x5f,0x31,0x34,0x30,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x5f,0x31,0x39,0x33,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,0x35,0x20,0x3d,0x20,0x28,0x5f,0x31,
0x39,0x33,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,0x31,
0x39,0x39,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x39,
0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x35,0x35,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x39,0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,
0x35,0x35,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,
0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x2b,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x28,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,0x31,
0x39,0x39,0x2e,0x78,0x79,0x29,0x2e,0x7a,0x20,0x3e,0x3d,0x20,0x5f,0x31,0x32,0x31,
0x2e,0x7a,0x29,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,0x37,0x39,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,0x38,
0x32,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,0x31,0x37,0x39,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,0x38,
0x32,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,0x38,0x32,0x2c,0x20,0x5f,0x31,
0x38,0x32,0x2c,0x20,0x5f,0x31,0x38,0x32,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
0x7d,0x0a,0x0a,0x00,
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,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x5f,0x32,0x30,0x34,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x34,0x30,0x2e,0x78,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x30,0x34,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,0x34,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,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x5f,0x32,0x31,0x30,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x35,0x34,
0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x31,0x30,
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,0x76,0x65,0x63,0x34,0x20,
0x5f,0x31,0x36,0x37,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,0x5f,0x32,0x31,0x30,0x2e,0x78,0x79,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x6c,0x65,0x6e,0x67,0x74,0x68,
0x28,0x5f,0x31,0x36,0x37,0x2e,0x78,0x79,0x7a,0x29,0x20,0x3e,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,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x2b,0x3d,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x36,0x37,0x2e,0x7a,0x20,0x3e,0x3d,
0x20,0x5f,0x31,0x32,0x31,0x2e,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x7d,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,0x35,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,0x38,0x38,
0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,0x31,0x38,0x35,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,0x38,0x38,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x20,0x5f,0x31,0x39,0x36,0x20,0x3d,0x20,0x70,0x6f,0x77,0x28,0x5f,0x31,0x38,
0x38,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,0x36,0x2c,0x20,0x5f,0x31,0x39,0x36,0x2c,0x20,0x5f,0x31,0x39,0x36,0x2c,
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#include <metal_stdlib>
@ -443,9 +473,10 @@ vs_ssao_source_metal_macos := u8.[
{
float4x4 projection;
float4 samples[64];
float ssao_power;
};
constant float4 _208 = {};
constant float4 _220 = {};
struct main0_out
{
@ -468,22 +499,27 @@ vs_ssao_source_metal_macos := u8.[
float occlusion = 0.0;
for (int i = 0; i < 64; i++)
{
float3 _121 = _26 + ((_85 * _109.samples[i].xyz) * 0.20000000298023223876953125);
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 _193;
_193.x = _140.x;
_193.y = _140.y;
float3 _155 = (_193.xyz * 0.5) + float3(0.5);
float4 _199;
_199.x = _155.x;
_199.y = _155.y;
occlusion += float(g_position.sample(ssao_smp, _199.xy).z >= _121.z);
float4 _204;
_204.x = _140.x;
_204.y = _140.y;
float3 _154 = (_204.xyz * 0.5) + float3(0.5);
float4 _210;
_210.x = _154.x;
_210.y = _154.y;
float4 _167 = g_position.sample(ssao_smp, _210.xy);
if (length(_167.xyz) > 0.00999999977648258209228515625)
{
occlusion += float(_167.z >= _121.z);
}
}
float _179 = occlusion;
float _182 = 1.0 - (_179 * 0.015625);
occlusion = _182;
out.out_color = float4(_182, _182, _182, 1.0);
float _185 = occlusion;
float _188 = 1.0 - (_185 * 0.015625);
occlusion = _188;
float _196 = powr(_188, _109.ssao_power);
out.out_color = float4(_196, _196, _196, 1.0);
return out;
}
@ -498,100 +534,110 @@ fs_ssao_source_metal_macos := u8.[
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,0x7d,0x3b,0x0a,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x30,0x38,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,
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,0x30,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,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,0x36,0x34,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,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,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,0x31,0x39,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,
0x31,0x39,0x33,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x34,0x30,0x2e,0x78,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x33,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,0x35,0x20,0x3d,0x20,0x28,
0x5f,0x31,0x39,0x33,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,0x31,
0x39,0x39,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x39,
0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x35,0x35,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x39,0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,
0x35,0x35,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,
0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x2b,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x28,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,0x31,0x39,
0x39,0x2e,0x78,0x79,0x29,0x2e,0x7a,0x20,0x3e,0x3d,0x20,0x5f,0x31,0x32,0x31,0x2e,
0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x20,0x5f,0x31,0x37,0x39,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,0x38,0x32,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,0x31,
0x37,0x39,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,0x38,0x32,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,0x31,0x38,0x32,0x2c,0x20,0x5f,0x31,0x38,0x32,0x2c,0x20,0x5f,0x31,0x38,
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,
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,0x36,0x34,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,
0x30,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x30,0x34,
0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x34,0x30,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x30,0x34,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,0x30,
0x34,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,0x30,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x31,0x30,0x2e,0x78,0x20,
0x3d,0x20,0x5f,0x31,0x35,0x34,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x5f,0x32,0x31,0x30,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,
0x34,0x20,0x5f,0x31,0x36,0x37,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,0x5f,0x32,0x31,0x30,0x2e,0x78,0x79,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x6c,0x65,0x6e,0x67,0x74,
0x68,0x28,0x5f,0x31,0x36,0x37,0x2e,0x78,0x79,0x7a,0x29,0x20,0x3e,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,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x2b,
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x36,0x37,0x2e,0x7a,0x20,0x3e,
0x3d,0x20,0x5f,0x31,0x32,0x31,0x2e,0x7a,0x29,0x3b,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,0x5f,0x31,0x38,0x35,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,0x38,0x38,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,
0x31,0x38,0x35,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,0x38,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x20,0x5f,0x31,0x39,0x36,0x20,0x3d,0x20,0x70,0x6f,0x77,0x72,0x28,0x5f,0x31,0x38,
0x38,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,0x31,0x39,0x36,0x2c,0x20,0x5f,0x31,0x39,0x36,0x2c,0x20,0x5f,0x31,0x39,0x36,
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;
@ -608,9 +654,9 @@ ssao_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc.attrs[1].glsl_name = "uv";
desc.uniform_blocks[1].stage = .FRAGMENT;
desc.uniform_blocks[1].layout = .STD140;
desc.uniform_blocks[1].size = 1088;
desc.uniform_blocks[1].size = 1104;
desc.uniform_blocks[1].glsl_uniforms[0].type = .FLOAT4;
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 68;
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;
@ -649,9 +695,9 @@ ssao_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc.attrs[1].glsl_name = "uv";
desc.uniform_blocks[1].stage = .FRAGMENT;
desc.uniform_blocks[1].layout = .STD140;
desc.uniform_blocks[1].size = 1088;
desc.uniform_blocks[1].size = 1104;
desc.uniform_blocks[1].glsl_uniforms[0].type = .FLOAT4;
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 68;
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;
@ -688,7 +734,7 @@ ssao_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc.attrs[1].base_type = .FLOAT;
desc.uniform_blocks[1].stage = .FRAGMENT;
desc.uniform_blocks[1].layout = .STD140;
desc.uniform_blocks[1].size = 1088;
desc.uniform_blocks[1].size = 1104;
desc.uniform_blocks[1].msl_buffer_n = 0;
desc.images[0].stage = .FRAGMENT;
desc.images[0].multisampled = false;

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,7 @@ 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;
@ -39,18 +40,20 @@ void main() {
float occlusion = 0.0;
for(int i = 0; i < 64; i++) {
vec3 sample_pos = tbn * samples[i].xyz;
sample_pos = frag_pos + sample_pos * 0.2;
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;
float sample_depth = texture(sampler2D(g_position, ssao_smp), offset.xy).z;
occlusion += (sample_depth >= sample_pos.z ? 1.0 : 0.0);
vec3 psample = texture(sampler2D(g_position, ssao_smp), offset.xy).xyz;
if (length(psample) > 0.01) {
occlusion += (psample.z >= sample_pos.z ? 1.0 : 0.0);
}
}
occlusion = 1.0 - (occlusion / 64.0);
out_color = vec4(vec3(occlusion), 1.0);
out_color = vec4(vec3(pow(occlusion, ssao_power)), 1.0);
}
@end

View File

@ -57,12 +57,14 @@ in vec4 fnormal;
out vec4 frag_color;
layout(binding=3) uniform trile_fs_params {
mat4 mvp_shadow;
int is_reflection;
mat4 mvp_shadow;
int is_reflection;
};
layout(binding = 0) uniform texture2D triletex;
layout(binding = 0) uniform sampler trilesmp;
layout(binding = 1) uniform texture2D ssaotex;
layout(binding = 1) uniform sampler ssaosmp;
const float PI = 3.1412854;
@ -209,7 +211,8 @@ void main() {
float metallic = float((packedMaterial >> 3) & 0x3) / 3.0;
// Ambient light.
vec3 light = 0.2 * albedo;
float ssao_sample = texelFetch(sampler2D(ssaotex, trilesmp), ivec2(gl_FragCoord.x, gl_FragCoord.y), 0).r;
vec3 light = 0.2 * albedo * ssao_sample;
vec3 N = normalize(fnormal.xyz);
vec3 V = normalize(cam - vpos.xyz);