[effects] Use shader traits API for reflection shader

icc-effect-5.14.5
Martin Gräßlin 2015-11-30 11:51:02 +01:00
parent 6bdef479a9
commit 5c59f4261b
3 changed files with 10 additions and 8 deletions

View File

@ -102,7 +102,10 @@ CubeEffect::CubeEffect()
if (effects->compositingType() == OpenGL2Compositing) {
const QString fragmentshader = QStandardPaths::locate(QStandardPaths::GenericDataLocation, m_shadersDir + QStringLiteral("cube-reflection.glsl"));
m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
QFile ffr(fragmentshader);
if (ffr.open(QIODevice::ReadOnly)) {
m_reflectionShader = ShaderManager::instance()->generateCustomShader(ShaderTrait::MapTexture, QByteArray(), ffr.readAll());
}
const QString capshader = QStandardPaths::locate(QStandardPaths::GenericDataLocation, m_shadersDir + QStringLiteral("cube-cap.glsl"));
QFile ff(capshader);
if (ff.open(QIODevice::ReadOnly)) {
@ -295,7 +298,6 @@ void CubeEffect::slotWallPaperLoaded()
void CubeEffect::slotResetShaders()
{
ShaderManager::instance()->resetShader(m_reflectionShader, ShaderManager::GenericShader);
ShaderManager::instance()->resetShader(cylinderShader, ShaderManager::GenericShader);
ShaderManager::instance()->resetShader(sphereShader, ShaderManager::GenericShader);
}
@ -486,9 +488,9 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
if (m_reflectionShader && m_reflectionShader->isValid()) {
// ensure blending is enabled - no attribute stack
ShaderBinder binder(m_reflectionShader);
QMatrix4x4 windowTransformation;
QMatrix4x4 windowTransformation = data.projectionMatrix();
windowTransformation.translate(rect.x() + rect.width() * 0.5f, 0.0, 0.0);
m_reflectionShader->setUniform("windowTransformation", windowTransformation);
m_reflectionShader->setUniform(GLShader::ModelViewProjectionMatrix, windowTransformation);
m_reflectionShader->setUniform("u_alpha", alpha);
QVector<float> verts;
QVector<float> texcoords;

View File

@ -1,8 +1,8 @@
uniform float u_alpha;
varying vec2 varyingTexCoords;
varying vec2 texcoord0;
void main()
{
gl_FragColor = vec4(0.0, 0.0, 0.0, u_alpha*varyingTexCoords.s);
gl_FragColor = vec4(0.0, 0.0, 0.0, u_alpha*texcoord0.s);
}

View File

@ -1,11 +1,11 @@
#version 140
uniform float u_alpha;
in vec2 varyingTexCoords;
in vec2 texcoord0;
out vec4 fragColor;
void main()
{
fragColor = vec4(0.0, 0.0, 0.0, u_alpha*varyingTexCoords.s);
fragColor = vec4(0.0, 0.0, 0.0, u_alpha*texcoord0.s);
}