diff --git a/CMakeLists.txt b/CMakeLists.txt index 8feae46..aa62630 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ function(add_shader FILE) function(compile OUTPUT) add_custom_command( OUTPUT ${OUTPUT} - COMMAND ${SHADERCROSS} ${HLSL} -s hlsl -o ${OUTPUT} -I src + COMMAND ${SHADERCROSS} ${HLSL} -s hlsl -o ${OUTPUT} -I shaders WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} DEPENDS ${HLSL} ${DEPENDS} COMMENT ${OUTPUT} diff --git a/shaders/bin/blur.comp.msl b/shaders/bin/blur.comp.msl index 7c77e55..fc385b5 100644 --- a/shaders/bin/blur.comp.msl +++ b/shaders/bin/blur.comp.msl @@ -10,34 +10,34 @@ kernel void main0(texture2d inputTexture [[texture(0)]], texture2d= _36)) + bool _46; + if (gl_GlobalInvocationID.x < _36) { - _47 = gl_GlobalInvocationID.y >= _37; + _46 = gl_GlobalInvocationID.y >= _37; } else { - _47 = true; + _46 = true; } - if (_47) + if (_46) { break; } + float _50; + _50 = 0.0; float _51; - _51 = 0.0; - float _52; - for (int _54 = -2; _54 <= 2; _51 = _52, _54++) + for (int _53 = -2; _53 <= 2; _50 = _51, _53++) { - int _65 = int(clamp(gl_GlobalInvocationID.y + uint(_54), 0u, _37 - 1u)); - _52 = _51; - for (int _69 = -2; _69 <= 2; ) + uint _63 = clamp(gl_GlobalInvocationID.y + uint(_53), 0u, _37 - 1u); + _51 = _50; + for (int _67 = -2; _67 <= 2; ) { - _52 += inputTexture.read(uint2(uint2(uint(int(clamp(gl_GlobalInvocationID.x + uint(_69), 0u, _36 - 1u))), uint(_65))), 0u).x; - _69++; + _51 += inputTexture.read(uint2(uint2(clamp(gl_GlobalInvocationID.x + uint(_67), 0u, _36 - 1u), _63)), 0u).x; + _67++; continue; } } - outputTexture.write(float4(_51 * 0.039999999105930328369140625), uint2(gl_GlobalInvocationID.xy)); + outputTexture.write(float4(_50 * 0.039999999105930328369140625), uint2(gl_GlobalInvocationID.xy)); break; } while(false); } diff --git a/shaders/bin/blur.comp.spv b/shaders/bin/blur.comp.spv index 545a1fa..4d18b1b 100644 Binary files a/shaders/bin/blur.comp.spv and b/shaders/bin/blur.comp.spv differ diff --git a/shaders/bin/composite.comp.msl b/shaders/bin/composite.comp.msl index c3ffc0e..c9c855e 100644 --- a/shaders/bin/composite.comp.msl +++ b/shaders/bin/composite.comp.msl @@ -61,16 +61,16 @@ kernel void main0(constant type_UniformBuffer& UniformBuffer [[buffer(0)]], cons do { uint2 _93 = uint2(colorTexture.get_width(), colorTexture.get_height()); - bool _105; - if (!(gl_GlobalInvocationID.x >= _93.x)) + bool _104; + if (gl_GlobalInvocationID.x < _93.x) { - _105 = gl_GlobalInvocationID.y >= _93.y; + _104 = gl_GlobalInvocationID.y >= _93.y; } else { - _105 = true; + _104 = true; } - if (_105) + if (_104) { break; } @@ -79,7 +79,7 @@ kernel void main0(constant type_UniformBuffer& UniformBuffer [[buffer(0)]], cons uint _113 = _112.x; float4 _115 = positionTexture.read(uint2(gl_GlobalInvocationID.xy), 0u); float3 _124 = lightTexture.read(uint2(gl_GlobalInvocationID.xy), 0u).xyz; - float _188; + float _186; do { float4 _135 = UniformBuffer.ShadowTransform * float4(_115.xyz, 1.0); @@ -89,103 +89,104 @@ kernel void main0(constant type_UniformBuffer& UniformBuffer [[buffer(0)]], cons float2 _145 = _142; _145.y = _144; float _146 = _142.x; - bool _152; - if (!(_146 < 0.0)) + bool _151; + if ((isunordered(_146, 0.0) || _146 >= 0.0)) { - _152 = _146 > 1.0; + _151 = _146 > 1.0; } else { - _152 = true; + _151 = true; } - bool _157; - if (!_152) + bool _156; + if (!_151) { - _157 = _144 < 0.0; + _156 = _144 < 0.0; } else { - _157 = true; + _156 = true; } - bool _162; - if (!_157) + bool _161; + if (!_156) { - _162 = _144 > 1.0; + _161 = _144 > 1.0; } else { - _162 = true; + _161 = true; } - if (_162) + if (_161) { - _188 = 0.4000000059604644775390625; + _186 = 0.4000000059604644775390625; break; } - float _177; - if (((_113 >> 0u) & 1u) != 0u) + float _175; + if ((_113 & 1u) != 0u) { - float _173 = dot(_79[((_113 >> 1u) & 15u) - 1u], fast::normalize(float4(UniformBuffer.ShadowTransform[0][2], UniformBuffer.ShadowTransform[1][2], UniformBuffer.ShadowTransform[2][2], UniformBuffer.ShadowTransform[3][2]).xyz)); - if (_173 > 0.0) + float _171 = dot(_79[((_113 >> 1u) & 15u) - 1u], fast::normalize(float4(UniformBuffer.ShadowTransform[0][2], UniformBuffer.ShadowTransform[1][2], UniformBuffer.ShadowTransform[2][2], UniformBuffer.ShadowTransform[3][2]).xyz)); + if (_171 > 0.0) { - _188 = 0.0; + _186 = 0.0; break; } - _177 = _173; + _175 = _171; } else { - _177 = -0.7070000171661376953125; + _175 = -0.7070000171661376953125; } if (_139.z < (shadowTexture.sample(shadowSampler, _145, level(0.0)).x + 0.001000000047497451305389404296875)) { - _188 = _177 * (-0.4000000059604644775390625); + _186 = _175 * (-0.4000000059604644775390625); break; } else { - _188 = 0.0; + _186 = 0.0; break; } break; // unreachable workaround } while(false); - float3 _220; - if (((_113 >> 0u) & 1u) != 0u) + float3 _216; + if ((_113 & 1u) != 0u) { - _220 = _110 * (((_124 + float3(0.5)) + float3(_188)) - float3(ssaoTexture.read(uint2(gl_GlobalInvocationID.xy), 0u).x * 2.0)); + _216 = _110 * (((_124 + float3(0.5)) + float3(_186)) - float3(ssaoTexture.read(uint2(gl_GlobalInvocationID.xy), 0u).x * 2.0)); } else { - bool _205; - if (!(length(_110) > 0.999000012874603271484375)) + float _196 = length(_110); + bool _201; + if ((isunordered(_196, 0.999000012874603271484375) || _196 <= 0.999000012874603271484375)) { - _205 = _113 == 0u; + _201 = _113 == 0u; } else { - _205 = true; + _201 = true; } - float3 _213; - if (_205) + float3 _209; + if (_201) { - _213 = _110; + _209 = _110; } else { - _213 = _110 * ((_124 + float3(0.5)) + float3(_188)); + _209 = _110 * ((_124 + float3(0.5)) + float3(_186)); } - _220 = _213; + _216 = _209; } - float3 _246; - if (!(_113 == 0u)) + float3 _241; + if (_113 != 0u) { - float3 _227 = _115.xyz - UniformBuffer_1.PlayerPosition; - _246 = mix(_220, mix(float3(0.2199999988079071044921875, 0.3490000069141387939453125, 0.70200002193450927734375), float3(0.21199999749660491943359375, 0.7730000019073486328125, 0.9570000171661376953125), float3((precise::atan2(_227.y, length(float2(_227.xz))) + 1.57079637050628662109375) * 0.3183098733425140380859375)), float3(precise::min(powr(distance(_115.xz, UniformBuffer_1.PlayerPosition.xz) * 0.0040000001899898052215576171875, 2.5), 1.0))); + float3 _222 = _115.xyz - UniformBuffer_1.PlayerPosition; + _241 = mix(_216, mix(float3(0.2199999988079071044921875, 0.3490000069141387939453125, 0.70200002193450927734375), float3(0.21199999749660491943359375, 0.7730000019073486328125, 0.9570000171661376953125), float3((precise::atan2(_222.y, length(float2(_222.xz))) + 1.57079637050628662109375) * 0.3183098733425140380859375)), float3(precise::min(powr(distance(_115.xz, UniformBuffer_1.PlayerPosition.xz) * 0.0040000001899898052215576171875, 2.5), 1.0))); } else { - _246 = _220; + _241 = _216; } - compositeTexture.write(float4(_246, 1.0), uint2(gl_GlobalInvocationID.xy)); + compositeTexture.write(float4(_241, 1.0), uint2(gl_GlobalInvocationID.xy)); break; } while(false); } diff --git a/shaders/bin/composite.comp.spv b/shaders/bin/composite.comp.spv index 1606d45..0185f67 100644 Binary files a/shaders/bin/composite.comp.spv and b/shaders/bin/composite.comp.spv differ diff --git a/shaders/bin/depth.frag.json b/shaders/bin/depth.frag.json index ec4afe4..5da5226 100644 --- a/shaders/bin/depth.frag.json +++ b/shaders/bin/depth.frag.json @@ -1 +1 @@ -{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 0 } +{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 0, "inputs": [], "outputs": [] } diff --git a/shaders/bin/depth.vert.json b/shaders/bin/depth.vert.json index 51723fc..e6fb933 100644 --- a/shaders/bin/depth.vert.json +++ b/shaders/bin/depth.vert.json @@ -1 +1 @@ -{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 3 } +{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 3, "inputs": [{ "name": "in.var.TEXCOORD0", "type": "uint", "location": 0 }], "outputs": [] } diff --git a/shaders/bin/opaque.frag.json b/shaders/bin/opaque.frag.json index 6fb7c55..334605c 100644 --- a/shaders/bin/opaque.frag.json +++ b/shaders/bin/opaque.frag.json @@ -1 +1 @@ -{ "samplers": 1, "storage_textures": 0, "storage_buffers": 1, "uniform_buffers": 1 } +{ "samplers": 1, "storage_textures": 0, "storage_buffers": 1, "uniform_buffers": 1, "inputs": [{ "name": "in.var.TEXCOORD0", "type": "float4", "location": 0 }, { "name": "in.var.TEXCOORD1", "type": "float3", "location": 1 }, { "name": "in.var.TEXCOORD2", "type": "float3", "location": 2 }, { "name": "in.var.TEXCOORD3", "type": "uint", "location": 3 }], "outputs": [{ "name": "out.var.SV_Target0", "type": "float4", "location": 0 }, { "name": "out.var.SV_Target1", "type": "float4", "location": 1 }, { "name": "out.var.SV_Target2", "type": "float4", "location": 2 }, { "name": "out.var.SV_Target3", "type": "uint", "location": 3 }] } diff --git a/shaders/bin/opaque.frag.msl b/shaders/bin/opaque.frag.msl index 57ab27b..2cc09c3 100644 --- a/shaders/bin/opaque.frag.msl +++ b/shaders/bin/opaque.frag.msl @@ -45,43 +45,43 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_UniformBuffer& { discard_fragment(); } - uint _82 = uint(UniformBuffer.LightCount); + uint _81 = uint(UniformBuffer.LightCount); + float3 _83; + _83 = float3(0.0); float3 _84; - _84 = float3(0.0); - float3 _85; - for (uint _87 = 0u; _87 < _82; _84 = _85, _87++) + for (uint _86 = 0u; _86 < _81; _83 = _84, _86++) { - float _100 = float((lightBuffer._m0[_87].Color & 4278190080u) >> 24u); - float3 _107 = (float3(float(lightBuffer._m0[_87].X), float(lightBuffer._m0[_87].Y), float(lightBuffer._m0[_87].Z)) + float3(0.5, 0.75, 0.5)) - in.in_var_TEXCOORD0.xyz; - float _108 = length(_107); - bool _114; - if (!(_108 >= _100)) + float _99 = float((lightBuffer._m0[_86].Color & 4278190080u) >> 24u); + float3 _106 = (float3(float(lightBuffer._m0[_86].X), float(lightBuffer._m0[_86].Y), float(lightBuffer._m0[_86].Z)) + float3(0.5, 0.75, 0.5)) - in.in_var_TEXCOORD0.xyz; + float _107 = length(_106); + bool _112; + if ((isunordered(_107, _99) || _107 < _99)) { - _114 = _100 <= 0.0; + _112 = _99 <= 0.0; } else { - _114 = true; + _112 = true; } - if (_114) + if (_112) { - _85 = _84; + _84 = _83; continue; } - float _120 = fast::clamp(dot(in.in_var_TEXCOORD1, _107 / float3(_108)), 0.0, 1.0); - if (_120 <= 0.0) + float _118 = fast::clamp(dot(in.in_var_TEXCOORD1, _106 / float3(_107)), 0.0, 1.0); + if (_118 <= 0.0) { - _85 = _84; + _84 = _83; continue; } - float _126 = fast::clamp(1.0 - (_108 / _100), 0.0, 1.0); - _85 = _84 + ((float3(float((lightBuffer._m0[_87].Color & 255u) >> 0u) * 0.0039215688593685626983642578125, float((lightBuffer._m0[_87].Color & 65280u) >> 8u) * 0.0039215688593685626983642578125, float((lightBuffer._m0[_87].Color & 16711680u) >> 16u) * 0.0039215688593685626983642578125) * _120) * (_126 * _126)); + float _124 = fast::clamp(1.0 - (_107 / _99), 0.0, 1.0); + _84 = _83 + ((float3(float(lightBuffer._m0[_86].Color & 255u) * 0.0039215688593685626983642578125, float((lightBuffer._m0[_86].Color & 65280u) >> 8u) * 0.0039215688593685626983642578125, float((lightBuffer._m0[_86].Color & 16711680u) >> 16u) * 0.0039215688593685626983642578125) * _118) * (_124 * _124)); } - float3 _144 = _84 * 2.0; + float3 _141 = _83 * 2.0; out.out_var_SV_Target0 = _71; out.out_var_SV_Target1 = in.in_var_TEXCOORD0; - out.out_var_SV_Target2 = float4(_144.x, _144.y, _144.z, float4(0.0).w); - out.out_var_SV_Target3 = (0u | (in.in_var_TEXCOORD3 & 1u)) | (in.in_var_TEXCOORD3 & 30u); + out.out_var_SV_Target2 = float4(_141.x, _141.y, _141.z, float4(0.0).w); + out.out_var_SV_Target3 = (in.in_var_TEXCOORD3 & 1u) | (in.in_var_TEXCOORD3 & 30u); return out; } diff --git a/shaders/bin/opaque.frag.spv b/shaders/bin/opaque.frag.spv index b61b1b8..6726fe8 100644 Binary files a/shaders/bin/opaque.frag.spv and b/shaders/bin/opaque.frag.spv differ diff --git a/shaders/bin/opaque.vert.json b/shaders/bin/opaque.vert.json index 51723fc..9e57c16 100644 --- a/shaders/bin/opaque.vert.json +++ b/shaders/bin/opaque.vert.json @@ -1 +1 @@ -{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 3 } +{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 3, "inputs": [{ "name": "in.var.TEXCOORD0", "type": "uint", "location": 0 }], "outputs": [{ "name": "out.var.TEXCOORD0", "type": "float4", "location": 0 }, { "name": "out.var.TEXCOORD1", "type": "float3", "location": 1 }, { "name": "out.var.TEXCOORD2", "type": "float3", "location": 2 }, { "name": "out.var.TEXCOORD3", "type": "uint", "location": 3 }] } diff --git a/shaders/bin/raycast.frag.json b/shaders/bin/raycast.frag.json index ec4afe4..eaf0ba6 100644 --- a/shaders/bin/raycast.frag.json +++ b/shaders/bin/raycast.frag.json @@ -1 +1 @@ -{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 0 } +{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 0, "inputs": [], "outputs": [{ "name": "out.var.SV_Target0", "type": "float4", "location": 0 }] } diff --git a/shaders/bin/raycast.vert.json b/shaders/bin/raycast.vert.json index e362be2..cf07e95 100644 --- a/shaders/bin/raycast.vert.json +++ b/shaders/bin/raycast.vert.json @@ -1 +1 @@ -{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 2 } +{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 2, "inputs": [], "outputs": [] } diff --git a/shaders/bin/raycast.vert.spv b/shaders/bin/raycast.vert.spv index c5d65dd..19b9e89 100644 Binary files a/shaders/bin/raycast.vert.spv and b/shaders/bin/raycast.vert.spv differ diff --git a/shaders/bin/shadow.frag.json b/shaders/bin/shadow.frag.json index ec4afe4..5da5226 100644 --- a/shaders/bin/shadow.frag.json +++ b/shaders/bin/shadow.frag.json @@ -1 +1 @@ -{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 0 } +{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 0, "inputs": [], "outputs": [] } diff --git a/shaders/bin/shadow.vert.json b/shaders/bin/shadow.vert.json index 51723fc..e6fb933 100644 --- a/shaders/bin/shadow.vert.json +++ b/shaders/bin/shadow.vert.json @@ -1 +1 @@ -{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 3 } +{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 3, "inputs": [{ "name": "in.var.TEXCOORD0", "type": "uint", "location": 0 }], "outputs": [] } diff --git a/shaders/bin/sky.frag.json b/shaders/bin/sky.frag.json index ec4afe4..538fe1a 100644 --- a/shaders/bin/sky.frag.json +++ b/shaders/bin/sky.frag.json @@ -1 +1 @@ -{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 0 } +{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 0, "inputs": [{ "name": "in.var.TEXCOORD0", "type": "float3", "location": 0 }], "outputs": [{ "name": "out.var.SV_Target0", "type": "float4", "location": 0 }, { "name": "out.var.SV_Target3", "type": "uint", "location": 3 }] } diff --git a/shaders/bin/sky.vert.json b/shaders/bin/sky.vert.json index e362be2..58b6196 100644 --- a/shaders/bin/sky.vert.json +++ b/shaders/bin/sky.vert.json @@ -1 +1 @@ -{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 2 } +{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 2, "inputs": [], "outputs": [{ "name": "out.var.TEXCOORD0", "type": "float3", "location": 0 }] } diff --git a/shaders/bin/ssao.comp.msl b/shaders/bin/ssao.comp.msl index 56c9b2c..8c57461 100644 --- a/shaders/bin/ssao.comp.msl +++ b/shaders/bin/ssao.comp.msl @@ -51,105 +51,105 @@ kernel void main0(texture2d voxelTexture [[texture(0)]], texture2d uint2 _62 = uint2(ssaoTexture.get_width(), ssaoTexture.get_height()); uint _63 = _62.x; uint _64 = _62.y; - bool _74; - if (!(gl_GlobalInvocationID.x >= _63)) + bool _73; + if (gl_GlobalInvocationID.x < _63) { - _74 = gl_GlobalInvocationID.y >= _64; + _73 = gl_GlobalInvocationID.y >= _64; } else { - _74 = true; + _73 = true; } - if (_74) + if (_73) { break; } ssaoTexture.write(float4(0.0), uint2(gl_GlobalInvocationID.xy)); - uint4 _80 = voxelTexture.read(uint2(gl_GlobalInvocationID.xy), 0u); - uint _81 = _80.x; - if (!(((_81 >> 0u) & 1u) != 0u)) + uint4 _79 = voxelTexture.read(uint2(gl_GlobalInvocationID.xy), 0u); + uint _80 = _79.x; + if ((_80 & 1u) == 0u) { break; } - float2 _88 = float2(gl_GlobalInvocationID.xy); - float2 _91 = float2(float(_63), float(_64)); - float2 _92 = _88 / _91; - uint _95 = ((_81 >> 1u) & 15u) - 1u; - float4 _97 = positionTexture.read(uint2(gl_GlobalInvocationID.xy), 0u); - float _100 = precise::max(abs(_97.w), 1.0); - float2 _103 = (float2(75.0) / _91) / float2(_100); - float _105; - _105 = 0.0; + float2 _85 = float2(gl_GlobalInvocationID.xy); + float2 _88 = float2(float(_63), float(_64)); + float2 _89 = _85 / _88; + uint _92 = ((_80 >> 1u) & 15u) - 1u; + float4 _94 = positionTexture.read(uint2(gl_GlobalInvocationID.xy), 0u); + float _97 = precise::max(abs(_94.w), 1.0); + float2 _100 = (float2(75.0) / _88) / float2(_97); + float _102; + _102 = 0.0; spvUnsafeArray _57; - float _106; - for (int _108 = -2; _108 <= 2; _105 = _106, _108++) + float _103; + for (int _105 = -2; _105 <= 2; _102 = _103, _105++) { - _106 = _105; - float _114; - for (int _116 = -2; _116 <= 2; _106 = _114, _116++) + _103 = _102; + float _111; + for (int _113 = -2; _113 <= 2; _103 = _111, _113++) { - float2 _125 = _92 + (float2(float(_108), float(_116)) * _103); - uint2 _139 = uint2((_125 + (((fract(float2(sin(dot(_125, float2(127.09999847412109375, 311.70001220703125))) * 43758.546875, sin(dot(_125, float2(269.5, 183.3000030517578125))) * 43758.546875)) * 2.0) - float2(1.0)) * _103)) * _91); - bool _145; - if (!(_108 == 0)) + float2 _122 = _89 + (float2(float(_105), float(_113)) * _100); + uint2 _136 = uint2((_122 + (((fract(float2(sin(dot(_122, float2(127.09999847412109375, 311.70001220703125))) * 43758.546875, sin(dot(_122, float2(269.5, 183.3000030517578125))) * 43758.546875)) * 2.0) - float2(1.0)) * _100)) * _88); + bool _141; + if (_105 != 0) { - _145 = _116 == 0; + _141 = _113 == 0; } else { - _145 = true; + _141 = true; } - bool _155; - if (!((!((!_145) ? false : true)) ? false : true)) + bool _149; + if (!_141) { - _155 = _139.x >= _63; + _149 = _136.x >= _63; } else { - _155 = true; + _149 = true; } - bool _161; - if (!_155) + bool _155; + if (!_149) { - _161 = _139.y >= _64; + _155 = _136.y >= _64; } else { - _161 = true; + _155 = true; } - if (_161) + if (_155) { - _114 = _106; + _111 = _103; continue; } - bool _199; + bool _193; do { - if (!(((voxelTexture.read(uint2(_139), 0u).x >> 0u) & 1u) != 0u)) + if ((voxelTexture.read(uint2(_136), 0u).x & 1u) == 0u) { - _199 = false; + _193 = false; break; } - float4 _177 = positionTexture.read(uint2(_139), 0u); - float _178 = _177.z; - float _179 = _97.z; - _57[0] = _178 - _179; - _57[1] = _179 - _178; - float _184 = _177.x; - float _185 = _97.x; - _57[2] = _184 - _185; - _57[3] = _185 - _184; - float _190 = _177.y; - float _191 = _97.y; - _57[4] = _190 - _191; - _57[5] = _191 - _190; - _199 = _57[_95] > 0.0500000007450580596923828125; + float4 _171 = positionTexture.read(uint2(_136), 0u); + float _172 = _171.z; + float _173 = _94.z; + _57[0] = _172 - _173; + _57[1] = _173 - _172; + float _178 = _171.x; + float _179 = _94.x; + _57[2] = _178 - _179; + _57[3] = _179 - _178; + float _184 = _171.y; + float _185 = _94.y; + _57[4] = _184 - _185; + _57[5] = _185 - _184; + _193 = _57[_92] > 0.0500000007450580596923828125; break; } while(false); - _114 = _106 + (float(_199) / precise::max(distance(_88, float2(_139)), 1.0)); + _111 = _103 + (float(_193) / precise::max(distance(_85, float2(_136)), 1.0)); } } - ssaoTexture.write(float4(_105 / _100), uint2(gl_GlobalInvocationID.xy)); + ssaoTexture.write(float4(_102 / _97), uint2(gl_GlobalInvocationID.xy)); break; } while(false); } diff --git a/shaders/bin/ssao.comp.spv b/shaders/bin/ssao.comp.spv index b5c1384..c02ba66 100644 Binary files a/shaders/bin/ssao.comp.spv and b/shaders/bin/ssao.comp.spv differ diff --git a/shaders/bin/transparent.frag.json b/shaders/bin/transparent.frag.json index 491809c..70f10ee 100644 --- a/shaders/bin/transparent.frag.json +++ b/shaders/bin/transparent.frag.json @@ -1 +1 @@ -{ "samplers": 3, "storage_textures": 0, "storage_buffers": 1, "uniform_buffers": 3 } +{ "samplers": 3, "storage_textures": 0, "storage_buffers": 1, "uniform_buffers": 3, "inputs": [{ "name": "in.var.TEXCOORD0", "type": "float4", "location": 0 }, { "name": "in.var.TEXCOORD1", "type": "float3", "location": 1 }, { "name": "in.var.TEXCOORD2", "type": "float3", "location": 2 }, { "name": "in.var.TEXCOORD3", "type": "uint", "location": 3 }, { "name": "in.var.TEXCOORD4", "type": "float2", "location": 4 }], "outputs": [{ "name": "out.var.SV_Target0", "type": "float4", "location": 0 }] } diff --git a/shaders/bin/transparent.frag.msl b/shaders/bin/transparent.frag.msl index c8000b3..773a2de 100644 --- a/shaders/bin/transparent.frag.msl +++ b/shaders/bin/transparent.frag.msl @@ -59,109 +59,109 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_UniformBuffer& float _131 = float((lightBuffer._m0[_118].Color & 4278190080u) >> 24u); float3 _138 = (float3(float(lightBuffer._m0[_118].X), float(lightBuffer._m0[_118].Y), float(lightBuffer._m0[_118].Z)) + float3(0.5, 0.75, 0.5)) - in.in_var_TEXCOORD0.xyz; float _139 = length(_138); - bool _145; - if (!(_139 >= _131)) + bool _144; + if ((isunordered(_139, _131) || _139 < _131)) { - _145 = _131 <= 0.0; + _144 = _131 <= 0.0; } else { - _145 = true; + _144 = true; } - if (_145) + if (_144) { _116 = _115; continue; } - float _151 = fast::clamp(dot(in.in_var_TEXCOORD1, _138 / float3(_139)), 0.0, 1.0); - if (_151 <= 0.0) + float _150 = fast::clamp(dot(in.in_var_TEXCOORD1, _138 / float3(_139)), 0.0, 1.0); + if (_150 <= 0.0) { _116 = _115; continue; } - float _157 = fast::clamp(1.0 - (_139 / _131), 0.0, 1.0); - _116 = _115 + ((float3(float((lightBuffer._m0[_118].Color & 255u) >> 0u) * 0.0039215688593685626983642578125, float((lightBuffer._m0[_118].Color & 65280u) >> 8u) * 0.0039215688593685626983642578125, float((lightBuffer._m0[_118].Color & 16711680u) >> 16u) * 0.0039215688593685626983642578125) * _151) * (_157 * _157)); + float _156 = fast::clamp(1.0 - (_139 / _131), 0.0, 1.0); + _116 = _115 + ((float3(float(lightBuffer._m0[_118].Color & 255u) * 0.0039215688593685626983642578125, float((lightBuffer._m0[_118].Color & 65280u) >> 8u) * 0.0039215688593685626983642578125, float((lightBuffer._m0[_118].Color & 16711680u) >> 16u) * 0.0039215688593685626983642578125) * _150) * (_156 * _156)); } - float _239; + float _235; do { - float4 _186 = UniformBuffer_1.ShadowTransform * float4(in.in_var_TEXCOORD0.xyz, 1.0); - float3 _190 = _186.xyz / float3(_186.w); - float2 _193 = (_190.xy * 0.5) + float2(0.5); - float _195 = 1.0 - _193.y; - float2 _196 = _193; - _196.y = _195; - float _197 = _193.x; - bool _203; - if (!(_197 < 0.0)) + float4 _184 = UniformBuffer_1.ShadowTransform * float4(in.in_var_TEXCOORD0.xyz, 1.0); + float3 _188 = _184.xyz / float3(_184.w); + float2 _191 = (_188.xy * 0.5) + float2(0.5); + float _193 = 1.0 - _191.y; + float2 _194 = _191; + _194.y = _193; + float _195 = _191.x; + bool _200; + if ((isunordered(_195, 0.0) || _195 >= 0.0)) { - _203 = _197 > 1.0; + _200 = _195 > 1.0; } else { - _203 = true; + _200 = true; } - bool _208; - if (!_203) + bool _205; + if (!_200) { - _208 = _195 < 0.0; + _205 = _193 < 0.0; } else { - _208 = true; + _205 = true; } - bool _213; - if (!_208) + bool _210; + if (!_205) { - _213 = _195 > 1.0; + _210 = _193 > 1.0; } else { - _213 = true; + _210 = true; } - if (_213) + if (_210) { - _239 = 0.4000000059604644775390625; + _235 = 0.4000000059604644775390625; break; } - float _228; - if (((in.in_var_TEXCOORD3 >> 0u) & 1u) != 0u) + float _224; + if ((in.in_var_TEXCOORD3 & 1u) != 0u) { - float _224 = dot(in.in_var_TEXCOORD1, fast::normalize(float4(UniformBuffer_1.ShadowTransform[0][2], UniformBuffer_1.ShadowTransform[1][2], UniformBuffer_1.ShadowTransform[2][2], UniformBuffer_1.ShadowTransform[3][2]).xyz)); - if (_224 > 0.0) + float _220 = dot(in.in_var_TEXCOORD1, fast::normalize(float4(UniformBuffer_1.ShadowTransform[0][2], UniformBuffer_1.ShadowTransform[1][2], UniformBuffer_1.ShadowTransform[2][2], UniformBuffer_1.ShadowTransform[3][2]).xyz)); + if (_220 > 0.0) { - _239 = 0.0; + _235 = 0.0; break; } - _228 = _224; + _224 = _220; } else { - _228 = -0.7070000171661376953125; + _224 = -0.7070000171661376953125; } - if (_190.z < (shadowTexture.sample(shadowSampler, _196, level(0.0)).x + 0.001000000047497451305389404296875)) + if (_188.z < (shadowTexture.sample(shadowSampler, _194, level(0.0)).x + 0.001000000047497451305389404296875)) { - _239 = _228 * (-0.4000000059604644775390625); + _235 = _224 * (-0.4000000059604644775390625); break; } else { - _239 = 0.0; + _235 = 0.0; break; } break; // unreachable workaround } while(false); - float3 _243 = in.in_var_TEXCOORD0.xyz - UniformBuffer_2.PlayerPosition; - float _275; + float3 _239 = in.in_var_TEXCOORD0.xyz - UniformBuffer_2.PlayerPosition; + float _271; if (((in.in_var_TEXCOORD3 >> 26u) & 63u) == 16u) { - _275 = _110 + ((in.in_var_TEXCOORD0.y - positionTexture.sample(positionSampler, in.in_var_TEXCOORD4).y) * 0.100000001490116119384765625); + _271 = _110 + ((in.in_var_TEXCOORD0.y - positionTexture.sample(positionSampler, in.in_var_TEXCOORD4).y) * 0.100000001490116119384765625); } else { - _275 = _110; + _271 = _110; } - out.out_var_SV_Target0 = float4(mix(_108.xyz * (((_115 * 2.0) + float3(0.5)) + float3(_239)), mix(float3(0.2199999988079071044921875, 0.3490000069141387939453125, 0.70200002193450927734375), float3(0.21199999749660491943359375, 0.7730000019073486328125, 0.9570000171661376953125), float3((precise::atan2(_243.y, length(float2(_243.xz))) + 1.57079637050628662109375) * 0.3183098733425140380859375)), float3(precise::min(powr(distance(in.in_var_TEXCOORD0.xz, UniformBuffer_2.PlayerPosition.xz) * 0.0040000001899898052215576171875, 2.5), 1.0))), _275); + out.out_var_SV_Target0 = float4(mix(_108.xyz * (((_115 * 2.0) + float3(0.5)) + float3(_235)), mix(float3(0.2199999988079071044921875, 0.3490000069141387939453125, 0.70200002193450927734375), float3(0.21199999749660491943359375, 0.7730000019073486328125, 0.9570000171661376953125), float3((precise::atan2(_239.y, length(float2(_239.xz))) + 1.57079637050628662109375) * 0.3183098733425140380859375)), float3(precise::min(powr(distance(in.in_var_TEXCOORD0.xz, UniformBuffer_2.PlayerPosition.xz) * 0.0040000001899898052215576171875, 2.5), 1.0))), _271); return out; } diff --git a/shaders/bin/transparent.frag.spv b/shaders/bin/transparent.frag.spv index d551712..f451728 100644 Binary files a/shaders/bin/transparent.frag.spv and b/shaders/bin/transparent.frag.spv differ diff --git a/shaders/bin/transparent.vert.json b/shaders/bin/transparent.vert.json index 51723fc..0199b49 100644 --- a/shaders/bin/transparent.vert.json +++ b/shaders/bin/transparent.vert.json @@ -1 +1 @@ -{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 3 } +{ "samplers": 0, "storage_textures": 0, "storage_buffers": 0, "uniform_buffers": 3, "inputs": [{ "name": "in.var.TEXCOORD0", "type": "uint", "location": 0 }], "outputs": [{ "name": "out.var.TEXCOORD0", "type": "float4", "location": 0 }, { "name": "out.var.TEXCOORD1", "type": "float3", "location": 1 }, { "name": "out.var.TEXCOORD2", "type": "float3", "location": 2 }, { "name": "out.var.TEXCOORD3", "type": "uint", "location": 3 }, { "name": "out.var.TEXCOORD4", "type": "float2", "location": 4 }] } diff --git a/shaders/bin/ui.comp.msl b/shaders/bin/ui.comp.msl index a760167..29daf19 100644 --- a/shaders/bin/ui.comp.msl +++ b/shaders/bin/ui.comp.msl @@ -23,142 +23,142 @@ kernel void main0(constant type_UniformBuffer& UniformBuffer [[buffer(0)]], cons do { uint2 _59 = uint2(colorTexture.get_width(), colorTexture.get_height()); - bool _71; - if (!(gl_GlobalInvocationID.x >= _59.x)) + bool _70; + if (gl_GlobalInvocationID.x < _59.x) { - _71 = gl_GlobalInvocationID.y >= _59.y; + _70 = gl_GlobalInvocationID.y >= _59.y; } else { - _71 = true; + _70 = true; } - if (_71) + if (_70) { break; } - float2 _76 = float2(UniformBuffer.Viewport); - float2 _77 = _76 * float2(0.0007812500116415321826934814453125, 0.001388888922519981861114501953125); - float _80 = precise::max(_77.x, _77.y); - float _81 = 50.0 * _80; - float _82 = 10.0 * _80; - float2 _85 = float2(_82) + float2(_81); - float _86 = float(gl_GlobalInvocationID.x); - float _93 = float(uint(UniformBuffer.Viewport.y) - gl_GlobalInvocationID.y); - bool _99; - if (_86 > _82) + float2 _75 = float2(UniformBuffer.Viewport); + float2 _76 = _75 * float2(0.0007812500116415321826934814453125, 0.001388888922519981861114501953125); + float _79 = precise::max(_76.x, _76.y); + float _80 = 50.0 * _79; + float _81 = 10.0 * _79; + float2 _84 = float2(_81) + float2(_80); + float _85 = float(gl_GlobalInvocationID.x); + float _92 = float(uint(UniformBuffer.Viewport.y) - gl_GlobalInvocationID.y); + bool _98; + if (_85 > _81) { - _99 = _86 < _85.x; + _98 = _85 < _84.x; } else { - _99 = false; + _98 = false; } - bool _103; - if (_99) + bool _102; + if (_98) { - _103 = _93 > _82; + _102 = _92 > _81; } else { - _103 = false; + _102 = false; } - bool _108; - if (_103) + bool _107; + if (_102) { - _108 = _93 < _85.y; + _107 = _92 < _84.y; } else { - _108 = false; + _107 = false; } - if (_108) + if (_107) { - float3 _121 = float3((_86 - _82) / _81, 1.0 - ((_93 - _82) / _81), float(UniformBuffer_1.Index)); - float4 _123 = atlasTexture.sample(atlasSampler, _121.xy, uint(rint(_121.z)), level(0.0)); - float _124 = _123.w; - if (_124 > 0.001000000047497451305389404296875) + float3 _120 = float3((_85 - _81) / _80, 1.0 - ((_92 - _81) / _80), float(UniformBuffer_1.Index)); + float4 _122 = atlasTexture.sample(atlasSampler, _120.xy, uint(rint(_120.z)), level(0.0)); + float _123 = _122.w; + if (_123 > 0.001000000047497451305389404296875) { spvImageFence(colorTexture); - float4 _130 = colorTexture.read(uint2(gl_GlobalInvocationID.xy)); - float _131 = fast::clamp(_124, 0.0, 1.0); - float _136 = 1.0 - _131; - colorTexture.write(float4((_123.xyz * _131) + (_130.xyz * _136), _131 + (_130.w * _136)), uint2(gl_GlobalInvocationID.xy)); + float4 _129 = colorTexture.read(uint2(gl_GlobalInvocationID.xy)); + float _130 = fast::clamp(_123, 0.0, 1.0); + float _135 = 1.0 - _130; + colorTexture.write(float4((_122.xyz * _130) + (_129.xyz * _135), _130 + (_129.w * _135)), uint2(gl_GlobalInvocationID.xy)); break; } } - float _146 = 8.0 * _80; - float _147 = 2.0 * _80; - float2 _148 = _76 * 0.5; - float2 _149 = float2(_146, _147); - float2 _150 = _148 - _149; - float2 _151 = _148 + _149; - float2 _152 = float2(_147, _146); - float2 _153 = _148 - _152; - float2 _154 = _148 + _152; - bool _161; - if (_86 > _150.x) + float _145 = 8.0 * _79; + float _146 = 2.0 * _79; + float2 _147 = _75 * 0.5; + float2 _148 = float2(_145, _146); + float2 _149 = _147 - _148; + float2 _150 = _147 + _148; + float2 _151 = float2(_146, _145); + float2 _152 = _147 - _151; + float2 _153 = _147 + _151; + bool _160; + if (_85 > _149.x) { - _161 = _93 > _150.y; + _160 = _92 > _149.y; } else { - _161 = false; + _160 = false; } - bool _166; - if (_161) + bool _165; + if (_160) { - _166 = _86 < _151.x; + _165 = _85 < _150.x; } else { - _166 = false; + _165 = false; } - bool _171; - if (_166) + bool _170; + if (_165) { - _171 = _93 < _151.y; + _170 = _92 < _150.y; } else { - _171 = false; + _170 = false; } - bool _192; - if (!_171) + bool _191; + if (!_170) { - bool _181; - if (_86 > _153.x) + bool _180; + if (_85 > _152.x) { - _181 = _93 > _153.y; + _180 = _92 > _152.y; } else { - _181 = false; + _180 = false; } - bool _186; - if (_181) + bool _185; + if (_180) { - _186 = _86 < _154.x; + _185 = _85 < _153.x; } else { - _186 = false; + _185 = false; } - bool _191; - if (_186) + bool _190; + if (_185) { - _191 = _93 < _154.y; + _190 = _92 < _153.y; } else { - _191 = false; + _190 = false; } - _192 = _191; + _191 = _190; } else { - _192 = true; + _191 = true; } - if (_192) + if (_191) { colorTexture.write(float4(1.0), uint2(gl_GlobalInvocationID.xy)); break; diff --git a/shaders/bin/ui.comp.spv b/shaders/bin/ui.comp.spv index fa4614e..2f331a8 100644 Binary files a/shaders/bin/ui.comp.spv and b/shaders/bin/ui.comp.spv differ diff --git a/shaders/shader.hlsl b/shaders/shader.hlsl index 4c53b17..2f0f26c 100644 --- a/shaders/shader.hlsl +++ b/shaders/shader.hlsl @@ -1,7 +1,8 @@ #ifndef SHADER_HLSL #define SHADER_HLSL -#include "voxel.inc" +// https://github.com/libsdl-org/SDL_shadercross/issues/211 +#include "../src/voxel.inc" static const float kEpsilon = 0.001f; static const float kPi = 3.14159265f; diff --git a/src/player.c b/src/player.c index 4c73f61..f6ddccc 100644 --- a/src/player.c +++ b/src/player.c @@ -227,7 +227,6 @@ void player_move(player_t* player, float dt) { player->is_on_ground = false; } - player->query = world_raycast(&player->camera, REACH); } else { @@ -237,6 +236,7 @@ void player_move(player_t* player, float dt) float dz = keys[SDL_SCANCODE_W] - keys[SDL_SCANCODE_S]; camera_move(&player->camera, dx * speed * dt, dy * speed * dt, dz * speed * dt); } + player->query = world_raycast(&player->camera, REACH); } void player_place_block(const player_t* player)