Files
shadertoy/shaders/test/test.vk.glsl

42 lines
1.0 KiB
GLSL

#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;
}