Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
How can I access the values given by gpu.js

I am learning to use gpu.js to do calculations in the GPU. I am able to do my calculations for two JavaScript matrices a and b and to display the result as a canvas image.

Question: How can I access the calculated numerical values? The values are generated by

const render = gpu.createKernel(function(a,b) {
        this.color(
    Math.sqrt(-2*Math.log(a[this.thread.y][this.thread.x]))*Math.cos(2*3.14*b[this.thread.y][this.thread.x]), 
    Math.sqrt(-2*Math.log(a[this.thread.y][this.thread.x]))*Math.sin(2*3.14*b[this.thread.y][this.thread.x]),
     0, 1);
}).setOutput([512, 512]).setGraphical(true);

Perhaps there is another setting instead of .setGraphical(true) which creates a standard JavaScript array, which I can then access.

Or perhaps (I don't think this is the right way) I should access the values of the canvas with some code like

var ctx = canvas.getContext("2d");
var p = ctx.getImageData(x, y, 1, 1).data;

as in Get pixel color from canvas, on mousemove

My code is at http://integraali.com/jsxgraph/kuvat/turbojs/kuvasta4.html (I tried to put my code to JSFiddle, but the code did not work there. Perhaps JSFiddle does not allow to load gpu.js, I don't know what is the issue.)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

After 3 hours, I found the answer from here: https://gist.github.com/globalpolicy/bb74dbbe7500b9d51da00b4797c7064d

Works in my website: http://integraali.com/jsxgraph/kuvat/gpujs/index.html

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda