Skip to content

Commit

Permalink
Merge pull request #681 from tobiasrau/osp2x
Browse files Browse the repository at this point in the history
OSPRay 2.x integration
  • Loading branch information
reinago authored Feb 1, 2021
2 parents 9f99364 + 591430d commit 52bfffc
Show file tree
Hide file tree
Showing 38 changed files with 1,669 additions and 2,005 deletions.
5 changes: 3 additions & 2 deletions plugins/OSPRay_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if(BUILD_${EXPORT_NAME}_PLUGIN)
set(DEP_LIST "${DEP_LIST};BUILD_OSPRAY_PLUGIN BUILD_CORE BUILD_GEOMETRY_CALLS_PLUGIN BUILD_MMSTD_DATATOOLS_PLUGIN BUILD_PROTEIN_CALLS_PLUGIN BUILD_MESH_PLUGIN" CACHE INTERNAL "")

find_package(ospray CONFIG REQUIRED)
find_package(rkcommon CONFIG REQUIRED)

file(GLOB_RECURSE public_header_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "include/*.h")
file(GLOB_RECURSE source_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "src/*.cpp")
Expand All @@ -23,10 +24,10 @@ if(BUILD_${EXPORT_NAME}_PLUGIN)
# Target definition
add_library(${PROJECT_NAME} STATIC ${public_header_files} ${header_files} ${shader_files} ${source_files})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${EXPORT_NAME}_EXPORTS)
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> "include" "src" ${OSPRAY_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> "include" "src")
target_link_libraries(${PROJECT_NAME}
PRIVATE core geometry_calls mmstd_datatools protein_calls mesh
PUBLIC ${OSPRAY_LIBRARIES})
PUBLIC ospray::ospray ospray::ospray_module_ispc rkcommon::rkcommon)

# Installation rules for generated files
#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION "include")
Expand Down
130 changes: 77 additions & 53 deletions plugins/OSPRay_plugin/include/OSPRay_plugin/CallOSPRayMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "mmcore/factories/CallAutoDescription.h"
#include "mmcore/Call.h"
#include <array>
#include <variant>


namespace megamol {
namespace ospray {
Expand All @@ -27,62 +29,84 @@ enum materialTypeEnum {
VELVET
};


// OBJMaterial/ScivisMaterial
struct objMaterial {
std::array<float, 3> Kd;
std::array<float, 3> Ks;
float Ns = 0.0f;
float d = 0.0f;
std::array<float, 3> Tf;
};

// LUMINOUS
struct luminousMaterial {
std::array<float, 3> lumColor;
float lumIntensity = 0.0f;
float lumTransparency = 0.0f;
};

// VELVET
struct velvetMaterial {
std::array<float, 3> velvetReflectance;
float velvetBackScattering = 0.0f;
std::array<float, 3> velvetHorizonScatteringColor;
float velvetHorizonScatteringFallOff = 0.0f;
};

// MATTE
struct matteMaterial {
std::array<float, 3> matteReflectance;
};

// METAL
struct metalMaterial {
std::array<float, 3> metalReflectance;
std::array<float, 3> metalEta;
std::array<float, 3> metalK;
float metalRoughness = 0.0f;
};

// METALLICPAINT
struct metallicpaintMaterial {
std::array<float, 3> metallicShadeColor;
std::array<float, 3> metallicGlitterColor;
float metallicGlitterSpread = 0.0f;
float metallicEta = 0.0f;
};

// GLASS
struct glassMaterial {
float glassEtaInside = 0.0f;
float glassEtaOutside = 0.0f;
std::array<float, 3> glassAttenuationColorInside;
std::array<float, 3> glassAttenuationColorOutside;
float glassAttenuationDistance = 0.0f;
};

// THINGLASS
struct thinglassMaterial {
std::array<float, 3> thinglassTransmission;
float thinglassEta = 0.0f;
float thinglassThickness = 0.0f;
};

// PLASTIC
struct plasticMaterial {
std::array<float, 3> plasticPigmentColor;
float plasticEta = 0.0f;
float plasticRoughness = 0.0f;
float plasticThickness = 0.0f;
};


struct OSPRayMaterialContainer {
materialTypeEnum materialType = materialTypeEnum::OBJMATERIAL;

// OBJMaterial/ScivisMaterial
std::array<float,3> Kd;
std::array<float,3> Ks;
float Ns = 0.0f;
float d = 0.0f;
std::array<float,3> Tf;

// LUMINOUS
std::array<float,3> lumColor;
float lumIntensity = 0.0f;
float lumTransparency = 0.0f;

// VELVET
std::array<float,3> velvetReflectance;
float velvetBackScattering = 0.0f;
std::array<float,3> velvetHorizonScatteringColor;
float velvetHorizonScatteringFallOff = 0.0f;

// MATTE
std::array<float,3> matteReflectance;

// METAL
std::array<float,3> metalReflectance;
std::array<float,3> metalEta;
std::array<float,3> metalK;
float metalRoughness = 0.0f;

// METALLICPAINT
std::array<float, 3> metallicShadeColor;
std::array<float, 3> metallicGlitterColor;
float metallicGlitterSpread = 0.0f;
float metallicEta = 0.0f;

// GLASS
float glassEtaInside = 0.0f;
float glassEtaOutside = 0.0f;
std::array<float, 3> glassAttenuationColorInside;
std::array<float, 3> glassAttenuationColorOutside;
float glassAttenuationDistance = 0.0f;

//THINGLASS
std::array<float, 3> thinglassTransmission;
float thinglassEta = 0.0f;
float thinglassThickness = 0.0f;

// PLASTIC
std::array<float, 3> plasticPigmentColor;
float plasticEta = 0.0f;
float plasticRoughness = 0.0f;
float plasticThickness = 0.0f;

std::variant<objMaterial, luminousMaterial, velvetMaterial, matteMaterial, metalMaterial, metallicpaintMaterial,
glassMaterial, thinglassMaterial, plasticMaterial> material;
bool isValid = false;

};


Expand Down Expand Up @@ -160,4 +184,4 @@ typedef core::factories::CallAutoDescription<CallOSPRayMaterial> CallOSPRayMater


} // namespace ospray
} // namespace megamol
} // namespace megamol
128 changes: 63 additions & 65 deletions plugins/OSPRay_plugin/include/OSPRay_plugin/CallOSPRayStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ enum structureTypeEnum { UNINITIALIZED, GEOMETRY, VOLUME, OSPRAY_API_STRUCTURES
enum geometryTypeEnum {
SPHERES,
NHSPHERES,
TRIANGLES,
STREAMLINES,
MESH,
LINES,
CURVES,
CYLINDERS,
QUADS
TEST
};

enum volumeTypeEnum { STRUCTUREDVOLUME, BLOCKBRICKEDVOLUME, GHOSTBLOCKBRICKEDVOLUME };
Expand All @@ -48,93 +49,90 @@ static uint32_t voxelDataTypeOSP[] = {2500, 3000, 3500, 6000, 7000};
// DOUBLE = OSP_DOUBLE
//};


class OSPRayStructureContainer {
public:
structureTypeEnum type;
std::shared_ptr<OSPRayMaterialContainer> materialContainer;
geometryTypeEnum geometryType;
volumeTypeEnum volumeType;
volumeRepresentationType volRepType;

std::shared_ptr<OSPRayTransformationContainer> transformationContainer = nullptr;
bool transformationChanged = false;

struct sphereStructure {
std::shared_ptr<std::vector<float>> vertexData;
std::shared_ptr<std::vector<float>> colorData;
std::shared_ptr<std::vector<unsigned int>> indexData;
void* voxels;
std::shared_ptr<std::vector<float>> gridOrigin;
std::shared_ptr<std::vector<float>> gridSpacing;
std::shared_ptr<std::vector<int>> dimensions;
std::shared_ptr<std::vector<float>> clippingBoxLower;
std::shared_ptr<std::vector<float>> clippingBoxUpper;
std::shared_ptr<std::vector<float>> isoValue;
std::shared_ptr<std::vector<float>> sliceData;
std::shared_ptr<std::vector<float>> clipPlaneData;
std::shared_ptr<std::vector<float>> clipPlaneColor;

const void* raw;
std::shared_ptr<void const*> raw2;
unsigned int vertexCount;
unsigned int vertexLength;
unsigned int dataStride;
unsigned int colorLength;
int colorType;
long long int partCount;
float globalRadius;
core::moldyn::SimpleSphericalParticles::ColourDataType mmpldColor =
core::moldyn::SimpleSphericalParticles::ColourDataType::COLDATA_NONE;
};

struct structuredVolumeStructure {
std::shared_ptr<std::vector<float>> tfRGB;
std::shared_ptr<std::vector<float>> tfA;
std::shared_ptr<std::pair<float, float>> valueRange;
std::shared_ptr<std::vector<float>> xData;
std::shared_ptr<std::vector<float>> yData;
std::shared_ptr<std::vector<float>> zData;
std::shared_ptr<megamol::core::BoundingBoxes> boundingBox; //< TODO data duplicate to extent container ... however,
// this makes access more concise in the renderer

std::pair<std::vector<void*>,structureTypeEnum> ospStructures;
std::array<float, 2> valueRange;

const void* voxels;
std::array<float, 3> gridOrigin;
std::array<float, 3> gridSpacing;
std::array<int, 3> dimensions;
std::array<float, 3> clippingBoxLower;
std::array<float, 3> clippingBoxUpper;
float isoValue;
bool clippingBoxActive;
volumeRepresentationType volRepType;
voxelDataType voxelDType;
unsigned int voxelCount;
unsigned int maxDim;
};

struct meshStrucutre {
std::shared_ptr<mesh::MeshDataAccessCollection> mesh;
std::shared_ptr<mesh::ImageDataAccessCollection> mesh_textures;
};

unsigned int voxelCount;
unsigned int maxDim;
unsigned int vertexCount;
struct apiStructure {
std::pair<std::vector<void*>, structureTypeEnum> ospStructures;
};

struct curveStructure {
std::shared_ptr<mesh::MeshDataAccessCollection> mesh;

std::shared_ptr<std::vector<float>> vertexData;
std::shared_ptr<std::vector<float>> colorData;
std::shared_ptr<std::vector<unsigned int>> indexData;
unsigned int vertexLength;
unsigned int vertexStride;
unsigned int dataStride;
unsigned int colorLength;
unsigned int colorStride;
int colorType;
long long int partCount;
float globalRadius;
core::moldyn::SimpleSphericalParticles::ColourDataType mmpldColor;
};

bool clippingBoxActive;
struct OSPRayStructureContainer {

structureTypeEnum type = structureTypeEnum::UNINITIALIZED;
std::shared_ptr<OSPRayMaterialContainer> materialContainer;

geometryTypeEnum geometryType;
volumeTypeEnum volumeType;

std::shared_ptr<OSPRayTransformationContainer> transformationContainer = nullptr;
bool transformationChanged = false;
bool dataChanged;
bool materialChanged;
bool parameterChanged;
bool isValid;
bool smooth; //< valid for lines

// stuff that should be in OSPRayVolumetricStructure: AbstractOSPRayStructure
// TODO: both actually.
bool useMIP;
bool useGradient;
bool usePreIntegration;
bool useAdaptiveSampling;
float adaptiveFactor;
float adaptiveMaxRate;

voxelDataType voxelDType;

float samplingRate;
float aoThreshold;
float aoRayOffsetFactor;
bool isValid = false;

OSPRayStructureContainer();
~OSPRayStructureContainer();
std::variant<sphereStructure, structuredVolumeStructure, meshStrucutre, apiStructure, curveStructure> structure;
};


class OSPRayExtendContainer {
public:
std::shared_ptr<megamol::core::BoundingBoxes_2> boundingBox;
unsigned int timeFramesCount;
bool isValid;
bool isValid = false;

OSPRayExtendContainer();
~OSPRayExtendContainer();
OSPRayExtendContainer() = default;
~OSPRayExtendContainer() = default;
};


Expand Down
Loading

0 comments on commit 52bfffc

Please sign in to comment.