Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344#version 450
struct ImageInstance { vec4 rect; vec4 color;};
layout(set = 0, binding = 0) readonly buffer ImageInstances { ImageInstance data[];} imageInstances;
layout(location = 1) out vec4 out_color;layout(location = 2) out vec2 out_texcoord;
layout(set = 1, binding = 0) uniform PushConstants { vec4 params; // window width, height, and instance-buffer offset} pc;
void main() { // Extract geometry boundaries ImageInstance image = imageInstances.data[gl_InstanceIndex + uint(pc.params.z)]; vec2 rectPos = image.rect.xy; vec2 rectSize = image.rect.zw;
// Generate corner offsets using gl_VertexIndex (for a TRIANGLE_STRIP) // Index 0: (0,0) -> Top-Left // Index 1: (1,0) -> Top-Right // Index 2: (0,1) -> Bottom-Left // Index 3: (1,1) -> Bottom-Right vec2 cornerOffset = vec2( float(gl_VertexIndex & 1), float((gl_VertexIndex >> 1) & 1) );
// Compute pixel position for the current vertex vec2 pixelPos = rectPos + (cornerOffset * rectSize); vec2 ndc = (pixelPos / pc.params.xy) * 2.0 - 1.0; ndc.y = -ndc.y; gl_Position = vec4(ndc, 0.0, 1.0);
out_color = image.color; out_texcoord = cornerOffset;}