work on ssao

This commit is contained in:
Tuomas Katajisto 2025-10-20 18:17:24 +03:00
parent c30381aa72
commit 4136bac55d
10 changed files with 967 additions and 8 deletions

View File

@ -7,7 +7,7 @@ theme_ptr : GR.Overall_Theme;
current_pipeline : s32 = 0; current_pipeline : s32 = 0;
current_slot : s32 = 0; current_slot : s32 = 0;
pipeline_names : []string = .["shadowmap", "reflection", "main", "position", "normal"]; pipeline_names : []string = .["shadowmap", "reflection", "main", "position", "normal", "ssao"];
draw_subwindow_texture_debug :: (state: *GR.Subwindow_State, r: GR.Rect, data: *void) { draw_subwindow_texture_debug :: (state: *GR.Subwindow_State, r: GR.Rect, data: *void) {
r2 := r; r2 := r;
@ -29,6 +29,7 @@ draw_subwindow_texture_debug :: (state: *GR.Subwindow_State, r: GR.Rect, data: *
case 2; image = g_rendertex; case 2; image = g_rendertex;
case 3; image = g_gbuf_position; case 3; image = g_gbuf_position;
case 4; image = g_gbuf_normal; case 4; image = g_gbuf_normal;
case 5; image = g_ssaobuf;
} }
uiTex.tex = image; uiTex.tex = image;

View File

@ -114,6 +114,7 @@ init_after_asset_pack :: () {
init_editor(); init_editor();
game_init(); game_init();
lworlds(); lworlds();
init_rendering();
load_post_process_from_pack(); load_post_process_from_pack();
} }

View File

@ -256,6 +256,19 @@ backend_process_command_buckets :: () {
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple. current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
// --- TODO: Do SSAO pass here: // --- TODO: Do SSAO pass here:
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_ssao_attachments}));
sg_apply_pipeline(gPipelines.ssao.pipeline);
gPipelines.ssao.bind.images[0] = g_gbuf_position;
gPipelines.ssao.bind.images[1] = g_gbuf_normal;
gPipelines.ssao.bind.images[2] = g_gbuf_position;
sg_apply_bindings(*gPipelines.ssao.bind);
ssao_fs_uniform : Ssao_Fs_Params;
mvp := create_viewproj(*camera);
ssao_fs_uniform.projection = mvp.floats;
ssao_fs_uniform.samples = g_ssao_samples;
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();
// 5. Main pass // 5. Main pass
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_rendertex_attachments})); sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_rendertex_attachments}));

View File

@ -2,15 +2,14 @@
#load "backend.jai"; #load "backend.jai";
init_rendering :: () {
init_ssao();
}
// Core rendering function, runs several passes. // Core rendering function, runs several passes.
render :: () { render :: () {
tasks_to_commands(); tasks_to_commands();
process_command_buckets(); process_command_buckets();
// // @ToDo: Consider a depth pre-pass here? Research required.
// shadow_pass();
// reflection_pass();
// forward_pass();
// // @ToDo: Post-processing.
} }
#scope_file #scope_file

View File

