sandbox updates
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
#version 450
|
||||
|
||||
//shader input
|
||||
layout (location = 0) in vec3 inColor;
|
||||
|
||||
//output write
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
//return red
|
||||
outFragColor = vec4(inColor,1.0f);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#version 450
|
||||
#extension GL_EXT_buffer_reference : require
|
||||
|
||||
struct TriangleVertex {
|
||||
vec4 vertex;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
layout(buffer_reference, std430) readonly buffer TriangleVertexBuffer {
|
||||
TriangleVertex vertices[];
|
||||
};
|
||||
|
||||
layout( push_constant ) uniform constants {
|
||||
TriangleVertexBuffer triangleBuffer;
|
||||
vec2 padding;
|
||||
vec4 data1;
|
||||
vec4 data2;
|
||||
vec4 data3;
|
||||
} PushConstants;
|
||||
|
||||
layout (location = 0) out vec3 outColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
//const array of positions for the triangle
|
||||
const vec3 positions[3] = vec3[3](
|
||||
vec3(-1.f,1.f, 0.0f),
|
||||
vec3(1.f,1.f, 0.0f),
|
||||
vec3(0.f,-1.f, 0.0f)
|
||||
);
|
||||
|
||||
//const array of colors for the triangle
|
||||
const vec3 colors[3] = vec3[3](
|
||||
vec3(1.0f, 0.0f, 0.0f), //red
|
||||
vec3(0.0f, 1.0f, 0.0f), //green
|
||||
vec3(00.f, 0.0f, 1.0f) //blue
|
||||
);
|
||||
|
||||
// Load vertex data from device address
|
||||
TriangleVertex v = PushConstants.triangleBuffer.vertices[gl_VertexIndex];
|
||||
|
||||
// output the position of each vertex
|
||||
gl_Position = vec4(v.vertex.xyz, 1.0);
|
||||
outColor = vec3(v.color.xyz);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#version 460
|
||||
|
||||
//size of a workgroup for compute
|
||||
layout (local_size_x = 16, local_size_y = 16) in;
|
||||
|
||||
//descriptor bindings for the pipeline
|
||||
layout(rgba16f,set = 0, binding = 0) uniform image2D image;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 texelCoord = ivec2(gl_GlobalInvocationID.xy);
|
||||
ivec2 size = imageSize(image);
|
||||
|
||||
if(texelCoord.x < size.x && texelCoord.y < size.y)
|
||||
{
|
||||
vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
if(gl_LocalInvocationID.x != 0 && gl_LocalInvocationID.y != 0)
|
||||
{
|
||||
color.x = float(texelCoord.x)/(size.x);
|
||||
color.y = float(texelCoord.y)/(size.y);
|
||||
}
|
||||
|
||||
imageStore(image, texelCoord, color);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user