From 1095bb8e03b8932e87b0dbe3e496396912b81d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nadir=20Rom=C3=A1n=20Guerrero?= Date: Mon, 26 Jun 2023 13:33:26 +0200 Subject: [PATCH] BRAYNS 558 - Migrate cylindric camera to OSPRay (#1188) --- .gitlab-ci.viz.yml | 2 +- Dockerfile | 6 +- README.md | 8 +-- plugins/CMakeLists.txt | 4 -- plugins/CylindricCamera/CMakeLists.txt | 18 ------ .../CylindricCamera/CylindricCameraPlugin.cpp | 3 - .../camera/ospray/OsprayCylindricCamera.cpp | 56 ------------------- .../camera/ospray/OsprayCylindricCamera.h | 41 -------------- .../camera/ospray/OsprayCylindricCamera.ispc | 52 ----------------- .../ospray/OsprayCylindricCameraShared.h | 52 ----------------- 10 files changed, 6 insertions(+), 236 deletions(-) delete mode 100644 plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.cpp delete mode 100644 plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.h delete mode 100644 plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.ispc delete mode 100644 plugins/CylindricCamera/camera/ospray/OsprayCylindricCameraShared.h diff --git a/.gitlab-ci.viz.yml b/.gitlab-ci.viz.yml index 7877dfb6b..c422ff211 100644 --- a/.gitlab-ci.viz.yml +++ b/.gitlab-ci.viz.yml @@ -96,7 +96,7 @@ ubuntu-clangformat-check: # Install OSPRay # https://github.com/ospray/ospray/releases - - OSPRAY_TAG=v2.10.4 + - OSPRAY_TAG=v2.10.5 - OSPRAY_SRC=/app/ospray - mkdir -p ${OSPRAY_SRC} diff --git a/Dockerfile b/Dockerfile index e9a839a6f..8e5236f6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,12 +29,9 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Get ISPC -# https://ispc.github.io/downloads.html - ARG ISPC_VERSION=1.18.0 ARG ISPC_DIR=ispc-v${ISPC_VERSION}-linux ARG ISPC_PATH=/app/ispc-v1.18.0-linux - RUN mkdir -p ${ISPC_PATH} \ && wget https://github.com/ispc/ispc/releases/download/v1.18.0/${ISPC_DIR}.tar.gz \ && tar zxvf ${ISPC_DIR}.tar.gz -C ${ISPC_PATH} --strip-components=1 \ @@ -52,7 +49,6 @@ RUN wget https://github.com/oneapi-src/oneTBB/releases/download/v${ONETBB_VERSIO && tar zxvf ${ONETBB_FILE} -C ${DIST_PATH} --strip-components=1 # Install embree -# https://github.com/embree/embree/releases ARG EMBREE_VERSION=3.13.3 ARG EMBREE_FILE=embree-${EMBREE_VERSION}.x86_64.linux.tar.gz RUN wget https://github.com/embree/embree/releases/download/v${EMBREE_VERSION}/${EMBREE_FILE} \ @@ -88,7 +84,7 @@ RUN mkdir ${OPENVKL_SRC} \ && ninja -j4 install # Install OSPRay -ARG OSPRAY_TAG=v2.10.4 +ARG OSPRAY_TAG=v2.10.5 ARG OSPRAY_SRC=/app/ospray RUN mkdir -p ${OSPRAY_SRC} \ diff --git a/README.md b/README.md index 00daa0682..6aa99dad3 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ The following components must be installed on the system where Brayns will be bu * Package config * SSL Development files * Python 3.9 or higher -* Custom OSPRay 2.10.4 (https://github.com/BlueBrain/ospray/tree/v2.10.4) +* Custom OSPRay 2.10.5 (https://github.com/BlueBrain/ospray/tree/v2.10.5) * zlib Optionally, to build the core plugins of Brayns, the following components are required. @@ -50,10 +50,10 @@ Brayns uses further dependencies, but if they are not present on the system, it * spdlog 1.9.2 (https://github.com/gabime/spdlog/tree/v1.9.2) * stb (https://github.com/nothings/stb) * tinyexr (https://github.com/syoyo/tinyexr/tree/v1.0.1) -* libsonata 0.1.20 (https://github.com/BlueBrain/libsonata/tree/v0.1.20) +* libsonata 0.1.22 (https://github.com/BlueBrain/libsonata/tree/v0.1.22) * MVDTool 2.4.4 (https://github.com/BlueBrain/MVDTool/tree/v2.4.4) -* MorphIO 3.3.4 (https://github.com/BlueBrain/MorphIO/tree/v3.3.4) -* Brion 3.3.9 (https://github.com/BlueBrain/Brion/tree/3.3.9) +* MorphIO 3.3.5 (https://github.com/BlueBrain/MorphIO/tree/v3.3.5) +* Brion 3.3.14 (https://github.com/BlueBrain/Brion/tree/3.3.14) ### Build command diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 6ed9fed9e..a4d5c8d9c 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -26,10 +26,6 @@ if(BRAYNS_ATLASEXPLORER_ENABLED) find_package(BZip2 REQUIRED) endif() -if(BRAYNS_CYLINDRICCAMERA_ENABLED) - find_package(rkcommon REQUIRED) -endif() - add_subdirectory(deps) if(BRAYNS_CIRCUITEXPLORER_ENABLED) diff --git a/plugins/CylindricCamera/CMakeLists.txt b/plugins/CylindricCamera/CMakeLists.txt index 55b7ff052..b6958618a 100644 --- a/plugins/CylindricCamera/CMakeLists.txt +++ b/plugins/CylindricCamera/CMakeLists.txt @@ -4,18 +4,8 @@ # # This file is part of Brayns -list(APPEND CMAKE_MODULE_PATH ${OSPRAY_CMAKE_ROOT}) -include(osprayUse) - file(GLOB_RECURSE BRAYNSCYLINDRICCAMERA_SOURCES RELATIVE ${CMAKE_CURRENT_LIST_DIR} *.cpp) file(GLOB_RECURSE BRAYNSCYLINDRICCAMERA_HEADERS RELATIVE ${CMAKE_CURRENT_LIST_DIR} *.h) -file(GLOB_RECURSE BRAYNSCYLINDRICCAMERA_ISPC_SOURCES RELATIVE ${CMAKE_CURRENT_LIST_DIR} *.ispc) - -ispc_include_directories(${CMAKE_CURRENT_LIST_DIR} - ${OSPRAY_INCLUDE_DIR} - ${OSPRAY_INCLUDE_DIR}/ospray/SDK/modules/cpu) -ispc_compile(${BRAYNSCYLINDRICCAMERA_ISPC_SOURCES}) -list(APPEND BRAYNSCYLINDRICCAMERA_SOURCES ${ISPC_OBJECTS}) add_library(braynsCylindricCamera SHARED ${BRAYNSCYLINDRICCAMERA_SOURCES} ${BRAYNSCYLINDRICCAMERA_HEADERS}) @@ -23,18 +13,10 @@ target_include_directories(braynsCylindricCamera PUBLIC "$" "$") -target_include_directories(braynsCylindricCamera PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/camera # to find the autogenerated *_ispc.h file - ${OSPRAY_INCLUDE_DIR} # to fix relative imports within Ospray SDK - ${OSPRAY_INCLUDE_DIR}/ospray/SDK/common - ${OSPRAY_INCLUDE_DIR}/ospray/SDK/modules/cpu - ${RKCOMMON_INCLUDE_DIRS}) - target_link_libraries(braynsCylindricCamera PRIVATE braynsEngine braynsPluginAPI braynsNetwork - rkcommon::rkcommon ospray::ospray ospray::ospray_sdk ospray::ospray_module_cpu) diff --git a/plugins/CylindricCamera/CylindricCameraPlugin.cpp b/plugins/CylindricCamera/CylindricCameraPlugin.cpp index 4c0d38bc2..d89a2c817 100644 --- a/plugins/CylindricCamera/CylindricCameraPlugin.cpp +++ b/plugins/CylindricCamera/CylindricCameraPlugin.cpp @@ -25,13 +25,10 @@ #include #include "camera/CylindricAdapter.h" -#include "camera/ospray/OsprayCylindricCamera.h" #include "network/entrypoints/CylindricCameraEntrypoint.h" CylindricCameraPlugin::CylindricCameraPlugin(brayns::PluginAPI &api) { - ospray::Camera::registerType(brayns::ProjectionTraits::name.c_str()); - auto &engine = api.getEngine(); auto &factories = engine.getFactories(); auto &cameras = factories.cameras; diff --git a/plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.cpp b/plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.cpp deleted file mode 100644 index f40589487..000000000 --- a/plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2015-2023, EPFL/Blue Brain Project - * All rights reserved. Do not distribute without permission. - * Responsible Author: Cyrille Favreau - * Grigori Chevtchenko - * - * This file is part of Brayns - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License version 3.0 as published - * by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "OsprayCylindricCamera.h" -#include "ospray/OsprayCylindricCamera_ispc.h" - -#include - -OsprayCylindricCamera::OsprayCylindricCamera() -{ - getSh()->super.initRay = ispc::OsprayCylindricCamera_initRay_addr(); -} - -std::string OsprayCylindricCamera::toString() const -{ - return "OsprayCylindricCamera"; -} - -void OsprayCylindricCamera::commit() -{ - ospray::Camera::commit(); - - auto fovy = getParam("fovy", 48.549f); - - dir = normalize(dir); - const auto dirDu = normalize(cross(dir, up)); - const auto dirDv = normalize(up); - dir = -dir; - - const auto imgPlaneSizeY = 2.0f * tanf(rkcommon::math::deg2rad(0.5f * fovy)); - - auto ispcEquivalent = getSh(); - ispcEquivalent->org = pos; - ispcEquivalent->dirCam = dir; - ispcEquivalent->dirDu = dirDu; - ispcEquivalent->dirDv = dirDv; - ispcEquivalent->imgPlaneSizeY = imgPlaneSizeY; -} diff --git a/plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.h b/plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.h deleted file mode 100644 index b9a3626f4..000000000 --- a/plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2015-2023, EPFL/Blue Brain Project - * All rights reserved. Do not distribute without permission. - * Responsible Author: Cyrille Favreau - * Grigori Chevtchenko - * - * This file is part of Brayns - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License version 3.0 as published - * by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include - -#include "OsprayCylindricCameraShared.h" - -/** - * This camera is designed for the opendeck. It has a fixed - * vertical field of view of 48.549 degrees. The rays are using - * cylindrical projection for the x axis and perspective projection - * for the y axis of an image. - */ -class OsprayCylindricCamera : public ospray::AddStructShared -{ -public: - OsprayCylindricCamera(); - - std::string toString() const override; - void commit() override; -}; diff --git a/plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.ispc b/plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.ispc deleted file mode 100644 index a28a3803b..000000000 --- a/plugins/CylindricCamera/camera/ospray/OsprayCylindricCamera.ispc +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2015-2023, EPFL/Blue Brain Project - * All rights reserved. Do not distribute without permission. - * Responsible Author: Cyrille Favreau - * Grigori Chevtchenko - * Nadir Roman Guerrero - * - * This file is part of Brayns - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License version 3.0 as published - * by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "ospray/SDK/modules/cpu/camera/Camera.ih" -#include "ospray/SDK/modules/cpu/math/LinearSpace.ih" - -#include "rkcommon/math/math.ih" - -#include "OsprayCylindricCameraShared.h" - -void OsprayCylindricCamera_initRay(const Camera *uniform _self, varying Ray &ray, const varying CameraSample &sample) -{ - const OsprayCylindricCamera *uniform self = (const OsprayCylindricCamera *uniform)_self; - - vec2f screen = sample.screen; - screen = Camera_subRegion(_self, screen); - - const float alpha = screen.x * -pi; - const float y = self->imgPlaneSizeY * (screen.y - 0.5f); - vec3f dir = normalize(make_vec3f(-cosf(alpha), y, sinf(alpha))); - - const LinearSpace3f cameraSpace = make_LinearSpace3f(self->dirDu, self->dirDv, self->dirCam); - dir = normalize(cameraSpace * dir); - - const float time = Camera_shutterTime(_self, screen, sample.time); - vec3f org = self->org; - setRay(ray, org, normalize(dir), self->super.nearClip, inf, time); -} - -export void *uniform OsprayCylindricCamera_initRay_addr() -{ - return OsprayCylindricCamera_initRay; -} diff --git a/plugins/CylindricCamera/camera/ospray/OsprayCylindricCameraShared.h b/plugins/CylindricCamera/camera/ospray/OsprayCylindricCameraShared.h deleted file mode 100644 index 7338c7ef1..000000000 --- a/plugins/CylindricCamera/camera/ospray/OsprayCylindricCameraShared.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2015-2023, EPFL/Blue Brain Project - * All rights reserved. Do not distribute without permission. - * Responsible Author: Nadir Roman Guerrero - * - * This file is part of Brayns - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License version 3.0 as published - * by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#pragma once - -#include - -#ifdef __cplusplus -namespace ispc -{ -#endif // __cplusplus - -struct OsprayCylindricCamera -{ - Camera super; - - vec3f org; - vec3f dirCam; - vec3f dirDu; - vec3f dirDv; - float imgPlaneSizeY; - -#ifdef __cplusplus - OsprayCylindricCamera(): - org(0.f), - dirCam(0.f), - dirDu(0.f), - dirDv(0.f), - imgPlaneSizeY(0.f) - { - } -}; -} // namespace ispc -#else -}; -#endif // __cplusplus