pathfinder/shaders/gles2/direct-3d-curve.vs.glsl

74 lines
2.9 KiB
Plaintext
Raw Normal View History

2017-09-05 22:47:19 -04:00
// pathfinder/shaders/gles2/direct-3d-curve.vs.glsl
//
// Copyright (c) 2017 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! A version of `direct-curve` that takes each vertex's Z value from the
//! transform instead of the path ID.
//!
//! FIXME(pcwalton): For CSS 3D transforms, I think `direct-curve` will need
//! to do what this shader does. Perhaps these two shaders should be unified…
2017-09-05 22:47:19 -04:00
precision highp float;
2018-01-04 21:07:14 -05:00
/// A 3D transform to be applied to all points.
2017-09-05 22:47:19 -04:00
uniform mat4 uTransform;
2018-01-04 21:07:14 -05:00
/// The size of the path transform buffer texture in texels.
uniform ivec2 uPathTransformSTDimensions;
2018-01-04 21:07:14 -05:00
/// The path transform buffer texture, one dilation per path ID.
uniform sampler2D uPathTransformST;
2018-01-04 21:07:14 -05:00
/// The size of the extra path transform factors buffer texture in texels.
uniform ivec2 uPathTransformExtDimensions;
2018-01-04 21:07:14 -05:00
/// The extra path transform factors buffer texture, packed two path transforms per texel.
uniform sampler2D uPathTransformExt;
2018-01-04 21:07:14 -05:00
/// The size of the path colors buffer texture in texels.
uniform ivec2 uPathColorsDimensions;
/// The path colors buffer texture, one color per path ID.
uniform sampler2D uPathColors;
/// The amount of faux-bold to apply, in local path units.
uniform vec2 uEmboldenAmount;
2017-09-05 22:47:19 -04:00
2018-01-04 21:07:14 -05:00
/// The 2D position of this point.
2017-09-05 22:47:19 -04:00
attribute vec2 aPosition;
2018-01-04 21:07:14 -05:00
/// The abstract Loop-Blinn texture coordinate for this point.
2017-09-05 22:47:19 -04:00
attribute vec2 aTexCoord;
2018-01-04 21:07:14 -05:00
/// The path ID, starting from 1.
2017-09-05 22:47:19 -04:00
attribute float aPathID;
2018-01-04 21:07:14 -05:00
/// Specifies whether this is a concave or convex curve.
2017-09-05 22:47:19 -04:00
attribute float aSign;
2018-01-04 21:07:14 -05:00
/// The angle of the 2D normal for this point.
attribute float aNormalAngle;
2017-09-05 22:47:19 -04:00
2018-01-04 21:07:14 -05:00
/// The fill color of this path.
2017-09-05 22:47:19 -04:00
varying vec4 vColor;
2018-01-04 21:07:14 -05:00
/// The outgoing abstract Loop-Blinn texture coordinate.
2017-09-05 22:47:19 -04:00
varying vec2 vTexCoord;
2018-01-04 21:07:14 -05:00
/// Specifies whether this is a concave or convex curve.
2017-09-05 22:47:19 -04:00
varying float vSign;
void main() {
int pathID = int(aPathID);
vec2 pathTransformExt;
vec4 pathTransformST = fetchPathAffineTransform(pathTransformExt,
uPathTransformST,
uPathTransformSTDimensions,
uPathTransformExt,
uPathTransformExtDimensions,
pathID);
2017-09-05 22:47:19 -04:00
vec2 position = dilatePosition(aPosition, aNormalAngle, uEmboldenAmount);
position = transformVertexPositionAffine(position, pathTransformST, pathTransformExt);
2017-09-05 22:47:19 -04:00
gl_Position = uTransform * vec4(position, 0.0, 1.0);
vColor = fetchFloat4Data(uPathColors, pathID, uPathColorsDimensions);
vTexCoord = vec2(aTexCoord) / 2.0;
vSign = aSign;
}