Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve glsl pre-roll triangles #12100

Merged
merged 14 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,7 @@ else()
if(QOPENGL)
target_sources(mixxx-lib PRIVATE
src/shaders/endoftrackshader.cpp
src/shaders/patternshader.cpp
src/shaders/rgbashader.cpp
src/shaders/rgbshader.cpp
src/shaders/shader.cpp
Expand Down
6 changes: 5 additions & 1 deletion src/shaders/endoftrackshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ void main()
{
highp float minAlpha = 0.5 * color.w;
highp float maxAlpha = 0.83 * color.w;
gl_FragColor = vec4(color.xyz, mix(minAlpha, maxAlpha, max(0.,vgradient)));
gl_FragColor = vec4(color.xyz, mix(minAlpha, maxAlpha, max(0.0, vgradient)));
}
)--");

load(vertexShaderCode, fragmentShaderCode);

m_positionLocation = attributeLocation("position");
m_gradientLocation = attributeLocation("gradient");
m_colorLocation = uniformLocation("color");
}
14 changes: 14 additions & 0 deletions src/shaders/endoftrackshader.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ class mixxx::EndOfTrackShader : public mixxx::Shader {
~EndOfTrackShader() = default;
void init();

int positionLocation() const {
return m_positionLocation;
}
int gradientLocation() const {
return m_gradientLocation;
}
int colorLocation() const {
return m_colorLocation;
}

private:
int m_positionLocation;
int m_gradientLocation;
int m_colorLocation;

DISALLOW_COPY_AND_ASSIGN(EndOfTrackShader)
};
35 changes: 35 additions & 0 deletions src/shaders/patternshader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "shaders/patternshader.h"

using namespace mixxx;

void PatternShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform highp mat4 matrix;
attribute highp vec4 position;
Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
attribute highp vec2 texcoor;
varying highp vec2 vTexcoor;
void main()
{
vTexcoor = texcoor;
gl_Position = matrix * position;
}
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
uniform sampler2D texture;
uniform vec2 repetitions;
varying highp vec2 vTexcoor;
void main()
{
gl_FragColor = texture2D(texture, fract(vTexcoor * repetitions));
}
)--");

load(vertexShaderCode, fragmentShaderCode);

m_matrixLocation = uniformLocation("matrix");
m_positionLocation = attributeLocation("position");
m_texcoordLocation = attributeLocation("texcoor");
m_textureLocation = uniformLocation("texture");
m_repetitionsLocation = uniformLocation("repetitions");
}
39 changes: 39 additions & 0 deletions src/shaders/patternshader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include "shaders/shader.h"

namespace mixxx {
class PatternShader;
}

class mixxx::PatternShader final : public mixxx::Shader {
public:
PatternShader() = default;
~PatternShader() = default;
void init();

int matrixLocation() const {
return m_matrixLocation;
}
int positionLocation() const {
return m_positionLocation;
}
int texcoordLocation() const {
return m_texcoordLocation;
}
int textureLocation() const {
return m_textureLocation;
}
int repetitionsLocation() const {
return m_repetitionsLocation;
}

private:
int m_matrixLocation;
int m_positionLocation;
int m_texcoordLocation;
int m_textureLocation;
int m_repetitionsLocation;

DISALLOW_COPY_AND_ASSIGN(PatternShader)
};
12 changes: 8 additions & 4 deletions src/shaders/rgbashader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ void RGBAShader::init() {
uniform mat4 matrix;
attribute highp vec4 position;
attribute highp vec4 color;
varying highp vec4 vcolor;
varying highp vec4 vColor;
void main()
{
vcolor = color;
vColor = color;
gl_Position = matrix * position;
}
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
varying highp vec4 vcolor;
varying highp vec4 vColor;
void main()
{
gl_FragColor = vcolor;
gl_FragColor = vColor;
}
)--");

load(vertexShaderCode, fragmentShaderCode);

m_matrixLocation = uniformLocation("matrix");
m_positionLocation = attributeLocation("position");
m_colorLocation = attributeLocation("color");
}
14 changes: 14 additions & 0 deletions src/shaders/rgbashader.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ class mixxx::RGBAShader final : public mixxx::Shader {
~RGBAShader() = default;
void init();

int matrixLocation() const {
return m_matrixLocation;
}
int positionLocation() const {
return m_positionLocation;
}
int colorLocation() const {
return m_colorLocation;
}

private:
int m_matrixLocation;
int m_positionLocation;
int m_colorLocation;

DISALLOW_COPY_AND_ASSIGN(RGBAShader)
};
12 changes: 8 additions & 4 deletions src/shaders/rgbshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ void RGBShader::init() {
uniform mat4 matrix;
attribute highp vec4 position;
attribute highp vec3 color;
varying highp vec3 vcolor;
varying highp vec3 vColor;
void main()
{
vcolor = color;
vColor = color;
gl_Position = matrix * position;
}
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
varying highp vec3 vcolor;
varying highp vec3 vColor;
void main()
{
gl_FragColor = vec4(vcolor,1.0);
gl_FragColor = vec4(vColor, 1.0);
}
)--");

load(vertexShaderCode, fragmentShaderCode);

