2017-08-11 21:11:57 -04:00
|
|
|
// pathfinder/shaders/gles2/direct-interior.vs.glsl
|
|
|
|
//
|
2017-10-03 18:32:03 -04:00
|
|
|
// 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.
|
2017-08-11 21:11:57 -04:00
|
|
|
|
2017-12-30 20:32:51 -05:00
|
|
|
//! Renders polygonal portions of a mesh.
|
|
|
|
//!
|
|
|
|
//! Typically, you will run this shader before running `direct-curve`.
|
|
|
|
//! Remember to enable the depth test with a `GREATER` depth function for optimal
|
|
|
|
//! performance.
|
|
|
|
|
2017-08-11 21:11:57 -04:00
|
|
|
precision highp float;
|
|
|
|
|
2018-01-04 20:32:20 -05:00
|
|
|
/// A 3D transform to be applied to all points.
|
2017-08-11 21:11:57 -04:00
|
|
|
uniform mat4 uTransform;
|
2018-01-04 20:32:20 -05:00
|
|
|
/// Vertical snapping positions.
|
2017-10-05 22:14:52 -04:00
|
|
|
uniform vec4 uHints;
|
2018-01-04 20:32:20 -05:00
|
|
|
/// The size of the path colors texture in texels.
|
2017-08-11 21:11:57 -04:00
|
|
|
uniform ivec2 uPathColorsDimensions;
|
2018-01-04 20:32:20 -05:00
|
|
|
/// The fill color for each path.
|
2017-08-11 21:11:57 -04:00
|
|
|
uniform sampler2D uPathColors;
|
2018-01-04 20:32:20 -05:00
|
|
|
/// The size of the path transform buffer texture in texels.
|
2017-11-29 13:50:47 -05:00
|
|
|
uniform ivec2 uPathTransformSTDimensions;
|
2018-01-04 20:32:20 -05:00
|
|
|
/// The path transform buffer texture, one path dilation per texel.
|
2017-11-29 13:50:47 -05:00
|
|
|
uniform sampler2D uPathTransformST;
|
2018-01-04 20:32:20 -05:00
|
|
|
/// The size of the extra path transform factors buffer texture in texels.
|
2017-11-29 13:50:47 -05:00
|
|
|
uniform ivec2 uPathTransformExtDimensions;
|
2018-01-04 20:32:20 -05:00
|
|
|
/// The extra path transform factors buffer texture, packed two path transforms per texel.
|
2017-11-29 13:50:47 -05:00
|
|
|
uniform sampler2D uPathTransformExt;
|
2018-01-04 20:32:20 -05:00
|
|
|
/// The amount of faux-bold to apply, in local path units.
|
|
|
|
uniform vec2 uEmboldenAmount;
|
2017-08-11 21:11:57 -04:00
|
|
|
|
|
|
|
attribute vec2 aPosition;
|
2017-08-16 01:09:09 -04:00
|
|
|
attribute float aPathID;
|
2017-11-09 19:20:15 -05:00
|
|
|
attribute float aNormalAngle;
|
2017-08-11 21:11:57 -04:00
|
|
|
|
2018-01-04 21:07:14 -05:00
|
|
|
/// The color of this path.
|
2017-08-11 21:11:57 -04:00
|
|
|
varying vec4 vColor;
|
|
|
|
|
|
|
|
void main() {
|
2017-08-16 01:09:09 -04:00
|
|
|
int pathID = int(aPathID);
|
|
|
|
|
2017-11-29 13:50:47 -05:00
|
|
|
vec2 pathTransformExt;
|
|
|
|
vec4 pathTransformST = fetchPathAffineTransform(pathTransformExt,
|
|
|
|
uPathTransformST,
|
|
|
|
uPathTransformSTDimensions,
|
|
|
|
uPathTransformExt,
|
|
|
|
uPathTransformExtDimensions,
|
|
|
|
pathID);
|
2017-08-22 21:25:32 -04:00
|
|
|
|
2017-11-09 19:20:15 -05:00
|
|
|
vec2 position = dilatePosition(aPosition, aNormalAngle, uEmboldenAmount);
|
|
|
|
position = hintPosition(position, uHints);
|
2017-11-29 13:50:47 -05:00
|
|
|
position = transformVertexPositionAffine(position, pathTransformST, pathTransformExt);
|
2017-08-22 21:25:32 -04:00
|
|
|
position = transformVertexPosition(position, uTransform);
|
|
|
|
|
2017-08-23 22:18:24 -04:00
|
|
|
float depth = convertPathIndexToViewportDepthValue(pathID);
|
2017-08-16 01:09:09 -04:00
|
|
|
gl_Position = vec4(position, depth, 1.0);
|
2017-08-11 21:11:57 -04:00
|
|
|
|
2017-08-16 01:09:09 -04:00
|
|
|
vColor = fetchFloat4Data(uPathColors, pathID, uPathColorsDimensions);
|
2017-08-11 21:11:57 -04:00
|
|
|
}
|