From f3841ef4022620500be9a175677ff6e1889b3196 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 4 Jan 2018 18:07:14 -0800 Subject: [PATCH] Document more shader parameters --- demo/client/src/xcaa-strategy.ts | 18 ++++----------- shaders/gles2/blit-gamma.fs.glsl | 2 -- shaders/gles2/demo-3d-distant-glyph.fs.glsl | 3 +++ shaders/gles2/demo-3d-distant-glyph.vs.glsl | 3 +++ shaders/gles2/demo-3d-monument.fs.glsl | 7 +++++- shaders/gles2/demo-3d-monument.vs.glsl | 2 ++ shaders/gles2/direct-3d-curve.vs.glsl | 22 ++++++++++++++++--- shaders/gles2/direct-curve.fs.glsl | 3 +++ shaders/gles2/direct-curve.vs.glsl | 8 +++++++ shaders/gles2/direct-interior.fs.glsl | 1 + shaders/gles2/direct-interior.vs.glsl | 1 + shaders/gles2/ecaa-curve.vs.glsl | 8 ++++++- shaders/gles2/ecaa-line.vs.glsl | 10 ++++++--- shaders/gles2/ecaa-transformed-curve.vs.glsl | 6 +++++ shaders/gles2/mcaa.fs.glsl | 3 +++ shaders/gles2/ssaa-subpixel-resolve.fs.glsl | 2 ++ shaders/gles2/xcaa-mono-resolve.fs.glsl | 3 +++ shaders/gles2/xcaa-mono-resolve.vs.glsl | 2 ++ .../gles2/xcaa-mono-subpixel-resolve.fs.glsl | 4 ++++ .../gles2/xcaa-mono-subpixel-resolve.vs.glsl | 2 ++ 20 files changed, 86 insertions(+), 24 deletions(-) diff --git a/demo/client/src/xcaa-strategy.ts b/demo/client/src/xcaa-strategy.ts index 23c54f31..7750d8dd 100644 --- a/demo/client/src/xcaa-strategy.ts +++ b/demo/client/src/xcaa-strategy.ts @@ -764,26 +764,16 @@ export class ECAAStrategy extends XCAAStrategy { if (renderer.meshData[0].segmentLineNormals.byteLength > 0) { gl.bindBuffer(gl.ARRAY_BUFFER, lineNormalsBuffer); - gl.vertexAttribPointer(attributes.aLeftNormalAngle, - 1, + gl.vertexAttribPointer(attributes.aNormalAngles, + 2, gl.FLOAT, false, FLOAT32_SIZE * 2, 0); - gl.vertexAttribPointer(attributes.aRightNormalAngle, - 1, - gl.FLOAT, - false, - FLOAT32_SIZE * 2, - FLOAT32_SIZE); - - gl.enableVertexAttribArray(attributes.aLeftNormalAngle); - gl.enableVertexAttribArray(attributes.aRightNormalAngle); + gl.enableVertexAttribArray(attributes.aNormalAngles); renderContext.instancedArraysExt - .vertexAttribDivisorANGLE(attributes.aLeftNormalAngle, 1); - renderContext.instancedArraysExt - .vertexAttribDivisorANGLE(attributes.aRightNormalAngle, 1); + .vertexAttribDivisorANGLE(attributes.aNormalAngles, 1); } gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, renderContext.quadElementsBuffer); diff --git a/shaders/gles2/blit-gamma.fs.glsl b/shaders/gles2/blit-gamma.fs.glsl index edc41910..08ad8705 100644 --- a/shaders/gles2/blit-gamma.fs.glsl +++ b/shaders/gles2/blit-gamma.fs.glsl @@ -14,10 +14,8 @@ precision mediump float; /// The source texture to blit. uniform sampler2D uSource; - /// The approximate background color, in linear RGB. uniform vec3 uBGColor; - /// The gamma LUT. uniform sampler2D uGammaLUT; diff --git a/shaders/gles2/demo-3d-distant-glyph.fs.glsl b/shaders/gles2/demo-3d-distant-glyph.fs.glsl index a0cb7180..5db91101 100644 --- a/shaders/gles2/demo-3d-distant-glyph.fs.glsl +++ b/shaders/gles2/demo-3d-distant-glyph.fs.glsl @@ -12,9 +12,12 @@ precision highp float; +/// The color of the font. uniform vec4 uColor; +/// The cached glyph atlas. uniform sampler2D uAtlas; +/// The texture coordinate. varying vec2 vTexCoord; void main() { diff --git a/shaders/gles2/demo-3d-distant-glyph.vs.glsl b/shaders/gles2/demo-3d-distant-glyph.vs.glsl index 71ed5c9c..4dc66282 100644 --- a/shaders/gles2/demo-3d-distant-glyph.vs.glsl +++ b/shaders/gles2/demo-3d-distant-glyph.vs.glsl @@ -19,9 +19,12 @@ uniform vec4 uGlyphTexCoords; /// The size of the glyph in local coordinates. uniform vec2 uGlyphSize; +/// The abstract quad position: (0.0, 0.0) to (1.0, 1.0). attribute vec2 aQuadPosition; +// The world-space 2D position of this vertex. attribute vec2 aPosition; +/// The texture coordinate. varying vec2 vTexCoord; void main() { diff --git a/shaders/gles2/demo-3d-monument.fs.glsl b/shaders/gles2/demo-3d-monument.fs.glsl index e4e9457e..8f5e495f 100644 --- a/shaders/gles2/demo-3d-monument.fs.glsl +++ b/shaders/gles2/demo-3d-monument.fs.glsl @@ -12,12 +12,17 @@ precision mediump float; +/// The 3D position of the light. uniform vec3 uLightPosition; +/// The ambient color of the light. uniform vec3 uAmbientColor; +/// The diffuse color of the light. uniform vec3 uDiffuseColor; +/// The Phong specular color of the light. uniform vec3 uSpecularColor; +/// The Phong albedo exponent. uniform float uShininess; - +/// The normal of these vertices. uniform vec3 uNormal; varying vec3 vPosition; diff --git a/shaders/gles2/demo-3d-monument.vs.glsl b/shaders/gles2/demo-3d-monument.vs.glsl index bb8bb5f4..54312ac9 100644 --- a/shaders/gles2/demo-3d-monument.vs.glsl +++ b/shaders/gles2/demo-3d-monument.vs.glsl @@ -17,8 +17,10 @@ uniform mat4 uProjection; /// The 3D modelview matrix. uniform mat4 uModelview; +/// The 3D vertex position. attribute vec3 aPosition; +/// The 3D vertex position. varying vec3 vPosition; void main() { diff --git a/shaders/gles2/direct-3d-curve.vs.glsl b/shaders/gles2/direct-3d-curve.vs.glsl index c59d6a12..1e10446d 100644 --- a/shaders/gles2/direct-3d-curve.vs.glsl +++ b/shaders/gles2/direct-3d-curve.vs.glsl @@ -16,23 +16,39 @@ precision highp float; +/// A 3D transform to be applied to all points. uniform mat4 uTransform; -uniform vec2 uEmboldenAmount; -uniform ivec2 uPathColorsDimensions; -uniform sampler2D uPathColors; +/// The size of the path transform buffer texture in texels. uniform ivec2 uPathTransformSTDimensions; +/// The path transform buffer texture, one dilation per path ID. uniform sampler2D uPathTransformST; +/// The size of the extra path transform factors buffer texture in texels. uniform ivec2 uPathTransformExtDimensions; +/// The extra path transform factors buffer texture, packed two path transforms per texel. uniform sampler2D uPathTransformExt; +/// 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; +/// The 2D position of this point. attribute vec2 aPosition; +/// The abstract Loop-Blinn texture coordinate for this point. attribute vec2 aTexCoord; +/// The path ID, starting from 1. attribute float aPathID; +/// Specifies whether this is a concave or convex curve. attribute float aSign; +/// The angle of the 2D normal for this point. attribute float aNormalAngle; +/// The fill color of this path. varying vec4 vColor; +/// The outgoing abstract Loop-Blinn texture coordinate. varying vec2 vTexCoord; +/// Specifies whether this is a concave or convex curve. varying float vSign; void main() { diff --git a/shaders/gles2/direct-curve.fs.glsl b/shaders/gles2/direct-curve.fs.glsl index 721c8f33..ab0f67f6 100644 --- a/shaders/gles2/direct-curve.fs.glsl +++ b/shaders/gles2/direct-curve.fs.glsl @@ -21,8 +21,11 @@ precision highp float; +/// The fill color of this path. varying vec4 vColor; +/// The abstract Loop-Blinn texture coordinate. varying vec2 vTexCoord; +/// Specifies whether this is a concave or convex curve. varying float vSign; void main() { diff --git a/shaders/gles2/direct-curve.vs.glsl b/shaders/gles2/direct-curve.vs.glsl index 24f6f3df..c0d62363 100644 --- a/shaders/gles2/direct-curve.vs.glsl +++ b/shaders/gles2/direct-curve.vs.glsl @@ -40,14 +40,22 @@ uniform sampler2D uPathTransformExt; /// The amount of faux-bold to apply, in local path units. uniform vec2 uEmboldenAmount; +/// The 2D position of this point. attribute vec2 aPosition; +/// The abstract Loop-Blinn texture coordinate for this point. attribute vec2 aTexCoord; +/// The path ID, starting from 1. attribute float aPathID; +/// Specifies whether this is a concave or convex curve. attribute float aSign; +/// The angle of the 2D normal for this point. attribute float aNormalAngle; +/// The fill color of this path. varying vec4 vColor; +/// The outgoing abstract Loop-Blinn texture coordinate. varying vec2 vTexCoord; +/// Specifies whether this is a concave or convex curve. varying float vSign; void main() { diff --git a/shaders/gles2/direct-interior.fs.glsl b/shaders/gles2/direct-interior.fs.glsl index e8134b68..99b08018 100644 --- a/shaders/gles2/direct-interior.fs.glsl +++ b/shaders/gles2/direct-interior.fs.glsl @@ -16,6 +16,7 @@ precision highp float; +/// The color of this path. varying vec4 vColor; void main() { diff --git a/shaders/gles2/direct-interior.vs.glsl b/shaders/gles2/direct-interior.vs.glsl index ff5ea1c0..3f7de525 100644 --- a/shaders/gles2/direct-interior.vs.glsl +++ b/shaders/gles2/direct-interior.vs.glsl @@ -39,6 +39,7 @@ attribute vec2 aPosition; attribute float aPathID; attribute float aNormalAngle; +/// The color of this path. varying vec4 vColor; void main() { diff --git a/shaders/gles2/ecaa-curve.vs.glsl b/shaders/gles2/ecaa-curve.vs.glsl index db551e53..9daaeae4 100644 --- a/shaders/gles2/ecaa-curve.vs.glsl +++ b/shaders/gles2/ecaa-curve.vs.glsl @@ -26,7 +26,7 @@ precision highp float; -/// A 3D transform to be applied to the object. +/// A 3D transform to be applied to all points. uniform mat4 uTransform; /// Vertical snapping positions. uniform vec4 uHints; @@ -47,11 +47,17 @@ uniform sampler2D uPathTransformExt; /// The amount of faux-bold to apply, in local path units. uniform vec2 uEmboldenAmount; +/// The abstract quad position: (0.0, 0.0) to (1.0, 1.0). attribute vec2 aQuadPosition; +/// The position of the left endpoint. attribute vec2 aLeftPosition; +/// The position of the control point. attribute vec2 aControlPointPosition; +/// The position of the right endpoint. attribute vec2 aRightPosition; +/// The path ID (starting from 1). attribute float aPathID; +/// The normal angles of the left endpoint, control point, and right endpoint, respectively. attribute vec3 aNormalAngles; varying vec4 vEndpoints; diff --git a/shaders/gles2/ecaa-line.vs.glsl b/shaders/gles2/ecaa-line.vs.glsl index 7074cb60..cb0ee5a5 100644 --- a/shaders/gles2/ecaa-line.vs.glsl +++ b/shaders/gles2/ecaa-line.vs.glsl @@ -45,12 +45,16 @@ uniform sampler2D uPathTransformExt; /// The amount of faux-bold to apply, in local path units. uniform vec2 uEmboldenAmount; +/// The abstract quad position: (0.0, 0.0) to (1.0, 1.0). attribute vec2 aQuadPosition; +/// The position of the left endpoint. attribute vec2 aLeftPosition; +/// The position of the right endpoint. attribute vec2 aRightPosition; +/// The path ID (starting from 1). attribute float aPathID; -attribute float aLeftNormalAngle; -attribute float aRightNormalAngle; +/// The normal angles of the left endpoint and right endpoint, respectively. +attribute vec2 aNormalAngles; varying vec4 vEndpoints; varying float vWinding; @@ -59,7 +63,7 @@ void main() { vec2 leftPosition = aLeftPosition; vec2 rightPosition = aRightPosition; int pathID = int(aPathID); - vec2 leftRightNormalAngles = vec2(aLeftNormalAngle, aRightNormalAngle); + vec2 leftRightNormalAngles = aNormalAngles; vec2 pathTransformExt; vec4 pathTransformST = fetchPathAffineTransform(pathTransformExt, diff --git a/shaders/gles2/ecaa-transformed-curve.vs.glsl b/shaders/gles2/ecaa-transformed-curve.vs.glsl index 3d8951f1..5ecf6807 100644 --- a/shaders/gles2/ecaa-transformed-curve.vs.glsl +++ b/shaders/gles2/ecaa-transformed-curve.vs.glsl @@ -56,11 +56,17 @@ uniform vec2 uEmboldenAmount; /// an identical draw call with this value set to 1. uniform int uPassIndex; +/// The abstract quad position: (0.0, 0.0) to (1.0, 1.0). attribute vec2 aQuadPosition; +/// The position of the left endpoint. attribute vec2 aLeftPosition; +/// The position of the control point. attribute vec2 aControlPointPosition; +/// The position of the right endpoint. attribute vec2 aRightPosition; +/// The path ID (starting from 1). attribute float aPathID; +/// The normal angles of the left endpoint, control point, and right endpoint, respectively. attribute vec3 aNormalAngles; varying vec4 vEndpoints; diff --git a/shaders/gles2/mcaa.fs.glsl b/shaders/gles2/mcaa.fs.glsl index c2c4eded..3ad7fae3 100644 --- a/shaders/gles2/mcaa.fs.glsl +++ b/shaders/gles2/mcaa.fs.glsl @@ -25,6 +25,9 @@ precision highp float; +/// True if multiple colors are being rendered; false otherwise. +/// +/// If this is true, then points will be snapped to the nearest pixel. uniform bool uMulticolor; varying vec4 vUpperEndpoints; diff --git a/shaders/gles2/ssaa-subpixel-resolve.fs.glsl b/shaders/gles2/ssaa-subpixel-resolve.fs.glsl index f7fe175d..bbe3386b 100644 --- a/shaders/gles2/ssaa-subpixel-resolve.fs.glsl +++ b/shaders/gles2/ssaa-subpixel-resolve.fs.glsl @@ -14,7 +14,9 @@ precision mediump float; +/// The alpha coverage texture. uniform sampler2D uSource; +/// The dimensions of the alpha coverage texture, in texels. uniform ivec2 uSourceDimensions; varying vec2 vTexCoord; diff --git a/shaders/gles2/xcaa-mono-resolve.fs.glsl b/shaders/gles2/xcaa-mono-resolve.fs.glsl index 1192956d..59f65bfa 100644 --- a/shaders/gles2/xcaa-mono-resolve.fs.glsl +++ b/shaders/gles2/xcaa-mono-resolve.fs.glsl @@ -12,8 +12,11 @@ precision mediump float; +/// The background color of the monochrome path. uniform vec4 uBGColor; +/// The foreground color of the monochrome path. uniform vec4 uFGColor; +/// The alpha coverage texture. uniform sampler2D uAAAlpha; varying vec2 vTexCoord; diff --git a/shaders/gles2/xcaa-mono-resolve.vs.glsl b/shaders/gles2/xcaa-mono-resolve.vs.glsl index 0f80873b..ae9e827e 100644 --- a/shaders/gles2/xcaa-mono-resolve.vs.glsl +++ b/shaders/gles2/xcaa-mono-resolve.vs.glsl @@ -17,7 +17,9 @@ uniform vec4 uTransformST; /// A fixed pair of factors to be applied to the texture coordinates. uniform vec2 uTexScale; +/// The abstract quad position: (0.0, 0.0) to (1.0, 1.0). attribute vec2 aPosition; +/// The texture coordinates: (0.0, 0.0) to (1.0, 1.0). attribute vec2 aTexCoord; varying vec2 vTexCoord; diff --git a/shaders/gles2/xcaa-mono-subpixel-resolve.fs.glsl b/shaders/gles2/xcaa-mono-subpixel-resolve.fs.glsl index 50e21966..f567eb26 100644 --- a/shaders/gles2/xcaa-mono-subpixel-resolve.fs.glsl +++ b/shaders/gles2/xcaa-mono-subpixel-resolve.fs.glsl @@ -14,9 +14,13 @@ precision mediump float; +/// The background color of the monochrome path. uniform vec4 uBGColor; +/// The foreground color of the monochrome path. uniform vec4 uFGColor; +/// The alpha coverage texture. uniform sampler2D uAAAlpha; +/// The dimensions of the alpha coverage texture, in texels. uniform ivec2 uAAAlphaDimensions; varying vec2 vTexCoord; diff --git a/shaders/gles2/xcaa-mono-subpixel-resolve.vs.glsl b/shaders/gles2/xcaa-mono-subpixel-resolve.vs.glsl index 1ea8e753..1f37054f 100644 --- a/shaders/gles2/xcaa-mono-subpixel-resolve.vs.glsl +++ b/shaders/gles2/xcaa-mono-subpixel-resolve.vs.glsl @@ -19,7 +19,9 @@ uniform vec4 uTransformST; /// A fixed pair of factors to be applied to the texture coordinates. uniform vec2 uTexScale; +/// The abstract quad position: (0.0, 0.0) to (1.0, 1.0). attribute vec2 aPosition; +/// The texture coordinates: (0.0, 0.0) to (1.0, 1.0). attribute vec2 aTexCoord; varying vec2 vTexCoord;