58 lines
2.0 KiB
GLSL
58 lines
2.0 KiB
GLSL
// 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…
|
|
|
|
precision highp float;
|
|
|
|
uniform mat4 uTransform;
|
|
uniform vec2 uEmboldenAmount;
|
|
uniform ivec2 uPathColorsDimensions;
|
|
uniform sampler2D uPathColors;
|
|
uniform ivec2 uPathTransformSTDimensions;
|
|
uniform sampler2D uPathTransformST;
|
|
uniform ivec2 uPathTransformExtDimensions;
|
|
uniform sampler2D uPathTransformExt;
|
|
|
|
attribute vec2 aPosition;
|
|
attribute vec2 aTexCoord;
|
|
attribute float aPathID;
|
|
attribute float aSign;
|
|
attribute float aNormalAngle;
|
|
|
|
varying vec4 vColor;
|
|
varying vec2 vTexCoord;
|
|
varying float vSign;
|
|
|
|
void main() {
|
|
int pathID = int(aPathID);
|
|
|
|
vec2 pathTransformExt;
|
|
vec4 pathTransformST = fetchPathAffineTransform(pathTransformExt,
|
|
uPathTransformST,
|
|
uPathTransformSTDimensions,
|
|
uPathTransformExt,
|
|
uPathTransformExtDimensions,
|
|
pathID);
|
|
|
|
vec2 position = dilatePosition(aPosition, aNormalAngle, uEmboldenAmount);
|
|
position = transformVertexPositionAffine(position, pathTransformST, pathTransformExt);
|
|
|
|
gl_Position = uTransform * vec4(position, 0.0, 1.0);
|
|
|
|
vColor = fetchFloat4Data(uPathColors, pathID, uPathColorsDimensions);
|
|
vTexCoord = vec2(aTexCoord) / 2.0;
|
|
vSign = aSign;
|
|
}
|