Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPLOM update #11

Merged
merged 8 commits into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test.js linguist-documentation
index.html linguist-generated
7 changes: 6 additions & 1 deletion circle-frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ varying vec4 fragColor, fragBorderColor;
uniform float opacity;
varying float fragBorderRadius, fragWidth;

float smoothStep(float edge0, float edge1, float x) {
float t;
t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
return t * t * (3.0 - 2.0 * t);
}

void main() {
float radius, alpha = 1.0, delta = fragWidth;

radius = length(2.0 * gl_PointCoord.xy - 1.0);

if(radius > 1.0 + delta) {
discard;
return;
}

alpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);
Expand Down
21 changes: 15 additions & 6 deletions circle-vert.glsl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
precision highp float;

attribute vec2 position, positionFract;
attribute float x, y, xFract, yFract;
attribute float size, borderSize;
attribute vec2 colorId, borderColorId;
attribute vec4 colorId, borderColorId;

uniform vec2 scale, scaleFract, translate, translateFract;
uniform float pixelRatio;
Expand All @@ -27,9 +27,18 @@ vec2 paletteCoord(vec2 id) {
);
}

vec4 getColor(vec4 id) {
// zero-palette means we deal with direct buffer
if (paletteSize.x == 0.) return id / 255.;
return texture2D(palette, paletteCoord(id.xy));
}

void main() {
vec4 color = texture2D(palette, paletteCoord(colorId));
vec4 borderColor = texture2D(palette, paletteCoord(borderColorId));
vec2 position = vec2(x, y);
vec2 positionFract = vec2(xFract, yFract);

vec4 color = getColor(colorId);
vec4 borderColor = getColor(borderColorId);

float size = size * maxSize / 255.;
float borderSize = borderSize * maxSize / 255.;
Expand All @@ -43,8 +52,8 @@ void main() {

gl_Position = vec4(pos * 2. - 1., 0, 1);

fragBorderRadius = borderSize == 0. ? 2. : 1. - 2. * borderSize / (size + borderSize);
fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);
fragColor = color;
fragBorderColor = borderColor;
fragBorderColor = borderColor.a == 0. ? vec4(color.rgb, 0.) : borderColor;
fragWidth = 1. / gl_PointSize;
}
22 changes: 0 additions & 22 deletions ie-frag.glsl

This file was deleted.

31 changes: 0 additions & 31 deletions ie-vert.glsl

This file was deleted.

Loading