Skip to content

Commit 30d3874

Browse files
committed
Fix custom markers for IE11
1 parent 939a6e1 commit 30d3874

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

marker-frag.glsl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ void main() {
2020
if (fragBorderColorLevel == fragColorLevel || fragBorderColor.a == 0.) {
2121
float colorAmt = smoothstep(.5 - delta, .5 + delta, dist);
2222
gl_FragColor = vec4(fragColor.rgb, colorAmt * fragColor.a * opacity);
23-
return;
2423
}
24+
else {
25+
float borderColorAmt = smoothstep(fragBorderColorLevel - delta, fragBorderColorLevel + delta, dist);
26+
float colorAmt = smoothstep(fragColorLevel - delta, fragColorLevel + delta, dist);
2527

28+
vec4 color = fragBorderColor;
29+
color.a *= borderColorAmt;
30+
color = mix(color, fragColor, colorAmt);
31+
color.a *= opacity;
2632

27-
float borderColorAmt = smoothstep(fragBorderColorLevel - delta, fragBorderColorLevel + delta, dist);
28-
float colorAmt = smoothstep(fragColorLevel - delta, fragColorLevel + delta, dist);
29-
30-
vec4 color = fragBorderColor;
31-
color.a *= borderColorAmt;
32-
color = mix(color, fragColor, colorAmt);
33-
color.a *= opacity;
33+
gl_FragColor = color;
34+
}
3435

35-
gl_FragColor = color;
3636
}

scatter.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,18 @@ function Scatter (regl, options) {
179179
markerOptions.frag = glslify('./marker-frag.glsl')
180180
markerOptions.vert = glslify('./marker-vert.glsl')
181181

182-
try {
183-
this.drawMarker = regl(markerOptions)
184-
} catch (e) {
185-
}
182+
this.drawMarker = regl(markerOptions)
186183

187184
// draw circle
188185
let circleOptions = extend({}, shaderOptions)
189186
circleOptions.frag = glslify('./circle-frag.glsl')
190187
circleOptions.vert = glslify('./circle-vert.glsl')
191188

192189
// polyfill IE
193-
if (ie) circleOptions.frag = circleOptions.frag.replace('smoothstep', 'smoothStep')
190+
if (ie) {
191+
circleOptions.frag = circleOptions.frag.replace('smoothstep', 'smoothStep')
192+
markerOptions.frag = markerOptions.frag.replace('smoothstep', 'smoothStep')
193+
}
194194

195195
this.drawCircle = regl(circleOptions)
196196
}

test.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ function show (arr) {
8383

8484

8585

86-
let N = 1e5
86+
let N = 1e4
8787
let ratio = window.innerWidth / window.innerHeight
8888
let range = [-10 * ratio, -10, 10 * ratio, 10]
8989
let colors = palettes[Math.floor(Math.random() * palettes.length)]
90-
let markers = [ null /*, dist*/ ]
90+
// let markers = [ null , dist ]
91+
let markers = [ dist ]
9192
let passes = markers.length
9293

9394
let scatter = createScatter(regl)
@@ -100,29 +101,29 @@ scatter.update(...Array(passes).fill(null).map((x, i) => {
100101
// [0,0.5,1,0.6,2,0.5,2.5,null,3,0.5]
101102
// ][i]
102103
return {
103-
positions: pos,
104-
// positions: [0,0, 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7],
104+
// positions: pos,
105+
positions: [0,0, 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7],
105106

106107
// size: Array(pos.length).fill(15).map(x => Math.random() * x/2 + x/2),
107108
// size: [2, 5, 9, 14, 20, 27, 35, 44, 54],
108-
size: 8,
109-
opacity: .15,
109+
size: 12,
110+
// opacity: .15,
110111

111-
// color: ['red', 'green', 'blue', 'black', 'red', 'red', 'red', 'gray'],
112+
color: ['red', 'green', 'blue', 'black', 'red', 'black', 'red', 'gray'],
112113
// color: Array(N).fill(0).map(() => colors[Math.floor(Math.random() * colors.length)]),
113-
color: 'rgba(0, 0, 255, .5)',
114+
// color: 'rgba(0, 0, 255, .5)',
114115
// color: Array(N * 4).fill(0).map(Math.random),
115116
// borderColor: 'rgba(0, 255, 0, .5)',
116117

117118
// marker: getCharSdf('©'),
118-
// marker: [null, null, null, null, dist, dist, dist, dist],
119-
//marker: markers[i],
119+
marker: [null, null, null, null, dist, dist, dist, dist],
120+
// marker: markers[i],
120121
// marker: Array(N).fill(0).map(() => markers[Math.floor(Math.random() * markers.length)]),
121122

122123
range: range,
123124
// borderSize: 3,
124125
// borderColor: Array(N).fill(0).map(() => colors[Math.floor(Math.random() * colors.length)]),
125-
snap: true,
126+
snap: false,
126127

127128
// viewport: [0,100,300,300]
128129
}

0 commit comments

Comments
 (0)