移除office-plugin, 使用新版jodconverter

This commit is contained in:
陈精华
2022-12-15 18:19:30 +08:00
parent 281a9cfbab
commit 7d3a4ebc4e
12562 changed files with 202 additions and 3641 deletions

View File

@@ -0,0 +1,87 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* TODO Use textureOffset for newest version of GLSL */
#version 130
uniform sampler2D crc_table;
uniform sampler2D sampler;
uniform float xstep;
uniform float ystep;
varying vec2 tex_coord;
const int scale = 4;
const float ratio = 16.0;
ivec2 crc64( ivec2 hval, int color )
{
int dx = 2 * ((hval[0] ^ color) & 0xff);
float s = dx / 255.0;
vec4 table_value_lo = round(texture2D( crc_table, vec2( s, 0.0 ) ) * 255.0);
s = (dx+1) / 255.0;
vec4 table_value_hi = round(texture2D( crc_table, vec2( s, 0.0 ) ) * 255.0);
int tvalue_lo = int(table_value_lo[0]) | (int(table_value_lo[1]) << 8) | (int(table_value_lo[2]) << 16) | (int(table_value_lo[3]) << 24);
int tvalue_hi = int(table_value_hi[0]) | (int(table_value_hi[1]) << 8) | (int(table_value_hi[2]) << 16) | (int(table_value_hi[3]) << 24);
hval[1] = tvalue_hi ^ (hval[1] >> 8);
hval[0] = tvalue_lo ^ ( (hval[1] << 24) | (hval[0] >> 8) );
return hval;
}
void main(void)
{
ivec2 Crc = ivec2( 0xffffffff, 0xffffffff );
vec2 offset = vec2( 0.0, 0.0 );
vec2 next_coord = tex_coord.st;
for( int y = 0; y < scale && next_coord.y <= 1.0; ++y )
{
for( int x = 0; x < scale && next_coord.x <= 1.0; ++x )
{
vec4 pixel = round(texture2D( sampler, next_coord ) * 255.0);
int r = int(pixel.r); // 0..255
int g = int(pixel.g); // 0..255
int b = int(pixel.b); // 0..255
int a = int(pixel.a); // 0..255
Crc = crc64( Crc, r );
Crc = crc64( Crc, g );
Crc = crc64( Crc, b );
Crc = crc64( Crc, a );
offset.x += xstep;
next_coord = tex_coord.st + offset;
}
offset.y += ystep;
offset.x = 0.0;
next_coord = tex_coord.st + offset;
}
Crc[0] = ~Crc[0];
Crc[1] = ~Crc[1];
int Hash = Crc[0] ^ Crc[1];
float fr = ( Hash & 0xff) / 255.0;
float fg = ((Hash >> 8) & 0xff) / 255.0;
float fb = ((Hash >> 16) & 0xff) / 255.0;
float fa = ((Hash >> 24) & 0xff) / 255.0;
gl_FragColor = vec4(fr, fg, fb, fa);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,59 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* TODO Use textureOffset for newest version of GLSL */
#version 130
uniform sampler2D sampler;
uniform int xscale;
uniform int yscale;
uniform float xstep;
uniform float ystep;
uniform float ratio; // = 1.0/(xscale*yscale)
varying vec2 tex_coord;
// This mode makes the scaling work like maskedTextureFragmentShader.glsl
// (instead of like plain textureVertexShader.glsl).
#ifdef MASKED
varying vec2 mask_coord;
uniform sampler2D mask;
#endif
/*
Just make the resulting color the average of all the source pixels
(which is an area (xscale)x(yscale) ).
*/
void main(void)
{
vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
vec2 offset = vec2( 0.0, 0.0 );
for( int y = 0; y < yscale; ++y )
{
for( int x = 0; x < xscale; ++x )
{
#ifndef MASKED
sum += texture2D( sampler, tex_coord.st + offset );
#else
vec4 texel;
texel = texture2D( sampler, tex_coord.st + offset );
texel.a = 1.0 - texture2D( mask, mask_coord.st + offset ).r;
sum += texel;
#endif
offset.x += xstep;
}
offset.y += ystep;
offset.x = 0.0;
}
sum *= ratio;
gl_FragColor = sum;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,239 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
uniform sampler2D sampler;
uniform int swidth;
uniform int sheight;
uniform float xscale;
uniform float yscale;
uniform float xoffset;
uniform float yoffset;
uniform float xfrompixelratio;
uniform float yfrompixelratio;
uniform float xtopixelratio;
uniform float ytopixelratio;
varying vec2 tex_coord;
// This mode makes the scaling work like maskedTextureFragmentShader.glsl
// (instead of like plain textureVertexShader.glsl).
#ifdef MASKED
varying vec2 mask_coord;
uniform sampler2D mask;
#endif
#ifdef USE_REDUCED_REGISTER_VARIANT
vec4 getTexel(int x, int y)
{
vec2 pos = vec2( x * xfrompixelratio + xoffset, y * yfrompixelratio + yoffset );
vec4 texel = texture2D(sampler, pos);
#ifdef MASKED
texel.a = 1.0 - texture2D(mask, pos - tex_coord.st + mask_coord.st).r;
#endif
return texel;
}
void main(void)
{
// Convert to pixel coordinates again.
int dx = int(( tex_coord.s - xoffset ) * xtopixelratio );
int dy = int(( tex_coord.t - yoffset ) * ytopixelratio );
// Compute the range of source pixels which will make up this destination pixel.
float fsx1 = min(dx * xscale, float(swidth - 1));
float fsx2 = min(fsx1 + xscale, float(swidth - 1));
float fsy1 = min(dy * yscale, float(sheight - 1));
float fsy2 = min(fsy1 + yscale, float(sheight - 1));
// To whole pixel coordinates.
int xstart = int(floor(fsx1));
int xend = int(floor(fsx2));
int ystart = int(floor(fsy1));
int yend = int(floor(fsy2));
float xlength = fsx2 - fsx1;
float ylength = fsy2 - fsy1;
float xContribution[3];
xContribution[0] = (1.0 - max(0.0, fsx1 - xstart)) / xlength;
xContribution[1] = 1.0 / xlength;
xContribution[2] = (1.0 - max(0.0, (xend + 1) - fsx2)) / xlength;
float yContribution[3];
yContribution[0] = (1.0 - max(0.0, fsy1 - ystart)) / ylength;
yContribution[1] = 1.0 / ylength;
yContribution[2] = (1.0 - max(0.0, (yend + 1) - fsy2)) / ylength;
vec4 sumAll = vec4(0.0, 0.0, 0.0, 0.0);
vec4 texel;
// First Y pass
{
vec4 sumX = vec4(0.0, 0.0, 0.0, 0.0);
sumX += getTexel(xstart, ystart) * xContribution[0];
for (int x = xstart + 1; x < xend; ++x)
{
sumX += getTexel(x, ystart) * xContribution[1];
}
sumX += getTexel(xend, ystart) * xContribution[2];
sumAll += sumX * yContribution[0];
}
// Middle Y Passes
for (int y = ystart + 1; y < yend; ++y)
{
vec4 sumX = vec4(0.0, 0.0, 0.0, 0.0);
sumX += getTexel(xstart, y) * xContribution[0];
for (int x = xstart + 1; x < xend; ++x)
{
sumX += getTexel(x, y) * xContribution[1];
}
sumX += getTexel(xend, y) * xContribution[2];
sumAll += sumX * yContribution[1];
}
// Last Y pass
{
vec4 sumX = vec4(0.0, 0.0, 0.0, 0.0);
sumX += getTexel(xstart, yend) * xContribution[0];
for (int x = xstart + 1; x < xend; ++x)
{
sumX += getTexel(x, yend) * xContribution[1];
}
sumX += getTexel(xend, yend) * xContribution[2];
sumAll += sumX * yContribution[2];
}
gl_FragColor = sumAll;
}
#else
void main(void)
{
// Convert to pixel coordinates again.
int dx = int(( tex_coord.s - xoffset ) * xtopixelratio );
int dy = int(( tex_coord.t - yoffset ) * ytopixelratio );
// How much each column/row will contribute to the resulting pixel.
// Note: These values are always the same for the same X (or Y),
// so they could be precalculated in C++ and passed to the shader,
// but GLSL has limits on the size of uniforms passed to it,
// so it'd need something like texture buffer objects from newer
// GLSL versions, and it seems the hassle is not really worth it.
float xratio[ 16 + 2 ];
float yratio[ 16 + 2 ];
// For finding the first and last source pixel.
int xpixel[ 16 + 2 ];
int ypixel[ 16 + 2 ];
int xpos = 0;
int ypos = 0;
// Compute the range of source pixels which will make up this destination pixel.
float fsx1 = dx * xscale;
float fsx2 = fsx1 + xscale;
// To whole pixel coordinates.
int sx1 = int( ceil( fsx1 ) );
int sx2 = int( floor( fsx2 ) );
// Range checking.
sx2 = min( sx2, swidth - 1 );
sx1 = min( sx1, sx2 );
// How much one full column contributes to the resulting pixel.
float width = min( xscale, swidth - fsx1 );
if( sx1 - fsx1 > 0.001 )
{ // The first column contributes only partially.
xpixel[ xpos ] = sx1 - 1;
xratio[ xpos ] = ( sx1 - fsx1 ) / width;
++xpos;
}
for( int sx = sx1; sx < sx2; ++sx )
{ // Columns that fully contribute to the resulting pixel.
xpixel[ xpos ] = sx;
xratio[ xpos ] = 1.0 / width;
++xpos;
}
if( fsx2 - sx2 > 0.001 )
{ // The last column contributes only partially.
xpixel[ xpos ] = sx2;
xratio[ xpos ] = min( min( fsx2 - sx2, 1.0 ) / width, 1.0 );
++xpos;
}
// The same for Y.
float fsy1 = dy * yscale;
float fsy2 = fsy1 + yscale;
int sy1 = int( ceil( fsy1 ) );
int sy2 = int( floor( fsy2 ) );
sy2 = min( sy2, sheight - 1 );
sy1 = min( sy1, sy2 );
float height = min( yscale, sheight - fsy1 );
if( sy1 - fsy1 > 0.001 )
{
ypixel[ ypos ] = sy1 - 1;
yratio[ ypos ] = ( sy1 - fsy1 ) / height;
++ypos;
}
for( int sy = sy1; sy < sy2; ++sy )
{
ypixel[ ypos ] = sy;
yratio[ ypos ] = 1.0 / height;
++ypos;
}
if( fsy2 - sy2 > 0.001 )
{
ypixel[ ypos ] = sy2;
yratio[ ypos ] = min( min( fsy2 - sy2, 1.0 ) / height, 1.0 );
++ypos;
}
int xstart = xpixel[ 0 ];
int xend = xpixel[ xpos - 1 ];
int ystart = ypixel[ 0 ];
int yend = ypixel[ ypos - 1 ];
vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
ypos = 0;
for( int y = ystart; y <= yend; ++y, ++ypos )
{
vec4 tmp = vec4( 0.0, 0.0, 0.0, 0.0 );
xpos = 0;
for( int x = xstart; x <= xend; ++x, ++xpos )
{
vec2 pos = vec2( x * xfrompixelratio + xoffset, y * yfrompixelratio + yoffset );
#ifndef MASKED
tmp += texture2D( sampler, pos ) * xratio[ xpos ];
#else
vec4 texel;
texel = texture2D( sampler, pos );
texel.a = 1.0 - texture2D( mask, pos - tex_coord.st + mask_coord.st ).r;
tmp += texel * xratio[ xpos ];
#endif
}
sum += tmp * yratio[ ypos ];
}
gl_FragColor = sum;
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,24 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform sampler2D slideTexture;
varying vec2 v_texturePosition;
varying vec3 v_normal;
void main() {
vec3 lightVector = vec3(0.0, 0.0, 1.0);
float light = max(dot(lightVector, v_normal), 0.0);
vec4 fragment = texture2D(slideTexture, v_texturePosition);
vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
gl_FragColor = mix(black, fragment, light);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,96 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#version 120
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_texCoord;
uniform mat4 u_projectionMatrix;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_sceneTransformMatrix;
uniform mat4 u_primitiveTransformMatrix;
uniform mat4 u_operationsTransformMatrix;
varying vec2 v_texturePosition;
varying vec3 v_normal;
#if __VERSION__ < 140
mat4 inverse(mat4 m)
{
float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
float b00 = a00 * a11 - a01 * a10;
float b01 = a00 * a12 - a02 * a10;
float b02 = a00 * a13 - a03 * a10;
float b03 = a01 * a12 - a02 * a11;
float b04 = a01 * a13 - a03 * a11;
float b05 = a02 * a13 - a03 * a12;
float b06 = a20 * a31 - a21 * a30;
float b07 = a20 * a32 - a22 * a30;
float b08 = a20 * a33 - a23 * a30;
float b09 = a21 * a32 - a22 * a31;
float b10 = a21 * a33 - a23 * a31;
float b11 = a22 * a33 - a23 * a32;
float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
return mat4(
a11 * b11 - a12 * b10 + a13 * b09,
a02 * b10 - a01 * b11 - a03 * b09,
a31 * b05 - a32 * b04 + a33 * b03,
a22 * b04 - a21 * b05 - a23 * b03,
a12 * b08 - a10 * b11 - a13 * b07,
a00 * b11 - a02 * b08 + a03 * b07,
a32 * b02 - a30 * b05 - a33 * b01,
a20 * b05 - a22 * b02 + a23 * b01,
a10 * b10 - a11 * b08 + a13 * b06,
a01 * b08 - a00 * b10 - a03 * b06,
a30 * b04 - a31 * b02 + a33 * b00,
a21 * b02 - a20 * b04 - a23 * b00,
a11 * b07 - a10 * b09 - a12 * b06,
a00 * b09 - a01 * b07 + a02 * b06,
a31 * b01 - a30 * b03 - a32 * b00,
a20 * b03 - a21 * b01 + a22 * b00) / det;
}
#endif
void main( void )
{
mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
mat3 normalMatrix = mat3(transpose(inverse(modelViewMatrix)));
gl_Position = u_projectionMatrix * modelViewMatrix * vec4(a_position, 1.0);
v_texturePosition = a_texCoord;
v_normal = normalize(normalMatrix * a_normal);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,33 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
varying vec2 tex_coord;
varying vec2 alpha_coord;
varying vec2 mask_coord;
uniform sampler2D sampler;
uniform sampler2D mask;
uniform sampler2D alpha;
void main()
{
vec4 texel0, texel1, texel2;
texel0 = texture2D(sampler, tex_coord);
texel1 = texture2D(mask, mask_coord);
texel2 = texture2D(alpha, alpha_coord);
gl_FragColor = texel0;
/* Only blend if the alpha texture wasn't fully transparent */
gl_FragColor.a = 1.0 - (1.0 - floor(texel2.r)) * texel1.r;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,28 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
attribute vec4 position;
attribute vec2 tex_coord_in;
attribute vec2 alpha_coord_in;
attribute vec2 mask_coord_in;
varying vec2 tex_coord;
varying vec2 alpha_coord;
varying vec2 mask_coord;
uniform mat4 mvp;
void main() {
gl_Position = mvp * position;
tex_coord = tex_coord_in;
alpha_coord = alpha_coord_in;
mask_coord = mask_coord_in;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
varying float fade_factor; // 0->1 fade factor used for AA
varying float multiply;
#ifdef USE_VERTEX_COLORS
varying vec4 vertex_color;
#endif
uniform vec4 color;
#define TYPE_NORMAL 0
#define TYPE_LINE 1
uniform int type;
void main()
{
#ifdef USE_VERTEX_COLORS
vec4 result = vertex_color;
#else
vec4 result = color;
#endif
if (type == TYPE_LINE)
{
float dist = (1.0 - abs(fade_factor)) * multiply;
float alpha = clamp(dist, 0.0, 1.0);
result.a = result.a * alpha;
}
gl_FragColor = result;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,73 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
varying vec2 tex_coord;
varying vec2 alpha_coord;
varying vec2 mask_coord;
#ifdef USE_VERTEX_COLORS
varying vec4 vertex_color;
#endif
uniform sampler2D texture;
uniform sampler2D mask;
uniform sampler2D alpha;
uniform vec4 color;
uniform int type;
#define TYPE_NORMAL 0
#define TYPE_BLEND 1
#define TYPE_MASKED 2
#define TYPE_DIFF 3
#define TYPE_MASKED_COLOR 4
void main()
{
vec4 texelTexture = texture2D(texture, tex_coord);
if (type == TYPE_NORMAL)
{
gl_FragColor = texelTexture;
}
else if (type == TYPE_BLEND)
{
vec4 texelMask = texture2D(mask, mask_coord);
vec4 texelAlpha = texture2D(alpha, alpha_coord);
gl_FragColor = texelTexture;
gl_FragColor.a = 1.0 - (1.0 - floor(texelAlpha.r)) * texelMask.r;
}
else if (type == TYPE_MASKED)
{
vec4 texelMask = texture2D(mask, mask_coord);
gl_FragColor = texelTexture;
gl_FragColor.a = 1.0 - texelMask.r;
}
else if (type == TYPE_DIFF)
{
vec4 texelMask = texture2D(mask, mask_coord);
float alpha = 1.0 - abs(texelTexture.r - texelMask.r);
if (alpha > 0.0)
gl_FragColor = texelMask / alpha;
gl_FragColor.a = alpha;
}
else if (type == TYPE_MASKED_COLOR)
{
#ifdef USE_VERTEX_COLORS
gl_FragColor = vertex_color;
#else
gl_FragColor = color;
#endif
gl_FragColor.a = 1.0 - texelTexture.r;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,43 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
attribute vec4 position;
attribute vec2 tex_coord_in;
attribute vec2 mask_coord_in;
attribute vec2 alpha_coord_in;
#ifdef USE_VERTEX_COLORS
attribute vec4 vertex_color_in;
#endif
varying vec2 tex_coord;
varying vec2 mask_coord;
varying vec2 alpha_coord;
#ifdef USE_VERTEX_COLORS
varying vec4 vertex_color;
#endif
uniform mat4 mvp;
uniform mat4 transform;
uniform int type;
void main()
{
gl_Position = mvp * transform * position;
tex_coord = tex_coord_in;
mask_coord = mask_coord_in;
alpha_coord = alpha_coord_in;
#ifdef USE_VERTEX_COLORS
vertex_color = vertex_color_in / 255.0;
#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,76 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
attribute vec2 position;
attribute vec4 extrusion_vectors;
#ifdef USE_VERTEX_COLORS
attribute vec4 vertex_color_in;
#endif
varying float fade_factor; // fade factor for anti-aliasing
varying float multiply;
#ifdef USE_VERTEX_COLORS
varying vec4 vertex_color;
#endif
uniform float line_width;
uniform float feather; // width where we fade the line
uniform mat4 mvp;
#define TYPE_NORMAL 0
#define TYPE_LINE 1
uniform int type;
void main()
{
vec2 extrusion_vector = extrusion_vectors.xy;
float render_thickness = 0.0;
if (type == TYPE_LINE)
{
// miter factor to additionally lengthen the distance of vertex (needed for miter)
// if 1.0 - miter_factor has no effect
float miter_factor = 1.0 / abs(extrusion_vectors.z);
// fade factor is always -1.0 or 1.0 -> we transport that info together with length
fade_factor = sign(extrusion_vectors.z);
#ifdef USE_VERTEX_COLORS
float the_feather = (1.0 + sign(extrusion_vectors.w)) / 4.0;
float the_line_width = abs(extrusion_vectors.w);
#else
float the_feather = feather;
float the_line_width = line_width;
#endif
render_thickness = (the_line_width * miter_factor + the_feather * 2.0 * miter_factor);
// Calculate the multiplier so we can transform the 0->1 fade factor
// to take feather and line width into account.
float start = mix(0.0, (the_line_width / 2.0) - the_feather, the_feather * 2.0);
float end = mix(1.0, (the_line_width / 2.0) + the_feather, the_feather * 2.0);
multiply = 1.0 / (1.0 - (start / end));
}
// lengthen the vertex in direction of the extrusion vector by line width.
vec4 final_position = vec4(position + (extrusion_vector * (render_thickness / 2.0) ), 0.0, 1.0);
gl_Position = mvp * final_position;
#ifdef USE_VERTEX_COLORS
vertex_color = vertex_color_in / 255.0;
#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,30 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* TODO Use textureOffset for newest version of GLSL */
#version 130
uniform sampler2D sampler;
uniform vec2 offsets[16];
uniform float kernel[16];
varying vec2 tex_coord;
void main(void)
{
vec4 sum = texture2D(sampler, tex_coord.st) * kernel[0];
for (int i = 1; i < 16; i++) {
sum += texture2D(sampler, tex_coord.st - offsets[i]) * kernel[i];
sum += texture2D(sampler, tex_coord.st + offsets[i]) * kernel[i];
}
gl_FragColor = sum;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,30 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
/*precision mediump float;*/
varying vec2 tex_coord;
varying vec2 mask_coord;
uniform sampler2D texture; /* white background */
uniform sampler2D mask; /* black background */
void main()
{
float alpha;
vec4 texel0, texel1;
texel0 = texture2D(texture, tex_coord);
texel1 = texture2D(mask, mask_coord);
alpha = 1.0 - abs(texel0.r - texel1.r);
if(alpha > 0.0)
gl_FragColor = texel1 / alpha;
gl_FragColor.a = alpha;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#version 120
uniform sampler2D leavingSlideTexture;
uniform sampler2D enteringSlideTexture;
uniform sampler2D permTexture;
uniform float time;
varying vec2 v_texturePosition;
float snoise(vec2 P) {
return texture2D(permTexture, P).r;
}
void main() {
float sn = snoise(10.0*v_texturePosition);
if( sn < time)
gl_FragColor = texture2D(enteringSlideTexture, v_texturePosition);
else
gl_FragColor = texture2D(leavingSlideTexture, v_texturePosition);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,20 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
attribute vec4 position;
uniform mat4 mvp;
void main() {
gl_Position = mvp * position;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,17 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
varying vec2 v_textureCoords2d;
void main(void)
{
gl_Position = ftransform();
v_textureCoords2d = gl_MultiTexCoord0.st;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,35 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform sampler2D leavingSlideTexture;
uniform sampler2D enteringSlideTexture;
uniform float time;
varying vec2 v_texturePosition;
void main() {
#ifdef use_white
vec4 color = vec4(1.0, 1.0, 1.0, 1.0);
#else
vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
#endif
vec4 texel;
float amount;
if (time < 0.5) {
texel = texture2D(leavingSlideTexture, v_texturePosition);
amount = time * 2;
} else {
texel = texture2D(enteringSlideTexture, v_texturePosition);
amount = (1.0 - time) * 2;
}
gl_FragColor = mix(texel, color, amount);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,23 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform sampler2D leavingSlideTexture;
uniform sampler2D enteringSlideTexture;
uniform float time;
varying vec2 v_texturePosition;
void main() {
vec4 leavingFragment = texture2D(leavingSlideTexture, v_texturePosition);
vec4 enteringFragment = texture2D(enteringSlideTexture, v_texturePosition);
gl_FragColor = mix(leavingFragment, enteringFragment, time);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,36 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
#define M_PI 3.1415926535897932384626433832795
uniform sampler2D leavingSlideTexture;
uniform sampler2D enteringSlideTexture;
varying vec2 v_texturePosition;
varying vec3 v_normal;
uniform float time;
varying float angle;
void main() {
vec3 lightVector = vec3(0.0, 0.0, 1.0);
float light = dot(lightVector, v_normal);
vec4 fragment;
if (angle < M_PI)
fragment = texture2D(leavingSlideTexture, v_texturePosition);
else
fragment = texture2D(enteringSlideTexture, v_texturePosition);
vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
gl_FragColor = mix(black, fragment, max(light, 0.0));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,128 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
#define M_PI 3.1415926535897932384626433832795
attribute vec3 a_position;
attribute vec3 a_normal;
uniform mat4 u_projectionMatrix;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_sceneTransformMatrix;
uniform mat4 u_primitiveTransformMatrix;
uniform mat4 u_operationsTransformMatrix;
varying vec2 v_texturePosition;
varying vec3 v_normal;
attribute vec3 center;
uniform float time;
uniform ivec2 numTiles;
uniform sampler2D permTexture;
varying float angle;
#if __VERSION__ < 140
mat4 inverse(mat4 m)
{
float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
float b00 = a00 * a11 - a01 * a10;
float b01 = a00 * a12 - a02 * a10;
float b02 = a00 * a13 - a03 * a10;
float b03 = a01 * a12 - a02 * a11;
float b04 = a01 * a13 - a03 * a11;
float b05 = a02 * a13 - a03 * a12;
float b06 = a20 * a31 - a21 * a30;
float b07 = a20 * a32 - a22 * a30;
float b08 = a20 * a33 - a23 * a30;
float b09 = a21 * a32 - a22 * a31;
float b10 = a21 * a33 - a23 * a31;
float b11 = a22 * a33 - a23 * a32;
float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
return mat4(
a11 * b11 - a12 * b10 + a13 * b09,
a02 * b10 - a01 * b11 - a03 * b09,
a31 * b05 - a32 * b04 + a33 * b03,
a22 * b04 - a21 * b05 - a23 * b03,
a12 * b08 - a10 * b11 - a13 * b07,
a00 * b11 - a02 * b08 + a03 * b07,
a32 * b02 - a30 * b05 - a33 * b01,
a20 * b05 - a22 * b02 + a23 * b01,
a10 * b10 - a11 * b08 + a13 * b06,
a01 * b08 - a00 * b10 - a03 * b06,
a30 * b04 - a31 * b02 + a33 * b00,
a21 * b02 - a20 * b04 - a23 * b00,
a11 * b07 - a10 * b09 - a12 * b06,
a00 * b09 - a01 * b07 + a02 * b06,
a31 * b01 - a30 * b03 - a32 * b00,
a20 * b03 - a21 * b01 + a22 * b00) / det;
}
#endif
float snoise(vec2 p)
{
return texture2D(permTexture, p).r;
}
mat4 translationMatrix(vec3 axis)
{
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
axis.x, axis.y, axis.z, 1.0);
}
mat4 rotationMatrix(vec3 axis, float angle)
{
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
0.0, 0.0, 0.0, 1.0);
}
void main( void )
{
vec2 pos = (center.xy + 1.0) / 2.0;
// 0..1 pseudo-random value used to randomize the tiles start time.
float fuzz = snoise(pos);
float startTime = pos.x * 0.5 + fuzz * 0.25;
float endTime = startTime + 0.25;
// Scale the transition time to minimize the time a tile will stay black.
float transitionTime = clamp((time - startTime) / (endTime - startTime), 0.0, 1.0);
if (transitionTime < 0.5)
transitionTime = transitionTime / 2.0;
else
transitionTime = (transitionTime / 2.0) + 0.5;
angle = transitionTime * M_PI * 2.0;
mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
mat4 transformMatrix = translationMatrix(center) * rotationMatrix(vec3(0.0, 1.0, 0.0), angle) * translationMatrix(-center);
mat3 normalMatrix = mat3(transpose(inverse(transformMatrix)));
gl_Position = u_projectionMatrix * modelViewMatrix * transformMatrix * vec4(a_position, 1.0);
v_texturePosition = vec2((a_position.x + 1.0) / 2.0, (1.0 - a_position.y) / 2.0);
v_normal = normalize(normalMatrix * a_normal);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,20 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
varying vec2 tex_coord;
uniform sampler2D sampler;
void main() {
vec4 texel = texture2D(sampler, tex_coord);
gl_FragColor = vec4(vec3(dot(texel.rgb, vec3(0.301, 0.591, 0.108))), 1.0);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,108 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 150
in vec2 texturePosition;
in float fuzz;
in vec2 v_center;
in vec3 normal;
in vec4 shadowCoordinate;
uniform sampler2D slideTexture;
uniform sampler2D colorShadowTexture;
uniform sampler2D depthShadowTexture;
uniform float selectedTexture;
uniform float time;
uniform float hexagonSize;
bool isBorder(vec2 point)
{
return point.x < 0.02 || point.x > 0.98 || point.y < 0.02 || point.y > 0.98;
}
void main()
{
const vec2 samplingPoints[9] = vec2[](
vec2(0, 0),
vec2(-1, -1),
vec2(-1, 0),
vec2(-1, 1),
vec2(0, 1),
vec2(1, 1),
vec2(1, 0),
vec2(1, -1),
vec2(0, -1)
);
vec4 fragment = vec4(texture(slideTexture, texturePosition).rgb, 1.0);
vec3 lightVector = vec3(0.0, 0.0, 1.0);
float light = max(dot(lightVector, normal), 0.0);
if (hexagonSize > 1.0) {
// The space in-between hexagons.
if (selectedTexture > 0.5)
fragment.a = 1.0 - time * 8 + gl_FragCoord.x / 1024.;
else
fragment.a = time * 8 - 7.3 + gl_FragCoord.x / 1024.;
} else {
// The hexagons themselves.
float startTime;
float actualTime;
if (selectedTexture > 0.5) {
// Leaving slide.
if (isBorder(v_center))
// If the center is “outside” of the canvas, clear it first.
startTime = 0.15;
else
startTime = 0.15 + fuzz * 0.4;
float endTime = startTime + 0.05;
actualTime = 1.0 - clamp((time - startTime) / (endTime - startTime), 0, 1);
} else {
// Entering slide.
if (isBorder(v_center))
// If the center is “outside” of the canvas, clear it first.
startTime = 0.85;
else
startTime = 0.3 + fuzz * 0.4;
float endTime = startTime + 0.05;
actualTime = clamp((time - startTime) / (endTime - startTime), 0, 1);
if (time < 0.8)
actualTime *= time / 0.8;
}
if (selectedTexture > 0.5) {
// Leaving texture needs to be transparent to see-through.
fragment.a = actualTime;
} else {
// Entering one though, would look weird with transparency.
fragment.rgb *= actualTime;
}
}
// Compute the shadow.
float visibility = 1.0;
const float epsilon = 0.0001;
if (selectedTexture < 0.5) {
float depthShadow = texture(depthShadowTexture, shadowCoordinate.xy).z;
float shadowRadius = (1.0 / (shadowCoordinate.z - depthShadow)) * 1000.0;
// Only the entering slide.
for (int i = 0; i < 9; ++i) {
vec2 coordinate = shadowCoordinate.xy + samplingPoints[i] / shadowRadius;
if (depthShadow < shadowCoordinate.z - epsilon) {
visibility -= 0.05 * texture(colorShadowTexture, coordinate).a;
}
}
}
vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
gl_FragColor = mix(black, fragment, visibility * light);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,111 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 150
layout(triangles) in;
layout(triangle_strip, max_vertices=27) out;
in mat4 projectionMatrix[];
in mat4 modelViewMatrix[];
in mat4 shadowMatrix[];
uniform float hexagonSize;
uniform sampler2D permTexture;
out vec2 texturePosition;
out float fuzz;
out vec2 v_center;
out vec3 normal;
out vec4 shadowCoordinate;
const float expandFactor = 0.0318;
float snoise(vec2 p)
{
return texture(permTexture, p).r;
}
mat4 identityMatrix(void)
{
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
}
mat4 scaleMatrix(vec3 axis)
{
mat4 matrix = identityMatrix();
matrix[0][0] = axis.x;
matrix[1][1] = axis.y;
matrix[2][2] = axis.z;
return matrix;
}
mat4 translationMatrix(vec3 axis)
{
mat4 matrix = identityMatrix();
matrix[3] = vec4(axis, 1.0);
return matrix;
}
void emitHexagonVertex(vec3 center, vec2 translation)
{
vec4 pos = vec4(center + hexagonSize * expandFactor * vec3(translation, 0.0), 1.0);
gl_Position = projectionMatrix[0] * modelViewMatrix[0] * pos;
shadowCoordinate = translationMatrix(vec3(0.5, 0.5, 0.5)) * scaleMatrix(vec3(0.5, 0.5, 0.5)) * shadowMatrix[0] * modelViewMatrix[0] * pos;
texturePosition = vec2((pos.x + 1), (1 - pos.y)) / 2;
EmitVertex();
}
void main()
{
const vec2 translateVectors[6] = vec2[](
vec2(-3, -2),
vec2(0, -4),
vec2(3, -2),
vec2(3, 2),
vec2(0, 4),
vec2(-3, 2)
);
vec3 center = gl_in[0].gl_Position.xyz;
v_center = (1 + center.xy) / 2;
fuzz = snoise(center.xy);
// Draw “walls” to the hexagons.
if (hexagonSize < 1.0) {
vec3 rearCenter = vec3(center.xy, -0.3);
normal = vec3(0.0, 0.0, 0.3);
emitHexagonVertex(center, translateVectors[5]);
emitHexagonVertex(rearCenter, translateVectors[5]);
for (int i = 0; i < 6; ++i) {
emitHexagonVertex(center, translateVectors[i]);
emitHexagonVertex(rearCenter, translateVectors[i]);
}
EndPrimitive();
}
// Draw the main hexagon part.
normal = vec3(0.0, 0.0, 1.0);
emitHexagonVertex(center, translateVectors[5]);
for (int i = 0; i < 6; ++i) {
emitHexagonVertex(center, translateVectors[i]);
emitHexagonVertex(center, vec2(0.0, 0.0));
}
EndPrimitive();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,118 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 150
#define M_PI 3.1415926535897932384626433832795
in vec3 a_position;
uniform mat4 u_projectionMatrix;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_sceneTransformMatrix;
uniform mat4 u_primitiveTransformMatrix;
uniform mat4 u_operationsTransformMatrix;
uniform float time;
uniform float selectedTexture;
uniform float shadow;
uniform mat4 orthoProjectionMatrix;
uniform mat4 orthoViewMatrix;
// Workaround for Intel's Windows driver, to prevent optimisation breakage.
uniform float zero;
out mat4 projectionMatrix;
out mat4 modelViewMatrix;
out mat4 shadowMatrix;
mat4 identityMatrix(void)
{
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
}
mat4 translationMatrix(vec3 axis)
{
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
axis.x, axis.y, axis.z, 1.0);
}
mat4 scaleMatrix(vec3 axis)
{
return mat4(axis.x, 0.0, 0.0, 0.0,
0.0, axis.y, 0.0, 0.0,
0.0, 0.0, axis.z, 0.0,
0.0, 0.0, 0.0, 1.0);
}
mat4 rotationMatrix(vec3 axis, float angle)
{
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
0.0, 0.0, 0.0, 1.0);
}
void main( void )
{
mat4 nmodelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
mat4 transformMatrix = identityMatrix();
// TODO: use the aspect ratio of the slide instead.
mat4 slideScaleMatrix = scaleMatrix(vec3(0.75, 1, 1));
mat4 invertSlideScaleMatrix = scaleMatrix(1.0 / vec3(0.75, 1, 1));
// These ugly zero comparisons are a workaround for Intel's Windows driver optimisation bug.
if (selectedTexture > 0.5) {
// Leaving texture
if (zero < 1.0)
transformMatrix = invertSlideScaleMatrix * transformMatrix;
if (zero < 2.0)
transformMatrix = rotationMatrix(vec3(0.0, 0.0, 1.0), -pow(time, 3) * M_PI) * transformMatrix;
if (zero < 3.0)
transformMatrix = slideScaleMatrix * transformMatrix;
if (zero < 4.0)
transformMatrix = scaleMatrix(vec3(1 + pow(2 * time, 2.1), 1 + pow(2 * time, 2.1), 0)) * transformMatrix;
if (zero < 5.0)
transformMatrix = translationMatrix(vec3(0, 0, 6 * time)) * transformMatrix;
} else {
// Entering texture
if (zero < 1.0)
transformMatrix = invertSlideScaleMatrix * transformMatrix;
if (zero < 2.0)
transformMatrix = rotationMatrix(vec3(0.0, 0.0, 1.0), pow(0.8 * (time - 1.0), 2.0) * M_PI) * transformMatrix;
if (zero < 3.0)
transformMatrix = slideScaleMatrix * transformMatrix;
if (zero < 4.0)
transformMatrix = translationMatrix(vec3(0, 0, 28 * (sqrt(time) - 1))) * transformMatrix;
}
if (shadow < 0.5) {
projectionMatrix = u_projectionMatrix;
shadowMatrix = orthoProjectionMatrix * orthoViewMatrix;
} else {
projectionMatrix = orthoProjectionMatrix * orthoViewMatrix;
shadowMatrix = mat4(0.0);
}
modelViewMatrix = nmodelViewMatrix * transformMatrix;
gl_Position = vec4(a_position, 1.0);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,25 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
/*precision mediump float;*/
void main() {
vec2 tex_mod = mod(gl_FragCoord, 2).xy;
bool bLeft = (tex_mod.x > 0.0) && (tex_mod.x < 1.0);
bool bTop = (tex_mod.y > 0.0) && (tex_mod.y < 1.0);
// horrors - where is the XOR operator ?
if ((bTop && bLeft) || (!bTop && !bLeft))
gl_FragColor = vec4(255,255,255,0);
else
gl_FragColor = vec4(0,0,0,0);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
varying float fade_factor; // 0->1 fade factor used for AA
uniform vec4 color;
uniform float line_width;
uniform float feather;
void main()
{
float start = (line_width / 2.0) - feather; // where we start to apply alpha
float end = (line_width / 2.0) + feather; // where we end to apply alpha
// Calculate the multiplier so we can transform the 0->1 fade factor
// to take feather and line width into account.
float multiplied = 1.0 / (1.0 - (start / end));
float dist = (1.0 - abs(fade_factor)) * multiplied;
float alpha = clamp(dist, 0.0, 1.0);
// modify the alpha channel only
vec4 result_color = color;
result_color.a = result_color.a * alpha;
gl_FragColor = result_color;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,37 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
attribute vec2 position;
attribute vec4 extrusion_vectors;
varying float fade_factor; // fade factor for anti-aliasing
uniform float line_width;
uniform float feather; // width where we fade the line
uniform mat4 mvp;
void main()
{
vec2 extrusion_vector = extrusion_vectors.xy;
// miter factor to additionally lengthen the distance of vertex (needed for miter)
// if 1.0 - miter_factor has no effect
float miter_factor = 1.0f / abs(extrusion_vectors.z);
// fade factor is always -1.0 or 1.0 -> we transport that info together with length
fade_factor = sign(extrusion_vectors.z);
float rendered_thickness = (line_width + feather * 2.0) * miter_factor;
// lengthen the vertex in direction of the extrusion vector by line width.
vec4 position = vec4(position + (extrusion_vector * (rendered_thickness / 2.0) ), 0.0, 1.0);
gl_Position = mvp * position;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,23 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform vec4 start_color;
uniform vec4 end_color;
uniform mat3x3 transform;
varying vec2 tex_coord;
void main(void)
{
gl_FragColor = mix(end_color, start_color,
clamp(tex_coord.t, 0.0, 1.0));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform int i_nColors;
uniform sampler1D t_colorArray4d;
uniform sampler1D t_stopArray1d;
uniform mat3x2 m_transform;
varying vec2 v_textureCoords2d;
int max(int x, int y)
{
if(x > y)
return x;
return y;
}
int findBucket(float t)
{
int nMinBucket=0;
while( nMinBucket < i_nColors &&
texture1D(t_stopArray1d, nMinBucket).s < t )
++nMinBucket;
return max(nMinBucket-1,0);
}
void main(void)
{
float fAlpha =
clamp( (m_transform * vec3(v_textureCoords2d,1)).s,
0.0, 1.0 );
int nMinBucket = findBucket( fAlpha );
float fLerp =
(fAlpha-texture1D(t_stopArray1d, nMinBucket).s) /
(texture1D(t_stopArray1d, nMinBucket+1).s -
texture1D(t_stopArray1d, nMinBucket).s);
gl_FragColor = mix(texture1D(t_colorArray4d, nMinBucket),
texture1D(t_colorArray4d, nMinBucket+1),
fLerp);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,26 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform vec4 v_startColor4d;
uniform vec4 v_endColor4d;
uniform mat3x2 m_transform;
varying vec2 v_textureCoords2d;
void main(void)
{
gl_FragColor = mix(v_startColor4d,
v_endColor4d,
clamp(
(m_transform * vec3(v_textureCoords2d,1)).s,
0.0, 1.0));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,23 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
varying vec2 tex_coord;
uniform sampler2D sampler;
uniform vec4 color;
void main() {
vec4 texel0;
texel0 = texture2D(sampler, tex_coord);
gl_FragColor = color;
gl_FragColor.a = 1.0 - texel0.r;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,27 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
/*precision mediump float;*/
varying vec2 tex_coord;
varying vec2 mask_coord;
uniform sampler2D sampler;
uniform sampler2D mask;
void main()
{
vec4 texel0, texel1;
texel0 = texture2D(sampler, tex_coord);
texel1 = texture2D(mask, mask_coord);
gl_FragColor = texel0;
gl_FragColor.a = 1.0 - texel1.r;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,26 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
attribute vec4 position;
attribute vec2 tex_coord_in;
attribute vec2 mask_coord_in;
varying vec2 tex_coord;
varying vec2 mask_coord;
uniform mat4 mvp;
void main()
{
gl_Position = mvp * position;
tex_coord = tex_coord_in;
mask_coord = mask_coord_in;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,23 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform vec4 start_color;
uniform vec4 end_color;
uniform vec2 center;
varying vec2 tex_coord;
void main(void)
{
gl_FragColor = mix(end_color, start_color,
clamp(distance(tex_coord, center), 0.0, 1.0));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,55 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform int i_nColors;
uniform sampler1D t_colorArray4d;
uniform sampler1D t_stopArray1d;
uniform mat3x2 m_transform;
varying vec2 v_textureCoords2d;
const vec2 v_center2d = vec2(0,0);
int max(int x, int y)
{
if(x > y)
return x;
return y;
}
int findBucket(float t)
{
int nMinBucket=0;
while( nMinBucket < i_nColors &&
texture1D(t_stopArray1d, nMinBucket).s < t )
++nMinBucket;
return max(nMinBucket-1,0);
}
void main(void)
{
float fAlpha =
clamp( 1.0 - distance(
vec2( m_transform * vec3(v_textureCoords2d,1)),
v_center2d),
0.0, 1.0 );
int nMinBucket=findBucket( fAlpha );
float fLerp =
(fAlpha-texture1D(t_stopArray1d, nMinBucket).s) /
(texture1D(t_stopArray1d, nMinBucket+1).s -
texture1D(t_stopArray1d, nMinBucket).s);
gl_FragColor = mix(texture1D(t_colorArray4d, nMinBucket),
texture1D(t_colorArray4d, nMinBucket+1),
fLerp);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,28 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform vec4 v_startColor4d;
uniform vec4 v_endColor4d;
uniform mat3x2 m_transform;
varying vec2 v_textureCoords2d;
const vec2 v_center2d = vec2(0,0);
void main(void)
{
gl_FragColor = mix(v_startColor4d,
v_endColor4d,
1.0 - distance(
vec2(
m_transform * vec3(v_textureCoords2d,1)),
v_center2d));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform int i_nColors;
uniform sampler1D t_colorArray4d;
uniform sampler1D t_stopArray1d;
uniform mat3x2 m_transform;
varying vec2 v_textureCoords2d;
int max(int x, int y)
{
if(x > y)
return x;
return y;
}
int findBucket(float t)
{
int nMinBucket=0;
while( nMinBucket < i_nColors &&
texture1D(t_stopArray1d, nMinBucket).s < t )
++nMinBucket;
return max(nMinBucket-1,0);
}
void main(void)
{
vec2 v = abs( vec2(m_transform * vec3(v_textureCoords2d,1)) );
float fAlpha = 1 - max(v.x, v.y);
int nMinBucket=findBucket( fAlpha );
float fLerp =
(fAlpha-texture1D(t_stopArray1d, nMinBucket).s) /
(texture1D(t_stopArray1d, nMinBucket+1).s -
texture1D(t_stopArray1d, nMinBucket).s);
gl_FragColor = mix(texture1D(t_colorArray4d, nMinBucket),
texture1D(t_colorArray4d, nMinBucket+1),
fLerp);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,25 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform vec4 v_startColor4d;
uniform vec4 v_endColor4d;
uniform mat3x2 m_transform;
varying vec2 v_textureCoords2d;
void main(void)
{
vec2 v = abs( vec2(m_transform * vec3(v_textureCoords2d,1)) );
float t = max(v.x, v.y);
gl_FragColor = mix(v_startColor4d,
v_endColor4d,
1.0-t);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,34 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
uniform sampler2D slideTexture;
varying float v_isShadow;
varying vec2 v_texturePosition;
varying vec3 v_normal;
void main() {
vec3 lightVector = vec3(0.0, 0.0, 1.0);
float light = max(dot(lightVector, v_normal), 0.0);
vec4 fragment = texture2D(slideTexture, v_texturePosition);
vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
fragment = mix(black, fragment, light);
if (v_isShadow > 0.5) {
if (v_texturePosition.y > 1.0 - 0.3)
gl_FragColor = mix(fragment, vec4(0.0, 0.0, 0.0, 0.0), (1.0 - v_texturePosition.y) / 0.3);
else
discard;
} else {
gl_FragColor = fragment;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,79 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_texCoord;
uniform mat4 u_projectionMatrix;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_sceneTransformMatrix;
uniform mat4 u_primitiveTransformMatrix;
uniform mat4 u_operationsTransformMatrix;
varying vec2 v_texturePosition;
varying vec3 v_normal;
varying float v_isShadow;
#if __VERSION__ < 140
mat4 inverse(mat4 m)
{
float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
float b00 = a00 * a11 - a01 * a10;
float b01 = a00 * a12 - a02 * a10;
float b02 = a00 * a13 - a03 * a10;
float b03 = a01 * a12 - a02 * a11;
float b04 = a01 * a13 - a03 * a11;
float b05 = a02 * a13 - a03 * a12;
float b06 = a20 * a31 - a21 * a30;
float b07 = a20 * a32 - a22 * a30;
float b08 = a20 * a33 - a23 * a30;
float b09 = a21 * a32 - a22 * a31;
float b10 = a21 * a33 - a23 * a31;
float b11 = a22 * a33 - a23 * a32;
float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
return mat4(
a11 * b11 - a12 * b10 + a13 * b09,
a02 * b10 - a01 * b11 - a03 * b09,
a31 * b05 - a32 * b04 + a33 * b03,
a22 * b04 - a21 * b05 - a23 * b03,
a12 * b08 - a10 * b11 - a13 * b07,
a00 * b11 - a02 * b08 + a03 * b07,
a32 * b02 - a30 * b05 - a33 * b01,
a20 * b05 - a22 * b02 + a23 * b01,
a10 * b10 - a11 * b08 + a13 * b06,
a01 * b08 - a00 * b10 - a03 * b06,
a30 * b04 - a31 * b02 + a33 * b00,
a21 * b02 - a20 * b04 - a23 * b00,
a11 * b07 - a10 * b09 - a12 * b06,
a00 * b09 - a01 * b07 + a02 * b06,
a31 * b01 - a30 * b03 - a32 * b00,
a20 * b03 - a21 * b01 + a22 * b00) / det;
}
#endif
void main( void )
{
mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
mat3 normalMatrix = mat3(transpose(inverse(modelViewMatrix)));
gl_Position = u_projectionMatrix * modelViewMatrix * vec4(a_position, 1.0);
v_texturePosition = a_texCoord;
v_normal = normalize(normalMatrix * a_normal);
v_isShadow = float(gl_VertexID >= 6);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,25 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
varying vec2 tex_coord;
uniform sampler2D sampler;
uniform vec4 search_color;
uniform vec4 replace_color;
uniform float epsilon;
void main() {
vec4 texel = texture2D(sampler, tex_coord);
vec4 diff = clamp(abs(texel - search_color) - epsilon, 0.0, 1.0);
float bump = max(0.0, 1.0 - ceil(diff.x + diff.y + diff.z));
gl_FragColor = texel + bump * (replace_color - search_color);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,57 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
#define M_PI 3.1415926535897932384626433832795
uniform sampler2D leavingSlideTexture;
uniform sampler2D enteringSlideTexture;
uniform float time;
uniform vec2 center;
uniform float slideRatio;
varying vec2 v_texturePosition;
// This function returns the distance between two points, taking into account the slide ratio.
float betterDistance(vec2 p1, vec2 p2)
{
p1.x *= slideRatio;
p2.x *= slideRatio;
return distance(p1, p2);
}
void main()
{
const float w = 0.5;
const float v = 0.1;
// Distance from this fragment to the center, in slide coordinates.
float dist = betterDistance(center, v_texturePosition);
// We want the ripple to span all of the slide at the end of the transition.
float t = time * (sqrt(2.0) * (slideRatio < 1.0 ? 1.0 / slideRatio : slideRatio));
// Interpolate the distance to the center in function of the time.
float mixed = smoothstep(t*w-v, t*w+v, dist);
// Get the displacement offset from the current pixel, for fragments that have been touched by the ripple already.
vec2 offset = (v_texturePosition - center) * (sin(dist * 64.0 - time * 16.0) + 0.5) / 32.0;
vec2 wavyTexCoord = mix(v_texturePosition + offset, v_texturePosition, time);
// Get the final position we will sample from.
vec2 pos = mix(wavyTexCoord, v_texturePosition, mixed);
// Sample from the textures and mix that together.
vec4 leaving = texture2D(leavingSlideTexture, pos);
vec4 entering = texture2D(enteringSlideTexture, pos);
gl_FragColor = mix(entering, leaving, mixed);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,19 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
/*precision mediump float;*/
uniform vec4 color;
void main() {
gl_FragColor = color;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#version 120
uniform sampler2D leavingSlideTexture;
uniform sampler2D enteringSlideTexture;
uniform sampler2D permTexture;
uniform float time;
varying vec2 v_texturePosition;
float snoise(vec2 P) {
return texture2D(permTexture, P).r;
}
#define PART 0.5
#define START 0.4
#define END 0.9
void main() {
float sn = snoise(10.0*v_texturePosition+time*0.07);
if( time < PART ) {
float sn1 = snoise(vec2(time*15.0, 20.0*v_texturePosition.y));
float sn2 = snoise(v_texturePosition);
if (sn1 > 1.0 - time*time && sn2 < 2.0*time+0.1)
gl_FragColor = vec4(sn, sn, sn, 1.0);
else if (time > START )
gl_FragColor = ((time-START)/(PART - START))*vec4(sn, sn, sn, 1.0) + (1.0 - (time - START)/(PART - START))*texture2D(leavingSlideTexture, v_texturePosition);
else
gl_FragColor = texture2D(leavingSlideTexture, v_texturePosition);
} else if ( time > END ) {
gl_FragColor = ((1.0 - time)/(1.0 - END))*vec4(sn, sn, sn, 1.0) + ((time - END)/(1.0 - END))*texture2D(enteringSlideTexture, v_texturePosition);
} else
gl_FragColor = vec4(sn, sn, sn, 1.0);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,20 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
/* precision mediump float; */
varying vec2 tex_coord;
uniform sampler2D sampler;
void main() {
gl_FragColor = texture2D(sampler, tex_coord);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,22 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
attribute vec4 position;
attribute vec2 tex_coord_in;
varying vec2 tex_coord;
uniform mat4 mvp;
void main() {
gl_Position = mvp * position;
tex_coord = tex_coord_in;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,28 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 130
attribute vec4 position;
attribute vec2 tex_coord_in;
attribute vec2 mask_coord_in;
uniform vec2 viewport;
uniform mat4 transform;
uniform mat4 mvp;
varying vec2 tex_coord;
varying vec2 mask_coord;
void main() {
vec4 pos = mvp * transform * position;
gl_Position = pos;
tex_coord = tex_coord_in;
mask_coord = mask_coord_in;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,68 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 150
uniform sampler2D slideTexture;
uniform sampler2D leavingShadowTexture;
uniform sampler2D enteringShadowTexture;
in vec2 v_texturePosition;
in vec3 v_normal;
in vec4 shadowCoordinate;
void main() {
const vec2 samplingPoints[9] = vec2[](
vec2(0, 0),
vec2(-1, -1),
vec2(-1, 0),
vec2(-1, 1),
vec2(0, 1),
vec2(1, 1),
vec2(1, 0),
vec2(1, -1),
vec2(0, -1)
);
// Compute the shadow...
float visibility = 1.0;
const float epsilon = 0.0001;
// for the leaving slide,
{
float depthShadow = texture(leavingShadowTexture, shadowCoordinate.xy).r;
float shadowRadius = (1.0 / (shadowCoordinate.z - depthShadow)) * 1000.0;
for (int i = 0; i < 9; ++i) {
vec2 coordinate = shadowCoordinate.xy + samplingPoints[i] / shadowRadius;
if (texture(leavingShadowTexture, coordinate).r < shadowCoordinate.z - epsilon) {
visibility -= 0.05;
}
}
}
// and for entering slide.
{
float depthShadow = texture(enteringShadowTexture, shadowCoordinate.xy).r;
float shadowRadius = (1.0 / (shadowCoordinate.z - depthShadow)) * 1000.0;
for (int i = 0; i < 9; ++i) {
vec2 coordinate = shadowCoordinate.xy + samplingPoints[i] / shadowRadius;
if (texture(enteringShadowTexture, coordinate).r < shadowCoordinate.z - epsilon) {
visibility -= 0.05;
}
}
}
vec3 lightVector = vec3(0.0, 0.0, 1.0);
float light = max(dot(lightVector, v_normal), 0.0);
vec4 fragment = texture(slideTexture, v_texturePosition);
vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
gl_FragColor = mix(black, fragment, visibility * light);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,116 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 150
layout(triangles) in;
layout(triangle_strip, max_vertices=11) out;
uniform float shadow;
uniform mat4 u_projectionMatrix;
uniform mat4 orthoProjectionMatrix;
uniform mat4 orthoViewMatrix;
in vec2 g_texturePosition[];
in vec3 g_normal[];
in mat4 modelViewMatrix[];
in mat4 transform[];
in float nTime[];
in float startTime[];
in float endTime[];
out vec2 v_texturePosition;
out vec3 v_normal;
out vec4 shadowCoordinate;
mat4 identityMatrix(void)
{
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
}
mat4 scaleMatrix(vec3 axis)
{
mat4 matrix = identityMatrix();
matrix[0][0] = axis.x;
matrix[1][1] = axis.y;
matrix[2][2] = axis.z;
return matrix;
}
mat4 translationMatrix(vec3 axis)
{
mat4 matrix = identityMatrix();
matrix[3] = vec4(axis, 1.0);
return matrix;
}
void emitHexagonVertex(int index, vec3 translation, float fdsq)
{
mat4 projectionMatrix;
mat4 shadowMatrix;
if (shadow < 0.5) {
projectionMatrix = u_projectionMatrix;
shadowMatrix = orthoProjectionMatrix * orthoViewMatrix;
} else {
projectionMatrix = orthoProjectionMatrix * orthoViewMatrix;
shadowMatrix = mat4(0.0);
}
mat4 normalMatrix = transpose(inverse(modelViewMatrix[index]));
vec4 pos = gl_in[index].gl_Position + vec4(translation, 0.0);
// Apply our transform operations.
pos = transform[index] * pos;
v_normal = normalize(vec3(normalMatrix * transform[index] * vec4(g_normal[index], 0.0)));
v_normal.z *= fdsq;
gl_Position = projectionMatrix * modelViewMatrix[index] * pos;
shadowCoordinate = translationMatrix(vec3(0.5, 0.5, 0.5)) * scaleMatrix(vec3(0.5, 0.5, 0.5)) * shadowMatrix * modelViewMatrix[index] * pos;
v_texturePosition = g_texturePosition[index];
EmitVertex();
}
void main()
{
const vec4 invalidPosition = vec4(-256.0, -256.0, -256.0, -256.0);
const vec3 noTranslation = vec3(0.0, 0.0, 0.0);
if (gl_in[0].gl_Position == invalidPosition)
return;
// Draw “walls” to the hexagons.
if (nTime[0] > startTime[0] && nTime[0] <= endTime[0]) {
const vec3 translation = vec3(0.0, 0.0, -0.02);
emitHexagonVertex(2, noTranslation, 0.3);
emitHexagonVertex(2, translation, 0.3);
for (int i = 0; i < 3; ++i) {
emitHexagonVertex(i, noTranslation, 0.3);
emitHexagonVertex(i, translation, 0.3);
}
EndPrimitive();
}
// Draw the main quad part.
for (int i = 0; i < 3; ++i) {
emitHexagonVertex(i, noTranslation, 1.0);
}
EndPrimitive();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,153 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 150
#define M_PI 3.1415926535897932384626433832795
in vec3 a_position;
in vec3 a_normal;
in vec2 a_texCoord;
in float tileInfo;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_sceneTransformMatrix;
uniform mat4 u_primitiveTransformMatrix;
uniform mat4 u_operationsTransformMatrix;
uniform float time;
uniform ivec2 numTiles;
uniform sampler2D permTexture;
uniform float slide;
// Workaround for Intel's Windows driver, to prevent optimisation breakage.
uniform float zero;
out vec2 g_texturePosition;
out vec3 g_normal;
out mat4 modelViewMatrix;
out mat4 transform;
out float nTime;
out float startTime;
out float endTime;
float snoise(vec2 p)
{
return texture(permTexture, p).r;
}
mat4 identityMatrix(void)
{
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
}
mat4 translationMatrix(vec3 axis)
{
mat4 matrix = identityMatrix();
matrix[3] = vec4(axis, 1.0);
return matrix;
}
mat4 rotationMatrix(vec3 axis, float angle)
{
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
0.0, 0.0, 0.0, 1.0);
}
void main( void )
{
// Each tile moves during only half of the transition. The leftmost
// tiles start moving at the start and arrive at their end
// position around time=0.5, when the tiles there (the rightmost
// ones) start moving. (The exact time each tile is moving is
// fuzzed a bit to make a more random appearance.)
// In GLSL 1.20 we don't have any bitwise operators, sigh
int tileXIndex = int(mod(int(tileInfo), 256));
int tileYIndex = int(mod(int(tileInfo) / 256, 256));
// A semi-random number 0..1, different for neighbouring tiles, to know when they should start moving.
float startTimeFuzz = snoise(vec2(float(tileXIndex)/(numTiles.x-1), float(tileYIndex)/(numTiles.y-1)));
// A semi-random number -1.5..1.5, different for neighbouring tiles, to specify their rotation center.
// The additional 0.5 on each side is because we want some tiles to rotate outside.
float rotationFuzz = snoise(vec2(float(numTiles.x + tileXIndex)/(numTiles.x-1), float(tileYIndex)/(numTiles.y-1))) * 3.0 - 1.5;
startTime = float(tileXIndex)/(numTiles.x-1) * 0.2 + startTimeFuzz * 0.2;
endTime = min(startTime + 0.7, 1.0);
bool isLeavingSlide = (slide < 0.5);
const vec4 invalidPosition = vec4(-256.0, -256.0, -256.0, -256.0);
// Dont display the tile before or after its rotation, depending on the slide.
if (!isLeavingSlide)
{
if (time < max(0.3, startTime))
{
gl_Position = invalidPosition;
return;
}
nTime = 1.0 - time;
}
else
{
if (time > endTime)
{
gl_Position = invalidPosition;
return;
}
nTime = time;
}
transform = identityMatrix();
if (nTime > startTime && nTime <= endTime)
{
// We are in the rotation part.
float rotation = (nTime - startTime) / (endTime - startTime);
if (isLeavingSlide)
rotation *= -1.0;
if (rotation < -0.5 || rotation > 0.5) {
gl_Position = invalidPosition;
return;
}
// Translation vector to set the origin of the rotation.
vec3 translationVector = vec3(rotationFuzz, 0.0, 0.0);
// Compute the actual rotation matrix.
// Intel's Windows driver gives a wrong matrix when all operations are done at once.
if (zero < 1.0)
transform = translationMatrix(translationVector) * transform;
if (zero < 2.0)
transform = rotationMatrix(vec3(0.0, 1.0, 0.0), clamp(rotation, -1.0, 1.0) * M_PI) * transform;
if (zero < 3.0)
transform = translationMatrix(-translationVector) * transform;
}
modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
gl_Position = vec4(a_position, 1.0);
g_texturePosition = a_texCoord;
g_normal = a_normal;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */