Added basic input attachment sample
This commit is contained in:
parent
8a6184dc81
commit
a1f166e001
11 changed files with 731 additions and 0 deletions
19
data/shaders/inputattachments/attachmentread.frag
Normal file
19
data/shaders/inputattachments/attachmentread.frag
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#version 450
|
||||
|
||||
layout (input_attachment_index = 0, binding = 0) uniform subpassInput inputColor;
|
||||
layout (input_attachment_index = 1, binding = 1) uniform subpassInput inputDepth;
|
||||
|
||||
layout (binding = 2) uniform UBO {
|
||||
vec2 range;
|
||||
int attachmentIndex;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec4 outColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Read values from previous sub pass
|
||||
vec3 col = ubo.attachmentIndex == 0 ? subpassLoad(inputColor).rgb : subpassLoad(inputDepth).rrr;
|
||||
|
||||
outColor.rgb = ((col - ubo.range[0]) * 1.0 / (ubo.range[1] - ubo.range[0]));
|
||||
}
|
||||
BIN
data/shaders/inputattachments/attachmentread.frag.spv
Normal file
BIN
data/shaders/inputattachments/attachmentread.frag.spv
Normal file
Binary file not shown.
10
data/shaders/inputattachments/attachmentread.vert
Normal file
10
data/shaders/inputattachments/attachmentread.vert
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#version 450
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2) * 2.0f - 1.0f, 0.0f, 1.0f);
|
||||
}
|
||||
BIN
data/shaders/inputattachments/attachmentread.vert.spv
Normal file
BIN
data/shaders/inputattachments/attachmentread.vert.spv
Normal file
Binary file not shown.
14
data/shaders/inputattachments/attachmentwrite.frag
Normal file
14
data/shaders/inputattachments/attachmentwrite.frag
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#version 450
|
||||
|
||||
layout (location = 0) in vec3 inColor;
|
||||
|
||||
layout (location = 0) out vec4 outSwapChainColor;
|
||||
layout (location = 1) out vec4 outColor;
|
||||
layout (location = 2) out float outDepth;
|
||||
|
||||
void main()
|
||||
{
|
||||
outSwapChainColor = vec4(0.0);
|
||||
outColor = vec4(inColor, 0.0);
|
||||
outDepth = gl_FragDepth;
|
||||
}
|
||||
BIN
data/shaders/inputattachments/attachmentwrite.frag.spv
Normal file
BIN
data/shaders/inputattachments/attachmentwrite.frag.spv
Normal file
Binary file not shown.
26
data/shaders/inputattachments/attachmentwrite.vert
Normal file
26
data/shaders/inputattachments/attachmentwrite.vert
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec4 inPos;
|
||||
layout (location = 1) in vec3 inColor;
|
||||
layout (location = 2) in vec3 inNormal;
|
||||
|
||||
layout (binding = 0) uniform UBO {
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outColor;
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ubo.projection * ubo.view * ubo.model * inPos;
|
||||
outColor = inColor;
|
||||
}
|
||||
BIN
data/shaders/inputattachments/attachmentwrite.vert.spv
Normal file
BIN
data/shaders/inputattachments/attachmentwrite.vert.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue