Skip to content

Commit

Permalink
Set SRGB Skip decode on rendered texture
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey committed Jul 26, 2024
1 parent 179f0e6 commit 287915c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
7 changes: 6 additions & 1 deletion src/plugins/minimal_scene/EngineToQtInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ GLuint EngineToQtInterface::TextureId(gz::rendering::CameraPtr &_camera)
{
if (!this->NeedsFallback(_camera))
{
return _camera->RenderTextureGLId();
auto textureId = _camera->RenderTextureGLId();

QOpenGLFunctions *glFuncs = this->dataPtr->glContext->functions();
glFuncs->glBindTexture(GL_TEXTURE_2D, textureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
return textureId;
}
else
{
Expand Down
6 changes: 0 additions & 6 deletions src/plugins/minimal_scene/MinimalScene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1545,12 +1545,6 @@ void MinimalScene::LoadConfig(const tinyxml2::XMLElement *_pluginElem)
}

renderWindow->SetEngineName(cmdRenderEngine);
// there is a problem with displaying ogre2 render textures that are in
// sRGB format. Workaround for now is to apply gamma correction
// manually.
// There maybe a better way to solve the problem by making OpenGL calls.
if (cmdRenderEngine == std::string("ogre2"))
this->PluginItem()->setProperty("gammaCorrect", true);
}

/////////////////////////////////////////////////
Expand Down
15 changes: 0 additions & 15 deletions src/plugins/minimal_scene/MinimalScene.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ Rectangle {
Layout.minimumHeight: 200
anchors.fill: parent

/**
* True to enable gamma correction
*/
property bool gammaCorrect: false

/**
* Get mouse position on 3D widget
*/
Expand All @@ -54,16 +49,6 @@ Rectangle {
visible: MinimalScene.loadingError.length == 0
}

/*
* Gamma correction for sRGB output. Enabled when engine is set to ogre2
*/
GammaAdjust {
anchors.fill: renderWindow
source: renderWindow
gamma: 2.4
enabled: gammaCorrect
visible: gammaCorrect
}

onParentChanged: {
if (undefined === parent)
Expand Down

0 comments on commit 287915c

Please sign in to comment.