// MIT License // // Copyright (C) 2018-2023, Tellusim Technologies Inc. https://tellusim.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #version 430 core /* */ #if COMPUTE_SHADER layout(local_size_x = 8, local_size_y = 8) in; layout(std140, binding = 0) uniform ComputeParameters { uint size; }; layout(std430, binding = 1) readonly buffer DataBuffer { uint data_buffer[]; }; layout(binding = 0, set = 1, rgba8) uniform writeonly image2D out_surface; /* */ void main() { uvec2 global_id = gl_GlobalInvocationID.xy; uint index = size * global_id.y + global_id.x; uint data = data_buffer[size * size + index]; vec4 color = vec4(data / float(size * size - 1)); imageStore(out_surface, ivec2(global_id), color); } #elif VERTEX_SHADER layout(location = 0) out vec2 s_texcoord; /* */ void main() { vec2 texcoord = vec2(0.0f); if(gl_VertexIndex == 0) texcoord.x = 2.0f; if(gl_VertexIndex == 2) texcoord.y = 2.0f; gl_Position = vec4(texcoord * 2.0f - 1.0f, 0.0f, 1.0f); #if CLAY_VK texcoord.y = 1.0f - texcoord.y; #endif s_texcoord = texcoord; } #elif FRAGMENT_SHADER layout(binding = 0, set = 1) uniform sampler in_sampler; layout(binding = 0, set = 0) uniform texture2D in_texture; layout(location = 0) in vec2 s_texcoord; layout(location = 0) out vec4 out_color; /* */ void main() { out_color = texture(sampler2D(in_texture, in_sampler), s_texcoord); } #endif