moved all shader code out of C++ source and into external shader files

General code cleanup and easier maintenance.
This commit is contained in:
itsmattkc
2019-12-10 00:10:00 +11:00
parent 3dc563b697
commit 2fb4047e6f
12 changed files with 56 additions and 62 deletions
+1 -15
View File
@@ -52,19 +52,5 @@ bool AlphaOverBlend::IsAccelerated() const
QString AlphaOverBlend::CodeFragment() const
{
return "#version 110"
"\n"
"varying vec2 ove_texcoord;\n"
"\n"
"uniform sampler2D base_in;\n"
"uniform sampler2D blend_in;\n"
"\n"
"void main(void) {\n"
" vec4 base_col = texture2D(base_in, ove_texcoord);\n"
" vec4 blend_col = texture2D(blend_in, ove_texcoord);\n"
" base_col *= 1.0 - blend_col.a;\n"
" base_col += blend_col;\n"
" \n"
" gl_FragColor = base_col;\n"
"}\n";
return ReadFileAsString(":/shaders/alphaover.frag");
}
-6
View File
@@ -87,9 +87,3 @@ TimeRange ClipBlock::InputTimeAdjustment(NodeInput *input, const TimeRange &inpu
return Block::InputTimeAdjustment(input, input_time);
}
NodeValueTable ClipBlock::Value(const NodeValueDatabase &value) const
{
// We just pass through the data here, the renderer should have gotten the correct time from InputTimeAdjustment
return value.Merge();
}
-2
View File
@@ -46,8 +46,6 @@ public:
virtual TimeRange InputTimeAdjustment(NodeInput* input, const TimeRange& input_time) const override;
virtual NodeValueTable Value(const NodeValueDatabase& value) const override;
private:
NodeInput* texture_input_;
@@ -32,23 +32,5 @@ bool CrossDissolveTransition::IsAccelerated() const
QString CrossDissolveTransition::CodeFragment() const
{
return "#version 110\n"
"\n"
"varying vec2 ove_texcoord;\n"
"\n"
"uniform sampler2D out_block_in;\n"
"uniform sampler2D in_block_in;\n"
"\n"
"uniform float transition_total_prog;\n"
"uniform float transition_out_prog;\n"
"uniform float transition_in_prog;\n"
"\n"
"void main(void) {\n"
" vec4 out_tex = texture2D(out_block_in, ove_texcoord);\n"
" vec4 in_tex = texture2D(in_block_in, ove_texcoord);\n"
" \n"
" in_tex *= transition_total_prog;\n"
" \n"
" gl_FragColor = out_tex - in_tex.a + in_tex;\n"
"}\n";
return ReadFileAsString(":/shaders/crossdissolve.frag");
}
+1 -10
View File
@@ -72,16 +72,7 @@ bool OpacityNode::IsAccelerated() const
QString OpacityNode::CodeFragment() const
{
return "#version 110"
"\n"
"varying vec2 olive_tex_coord;\n"
"\n"
"uniform sampler2D tex_in;\n"
"uniform float opacity_in;\n"
"\n"
"void main(void) {\n"
" gl_FragColor = texture2D(tex_in, olive_tex_coord) * (opacity_in * 0.01);\n"
"}\n";
return ReadFileAsString(":/shaders/opacity.frag");
}
NodeInput *OpacityNode::texture_input() const
+1 -7
View File
@@ -60,13 +60,7 @@ bool SolidGenerator::IsAccelerated() const
QString SolidGenerator::CodeFragment() const
{
return "#version 110\n"
"\n"
"uniform vec4 color_in;\n"
"\n"
"void main(void) {\n"
" gl_FragColor = color_in;\n"
"}\n";
return ReadFileAsString(":/shaders/solid.frag");
}
void SolidGenerator::Retranslate()
+1 -3
View File
@@ -91,9 +91,7 @@ void Node::AddParameter(NodeParam *param)
NodeValueTable Node::Value(const NodeValueDatabase &value) const
{
Q_UNUSED(value)
return NodeValueTable();
return value.Merge();
}
void Node::InvalidateCache(const rational &start_range, const rational &end_range, NodeInput *from)
+15
View File
@@ -0,0 +1,15 @@
#version 110
varying vec2 ove_texcoord;
uniform sampler2D base_in;
uniform sampler2D blend_in;
void main(void) {
vec4 base_col = texture2D(base_in, ove_texcoord);
vec4 blend_col = texture2D(blend_in, ove_texcoord);
base_col *= 1.0 - blend_col.a;
base_col += blend_col;
gl_FragColor = base_col;
}
+15
View File
@@ -0,0 +1,15 @@
#version 110
varying vec2 ove_texcoord;
uniform sampler2D base_in;
uniform sampler2D blend_in;
void main(void) {
vec4 base_col = texture2D(base_in, ove_texcoord);
vec4 blend_col = texture2D(blend_in, ove_texcoord);
base_col *= 1.0 - blend_col.a;
base_col += blend_col;
gl_FragColor = base_col;
}
+10
View File
@@ -0,0 +1,10 @@
#version 110
varying vec2 ove_tex_coord;
uniform sampler2D tex_in;
uniform float opacity_in;
void main(void) {
gl_FragColor = texture2D(tex_in, ove_tex_coord) * (opacity_in * 0.01);
}
+4
View File
@@ -1,5 +1,9 @@
<RCC>
<qresource prefix="/shaders">
<file>alphaover.frag</file>
<file>crossdissolve.frag</file>
<file>opacity.frag</file>
<file>solid.frag</file>
<file>videoinput.frag</file>
<file>videoinput.vert</file>
</qresource>
+7
View File
@@ -0,0 +1,7 @@
#version 110
uniform vec4 color_in;
void main(void) {
gl_FragColor = color_in;
}