mirror of
https://github.com/gpujs/gpu.js.git
synced 2025-12-08 20:35:56 +00:00
...it kind of snowballed from some needs Fixes #521 - If `tactic` is not set, check precision allowed from WebGL, and automatically change based off needs, otherwise use value from `tactic`. Fixes #535 - Internally check if texture from argument is the same as output, if so, clone this texture, and then clean it up after the kernel runs. Fixes #536 - Normalize all declarations to non-destructured, and then parse Fixes #537 - Change logic Fixes #538 - Found the GL script that would work, and reduced the methods to use it Fixes #539 - Found a better way of testing random, and this gives me an error for 1 in 10 runs, acceptable Some refactoring for less duplicate code and documentation
47 lines
935 B
HTML
47 lines
935 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Slow Fade</title>
|
|
</head>
|
|
<body>
|
|
<h1>Slow Fade</h1>
|
|
<div>
|
|
<canvas id="c"></canvas>
|
|
</div>
|
|
</body>
|
|
<script src="../dist/gpu-browser.min.js"></script>
|
|
<script>
|
|
const canvas = document.getElementById('c');
|
|
const gpu = new GPU({
|
|
canvas: canvas,
|
|
mode: 'gpu'
|
|
});
|
|
const dim = 512;
|
|
const kernel = gpu.createKernel(
|
|
function(x) {
|
|
this.color(
|
|
(x * (this.thread.y + this.thread.x)) / 1024,
|
|
(x * (this.thread.y * this.thread.x)) / (1024 * 1024),
|
|
(x * (this.thread.y * 2 * this.thread.x)) / (1024 * 2),
|
|
1
|
|
);
|
|
},
|
|
{
|
|
useLegacyEncoder: true,
|
|
output: [dim, dim],
|
|
graphical: true
|
|
}
|
|
);
|
|
|
|
let param = 0;
|
|
const doDraw = () => {
|
|
kernel(param);
|
|
param += 0.001;
|
|
window.requestAnimationFrame(doDraw);
|
|
};
|
|
|
|
window.requestAnimationFrame(doDraw);
|
|
</script>
|
|
</html>
|