1#version 450 core 2#define PRECISION ${PRECISION} 3#define FORMAT ${FORMAT} 4 5layout(std430) buffer; 6 7/* Qualifiers: layout - storage - precision - memory */ 8 9layout(set = 0, binding = 0, FORMAT) uniform PRECISION restrict writeonly image3D uOutput; 10layout(set = 0, binding = 1) uniform PRECISION sampler3D uInput; 11layout(set = 0, binding = 2) uniform PRECISION restrict Block { 12 ivec4 size; 13 float negative_slope; 14} uBlock; 15 16layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; 17 18void main() { 19 const ivec3 pos = ivec3(gl_GlobalInvocationID); 20 21 if (all(lessThan(pos, uBlock.size.xyz))) { 22 const vec4 inval = texelFetch(uInput, pos, 0); 23 const vec4 negative_values = vec4(lessThan(inval, vec4(0.0f))); 24 const vec4 positive_values = vec4(1.0) - negative_values; 25 const vec4 mask = negative_values * vec4(uBlock.negative_slope) + positive_values; 26 const vec4 outval = inval * mask; 27 imageStore(uOutput, pos, outval); 28 } 29} 30