This commit is contained in:
peterino2 2025-06-07 14:16:56 -07:00
parent fc54c0dd55
commit d90d9276b2
57 changed files with 24888 additions and 23 deletions

View File

@ -16,9 +16,6 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/platform.zig"),
});
const test_vert = sdl3.addShaderDefinition(b, "../../lib/sdl3", optimize, "test.vert", b.path("shaders/test.vert.json"));
mod.addImport("test.vert", test_vert);
const tests = b.addTest(.{
.target = target,
.optimize = optimize,

View File

@ -32,22 +32,22 @@ pub fn build(b: *std.Build) void {
}
}
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "sample.vert", b.path("shaders/sample.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "meshes.vert", b.path("shaders/meshes.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "lit_mesh.frag", b.path("shaders/lit_mesh.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "sample.vert", b.path("shaders/sample.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "meshes.vert", b.path("shaders/meshes.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "lit_mesh.frag", b.path("shaders/lit_mesh.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "debug.frag", b.path("shaders/debug.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "debug.vert", b.path("shaders/debug.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "debug.frag", b.path("shaders/debug.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "debug.vert", b.path("shaders/debug.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "depthOnly.frag", b.path("shaders/depthOnly.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "depthOnly.frag", b.path("shaders/depthOnly.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "skybox.frag", b.path("shaders/skybox.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "skybox.vert", b.path("shaders/skybox.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "skybox.frag", b.path("shaders/skybox.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "skybox.vert", b.path("shaders/skybox.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "postProc.frag", b.path("shaders/postProc.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "postProc.vert", b.path("shaders/postProc.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "postProc.frag", b.path("shaders/postProc.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "postProc.vert", b.path("shaders/postProc.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "ssao.frag", b.path("shaders/ssao.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "ssao.frag", b.path("shaders/ssao.frag.json"));
// ========== tests ==========
const tests = b.addTest(.{

View File

@ -27,11 +27,11 @@ pub fn build(b: *std.Build) void {
}
// shaders
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "rect.vert", b.path("shaders/rect.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "rect.frag", b.path("shaders/rect.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "rect.vert", b.path("shaders/rect.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "rect.frag", b.path("shaders/rect.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "text.vert", b.path("shaders/text.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", optimize, "text.frag", b.path("shaders/text.frag.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "text.vert", b.path("shaders/text.vert.json"));
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "text.frag", b.path("shaders/text.frag.json"));
// ========== tests ==========
const tests = b.addTest(.{

View File

@ -1,5 +1,5 @@
[ENGINE ]: defining componentScene
[ENGINE ]: Component container created scene.Scene @1c60c524798
[ENGINE ]: Component container created scene.Scene @16ed1884f98
[ENGINE ]: creating lua metatable Scene
[ENGINE ]: module started >>>> core <<<<
[ENGINE ]: platform settings windowing.PlatformParams{ .extent = math.Vector2Type(c_int,"Vector2c"[0..8]){ .x = 1600, .y = 900 }, .windowName = { 66, 97, 99, 107, 108, 111, 103, 32, 69, 110, 103, 105, 110, 101 }, .icon = { 116, 101, 120, 116, 117, 114, 101, 115, 47, 105, 99, 111, 110, 46, 112, 110, 103 }, .hasVideo = true }
@ -56,10 +56,10 @@
[ENGINE ]: creating shader postProc.vert => _shaders/spv/postProc.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
[ENGINE ]: creating shader ssao.frag => _shaders/spv/ssao.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 3, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 1 }
[ENGINE ]: defining component_MeshComponent
[ENGINE ]: Component container created meshes.MeshComponent @24618af28e8
[ENGINE ]: Component container created meshes.MeshComponent @16e88766338
[ENGINE ]: creating lua metatable Mesh
[ENGINE ]: defining component_CameraComponent
[ENGINE ]: Component container created camera.CameraComponent @1c60e4b9d68
[ENGINE ]: Component container created camera.CameraComponent @16ed3fef308
[ENGINE ]: creating lua metatable Camera
[ENGINE ]: module started >>>> rend <<<<
[GRAPHICS ]: imgui startup
@ -97,7 +97,7 @@
[ENGINE ]: install mesh by name 38
[ENGINE ]: Processing exit signals
[ENGINE ]: checking everything is ready to exit
[ENGINE ]: checking everything is ready to exit engineObject.InterfaceRef2(engineObject.EngineObjectVTable){ .ptr = anyopaque@1c60c49a9e8, .vtable = engineObject.EngineObjectVTable{ .typeName = { 119, 105, 110, 100, 111, 119, 105, 110, 103, 46, 80, 108, 97, 116, 102, 111, 114, 109, 73, 110, 115, 116, 97, 110, 99, 101 }, .typeSize = 112, .typeAlign = 8, .singletonName = { 112, 108, 97, 116, 102, 111, 114, 109, 46, 73, 110, 115, 116, 97, 110, 99, 101 }, .init_func = fn (mem.Allocator) error{OutOfMemory,UnknownStatePanic,BadInit,UnknownError}!*anyopaque@7ff66491a590, .tick_func = null, .engineDraw_func = null, .preTick_func = null, .deinit_func = fn (*anyopaque) void@7ff66491a7f0, .postInit_func = null, .processEvents = null, .exitSignal_func = fn (*anyopaque) error{OutOfMemory,UnknownStatePanic,BadInit,UnknownError}!void@7ff66491a6d0, .readyToExit_func = fn (*anyopaque) bool@7ff66491a750, .prepare_func = null, .fieldListHash = null, .fieldList = null, .slackSize = null } }
[ENGINE ]: checking everything is ready to exit engineObject.InterfaceRef2(engineObject.EngineObjectVTable){ .ptr = anyopaque@16ed18a2458, .vtable = engineObject.EngineObjectVTable{ .typeName = { 119, 105, 110, 100, 111, 119, 105, 110, 103, 46, 80, 108, 97, 116, 102, 111, 114, 109, 73, 110, 115, 116, 97, 110, 99, 101 }, .typeSize = 112, .typeAlign = 8, .singletonName = { 112, 108, 97, 116, 102, 111, 114, 109, 46, 73, 110, 115, 116, 97, 110, 99, 101 }, .init_func = fn (mem.Allocator) error{OutOfMemory,UnknownStatePanic,BadInit,UnknownError}!*anyopaque@7ff7f0769030, .tick_func = null, .engineDraw_func = null, .preTick_func = null, .deinit_func = fn (*anyopaque) void@7ff7f0769290, .postInit_func = null, .processEvents = null, .exitSignal_func = fn (*anyopaque) error{OutOfMemory,UnknownStatePanic,BadInit,UnknownError}!void@7ff7f0769170, .readyToExit_func = fn (*anyopaque) bool@7ff7f07691f0, .prepare_func = null, .fieldListHash = null, .fieldList = null, .slackSize = null } }
[ENGINE ]: exiting
[ENGINE ]: module shutting down >>>> ui <<<<
[ENGINE ]: module shutting down >>>> imgui <<<<

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,25 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 out_var_SV_Target0 [[color(0)]];
float4 out_var_SV_Target1 [[color(1)]];
};
struct main0_in
{
float3 in_var_TEXCOORD0 [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
float4 _20 = float4(in.in_var_TEXCOORD0 * 4.0, 1.0);
out.out_var_SV_Target0 = _20;
out.out_var_SV_Target1 = _20;
return out;
}

View File

@ -0,0 +1,40 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Scene
{
float4x4 Model;
float4 Color;
};
struct type_StructuredBuffer_Scene
{
Scene _m0[1];
};
struct type_Uniforms
{
float4x4 ViewProjection;
};
struct main0_out
{
float3 out_var_TEXCOORD0 [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_var_TEXCOORD0 [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(1)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
out.out_var_TEXCOORD0 = scene._m0[gl_InstanceIndex].Color.xyz;
out.gl_Position = Uniforms.ViewProjection * (scene._m0[gl_InstanceIndex].Model * float4(in.in_var_TEXCOORD0, 1.0));
return out;
}

View File

@ -0,0 +1,17 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 out_var_SV_Target0 [[color(0)]];
};
fragment main0_out main0()
{
main0_out out = {};
out.out_var_SV_Target0 = float4(1.0);
return out;
}

View File

@ -0,0 +1,198 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct type_Uniforms
{
float4 viewPos;
float4 lightPosition;
float4 directionalLight;
float4 directionalLightColor;
float2 screenSize;
float lightPower;
float time;
};
struct Scene
{
float4x4 Model;
uint textureMode;
uint pad0;
uint pad1;
uint pad2;
};
struct type_StructuredBuffer_Scene
{
Scene _m0[1];
};
constant float4 _90 = {};
constant float3 _92 = {};
struct main0_out
{
float4 out_var_SV_Target0 [[color(0)]];
float4 out_var_SV_Target1 [[color(1)]];
float4 out_var_SV_Target2 [[color(2)]];
float4 out_var_SV_Target3 [[color(3)]];
};
struct main0_in
{
float2 in_var_TEXCOORD0 [[user(locn0)]];
float3 in_var_TEXCOORD1 [[user(locn1)]];
float3 in_var_TEXCOORD2 [[user(locn2)]];
float4 in_var_TEXCOORD3 [[user(locn3)]];
uint in_var_TEXCOORD4 [[user(locn4)]];
float3 in_var_TEXCOORD5 [[user(locn5)]];
};
fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(1)]], texture2d<float> Texture0 [[texture(0)]], texture2d<float> Texture1 [[texture(1)]], texture2d<float> Texture2 [[texture(2)]], texture2d<float> DirectionalShadowDepthMap [[texture(3)]], sampler Sampler0 [[sampler(0)]], sampler Sampler1 [[sampler(1)]], sampler Sampler2 [[sampler(2)]], sampler DirectionalShadowSampler [[sampler(3)]])
{
main0_out out = {};
int _102 = int(scene._m0[in.in_var_TEXCOORD4].textureMode);
int _103 = _102 & 240;
float4 _137;
if (_103 == 16)
{
float3 _124 = float3(Texture0.sample(Sampler0, in.in_var_TEXCOORD0).x, Texture1.sample(Sampler1, in.in_var_TEXCOORD0).x, Texture2.sample(Sampler2, in.in_var_TEXCOORD0).x) + float3(-0.0625, -0.5, -0.5);
_137 = float4(dot(_124, float3(1.164000034332275390625, 0.0, 1.7929999828338623046875)), dot(_124, float3(1.164000034332275390625, -0.212999999523162841796875, -0.53299999237060546875)), dot(_124, float3(1.164000034332275390625, 2.111999988555908203125, 0.0)), 1.0);
}
else
{
float4 _136;
if (_103 == 0)
{
_136 = Texture0.sample(Sampler0, in.in_var_TEXCOORD0);
}
else
{
_136 = _90;
}
_137 = _136;
}
float4 _143;
if ((_102 & 1) == 1)
{
_143 = powr(_137, float4(2.2000000476837158203125));
}
else
{
_143 = _137;
}
if (_143.w < 0.00999999977648258209228515625)
{
discard_fragment();
}
float3 _153 = float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * Uniforms.lightPower;
float3 _200;
do
{
float3 _157 = Uniforms.lightPosition.xyz - in.in_var_TEXCOORD1;
float _158 = length(_157);
float _159 = _158 * _158;
float _165;
if (_158 > 2.0)
{
_165 = 0.5 / _159;
}
else
{
_165 = 1.0 / _159;
}
float _170;
if (_158 > 4.0)
{
_170 = _165 * 0.5;
}
else
{
_170 = _165;
}
float _172 = (_158 > 15.0) ? 0.0 : _170;
float _174 = (_172 > 1.0) ? 1.0 : _172;
if (length(in.in_var_TEXCOORD2) < 0.100000001490116119384765625)
{
_200 = (in.in_var_TEXCOORD1 * _153) * _174;
break;
}
float3 _181 = fast::normalize(_157);
_200 = ((_153 * precise::max(dot(_181, in.in_var_TEXCOORD2), 0.0)) * _174) + (((_153 * powr(precise::max(dot(in.in_var_TEXCOORD2, fast::normalize(_181 + fast::normalize(in.in_var_TEXCOORD1 - Uniforms.viewPos.xyz))), 0.0), 30.0)) * 2.0) * _174);
break;
} while(false);
float3 _217 = ((in.in_var_TEXCOORD3.xyz / float3(in.in_var_TEXCOORD3.w)) * 0.5) + float3(0.5);
float3 _219;
_219.x = _217.x;
float2 _220 = _219.xy;
_220.y = -_217.y;
float _227;
int _230;
int _232;
_227 = 0.0;
_230 = 0;
_232 = -2;
float _228;
int _231;
for (; _232 <= 2; _227 = _228, _230 = _231, _232++)
{
_231 = _230;
_228 = _227;
for (int _241 = -2; _241 <= 2; )
{
_231++;
_228 += float((in.in_var_TEXCOORD3.z - 0.0030000000260770320892333984375) > DirectionalShadowDepthMap.sample(DirectionalShadowSampler, (_220 + float2(float(_241) * 0.000244140625, float(_232) * 0.000244140625))).x);
_241++;
continue;
}
}
float3 _270;
if ((_102 & 2) > 0)
{
_270 = _143.xyz * 2.0;
}
else
{
_270 = _143.xyz * ((float3(0.100000001490116119384765625) + _200) + ((Uniforms.directionalLightColor.xyz * precise::max(dot(Uniforms.directionalLight.xyz, in.in_var_TEXCOORD2), 0.0)) * (1.0 - (_227 / float(_230)))));
}
float4 _287;
if (_270.x > 1.0)
{
float4 _286 = float4(0.0, 0.0, 0.0, 1.0);
_286.x = _270.x;
_287 = _286;
}
else
{
_287 = float4(0.0, 0.0, 0.0, 1.0);
}
float4 _292;
if (_270.y > 1.0)
{
float4 _291 = _287;
_291.y = _270.y;
_292 = _291;
}
else
{
_292 = _287;
}
float4 _297;
if (_270.z > 1.0)
{
float4 _296 = _292;
_296.z = _270.z;
_297 = _296;
}
else
{
_297 = _292;
}
out.out_var_SV_Target0 = float4(_270, _143.w);
out.out_var_SV_Target1 = _297;
out.out_var_SV_Target2 = float4(in.in_var_TEXCOORD1, 1.0);
out.out_var_SV_Target3 = float4(in.in_var_TEXCOORD5, 1.0);
return out;
}

View File

@ -0,0 +1,62 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Scene
{
float4x4 Model;
uint textureMode;
uint pad0;
uint pad1;
uint pad2;
};
struct type_StructuredBuffer_Scene
{
Scene _m0[1];
};
struct type_Uniforms
{
float4x4 ViewProjection;
float4x4 NoTranslateView;
float4x4 ShadowMapProjection;
float time;
};
struct main0_out
{
float2 out_var_TEXCOORD0 [[user(locn0)]];
float3 out_var_TEXCOORD1 [[user(locn1)]];
float3 out_var_TEXCOORD2 [[user(locn2)]];
float4 out_var_TEXCOORD3 [[user(locn3)]];
uint out_var_TEXCOORD4 [[user(locn4)]];
float3 out_var_TEXCOORD5 [[user(locn5)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_var_TEXCOORD0 [[attribute(0)]];
float3 in_var_TEXCOORD1 [[attribute(1)]];
float2 in_var_TEXCOORD3 [[attribute(3)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(1)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
float4 _53 = float4(in.in_var_TEXCOORD0, 1.0);
float4 _56 = scene._m0[gl_InstanceIndex].Model * _53;
float4x4 _91 = float4x4(float4(fast::normalize(float3(scene._m0[gl_InstanceIndex].Model[0][0], scene._m0[gl_InstanceIndex].Model[1][0], scene._m0[gl_InstanceIndex].Model[2][0])), 0.0), float4(fast::normalize(float3(scene._m0[gl_InstanceIndex].Model[0][1], scene._m0[gl_InstanceIndex].Model[1][1], scene._m0[gl_InstanceIndex].Model[2][1])), 0.0), float4(fast::normalize(float3(scene._m0[gl_InstanceIndex].Model[0][2], scene._m0[gl_InstanceIndex].Model[1][2], scene._m0[gl_InstanceIndex].Model[2][2])), 0.0), float4(0.0, 0.0, 0.0, 1.0));
float4 _95 = float4(in.in_var_TEXCOORD1, 1.0);
out.out_var_TEXCOORD0 = in.in_var_TEXCOORD3;
out.out_var_TEXCOORD1 = _56.xyz;
out.out_var_TEXCOORD2 = fast::normalize(_95 * _91).xyz;
out.out_var_TEXCOORD3 = Uniforms.ShadowMapProjection * _56;
out.out_var_TEXCOORD4 = gl_InstanceIndex;
out.out_var_TEXCOORD5 = (_95 * (_91 * transpose(Uniforms.NoTranslateView))).xyz;
out.gl_Position = Uniforms.ViewProjection * (scene._m0[gl_InstanceIndex].Model * _53);
return out;
}

View File

@ -0,0 +1,59 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 out_var_SV_Target0 [[color(0)]];
};
struct main0_in
{
float2 in_var_TEXCOORD0 [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> ColorTexture [[texture(0)]], texture2d<float> EmissiveTexture [[texture(1)]], texture2d<float> SsaoTexture [[texture(2)]], sampler Sampler0 [[sampler(0)]], sampler Sampler1 [[sampler(1)]], sampler Sampler2 [[sampler(2)]])
{
main0_out out = {};
float2 _51 = in.in_var_TEXCOORD0;
_51.y = (_51.y * (-1.0)) + 1.0;
float4 _59 = ColorTexture.sample(Sampler0, _51);
float3 _60 = _59.xyz;
float3 _74;
int _77;
_74 = EmissiveTexture.sample(Sampler1, _51).xyz * 0.2270270287990570068359375;
_77 = 0;
float3 _75;
for (; _77 < 5; _74 = _75, _77++)
{
_75 = _74;
for (int _85 = 0; _85 < 5; )
{
float2 _93 = float2(float(_77) - 2.5, float(_85)) * float2(0.001953125);
_75 = (_75 + (EmissiveTexture.sample(Sampler1, (_51 + _93)).xyz * float3(0.039999999105930328369140625))) + (EmissiveTexture.sample(Sampler1, (_51 - _93)).xyz * float3(0.039999999105930328369140625));
_85++;
continue;
}
}
float3 _109;
int _112;
_109 = float3(0.0);
_112 = 0;
float3 _110;
for (; _112 < 5; _109 = _110, _112++)
{
_110 = _109;
for (int _120 = 0; _120 < 5; )
{
float2 _128 = float2(float(_112) - 2.5, float(_120)) * float2(0.0009765625);
_110 = (_110 + (SsaoTexture.sample(Sampler2, (_51 + _128)).xyz * float3(0.0199999995529651641845703125))) + (SsaoTexture.sample(Sampler2, (_51 - _128)).xyz * float3(0.0199999995529651641845703125));
_120++;
continue;
}
}
float3 _142 = ((powr((_60 * (float3(1.0) + (_60 * float3(0.00999999977648258209228515625)))) / (float3(1.0) + _60), float3(0.4545454680919647216796875)) + (_74 * 0.0500000007450580596923828125)) * 1.0) * _109;
out.out_var_SV_Target0 = float4(((_142.x * (1.0 + (9.9999999747524270787835121154785e-07 * EmissiveTexture.sample(Sampler1, _51).x))) * (1.0 + (9.9999999747524270787835121154785e-07 * ColorTexture.sample(Sampler0, _51).x))) * (1.0 + (9.9999999747524270787835121154785e-07 * SsaoTexture.sample(Sampler2, _51).x)), _142.yz, 1.0);
return out;
}

View File

@ -0,0 +1,25 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float2 out_var_TEXCOORD0 [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_var_TEXCOORD0 [[attribute(0)]];
float2 in_var_TEXCOORD3 [[attribute(3)]];
};
vertex main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.out_var_TEXCOORD0 = in.in_var_TEXCOORD3;
out.gl_Position = float4(in.in_var_TEXCOORD0, 1.0);
return out;
}

View File

@ -0,0 +1,259 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Scene
{
float2 imagePosition;
float2 _imageSize;
float2 anchorPoint;
float2 scale;
float alpha;
float borderWidth;
uint flags;
float4 baseColor;
float4 rounding;
float4 edgeColor;
};
struct type_StructuredBuffer_Scene
{
Scene _m0[1];
};
struct main0_out
{
float4 out_var_SV_Target0 [[color(0)]];
};
struct main0_in
{
float4 in_var_TEXCOORD0 [[user(locn0)]];
float2 in_var_TEXCOORD1 [[user(locn1)]];
float2 in_var_TEXCOORD2 [[user(locn2)]];
uint in_var_TEXCOORD3 [[user(locn3)]];
};
fragment main0_out main0(main0_in in [[stage_in]], const device type_StructuredBuffer_Scene& scene [[buffer(4294967295)]], texture2d<float> Texture0 [[texture(0)]], sampler Sampler0 [[sampler(0)]])
{
main0_out out = {};
bool _73 = in.in_var_TEXCOORD2.x < scene._m0[in.in_var_TEXCOORD3].rounding.x;
bool _80;
if (_73)
{
_80 = in.in_var_TEXCOORD2.y < scene._m0[in.in_var_TEXCOORD3].rounding.y;
}
else
{
_80 = false;
}
float _97;
float3 _98;
if (_80)
{
float _84 = distance(in.in_var_TEXCOORD2, float2(scene._m0[in.in_var_TEXCOORD3].rounding.x));
float _95;
float3 _96;
if (_84 > scene._m0[in.in_var_TEXCOORD3].rounding.x)
{
discard_fragment();
}
else
{
if (abs(_84 - scene._m0[in.in_var_TEXCOORD3].rounding.x) < 1.0)
{
_95 = scene._m0[in.in_var_TEXCOORD3].edgeColor.w;
_96 = scene._m0[in.in_var_TEXCOORD3].edgeColor.xyz;
}
else
{
_95 = scene._m0[in.in_var_TEXCOORD3].alpha;
_96 = in.in_var_TEXCOORD0.xyz;
}
}
_97 = _95;
_98 = _96;
}
else
{
_97 = scene._m0[in.in_var_TEXCOORD3].alpha;
_98 = in.in_var_TEXCOORD0.xyz;
}
float _101 = scene._m0[in.in_var_TEXCOORD3]._imageSize.x - scene._m0[in.in_var_TEXCOORD3].rounding.y;
bool _108;
if (in.in_var_TEXCOORD2.x > _101)
{
_108 = in.in_var_TEXCOORD2.y < scene._m0[in.in_var_TEXCOORD3].rounding.y;
}
else
{
_108 = false;
}
float _125;
float3 _126;
if (_108)
{
float _112 = distance(in.in_var_TEXCOORD2, float2(_101, scene._m0[in.in_var_TEXCOORD3].rounding.y));
float _123;
float3 _124;
if (_112 > scene._m0[in.in_var_TEXCOORD3].rounding.y)
{
discard_fragment();
}
else
{
if (abs(_112 - scene._m0[in.in_var_TEXCOORD3].rounding.y) < 1.0)
{
_123 = scene._m0[in.in_var_TEXCOORD3].edgeColor.w;
_124 = scene._m0[in.in_var_TEXCOORD3].edgeColor.xyz;
}
else
{
_123 = _97;
_124 = _98;
}
}
_125 = _123;
_126 = _124;
}
else
{
_125 = _97;
_126 = _98;
}
bool _134;
if (_73)
{
_134 = in.in_var_TEXCOORD2.y > (scene._m0[in.in_var_TEXCOORD3]._imageSize.y - scene._m0[in.in_var_TEXCOORD3].rounding.y);
}
else
{
_134 = false;
}
float _153;
float3 _154;
if (_134)
{
float _140 = distance(in.in_var_TEXCOORD2, float2(scene._m0[in.in_var_TEXCOORD3].rounding.x, scene._m0[in.in_var_TEXCOORD3]._imageSize.y - scene._m0[in.in_var_TEXCOORD3].rounding.y));
float _151;
float3 _152;
if (_140 > scene._m0[in.in_var_TEXCOORD3].rounding.y)
{
discard_fragment();
}
else
{
if (abs(_140 - scene._m0[in.in_var_TEXCOORD3].rounding.y) < 1.0)
{
_151 = scene._m0[in.in_var_TEXCOORD3].edgeColor.w;
_152 = scene._m0[in.in_var_TEXCOORD3].edgeColor.xyz;
}
else
{
_151 = _125;
_152 = _126;
}
}
_153 = _151;
_154 = _152;
}
else
{
_153 = _125;
_154 = _126;
}
bool _165;
if (in.in_var_TEXCOORD2.x > (scene._m0[in.in_var_TEXCOORD3]._imageSize.x - scene._m0[in.in_var_TEXCOORD3].rounding.w))
{
_165 = (scene._m0[in.in_var_TEXCOORD3]._imageSize.y - in.in_var_TEXCOORD2.y) < scene._m0[in.in_var_TEXCOORD3].rounding.w;
}
else
{
_165 = false;
}
float _185;
float3 _186;
if (_165)
{
float _172 = distance(in.in_var_TEXCOORD2, float2(scene._m0[in.in_var_TEXCOORD3]._imageSize.x - scene._m0[in.in_var_TEXCOORD3].rounding.x, scene._m0[in.in_var_TEXCOORD3]._imageSize.y - scene._m0[in.in_var_TEXCOORD3].rounding.y));
float _183;
float3 _184;
if (_172 > scene._m0[in.in_var_TEXCOORD3].rounding.y)
{
discard_fragment();
}
else
{
if (abs(_172 - scene._m0[in.in_var_TEXCOORD3].rounding.y) < 1.0)
{
_183 = scene._m0[in.in_var_TEXCOORD3].edgeColor.w;
_184 = scene._m0[in.in_var_TEXCOORD3].edgeColor.xyz;
}
else
{
_183 = _153;
_184 = _154;
}
}
_185 = _183;
_186 = _184;
}
else
{
_185 = _153;
_186 = _154;
}
bool _193;
if (!(in.in_var_TEXCOORD2.x < scene._m0[in.in_var_TEXCOORD3].borderWidth))
{
_193 = in.in_var_TEXCOORD2.x > (scene._m0[in.in_var_TEXCOORD3]._imageSize.x - scene._m0[in.in_var_TEXCOORD3].borderWidth);
}
else
{
_193 = true;
}
bool _200;
if (!_193)
{
_200 = in.in_var_TEXCOORD2.y < scene._m0[in.in_var_TEXCOORD3].borderWidth;
}
else
{
_200 = true;
}
bool _209;
if (!_200)
{
_209 = in.in_var_TEXCOORD2.y > (scene._m0[in.in_var_TEXCOORD3]._imageSize.y - scene._m0[in.in_var_TEXCOORD3].borderWidth);
}
else
{
_209 = true;
}
float _214;
float3 _215;
if (_209)
{
_214 = scene._m0[in.in_var_TEXCOORD3].edgeColor.w;
_215 = scene._m0[in.in_var_TEXCOORD3].edgeColor.xyz;
}
else
{
_214 = _185;
_215 = _186;
}
float4 _241;
if ((scene._m0[in.in_var_TEXCOORD3].flags & 1u) > 0u)
{
float4 _229 = Texture0.sample(Sampler0, float2(in.in_var_TEXCOORD1.x, 1.0 - in.in_var_TEXCOORD1.y));
_241 = float4(_229.xyz, _229.w * _214);
}
else
{
_241 = float4(powr(_215, float3(2.2000000476837158203125)), _214);
}
out.out_var_SV_Target0 = _241;
return out;
}

View File

@ -0,0 +1,59 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Scene
{
float2 imagePosition;
float2 _imageSize;
float2 anchorPoint;
float2 scale;
float alpha;
float borderWidth;
uint flags;
float4 baseColor;
float4 rounding;
float4 edgeColor;
};
struct type_StructuredBuffer_Scene
{
Scene _m0[1];
};
struct type_Uniforms
{
float2 Extents;
};
struct main0_out
{
float4 out_var_TEXCOORD0 [[user(locn0)]];
float2 out_var_TEXCOORD1 [[user(locn1)]];
float2 out_var_TEXCOORD2 [[user(locn2)]];
uint out_var_TEXCOORD3 [[user(locn3)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_var_TEXCOORD0 [[attribute(0)]];
float2 in_var_TEXCOORD3 [[attribute(3)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(1)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
float2 _63 = scene._m0[gl_InstanceIndex]._imageSize / Uniforms.Extents;
float2 _69 = (((scene._m0[gl_InstanceIndex].imagePosition / Uniforms.Extents) * 2.0) - float2(1.0)) - ((scene._m0[gl_InstanceIndex].anchorPoint * _63) * scene._m0[gl_InstanceIndex].scale);
float2 _99 = ((in.in_var_TEXCOORD0.xy - scene._m0[gl_InstanceIndex].anchorPoint) * float2(0.5)) * scene._m0[gl_InstanceIndex]._imageSize;
_99.y = scene._m0[gl_InstanceIndex]._imageSize.y - _99.y;
out.out_var_TEXCOORD0 = scene._m0[gl_InstanceIndex].baseColor;
out.out_var_TEXCOORD1 = float2(1.0 - in.in_var_TEXCOORD3.x, in.in_var_TEXCOORD3.y);
out.out_var_TEXCOORD2 = _99;
out.out_var_TEXCOORD3 = gl_InstanceIndex;
out.gl_Position = float4(_69.x + ((in.in_var_TEXCOORD0.x * _63.x) * scene._m0[gl_InstanceIndex].scale.x), _69.y + (((-in.in_var_TEXCOORD0.y) * _63.y) * scene._m0[gl_InstanceIndex].scale.y), in.in_var_TEXCOORD0.z, 1.0);
return out;
}

View File

@ -0,0 +1,22 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 out_var_SV_Target0 [[color(0)]];
};
struct main0_in
{
float4 in_var_TEXCOORD0 [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.out_var_SV_Target0 = in.in_var_TEXCOORD0;
return out;
}

View File

@ -0,0 +1,66 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Scene
{
float3 color;
};
struct type_StructuredBuffer_Scene
{
Scene _m0[1];
};
constant float2 _31 = {};
constant float4 _32 = {};
struct main0_out
{
float4 out_var_TEXCOORD0 [[user(locn0)]];
float4 gl_Position [[position]];
};
vertex main0_out main0(const device type_StructuredBuffer_Scene& test [[buffer(0)]], uint gl_VertexIndex [[vertex_id]])
{
main0_out out = {};
float4 _71;
float2 _72;
if (gl_VertexIndex == 0u)
{
_71 = float4(test._m0[0u].color, 1.0);
_72 = float2(-1.0);
}
else
{
float4 _69;
float2 _70;
if (gl_VertexIndex == 1u)
{
_69 = float4(test._m0[1u].color, 1.0);
_70 = float2(1.0, -1.0);
}
else
{
bool _57 = gl_VertexIndex == 2u;
float4 _66;
if (_57)
{
_66 = float4(test._m0[2u].color, 1.0);
}
else
{
_66 = _32;
}
_69 = _66;
_70 = select(_31, float2(0.0, 1.0), bool2(_57));
}
_71 = _69;
_72 = _70;
}
out.out_var_TEXCOORD0 = _71;
out.gl_Position = float4(_72, 0.0, 1.0);
return out;
}

View File

@ -0,0 +1,32 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct type_Uniforms
{
float brightnessFactor;
};
constant float4 _28 = {};
struct main0_out
{
float4 out_var_SV_Target0 [[color(0)]];
float4 out_var_SV_Target1 [[color(1)]];
};
struct main0_in
{
float3 in_var_TEXCOORD0 [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], texturecube<float> SkyboxTexture [[texture(0)]], sampler SkyboxSampler [[sampler(0)]])
{
main0_out out = {};
float4 _38 = SkyboxTexture.sample(SkyboxSampler, in.in_var_TEXCOORD0) * Uniforms.brightnessFactor;
out.out_var_SV_Target0 = _38;
out.out_var_SV_Target1 = select(_28, _38, bool4(length(_38) > 1.0));
return out;
}

View File

@ -0,0 +1,29 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct type_Uniforms
{
float4x4 ViewProjection;
};
struct main0_out
{
float3 out_var_TEXCOORD0 [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_var_TEXCOORD0 [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]])
{
main0_out out = {};
out.out_var_TEXCOORD0 = in.in_var_TEXCOORD0;
out.gl_Position = Uniforms.ViewProjection * float4(in.in_var_TEXCOORD0, 1.0);
return out;
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,66 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Scene
{
float4 color;
};
struct type_StructuredBuffer_Scene
{
Scene _m0[1];
};
constant float2 _30 = {};
constant float4 _31 = {};
struct main0_out
{
float4 out_var_TEXCOORD0 [[user(locn0)]];
float4 gl_Position [[position]];
};
vertex main0_out main0(const device type_StructuredBuffer_Scene& test [[buffer(0)]], uint gl_VertexIndex [[vertex_id]])
{
main0_out out = {};
float4 _58;
float2 _59;
if (gl_VertexIndex == 0u)
{
_58 = test._m0[0u].color;
_59 = float2(-1.0);
}
else
{
float4 _56;
float2 _57;
if (gl_VertexIndex == 1u)
{
_56 = test._m0[1u].color;
_57 = float2(1.0, -1.0);
}
else
{
bool _48 = gl_VertexIndex == 2u;
float4 _53;
if (_48)
{
_53 = test._m0[2u].color;
}
else
{
_53 = _31;
}
_56 = _53;
_57 = select(_30, float2(0.0, 1.0), bool2(_48));
}
_58 = _56;
_59 = _57;
}
out.out_var_TEXCOORD0 = _58;
out.gl_Position = float4(_59, 0.0, 1.0);
return out;
}

View File

@ -0,0 +1,100 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct FontInfo
{
float2 position;
float size;
uint isSdf;
uint pad0;
packed_float2 pad2;
char _m0_final_padding[4];
};
struct type_StructuredBuffer_FontInfo
{
FontInfo _m0[1];
};
struct main0_out
{
float4 out_var_SV_Target0 [[color(0)]];
};
struct main0_in
{
float4 in_var_TEXCOORD0 [[user(locn0)]];
float2 in_var_TEXCOORD1 [[user(locn1)]];
float2 in_var_TEXCOORD2 [[user(locn2)]];
uint in_var_TEXCOORD3 [[user(locn3)]];
};
fragment main0_out main0(main0_in in [[stage_in]], const device type_StructuredBuffer_FontInfo& fontBuffer [[buffer(4294967295)]], texture2d<float> Texture0 [[texture(0)]], sampler Sampler0 [[sampler(0)]])
{
main0_out out = {};
float4 _64 = Texture0.sample(Sampler0, in.in_var_TEXCOORD1);
bool _99;
do
{
bool _81;
if (in.in_var_TEXCOORD2.x >= fontBuffer._m0[in.in_var_TEXCOORD3].position.x)
{
_81 = in.in_var_TEXCOORD2.x <= (fontBuffer._m0[in.in_var_TEXCOORD3].position.x + fontBuffer._m0[in.in_var_TEXCOORD3].size);
}
else
{
_81 = false;
}
bool _88;
if (_81)
{
_88 = in.in_var_TEXCOORD2.y >= fontBuffer._m0[in.in_var_TEXCOORD3].position.y;
}
else
{
_88 = false;
}
bool _96;
if (_88)
{
_96 = in.in_var_TEXCOORD2.y <= (fontBuffer._m0[in.in_var_TEXCOORD3].position.y + fontBuffer._m0[in.in_var_TEXCOORD3].size);
}
else
{
_96 = false;
}
if (_96)
{
_99 = true;
break;
}
_99 = false;
break;
} while(false);
if (!_99)
{
discard_fragment();
}
float4 _170;
if (fontBuffer._m0[in.in_var_TEXCOORD3].isSdf == 1u)
{
float _107 = _64.x;
float _108 = fwidth(_107);
float _109 = 0.529411792755126953125 - _108;
float _110 = 0.529411792755126953125 + _108;
float2 _116 = (dfdx(in.in_var_TEXCOORD1) + dfdy(in.in_var_TEXCOORD1)) * 0.3540000021457672119140625;
float4 _123 = float4(in.in_var_TEXCOORD1 - _116, in.in_var_TEXCOORD1 + _116);
float4 _157 = float4(in.in_var_TEXCOORD0.xyz, (fast::clamp(smoothstep(_109, _110, _107), 0.0, 1.0) + (0.5 * (((fast::clamp(smoothstep(_109, _110, Texture0.sample(Sampler0, _123.xy).x), 0.0, 1.0) + fast::clamp(smoothstep(_109, _110, Texture0.sample(Sampler0, _123.zw).x), 0.0, 1.0)) + fast::clamp(smoothstep(_109, _110, Texture0.sample(Sampler0, _123.xw).x), 0.0, 1.0)) + fast::clamp(smoothstep(_109, _110, Texture0.sample(Sampler0, _123.zy).x), 0.0, 1.0)))) * 0.3333333432674407958984375);
float3 _159 = powr(_157.xyz, float3(2.2000000476837158203125));
_170 = float4(_159.x, _159.y, _159.z, _157.w);
}
else
{
_170 = float4(in.in_var_TEXCOORD0.xyz, powr(_64.x / dot(in.in_var_TEXCOORD0.xyz, float3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)), 0.4545454680919647216796875));
}
out.out_var_SV_Target0 = _170;
return out;
}

View File

@ -0,0 +1,53 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct FontInfo
{
float2 position;
float size;
uint isSdf;
uint pad0;
packed_float2 pad2;
char _m0_final_padding[4];
};
struct type_StructuredBuffer_FontInfo
{
FontInfo _m0[1];
};
struct type_Uniforms
{
float2 Extents;
};
struct main0_out
{
float4 out_var_TEXCOORD0 [[user(locn0)]];
float2 out_var_TEXCOORD1 [[user(locn1)]];
float2 out_var_TEXCOORD2 [[user(locn2)]];
uint out_var_TEXCOORD3 [[user(locn3)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_var_TEXCOORD0 [[attribute(0)]];
float4 in_var_TEXCOORD2 [[attribute(2)]];
float2 in_var_TEXCOORD3 [[attribute(3)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_FontInfo& fontBuffer [[buffer(1)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
float2 _51 = in.in_var_TEXCOORD0.xy + fontBuffer._m0[gl_InstanceIndex].position;
out.out_var_TEXCOORD0 = in.in_var_TEXCOORD2;
out.out_var_TEXCOORD1 = in.in_var_TEXCOORD3;
out.out_var_TEXCOORD2 = _51;
out.out_var_TEXCOORD3 = gl_InstanceIndex;
out.gl_Position = float4(((_51 / Uniforms.Extents) * 2.0) + float2(-1.0), in.in_var_TEXCOORD0.z, 1.0);
return out;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -18,6 +18,7 @@ pub fn prepare(self: *@This()) !void {
pub fn tick(self: *@This(), dt: f64) void {
_ = self;
_ = dt;
ig.showDemoWindow(null);
}
pub fn deinit(self: *@This()) void {
@ -37,5 +38,5 @@ pub fn main() anyerror!void {
const std = @import("std");
const bl = @import("Backlog");
// const ig = backlog.imgui.api; // imgui api
const ig = bl.imgui.api; // imgui api
const core = bl.core;

23631
projects/out.txt Normal file

File diff suppressed because it is too large Load Diff