Skip to content

Commit cc11219

Browse files
committed
Running standard
1 parent 9c71a1a commit cc11219

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

bin/build-gallery.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ function generateGallery (files) {
334334
</body>
335335
</html>`
336336

337-
fs.writeFile('www/gallery.html', html, function(err){
337+
fs.writeFile('www/gallery.html', html, function (err) {
338338
if (err) {
339339
throw err
340340
}
@@ -372,7 +372,7 @@ mkdirp('www/gallery', function (err) {
372372
b.transform(es2020)
373373
b.bundle(function (err, bundle) {
374374
if (err) {
375-
console.log ("Problem with", file);
375+
console.log('Problem with', file)
376376
throw err
377377
}
378378
console.log('bundled', file)

example/matrix_code.js

+28-29
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
const numColumns = 60
2121
const glyphTextureColumns = 8
2222
const glyphSequenceLength = 57
23-
const msdfURL = "assets/matrix_glyphs_msdf.png"
24-
const paletteURL = "assets/matrix_palette.png"
23+
const msdfURL = 'assets/matrix_glyphs_msdf.png'
24+
const paletteURL = 'assets/matrix_palette.png'
2525

26-
document.body.style = "background-color: black;"
26+
document.body.style = 'background-color: black;'
2727
document.addEventListener('touchmove', e => e.preventDefault(), { passive: false })
2828
const canvas = document.body.appendChild(document.createElement('canvas'))
2929
const fit = require('canvas-fit')
@@ -33,14 +33,14 @@ const regl = require('../regl')({
3333
canvas,
3434
extensions: [
3535
'OES_texture_half_float',
36-
'OES_texture_half_float_linear',
36+
'OES_texture_half_float_linear'
3737
],
3838
optionalExtensions: [
3939
// These extensions are also needed, but Safari misreports that they are missing
4040
'EXT_color_buffer_half_float',
4141
'WEBGL_color_buffer_float',
4242
'OES_standard_derivatives'
43-
],
43+
]
4444
})
4545

4646
// These two framebuffers are used to compute the raining code.
@@ -152,13 +152,12 @@ const updateRain = regl({
152152

153153
uniforms: {
154154
glyphSequenceLength,
155-
time: regl.context('time'),
155+
time: regl.context('time')
156156
},
157157

158-
framebuffer: ({tick}) => state[(tick + 1) % 2] // The crucial state FBO alternator
158+
framebuffer: ({ tick }) => state[(tick + 1) % 2] // The crucial state FBO alternator
159159
})
160160

161-
162161
// We render the code into an FBO using MSDFs: https://github.com/Chlumsky/msdfgen
163162
const renderRain = regl({
164163
vert: `
@@ -173,7 +172,7 @@ const renderRain = regl({
173172
}
174173
`,
175174

176-
frag:`
175+
frag: `
177176
#ifdef GL_OES_standard_derivatives
178177
#extension GL_OES_standard_derivatives: enable
179178
#endif
@@ -211,9 +210,9 @@ const renderRain = regl({
211210
`,
212211

213212
uniforms: {
214-
glyphMSDF: regl.prop("glyphMSDF"),
213+
glyphMSDF: regl.prop('glyphMSDF'),
215214
width: regl.context('viewportHeight'),
216-
height: regl.context('viewportWidth'),
215+
height: regl.context('viewportWidth')
217216
},
218217

219218
framebuffer: renderedFBO
@@ -237,10 +236,10 @@ const highPass = regl({
237236
}
238237
`,
239238
uniforms: {
240-
tex: regl.prop("tex"),
239+
tex: regl.prop('tex'),
241240
threshold: 0.3
242241
},
243-
framebuffer: regl.prop("fbo")
242+
framebuffer: regl.prop('fbo')
244243
})
245244

246245
// A 2D gaussian blur is just a 1D blur done horizontally, then done vertically.
@@ -264,29 +263,29 @@ const blur = regl({
264263
}
265264
`,
266265
uniforms: {
267-
tex: regl.prop("tex"),
268-
direction: regl.prop("direction"),
266+
tex: regl.prop('tex'),
267+
direction: regl.prop('direction'),
269268
height: regl.context('viewportWidth'),
270-
width: regl.context('viewportHeight'),
269+
width: regl.context('viewportHeight')
271270
},
272-
framebuffer: regl.prop("fbo")
271+
framebuffer: regl.prop('fbo')
273272
})
274273

275274
// The pyramid of textures gets flattened onto the source texture.
276275
const combineBloom = regl({
277276
frag: `
278277
precision mediump float;
279278
varying vec2 vUV;
280-
${verticalBlurPyramid.map((_, index) => `uniform sampler2D tex_${index};`).join("\n")}
279+
${verticalBlurPyramid.map((_, index) => `uniform sampler2D tex_${index};`).join('\n')}
281280
uniform sampler2D tex;
282281
void main() {
283282
vec4 total = vec4(0.);
284-
${verticalBlurPyramid.map((_, index) => `total += texture2D(tex_${index}, vUV);`).join("\n")}
283+
${verticalBlurPyramid.map((_, index) => `total += texture2D(tex_${index}, vUV);`).join('\n')}
285284
gl_FragColor = total + texture2D(tex, vUV);
286285
}
287286
`,
288-
uniforms: Object.assign({ tex: regl.prop("tex") }, pyramidUniforms(verticalBlurPyramid)),
289-
framebuffer: regl.prop("fbo")
287+
uniforms: Object.assign({ tex: regl.prop('tex') }, pyramidUniforms(verticalBlurPyramid)),
288+
framebuffer: regl.prop('fbo')
290289
})
291290

292291
// Finally, the values are mapped to colors in a palette texture.
@@ -320,7 +319,7 @@ const colorizeByPalette = regl({
320319

321320
uniforms: {
322321
ditherMagnitude: 0.05,
323-
palette: regl.prop("palette"),
322+
palette: regl.prop('palette'),
324323
tex: bloomedFBO,
325324
time: regl.context('time')
326325
}
@@ -342,9 +341,9 @@ const setupQuad = regl({
342341
},
343342

344343
uniforms: {
345-
lastState: ({tick}) => state[tick % 2],
344+
lastState: ({ tick }) => state[tick % 2],
346345
numColumns,
347-
glyphTextureColumns,
346+
glyphTextureColumns
348347
},
349348

350349
depth: { enable: false },
@@ -375,7 +374,7 @@ require('resl')({
375374
},
376375
onDone: resources => {
377376
setupQuad({}, updateRain)
378-
regl.frame(({viewportWidth, viewportHeight}) => {
377+
regl.frame(({ viewportWidth, viewportHeight }) => {
379378
// All the FBOs except the compute FBOs need to be sized to the window.
380379
renderedFBO.resize(viewportWidth, viewportHeight)
381380
bloomedFBO.resize(viewportWidth, viewportHeight)
@@ -389,10 +388,10 @@ require('resl')({
389388
setupQuad(() => {
390389
updateRain()
391390
renderRain(resources)
392-
highPassPyramid.forEach(fbo => highPass({fbo, tex: renderedFBO}))
393-
horizontalBlurPyramid.forEach((fbo, index) => blur({ fbo, tex: highPassPyramid[index], direction: [1, 0]}))
394-
verticalBlurPyramid.forEach((fbo, index) => blur({ fbo, tex: horizontalBlurPyramid[index], direction: [0, 1]}))
395-
combineBloom({tex: renderedFBO, fbo: bloomedFBO})
391+
highPassPyramid.forEach(fbo => highPass({ fbo, tex: renderedFBO }))
392+
horizontalBlurPyramid.forEach((fbo, index) => blur({ fbo, tex: highPassPyramid[index], direction: [1, 0] }))
393+
verticalBlurPyramid.forEach((fbo, index) => blur({ fbo, tex: horizontalBlurPyramid[index], direction: [0, 1] }))
394+
combineBloom({ tex: renderedFBO, fbo: bloomedFBO })
396395
colorizeByPalette(resources)
397396
})
398397
})

0 commit comments

Comments
 (0)