Skip to content

1.3.3

Choose a tag to compare

@xiaoiver xiaoiver released this 18 Oct 02:10
· 45 commits to master since this release
34b73df

Patch Changes

  • fbcb785: Support floating-point texture.

Allow texture with floating-point pixel. Both WebGL1 & WebGL2 need some extensions:

  • The OES_texture_float & WEBGL_color_buffer_float extension is needed in WebGL1.
  • The EXT_color_buffer_float extension is needed in WebGL2.
const renderTarget = device.createRenderTarget({
  format: Format.F32_RGBA, // Float format
  width: $canvas.width,
  height: $canvas.height,
});

Then we can output a fixed color in fragment shader:

out vec4 outputColor;

void main() {
  outputColor = vec4(0.5, 0.4, 0.3, 1.0);
}

Finally we try to read floating-point data from this render target:

const readback = device.createReadback();
const result = await readback.readRenderTarget(
  renderTarget,
  250,
  250,
  1,
  1,
  new Float32Array(4),
);
console.log(result); // [0.5, 0.4, 0.3, 1.0]