Different scene, toon shading and separate parameters for color input attachment

This commit is contained in:
saschawillems 2018-07-19 11:01:15 +02:00
parent bdb9af7ef7
commit 0fb88d5467
8 changed files with 74 additions and 31 deletions

View file

@ -4,16 +4,30 @@ 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 brightnessContrast;
vec2 range;
int attachmentIndex;
} ubo;
layout (location = 0) out vec4 outColor;
vec3 brightnessContrast(vec3 color, float brightness, float contrast) {
return (color - 0.5) * contrast + 0.5 + brightness;
}
void main()
{
// Read values from previous sub pass
vec3 col = ubo.attachmentIndex == 0 ? subpassLoad(inputColor).rgb : subpassLoad(inputDepth).rrr;
// Apply brightness and contrast filer to color input
if (ubo.attachmentIndex == 0) {
// Read color from previous color input attachment
vec3 color = subpassLoad(inputColor).rgb;
outColor.rgb = brightnessContrast(color, ubo.brightnessContrast[0], ubo.brightnessContrast[1]);
}
outColor.rgb = ((col - ubo.range[0]) * 1.0 / (ubo.range[1] - ubo.range[0]));
// Visualize depth input range
if (ubo.attachmentIndex == 1) {
// Read depth from previous depth input attachment
float depth = subpassLoad(inputDepth).r;
outColor.rgb = vec3((depth - ubo.range[0]) * 1.0 / (ubo.range[1] - ubo.range[0]));
}
}