How to use HTML5 canvas as a WebGL texture

I want:

  • Set common values ​​for case i.
  • Render compute shader for case i for the HTML5 tag <canvas>.
  • Use the content <canvas>(output of the output i case) as a texture in the next rendering pass.
  • Repeat for all cases.
  • Extract responses in JS from color data.

I am trying to create a computational shader and have to transfer the value per pixel (fragment) for each rendering step. A simple example would be to increase the blue pixel value with each render call.

those.

pass 1: b=1
pass 2: b=2
pass 2: b=3
etc.
  • Is such a shader loop possible?

  • a'carry ( , )?

+4
1

:

.

  1. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, gl.canvas);
    

    .

  2. , .

    , , ( , , ). .

+9

Source: https://habr.com/ru/post/1532918/


All Articles