kwin: Normalize the texcoords in the vertex shader
This commit is contained in:
parent
2fa966e0f9
commit
5e97ccf7e0
7 changed files with 16 additions and 28 deletions
|
@ -1,20 +1,13 @@
|
|||
uniform sampler2D sample;
|
||||
uniform float textureWidth;
|
||||
uniform float textureHeight;
|
||||
uniform float opacity;
|
||||
uniform float brightness;
|
||||
uniform float saturation;
|
||||
|
||||
varying vec2 varyingTexCoords;
|
||||
|
||||
vec2 pix2tex(vec2 pix)
|
||||
{
|
||||
return vec2(pix.x / textureWidth, pix.y / textureHeight);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex = texture2D(sample, pix2tex(varyingTexCoords));
|
||||
vec4 tex = texture2D(sample, varyingTexCoords);
|
||||
if( saturation != 1.0 )
|
||||
{
|
||||
vec3 desaturated = tex.rgb * vec3( 0.30, 0.59, 0.11 );
|
||||
|
|
|
@ -25,6 +25,8 @@ uniform float width;
|
|||
uniform float cubeAngle;
|
||||
uniform float xCoord;
|
||||
uniform float timeLine;
|
||||
uniform float textureWidth;
|
||||
uniform float textureHeight;
|
||||
|
||||
attribute vec4 vertex;
|
||||
attribute vec2 texCoord;
|
||||
|
@ -33,7 +35,7 @@ varying vec2 varyingTexCoords;
|
|||
|
||||
void main()
|
||||
{
|
||||
varyingTexCoords = texCoord;
|
||||
varyingTexCoords = texCoord / vec2(textureWidth, textureHeight);
|
||||
vec4 transformedVertex = vec4(vertex.x - ( width - xCoord ), vertex.yzw);
|
||||
float radian = radians(cubeAngle);
|
||||
float radius = (width)*tan(radian);
|
||||
|
|
|
@ -23,7 +23,8 @@ vec2 pix2tex( vec2 pix )
|
|||
void main()
|
||||
{
|
||||
// Original (unscaled) position in pixels
|
||||
vec2 origpos = varyingTexCoords;
|
||||
// ### FIXME: Use a custom vertex shader that outputs the untransformed texcoords
|
||||
vec2 origpos = varyingTexCoords * vec2(textureWidth, textureHeight);
|
||||
// Position in pixels on the scaled window
|
||||
vec2 pos = origpos * scale;
|
||||
// Start/end position of current region
|
||||
|
|
|
@ -8,15 +8,9 @@ uniform int u_forceAlpha;
|
|||
|
||||
varying vec2 varyingTexCoords;
|
||||
|
||||
// Converts pixel coordinates to texture coordinates
|
||||
vec2 pix2tex( vec2 pix )
|
||||
{
|
||||
return vec2( pix.s / textureWidth, pix.t / textureHeight );
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex = texture2D( sample, pix2tex( varyingTexCoords ));
|
||||
vec4 tex = texture2D(sample, varyingTexCoords);
|
||||
if( saturation != 1.0 )
|
||||
{
|
||||
vec3 desaturated = tex.rgb * vec3( 0.30, 0.59, 0.11 );
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
uniform sampler2D sample;
|
||||
uniform float textureWidth;
|
||||
uniform float textureHeight;
|
||||
uniform float opacity;
|
||||
uniform float brightness;
|
||||
uniform float saturation;
|
||||
|
@ -11,14 +9,8 @@ varying vec2 varyingTexCoords;
|
|||
|
||||
//varying vec4 color;
|
||||
|
||||
// Converts pixel coordinates to texture coordinates
|
||||
vec2 pix2tex( vec2 pix )
|
||||
{
|
||||
return vec2( pix.s / textureWidth, pix.t / textureHeight );
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 tex = texture2D(sample, pix2tex(varyingTexCoords));
|
||||
vec4 tex = texture2D(sample, varyingTexCoords);
|
||||
if( saturation != 1.0 ) {
|
||||
vec3 desaturated = tex.rgb * vec3( 0.30, 0.59, 0.11 );
|
||||
desaturated = vec3( dot( desaturated, tex.rgb ));
|
||||
|
|
|
@ -3,6 +3,9 @@ uniform mat4 modelview;
|
|||
uniform mat4 screenTransformation;
|
||||
uniform mat4 windowTransformation;
|
||||
|
||||
uniform float textureWidth;
|
||||
uniform float textureHeight;
|
||||
|
||||
// passed in vertex - only x and y are used
|
||||
attribute vec4 vertex;
|
||||
// passed in texCoords - to be forwarded
|
||||
|
@ -12,6 +15,6 @@ attribute vec2 texCoord;
|
|||
varying vec2 varyingTexCoords;
|
||||
|
||||
void main() {
|
||||
varyingTexCoords = texCoord;
|
||||
varyingTexCoords = texCoord / vec2(textureWidth, textureHeight);
|
||||
gl_Position = vertex*(windowTransformation*screenTransformation*modelview)*projection;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ uniform mat4 projection;
|
|||
// offset of the window/texture to be rendered
|
||||
uniform vec2 offset;
|
||||
|
||||
uniform float textureWidth;
|
||||
uniform float textureHeight;
|
||||
|
||||
// passed in vertex - only x and y are used
|
||||
attribute vec4 vertex;
|
||||
// passed in texCoords - to be forwarded
|
||||
|
@ -11,6 +14,6 @@ attribute vec2 texCoord;
|
|||
varying vec2 varyingTexCoords;
|
||||
|
||||
void main() {
|
||||
varyingTexCoords = texCoord;
|
||||
varyingTexCoords = texCoord / vec2(textureWidth, textureHeight);
|
||||
gl_Position = vec4(vertex.xy + offset, vertex.zw) * projection;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue