From 8489b8466093a2bcd5042762381d5f338262d039 Mon Sep 17 00:00:00 2001 From: katajisto Date: Thu, 23 Oct 2025 17:01:04 +0300 Subject: [PATCH] fix ssao for mac --- src/shaders/jai/shader_op.jai | 71 +++++++++++------------ src/shaders/jai/shader_ssao.jai | 99 +++++++++++++++++---------------- src/shaders/shader_ssao.glsl | 4 ++ 3 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/shaders/jai/shader_op.jai b/src/shaders/jai/shader_op.jai index e35fa4a..160c782 100644 --- a/src/shaders/jai/shader_op.jai +++ b/src/shaders/jai/shader_op.jai @@ -71,14 +71,14 @@ vs_op_source_glsl430 := u8.[ { vec2 _28 = vec2(1.0) / vec2(textureSize(optex_opsmp, 0)); float result = 0.0; - for (int x = -3; x < 3; x++) + for (int x = -2; x < 2; x++) { - for (int y = -3; y < 3; y++) + for (int y = -2; y < 2; y++) { result += texture(optex_opsmp, texcoord + (vec2(float(x), float(y)) * _28)).x; } } - float _84 = result * 0.02777777798473834991455078125; + float _84 = result * 0.0625; frag_color = vec4(_84, _84, _84, 1.0); } @@ -100,10 +100,10 @@ fs_op_source_glsl430 := u8.[ 0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x30,0x29,0x29,0x3b, 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x65,0x73,0x75,0x6c, 0x74,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72, - 0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d,0x33,0x3b,0x20,0x78,0x20, - 0x3c,0x20,0x33,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a, + 0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d,0x32,0x3b,0x20,0x78,0x20, + 0x3c,0x20,0x32,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74, - 0x20,0x79,0x20,0x3d,0x20,0x2d,0x33,0x3b,0x20,0x79,0x20,0x3c,0x20,0x33,0x3b,0x20, + 0x20,0x79,0x20,0x3d,0x20,0x2d,0x32,0x3b,0x20,0x79,0x20,0x3c,0x20,0x32,0x3b,0x20, 0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x72,0x65,0x73,0x75,0x6c, 0x74,0x20,0x2b,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f,0x70,0x74, @@ -113,12 +113,10 @@ fs_op_source_glsl430 := u8.[ 0x20,0x5f,0x32,0x38,0x29,0x29,0x2e,0x78,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,0x38,0x34,0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74, - 0x20,0x2a,0x20,0x30,0x2e,0x30,0x32,0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x39,0x38, - 0x34,0x37,0x33,0x38,0x33,0x34,0x39,0x39,0x31,0x34,0x35,0x35,0x30,0x37,0x38,0x31, - 0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c, - 0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x38,0x34,0x2c,0x20,0x5f, - 0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d, - 0x0a,0x0a,0x00, + 0x20,0x2a,0x20,0x30,0x2e,0x30,0x36,0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34, + 0x28,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20, + 0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, ]; /* #version 300 es @@ -162,14 +160,14 @@ vs_op_source_glsl300es := u8.[ { highp vec2 _28 = vec2(1.0) / vec2(textureSize(optex_opsmp, 0)); highp float result = 0.0; - for (int x = -3; x < 3; x++) + for (int x = -2; x < 2; x++) { - for (int y = -3; y < 3; y++) + for (int y = -2; y < 2; y++) { result += texture(optex_opsmp, texcoord + (vec2(float(x), float(y)) * _28)).x; } } - highp float _84 = result * 0.02777777798473834991455078125; + highp float _84 = result * 0.0625; frag_color = vec4(_84, _84, _84, 1.0); } @@ -194,10 +192,10 @@ fs_op_source_glsl300es := u8.[ 0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20, 0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20, 0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d, - 0x33,0x3b,0x20,0x78,0x20,0x3c,0x20,0x33,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20, + 0x32,0x3b,0x20,0x78,0x20,0x3c,0x20,0x32,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20, 0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72, - 0x20,0x28,0x69,0x6e,0x74,0x20,0x79,0x20,0x3d,0x20,0x2d,0x33,0x3b,0x20,0x79,0x20, - 0x3c,0x20,0x33,0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x28,0x69,0x6e,0x74,0x20,0x79,0x20,0x3d,0x20,0x2d,0x32,0x3b,0x20,0x79,0x20, + 0x3c,0x20,0x32,0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2b,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72, 0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x74, @@ -207,11 +205,10 @@ fs_op_source_glsl300es := u8.[ 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, 0x38,0x34,0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2a,0x20,0x30,0x2e, - 0x30,0x32,0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x39,0x38,0x34,0x37,0x33,0x38,0x33, - 0x34,0x39,0x39,0x31,0x34,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x3b,0x0a,0x20, - 0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20, - 0x76,0x65,0x63,0x34,0x28,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x5f, - 0x38,0x34,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, + 0x30,0x36,0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x38,0x34,0x2c, + 0x20,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b, + 0x0a,0x7d,0x0a,0x0a,0x00, ]; /* #include @@ -291,14 +288,14 @@ vs_op_source_metal_macos := u8.[ main0_out out = {}; float2 _28 = float2(1.0) / float2(int2(optex.get_width(), optex.get_height())); float result = 0.0; - for (int x = -3; x < 3; x++) + for (int x = -2; x < 2; x++) { - for (int y = -3; y < 3; y++) + for (int y = -2; y < 2; y++) { result += optex.sample(opsmp, (in.texcoord + (float2(float(x), float(y)) * _28))).x; } } - float _84 = result * 0.02777777798473834991455078125; + float _84 = result * 0.0625; out.frag_color = float4(_84, _84, _84, 1.0); return out; } @@ -333,11 +330,11 @@ fs_op_source_metal_macos := u8.[ 0x74,0x65,0x78,0x2e,0x67,0x65,0x74,0x5f,0x68,0x65,0x69,0x67,0x68,0x74,0x28,0x29, 0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x65, 0x73,0x75,0x6c,0x74,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, - 0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d,0x33,0x3b, - 0x20,0x78,0x20,0x3c,0x20,0x33,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20, + 0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d,0x32,0x3b, + 0x20,0x78,0x20,0x3c,0x20,0x32,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20, 0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28, - 0x69,0x6e,0x74,0x20,0x79,0x20,0x3d,0x20,0x2d,0x33,0x3b,0x20,0x79,0x20,0x3c,0x20, - 0x33,0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x69,0x6e,0x74,0x20,0x79,0x20,0x3d,0x20,0x2d,0x32,0x3b,0x20,0x79,0x20,0x3c,0x20, + 0x32,0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x72,0x65, 0x73,0x75,0x6c,0x74,0x20,0x2b,0x3d,0x20,0x6f,0x70,0x74,0x65,0x78,0x2e,0x73,0x61, 0x6d,0x70,0x6c,0x65,0x28,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e, @@ -346,14 +343,12 @@ fs_op_source_metal_macos := u8.[ 0x61,0x74,0x28,0x79,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x38,0x29,0x29,0x29,0x2e, 0x78,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,0x38,0x34, - 0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2a,0x20,0x30,0x2e,0x30,0x32, - 0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x39,0x38,0x34,0x37,0x33,0x38,0x33,0x34,0x39, - 0x39,0x31,0x34,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x3b,0x0a,0x20,0x20,0x20, - 0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20, - 0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38, - 0x34,0x2c,0x20,0x5f,0x38,0x34,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, + 0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2a,0x20,0x30,0x2e,0x30,0x36, + 0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28, + 0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,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, ]; op_shader_desc :: (backend: sg_backend) -> sg_shader_desc { desc: sg_shader_desc; diff --git a/src/shaders/jai/shader_ssao.jai b/src/shaders/jai/shader_ssao.jai index 16d9968..4b3b9c0 100644 --- a/src/shaders/jai/shader_ssao.jai +++ b/src/shaders/jai/shader_ssao.jai @@ -476,7 +476,7 @@ vs_ssao_source_metal_macos := u8.[ float ssao_power; }; - constant float4 _220 = {}; + constant float4 _227 = {}; struct main0_out { @@ -502,24 +502,24 @@ vs_ssao_source_metal_macos := u8.[ 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 _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) + float4 _208; + _208.x = _140.x; + _208.y = _140.y; + float3 _154 = (_208.xyz * 0.5) + float3(0.5); + float4 _214; + _214.x = _154.x; + _214.y = 1.0 - _154.y; + float4 _171 = g_position.sample(ssao_smp, _214.xy); + if (length(_171.xyz) > 0.00999999977648258209228515625) { - occlusion += float(_167.z >= _121.z); + occlusion += float(_171.z >= _121.z); } } - 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); + float _189 = occlusion; + float _192 = 1.0 - (_189 * 0.015625); + occlusion = _192; + float _200 = powr(_192, _109.ssao_power); + out.out_color = float4(_200, _200, _200, 1.0); return out; } @@ -536,7 +536,7 @@ fs_ssao_source_metal_macos := u8.[ 0x61,0x74,0x34,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x73,0x5b,0x36,0x34,0x5d,0x3b, 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x73,0x61,0x6f,0x5f, 0x70,0x6f,0x77,0x65,0x72,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x63,0x6f,0x6e,0x73,0x74, - 0x61,0x6e,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x32,0x30,0x20, + 0x61,0x6e,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x32,0x37,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, @@ -601,43 +601,44 @@ fs_ssao_source_metal_macos := u8.[ 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, + 0x30,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x30,0x38, 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, + 0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x30,0x38,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, + 0x38,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, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x31,0x34,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x32,0x31,0x34,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, + 0x20,0x20,0x5f,0x32,0x31,0x34,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d, + 0x20,0x5f,0x31,0x35,0x34,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x31,0x37,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,0x32,0x31,0x34,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,0x37,0x31,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, + 0x37,0x31,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,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,0x39,0x32,0x20,0x3d,0x20,0x31,0x2e, + 0x30,0x20,0x2d,0x20,0x28,0x5f,0x31,0x38,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,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x30,0x30,0x20,0x3d,0x20,0x70,0x6f, + 0x77,0x72,0x28,0x5f,0x31,0x39,0x32,0x2c,0x20,0x5f,0x31,0x30,0x39,0x2e,0x73,0x73, + 0x61,0x6f,0x5f,0x70,0x6f,0x77,0x65,0x72,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f, + 0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x28,0x5f,0x32,0x30,0x30,0x2c,0x20,0x5f,0x32,0x30,0x30, + 0x2c,0x20,0x5f,0x32,0x30,0x30,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; diff --git a/src/shaders/shader_ssao.glsl b/src/shaders/shader_ssao.glsl index 7a3c4d4..94e252d 100644 --- a/src/shaders/shader_ssao.glsl +++ b/src/shaders/shader_ssao.glsl @@ -47,6 +47,10 @@ void main() { offset.xyz /= offset.w; offset.xyz = offset.xyz * 0.5 + 0.5; + #if !SOKOL_GLSL + offset.y = 1.0 - offset.y; + #endif + 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);