SebMon / BachelorProject

Magnus and Sebastian's bachelor project repository
0 stars 0 forks source link

Research WebGL #1

Open SebMon opened 1 year ago

SebMon commented 1 year ago

WebGL is primarily meant for rendering 2d and 3d graphics utilizing the GPU. This is done by passing math to WebGL which then displays it in an HTML canvas. As far as I can tell, there is not a built in method to fetch the calculated data, instead of rendering it to the canvas, BUT there is a way to use the canvas to store this data: Pixels (see https://www.youtube.com/watch?v=qkDg-Y9iHBA). Each pixel has an RGB value, and you can fetch the information about the canvas and then read the pixels' RGB values. This way, we can store numbers by coloring each pixel and reading this color. This does have various limits (e.g. WebGL not supporting bitshifting operations), but can be used for things such as machine learning - lots of relatively simple math calculations that can be batched together, and the GPU can then do them VERY FAST (see TensorFire).

There might be other ways to utilize WebGL than reading pixels off of the canvas that I have not found.

There is a tool called WebCL (Web Compute Library, see https://www.khronos.org/webcl/) that is specifically built to utilize the GPU for "heterogeneous parallel computing" (many maths), without having to go through some canvas and graphics stuff, but it is not supported by any web browsers without the use of plug-ins.