Added Vulkan examples sources!
This commit is contained in:
parent
367fda186b
commit
c91341813c
868 changed files with 514080 additions and 5584 deletions
47
data/shaders/computeshader/edgedetect.comp
Normal file
47
data/shaders/computeshader/edgedetect.comp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (local_size_x = 16, local_size_y = 16) in;
|
||||
layout (binding = 0, rgba8) uniform image2D inputImage;
|
||||
layout (binding = 1, rgba8) uniform image2D resultImage;
|
||||
|
||||
float conv(in float[9] kernel, in float[9] data, in float denom, in float offset)
|
||||
{
|
||||
float res = 0.0;
|
||||
for (int i=0; i<9; ++i)
|
||||
{
|
||||
res += kernel[i] * data[i];
|
||||
}
|
||||
return clamp(res/denom + offset, 0.0, 1.0);
|
||||
}
|
||||
|
||||
struct ImageData
|
||||
{
|
||||
float avg[9];
|
||||
} imageData;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Fetch neighbouring texels
|
||||
int n = -1;
|
||||
for (int i=-1; i<2; ++i)
|
||||
{
|
||||
for(int j=-1; j<2; ++j)
|
||||
{
|
||||
n++;
|
||||
vec3 rgb = imageLoad(inputImage, ivec2(gl_GlobalInvocationID.x + i, gl_GlobalInvocationID.y + j)).rgb;
|
||||
imageData.avg[n] = (rgb.r + rgb.g + rgb.b) / 3.0;
|
||||
}
|
||||
}
|
||||
|
||||
float[9] kernel;
|
||||
kernel[0] = -1.0/8.0; kernel[1] = -1.0/8.0; kernel[2] = -1.0/8.0;
|
||||
kernel[3] = -1.0/8.0; kernel[4] = 1.0; kernel[5] = -1.0/8.0;
|
||||
kernel[6] = -1.0/8.0; kernel[7] = -1.0/8.0; kernel[8] = -1.0/8.0;
|
||||
|
||||
vec4 res = vec4(vec3(conv(kernel, imageData.avg, 0.1, 0.0)), 1.0);
|
||||
|
||||
imageStore(resultImage, ivec2(gl_GlobalInvocationID.xy), res);
|
||||
}
|
||||
BIN
data/shaders/computeshader/edgedetect.comp.spv
Normal file
BIN
data/shaders/computeshader/edgedetect.comp.spv
Normal file
Binary file not shown.
47
data/shaders/computeshader/emboss.comp
Normal file
47
data/shaders/computeshader/emboss.comp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (local_size_x =16, local_size_y = 16) in;
|
||||
layout (binding = 0, rgba8) uniform image2D inputImage;
|
||||
layout (binding = 1, rgba8) uniform image2D resultImage;
|
||||
|
||||
float conv(in float[9] kernel, in float[9] data, in float denom, in float offset)
|
||||
{
|
||||
float res = 0.0;
|
||||
for (int i=0; i<9; ++i)
|
||||
{
|
||||
res += kernel[i] * data[i];
|
||||
}
|
||||
return clamp(res/denom + offset, 0.0, 1.0);
|
||||
}
|
||||
|
||||
struct ImageData
|
||||
{
|
||||
float avg[9];
|
||||
} imageData;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Fetch neighbouring texels
|
||||
int n = -1;
|
||||
for (int i=-1; i<2; ++i)
|
||||
{
|
||||
for(int j=-1; j<2; ++j)
|
||||
{
|
||||
n++;
|
||||
vec3 rgb = imageLoad(inputImage, ivec2(gl_GlobalInvocationID.x + i, gl_GlobalInvocationID.y + j)).rgb;
|
||||
imageData.avg[n] = (rgb.r + rgb.g + rgb.b) / 3.0;
|
||||
}
|
||||
}
|
||||
|
||||
float[9] kernel;
|
||||
kernel[0] = -1.0; kernel[1] = 0.0; kernel[2] = 0.0;
|
||||
kernel[3] = 0.0; kernel[4] = -1.0; kernel[5] = 0.0;
|
||||
kernel[6] = 0.0; kernel[7] = 0.0; kernel[8] = 2.0;
|
||||
|
||||
vec4 res = vec4(vec3(conv(kernel, imageData.avg, 1.0, 0.50)), 1.0);
|
||||
|
||||
imageStore(resultImage, ivec2(gl_GlobalInvocationID.xy), res);
|
||||
}
|
||||
BIN
data/shaders/computeshader/emboss.comp.spv
Normal file
BIN
data/shaders/computeshader/emboss.comp.spv
Normal file
Binary file not shown.
7
data/shaders/computeshader/generate-spirv.bat
Normal file
7
data/shaders/computeshader/generate-spirv.bat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
glslangvalidator -V edgedetect.comp -o edgedetect.comp.spv
|
||||
glslangvalidator -V emboss.comp -o emboss.comp.spv
|
||||
glslangvalidator -V sharpen.comp -o sharpen.comp.spv
|
||||
glslangvalidator -V texture.frag -o texture.frag.spv
|
||||
glslangvalidator -V texture.vert -o texture.vert.spv
|
||||
|
||||
|
||||
56
data/shaders/computeshader/sharpen.comp
Normal file
56
data/shaders/computeshader/sharpen.comp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (local_size_x =16, local_size_y = 16) in;
|
||||
layout (binding = 0, rgba8) uniform image2D inputImage;
|
||||
layout (binding = 1, rgba8) uniform image2D resultImage;
|
||||
|
||||
float conv(in float[9] kernel, in float[9] data, in float denom, in float offset)
|
||||
{
|
||||
float res = 0.0;
|
||||
for (int i=0; i<9; ++i)
|
||||
{
|
||||
res += kernel[i] * data[i];
|
||||
}
|
||||
return clamp(res/denom + offset, 0.0, 1.0);
|
||||
}
|
||||
|
||||
struct ImageData
|
||||
{
|
||||
float r[9];
|
||||
float g[9];
|
||||
float b[9];
|
||||
} imageData;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
// Fetch neighbouring texels
|
||||
int n = -1;
|
||||
for (int i=-1; i<2; ++i)
|
||||
{
|
||||
for(int j=-1; j<2; ++j)
|
||||
{
|
||||
n++;
|
||||
vec3 rgb = imageLoad(inputImage, ivec2(gl_GlobalInvocationID.x + i, gl_GlobalInvocationID.y + j)).rgb;
|
||||
imageData.r[n] = rgb.r;
|
||||
imageData.g[n] = rgb.g;
|
||||
imageData.b[n] = rgb.b;
|
||||
}
|
||||
}
|
||||
|
||||
float[9] kernel;
|
||||
kernel[0] = -1.0; kernel[1] = -1.0; kernel[2] = -1.0;
|
||||
kernel[3] = -1.0; kernel[4] = 9.0; kernel[5] = -1.0;
|
||||
kernel[6] = -1.0; kernel[7] = -1.0; kernel[8] = -1.0;
|
||||
|
||||
vec4 res = vec4(
|
||||
conv(kernel, imageData.r, 1.0, 0.0),
|
||||
conv(kernel, imageData.g, 1.0, 0.0),
|
||||
conv(kernel, imageData.b, 1.0, 0.0),
|
||||
1.0);
|
||||
|
||||
imageStore(resultImage, ivec2(gl_GlobalInvocationID.xy), res);
|
||||
}
|
||||
BIN
data/shaders/computeshader/sharpen.comp.spv
Normal file
BIN
data/shaders/computeshader/sharpen.comp.spv
Normal file
Binary file not shown.
15
data/shaders/computeshader/texture.frag
Normal file
15
data/shaders/computeshader/texture.frag
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 1) uniform sampler2D samplerColor;
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
outFragColor = texture(samplerColor, inUV);
|
||||
}
|
||||
BIN
data/shaders/computeshader/texture.frag.spv
Normal file
BIN
data/shaders/computeshader/texture.frag.spv
Normal file
Binary file not shown.
21
data/shaders/computeshader/texture.vert
Normal file
21
data/shaders/computeshader/texture.vert
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
layout (location = 1) in vec2 inUV;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
|
||||
void main()
|
||||
{
|
||||
outUV = inUV;
|
||||
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
}
|
||||
BIN
data/shaders/computeshader/texture.vert.spv
Normal file
BIN
data/shaders/computeshader/texture.vert.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue