diff --git a/bioexplorer/backend/CMakeLists.txt b/bioexplorer/backend/CMakeLists.txt index 548e25862..15ba21e8f 100644 --- a/bioexplorer/backend/CMakeLists.txt +++ b/bioexplorer/backend/CMakeLists.txt @@ -170,8 +170,6 @@ set(${NAME}_PRIVATE_MODULE_LIBRARIES) if(PLATFORM_OSPRAY_ENABLED) list(APPEND ${NAME}_SOURCES module/ispc/renderer/artistic/GolgiStyleRenderer.cpp - module/ispc/renderer/field/PointFieldsRenderer.cpp - module/ispc/renderer/field/VectorFieldsRenderer.cpp module/ispc/renderer/DensityRenderer.cpp module/ispc/renderer/PathTracingRenderer.cpp module/ispc/renderer/VoxelRenderer.cpp @@ -179,8 +177,6 @@ if(PLATFORM_OSPRAY_ENABLED) set(${NAME}_ISPC_SOURCES module/ispc/renderer/artistic/GolgiStyleRenderer.ispc - module/ispc/renderer/field/PointFieldsRenderer.ispc - module/ispc/renderer/field/VectorFieldsRenderer.ispc module/ispc/renderer/DensityRenderer.ispc module/ispc/renderer/PathTracingRenderer.ispc module/ispc/renderer/VoxelRenderer.ispc diff --git a/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.cpp b/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.cpp deleted file mode 100644 index e2f9fadd3..000000000 --- a/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * The Blue Brain BioExplorer is a tool for scientists to extract and analyse - * scientific data from visualization - * - * This file is part of Blue Brain BioExplorer - * - * Copyright 2020-2024 Blue BrainProject / EPFL - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program 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 General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#include "PointFieldsRenderer.h" - -#include - -#include -#include - -// ospray -#include -#include -#include - -// ::ispc exports -#include "PointFieldsRenderer_ispc.h" - -using namespace core; - -namespace bioexplorer -{ -namespace rendering -{ -void PointFieldsRenderer::commit() -{ - AbstractRenderer::commit(); - - _exposure = getParam1f(COMMON_PROPERTY_EXPOSURE.name.c_str(), DEFAULT_COMMON_EXPOSURE); - _minRayStep = getParam1f(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_MIN_RAY_STEP.name.c_str(), - BIOEXPLORER_DEFAULT_RENDERER_FIELDS_MIN_RAY_STEP); - _nbRaySteps = getParam1i(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_NB_RAY_STEPS.name.c_str(), - BIOEXPLORER_DEFAULT_RENDERER_FIELDS_NB_RAY_STEPS); - _nbRayRefinementSteps = getParam1i(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_NB_RAY_REFINEMENT_STEPS.name.c_str(), - BIOEXPLORER_DEFAULT_RENDERER_FIELDS_NB_RAY_REFINEMENT_STEPS); - _alphaCorrection = getParam1f(RENDERER_PROPERTY_ALPHA_CORRECTION.name.c_str(), DEFAULT_RENDERER_ALPHA_CORRECTION); - _cutoff = getParam1f(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_CUTOFF_DISTANCE.name.c_str(), - BIOEXPLORER_DEFAULT_RENDERER_FIELDS_CUTOFF_DISTANCE); - - // Octree - _userData = getParamData(RENDERER_PROPERTY_USER_DATA); - _userDataSize = _userData ? _userData->size() : 0; - - // Transfer function - ::ospray::TransferFunction* transferFunction = - (::ospray::TransferFunction*)getParamObject(DEFAULT_COMMON_TRANSFER_FUNCTION, nullptr); - if (transferFunction) - ::ispc::PointFieldsRenderer_setTransferFunction(getIE(), transferFunction->getIE()); - - ::ispc::PointFieldsRenderer_set(getIE(), (_bgMaterial ? _bgMaterial->getIE() : nullptr), - (_userData ? (float*)_userData->data : nullptr), _userDataSize, _randomNumber, - _timestamp, spp, _lightPtr, _lightArray.size(), _minRayStep, _nbRaySteps, - _nbRayRefinementSteps, _exposure, _useHardwareRandomizer, _cutoff, _alphaCorrection, - _anaglyphEnabled, (ispc::vec3f&)_anaglyphIpdOffset); -} - -PointFieldsRenderer::PointFieldsRenderer() -{ - ispcEquivalent = ::ispc::PointFieldsRenderer_create(this); -} - -OSP_REGISTER_RENDERER(PointFieldsRenderer, point_fields); -OSP_REGISTER_MATERIAL(point_fields, core::engine::ospray::AdvancedMaterial, default); -} // namespace rendering -} // namespace bioexplorer diff --git a/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.h b/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.h deleted file mode 100644 index 64726fee7..000000000 --- a/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * The Blue Brain BioExplorer is a tool for scientists to extract and analyse - * scientific data from visualization - * - * This file is part of Blue Brain BioExplorer - * - * Copyright 2020-2024 Blue BrainProject / EPFL - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program 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 General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#pragma once - -#include - -#include - -namespace bioexplorer -{ -namespace rendering -{ -/** - * @brief The PointFieldsRenderer class allows visualization of magnetic fields created by atoms in the 3D scene. An - * Octree acceleration structure has to be built by the be_build_fields API in order to feed the renderer with the - * information needed to compute the value of the field for every point in the 3D space - */ -class PointFieldsRenderer : public ::core::engine::ospray::AbstractRenderer -{ -public: - /** - * @brief Construct a new Bio Explorer Fields Renderer object - * - */ - PointFieldsRenderer(); - - /** - * @brief Returns the class name as a string - * - * @return A string containing the name of the object in the OSPRay context - */ - std::string toString() const final { return RENDERER_POINT_FIELDS; } - - /** - * @brief Commit the changes to the OSPRay engine - * - */ - void commit() final; - -private: - bool _useHardwareRandomizer{false}; - ::ospray::uint32 _randomNumber{0}; - - double _exposure{1.f}; - - double _alphaCorrection{1.f}; - - // Octree - double _minRayStep; - ::ospray::uint32 _nbRaySteps; - ::ospray::uint32 _nbRayRefinementSteps; - - double _cutoff; - ::ospray::Ref<::ospray::Data> _userData; - ::ospray::uint64 _userDataSize; -}; -} // namespace rendering -} // namespace bioexplorer diff --git a/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.ih b/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.ih deleted file mode 100644 index fc08870c6..000000000 --- a/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.ih +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * The Blue Brain BioExplorer is a tool for scientists to extract and analyse - * scientific data from visualization - * - * This file is part of Blue Brain BioExplorer - * - * Copyright 2020-2024 Blue BrainProject / EPFL - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program 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 General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#include -#include - -struct PointFieldsRenderer -{ - AbstractRenderer super; - - const uniform TransferFunction* uniform transferFunction; - float exposure; - bool useHardwareRandomizer; - int randomNumber; - float pixelOpacity; - float minRayStep; - uint32 nbRaySteps; - uint32 nbRayRefinementSteps; - float alphaCorrection; - float distance; - float cutoff; - uniform float* uniform userData; - uint64 userDataSize; - vec3f size; - vec3f spacing; - vec3f offset; - uint64 startIndices; - uint64 startData; -}; diff --git a/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.ispc b/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.ispc deleted file mode 100644 index f79a22454..000000000 --- a/bioexplorer/backend/module/ispc/renderer/field/PointFieldsRenderer.ispc +++ /dev/null @@ -1,195 +0,0 @@ -/* - * - * The Blue Brain BioExplorer is a tool for scientists to extract and analyse - * scientific data from visualization - * - * This file is part of Blue Brain BioExplorer - * - * Copyright 2020-2024 Blue BrainProject / EPFL - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program 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 General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#include "PointFieldsRenderer.ih" - -#include - -#include -#include -#include - -float treeWalker(const uniform PointFieldsRenderer* uniform self, const vec3f& point, const varying float distance, - const varying float cutoff, const varying int32 index = 0) -{ - const uint64 begin = self->userData[self->startIndices + index * 2]; - const uint64 end = self->userData[self->startIndices + index * 2 + 1]; - const uint64 idxData = self->startData + index * FIELD_POINT_DATA_SIZE; - - if (idxData >= self->userDataSize) - return 0.f; - - if (begin == 0 && end == 0) - // Leaf - return self->userData[idxData + FIELD_POINT_OFFSET_VALUE] / (distance * distance); - - float voxelValue = 0.f; - for (uint64 childIndex = begin; childIndex <= end; ++childIndex) - { - const uint64 idx = self->startData + childIndex * FIELD_POINT_DATA_SIZE; - const vec3f childPosition = make_vec3f(self->userData[idx + FIELD_POINT_OFFSET_POSITION_X], - self->userData[idx + FIELD_POINT_OFFSET_POSITION_Y], - self->userData[idx + FIELD_POINT_OFFSET_POSITION_Z]); - const float d = length(point - childPosition); - if (d >= cutoff) - { - // Child is further than the cutoff distance, no need to evaluate events in the child node, we take the - // precomputed value of node instead - voxelValue += self->userData[idx + FIELD_POINT_OFFSET_VALUE] / (d * d); - } - else - // Dive into the child node and compute its contents - voxelValue += treeWalker(self, point, d, cutoff / 2.f, childIndex); - } - return voxelValue; -} - -inline vec3f PointFieldsRenderer_shadeRay(const uniform PointFieldsRenderer* uniform self, varying ScreenSample& sample) -{ - vec4f finalColor = make_vec4f(0.f); - const Ray ray = sample.ray; - - if (sample.sampleID.z == 0) - { - sample.alpha = 0.f; - sample.z = inf; - } - - const uniform box3f box = make_box3f(self->offset, self->offset + self->size * self->spacing); - - const float diag = max(max(self->size.x, self->size.y), self->size.z); - const float t_step = max(self->minRayStep, diag / (float)self->nbRaySteps); - - float t0, t1; - intersectBox(ray, box, t0, t1); - - const float random = - t_step * (float)(sample.sampleID.z % self->nbRayRefinementSteps) / (float)(self->nbRayRefinementSteps); - - float t = max(0.f, t0) + random; - while (t < t1 && finalColor.w < 1.f) - { - const vec3f p = ray.org + t * ray.dir; - const vec3f point = (p - self->offset) / self->spacing; - float value = treeWalker(self, point, self->distance, self->cutoff); - const float sampleOpacity = self->transferFunction->getOpacityForValue(self->transferFunction, value); - if (sampleOpacity > 0.f) - { - const vec3f sampleColor = self->transferFunction->getColorForValue(self->transferFunction, value); - compose(make_vec4f(sampleColor, sampleOpacity), finalColor, self->alphaCorrection); - } - - t += t_step; - } - - sample.alpha = finalColor.w; - return clamp(make_vec3f(finalColor) * self->exposure, make_vec3f(0.f), make_vec3f(1.f)); -} - -void PointFieldsRenderer_renderSample(uniform Renderer* uniform _self, void* uniform perFrameData, - varying ScreenSample& sample) -{ - uniform PointFieldsRenderer* uniform self = (uniform PointFieldsRenderer * uniform) _self; - sample.ray.time = self->super.timestamp; - if (self->super.anaglyphEnabled) - { - ScreenSample s = sample; - s.ray.org = s.ray.org - self->super.anaglyphIpdOffset; - const vec3f colorLeft = PointFieldsRenderer_shadeRay(self, s); - const vec3f leftAnaglyphColor = getAnaglyphLeftColor(colorLeft); - - s = sample; - s.ray.org = s.ray.org + self->super.anaglyphIpdOffset; - const vec3f colorRight = PointFieldsRenderer_shadeRay(self, s); - const vec3f rightAnaglyphColor = getAnaglyphRightColor(colorRight); - - sample.rgb = leftAnaglyphColor + rightAnaglyphColor; - } - else - sample.rgb = PointFieldsRenderer_shadeRay(self, sample); -} - -// Exports (called from C++) -export void* uniform PointFieldsRenderer_create(void* uniform cppE) -{ - uniform PointFieldsRenderer* uniform self = uniform new uniform PointFieldsRenderer; - Renderer_Constructor(&self->super.super, cppE); - self->super.super.renderSample = PointFieldsRenderer_renderSample; - return self; -} - -export void PointFieldsRenderer_set(void* uniform _self, void* uniform bgMaterial, uniform float* uniform userData, - const uniform uint64 userDataSize, const uniform int& randomNumber, - const uniform float& timestamp, const uniform int& spp, void** uniform lights, - const uniform int32 numLights, const uniform float& minRayStep, - const uniform int32& nbRaySteps, const uniform int32& nbRayRefinementSteps, - const uniform float& exposure, const uniform bool& useHardwareRandomizer, - const uniform float& cutoff, const uniform float& alphaCorrection, - const uniform bool anaglyphEnabled, const uniform vec3f& anaglyphIpdOffset) -{ - uniform PointFieldsRenderer* uniform self = (uniform PointFieldsRenderer * uniform) _self; - - // OSPRay - self->super.super.spp = spp; - - // Abstract - self->super.anaglyphEnabled = anaglyphEnabled; - self->super.anaglyphIpdOffset = anaglyphIpdOffset; - self->super.lights = (const uniform Light* uniform* uniform)lights; - self->super.numLights = numLights; - self->super.bgMaterial = (uniform AdvancedMaterial * uniform) bgMaterial; - self->super.timestamp = timestamp; - - // Fields - self->exposure = exposure; - self->useHardwareRandomizer = useHardwareRandomizer; - - self->minRayStep = minRayStep; - self->nbRaySteps = nbRaySteps; - self->nbRayRefinementSteps = nbRayRefinementSteps; - self->alphaCorrection = alphaCorrection; - - self->cutoff = cutoff; - - self->userData = userData; - self->userDataSize = userDataSize; - - self->offset = (userData ? make_vec3f(userData[OCTREE_DATA_OFFSET_X], userData[OCTREE_DATA_OFFSET_Y], - userData[OCTREE_DATA_OFFSET_Z]) - : make_vec3f(0.f)); - self->spacing = (userData ? make_vec3f(userData[OCTREE_DATA_SPACING_X], userData[OCTREE_DATA_SPACING_Y], - userData[OCTREE_DATA_SPACING_Z]) - : make_vec3f(0.f)); - self->size = (userData ? make_vec3f(userData[OCTREE_DATA_DIMENSION_X], userData[OCTREE_DATA_DIMENSION_Y], - userData[OCTREE_DATA_DIMENSION_Z]) - : make_vec3f(0.f)); - self->distance = (userData ? userData[OCTREE_DATA_INITIAL_DISTANCE] * 5.f : 0.f); // Octree size * 5 - self->startIndices = OCTREE_DATA_INDICES; - self->startData = (userData ? self->startIndices + userData[OCTREE_DATA_VALUES] : 0); -} - -export void PointFieldsRenderer_setTransferFunction(void* uniform _self, void* uniform value) -{ - uniform PointFieldsRenderer* uniform self = (uniform PointFieldsRenderer * uniform) _self; - self->transferFunction = (TransferFunction * uniform) value; -} diff --git a/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.cpp b/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.cpp deleted file mode 100644 index 4f7c0d24c..000000000 --- a/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * The Blue Brain BioExplorer is a tool for scientists to extract and analyse - * scientific data from visualization - * - * This file is part of Blue Brain BioExplorer - * - * Copyright 2020-2024 Blue BrainProject / EPFL - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program 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 General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#include "VectorFieldsRenderer.h" - -#include - -#include -#include - -// ospray -#include -#include -#include - -// ::ispc exports -#include "VectorFieldsRenderer_ispc.h" - -using namespace core; - -namespace bioexplorer -{ -namespace rendering -{ -void VectorFieldsRenderer::commit() -{ - AbstractRenderer::commit(); - - _exposure = getParam1f(COMMON_PROPERTY_EXPOSURE.name.c_str(), DEFAULT_COMMON_EXPOSURE); - _minRayStep = getParam1f(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_MIN_RAY_STEP.name.c_str(), - BIOEXPLORER_DEFAULT_RENDERER_FIELDS_MIN_RAY_STEP); - _nbRaySteps = getParam1i(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_NB_RAY_STEPS.name.c_str(), - BIOEXPLORER_DEFAULT_RENDERER_FIELDS_NB_RAY_STEPS); - _nbRayRefinementSteps = getParam1i(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_NB_RAY_REFINEMENT_STEPS.name.c_str(), - BIOEXPLORER_DEFAULT_RENDERER_FIELDS_NB_RAY_REFINEMENT_STEPS); - _alphaCorrection = getParam1f(RENDERER_PROPERTY_ALPHA_CORRECTION.name.c_str(), DEFAULT_RENDERER_ALPHA_CORRECTION); - _cutoff = getParam1f(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_CUTOFF_DISTANCE.name.c_str(), - BIOEXPLORER_DEFAULT_RENDERER_FIELDS_CUTOFF_DISTANCE); - _showVectorDirections = getParam(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_SHOW_VECTOR_DIRECTIONS.name.c_str(), - BIOEXPLORER_DEFAULT_RENDERER_FIELDS_SHOW_VECTOR_DIRECTIONS); - - // Octree - _userData = getParamData(RENDERER_PROPERTY_USER_DATA); - _userDataSize = _userData ? _userData->size() : 0; - - // Transfer function - ::ospray::TransferFunction* transferFunction = - (::ospray::TransferFunction*)getParamObject(DEFAULT_COMMON_TRANSFER_FUNCTION, nullptr); - if (transferFunction) - ::ispc::VectorFieldsRenderer_setTransferFunction(getIE(), transferFunction->getIE()); - - ::ispc::VectorFieldsRenderer_set(getIE(), (_bgMaterial ? _bgMaterial->getIE() : nullptr), - (_userData ? (float*)_userData->data : nullptr), _userDataSize, _randomNumber, - _timestamp, spp, _lightPtr, _lightArray.size(), _minRayStep, _nbRaySteps, - _nbRayRefinementSteps, _exposure, _useHardwareRandomizer, _cutoff, - _alphaCorrection, _showVectorDirections, _anaglyphEnabled, - (ispc::vec3f&)_anaglyphIpdOffset); -} - -VectorFieldsRenderer::VectorFieldsRenderer() -{ - ispcEquivalent = ::ispc::VectorFieldsRenderer_create(this); -} - -OSP_REGISTER_RENDERER(VectorFieldsRenderer, vector_fields); -OSP_REGISTER_MATERIAL(vector_fields, core::engine::ospray::AdvancedMaterial, default); -} // namespace rendering -} // namespace bioexplorer diff --git a/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.h b/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.h deleted file mode 100644 index 837f04339..000000000 --- a/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * The Blue Brain BioExplorer is a tool for scientists to extract and analyse - * scientific data from visualization - * - * This file is part of Blue Brain BioExplorer - * - * Copyright 2020-2024 Blue BrainProject / EPFL - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program 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 General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#pragma once - -#include - -#include - -namespace bioexplorer -{ -namespace rendering -{ -/** - * @brief The VectorFieldsRenderer class allows visualization of magnetic fields created by atoms in the 3D scene. An - * Octree acceleration structure has to be built by the be-build-fields API in order to feed the renderer with the - * information needed to compute the value of the field for every point in the 3D space - */ -class VectorFieldsRenderer : public ::core::engine::ospray::AbstractRenderer -{ -public: - /** - * @brief Construct a new Vector Fields Renderer object - * - */ - VectorFieldsRenderer(); - - /** - * @brief Returns the class name as a string - * - * @return A string containing the name of the object in the OSPRay context - */ - std::string toString() const final { return RENDERER_POINT_FIELDS; } - - /** - * @brief Commit the changes to the OSPRay engine - * - */ - void commit() final; - -private: - bool _useHardwareRandomizer{false}; - ::ospray::uint32 _randomNumber{0}; - - double _exposure{1.f}; - double _alphaCorrection{1.f}; - - // Octree - double _minRayStep; - ::ospray::uint32 _nbRaySteps; - ::ospray::uint32 _nbRayRefinementSteps; - - double _cutoff; - ::ospray::Ref<::ospray::Data> _userData; - ::ospray::uint64 _userDataSize; - bool _showVectorDirections{false}; -}; -} // namespace rendering -} // namespace bioexplorer diff --git a/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.ih b/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.ih deleted file mode 100644 index 394a7074e..000000000 --- a/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.ih +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * The Blue Brain BioExplorer is a tool for scientists to extract and analyse - * scientific data from visualization - * - * This file is part of Blue Brain BioExplorer - * - * Copyright 2020-2024 Blue BrainProject / EPFL - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program 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 General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#include -#include - -struct VectorFieldsRenderer -{ - AbstractRenderer super; - - const uniform TransferFunction* uniform transferFunction; - float exposure; - bool useHardwareRandomizer; - int randomNumber; - float pixelOpacity; - float minRayStep; - uint32 nbRaySteps; - uint32 nbRayRefinementSteps; - float alphaCorrection; - float distance; - float cutoff; - uniform float* uniform userData; - uint64 userDataSize; - vec3f size; - vec3f spacing; - vec3f offset; - uint64 startIndices; - uint64 startData; - bool showVectorDirections; -}; diff --git a/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.ispc b/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.ispc deleted file mode 100644 index 5ea1faed2..000000000 --- a/bioexplorer/backend/module/ispc/renderer/field/VectorFieldsRenderer.ispc +++ /dev/null @@ -1,208 +0,0 @@ -/* - * - * The Blue Brain BioExplorer is a tool for scientists to extract and analyse - * scientific data from visualization - * - * This file is part of Blue Brain BioExplorer - * - * Copyright 2020-2024 Blue BrainProject / EPFL - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program 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 General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#include "VectorFieldsRenderer.ih" - -#include -#include -#include - -vec3f treeWalker(const uniform VectorFieldsRenderer* uniform self, const vec3f& point, const varying float distance, - const varying float cutoff, const varying int32 index = 0) -{ - const uint64 begin = self->userData[self->startIndices + index * 2]; - const uint64 end = self->userData[self->startIndices + index * 2 + 1]; - const uint64 idxData = self->startData + index * FIELD_VECTOR_DATA_SIZE; - - if (idxData >= self->userDataSize) - return make_vec3f(0.f); - - if (begin == 0 && end == 0) - { - // Leaf - const vec3f vectorDirection = make_vec3f(self->userData[idxData + FIELD_VECTOR_OFFSET_DIRECTION_X], - self->userData[idxData + FIELD_VECTOR_OFFSET_DIRECTION_Y], - self->userData[idxData + FIELD_VECTOR_OFFSET_DIRECTION_Z]); - return vectorDirection / (distance * distance); - } - - vec3f voxelValue = make_vec3f(0.f); - for (unsigned int64 childIndex = begin; childIndex <= end; ++childIndex) - { - const uint64 idx = self->startData + childIndex * FIELD_VECTOR_DATA_SIZE; - const vec3f childPosition = make_vec3f(self->userData[idx + FIELD_VECTOR_OFFSET_POSITION_X], - self->userData[idx + FIELD_VECTOR_OFFSET_POSITION_Y], - self->userData[idx + FIELD_VECTOR_OFFSET_POSITION_Z]); - const float d = length(point - childPosition); - - if (d >= cutoff) - { - // Child is further than the cutoff distance, no need to evaluate events in the child node, we take the - // precomputed value of node instead - const vec3f vectorDirection = make_vec3f(self->userData[idx + FIELD_VECTOR_OFFSET_DIRECTION_X], - self->userData[idx + FIELD_VECTOR_OFFSET_DIRECTION_Y], - self->userData[idx + FIELD_VECTOR_OFFSET_DIRECTION_Z]); - voxelValue = voxelValue + vectorDirection / (d * d); - } - else - // Dive into the child node and compute its contents - voxelValue = voxelValue + treeWalker(self, point, d, cutoff / 2.f, childIndex); - } - return voxelValue; -} - -inline vec3f VectorFieldsRenderer_shadeRay(const uniform VectorFieldsRenderer* uniform self, - varying ScreenSample& sample) -{ - vec4f finalColor = make_vec4f(0.f); - const Ray ray = sample.ray; - - if (sample.sampleID.z == 0) - { - sample.alpha = 0.f; - sample.z = inf; - } - - const uniform box3f box = make_box3f(self->offset, self->offset + self->size * self->spacing); - - const float diag = max(max(self->size.x, self->size.y), self->size.z); - const float t_step = max(self->minRayStep, diag / (float)self->nbRaySteps); - - float t0, t1; - intersectBox(ray, box, t0, t1); - - const float random = - t_step * (float)(sample.sampleID.z % self->nbRayRefinementSteps) / (float)(self->nbRayRefinementSteps); - - float t = max(0.f, t0) + random; - while (t < t1 && finalColor.w < 1.f) - { - const vec3f p = ray.org + t * ray.dir; - const vec3f point = (p - self->offset) / self->spacing; - const vec3f sampleValue = treeWalker(self, point, self->distance, self->cutoff); - const float vectorLength = - clamp(length(sampleValue), self->transferFunction->valueRange.x, self->transferFunction->valueRange.y); - const float mapOpacity = self->transferFunction->getOpacityForValue(self->transferFunction, vectorLength); - if (mapOpacity > 0.f) - { - const vec3f mapColor = self->transferFunction->getColorForValue(self->transferFunction, vectorLength); - if (self->showVectorDirections) - { - const vec3f v = normalize(sampleValue); - const vec3f vectorColor = make_vec3f(0.5f + v.x * 0.5f, 0.5f + v.y * 0.5f, 0.5f + v.z * 0.5f); - compose(make_vec4f(vectorColor, mapOpacity), finalColor, self->alphaCorrection); - } - else - compose(make_vec4f(mapColor, mapOpacity), finalColor, self->alphaCorrection); - } - - t += t_step; - } - - sample.alpha = finalColor.w; - return clamp(make_vec3f(finalColor) * self->exposure, make_vec3f(0.f), make_vec3f(1.f)); -} - -void VectorFieldsRenderer_renderSample(uniform Renderer* uniform _self, void* uniform perFrameData, - varying ScreenSample& sample) -{ - uniform VectorFieldsRenderer* uniform self = (uniform VectorFieldsRenderer * uniform) _self; - sample.ray.time = self->super.timestamp; - if (self->super.anaglyphEnabled) - { - ScreenSample s = sample; - s.ray.org = s.ray.org - self->super.anaglyphIpdOffset; - const vec3f colorLeft = VectorFieldsRenderer_shadeRay(self, s); - const vec3f leftAnaglyphColor = getAnaglyphLeftColor(colorLeft); - - s = sample; - s.ray.org = s.ray.org + self->super.anaglyphIpdOffset; - const vec3f colorRight = VectorFieldsRenderer_shadeRay(self, s); - const vec3f rightAnaglyphColor = getAnaglyphRightColor(colorRight); - - sample.rgb = leftAnaglyphColor + rightAnaglyphColor; - } - else - sample.rgb = VectorFieldsRenderer_shadeRay(self, sample); -} - -// Exports (called from C++) -export void* uniform VectorFieldsRenderer_create(void* uniform cppE) -{ - uniform VectorFieldsRenderer* uniform self = uniform new uniform VectorFieldsRenderer; - Renderer_Constructor(&self->super.super, cppE); - self->super.super.renderSample = VectorFieldsRenderer_renderSample; - return self; -} - -export void VectorFieldsRenderer_set(void* uniform _self, void* uniform bgMaterial, uniform float* uniform userData, - const uniform uint64 userDataSize, const uniform int& randomNumber, - const uniform float& timestamp, const uniform int& spp, void** uniform lights, - const uniform int32 numLights, const uniform float& minRayStep, - const uniform int32& nbRaySteps, const uniform int32& nbRayRefinementSteps, - const uniform float& exposure, const uniform bool& useHardwareRandomizer, - const uniform float& cutoff, const uniform float& alphaCorrection, - const uniform bool& showVectorDirections, const uniform bool& anaglyphEnabled, - const uniform vec3f& anaglyphIpdOffset) -{ - uniform VectorFieldsRenderer* uniform self = (uniform VectorFieldsRenderer * uniform) _self; - - // OSPRay - self->super.super.spp = spp; - - // Abstract - self->super.anaglyphEnabled = anaglyphEnabled; - self->super.anaglyphIpdOffset = anaglyphIpdOffset; - self->super.lights = (const uniform Light* uniform* uniform)lights; - self->super.numLights = numLights; - self->super.bgMaterial = (uniform AdvancedMaterial * uniform) bgMaterial; - self->super.timestamp = timestamp; - - // Fields - self->exposure = exposure; - self->useHardwareRandomizer = useHardwareRandomizer; - - self->minRayStep = minRayStep; - self->nbRaySteps = nbRaySteps; - self->nbRayRefinementSteps = nbRayRefinementSteps; - self->alphaCorrection = alphaCorrection; - - self->cutoff = cutoff; - self->showVectorDirections = showVectorDirections; - - self->userData = userData; - self->userDataSize = userDataSize; - - self->offset = (userData ? make_vec3f(userData[0], userData[1], userData[2]) : make_vec3f(0.f)); - self->spacing = (userData ? make_vec3f(userData[3], userData[4], userData[5]) : make_vec3f(0.f)); - self->size = (userData ? make_vec3f(userData[6], userData[7], userData[8]) : make_vec3f(0.f)); - self->distance = (userData ? userData[9] * 5.f : 0.f); // Octree size * 5 - self->startIndices = 11; - self->startData = (userData ? self->startIndices + userData[10] : 0); -} - -export void VectorFieldsRenderer_setTransferFunction(void* uniform _self, void* uniform value) -{ - uniform VectorFieldsRenderer* uniform self = (uniform VectorFieldsRenderer * uniform) _self; - self->transferFunction = (TransferFunction * uniform) value; -} diff --git a/bioexplorer/backend/science/BioExplorerPlugin.cpp b/bioexplorer/backend/science/BioExplorerPlugin.cpp index fae675db3..48f52721e 100644 --- a/bioexplorer/backend/science/BioExplorerPlugin.cpp +++ b/bioexplorer/backend/science/BioExplorerPlugin.cpp @@ -153,33 +153,6 @@ void _addBioExplorerVoxelRenderer(Engine &engine) engine.addRendererType(RENDERER_VOXEL, properties); } -void _addBioExplorerPointFieldsRenderer(Engine &engine) -{ - PLUGIN_REGISTER_RENDERER(RENDERER_POINT_FIELDS); - PropertyMap properties; - properties.setProperty(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_MIN_RAY_STEP); - properties.setProperty(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_NB_RAY_STEPS); - properties.setProperty(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_NB_RAY_REFINEMENT_STEPS); - properties.setProperty(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_CUTOFF_DISTANCE); - properties.setProperty(RENDERER_PROPERTY_ALPHA_CORRECTION); - properties.setProperty(COMMON_PROPERTY_EXPOSURE); - engine.addRendererType(RENDERER_POINT_FIELDS, properties); -} - -void _addBioExplorerVectorFieldsRenderer(Engine &engine) -{ - PLUGIN_REGISTER_RENDERER(RENDERER_VECTOR_FIELDS); - PropertyMap properties; - properties.setProperty(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_MIN_RAY_STEP); - properties.setProperty(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_NB_RAY_STEPS); - properties.setProperty(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_NB_RAY_REFINEMENT_STEPS); - properties.setProperty(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_CUTOFF_DISTANCE); - properties.setProperty(BIOEXPLORER_RENDERER_PROPERTY_FIELDS_SHOW_VECTOR_DIRECTIONS); - properties.setProperty(RENDERER_PROPERTY_ALPHA_CORRECTION); - properties.setProperty(COMMON_PROPERTY_EXPOSURE); - engine.addRendererType(RENDERER_VECTOR_FIELDS, properties); -} - void _addBioExplorerDensityRenderer(Engine &engine) { PLUGIN_REGISTER_RENDERER(RENDERER_DENSITY); @@ -683,11 +656,6 @@ void BioExplorerPlugin::_createRenderers() auto &engine = _api->getEngine(); auto ¶ms = engine.getParametersManager().getApplicationParameters(); const auto &engineName = params.getEngine(); - if (engineName == ENGINE_OSPRAY) - { - _addBioExplorerPointFieldsRenderer(engine); - _addBioExplorerVectorFieldsRenderer(engine); - } _addBioExplorerVoxelRenderer(engine); _addBioExplorerDensityRenderer(engine); _addBioExplorerPathTracingRenderer(engine);