Commit 855a41a7 authored by Halla Rempt's avatar Halla Rempt
Browse files

Remove the old exposure shader

It's replaced by the opencolorio shader. Weirdly enough, it doesn't
seem to do anything yet.
parent e4990925
install( FILES
hdr_exposure.frag
linear_gradient.frag
bilinear_gradient.frag
radial_gradient.frag
......
/*
* Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
uniform sampler2D image;
uniform vec4 exposure;
uniform vec4 gamma;
const vec4 grey = vec4(84.66 / 255.0, 84.66 / 255.0, 84.66 / 255.0, 1.0);
void main(void)
{
vec4 colour = texture2D(image, gl_TexCoord[0].st);
colour *= exposure;
colour = pow(colour, gamma);
colour *= grey;
gl_FragColor = colour;
}
......@@ -26,7 +26,8 @@
#include <sstream>
#include <kdebug.h>
\
#include <kis_config.h>
#ifdef HAVE_OPENGL
static const int LUT3D_EDGE_SIZE = 32;
......@@ -224,6 +225,11 @@ void OcioDisplayFilter::updateProcessor()
#ifdef HAVE_OPENGL
// check whether we are allowed to use shaders -- though that should
// work for everyone these days
KisConfig cfg;
if (!cfg.useOpenGLShaders()) return;
if (m_lut3d.size() == 0) {
glGenTextures(1, &m_lut3dTexID);
......
......@@ -197,7 +197,6 @@ if(HAVE_OPENGL)
opengl/kis_opengl_fragment_shader.cpp
opengl/kis_opengl_vertex_shader.cpp
opengl/kis_opengl_program.cpp
opengl/kis_opengl_hdr_exposure_program.cpp
opengl/kis_opengl_gradient_program.cpp
)
endif(HAVE_GLEW)
......
......@@ -252,15 +252,6 @@ void KisOpenGLCanvas2::drawImage()
QRect wr = widgetRectInImagePixels.toAlignedRect() &
m_d->openGLImageTextures->storedImageBounds();
if (image->colorSpace()->hasHighDynamicRange()) {
if (m_d->openGLImageTextures->usingHDRExposureProgram()) {
m_d->openGLImageTextures->activateHDRExposureProgram();
}
m_d->openGLImageTextures->setHDRExposure(canvas()->view()->resourceProvider()->HDRExposure(),
canvas()->view()->resourceProvider()->HDRGamma());
}
makeCurrent();
int firstColumn = m_d->openGLImageTextures->xToCol(wr.left());
......
/*
* Copyright (c) 2007 Adrian Page <adrian@pagenet.plus.com>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "opengl/kis_opengl_hdr_exposure_program.h"
#include <cmath>
#include "opengl/kis_opengl.h"
#include "opengl/kis_opengl_fragment_shader.h"
KisOpenGLHDRExposureProgram::KisOpenGLHDRExposureProgram()
{
m_exposure = 0.0;
m_gamma = 2.2;
createProgram();
}
void KisOpenGLHDRExposureProgram::setExposure(float exposure)
{
m_exposure = exposure;
if (active()) {
setExposureUniformVariable();
}
}
void KisOpenGLHDRExposureProgram::setGamma(float gamma)
{
m_gamma = gamma;
if (active()) {
setGammaUniformVariable();
}
}
void KisOpenGLHDRExposureProgram::setExposureUniformVariable()
{
Q_ASSERT(active());
float exposure = pow(2, m_exposure + 2.47393);
setUniformVariable("exposure", exposure, exposure, exposure, 1.0);
}
void KisOpenGLHDRExposureProgram::setGammaUniformVariable()
{
Q_ASSERT(active());
float gamma = 1.0 / m_gamma;
setUniformVariable("gamma", gamma, gamma, gamma, 1.0);
}
void KisOpenGLHDRExposureProgram::activate()
{
KisOpenGLProgram::activate();
setExposureUniformVariable();
setGammaUniformVariable();
setUniformVariable("image", ImageTextureUnit);
}
void KisOpenGLHDRExposureProgram::createProgram()
{
KisOpenGLFragmentShader *shader = KisOpenGLFragmentShader::createFromSourceCodeFile("hdr_exposure.frag");
Q_CHECK_PTR(shader);
if (shader && shader->isValid()) {
attachShader(*shader);
link();
}
delete shader;
}
/*
* Copyright (c) 2007 Adrian Page <adrian@pagenet.plus.com>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_OPENGL_HDR_EXPOSURE_PROGRAM_H_
#define KIS_OPENGL_HDR_EXPOSURE_PROGRAM_H_
#include <GL/glew.h>
#include "krita_export.h"
#include "opengl/kis_opengl_program.h"
/**
* An OpenGL program for displaying high dynamic range images using an exposure control.
*/
class KRITAUI_EXPORT KisOpenGLHDRExposureProgram : public KisOpenGLProgram
{
public:
KisOpenGLHDRExposureProgram();
/**
* Set the exposure. A typical range of values is -10 to 10.
* @param exposure the exposure value
*/
void setExposure(float exposure);
/**
* @brief setGamma set the gamma correction
* @param gamma in a range from 0 to 5; 2.2 is "standard"
*/
void setGamma(float gamma);
/**
* Activate the program ready for rendering.
*/
virtual void activate();
private:
virtual void createProgram();
void setExposureUniformVariable();
void setGammaUniformVariable();
static const GLint ImageTextureUnit = 0;
static const GLint ImageTextureUnitEnum = GL_TEXTURE0 + ImageTextureUnit;
GLfloat m_exposure;
GLfloat m_gamma;
};
#endif // KIS_OPENGL_HDR_EXPOSURE_PROGRAM_H_
......@@ -33,10 +33,6 @@
#include <half.h>
#endif
#ifdef HAVE_GLEW
#include "opengl/kis_opengl_hdr_exposure_program.h"
#endif
#ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F
#endif
......@@ -48,17 +44,11 @@
KisOpenGLImageTextures::ImageTexturesMap KisOpenGLImageTextures::imageTexturesMap;
#ifdef HAVE_GLEW
KisOpenGLHDRExposureProgram *KisOpenGLImageTextures::HDRExposureProgram = 0;
#endif
KisOpenGLImageTextures::KisOpenGLImageTextures()
: m_displayFilter(0)
{
m_image = 0;
m_monitorProfile = 0;
m_exposure = 0.0;
m_gamma = 2.2;
}
KisOpenGLImageTextures::KisOpenGLImageTextures(KisImageWSP image, KoColorProfile *monitorProfile)
......@@ -66,8 +56,6 @@ KisOpenGLImageTextures::KisOpenGLImageTextures(KisImageWSP image, KoColorProfile
{
m_image = image;
m_monitorProfile = monitorProfile;
m_exposure = 0;
m_gamma = 2.2;
KisOpenGL::makeContextCurrent();
......@@ -103,7 +91,6 @@ bool KisOpenGLImageTextures::imageCanShareTextures(KisImageWSP image)
KisOpenGLImageTexturesSP KisOpenGLImageTextures::getImageTextures(KisImageWSP image, KoColorProfile *monitorProfile, KoColorConversionTransformation::Intent renderingIntent)
{
KisOpenGL::makeContextCurrent();
createHDRExposureProgramIfCan();
if (imageCanShareTextures(image)) {
ImageTexturesMap::iterator it = imageTexturesMap.find(image);
......@@ -315,51 +302,6 @@ void KisOpenGLImageTextures::setMonitorProfile(const KoColorProfile *monitorProf
void KisOpenGLImageTextures::setDisplayFilter(KisDisplayFilter *displayFilter)
{
m_displayFilter = displayFilter;
setHDRExposure(displayFilter->exposure, displayFilter->gamma);
}
void KisOpenGLImageTextures::setHDRExposure(float exposure, float gamma)
{
if (exposure != m_exposure || gamma != m_gamma) {
m_exposure = exposure;
m_gamma = gamma;
if (m_image->colorSpace()->hasHighDynamicRange()) {
#ifdef HAVE_GLEW
if (m_usingHDRExposureProgram) {
HDRExposureProgram->setExposure(exposure);
HDRExposureProgram->setGamma(gamma);
}
else {
#endif
#ifdef __GNUC__
#warning "FIXME: Move this setOverrideCursor to a higher level"
#else
#pragma WARNING( "FIXME: Move this setOverrideCursor to a higher level") { )
#endif
QApplication::setOverrideCursor(Qt::WaitCursor);
KisOpenGLUpdateInfoSP info = updateCache(m_image->bounds());
recalculateCache(info);
QApplication::restoreOverrideCursor();
#ifdef HAVE_GLEW
}
#endif
}
}
}
void KisOpenGLImageTextures::createHDRExposureProgramIfCan()
{
KisConfig cfg;
if (!cfg.useOpenGLShaders()) return;
#ifdef HAVE_GLEW
if (!HDRExposureProgram && KisOpenGL::hasShadingLanguage()) {
dbgUI << "Creating shared HDR exposure program";
HDRExposureProgram = new KisOpenGLHDRExposureProgram();
Q_CHECK_PTR(HDRExposureProgram);
}
#endif
}
bool KisOpenGLImageTextures::usingHDRExposureProgram() const
......@@ -374,8 +316,8 @@ bool KisOpenGLImageTextures::usingHDRExposureProgram() const
void KisOpenGLImageTextures::activateHDRExposureProgram()
{
#ifdef HAVE_GLEW
if (m_usingHDRExposureProgram) {
HDRExposureProgram->activate();
if (m_usingHDRExposureProgram && m_displayFilter && m_displayFilter->program()) {
glUseProgram(m_displayFilter->program());
}
#endif
}
......@@ -383,8 +325,8 @@ void KisOpenGLImageTextures::activateHDRExposureProgram()
void KisOpenGLImageTextures::deactivateHDRExposureProgram()
{
#ifdef HAVE_GLEW
if (m_usingHDRExposureProgram) {
KisOpenGLProgram::deactivate();
if (m_usingHDRExposureProgram && m_displayFilter && m_displayFilter->program()) {
glUseProgram(0);
}
#endif
}
......@@ -480,10 +422,7 @@ bool KisOpenGLImageTextures::imageCanUseHDRExposureProgram(KisImageWSP image)
KisConfig cfg;
if (!image->colorSpace()->hasHighDynamicRange() ||
!cfg.useOpenGLShaders() ||
!HDRExposureProgram ||
!HDRExposureProgram->isValid()) {
!cfg.useOpenGLShaders()) {
return false;
}
......
......@@ -82,14 +82,6 @@ public:
*/
void setDisplayFilter(KisDisplayFilter *displayFilter);
/**
* Set the exposure level used to display high dynamic range images. Typical values
* are between -10 and 10.
* @param exposure The exposure level
* @param gamma The gamma correction
*/
void setHDRExposure(float exposure, float gamma = 2.2);
/**
* Generate a background texture from the given QImage. This is used for the checker
* pattern on which the image is rendered.
......@@ -154,7 +146,6 @@ protected:
void createImageTextureTiles();
void destroyImageTextureTiles();
static void createHDRExposureProgramIfCan();
static bool imageCanUseHDRExposureProgram(KisImageWSP image);
static bool imageCanShareTextures(KisImageWSP image);
......@@ -168,8 +159,6 @@ private:
QRect m_storedImageBounds;
const KoColorProfile *m_monitorProfile;
KoColorConversionTransformation::Intent m_renderingIntent;
float m_exposure;
float m_gamma;
GLuint m_backgroundTexture;
KisGLTexturesInfo m_texturesInfo;
......@@ -178,7 +167,6 @@ private:
#ifdef HAVE_GLEW
bool m_usingHDRExposureProgram;
static KisOpenGLHDRExposureProgram *HDRExposureProgram;
#endif
KisDisplayFilter *m_displayFilter;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment