Add SDL3 GPU backend (Vulkan/Metal) with OpenGL fallback
This commit is contained in:
19
shaders/_common/passthrough.vert.msl
Normal file
19
shaders/_common/passthrough.vert.msl
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
// Shared fullscreen-triangle vertex shader for the SDL3 GPU backend.
|
||||
// Emits uv in Shadertoy convention: (0,0) bottom-left, (1,1) top-right.
|
||||
|
||||
struct PassthroughVOut {
|
||||
float4 pos [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex PassthroughVOut passthrough_vs(uint vid [[vertex_id]]) {
|
||||
const float2 positions[3] = { {-1.0, -1.0}, {3.0, -1.0}, {-1.0, 3.0} };
|
||||
PassthroughVOut out;
|
||||
float2 pos = positions[vid];
|
||||
out.uv = pos * 0.5 + 0.5;
|
||||
out.pos = float4(pos.x, -pos.y, 0.0, 1.0);
|
||||
return out;
|
||||
}
|
||||
BIN
shaders/_common/passthrough.vert.spv
Normal file
BIN
shaders/_common/passthrough.vert.spv
Normal file
Binary file not shown.
18
shaders/_common/passthrough.vk.glsl
Normal file
18
shaders/_common/passthrough.vk.glsl
Normal file
@@ -0,0 +1,18 @@
|
||||
#version 450
|
||||
|
||||
// Shared fullscreen-triangle vertex shader for the SDL3 GPU backend.
|
||||
// Emits vUV in Shadertoy convention: (0,0) bottom-left, (1,1) top-right.
|
||||
// Y flipped in NDC because Vulkan/Metal point Y down by default.
|
||||
|
||||
layout(location = 0) out vec2 vUV;
|
||||
|
||||
void main() {
|
||||
const vec2 positions[3] = vec2[3](
|
||||
vec2(-1.0, -1.0),
|
||||
vec2( 3.0, -1.0),
|
||||
vec2(-1.0, 3.0)
|
||||
);
|
||||
vec2 pos = positions[gl_VertexIndex];
|
||||
vUV = pos * 0.5 + 0.5;
|
||||
gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0);
|
||||
}
|
||||
2
shaders/cineshader_lava/meta.txt
Normal file
2
shaders/cineshader_lava/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Cineshader Lava
|
||||
Author: edankwan
|
||||
2
shaders/creation/meta.txt
Normal file
2
shaders/creation/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Creation by Silexars
|
||||
Author: Danguafer
|
||||
2
shaders/cube_lines/meta.txt
Normal file
2
shaders/cube_lines/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Cube lines
|
||||
Author: Danil
|
||||
2
shaders/dbz/meta.txt
Normal file
2
shaders/dbz/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: New Leaked 3I/Atlas NASA Footage
|
||||
Author: msm01
|
||||
2
shaders/fractal_pyramid/meta.txt
Normal file
2
shaders/fractal_pyramid/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Fractal Pyramid
|
||||
Author: bradjamesgrant
|
||||
2
shaders/just_another_cube/meta.txt
Normal file
2
shaders/just_another_cube/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Just Another Cube
|
||||
Author: mrange
|
||||
2
shaders/octograms/meta.txt
Normal file
2
shaders/octograms/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Octograms
|
||||
Author: whisky_shusuky
|
||||
2
shaders/remember/meta.txt
Normal file
2
shaders/remember/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Remember
|
||||
Author: diatribes
|
||||
2
shaders/seascape/meta.txt
Normal file
2
shaders/seascape/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Seascape
|
||||
Author: Alexander Alekseev
|
||||
2
shaders/shader_art_coding_introduction/meta.txt
Normal file
2
shaders/shader_art_coding_introduction/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Shader Art Coding Introduction
|
||||
Author: kishimisu
|
||||
2
shaders/test/meta.txt
Normal file
2
shaders/test/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Test
|
||||
Author: JailDesigner
|
||||
36
shaders/test/test.frag.msl
Normal file
36
shaders/test/test.frag.msl
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
// Test shader (Metal Shading Language port of test.vk.glsl).
|
||||
// Author: JailDesigner
|
||||
|
||||
struct ShadertoyUBO {
|
||||
float iTime;
|
||||
float2 iResolution;
|
||||
};
|
||||
|
||||
struct PassthroughVOut {
|
||||
float4 pos [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
static float3 palette(float t) {
|
||||
float3 a = float3(1.0, 0.5, 0.5);
|
||||
float3 b = float3(1.0, 0.5, 0.5);
|
||||
float3 c = float3(1.0, 1.0, 1.0);
|
||||
float3 d = float3(0.263, 0.416, 0.557);
|
||||
return a + b * cos(6.28318 * (c * t * d));
|
||||
}
|
||||
|
||||
fragment float4 test_fs(PassthroughVOut in [[stage_in]],
|
||||
constant ShadertoyUBO& u [[buffer(0)]]) {
|
||||
float2 fragCoord = in.uv * u.iResolution;
|
||||
float2 uv = (fragCoord * 2.0 - u.iResolution) / u.iResolution.y;
|
||||
float d = length(uv);
|
||||
float3 col = palette(d);
|
||||
d = sin(d * 8.0 + u.iTime) / 8.0;
|
||||
d = abs(d);
|
||||
d = 0.02 / d;
|
||||
col *= d;
|
||||
return float4(col, 1.0);
|
||||
}
|
||||
BIN
shaders/test/test.frag.spv
Normal file
BIN
shaders/test/test.frag.spv
Normal file
Binary file not shown.
41
shaders/test/test.vk.glsl
Normal file
41
shaders/test/test.vk.glsl
Normal file
@@ -0,0 +1,41 @@
|
||||
#version 450
|
||||
|
||||
// Name: Test
|
||||
// Author: JailDesigner
|
||||
//
|
||||
// Vulkan port of test.gl.glsl. Bindings follow the SDL3 GPU convention:
|
||||
// set=3, binding=0 — fragment uniform buffer (ShadertoyUniforms in C++).
|
||||
|
||||
layout(location = 0) in vec2 vUV;
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
layout(set = 3, binding = 0) uniform ShadertoyUBO {
|
||||
float iTime;
|
||||
vec2 iResolution;
|
||||
} u;
|
||||
|
||||
vec3 palette(float t) {
|
||||
vec3 a = vec3(1.0, 0.5, 0.5);
|
||||
vec3 b = vec3(1.0, 0.5, 0.5);
|
||||
vec3 c = vec3(1.0, 1.0, 1.0);
|
||||
vec3 d = vec3(0.263, 0.416, 0.557);
|
||||
return a + b * cos(6.28318 * (c * t * d));
|
||||
}
|
||||
|
||||
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
||||
vec2 uv = (fragCoord * 2.0 - u.iResolution) / u.iResolution.y;
|
||||
float d = length(uv);
|
||||
vec3 col = palette(d);
|
||||
d = sin(d * 8.0 + u.iTime) / 8.0;
|
||||
d = abs(d);
|
||||
d = 0.02 / d;
|
||||
col *= d;
|
||||
fragColor = vec4(col, 1.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 fragCoordPixels = vUV * u.iResolution;
|
||||
vec4 outColor;
|
||||
mainImage(outColor, fragCoordPixels);
|
||||
FragColor = outColor;
|
||||
}
|
||||
2
shaders/water/meta.txt
Normal file
2
shaders/water/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Water
|
||||
Author: diatribes
|
||||
Reference in New Issue
Block a user