[effects] Use shader traits API for reflection shader
parent
6bdef479a9
commit
5c59f4261b
|
@ -102,7 +102,10 @@ CubeEffect::CubeEffect()
|
||||||
|
|
||||||
if (effects->compositingType() == OpenGL2Compositing) {
|
if (effects->compositingType() == OpenGL2Compositing) {
|
||||||
const QString fragmentshader = QStandardPaths::locate(QStandardPaths::GenericDataLocation, m_shadersDir + QStringLiteral("cube-reflection.glsl"));
|
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"));
|
const QString capshader = QStandardPaths::locate(QStandardPaths::GenericDataLocation, m_shadersDir + QStringLiteral("cube-cap.glsl"));
|
||||||
QFile ff(capshader);
|
QFile ff(capshader);
|
||||||
if (ff.open(QIODevice::ReadOnly)) {
|
if (ff.open(QIODevice::ReadOnly)) {
|
||||||
|
@ -295,7 +298,6 @@ void CubeEffect::slotWallPaperLoaded()
|
||||||
|
|
||||||
void CubeEffect::slotResetShaders()
|
void CubeEffect::slotResetShaders()
|
||||||
{
|
{
|
||||||
ShaderManager::instance()->resetShader(m_reflectionShader, ShaderManager::GenericShader);
|
|
||||||
ShaderManager::instance()->resetShader(cylinderShader, ShaderManager::GenericShader);
|
ShaderManager::instance()->resetShader(cylinderShader, ShaderManager::GenericShader);
|
||||||
ShaderManager::instance()->resetShader(sphereShader, 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()) {
|
if (m_reflectionShader && m_reflectionShader->isValid()) {
|
||||||
// ensure blending is enabled - no attribute stack
|
// ensure blending is enabled - no attribute stack
|
||||||
ShaderBinder binder(m_reflectionShader);
|
ShaderBinder binder(m_reflectionShader);
|
||||||
QMatrix4x4 windowTransformation;
|
QMatrix4x4 windowTransformation = data.projectionMatrix();
|
||||||
windowTransformation.translate(rect.x() + rect.width() * 0.5f, 0.0, 0.0);
|
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);
|
m_reflectionShader->setUniform("u_alpha", alpha);
|
||||||
QVector<float> verts;
|
QVector<float> verts;
|
||||||
QVector<float> texcoords;
|
QVector<float> texcoords;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
uniform float u_alpha;
|
uniform float u_alpha;
|
||||||
|
|
||||||
varying vec2 varyingTexCoords;
|
varying vec2 texcoord0;
|
||||||
|
|
||||||
void main()
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#version 140
|
#version 140
|
||||||
uniform float u_alpha;
|
uniform float u_alpha;
|
||||||
|
|
||||||
in vec2 varyingTexCoords;
|
in vec2 texcoord0;
|
||||||
|
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
void main()
|
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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue