-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef20302
commit 287749a
Showing
21 changed files
with
809 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Vulkan/Vulkan_Sample/Vulkan/assets/shaders/computeshader/edgedetect.comp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#version 450 | ||
|
||
layout (local_size_x = 16, local_size_y = 16) in; | ||
layout (binding = 0, rgba8) uniform readonly 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); | ||
} |
Binary file added
BIN
+3.85 KB
Vulkan/Vulkan_Sample/Vulkan/assets/shaders/computeshader/edgedetect.comp.spv
Binary file not shown.
44 changes: 44 additions & 0 deletions
44
Vulkan/Vulkan_Sample/Vulkan/assets/shaders/computeshader/emboss.comp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#version 450 | ||
|
||
layout (local_size_x = 16, local_size_y = 16) in; | ||
layout (binding = 0, rgba8) uniform readonly 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); | ||
} |
Binary file added
BIN
+3.86 KB
Vulkan/Vulkan_Sample/Vulkan/assets/shaders/computeshader/emboss.comp.spv
Binary file not shown.
53 changes: 53 additions & 0 deletions
53
Vulkan/Vulkan_Sample/Vulkan/assets/shaders/computeshader/sharpen.comp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#version 450 | ||
|
||
layout (local_size_x = 16, local_size_y = 16) in; | ||
layout (binding = 0, rgba8) uniform readonly 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); | ||
} |
Binary file added
BIN
+4.34 KB
Vulkan/Vulkan_Sample/Vulkan/assets/shaders/computeshader/sharpen.comp.spv
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
Vulkan/Vulkan_Sample/Vulkan/assets/shaders/computeshader/texture.frag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#version 450 | ||
|
||
layout (binding = 1) uniform sampler2D samplerColor; | ||
|
||
layout (location = 0) in vec2 inUV; | ||
|
||
layout (location = 0) out vec4 outFragColor; | ||
|
||
void main() | ||
{ | ||
outFragColor = texture(samplerColor, inUV); | ||
} |
Binary file added
BIN
+568 Bytes
Vulkan/Vulkan_Sample/Vulkan/assets/shaders/computeshader/texture.frag.spv
Binary file not shown.
23 changes: 23 additions & 0 deletions
23
Vulkan/Vulkan_Sample/Vulkan/assets/shaders/computeshader/texture.vert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#version 450 | ||
|
||
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; | ||
|
||
out gl_PerVertex | ||
{ | ||
vec4 gl_Position; | ||
}; | ||
|
||
void main() | ||
{ | ||
outUV = inUV; | ||
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0); | ||
} |
Binary file added
BIN
+1.2 KB
Vulkan/Vulkan_Sample/Vulkan/assets/shaders/computeshader/texture.vert.spv
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.