126 OCIO::DisplayTransformRcPtr transform = OCIO::DisplayTransform::Create();
129 transform->setView(
view);
148 transform->setLooksOverride(
look);
149 transform->setLooksOverrideEnabled(
true);
152 OCIO::GroupTransformRcPtr approximateTransform = OCIO::GroupTransform::Create();
156 float exposureGain = powf(2.0f,
exposure);
158 const qreal minRange = 0.001;
166 const float newMin[] = { 0.0f, 0.0f, 0.0f, 0.0f };
167 const float newMax[] = { exposureGain, exposureGain, exposureGain, 1.0f };
171 OCIO::MatrixTransform::Fit(m44, offset4, oldMin, oldMax, newMin, newMax);
172 OCIO::MatrixTransformRcPtr mtx = OCIO::MatrixTransform::Create();
173 mtx->setValue(m44, offset4);
174 transform->setLinearCC(mtx);
177 approximateTransform->push_back(mtx);
223 config->getDefaultLumaCoefs(lumacoef);
226 OCIO::MatrixTransform::View(m44, offset, channelHot, lumacoef);
227 OCIO::MatrixTransformRcPtr swizzleTransform = OCIO::MatrixTransform::Create();
228 swizzleTransform->setValue(m44, offset);
229 transform->setChannelView(swizzleTransform);
234 float exponent = 1.0f/std::max(1e-6f,
static_cast<float>(
gamma));
235 const float exponent4f[] = { exponent, exponent, exponent, exponent };
236 OCIO::ExponentTransformRcPtr expTransform = OCIO::ExponentTransform::Create();
237 expTransform->setValue(exponent4f);
238 transform->setDisplayCC(expTransform);
241 approximateTransform->push_back(expTransform);
247 }
catch (OCIO::Exception &e) {
249 errKrita <<
"OCIO exception while parsing the current context:" << e.what();
259 warnKrita <<
"OCIO inverted matrix does not exist!";
269 QOpenGLContext *ctx = QOpenGLContext::currentContext();
272 if (ctx->format().majorVersion() >= 3) {
273 QOpenGLExtraFunctions *f = ctx->extraFunctions();
277 }
else if (ctx->hasExtension(
"GL_OES_texture_half_float") && ctx->hasExtension(
"GL_EXT_color_buffer_half_float")
278 && ctx->hasExtension(
"GL_OES_texture_half_float_linear")) {
279 QOpenGLExtraFunctions *f = ctx->extraFunctions();
284 dbgKrita <<
"OcioDisplayFilter::updateShader (2020)"
285 <<
"OpenGL ES v2+ support detected but no OES_texture_half_float,"
286 "GL_EXT_color_buffer_half_float or GL_OES_texture_half_float_linear were found";
289#if defined(QT_OPENGL_3)
291 QOpenGLFunctions_3_2_Core *f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_2_Core>();
300#if defined(QT_OPENGL_3)
301#if defined(Q_OS_MAC) && defined(QT_OPENGL_3_2)
302 QOpenGLFunctions_3_2_Core *f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_2_Core>();
304 QOpenGLFunctions_3_0 *f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_0>();
311#if !defined(QT_OPENGL_ES_2)
312 QOpenGLFunctions_2_0 *f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
331 qWarning() <<
"Failed to get valid OpenGL functions for OcioDisplayFilter!";
335 f->initializeOpenGLFunctions();
337 bool shouldRecompileShader =
false;
345 int num3Dentries = 3 * lut3DEdgeSize * lut3DEdgeSize * lut3DEdgeSize;
346 m_lut3d.fill(0.0, num3Dentries);
348 f->glActiveTexture(GL_TEXTURE1);
351 f->glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
352 f->glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
356 f->glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB16F_ARB,
357 lut3DEdgeSize, lut3DEdgeSize, lut3DEdgeSize,
358 0, GL_RGB, GL_FLOAT, &
m_lut3d.constData()[0]);
362 OCIO::GpuShaderDesc shaderDesc;
365 shaderDesc.setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_3);
368 shaderDesc.setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_0);
372 shaderDesc.setFunctionName(
"OCIODisplay");
373 shaderDesc.setLut3DEdgeLen(lut3DEdgeSize);
377 QString lut3dCacheID = QString::fromLatin1(
m_processor->getGpuLut3DCacheID(shaderDesc));
384 f->glTexSubImage3D(GL_TEXTURE_3D, 0,
386 lut3DEdgeSize, lut3DEdgeSize, lut3DEdgeSize,
387 GL_RGB, GL_FLOAT, &
m_lut3d[0]);
391 QString shaderCacheID = QString::fromLatin1(
m_processor->getGpuShaderTextCacheID(shaderDesc));
397 std::ostringstream os;
398 os <<
m_processor->getGpuShaderText(shaderDesc) <<
"\n";
400 m_program = QString::fromLatin1(os.str().c_str());
401 shouldRecompileShader =
true;
405 return shouldRecompileShader;