Use generic fragment shader for Cylinder and Sphere

Shaders were broken. Issue mentioned in the TODO seems to no longer be
present (at least not on the system I used for testing).

REVIEW: 110570
This commit is contained in:
Martin Gräßlin 2013-05-21 08:43:51 +02:00
parent 58ffb7b627
commit 2bee9a0ee0
3 changed files with 3 additions and 27 deletions

View file

@ -24,7 +24,6 @@ install( FILES
cube/data/cube-cap.glsl
cube/data/cube-reflection.glsl
cube/data/cubecap.png
cube/data/cylinder.frag
cube/data/cylinder.vert
cube/data/sphere.vert
DESTINATION ${DATA_INSTALL_DIR}/kwin )

View file

@ -283,16 +283,14 @@ bool CubeEffect::loadShader()
if (!(GLPlatform::instance()->supports(GLSL) &&
(effects->compositingType() == OpenGL2Compositing)))
return false;
QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/cylinder.frag");
QString cylinderVertexshader = KGlobal::dirs()->findResource("data", "kwin/cylinder.vert");
QString sphereVertexshader = KGlobal::dirs()->findResource("data", "kwin/sphere.vert");
if (fragmentshader.isEmpty() || cylinderVertexshader.isEmpty() || sphereVertexshader.isEmpty()) {
if (cylinderVertexshader.isEmpty() || sphereVertexshader.isEmpty()) {
kError(1212) << "Couldn't locate shader files" << endl;
return false;
}
// TODO: use generic shader - currently it is failing in alpha/brightness manipulation
cylinderShader = new GLShader(cylinderVertexshader, fragmentshader);
cylinderShader = ShaderManager::instance()->loadVertexShader(ShaderManager::GenericShader, cylinderVertexshader);
if (!cylinderShader->isValid()) {
kError(1212) << "The cylinder shader failed to load!" << endl;
return false;
@ -321,8 +319,7 @@ bool CubeEffect::loadShader()
QRect rect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop());
cylinderShader->setUniform("width", (float)rect.width() * 0.5f);
}
// TODO: use generic shader - currently it is failing in alpha/brightness manipulation
sphereShader = new GLShader(sphereVertexshader, fragmentshader);
sphereShader = ShaderManager::instance()->loadVertexShader(ShaderManager::GenericShader, sphereVertexshader);
if (!sphereShader->isValid()) {
kError(1212) << "The sphere shader failed to load!" << endl;
return false;

View file

@ -1,20 +0,0 @@
uniform sampler2D sampler;
uniform float opacity;
uniform float brightness;
uniform float saturation;
varying vec2 varyingTexCoords;
void main()
{
vec4 tex = texture2D(sampler, varyingTexCoords);
if( saturation != 1.0 )
{
vec3 desaturated = tex.rgb * vec3( 0.30, 0.59, 0.11 );
desaturated = vec3( dot( desaturated, tex.rgb ));
tex.rgb = tex.rgb * vec3( saturation ) + desaturated * vec3( 1.0 - saturation );
}
// tex.rgb = tex.rgb * opacity * brightness;
// tex.a = tex.a * opacity;
gl_FragColor = tex;
}