Below are minimal, idiomatic GLSL shaders you can drop straight into a Vulkan project to draw a colored triangle. Compile each source file to SPIR-V (e.g. with glslangValidator) and hook them up in a graphics pipeline.
Vertex shader – triangle.vert
glsl
#version 450
// ── Vertex attributes ────────────────────────────────────────────────
layout(location = 0) in vec2 inPos; // 2-D position (x, y) in NDC [-1, 1]
layout(location = 1) in vec3 inColor; // Per-vertex RGB color
// ── Outputs to the fragment stage ────────────────────────────────────
layout(location = 0) out vec3 fragColor;
void main() {
gl_Position = vec4(inPos, 0.0, 1.0); // Lift to homogeneous clip space
fragColor = inColor; // Pass color through
}
Fragment shader – triangle.frag
glsl
#version 450
layout(location = 0) in vec3 fragColor; // Interpolated color
layout(location = 0) out vec4 outColor; // Final pixel color
void main() {
outColor = vec4(fragColor, 1.0); // Add opaque alpha
}