Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!