m_matrixLocation = uniformLocation("matrix");
m_positionLocation = attributeLocation("position");
m_colorLocation = attributeLocation("color");
}
14 changes: 14 additions & 0 deletions src/shaders/rgbshader.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ class mixxx::RGBShader final : public mixxx::Shader {
~RGBShader() = default;
void init();

int matrixLocation() const {
return m_matrixLocation;
}
int positionLocation() const {
return m_positionLocation;
}
int colorLocation() const {
return m_colorLocation;
}

private:
int m_matrixLocation;
int m_positionLocation;
int m_colorLocation;

DISALLOW_COPY_AND_ASSIGN(RGBShader)
};
18 changes: 9 additions & 9 deletions src/shaders/textureshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ using namespace mixxx;

void TextureShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
uniform highp mat4 matrix;
attribute highp vec4 position;
attribute highp vec3 texcoor;
varying highp vec3 vTexcoor;
attribute highp vec2 texcoord;
varying highp vec2 vTexcoord;
void main()
{
vTexcoor = texcoor;
vTexcoord = texcoord;
gl_Position = matrix * position;
}
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
uniform sampler2D sampler;
varying highp vec3 vTexcoor;
uniform sampler2D texture;
varying highp vec2 vTexcoord;
void main()
{
gl_FragColor = texture2D(sampler, vTexcoor.xy);
gl_FragColor = texture2D(texture, vTexcoord);
}
)--");

load(vertexShaderCode, fragmentShaderCode);

m_matrixLocation = uniformLocation("matrix");
m_samplerLocation = uniformLocation("sampler");
m_positionLocation = attributeLocation("position");
m_texcoordLocation = attributeLocation("texcoor");
m_texcoordLocation = attributeLocation("texcoord");
m_textureLocation = uniformLocation("texture");
}
8 changes: 4 additions & 4 deletions src/shaders/textureshader.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ class mixxx::TextureShader final : public mixxx::Shader {
int matrixLocation() const {
return m_matrixLocation;
}
int samplerLocation() const {
return m_samplerLocation;
}
int positionLocation() const {
return m_positionLocation;
}
int texcoordLocation() const {
return m_texcoordLocation;
}
int textureLocation() const {
return m_textureLocation;
}

private:
int m_matrixLocation;
int m_samplerLocation;
int m_positionLocation;
int m_texcoordLocation;
int m_textureLocation;

DISALLOW_COPY_AND_ASSIGN(TextureShader)
};
4 changes: 4 additions & 0 deletions src/shaders/unicolorshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ void main()
)--");

load(vertexShaderCode, fragmentShaderCode);

m_matrixLocation = uniformLocation("matrix");
m_positionLocation = attributeLocation("position");
m_colorLocation = uniformLocation("color");
}
14 changes: 14 additions & 0 deletions src/shaders/unicolorshader.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ class mixxx::UnicolorShader final : public mixxx::Shader {
~UnicolorShader() = default;
void init();

int matrixLocation() const {
return m_matrixLocation;
}
int positionLocation() const {
return m_positionLocation;
}
int colorLocation() const {
return m_colorLocation;
}

private:
int m_matrixLocation;
int m_positionLocation;
int m_colorLocation;

DISALLOW_COPY_AND_ASSIGN(UnicolorShader)
};
20 changes: 10 additions & 10 deletions src/shaders/vinylqualityshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ void VinylQualityShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute highp vec4 position;
attribute highp vec3 texcoor;
varying highp vec3 vTexcoor;
attribute highp vec2 texcoord;
varying highp vec2 vTexcoord;
void main()
{
vTexcoor = texcoor;
vTexcoord = texcoord;
gl_Position = matrix * position;
}
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
uniform sampler2D sampler;
uniform highp vec4 color;
varying highp vec3 vTexcoor;
uniform sampler2D texture;
uniform highp vec3 color;
varying highp vec2 vTexcoord;
void main()
{
gl_FragColor = vec4(color.xyz, texture2D(sampler, vTexcoor.xy) * 0.75);
gl_FragColor = vec4(color, texture2D(texture, vTexcoord) * 0.75);
}
)--");

load(vertexShaderCode, fragmentShaderCode);

m_matrixLocation = uniformLocation("matrix");
m_samplerLocation = uniformLocation("sampler");
m_colorLocation = uniformLocation("color");
m_positionLocation = attributeLocation("position");
m_texcoordLocation = attributeLocation("texcoor");
m_texcoordLocation = attributeLocation("texcoord");
m_textureLocation = uniformLocation("texture");
m_colorLocation = uniformLocation("color");
}
17 changes: 9 additions & 8 deletions src/shaders/vinylqualityshader.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,26 @@ class mixxx::VinylQualityShader final : public mixxx::Shader {
int matrixLocation() const {
return m_matrixLocation;
}
int samplerLocation() const {
return m_samplerLocation;
}
int colorLocation() const {
return m_colorLocation;
}
int positionLocation() const {
return m_positionLocation;
}
int texcoordLocation() const {
return m_texcoordLocation;
}

int textureLocation() const {
return m_textureLocation;
}
int colorLocation() const {
return m_colorLocation;
}

private:
int m_matrixLocation;
int m_samplerLocation;
int m_colorLocation;
int m_positionLocation;
int m_texcoordLocation;
int m_textureLocation;
int m_colorLocation;

DISALLOW_COPY_AND_ASSIGN(VinylQualityShader)
};
Loading