diff --git a/src/xrt/compositor/CMakeLists.txt b/src/xrt/compositor/CMakeLists.txt index 070d84df4..b23db4b87 100644 --- a/src/xrt/compositor/CMakeLists.txt +++ b/src/xrt/compositor/CMakeLists.txt @@ -93,8 +93,6 @@ if(XRT_HAVE_VULKAN) shaders/layer.comp shaders/mesh.frag shaders/mesh.vert - shaders/layer.frag - shaders/layer.vert shaders/layer_cylinder.frag shaders/layer_cylinder.vert shaders/layer_equirect2.frag @@ -102,14 +100,7 @@ if(XRT_HAVE_VULKAN) shaders/layer_projection.vert shaders/layer_quad.vert shaders/layer_shared.frag - shaders/equirect1.vert - shaders/equirect1.frag - shaders/equirect2.vert - shaders/equirect2.frag ) - if(XRT_FEATURE_OPENXR_LAYER_CUBE) - list(APPEND SHADERS shaders/cube.vert shaders/cube.frag) - endif() spirv_shaders( SHADER_HEADERS diff --git a/src/xrt/compositor/render/render_interface.h b/src/xrt/compositor/render/render_interface.h index 805c55ae6..a797b43ae 100644 --- a/src/xrt/compositor/render/render_interface.h +++ b/src/xrt/compositor/render/render_interface.h @@ -139,17 +139,6 @@ struct render_shaders VkShaderModule mesh_vert; VkShaderModule mesh_frag; - VkShaderModule equirect1_vert; - VkShaderModule equirect1_frag; - - VkShaderModule equirect2_vert; - VkShaderModule equirect2_frag; - - VkShaderModule cube_vert; - VkShaderModule cube_frag; - - VkShaderModule layer_vert; - VkShaderModule layer_frag; /* * New layer renderer. diff --git a/src/xrt/compositor/render/render_shaders.c b/src/xrt/compositor/render/render_shaders.c index 39932f8bb..b07cae07c 100644 --- a/src/xrt/compositor/render/render_shaders.c +++ b/src/xrt/compositor/render/render_shaders.c @@ -30,12 +30,6 @@ #include "shaders/clear.comp.h" #include "shaders/layer.comp.h" #include "shaders/distortion.comp.h" -#include "shaders/layer.frag.h" -#include "shaders/layer.vert.h" -#include "shaders/equirect1.frag.h" -#include "shaders/equirect1.vert.h" -#include "shaders/equirect2.frag.h" -#include "shaders/equirect2.vert.h" #include "shaders/layer_cylinder.frag.h" #include "shaders/layer_cylinder.vert.h" #include "shaders/layer_equirect2.frag.h" @@ -123,20 +117,6 @@ render_shaders_load(struct render_shaders *s, struct vk_bundle *vk) LOAD(mesh_vert); LOAD(mesh_frag); - LOAD(equirect1_vert); - LOAD(equirect1_frag); - - LOAD(equirect2_vert); - LOAD(equirect2_frag); - -#ifdef XRT_FEATURE_OPENXR_LAYER_CUBE - LOAD(cube_vert); - LOAD(cube_frag); -#endif - - LOAD(layer_vert); - LOAD(layer_frag); - LOAD(layer_cylinder_frag); LOAD(layer_cylinder_vert); LOAD(layer_equirect2_frag); @@ -159,16 +139,6 @@ render_shaders_close(struct render_shaders *s, struct vk_bundle *vk) D(ShaderModule, s->layer_comp); D(ShaderModule, s->mesh_vert); D(ShaderModule, s->mesh_frag); - D(ShaderModule, s->equirect1_vert); - D(ShaderModule, s->equirect1_frag); - D(ShaderModule, s->equirect2_vert); - D(ShaderModule, s->equirect2_frag); -#ifdef XRT_FEATURE_OPENXR_LAYER_CUBE - D(ShaderModule, s->cube_vert); - D(ShaderModule, s->cube_frag); -#endif - D(ShaderModule, s->layer_vert); - D(ShaderModule, s->layer_frag); D(ShaderModule, s->layer_cylinder_frag); D(ShaderModule, s->layer_cylinder_vert); diff --git a/src/xrt/compositor/shaders/cube.frag b/src/xrt/compositor/shaders/cube.frag deleted file mode 100644 index 518358e4d..000000000 --- a/src/xrt/compositor/shaders/cube.frag +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2020 Simon Zeni -// Author: Simon Zeni -// Author: Bjorn Swenson -// SPDX-License-Identifier: BSL-1.0 - -#version 460 - -layout (binding = 0, std140) uniform Transformation -{ - mat4 mvp; - ivec2 offset; - ivec2 extent; - bool flip_y; -} ubo; - -layout (binding = 1) uniform samplerCube cube; - -layout (location = 0) in vec2 uv; -layout (location = 0) out vec4 out_color; - -void main () -{ - vec2 frag_coord = vec2(uv) * 2 - 1; - vec4 view_dir = normalize(ubo.mvp * vec4(frag_coord.x, frag_coord.y, 1, 1)); - - out_color = texture(cube, view_dir.xyz); -} diff --git a/src/xrt/compositor/shaders/cube.vert b/src/xrt/compositor/shaders/cube.vert deleted file mode 100644 index d9d5066fc..000000000 --- a/src/xrt/compositor/shaders/cube.vert +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2020 Simon Zeni -// Author: Simon Zeni -// Author: Bjorn Swenson -// SPDX-License-Identifier: BSL-1.0 - -#version 460 - -layout (binding = 0, std140) uniform Transformation -{ - mat4 mvp; - ivec2 offset; - ivec2 extent; - bool flip_y; -} transformation; - -layout (location = 0) in vec3 position; -layout (location = 1) in vec2 uv; -layout (location = 0) out vec2 out_uv; - -const mat4 mvp = mat4( - 2, 0, 0, 0, - 0, 2, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 -); - -void main() { - gl_Position = mvp * vec4(position, 1.0); - gl_Position.y *= -1.; - - out_uv = uv; - - if (transformation.flip_y) { - out_uv.y = 1.0 - out_uv.y; - } -} diff --git a/src/xrt/compositor/shaders/equirect1.frag b/src/xrt/compositor/shaders/equirect1.frag deleted file mode 100644 index c1bf0b0d9..000000000 --- a/src/xrt/compositor/shaders/equirect1.frag +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2020 Collabora Ltd. -// Author: Lubosz Sarnecki -// SPDX-License-Identifier: BSL-1.0 - -#version 460 - - -layout (set = 0, binding = 0, std140) uniform Transformation -{ - mat4 mvp; - ivec2 offset; - ivec2 extent; - bool flip_y; -} ubo; - -layout (set = 0, binding = 1) uniform sampler2D image; - -layout (set = 1, binding = 0, std140) uniform Equirect -{ - vec2 scale; - vec2 bias; - float radius; -} equirect; - -layout (location = 0) in vec2 uv; -layout (location = 0) out vec4 out_color; - -const float PI = 3.1416; - - -void main () -{ - vec2 uv_sub = vec2(ubo.offset) + uv * vec2(ubo.extent); - uv_sub /= textureSize(image, 0); - - vec2 frag_coord = vec2(uv_sub) * 2 - 1; - - vec4 view_dir = normalize(ubo.mvp * vec4(frag_coord.x, -frag_coord.y, 1, 1)); - - float lat = atan(view_dir.x, -view_dir.z) / (2 * PI); - float lon = acos(view_dir.y) / PI; - - lat *= equirect.scale.x; - lon *= equirect.scale.y; - - lat += equirect.bias.x; - lon += equirect.bias.y; - - out_color = texture(image, vec2(lat, lon)); -} - diff --git a/src/xrt/compositor/shaders/equirect1.vert b/src/xrt/compositor/shaders/equirect1.vert deleted file mode 100644 index b7a6e6b12..000000000 --- a/src/xrt/compositor/shaders/equirect1.vert +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2020 Collabora Ltd. -// Author: Lubosz Sarnecki -// SPDX-License-Identifier: BSL-1.0 - -#version 460 - -layout (binding = 0, std140) uniform Transformation { - mat4 mvp; - ivec2 offset; - ivec2 extent; - bool flip_y; -} transformation; - -layout (location = 0) in vec3 position; -layout (location = 1) in vec2 uv; -layout (location = 0) out vec2 out_uv; - -out gl_PerVertex { - vec4 gl_Position; -}; - -const mat4 mvp = mat4( - 2, 0, 0, 0, - 0, 2, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 -); - -void main() -{ - gl_Position = mvp * vec4 (position, 1.0f); - gl_Position.y = -gl_Position.y; - out_uv = uv; - - if (transformation.flip_y) { - out_uv.y = 1.0 - out_uv.y; - } -} diff --git a/src/xrt/compositor/shaders/equirect2.frag b/src/xrt/compositor/shaders/equirect2.frag deleted file mode 100644 index 0b6399c1e..000000000 --- a/src/xrt/compositor/shaders/equirect2.frag +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2020 Collabora Ltd. -// Author: Lubosz Sarnecki -// SPDX-License-Identifier: BSL-1.0 - -#version 460 - - -layout (set = 0, binding = 0, std140) uniform Transformation { - mat4 mvp; - ivec2 offset; - ivec2 extent; - bool flip_y; -} ubo; - -layout (set = 0, binding = 1) uniform sampler2D image; - -layout (set = 1, binding = 0, std140) uniform Equirect { - float radius; - float central_horizontal_angle; - float upper_vertical_angle; - float lower_vertical_angle; -} equirect; - -layout (location = 0) in vec2 uv; -layout (location = 0) out vec4 out_color; - -const float PI = 3.1416; - - -void main () -{ - vec2 uv_sub = vec2(ubo.offset) + uv * vec2(ubo.extent); - uv_sub /= textureSize(image, 0); - - vec2 frag_coord = vec2(uv_sub) * 2 - 1; - - vec4 view_dir = normalize(ubo.mvp * vec4(frag_coord.x, -frag_coord.y, 1, 1)); - - float lat = atan(view_dir.x, -view_dir.z) / (2 * PI); - float lon = acos(view_dir.y) / PI; - -#undef DEBUG -#ifdef DEBUG - int lat_int = int(lat * 1000.0); - int lon_int = int(lon * 1000.0); - - if (lat < 0.001 && lat > -0.001) { - out_color = vec4(1, 0, 0, 1); - } else if (lat_int % 50 == 0) { - out_color = vec4(1, 1, 1, 1); - } else if (lon_int % 50 == 0) { - out_color = vec4(1, 1, 1, 1); - } else { - out_color = vec4(lat, lon, 0, 1); - } -#endif - - float chan = equirect.central_horizontal_angle / (PI * 2.0f); - - // Normalize [0, 2π] to [0, 1] - float uhan = chan / 2.0f; - float lhan = -chan / 2.0f; - - // Normalize [-π/2, π/2] to [0, 1] - float uvan = equirect.upper_vertical_angle / PI + 0.5f; - float lvan = equirect.lower_vertical_angle / PI + 0.5f; - - if (lon < uvan && lon > lvan && lat < uhan && lat > lhan) { - -#ifdef DEBUG - out_color += texture(image, vec2(lat, lon)) / 2.0; -#else - out_color = texture(image, vec2(lat, lon)); - } else { - out_color = vec4(0, 0, 0, 0); - } -#endif -} - diff --git a/src/xrt/compositor/shaders/equirect2.vert b/src/xrt/compositor/shaders/equirect2.vert deleted file mode 100644 index d1684f85e..000000000 --- a/src/xrt/compositor/shaders/equirect2.vert +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2020 Collabora Ltd. -// Author: Lubosz Sarnecki -// SPDX-License-Identifier: BSL-1.0 - -#version 460 - - -layout (binding = 0, std140) uniform Transformation -{ - mat4 mvp; - ivec2 offset; - ivec2 extent; - bool flip_y; -} transformation; - -layout (location = 0) in vec3 position; -layout (location = 1) in vec2 uv; -layout (location = 0) out vec2 out_uv; - -out gl_PerVertex -{ - vec4 gl_Position; -}; - -const mat4 mvp = mat4( - 2, 0, 0, 0, - 0, 2, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 -); - - -void main() { - gl_Position = mvp * vec4 (position, 1.0f); - gl_Position.y = -gl_Position.y; - out_uv = uv; - - if (transformation.flip_y) { - out_uv.y = 1.0 - out_uv.y; - } -} diff --git a/src/xrt/compositor/shaders/layer.frag b/src/xrt/compositor/shaders/layer.frag deleted file mode 100644 index 0c4d2635b..000000000 --- a/src/xrt/compositor/shaders/layer.frag +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2020 Collabora Ltd. -// Author: Lubosz Sarnecki -// SPDX-License-Identifier: BSL-1.0 - -#version 460 - - -layout (binding = 0, std140) uniform Transformation -{ - mat4 mvp; - ivec2 offset; - ivec2 extent; - bool flip_y; -} ubo; - -layout (binding = 1) uniform sampler2D image; - -layout (location = 0) in vec2 uv; -layout (location = 0) out vec4 out_color; - - -void main () -{ - vec2 uv_sub = vec2(ubo.offset) + uv * vec2(ubo.extent); - uv_sub /= textureSize(image, 0); - out_color = texture(image, uv_sub); -} diff --git a/src/xrt/compositor/shaders/layer.vert b/src/xrt/compositor/shaders/layer.vert deleted file mode 100644 index 376de6849..000000000 --- a/src/xrt/compositor/shaders/layer.vert +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2020 Collabora Ltd. -// Author: Lubosz Sarnecki -// SPDX-License-Identifier: BSL-1.0 - -#version 460 - - -layout (binding = 0, std140) uniform Transformation -{ - mat4 mvp; - ivec2 offset; - ivec2 extent; - bool flip_y; -} transformation; - -layout (location = 0) in vec3 position; -layout (location = 1) in vec2 uv; -layout (location = 0) out vec2 out_uv; - -out gl_PerVertex -{ - vec4 gl_Position; -}; - - -void main() { - gl_Position = transformation.mvp * vec4 (position, 1.0f); - gl_Position.y = -gl_Position.y; - out_uv = uv; - - if (transformation.flip_y) { - out_uv.y = 1.0 - out_uv.y; - } -}