can set default input color space

This commit is contained in:
itsmattkc
2019-03-27 00:15:20 +11:00
parent cab38b5e90
commit fe9eb8754f
14 changed files with 112 additions and 68 deletions
+15 -8
View File
@@ -27,14 +27,6 @@
namespace olive {
struct PixelFormatInfo {
QString name;
GLint internal_format;
GLenum pixel_format;
GLenum pixel_type;
int bytes_per_pixel;
};
/**
* @brief The PixelFormat enum
*
@@ -49,6 +41,21 @@ enum PixelFormat {
PIX_FMT_COUNT
};
/**
* @brief The PixelFormatInfo struct
*
* A struct of information pertaining to each enum PixelFormat. Primarily this is a means of retrieving OpenGL texture
* information for different pixel formats/bit depths. Using the values in pixel_formats is always recommended over
* manually using OpenGL constants (e.g. GL_RGBA or GL_RGBA32F) directly.
*/
struct PixelFormatInfo {
QString name;
GLint internal_format;
GLenum pixel_format;
GLenum pixel_type;
int bytes_per_pixel;
};
extern QVector<PixelFormatInfo> pixel_formats;
void InitializePixelFormats();
-22
View File
@@ -1,22 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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 3 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, see <http://www.gnu.org/licenses/>.
***/
#include "qopenglshaderprogramptr.h"
+7 -3
View File
@@ -101,6 +101,7 @@ void olive::rendering::Blit(QOpenGLShaderProgram* pipeline, bool flipped, QMatri
pipeline->setUniformValue("mvp_matrix", matrix);
pipeline->setUniformValue("texture", 0);
GLuint vertex_location = pipeline->attributeLocation("a_position");
m_vbo.bind();
func->glEnableVertexAttribArray(vertex_location);
@@ -179,11 +180,15 @@ void process_effect(QOpenGLContext* ctx,
}
bool can_process_shaders = ((e->Flags() & Effect::ShaderFlag) && olive::CurrentRuntimeConfig.shaders_are_enabled);
if (can_process_shaders || (e->Flags() & Effect::SuperimposeFlag)) {
e->startEffect();
if (!e->is_open()) {
e->open();
}
if (can_process_shaders && e->is_shader_linked()) {
for (int i=0;i<e->getIterations();i++) {
e->process_shader(timecode, coords, i);
composite_texture = draw_clip(ctx, pipeline, c->fbo.at(fbo_switcher), composite_texture, true);
composite_texture = draw_clip(ctx, e->GetShaderPipeline(), c->fbo.at(fbo_switcher), composite_texture, true);
fbo_switcher = !fbo_switcher;
}
}
@@ -208,7 +213,6 @@ void process_effect(QOpenGLContext* ctx,
composite_texture = draw_clip(ctx, pipeline, c->fbo.at(!fbo_switcher), superimpose_texture, false);
}
}
e->endEffect();
}
}
}
+9 -8
View File
@@ -2,7 +2,7 @@
#include <QOpenGLExtraFunctions>
QOpenGLShaderProgramPtr olive::shader::GetPipeline(const QString& shader_code)
QOpenGLShaderProgramPtr olive::shader::GetPipeline(const QString& function_name, const QString& shader_code)
{
QOpenGLShaderProgramPtr program = std::make_shared<QOpenGLShaderProgram>();
@@ -62,16 +62,16 @@ QOpenGLShaderProgramPtr olive::shader::GetPipeline(const QString& shader_code)
// If additional code was passed, add it and reference it in main().
//
// The function in the additional code is expected to be `vec4 process(vec4 color)`. The texture coordinate can be
// The function in the additional code is expected to be `vec4 function_name(vec4 color)`. The texture coordinate can be
// acquired through `v_texcoord`.
frag_shader.append(shader_code);
frag_shader.append("\n"
frag_shader.append(QString("\n"
"void main() {\n"
" vec4 color = process(texture2D(texture, v_texcoord))*opacity;\n"
" vec4 color = %1(texture2D(texture, v_texcoord))*opacity;\n"
" gl_FragColor = color;\n"
"}\n");
"}\n").arg(function_name));
}
@@ -211,16 +211,17 @@ QOpenGLShaderProgramPtr olive::shader::SetupOCIO(QOpenGLContext* ctx,
}
// Add process() function, which GetPipeline() will call if specified
QString process_function_name = "process";
shader_text.append(QString("\n"
"uniform sampler3D tex2;\n"
"\n"
"vec4 process(vec4 col) {\n"
"vec4 %2(vec4 col) {\n"
" return %1\n"
"}\n").arg(shader_call));
"}\n").arg(shader_call, process_function_name));
// Get pipeline-based shader to inject OCIO shader into
QOpenGLShaderProgramPtr shader = olive::shader::GetPipeline(shader_text);
QOpenGLShaderProgramPtr shader = olive::shader::GetPipeline(process_function_name, shader_text);
// Release LUT
xf->glBindTexture(GL_TEXTURE_3D, 0);
+1 -1
View File
@@ -9,7 +9,7 @@ namespace OCIO = OCIO_NAMESPACE::v1;
namespace olive {
namespace shader {
QOpenGLShaderProgramPtr GetPipeline(const QString &shader_code = QString());
QOpenGLShaderProgramPtr GetPipeline(const QString &function_name = QString(), const QString &shader_code = QString());
QOpenGLShaderProgramPtr SetupOCIO(QOpenGLContext *ctx,
GLuint &lut_texture,