Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open exr #1235

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/compositing_gl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ megamol_plugin(compositing_gl

if (compositing_gl_PLUGIN_ENABLED)
# Additional sources
find_package(OpenEXR CONFIG REQUIRED)
target_link_libraries(compositing_gl PRIVATE OpenEXR::OpenEXR)
file(GLOB_RECURSE extra_header_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "3rd/*.h")
file(GLOB_RECURSE extra_source_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "3rd/*.cpp")
target_sources(compositing_gl PRIVATE ${extra_header_files} ${extra_source_files})
Expand Down
124 changes: 74 additions & 50 deletions plugins/compositing_gl/src/CompositingOutHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,18 @@
namespace megamol::compositing_gl {

bool CompositingOutHandler::updateSelectionsExternally(core::param::ParamSlot& slot) {
selectedType_ = GL_FLOAT;
recentlyChanged_ = true;
unsigned int e = availableInternalFormats_[slot.Param<core::param::EnumParam>()->Value()];
selectedInternal_ = e;
switch (e) {
case GL_RGBA32F:
case GL_RGBA16F:
case GL_RGBA8_SNORM:
selectedFormat_ = GL_RGBA;
break;
case GL_RGB32F:
case GL_RGB16F:
case GL_RGB8_SNORM:
selectedFormat_ = GL_RGB;
break;
case GL_RG32F:
case GL_RG16F:
case GL_RG8_SNORM:
selectedFormat_ = GL_RG;
break;
case GL_R32F:
case GL_R16F:
case GL_R8_SNORM:
selectedFormat_ = GL_RED;
break;
}
updateSelections(slot);
//external update
return externalUpdateFunc_();
}

bool CompositingOutHandler::updateSelections(core::param::ParamSlot& slot) {
selectedType_ = GL_FLOAT;
recentlyChanged_ = true;
unsigned int e = availableInternalFormats_[slot.Param<core::param::EnumParam>()->Value()];
selectedInternal_ = e;
switch (e) {
case GL_RGBA32F:
case GL_RGBA16F:
case GL_RGBA8_SNORM:
selectedFormat_ = GL_RGBA;
return true;
case GL_RGB32F:
case GL_RGB16F:
case GL_RGB8_SNORM:
selectedFormat_ = GL_RGB;
return true;
case GL_RG32F:
case GL_RG16F:
case GL_RG8_SNORM:
selectedFormat_ = GL_RG;
return true;
case GL_R32F:
case GL_R16F:
case GL_R8_SNORM:
selectedFormat_ = GL_RED;
return true;
}
return false;
selectedFormat_ = enumToFormat(e);
selectedType_ = enumToType(e);
return (e != 0 && selectedFormat_ != 0 && selectedType_ != 0);
}

GLenum CompositingOutHandler::getInternalFormat() {
Expand Down Expand Up @@ -95,6 +49,7 @@ CompositingOutHandler::CompositingOutHandler(std::string defineName, std::vector
}
formatSlot_.SetParameter(out_tex_formats);
formatSlot_.SetUpdateCallback(this, &CompositingOutHandler::updateSelections);
updateSelections(formatSlot_);
}

/**
Expand All @@ -114,6 +69,7 @@ CompositingOutHandler::CompositingOutHandler(std::string defineName, std::vector
}
formatSlot_.SetParameter(out_tex_formats);
formatSlot_.SetUpdateCallback(this, &CompositingOutHandler::updateSelectionsExternally);
updateSelections(formatSlot_);
}

megamol::core::AbstractSlot* CompositingOutHandler::getFormatSelectorSlot() {
Expand All @@ -128,24 +84,32 @@ std::string CompositingOutHandler::enumToString(unsigned int e) {
return "GL_RGBA16F";
case GL_RGBA8_SNORM:
return "GL_RGBA8_SNORM";
case GL_RGBA8:
return "GL_RGBA8";
case GL_RGB32F:
return "GL_RGB32F";
case GL_RGB16F:
return "GL_RGB16F";
case GL_RGB8_SNORM:
return "GL_RGB8_SNORM";
case GL_RGB8:
return "GL_RGB8";
case GL_RG32F:
return "GL_RG32F";
case GL_RG16F:
return "GL_RG16F";
case GL_RG8_SNORM:
return "GL_RG8_SNORM";
case GL_RG8:
return "GL_RG8";
case GL_R32F:
return "GL_R32F";
case GL_R16F:
return "GL_R16F";
case GL_R8_SNORM:
return "GL_R8_SNORM";
case GL_R8:
return "GL_R8";
}
}

Expand All @@ -157,27 +121,87 @@ std::string CompositingOutHandler::enumToDefinition(unsigned int e) {
return "rgba16f";
case GL_RGBA8_SNORM:
return "rgba8_snorm";
case GL_RGBA8:
return "rgba8";
case GL_RGB32F:
return "rgb32f";
case GL_RGB16F:
return "rgb16f";
case GL_RGB8_SNORM:
return "rgb8_snorm";
case GL_RGB8:
return "rgb8";
case GL_RG32F:
return "rg32f";
case GL_RG16F:
return "rg16f";
case GL_RG8_SNORM:
return "rg8_snorm";
case GL_RG8:
return "rg8";
case GL_R32F:
return "r32f";
case GL_R16F:
return "r16f";
case GL_R8_SNORM:
return "r8_snorm";
case GL_R8:
return "r8";
}
}

unsigned int CompositingOutHandler::enumToFormat(unsigned int e) {
switch (e) {
case GL_RGBA32F:
case GL_RGBA16F:
case GL_RGBA8_SNORM:
case GL_RGBA8:
return GL_RGBA;
case GL_RGB32F:
case GL_RGB16F:
case GL_RGB8_SNORM:
case GL_RGB8:
return GL_RGB;
case GL_RG32F:
case GL_RG16F:
case GL_RG8_SNORM:
case GL_RG8:
return GL_RG;
case GL_R32F:
case GL_R16F:
case GL_R8_SNORM:
case GL_R8:
return GL_RED;
default:
return 0;
}
}

unsigned int CompositingOutHandler::enumToType(unsigned int e) {
switch (e) {
case GL_RGBA32F:
case GL_RGB32F:
case GL_RG32F:
case GL_R32F:
return GL_FLOAT;
case GL_RGBA16F:
case GL_RGB16F:
case GL_RG16F:
case GL_R16F:
return GL_HALF_FLOAT;
case GL_RGBA8_SNORM:
case GL_RGB8_SNORM:
case GL_RG8_SNORM:
case GL_R8_SNORM:
case GL_RGBA8:
case GL_RGB8:
case GL_RG8:
case GL_R8:
return GL_INT;
default:
return 0;
}
}

std::unique_ptr<msf::ShaderFactoryOptionsOpenGL> CompositingOutHandler::addDefinitions(
msf::ShaderFactoryOptionsOpenGL shdr_options) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/compositing_gl/src/CompositingOutHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class CompositingOutHandler {

std::string enumToString(unsigned int e);
std::string enumToDefinition(unsigned int e);
unsigned int enumToType(unsigned int e);
unsigned int enumToFormat(unsigned int e);

/**
* \brief Updates currently chosen formats. Sets recently changed to true. Does not recompile shaders.
Expand Down
2 changes: 1 addition & 1 deletion plugins/compositing_gl/src/DepthDarkening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ megamol::compositing_gl::DepthDarkening::DepthDarkening()
, intermediateTex_(nullptr)
, intermediateTex2_(nullptr)
, outputTex_(nullptr)
, outFormatHandler_("OUTFORMAT", {GL_RGBA8_SNORM, GL_RGBA16F, GL_RGBA32F},
, outFormatHandler_("OUTFORMAT", {GL_RGBA8, GL_RGBA16F, GL_RGBA32F},
std::function<bool()>(std::bind(&DepthDarkening::textureFormatUpdate, this))) {

outputTexSlot_.SetCallback(CallTexture2D::ClassName(), CallTexture2D::FunctionName(CallTexture2D::CallGetData),
Expand Down
Loading
Loading