@ -24,6 +24,9 @@ g_gbuf_depth : sg_image;
g_gbuf_attachments : sg_attachments; g_gbuf_attachments : sg_attachments;
g_ssaobuf : sg_image; g_ssaobuf : sg_image;
g_ssao_noise_buf : sg_image;
g_ssaobuf_depth : sg_image;
g_ssao_attachments : sg_attachments;
gPipelines : struct { gPipelines : struct {
// G-Buffer generation for SSAO and other effects // G-Buffer generation for SSAO and other effects
@ -43,10 +46,14 @@ gPipelines : struct {
// Renders sets of triles // Renders sets of triles
trile : Pipeline_Binding; trile : Pipeline_Binding;
// Renders the ground plane. // Renders the ground plane. (just water)
plane : Pipeline_Binding; plane : Pipeline_Binding;
// Post-processing pipeline
postprocess : Pipeline_Binding; postprocess : Pipeline_Binding;
// Renders the SSAO texture using things from the gbuffer pass.
ssao: Pipeline_Binding;
} }
create_final_image :: () { create_final_image :: () {
@ -117,6 +124,7 @@ create_pipelines :: () {
create_sky_pipeline(); create_sky_pipeline();
create_plane_pipeline(); create_plane_pipeline();
create_postprocess_pipeline(); create_postprocess_pipeline();
create_ssao_pipeline();
create_shadowmap_image(); create_shadowmap_image();
create_final_image(); create_final_image();
@ -669,6 +677,101 @@ create_postprocess_pipeline :: () {
} }
create_ssao_pipeline :: () {
platconf := get_plat_conf();
pipeline: sg_pipeline_desc;
shader_desc := ssao_shader_desc(sg_query_backend());
pipeline.shader = sg_make_shader(*shader_desc);
pipeline.layout.attrs[ATTR_ssao_position] = .{ format = .FLOAT2 };
pipeline.layout.attrs[ATTR_ssao_uv] = .{ format = .FLOAT2 };
pipeline.index_type = .UINT16;
color_state := sg_color_target_state.{
blend = .{
enabled = true,
src_factor_rgb = .SRC_ALPHA,
dst_factor_rgb = .ONE_MINUS_SRC_ALPHA
}
};
pipeline.color_count = 1;
pipeline.depth = .{
write_enabled = true,
compare = .LESS_EQUAL,
pixel_format = .DEPTH
};
pipeline.colors[0] = color_state;
gPipelines.ssao.pipeline = sg_make_pipeline(*pipeline);
quad_vertices : [16]float = .[
-1.0, 1.0, 0.0, flip_if_plat(1.0), // top-let
-1.0, -1.0, 0.0, flip_if_plat(0.0), // bottom-let
1.0, -1.0, 1.0, flip_if_plat(0.0), // bottom-right
1.0, 1.0, 1.0, flip_if_plat(1.0), // top-right
];
quad_indices : [6]u16 = .[
0, 1, 2, 0, 2, 3
];
vbuffer := sg_buffer_desc.{ size = size_of(float) * 16, data = .{
ptr = quad_vertices.data,
size = 16 * 4
}};
ibuffer := sg_buffer_desc.{ size = size_of(u16) * 6, data = .{
ptr = quad_indices.data,
size = 6 * 2
},
type = .INDEXBUFFER,
};
gPipelines.ssao.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
gPipelines.ssao.bind.index_buffer = sg_make_buffer(*ibuffer);
gPipelines.ssao.bind.samplers[0] = sg_make_sampler(*(sg_sampler_desc.{
wrap_u = .CLAMP_TO_EDGE,
wrap_v = .CLAMP_TO_EDGE,
min_filter = .NEAREST,
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)};
texdesc : sg_image_desc = .{
render_target = false,
width = 4,
height = 4,
pixel_format = sg_pixel_format.RGBA8,
sample_count = 1,
data = imgdata
};
g_ssao_noise_buf = sg_make_image(*texdesc);
}
init_plane_textures :: () { init_plane_textures :: () {
gPipelines.plane.bind.images[3] = create_texture_from_pack("./resources/utiltex/water.png"); gPipelines.plane.bind.images[3] = create_texture_from_pack("./resources/utiltex/water.png");
} }

View File

@ -8,6 +8,7 @@
*/ */
#load "sky.jai"; #load "sky.jai";
#load "ssao.jai";
#load "core.jai"; #load "core.jai";
#load "tasks.jai"; #load "tasks.jai";
#load "camera.jai"; #load "camera.jai";

33
src/rendering/ssao.jai Normal file
View File

@ -0,0 +1,33 @@
#scope_file
Random :: #import "Random";
#scope_export
g_ssao_samples : [64][4]float;
g_ssao_noise : [16*4]float;
init_ssao :: () {
for 0..63 {
vec := Vector3.{
Random.random_get_zero_to_one() * 2 - 1,
Random.random_get_zero_to_one() * 2 - 1,
Random.random_get_zero_to_one(),
};
vec = normalize(vec);
vec *= Random.random_get_zero_to_one();
scale := cast(float)it/64.0;
scale = lerp(0.1, 1.0, scale*scale);
vec *= scale;
g_ssao_samples[it][0] = vec.x;
g_ssao_samples[it][1] = vec.y;
g_ssao_samples[it][2] = vec.z;
g_ssao_samples[it][3] = 0;
}
for 0..15 {
g_ssao_noise[it*4+0] = Random.random_get_zero_to_one() * 2 - 1;
g_ssao_noise[it*4+1] = Random.random_get_zero_to_one() * 2 - 1;
g_ssao_noise[it*4+2] = 0.0;
g_ssao_noise[it*4+3] = 0.0;
}
}

View File

@ -0,0 +1,749 @@
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc -i shader_ssao.glsl -o ./jai/shader_ssao.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
Overview:
=========
Shader program: 'ssao':
Get shader desc: ssao_shader_desc(sg_query_backend())
Vertex Shader: vs_ssao
Fragment Shader: fs_ssao
Attributes:
ATTR_ssao_position => 0
ATTR_ssao_uv => 1
Bindings:
Uniform block 'ssao_fs_params':
Jai struct: Ssao_Fs_Params
Bind slot: UB_ssao_fs_params => 1
Image 'g_position':
Image type: ._2D
Sample type: .FLOAT
Multisampled: false
Bind slot: IMG_g_position => 0
Image 'g_normal':
Image type: ._2D
Sample type: .FLOAT
Multisampled: false
Bind slot: IMG_g_normal => 1
Image 'tex_noise':
Image type: ._2D
Sample type: .FLOAT
Multisampled: false
Bind slot: IMG_tex_noise => 2
Sampler 'ssao_smp':
Type: .FILTERING
Bind slot: SMP_ssao_smp => 0
*/
ATTR_ssao_position :: 0;
ATTR_ssao_uv :: 1;
UB_ssao_fs_params :: 1;
IMG_g_position :: 0;
IMG_g_normal :: 1;
IMG_tex_noise :: 2;
SMP_ssao_smp :: 0;
Ssao_Fs_Params :: struct {
projection: [16]float;
samples: [64][4]float;
};
/*
#version 430
layout(location = 0) in vec2 position;
layout(location = 0) out vec2 quad_uv;
layout(location = 1) in vec2 uv;
void main()
{
gl_Position = vec4(position, 0.0, 1.0);
quad_uv = uv;
}
*/
vs_ssao_source_glsl430 := u8.[
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
0x63,0x32,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,
0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x71,0x75,0x61,0x64,
0x5f,0x75,0x76,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 430
vec4 _204;
uniform vec4 ssao_fs_params[68];
layout(binding = 16) uniform sampler2D g_position_ssao_smp;
layout(binding = 17) uniform sampler2D g_normal_ssao_smp;
layout(binding = 18) uniform sampler2D tex_noise_ssao_smp;
layout(location = 0) in vec2 quad_uv;
layout(location = 0) out vec4 out_color;
void main()
{
vec4 _25 = texture(g_position_ssao_smp, quad_uv);
vec3 _26 = _25.xyz;
vec3 _35 = normalize(texture(g_normal_ssao_smp, quad_uv).xyz);
vec3 _51 = normalize(texture(tex_noise_ssao_smp, quad_uv * vec2(320.0, 180.0)).xyz);
vec3 _60 = normalize(_51 - (_35 * dot(_51, _35)));
mat3 _85 = mat3(_60, cross(_35, _60), _35);
float occlusion = 0.0;
for (int i = 0; i < 64; i++)
{
vec3 _119 = _26 + (_85 * ssao_fs_params[i * 1 + 4].xyz);
vec4 _131 = mat4(ssao_fs_params[0], ssao_fs_params[1], ssao_fs_params[2], ssao_fs_params[3]) * vec4(_119, 1.0);
vec2 _138 = _131.xy / vec2(_131.w);
vec4 _192;
_192.x = _138.x;
_192.y = _138.y;
vec2 _150 = (_192.xy * 0.5) + vec2(0.5);
vec4 _196;
_196.x = _150.x;
_196.y = _150.y;
vec4 _161 = texture(g_position_ssao_smp, _196.xy);
float _163 = _161.z;
occlusion += (float(_163 >= _119.z) * smoothstep(0.0, 1.0, 1.0 - (_25.z - _163)));
}
float _182 = occlusion;
float _185 = 1.0 - (_182 * 0.015625);
occlusion = _185;
out_color = vec4(_185, _185, _185, 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,0x34,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,
0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x36,0x29,0x20,
0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,
0x44,0x20,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x73,0x73,0x61,
0x6f,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,
0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x37,0x29,0x20,0x75,0x6e,0x69,0x66,
0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x67,0x5f,
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x3b,
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,
0x3d,0x20,0x31,0x38,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,
0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x5f,0x6e,0x6f,0x69,0x73,
0x65,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,
0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,
0x20,0x6f,0x75,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,
0x65,0x63,0x34,0x20,0x5f,0x32,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,
0x65,0x28,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x73,0x73,0x61,
0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x36,0x20,0x3d,0x20,
0x5f,0x32,0x35,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,
0x33,0x20,0x5f,0x33,0x35,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,
0x65,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x67,0x5f,0x6e,0x6f,0x72,0x6d,
0x61,0x6c,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,0x61,
0x64,0x5f,0x75,0x76,0x29,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x76,0x65,0x63,0x33,0x20,0x5f,0x35,0x31,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,
0x6c,0x69,0x7a,0x65,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,
0x5f,0x6e,0x6f,0x69,0x73,0x65,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,
0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28,
0x33,0x32,0x30,0x2e,0x30,0x2c,0x20,0x31,0x38,0x30,0x2e,0x30,0x29,0x29,0x2e,0x78,
0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x36,
0x30,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,
0x31,0x20,0x2d,0x20,0x28,0x5f,0x33,0x35,0x20,0x2a,0x20,0x64,0x6f,0x74,0x28,0x5f,
0x35,0x31,0x2c,0x20,0x5f,0x33,0x35,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x6d,0x61,0x74,0x33,0x20,0x5f,0x38,0x35,0x20,0x3d,0x20,0x6d,0x61,0x74,0x33,0x28,
0x5f,0x36,0x30,0x2c,0x20,0x63,0x72,0x6f,0x73,0x73,0x28,0x5f,0x33,0x35,0x2c,0x20,
0x5f,0x36,0x30,0x29,0x2c,0x20,0x5f,0x33,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,
0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,
0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,0x20,0x36,
0x34,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x31,0x39,0x20,
0x3d,0x20,0x5f,0x32,0x36,0x20,0x2b,0x20,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,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x31,0x33,0x31,
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,0x31,0x39,0x2c,
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,
0x65,0x63,0x32,0x20,0x5f,0x31,0x33,0x38,0x20,0x3d,0x20,0x5f,0x31,0x33,0x31,0x2e,
0x78,0x79,0x20,0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x31,0x33,0x31,0x2e,0x77,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,
0x5f,0x31,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,
0x39,0x32,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x33,0x38,0x2e,0x78,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x32,0x2e,0x79,0x20,0x3d,0x20,
0x5f,0x31,0x33,0x38,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x76,0x65,0x63,0x32,0x20,0x5f,0x31,0x35,0x30,0x20,0x3d,0x20,0x28,0x5f,0x31,0x39,
0x32,0x2e,0x78,0x79,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x20,0x2b,0x20,0x76,0x65,
0x63,0x32,0x28,0x30,0x2e,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x31,0x39,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x36,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x35,
0x30,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,
0x36,0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,0x35,0x30,0x2e,0x79,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x31,0x36,0x31,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,0x36,0x2e,0x78,0x79,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x36,0x33,0x20,0x3d,0x20,0x5f,0x31,
0x36,0x31,0x2e,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,
0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x2b,0x3d,0x20,0x28,0x66,0x6c,0x6f,0x61,
0x74,0x28,0x5f,0x31,0x36,0x33,0x20,0x3e,0x3d,0x20,0x5f,0x31,0x31,0x39,0x2e,0x7a,
0x29,0x20,0x2a,0x20,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x30,
0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,
0x5f,0x32,0x35,0x2e,0x7a,0x20,0x2d,0x20,0x5f,0x31,0x36,0x33,0x29,0x29,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x20,0x5f,0x31,0x38,0x32,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,
0x35,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,0x31,0x38,0x32,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,
0x35,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,0x35,0x2c,0x20,0x5f,0x31,
0x38,0x35,0x2c,0x20,0x5f,0x31,0x38,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
0x7d,0x0a,0x0a,0x00,
];
/*
#version 300 es
layout(location = 0) in vec2 position;
out vec2 quad_uv;
layout(location = 1) in vec2 uv;
void main()
{
gl_Position = vec4(position, 0.0, 1.0);
quad_uv = uv;
}
*/
vs_ssao_source_glsl300es := u8.[
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,
0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,
0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,
0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,
0x76,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 300 es
precision mediump float;
precision highp int;
vec4 _204;
uniform highp vec4 ssao_fs_params[68];
uniform highp sampler2D g_position_ssao_smp;
uniform highp sampler2D g_normal_ssao_smp;
uniform highp sampler2D tex_noise_ssao_smp;
in highp vec2 quad_uv;
layout(location = 0) out highp vec4 out_color;
void main()
{
highp vec4 _25 = texture(g_position_ssao_smp, quad_uv);
highp vec3 _26 = _25.xyz;
highp vec3 _35 = normalize(texture(g_normal_ssao_smp, quad_uv).xyz);
highp vec3 _51 = normalize(texture(tex_noise_ssao_smp, quad_uv * vec2(320.0, 180.0)).xyz);
highp vec3 _60 = normalize(_51 - (_35 * dot(_51, _35)));
highp mat3 _85 = mat3(_60, cross(_35, _60), _35);
highp float occlusion = 0.0;
for (int i = 0; i < 64; i++)
{
highp vec3 _119 = _26 + (_85 * ssao_fs_params[i * 1 + 4].xyz);
highp vec4 _131 = mat4(ssao_fs_params[0], ssao_fs_params[1], ssao_fs_params[2], ssao_fs_params[3]) * vec4(_119, 1.0);
highp vec2 _138 = _131.xy / vec2(_131.w);
highp vec4 _192;
_192.x = _138.x;
_192.y = _138.y;
highp vec2 _150 = (_192.xy * 0.5) + vec2(0.5);
highp vec4 _196;
_196.x = _150.x;
_196.y = _150.y;
highp vec4 _161 = texture(g_position_ssao_smp, _196.xy);
highp float _163 = _161.z;
occlusion += (float(_163 >= _119.z) * smoothstep(0.0, 1.0, 1.0 - (_25.z - _163)));
}
highp float _182 = occlusion;
highp float _185 = 1.0 - (_182 * 0.015625);
occlusion = _185;
out_color = vec4(_185, _185, _185, 1.0);
}
*/
fs_ssao_source_glsl300es := u8.[
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x76,
0x65,0x63,0x34,0x20,0x5f,0x32,0x30,0x34,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,
0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x67,0x5f,0x70,0x6f,0x73,0x69,
0x74,0x69,0x6f,0x6e,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x75,
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x67,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x5f,
0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,
0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,
0x44,0x20,0x74,0x65,0x78,0x5f,0x6e,0x6f,0x69,0x73,0x65,0x5f,0x73,0x73,0x61,0x6f,
0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
0x76,0x65,0x63,0x32,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x3b,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
0x34,0x20,0x6f,0x75,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x32,0x35,0x20,0x3d,
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,
0x61,0x64,0x5f,0x75,0x76,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x32,0x36,0x20,0x3d,0x20,0x5f,0x32,0x35,
0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
0x76,0x65,0x63,0x33,0x20,0x5f,0x33,0x35,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,
0x6c,0x69,0x7a,0x65,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x67,0x5f,0x6e,
0x6f,0x72,0x6d,0x61,0x6c,0x5f,0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,
0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x29,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x35,
0x31,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x74,0x65,
0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x5f,0x6e,0x6f,0x69,0x73,0x65,0x5f,
0x73,0x73,0x61,0x6f,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,
0x76,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28,0x33,0x32,0x30,0x2e,0x30,0x2c,0x20,
0x31,0x38,0x30,0x2e,0x30,0x29,0x29,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x36,0x30,
0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x31,
0x20,0x2d,0x20,0x28,0x5f,0x33,0x35,0x20,0x2a,0x20,0x64,0x6f,0x74,0x28,0x5f,0x35,
0x31,0x2c,0x20,0x5f,0x33,0x35,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,
0x69,0x67,0x68,0x70,0x20,0x6d,0x61,0x74,0x33,0x20,0x5f,0x38,0x35,0x20,0x3d,0x20,
0x6d,0x61,0x74,0x33,0x28,0x5f,0x36,0x30,0x2c,0x20,0x63,0x72,0x6f,0x73,0x73,0x28,
0x5f,0x33,0x35,0x2c,0x20,0x5f,0x36,0x30,0x29,0x2c,0x20,0x5f,0x33,0x35,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x2e,0x30,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,
0x20,0x3d,0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,0x20,0x36,0x34,0x3b,0x20,0x69,0x2b,
0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x31,0x39,
0x20,0x3d,0x20,0x5f,0x32,0x36,0x20,0x2b,0x20,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,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,
0x63,0x34,0x20,0x5f,0x31,0x33,0x31,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,0x31,0x39,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,0x32,
0x20,0x5f,0x31,0x33,0x38,0x20,0x3d,0x20,0x5f,0x31,0x33,0x31,0x2e,0x78,0x79,0x20,
0x2f,0x20,0x76,0x65,0x63,0x32,0x28,0x5f,0x31,0x33,0x31,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,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x5f,0x31,0x39,0x32,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x33,0x38,0x2e,0x78,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x32,0x2e,0x79,
0x20,0x3d,0x20,0x5f,0x31,0x33,0x38,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x31,
0x35,0x30,0x20,0x3d,0x20,0x28,0x5f,0x31,0x39,0x32,0x2e,0x78,0x79,0x20,0x2a,0x20,
0x30,0x2e,0x35,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,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,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x5f,0x31,0x39,0x36,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x35,0x30,
0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x36,
0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,0x35,0x30,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,0x31,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,0x36,0x2e,0x78,0x79,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x20,0x5f,0x31,0x36,0x33,0x20,0x3d,0x20,0x5f,0x31,0x36,0x31,0x2e,0x7a,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,0x69,
0x6f,0x6e,0x20,0x2b,0x3d,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x36,
0x33,0x20,0x3e,0x3d,0x20,0x5f,0x31,0x31,0x39,0x2e,0x7a,0x29,0x20,0x2a,0x20,0x73,
0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,
0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,0x32,0x35,0x2e,0x7a,
0x20,0x2d,0x20,0x5f,0x31,0x36,0x33,0x29,0x29,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,0x38,0x32,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,0x35,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,
0x20,0x28,0x5f,0x31,0x38,0x32,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,0x35,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,0x35,0x2c,0x20,0x5f,0x31,0x38,0x35,0x2c,0x20,0x5f,0x31,0x38,0x35,0x2c,
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float2 quad_uv [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float2 position [[attribute(0)]];
float2 uv [[attribute(1)]];
};
vertex main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.gl_Position = float4(in.position, 0.0, 1.0);
out.quad_uv = in.uv;
return out;
}
*/
vs_ssao_source_metal_macos := u8.[
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x32,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x20,0x5b,0x5b,
0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,0x5b,
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,
0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,
0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,
0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,
0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,
0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x70,
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,
0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x71,0x75,0x61,0x64,
0x5f,0x75,0x76,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
];
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct ssao_fs_params
{
float4x4 projection;
float4 samples[64];
};
constant float4 _204 = {};
struct main0_out
{
float4 out_color [[color(0)]];
};
struct main0_in
{
float2 quad_uv [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], constant ssao_fs_params& _109 [[buffer(0)]], texture2d<float> g_position [[texture(0)]], texture2d<float> g_normal [[texture(1)]], texture2d<float> tex_noise [[texture(2)]], sampler ssao_smp [[sampler(0)]])
{
main0_out out = {};
float4 _25 = g_position.sample(ssao_smp, in.quad_uv);
float3 _26 = _25.xyz;
float3 _35 = fast::normalize(g_normal.sample(ssao_smp, in.quad_uv).xyz);
float3 _51 = fast::normalize(tex_noise.sample(ssao_smp, (in.quad_uv * float2(320.0, 180.0))).xyz);
float3 _60 = fast::normalize(_51 - (_35 * dot(_51, _35)));
float3x3 _85 = float3x3(_60, cross(_35, _60), _35);
float occlusion = 0.0;
for (int i = 0; i < 64; i++)
{
float3 _119 = _26 + (_85 * _109.samples[i].xyz);
float4 _131 = _109.projection * float4(_119, 1.0);
float2 _138 = _131.xy / float2(_131.w);
float4 _192;
_192.x = _138.x;
_192.y = _138.y;
float2 _150 = (_192.xy * 0.5) + float2(0.5);
float4 _196;
_196.x = _150.x;
_196.y = _150.y;
float4 _161 = g_position.sample(ssao_smp, _196.xy);
float _163 = _161.z;
occlusion += (float(_163 >= _119.z) * smoothstep(0.0, 1.0, 1.0 - (_25.z - _163)));
}
float _182 = occlusion;
float _185 = 1.0 - (_182 * 0.015625);
occlusion = _185;
out.out_color = float4(_185, _185, _185, 1.0);
return out;
}
*/
fs_ssao_source_metal_macos := u8.[
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x73,
0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x70,0x72,0x6f,
0x6a,0x65,0x63,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x73,0x5b,0x36,0x34,0x5d,0x3b,
0x0a,0x7d,0x3b,0x0a,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x30,0x34,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,
0x75,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,
0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,
0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x71,0x75,0x61,0x64,0x5f,0x75,0x76,0x20,
0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,
0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,
0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,
0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,
0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,
0x20,0x73,0x73,0x61,0x6f,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,
0x20,0x5f,0x31,0x30,0x39,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,
0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,
0x6c,0x6f,0x61,0x74,0x3e,0x20,0x67,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,
0x3e,0x20,0x67,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x74,0x65,0x78,
0x74,0x75,0x72,0x65,0x28,0x31,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,
0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x74,0x65,0x78,0x5f,
0x6e,0x6f,0x69,0x73,0x65,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,
0x32,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x73,0x73,
0x61,0x6f,0x5f,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,
0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x35,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,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,0x36,0x20,0x3d,0x20,0x5f,0x32,0x35,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,0x33,0x32,0x30,0x2e,0x30,0x2c,0x20,0x31,0x38,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,0x31,0x39,0x20,0x3d,0x20,0x5f,0x32,0x36,0x20,0x2b,0x20,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,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x31,0x33,0x31,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,0x31,0x39,0x2c,0x20,
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x32,0x20,0x5f,0x31,0x33,0x38,0x20,0x3d,0x20,0x5f,0x31,0x33,0x31,
0x2e,0x78,0x79,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x31,0x33,
0x31,0x2e,0x77,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x5f,0x31,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x5f,0x31,0x39,0x32,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x33,0x38,
0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x32,
0x2e,0x79,0x20,0x3d,0x20,0x5f,0x31,0x33,0x38,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x31,0x35,0x30,
0x20,0x3d,0x20,0x28,0x5f,0x31,0x39,0x32,0x2e,0x78,0x79,0x20,0x2a,0x20,0x30,0x2e,
0x35,0x29,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,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,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,
0x31,0x39,0x36,0x2e,0x78,0x20,0x3d,0x20,0x5f,0x31,0x35,0x30,0x2e,0x78,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x39,0x36,0x2e,0x79,0x20,0x3d,
0x20,0x5f,0x31,0x35,0x30,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x31,0x36,0x31,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,0x31,0x39,0x36,0x2e,
0x78,0x79,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x20,0x5f,0x31,0x36,0x33,0x20,0x3d,0x20,0x5f,0x31,0x36,0x31,0x2e,0x7a,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x63,0x63,0x6c,0x75,0x73,
0x69,0x6f,0x6e,0x20,0x2b,0x3d,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,
0x36,0x33,0x20,0x3e,0x3d,0x20,0x5f,0x31,0x31,0x39,0x2e,0x7a,0x29,0x20,0x2a,0x20,
0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x30,0x2e,0x30,0x2c,0x20,
0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,0x32,0x35,0x2e,
0x7a,0x20,0x2d,0x20,0x5f,0x31,0x36,0x33,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x31,0x38,
0x32,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,0x35,0x20,0x3d,0x20,
0x31,0x2e,0x30,0x20,0x2d,0x20,0x28,0x5f,0x31,0x38,0x32,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,0x35,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,0x35,0x2c,0x20,
0x5f,0x31,0x38,0x35,0x2c,0x20,0x5f,0x31,0x38,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
ssao_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc: sg_shader_desc;
desc.label = "ssao_shader";
if backend == {
case .GLCORE;
desc.vertex_func.source = xx *vs_ssao_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = xx *fs_ssao_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[0].glsl_name = "position";
desc.attrs[1].base_type = .FLOAT;
desc.attrs[1].glsl_name = "uv";
desc.uniform_blocks[1].stage = .FRAGMENT;
desc.uniform_blocks[1].layout = .STD140;
desc.uniform_blocks[1].size = 1088;
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].glsl_name = "ssao_fs_params";
desc.images[0].stage = .FRAGMENT;
desc.images[0].multisampled = false;
desc.images[0].image_type = ._2D;
desc.images[0].sample_type = .FLOAT;
desc.images[1].stage = .FRAGMENT;
desc.images[1].multisampled = false;
desc.images[1].image_type = ._2D;
desc.images[1].sample_type = .FLOAT;
desc.images[2].stage = .FRAGMENT;
desc.images[2].multisampled = false;
desc.images[2].image_type = ._2D;
desc.images[2].sample_type = .FLOAT;
desc.samplers[0].stage = .FRAGMENT;
desc.samplers[0].sampler_type = .FILTERING;
desc.image_sampler_pairs[0].stage = .FRAGMENT;
desc.image_sampler_pairs[0].image_slot = 0;
desc.image_sampler_pairs[0].sampler_slot = 0;
desc.image_sampler_pairs[0].glsl_name = "g_position_ssao_smp";
desc.image_sampler_pairs[1].stage = .FRAGMENT;
desc.image_sampler_pairs[1].image_slot = 1;
desc.image_sampler_pairs[1].sampler_slot = 0;
desc.image_sampler_pairs[1].glsl_name = "g_normal_ssao_smp";
desc.image_sampler_pairs[2].stage = .FRAGMENT;
desc.image_sampler_pairs[2].image_slot = 2;
desc.image_sampler_pairs[2].sampler_slot = 0;
desc.image_sampler_pairs[2].glsl_name = "tex_noise_ssao_smp";
case .GLES3;
desc.vertex_func.source = xx *vs_ssao_source_glsl300es;
desc.vertex_func.entry = "main";
desc.fragment_func.source = xx *fs_ssao_source_glsl300es;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[0].glsl_name = "position";
desc.attrs[1].base_type = .FLOAT;
desc.attrs[1].glsl_name = "uv";
desc.uniform_blocks[1].stage = .FRAGMENT;
desc.uniform_blocks[1].layout = .STD140;
desc.uniform_blocks[1].size = 1088;
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].glsl_name = "ssao_fs_params";
desc.images[0].stage = .FRAGMENT;
desc.images[0].multisampled = false;
desc.images[0].image_type = ._2D;
desc.images[0].sample_type = .FLOAT;
desc.images[1].stage = .FRAGMENT;
desc.images[1].multisampled = false;
desc.images[1].image_type = ._2D;
desc.images[1].sample_type = .FLOAT;
desc.images[2].stage = .FRAGMENT;
desc.images[2].multisampled = false;
desc.images[2].image_type = ._2D;
desc.images[2].sample_type = .FLOAT;
desc.samplers[0].stage = .FRAGMENT;
desc.samplers[0].sampler_type = .FILTERING;
desc.image_sampler_pairs[0].stage = .FRAGMENT;
desc.image_sampler_pairs[0].image_slot = 0;
desc.image_sampler_pairs[0].sampler_slot = 0;
desc.image_sampler_pairs[0].glsl_name = "g_position_ssao_smp";
desc.image_sampler_pairs[1].stage = .FRAGMENT;
desc.image_sampler_pairs[1].image_slot = 1;
desc.image_sampler_pairs[1].sampler_slot = 0;
desc.image_sampler_pairs[1].glsl_name = "g_normal_ssao_smp";
desc.image_sampler_pairs[2].stage = .FRAGMENT;
desc.image_sampler_pairs[2].image_slot = 2;
desc.image_sampler_pairs[2].sampler_slot = 0;
desc.image_sampler_pairs[2].glsl_name = "tex_noise_ssao_smp";
case .METAL_MACOS;
desc.vertex_func.source = xx *vs_ssao_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = xx *fs_ssao_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[1].base_type = .FLOAT;
desc.uniform_blocks[1].stage = .FRAGMENT;
desc.uniform_blocks[1].layout = .STD140;
desc.uniform_blocks[1].size = 1088;
desc.uniform_blocks[1].msl_buffer_n = 0;
desc.images[0].stage = .FRAGMENT;
desc.images[0].multisampled = false;
desc.images[0].image_type = ._2D;
desc.images[0].sample_type = .FLOAT;
desc.images[0].msl_texture_n = 0;
desc.images[1].stage = .FRAGMENT;
desc.images[1].multisampled = false;
desc.images[1].image_type = ._2D;
desc.images[1].sample_type = .FLOAT;
desc.images[1].msl_texture_n = 1;
desc.images[2].stage = .FRAGMENT;
desc.images[2].multisampled = false;
desc.images[2].image_type = ._2D;
desc.images[2].sample_type = .FLOAT;
desc.images[2].msl_texture_n = 2;
desc.samplers[0].stage = .FRAGMENT;
desc.samplers[0].sampler_type = .FILTERING;
desc.samplers[0].msl_sampler_n = 0;
desc.image_sampler_pairs[0].stage = .FRAGMENT;
desc.image_sampler_pairs[0].image_slot = 0;
desc.image_sampler_pairs[0].sampler_slot = 0;
desc.image_sampler_pairs[1].stage = .FRAGMENT;
desc.image_sampler_pairs[1].image_slot = 1;
desc.image_sampler_pairs[1].sampler_slot = 0;
desc.image_sampler_pairs[2].stage = .FRAGMENT;
desc.image_sampler_pairs[2].image_slot = 2;
desc.image_sampler_pairs[2].sampler_slot = 0;
}
return desc;
}

View File

@ -0,0 +1,59 @@
@vs vs_ssao
in vec2 position;
in vec2 uv;
out vec2 quad_uv;
void main() {
gl_Position = vec4(position, 0.0, 1.0);
quad_uv = uv;
}
@end
@fs fs_ssao
layout(binding=0) uniform texture2D g_position;
layout(binding=1) uniform texture2D g_normal;
layout(binding=2) uniform texture2D tex_noise;
layout(binding=0) uniform sampler ssao_smp;
layout(binding=1) uniform ssao_fs_params {
mat4 projection;
vec4 samples[64];
};
in vec2 quad_uv;
out vec4 out_color;
void main() {
vec3 frag_pos = texture(sampler2D(g_position, ssao_smp), quad_uv).xyz;
vec3 normal = normalize(texture(sampler2D(g_normal, ssao_smp), quad_uv).rgb);
vec2 noise_scale = vec2(1280.0/4.0, 720.0/4.0); // @Incomplete: get screen size
vec3 random_vec = normalize(texture(sampler2D(tex_noise, ssao_smp), quad_uv * noise_scale).xyz);
vec3 tangent = normalize(random_vec - normal * dot(random_vec, normal));
vec3 bitangent = cross(normal, tangent);
mat3 tbn = mat3(tangent, bitangent, normal);
float occlusion = 0.0;
for (int i = 0; i < 64; ++i) {
vec3 sample_pos = tbn * samples[i].xyz;
sample_pos = frag_pos + sample_pos;
vec4 offset = vec4(sample_pos, 1.0);
offset = projection * offset;
offset.xy /= offset.w;
offset.xy = offset.xy * 0.5 + 0.5;
float sample_depth = texture(sampler2D(g_position, ssao_smp), offset.xy).z;
float range_check = smoothstep(0.0, 1.0, 1.0 - (frag_pos.z - sample_depth));
occlusion += (sample_depth >= sample_pos.z ? 1.0 : 0.0) * range_check;
}
occlusion = 1.0 - (occlusion / 64.0);
out_color = vec4(occlusion, occlusion, occlusion, 1.0);
}
@end
@program ssao vs_ssao fs_ssao