Drop64/vendor/mathbox/build/shaders.js
2017-02-14 21:58:19 -06:00

99 lines
42 KiB
JavaScript

module.exports = {"arrow.position": "uniform float worldUnit;\nuniform float lineDepth;\nuniform float lineWidth;\nuniform float focusDepth;\n\nuniform vec4 geometryClip;\nuniform float arrowSize;\nuniform float arrowSpace;\n\nattribute vec4 position4;\nattribute vec3 arrow;\nattribute vec2 attach;\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\n\nvoid getArrowGeometry(vec4 xyzw, float near, float far, out vec3 left, out vec3 right, out vec3 start) {\n right = getPosition(xyzw, 1.0);\n left = getPosition(vec4(near, xyzw.yzw), 0.0);\n start = getPosition(vec4(far, xyzw.yzw), 0.0);\n}\n\nmat4 getArrowMatrix(vec3 left, vec3 right, vec3 start) {\n\n float depth = focusDepth;\n if (lineDepth < 1.0) {\n // Depth blending\n float z = max(0.00001, -right.z);\n depth = mix(z, focusDepth, lineDepth);\n }\n \n vec3 diff = left - right;\n float l = length(diff);\n if (l == 0.0) {\n return mat4(1.0, 0.0, 0.0, 0.0,\n 0.0, 1.0, 0.0, 0.0,\n 0.0, 0.0, 1.0, 0.0,\n 0.0, 0.0, 0.0, 1.0);\n }\n\n // Construct TBN matrix around shaft\n vec3 t = normalize(diff);\n vec3 n = normalize(cross(t, t.yzx + vec3(.1, .2, .3)));\n vec3 b = cross(n, t);\n \n // Shrink arrows when vector gets too small\n // Approach linear scaling with cubic ease the smaller we get\n float size = arrowSize * lineWidth * worldUnit * depth * 1.25;\n diff = right - start;\n l = length(diff) * arrowSpace;\n float mini = clamp(1.0 - l / size * .333, 0.0, 1.0);\n float scale = 1.0 - mini * mini * mini;\n float range = size * scale;\n \n // Size to 2.5:1 ratio\n float rangeNB = range / 2.5;\n\n // Anchor at end position\n return mat4(vec4(n * rangeNB, 0),\n vec4(b * rangeNB, 0),\n vec4(t * range, 0),\n vec4(right, 1.0));\n}\n\nvec3 getArrowPosition() {\n vec3 left, right, start;\n \n vec4 p = min(geometryClip, position4);\n \n getArrowGeometry(p, attach.x, attach.y, left, right, start);\n mat4 matrix = getArrowMatrix(left, right, start);\n return (matrix * vec4(arrow.xyz, 1.0)).xyz;\n\n}\n",
"axis.position": "uniform vec4 axisStep;\nuniform vec4 axisPosition;\n\nvec4 getAxisPosition(vec4 xyzw, inout vec4 stpq) {\n return axisStep * xyzw.x + axisPosition;\n}\n",
"cartesian.position": "uniform mat4 viewMatrix;\n\nvec4 getCartesianPosition(vec4 position, inout vec4 stpq) {\n return viewMatrix * vec4(position.xyz, 1.0);\n}\n",
"cartesian4.position": "uniform vec4 basisScale;\nuniform vec4 basisOffset;\nuniform vec4 viewScale;\nuniform vec4 viewOffset;\n\nvec4 getCartesian4Position(vec4 position, inout vec4 stpq) {\n return position * basisScale + basisOffset;\n}\n",
"color.opaque": "vec4 opaqueColor(vec4 color) {\n return vec4(color.rgb, 1.0);\n}\n",
"face.position": "uniform vec4 geometryClip;\nattribute vec4 position4;\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\n\nvec3 getFacePosition() {\n vec4 p = min(geometryClip, position4);\n return getPosition(p, 1.0);\n}\n",
"face.position.normal": "attribute vec4 position4;\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\n\nvarying vec3 vNormal;\nvarying vec3 vLight;\nvarying vec3 vPosition;\n\nvoid getFaceGeometry(vec4 xyzw, out vec3 pos, out vec3 normal) {\n vec3 a, b, c;\n\n a = getPosition(vec4(xyzw.xyz, 0.0), 0.0);\n b = getPosition(vec4(xyzw.xyz, 1.0), 0.0);\n c = getPosition(vec4(xyzw.xyz, 2.0), 0.0);\n\n pos = getPosition(xyzw, 1.0);\n normal = normalize(cross(c - a, b - a));\n}\n\nvec3 getFacePositionNormal() {\n vec3 center, normal;\n\n getFaceGeometry(position4, center, normal);\n vNormal = normal;\n vLight = normalize((viewMatrix * vec4(1.0, 2.0, 2.0, 0.0)).xyz);\n vPosition = -center;\n\n return center;\n}\n",
"float.encode": "/*\nFloat encoding technique by\nCarlos Scheidegger\nhttps://github.com/cscheid/lux/blob/master/src/shade/bits/encode_float.js\n\nConversion to GLSL by:\nhttp://concord-consortium.github.io/lab/experiments/webgl-gpgpu/script.js\n*/\n\nfloat shift_right(float v, float amt) { \n v = floor(v) + 0.5; \n return floor(v / exp2(amt)); \n}\n\nfloat shift_left(float v, float amt) { \n return floor(v * exp2(amt) + 0.5); \n}\n\nfloat mask_last(float v, float bits) { \n return mod(v, shift_left(1.0, bits)); \n}\n\nfloat extract_bits(float num, float from, float to) { \n from = floor(from + 0.5); to = floor(to + 0.5); \n return mask_last(shift_right(num, from), to - from); \n}\n\nvec4 encode_float(float val) { \n if (val == 0.0) return vec4(0, 0, 0, 0); \n float valuesign = val > 0.0 ? 0.0 : 1.0; \n val = abs(val); \n float exponent = floor(log2(val)); \n float biased_exponent = exponent + 127.0; \n float fraction = ((val / exp2(exponent)) - 1.0) * 8388608.0; \n float t = biased_exponent / 2.0; \n float last_bit_of_biased_exponent = fract(t) * 2.0; \n float remaining_bits_of_biased_exponent = floor(t); \n float byte4 = extract_bits(fraction, 0.0, 8.0) / 255.0; \n float byte3 = extract_bits(fraction, 8.0, 16.0) / 255.0; \n float byte2 = (last_bit_of_biased_exponent * 128.0 + extract_bits(fraction, 16.0, 23.0)) / 255.0; \n float byte1 = (valuesign * 128.0 + remaining_bits_of_biased_exponent) / 255.0; \n return vec4(byte4, byte3, byte2, byte1); \n}\n",
"float.index.pack": "uniform vec4 indexModulus;\n\nvec4 getSample(vec4 xyzw);\nvec4 getIndex(vec4 xyzw);\n\nvec4 floatPackIndex(vec4 xyzw) {\n vec4 value = getSample(xyzw);\n vec4 index = getIndex(xyzw);\n\n vec4 offset = floor(index + .5) * indexModulus;\n vec2 sum2 = offset.xy + offset.zw;\n float sum = sum2.x + sum2.y;\n return vec4(value.xyz, sum);\n}",
"float.stretch": "vec4 getSample(vec4 xyzw);\n\nfloat floatStretch(vec4 xyzw, float channelIndex) {\n vec4 sample = getSample(xyzw);\n vec2 xy = channelIndex > 1.5 ? sample.zw : sample.xy;\n return mod(channelIndex, 2.0) > .5 ? xy.y : xy.x;\n}",
"fragment.clip.dashed": "varying float vClipStrokeWidth;\nvarying float vClipStrokeIndex;\nvarying vec3 vClipStrokeEven;\nvarying vec3 vClipStrokeOdd;\nvarying vec3 vClipStrokePosition;\n\nvoid clipStrokeFragment() {\n bool odd = mod(vClipStrokeIndex, 2.0) >= 1.0;\n\n vec3 tangent;\n if (odd) {\n tangent = vClipStrokeOdd;\n }\n else {\n tangent = vClipStrokeEven;\n }\n\n float travel = dot(vClipStrokePosition, normalize(tangent)) / vClipStrokeWidth;\n if (mod(travel, 16.0) > 8.0) {\n discard;\n }\n}\n",
"fragment.clip.dotted": "varying float vClipStrokeWidth;\nvarying float vClipStrokeIndex;\nvarying vec3 vClipStrokeEven;\nvarying vec3 vClipStrokeOdd;\nvarying vec3 vClipStrokePosition;\n\nvoid clipStrokeFragment() {\n bool odd = mod(vClipStrokeIndex, 2.0) >= 1.0;\n\n vec3 tangent;\n if (odd) {\n tangent = vClipStrokeOdd;\n }\n else {\n tangent = vClipStrokeEven;\n }\n\n float travel = dot(vClipStrokePosition, normalize(tangent)) / vClipStrokeWidth;\n if (mod(travel, 4.0) > 2.0) {\n discard;\n }\n}\n",
"fragment.clip.ends": "varying vec2 vClipEnds;\n\nvoid clipEndsFragment() {\n if (vClipEnds.x < 0.0 || vClipEnds.y < 0.0) discard;\n}\n",
"fragment.clip.proximity": "varying float vClipProximity;\n\nvoid clipProximityFragment() {\n if (vClipProximity >= 0.5) discard;\n}",
"fragment.color": "void setFragmentColor(vec4 color) {\n gl_FragColor = color;\n}",
"fragment.map.rgba": "vec4 fragmentRGBA(vec4 rgba, vec4 stpq) {\n return rgba;\n}",
"fragment.solid": "void setFragmentColor(vec4 color) {\n if (color.a < 1.0) discard;\n gl_FragColor = color;\n}",
"fragment.transparent": "void setFragmentColor(vec4 color) {\n if (color.a >= 1.0) discard;\n gl_FragColor = color;\n}",
"grid.position": "uniform vec4 gridPosition;\nuniform vec4 gridStep;\nuniform vec4 gridAxis;\n\nvec4 sampleData(vec2 xy);\n\nvec4 getGridPosition(vec4 xyzw) {\n vec4 onAxis = gridAxis * sampleData(vec2(xyzw.y, 0.0)).x;\n vec4 offAxis = gridStep * xyzw.x + gridPosition;\n return onAxis + offAxis;\n}\n",
"grow.position": "uniform float growScale;\nuniform vec4 growMask;\nuniform vec4 growAnchor;\n\nvec4 getSample(vec4 xyzw);\n\nvec4 getGrowSample(vec4 xyzw) {\n vec4 anchor = xyzw * growMask + growAnchor;\n\n vec4 position = getSample(xyzw);\n vec4 center = getSample(anchor);\n\n return mix(center, position, growScale);\n}",
"join.position": "uniform float joinStride;\nuniform float joinStrideInv;\n\nfloat getIndex(vec4 xyzw);\nvec4 getRest(vec4 xyzw);\nvec4 injectIndices(float a, float b);\n\nvec4 getJoinXYZW(vec4 xyzw) {\n\n float a = getIndex(xyzw);\n float b = a * joinStrideInv;\n\n float integer = floor(b);\n float fraction = b - integer;\n \n return injectIndices(fraction * joinStride, integer) + getRest(xyzw);\n}\n",
"label.alpha": "varying float vPixelSize;\n\nvec4 getLabelAlphaColor(vec4 color, vec4 sample) {\n float mask = clamp(sample.r * 1000.0, 0.0, 1.0);\n float alpha = (sample.r - .5) * vPixelSize + .5;\n float a = mask * alpha * color.a;\n if (a <= 0.0) discard;\n return vec4(color.xyz, a);\n}\n",
"label.map": "vec2 mapUV(vec4 uvwo, vec4 stpq) {\n return uvwo.xy;\n}\n",
"label.outline": "uniform float outlineExpand;\nuniform float outlineStep;\nuniform vec3 outlineColor;\n\nvarying float vPixelSize;\n\nconst float PIXEL_STEP = 255.0 / 16.0;\n\nvec4 getLabelOutlineColor(vec4 color, vec4 sample) {\n float ps = vPixelSize * PIXEL_STEP;\n float os = outlineStep;\n\n float sdf = sample.r - .5 + outlineExpand;\n vec2 sdfs = vec2(sdf, sdf + os);\n vec2 alpha = clamp(sdfs * ps + .5, 0.0, 1.0);\n\n if (alpha.y <= 0.0) {\n discard;\n }\n\n vec3 blend = color.xyz;\n if (alpha.y > alpha.x) {\n blend = sqrt(mix(outlineColor * outlineColor, blend * blend, alpha.x));\n }\n \n return vec4(blend, alpha.y * color.a);\n}\n",
"layer.position": "uniform vec4 layerScale;\nuniform vec4 layerBias;\n\nvec4 layerPosition(vec4 position, inout vec4 stpq) {\n return layerScale * position + layerBias;\n}\n",
"lerp.depth": "uniform float sampleRatio;\n\n// External\nvec4 sampleData(vec4 xyzw);\n\nvec4 lerpDepth(vec4 xyzw) {\n float x = xyzw.z * sampleRatio;\n float i = floor(x);\n float f = x - i;\n \n vec4 xyzw1 = vec4(xyzw.xy, i, xyzw.w);\n vec4 xyzw2 = vec4(xyzw.xy, i + 1.0, xyzw.w);\n \n vec4 a = sampleData(xyzw1);\n vec4 b = sampleData(xyzw2);\n\n return mix(a, b, f);\n}\n",
"lerp.height": "uniform float sampleRatio;\n\n// External\nvec4 sampleData(vec4 xyzw);\n\nvec4 lerpHeight(vec4 xyzw) {\n float x = xyzw.y * sampleRatio;\n float i = floor(x);\n float f = x - i;\n \n vec4 xyzw1 = vec4(xyzw.x, i, xyzw.zw);\n vec4 xyzw2 = vec4(xyzw.x, i + 1.0, xyzw.zw);\n \n vec4 a = sampleData(xyzw1);\n vec4 b = sampleData(xyzw2);\n\n return mix(a, b, f);\n}\n",
"lerp.items": "uniform float sampleRatio;\n\n// External\nvec4 sampleData(vec4 xyzw);\n\nvec4 lerpItems(vec4 xyzw) {\n float x = xyzw.w * sampleRatio;\n float i = floor(x);\n float f = x - i;\n \n vec4 xyzw1 = vec4(xyzw.xyz, i);\n vec4 xyzw2 = vec4(xyzw.xyz, i + 1.0);\n \n vec4 a = sampleData(xyzw1);\n vec4 b = sampleData(xyzw2);\n\n return mix(a, b, f);\n}\n",
"lerp.width": "uniform float sampleRatio;\n\n// External\nvec4 sampleData(vec4 xyzw);\n\nvec4 lerpWidth(vec4 xyzw) {\n float x = xyzw.x * sampleRatio;\n float i = floor(x);\n float f = x - i;\n \n vec4 xyzw1 = vec4(i, xyzw.yzw);\n vec4 xyzw2 = vec4(i + 1.0, xyzw.yzw);\n \n vec4 a = sampleData(xyzw1);\n vec4 b = sampleData(xyzw2);\n\n return mix(a, b, f);\n}\n",
"line.position": "uniform float worldUnit;\nuniform float lineWidth;\nuniform float lineDepth;\nuniform float focusDepth;\n\nuniform vec4 geometryClip;\nattribute vec2 line;\nattribute vec4 position4;\n\n#ifdef LINE_PROXIMITY\nuniform float lineProximity;\nvarying float vClipProximity;\n#endif\n\n#ifdef LINE_STROKE\nvarying float vClipStrokeWidth;\nvarying float vClipStrokeIndex;\nvarying vec3 vClipStrokeEven;\nvarying vec3 vClipStrokeOdd;\nvarying vec3 vClipStrokePosition;\n#endif\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\n\n#ifdef LINE_CLIP\nuniform float clipRange;\nuniform vec2 clipStyle;\nuniform float clipSpace;\n\nattribute vec2 strip;\n\nvarying vec2 vClipEnds;\n\nvoid clipEnds(vec4 xyzw, vec3 center, vec3 pos) {\n\n // Sample end of line strip\n vec4 xyzwE = vec4(strip.y, xyzw.yzw);\n vec3 end = getPosition(xyzwE, 0.0);\n\n // Sample start of line strip\n vec4 xyzwS = vec4(strip.x, xyzw.yzw);\n vec3 start = getPosition(xyzwS, 0.0);\n\n // Measure length\n vec3 diff = end - start;\n float l = length(diff) * clipSpace;\n\n // Arrow length (=2.5x radius)\n float arrowSize = 1.25 * clipRange * lineWidth * worldUnit;\n\n vClipEnds = vec2(1.0);\n\n if (clipStyle.y > 0.0) {\n // Depth blend end\n float depth = focusDepth;\n if (lineDepth < 1.0) {\n float z = max(0.00001, -end.z);\n depth = mix(z, focusDepth, lineDepth);\n }\n \n // Absolute arrow length\n float size = arrowSize * depth;\n\n // Adjust clip range\n // Approach linear scaling with cubic ease the smaller we get\n float mini = clamp(1.0 - l / size * .333, 0.0, 1.0);\n float scale = 1.0 - mini * mini * mini; \n float invrange = 1.0 / (size * scale);\n \n // Clip end\n diff = normalize(end - center);\n float d = dot(end - pos, diff);\n vClipEnds.x = d * invrange - 1.0;\n }\n\n if (clipStyle.x > 0.0) {\n // Depth blend start\n float depth = focusDepth;\n if (lineDepth < 1.0) {\n float z = max(0.00001, -start.z);\n depth = mix(z, focusDepth, lineDepth);\n }\n \n // Absolute arrow length\n float size = arrowSize * depth;\n\n // Adjust clip range\n // Approach linear scaling with cubic ease the smaller we get\n float mini = clamp(1.0 - l / size * .333, 0.0, 1.0);\n float scale = 1.0 - mini * mini * mini; \n float invrange = 1.0 / (size * scale);\n \n // Clip start \n diff = normalize(center - start);\n float d = dot(pos - start, diff);\n vClipEnds.y = d * invrange - 1.0;\n }\n\n\n}\n#endif\n\nconst float epsilon = 1e-5;\nvoid fixCenter(vec3 left, inout vec3 center, vec3 right) {\n if (center.z >= 0.0) {\n if (left.z < 0.0) {\n float d = (center.z - epsilon) / (center.z - left.z);\n center = mix(center, left, d);\n }\n else if (right.z < 0.0) {\n float d = (center.z - epsilon) / (center.z - right.z);\n center = mix(center, right, d);\n }\n }\n}\n\n\nvoid getLineGeometry(vec4 xyzw, float edge, out vec3 left, out vec3 center, out vec3 right) {\n vec4 delta = vec4(1.0, 0.0, 0.0, 0.0);\n\n center = getPosition(xyzw, 1.0);\n left = (edge > -0.5) ? getPosition(xyzw - delta, 0.0) : center;\n right = (edge < 0.5) ? getPosition(xyzw + delta, 0.0) : center;\n}\n\nvec3 getLineJoin(float edge, bool odd, vec3 left, vec3 center, vec3 right, float width) {\n vec2 join = vec2(1.0, 0.0);\n\n fixCenter(left, center, right);\n\n vec4 a = vec4(left.xy, right.xy);\n vec4 b = a / vec4(left.zz, right.zz);\n\n vec2 l = b.xy;\n vec2 r = b.zw;\n vec2 c = center.xy / center.z;\n\n vec4 d = vec4(l, c) - vec4(c, r);\n float l1 = dot(d.xy, d.xy);\n float l2 = dot(d.zw, d.zw);\n\n if (l1 + l2 > 0.0) {\n \n if (edge > 0.5 || l2 == 0.0) {\n vec2 nl = normalize(d.xy);\n vec2 tl = vec2(nl.y, -nl.x);\n\n#ifdef LINE_PROXIMITY\n vClipProximity = 1.0;\n#endif\n\n#ifdef LINE_STROKE\n vClipStrokeEven = vClipStrokeOdd = normalize(left - center);\n#endif\n join = tl;\n }\n else if (edge < -0.5 || l1 == 0.0) {\n vec2 nr = normalize(d.zw);\n vec2 tr = vec2(nr.y, -nr.x);\n\n#ifdef LINE_PROXIMITY\n vClipProximity = 1.0;\n#endif\n\n#ifdef LINE_STROKE\n vClipStrokeEven = vClipStrokeOdd = normalize(center - right);\n#endif\n join = tr;\n }\n else {\n // Limit join stretch for tiny segments\n float lmin2 = min(l1, l2) / (width * width);\n\n // Hide line segment if ratio of leg lengths exceeds promixity threshold\n#ifdef LINE_PROXIMITY\n float lr = l1 / l2;\n float rl = l2 / l1;\n float ratio = max(lr, rl);\n float thresh = lineProximity + 1.0;\n vClipProximity = (ratio > thresh * thresh) ? 1.0 : 0.0;\n#endif\n \n // Calculate normals/tangents\n vec2 nl = normalize(d.xy);\n vec2 nr = normalize(d.zw);\n\n vec2 tl = vec2(nl.y, -nl.x);\n vec2 tr = vec2(nr.y, -nr.x);\n\n#ifdef LINE_PROXIMITY\n // Mix tangents according to leg lengths\n vec2 tc = normalize(mix(tl, tr, l1/(l1+l2)));\n#else\n // Average tangent\n vec2 tc = normalize(tl + tr);\n#endif\n \n float cosA = dot(nl, tc);\n float sinA = max(0.1, abs(dot(tl, tc)));\n float factor = cosA / sinA;\n float scale = sqrt(1.0 + min(lmin2, factor * factor));\n\n#ifdef LINE_STROKE\n vec3 stroke1 = normalize(left - center);\n vec3 stroke2 = normalize(center - right);\n\n if (odd) {\n vClipStrokeEven = stroke1;\n vClipStrokeOdd = stroke2;\n }\n else {\n vClipStrokeEven = stroke2;\n vClipStrokeOdd = stroke1;\n }\n#endif\n join = tc * scale;\n }\n return vec3(join, 0.0);\n }\n else {\n return vec3(0.0);\n }\n\n}\n\nvec3 getLinePosition() {\n vec3 left, center, right, join;\n\n float edge = line.x;\n float offset = line.y;\n\n vec4 p = min(geometryClip, position4);\n edge += max(0.0, position4.x - geometryClip.x);\n\n // Get position + adjacent neighbours\n getLineGeometry(p, edge, left, center, right);\n\n#ifdef LINE_STROKE\n // Set parameters for line stroke fragment shader\n vClipStrokePosition = center;\n vClipStrokeIndex = p.x;\n bool odd = mod(p.x, 2.0) >= 1.0;\n#else\n bool odd = true;\n#endif\n\n // Divide line width up/down\n float width = lineWidth * 0.5;\n\n float depth = focusDepth;\n if (lineDepth < 1.0) {\n // Depth blending\n float z = max(0.00001, -center.z);\n depth = mix(z, focusDepth, lineDepth);\n }\n width *= depth;\n\n // Convert to world units\n width *= worldUnit;\n\n join = getLineJoin(edge, odd, left, center, right, width);\n\n#ifdef LINE_STROKE\n vClipStrokeWidth = width;\n#endif\n \n vec3 pos = center + join * offset * width;\n\n#ifdef LINE_CLIP\n clipEnds(p, center, pos);\n#endif\n\n return pos;\n}\n",
"map.2d.data": "uniform vec2 dataResolution;\nuniform vec2 dataPointer;\n\nvec2 map2DData(vec2 xy) {\n return fract((xy + dataPointer) * dataResolution);\n}\n",
"map.xyzw.2dv": "void mapXyzw2DV(vec4 xyzw, out vec2 xy, out float z) {\n xy = xyzw.xy;\n z = xyzw.z;\n}\n\n",
"map.xyzw.texture": "uniform float textureItems;\nuniform float textureHeight;\n\nvec2 mapXyzwTexture(vec4 xyzw) {\n \n float x = xyzw.x;\n float y = xyzw.y;\n float z = xyzw.z;\n float i = xyzw.w;\n \n return vec2(i, y) + vec2(x, z) * vec2(textureItems, textureHeight);\n}\n\n",
"mesh.fragment.color": "varying vec4 vColor;\n\nvec4 getColor() {\n return vColor;\n}\n",
"mesh.fragment.map": "#ifdef POSITION_STPQ\nvarying vec4 vSTPQ;\n#endif\n#ifdef POSITION_U\nvarying float vU;\n#endif\n#ifdef POSITION_UV\nvarying vec2 vUV;\n#endif\n#ifdef POSITION_UVW\nvarying vec3 vUVW;\n#endif\n#ifdef POSITION_UVWO\nvarying vec4 vUVWO;\n#endif\n\nvec4 getSample(vec4 uvwo, vec4 stpq);\n\nvec4 getMapColor() {\n #ifdef POSITION_STPQ\n vec4 stpq = vSTPQ;\n #else\n vec4 stpq = vec4(0.0);\n #endif\n\n #ifdef POSITION_U\n vec4 uvwo = vec4(vU, 0.0, 0.0, 0.0);\n #endif\n #ifdef POSITION_UV\n vec4 uvwo = vec4(vUV, 0.0, 0.0);\n #endif\n #ifdef POSITION_UVW\n vec4 uvwo = vec4(vUVW, 0.0);\n #endif\n #ifdef POSITION_UVWO\n vec4 uvwo = vec4(vUVWO);\n #endif\n\n return getSample(uvwo, stpq);\n}\n",
"mesh.fragment.mask": "varying float vMask;\n\nfloat ease(float t) {\n t = clamp(t, 0.0, 1.0);\n return t * t * (3.0 - 2.0 * t);\n}\n\nvec4 maskColor() {\n if (vMask <= 0.0) discard;\n return vec4(vec3(1.0), ease(vMask));\n}\n",
"mesh.fragment.shaded": "varying vec3 vNormal;\nvarying vec3 vLight;\nvarying vec3 vPosition;\n\nvec3 offSpecular(vec3 color) {\n vec3 c = 1.0 - color;\n return 1.0 - c * c;\n}\n\nvec4 getShadedColor(vec4 rgba) {\n \n vec3 color = rgba.xyz;\n vec3 color2 = offSpecular(rgba.xyz);\n\n vec3 normal = normalize(vNormal);\n vec3 light = normalize(vLight);\n vec3 position = normalize(vPosition);\n \n float side = gl_FrontFacing ? -1.0 : 1.0;\n float cosine = side * dot(normal, light);\n float diffuse = mix(max(0.0, cosine), .5 + .5 * cosine, .1);\n \n vec3 halfLight = normalize(light + position);\n\tfloat cosineHalf = max(0.0, side * dot(normal, halfLight));\n\tfloat specular = pow(cosineHalf, 16.0);\n\t\n\treturn vec4(color * (diffuse * .9 + .05) + .25 * color2 * specular, rgba.a);\n}\n",
"mesh.fragment.texture": "",
"mesh.gamma.in": "vec4 getGammaInColor(vec4 rgba) {\n return vec4(rgba.rgb * rgba.rgb, rgba.a);\n}\n",
"mesh.gamma.out": "vec4 getGammaOutColor(vec4 rgba) {\n return vec4(sqrt(rgba.rgb), rgba.a);\n}\n",
"mesh.map.uvwo": "vec4 mapUVWO(vec4 uvwo, vec4 stpq) {\n return uvwo;\n}\n",
"mesh.position": "uniform vec4 geometryClip;\nattribute vec4 position4;\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\n\nvec3 getMeshPosition() {\n vec4 p = min(geometryClip, position4);\n return getPosition(p, 1.0);\n}\n",
"mesh.vertex.color": "attribute vec4 position4;\nuniform vec4 geometryClip;\nvarying vec4 vColor;\n\n// External\nvec4 getSample(vec4 xyzw);\n\nvoid vertexColor() {\n vec4 p = min(geometryClip, position4);\n vColor = getSample(p);\n}\n",
"mesh.vertex.mask": "attribute vec4 position4;\nuniform vec4 geometryResolution;\nuniform vec4 geometryClip;\nvarying float vMask;\n\n// External\nfloat getSample(vec4 xyzw);\n\nvoid maskLevel() {\n vec4 p = min(geometryClip, position4);\n vMask = getSample(p * geometryResolution);\n}\n",
"mesh.vertex.position": "uniform vec4 geometryResolution;\n\n#ifdef POSITION_STPQ\nvarying vec4 vSTPQ;\n#endif\n#ifdef POSITION_U\nvarying float vU;\n#endif\n#ifdef POSITION_UV\nvarying vec2 vUV;\n#endif\n#ifdef POSITION_UVW\nvarying vec3 vUVW;\n#endif\n#ifdef POSITION_UVWO\nvarying vec4 vUVWO;\n#endif\n\n// External\nvec3 getPosition(vec4 xyzw, vec4 stpq);\n\nvec3 getMeshPosition(vec4 xyzw, float canonical) {\n vec4 stpq = xyzw * geometryResolution;\n vec3 xyz = getPosition(xyzw, stpq);\n\n #ifdef POSITION_MAP\n if (canonical > 0.5) {\n #ifdef POSITION_STPQ\n vSTPQ = stpq;\n #endif\n #ifdef POSITION_U\n vU = stpq.x;\n #endif\n #ifdef POSITION_UV\n vUV = stpq.xy;\n #endif\n #ifdef POSITION_UVW\n vUVW = stpq.xyz;\n #endif\n #ifdef POSITION_UVWO\n vUVWO = stpq;\n #endif\n }\n #endif\n return xyz;\n}\n",
"move.position": "uniform float transitionEnter;\nuniform float transitionExit;\nuniform vec4 transitionScale;\nuniform vec4 transitionBias;\nuniform float transitionSkew;\nuniform float transitionActive;\n\nuniform vec4 moveFrom;\nuniform vec4 moveTo;\n\nfloat ease(float t) {\n t = clamp(t, 0.0, 1.0);\n return 1.0 - (2.0 - t) * t;\n}\n\nvec4 getTransitionPosition(vec4 xyzw, inout vec4 stpq) {\n if (transitionActive < 0.5) return xyzw;\n\n float enter = transitionEnter;\n float exit = transitionExit;\n float skew = transitionSkew;\n vec4 scale = transitionScale;\n vec4 bias = transitionBias;\n\n float factor = 1.0 + skew;\n float offset = dot(vec4(1.0), stpq * scale + bias);\n\n float a1 = ease(enter * factor - offset);\n float a2 = ease(exit * factor + offset - skew);\n\n return xyzw + a1 * moveFrom + a2 * moveTo;\n}",
"object.mask.default": "vec4 getMask(vec4 xyzw) {\n return vec4(1.0);\n}",
"point.alpha.circle": "varying float vPixelSize;\n\nfloat getDiscAlpha(float mask) {\n // Approximation: 1 - x*x is approximately linear around x = 1 with slope 2\n return vPixelSize * (1.0 - mask);\n // return vPixelSize * 2.0 * (1.0 - sqrt(mask));\n}\n",
"point.alpha.circle.hollow": "varying float vPixelSize;\n\nfloat getDiscHollowAlpha(float mask) {\n return vPixelSize * (0.5 - 2.0 * abs(sqrt(mask) - .75));\n}\n",
"point.alpha.generic": "varying float vPixelSize;\n\nfloat getGenericAlpha(float mask) {\n return vPixelSize * 2.0 * (1.0 - mask);\n}\n",
"point.alpha.generic.hollow": "varying float vPixelSize;\n\nfloat getGenericHollowAlpha(float mask) {\n return vPixelSize * (0.5 - 2.0 * abs(mask - .75));\n}\n",
"point.edge": "varying vec2 vSprite;\n\nfloat getSpriteMask(vec2 xy);\nfloat getSpriteAlpha(float mask);\n\nvoid setFragmentColorFill(vec4 color) {\n float mask = getSpriteMask(vSprite);\n if (mask > 1.0) {\n discard;\n }\n float alpha = getSpriteAlpha(mask);\n if (alpha >= 1.0) {\n discard;\n }\n gl_FragColor = vec4(color.rgb, alpha * color.a);\n}\n",
"point.fill": "varying vec2 vSprite;\n\nfloat getSpriteMask(vec2 xy);\nfloat getSpriteAlpha(float mask);\n\nvoid setFragmentColorFill(vec4 color) {\n float mask = getSpriteMask(vSprite);\n if (mask > 1.0) {\n discard;\n }\n float alpha = getSpriteAlpha(mask);\n if (alpha < 1.0) {\n discard;\n }\n gl_FragColor = color;\n}\n\n",
"point.mask.circle": "varying float vPixelSize;\n\nfloat getCircleMask(vec2 uv) {\n return dot(uv, uv);\n}\n",
"point.mask.diamond": "varying float vPixelSize;\n\nfloat getDiamondMask(vec2 uv) {\n vec2 a = abs(uv);\n return a.x + a.y;\n}\n",
"point.mask.down": "varying float vPixelSize;\n\nfloat getTriangleDownMask(vec2 uv) {\n uv.y += .25;\n return max(uv.y, abs(uv.x) * .866 - uv.y * .5 + .6);\n}\n",
"point.mask.left": "varying float vPixelSize;\n\nfloat getTriangleLeftMask(vec2 uv) {\n uv.x += .25;\n return max(uv.x, abs(uv.y) * .866 - uv.x * .5 + .6);\n}\n",
"point.mask.right": "varying float vPixelSize;\n\nfloat getTriangleRightMask(vec2 uv) {\n uv.x -= .25;\n return max(-uv.x, abs(uv.y) * .866 + uv.x * .5 + .6);\n}\n",
"point.mask.square": "varying float vPixelSize;\n\nfloat getSquareMask(vec2 uv) {\n vec2 a = abs(uv);\n return max(a.x, a.y);\n}\n",
"point.mask.up": "varying float vPixelSize;\n\nfloat getTriangleUpMask(vec2 uv) {\n uv.y -= .25;\n return max(-uv.y, abs(uv.x) * .866 + uv.y * .5 + .6);\n}\n",
"point.position": "uniform float pointDepth;\n\nuniform float pixelUnit;\nuniform float renderScale;\nuniform float renderScaleInv;\nuniform float focusDepth;\n\nuniform vec4 geometryClip;\nattribute vec4 position4;\nattribute vec2 sprite;\n\nvarying vec2 vSprite;\nvarying float vPixelSize;\n\nconst float pointScale = POINT_SHAPE_SCALE;\n\n// External\nfloat getPointSize(vec4 xyzw);\nvec3 getPosition(vec4 xyzw, float canonical);\n\nvec3 getPointPosition() {\n vec4 p = min(geometryClip, position4);\n vec3 center = getPosition(p, 1.0);\n\n // Depth blending\n // TODO: orthographic camera\n // Workaround: set depth = 0\n float z = -center.z;\n float depth = mix(z, focusDepth, pointDepth);\n \n // Match device/unit mapping \n // Sprite goes from -1..1, width = 2.\n float pointSize = getPointSize(p);\n float size = pointScale * pointSize * pixelUnit * .5;\n float depthSize = depth * size;\n \n // Pad sprite by half a pixel to make the anti-aliasing straddle the pixel edge\n // Note: pixelsize measures radius\n float pixelSize = .5 * (pointDepth > 0.0 ? depthSize / z : size);\n float paddedSize = pixelSize + 0.5;\n float padFactor = paddedSize / pixelSize;\n\n vPixelSize = paddedSize;\n vSprite = sprite;\n\n return center + vec3(sprite * depthSize * renderScaleInv * padFactor, 0.0);\n}\n",
"point.size.uniform": "uniform float pointSize;\n\nfloat getPointSize(vec4 xyzw) {\n return pointSize;\n}",
"point.size.varying": "uniform float pointSize;\n\nvec4 getSample(vec4 xyzw);\n\nfloat getPointSize(vec4 xyzw) {\n return pointSize * getSample(xyzw).x;\n}",
"polar.position": "uniform float polarBend;\nuniform float polarFocus;\nuniform float polarAspect;\nuniform float polarHelix;\n\nuniform mat4 viewMatrix;\n\nvec4 getPolarPosition(vec4 position, inout vec4 stpq) {\n if (polarBend > 0.0) {\n\n if (polarBend < 0.001) {\n // Factor out large addition/subtraction of polarFocus\n // to avoid numerical error\n // sin(x) ~ x\n // cos(x) ~ 1 - x * x / 2\n vec2 pb = position.xy * polarBend;\n float ppbbx = pb.x * pb.x;\n return viewMatrix * vec4(\n position.x * (1.0 - polarBend + (pb.y * polarAspect)),\n position.y * (1.0 - .5 * ppbbx) - (.5 * ppbbx) * polarFocus / polarAspect,\n position.z + position.x * polarHelix * polarBend,\n 1.0\n );\n }\n else {\n vec2 xy = position.xy * vec2(polarBend, polarAspect);\n float radius = polarFocus + xy.y;\n return viewMatrix * vec4(\n sin(xy.x) * radius,\n (cos(xy.x) * radius - polarFocus) / polarAspect,\n position.z + position.x * polarHelix * polarBend,\n 1.0\n );\n }\n }\n else {\n return viewMatrix * vec4(position.xyz, 1.0);\n }\n}",
"project.position": "uniform float styleZBias;\nuniform float styleZIndex;\n\nvoid setPosition(vec3 position) {\n vec4 pos = projectionMatrix * vec4(position, 1.0);\n\n // Apply relative Z bias\n float bias = (1.0 - styleZBias / 32768.0);\n pos.z *= bias;\n \n // Apply large scale Z index changes\n if (styleZIndex > 0.0) {\n float z = pos.z / pos.w;\n pos.z = ((z + 1.0) / (styleZIndex + 1.0) - 1.0) * pos.w;\n }\n \n gl_Position = pos;\n}",
"project.readback": "// This is three.js' global uniform, missing from fragment shaders.\nuniform mat4 projectionMatrix;\n\nvec4 readbackPosition(vec3 position) {\n vec4 pos = projectionMatrix * vec4(position, 1.0);\n vec3 final = pos.xyz / pos.w;\n if (final.z < -1.0) {\n return vec4(0.0, 0.0, 0.0, -1.0);\n }\n else {\n return vec4(final, -position.z);\n }\n}\n",
"raw.position.scale": "uniform vec4 geometryScale;\nattribute vec4 position4;\n\nvec4 getRawPositionScale() {\n return geometryScale * position4;\n}\n",
"repeat.position": "uniform vec4 repeatModulus;\n\nvec4 getRepeatXYZW(vec4 xyzw) {\n return mod(xyzw + .5, repeatModulus) - .5;\n}\n",
"resample.padding": "uniform vec4 resampleBias;\n\nvec4 resamplePadding(vec4 xyzw) {\n return xyzw + resampleBias;\n}",
"resample.relative": "uniform vec4 resampleFactor;\n\nvec4 resampleRelative(vec4 xyzw) {\n return xyzw * resampleFactor;\n}",
"reveal.mask": "uniform float transitionEnter;\nuniform float transitionExit;\nuniform vec4 transitionScale;\nuniform vec4 transitionBias;\nuniform float transitionSkew;\nuniform float transitionActive;\n\nfloat getTransitionSDFMask(vec4 stpq) {\n if (transitionActive < 0.5) return 1.0;\n\n float enter = transitionEnter;\n float exit = transitionExit;\n float skew = transitionSkew;\n vec4 scale = transitionScale;\n vec4 bias = transitionBias;\n\n float factor = 1.0 + skew;\n float offset = dot(vec4(1.0), stpq * scale + bias);\n\n vec2 d = vec2(enter, exit) * factor + vec2(-offset, offset - skew);\n if (exit == 1.0) return d.x;\n if (enter == 1.0) return d.y;\n return min(d.x, d.y);\n}",
"root.position": "vec3 getRootPosition(vec4 position, in vec4 stpq) {\n return position.xyz;\n}",
"sample.2d": "uniform sampler2D dataTexture;\n\nvec4 sample2D(vec2 uv) {\n return texture2D(dataTexture, uv);\n}\n",
"scale.position": "uniform vec4 scaleAxis;\nuniform vec4 scaleOffset;\n\nvec4 sampleData(float x);\n\nvec4 getScalePosition(vec4 xyzw) {\n return scaleAxis * sampleData(xyzw.x).x + scaleOffset;\n}\n",
"screen.map.stpq": "uniform vec4 remapSTPQScale;\n\nvec4 screenMapSTPQ(vec4 xyzw, out vec4 stpq) {\n stpq = xyzw * remapSTPQScale;\n return xyzw;\n}\n",
"screen.map.xy": "uniform vec2 remapUVScale;\n\nvec4 screenMapXY(vec4 uvwo, vec4 stpq) {\n return vec4(floor(remapUVScale * uvwo.xy), 0.0, 0.0);\n}\n",
"screen.map.xyzw": "uniform vec2 remapUVScale;\nuniform vec2 remapModulus;\nuniform vec2 remapModulusInv;\n\nvec4 screenMapXYZW(vec4 uvwo, vec4 stpq) {\n vec2 st = floor(remapUVScale * uvwo.xy);\n vec2 xy = st * remapModulusInv;\n vec2 ixy = floor(xy);\n vec2 fxy = xy - ixy;\n vec2 zw = fxy * remapModulus;\n return vec4(ixy.x, zw.y, ixy.y, zw.x);\n}\n",
"screen.pass.uv": "vec2 screenPassUV(vec4 uvwo, vec4 stpq) {\n return uvwo.xy;\n}\n",
"screen.position": "void setScreenPosition(vec4 position) {\n gl_Position = vec4(position.xy * 2.0 - 1.0, 0.5, 1.0);\n}\n",
"slice.position": "uniform vec4 sliceOffset;\n\nvec4 getSliceOffset(vec4 xyzw) {\n return xyzw + sliceOffset;\n}\n",
"spherical.position": "uniform float sphericalBend;\nuniform float sphericalFocus;\nuniform float sphericalAspectX;\nuniform float sphericalAspectY;\nuniform float sphericalScaleY;\n\nuniform mat4 viewMatrix;\n\nvec4 getSphericalPosition(vec4 position, inout vec4 stpq) {\n if (sphericalBend > 0.0001) {\n\n vec3 xyz = position.xyz * vec3(sphericalBend, sphericalBend / sphericalAspectY * sphericalScaleY, sphericalAspectX);\n float radius = sphericalFocus + xyz.z;\n float cosine = cos(xyz.y) * radius;\n\n return viewMatrix * vec4(\n sin(xyz.x) * cosine,\n sin(xyz.y) * radius * sphericalAspectY,\n (cos(xyz.x) * cosine - sphericalFocus) / sphericalAspectX,\n 1.0\n );\n }\n else {\n return viewMatrix * vec4(position.xyz, 1.0);\n }\n}",
"split.position": "uniform float splitStride;\n\nvec2 getIndices(vec4 xyzw);\nvec4 getRest(vec4 xyzw);\nvec4 injectIndex(float v);\n\nvec4 getSplitXYZW(vec4 xyzw) {\n vec2 uv = getIndices(xyzw);\n float offset = uv.x + uv.y * splitStride;\n return injectIndex(offset) + getRest(xyzw);\n}\n",
"spread.position": "uniform vec4 spreadOffset;\nuniform mat4 spreadMatrix;\n\n// External\nvec4 getSample(vec4 xyzw);\n\nvec4 getSpreadSample(vec4 xyzw) {\n vec4 sample = getSample(xyzw);\n return sample + spreadMatrix * (spreadOffset + xyzw);\n}\n",
"sprite.fragment": "varying vec2 vSprite;\n\nvec4 getSample(vec2 xy);\n\nvec4 getSpriteColor() {\n return getSample(vSprite);\n}",
"sprite.position": "uniform vec2 spriteOffset;\nuniform float spriteScale;\nuniform float spriteDepth;\nuniform float spriteSnap;\n\nuniform vec2 renderOdd;\nuniform float renderScale;\nuniform float renderScaleInv;\nuniform float pixelUnit;\nuniform float focusDepth;\n\nuniform vec4 geometryClip;\nattribute vec4 position4;\nattribute vec2 sprite;\n\nvarying float vPixelSize;\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\nvec4 getSprite(vec4 xyzw);\n\nvec3 getSpritePosition() {\n // Clip points\n vec4 p = min(geometryClip, position4);\n float diff = length(position4 - p);\n if (diff > 0.0) {\n return vec3(0.0, 0.0, 1000.0);\n }\n\n // Make sprites\n vec3 center = getPosition(p, 1.0);\n vec4 atlas = getSprite(p);\n\n // Sprite goes from -1..1, width = 2.\n // -1..1 -> -0.5..0.5\n vec2 halfSprite = sprite * .5;\n vec2 halfFlipSprite = vec2(halfSprite.x, -halfSprite.y);\n\n#ifdef POSITION_UV\n // Assign UVs\n vUV = atlas.xy + atlas.zw * (halfFlipSprite + .5);\n#endif\n\n // Depth blending\n // TODO: orthographic camera\n // Workaround: set depth = 0\n float depth = focusDepth, z;\n z = -center.z;\n if (spriteDepth < 1.0) {\n depth = mix(z, focusDepth, spriteDepth);\n }\n \n // Match device/unit mapping \n float size = pixelUnit * spriteScale;\n float depthSize = depth * size;\n\n // Calculate pixelSize for anti-aliasing\n float pixelSize = (spriteDepth > 0.0 ? depthSize / z : size);\n vPixelSize = pixelSize;\n\n // Position sprite\n vec2 atlasOdd = fract(atlas.zw / 2.0);\n vec2 offset = (spriteOffset + halfSprite * atlas.zw) * depthSize;\n if (spriteSnap > 0.5) {\n // Snap to pixel (w/ epsilon shift to avoid jitter)\n return vec3(((floor(center.xy / center.z * renderScale + 0.001) + renderOdd + atlasOdd) * center.z + offset) * renderScaleInv, center.z);\n }\n else {\n // Place directly\n return center + vec3(offset * renderScaleInv, 0.0);\n }\n\n}\n",
"stereographic.position": "uniform float stereoBend;\n\nuniform mat4 viewMatrix;\n\nvec4 getStereoPosition(vec4 position, inout vec4 stpq) {\n if (stereoBend > 0.0001) {\n\n vec3 pos = position.xyz;\n float r = length(pos);\n float z = r + pos.z;\n vec3 project = vec3(pos.xy / z, r);\n \n vec3 lerped = mix(pos, project, stereoBend);\n\n return viewMatrix * vec4(lerped, 1.0);\n }\n else {\n return viewMatrix * vec4(position.xyz, 1.0);\n }\n}",
"stereographic4.position": "uniform float stereoBend;\nuniform vec4 basisScale;\nuniform vec4 basisOffset;\nuniform mat4 viewMatrix;\nuniform vec2 view4D;\n\nvec4 getStereographic4Position(vec4 position, inout vec4 stpq) {\n \n vec4 transformed;\n if (stereoBend > 0.0001) {\n\n float r = length(position);\n float w = r + position.w;\n vec4 project = vec4(position.xyz / w, r);\n \n transformed = mix(position, project, stereoBend);\n }\n else {\n transformed = position;\n }\n\n vec4 pos4 = transformed * basisScale - basisOffset;\n vec3 xyz = (viewMatrix * vec4(pos4.xyz, 1.0)).xyz;\n return vec4(xyz, pos4.w * view4D.y + view4D.x);\n}\n",
"stpq.sample.2d": "varying vec2 vST;\n\nvec4 getSample(vec2 st);\n\nvec4 getSTSample() {\n return getSample(vST);\n}\n",
"stpq.xyzw.2d": "varying vec2 vUV;\n\nvoid setRawUV(vec4 xyzw) {\n vUV = xyzw.xy;\n}\n",
"strip.position.normal": "uniform vec4 geometryClip;\nattribute vec4 position4;\nattribute vec3 strip;\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\n\nvarying vec3 vNormal;\nvarying vec3 vLight;\nvarying vec3 vPosition;\n\nvoid getStripGeometry(vec4 xyzw, vec3 strip, out vec3 pos, out vec3 normal) {\n vec3 a, b, c;\n\n a = getPosition(xyzw, 1.0);\n b = getPosition(vec4(xyzw.xyz, strip.x), 0.0);\n c = getPosition(vec4(xyzw.xyz, strip.y), 0.0);\n\n normal = normalize(cross(c - a, b - a)) * strip.z;\n \n pos = a;\n}\n\nvec3 getStripPositionNormal() {\n vec3 center, normal;\n\n vec4 p = min(geometryClip, position4);\n\n getStripGeometry(p, strip, center, normal);\n vNormal = normal;\n vLight = normalize((viewMatrix * vec4(1.0, 2.0, 2.0, 0.0)).xyz);\n vPosition = -center;\n\n return center;\n}\n",
"style.color": "uniform vec3 styleColor;\nuniform float styleOpacity;\n\nvec4 getStyleColor() {\n return vec4(styleColor, styleOpacity);\n}\n",
"surface.mask.hollow": "attribute vec4 position4;\n\nfloat getSurfaceHollowMask(vec4 xyzw) {\n vec4 df = abs(fract(position4) - .5);\n vec2 df2 = min(df.xy, df.zw);\n float df3 = min(df2.x, df2.y);\n return df3;\n}",
"surface.position": "uniform vec4 geometryClip;\nuniform vec4 geometryResolution;\nuniform vec4 mapSize;\n\nattribute vec4 position4;\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\n\nvec3 getSurfacePosition() {\n vec4 p = min(geometryClip, position4);\n vec3 xyz = getPosition(p, 1.0);\n\n // Overwrite UVs\n#ifdef POSITION_UV\n#ifdef POSITION_UV_INT\n vUV = -.5 + (position4.xy * geometryResolution.xy) * mapSize.xy;\n#else\n vUV = position4.xy * geometryResolution.xy;\n#endif\n#endif\n\n return xyz;\n}\n",
"surface.position.normal": "uniform vec4 mapSize;\nuniform vec4 geometryResolution;\nuniform vec4 geometryClip;\nattribute vec4 position4;\nattribute vec2 surface;\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\n\nvoid getSurfaceGeometry(vec4 xyzw, float edgeX, float edgeY, out vec3 left, out vec3 center, out vec3 right, out vec3 up, out vec3 down) {\n vec4 deltaX = vec4(1.0, 0.0, 0.0, 0.0);\n vec4 deltaY = vec4(0.0, 1.0, 0.0, 0.0);\n\n /*\n // high quality, 5 tap\n center = getPosition(xyzw, 1.0);\n left = (edgeX > -0.5) ? getPosition(xyzw - deltaX, 0.0) : center;\n right = (edgeX < 0.5) ? getPosition(xyzw + deltaX, 0.0) : center;\n down = (edgeY > -0.5) ? getPosition(xyzw - deltaY, 0.0) : center;\n up = (edgeY < 0.5) ? getPosition(xyzw + deltaY, 0.0) : center;\n */\n \n // low quality, 3 tap\n center = getPosition(xyzw, 1.0);\n left = center;\n down = center;\n right = (edgeX < 0.5) ? getPosition(xyzw + deltaX, 0.0) : (2.0 * center - getPosition(xyzw - deltaX, 0.0));\n up = (edgeY < 0.5) ? getPosition(xyzw + deltaY, 0.0) : (2.0 * center - getPosition(xyzw - deltaY, 0.0));\n}\n\nvec3 getSurfaceNormal(vec3 left, vec3 center, vec3 right, vec3 up, vec3 down) {\n vec3 dx = right - left;\n vec3 dy = up - down;\n vec3 n = cross(dy, dx);\n if (length(n) > 0.0) {\n return normalize(n);\n }\n return vec3(0.0, 1.0, 0.0);\n}\n\nvarying vec3 vNormal;\nvarying vec3 vLight;\nvarying vec3 vPosition;\n\nvec3 getSurfacePositionNormal() {\n vec3 left, center, right, up, down;\n\n vec4 p = min(geometryClip, position4);\n\n getSurfaceGeometry(p, surface.x, surface.y, left, center, right, up, down);\n vNormal = getSurfaceNormal(left, center, right, up, down);\n vLight = normalize((viewMatrix * vec4(1.0, 2.0, 2.0, 0.0)).xyz); // hardcoded directional light\n vPosition = -center;\n\n#ifdef POSITION_UV\n#ifdef POSITION_UV_INT\n vUV = -.5 + (position4.xy * geometryResolution.xy) * mapSize.xy;\n#else\n vUV = position4.xy * geometryResolution.xy;\n#endif\n#endif\n \n return center;\n}\n",
"ticks.position": "uniform float worldUnit;\nuniform float focusDepth;\nuniform float tickSize;\nuniform float tickEpsilon;\nuniform vec3 tickNormal;\nuniform vec2 tickStrip;\n\nvec4 getSample(vec4 xyzw);\n\nvec3 transformPosition(vec4 position, vec4 stpq);\n\nvec3 getTickPosition(vec4 xyzw, vec4 stpq) {\n\n float epsilon = tickEpsilon;\n\n // determine tick direction\n float leftX = max(tickStrip.x, xyzw.y - 1.0);\n float rightX = min(tickStrip.y, xyzw.y + 1.0);\n \n vec4 left = getSample(vec4(leftX, xyzw.zw, 0.0));\n vec4 right = getSample(vec4(rightX, xyzw.zw, 0.0));\n vec4 diff = right - left;\n\n vec3 normal = cross(normalize(diff.xyz + vec3(diff.w)), tickNormal);\n float bias = max(0.0, 1.0 - length(normal) * 2.0);\n normal = mix(normal, tickNormal.yzx, bias * bias);\n \n // transform (point) and (point + delta)\n vec4 center = getSample(vec4(xyzw.yzw, 0.0));\n vec4 delta = vec4(normal, 0.0) * epsilon;\n\n vec4 a = center;\n vec4 b = center + delta;\n\n vec3 c = transformPosition(a, stpq);\n vec3 d = transformPosition(b, stpq);\n \n // sample on either side to create line\n float line = xyzw.x - .5;\n vec3 mid = c;\n vec3 side = normalize(d - c);\n\n return mid + side * line * tickSize * worldUnit * focusDepth;\n}\n",
"transform3.position": "uniform mat4 transformMatrix;\n\nvec4 transformPosition(vec4 position, inout vec4 stpq) {\n return transformMatrix * vec4(position.xyz, 1.0);\n}\n",
"transform4.position": "uniform mat4 transformMatrix;\nuniform vec4 transformOffset;\n\nvec4 transformPosition(vec4 position, inout vec4 stpq) {\n return transformMatrix * position + transformOffset;\n}\n",
"view.position": "// Implicit three.js uniform\n// uniform mat4 viewMatrix;\n\nvec4 getViewPosition(vec4 position, inout vec4 stpq) {\n return (viewMatrix * vec4(position.xyz, 1.0));\n}\n"};