Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Improve examples #57

Open
kenchris opened this issue Jan 23, 2015 · 5 comments
Open

Improve examples #57

kenchris opened this issue Jan 23, 2015 · 5 comments

Comments

@kenchris
Copy link

According to Marcos it is fine to use ES15 in specs, like 'let' in loops and => instead of functions.

Also s/reason/err/ in the promise catch. And write out gUM. it is not obvious what that is, and examples should be obvious

@anssiko
Copy link
Member

anssiko commented Jan 20, 2017

@astojilj promised to improve the examples inline with the API changes that will land soon.

@anssiko anssiko removed the v2 label Jan 20, 2017
@anssiko
Copy link
Member

anssiko commented Feb 15, 2017

Could reuse some examples for the @astojilj's article: https://01.org/chromium/blogs/astojilj/2017/depth-camera-capture-html5

I suggest checking any example code we add to the spec with http://jshint.com/.

@kenchris
Copy link
Author

The second example is impossible to follow as it only does half of what it says and just contains a lot of ... :-)

https://github.com/01org/depth-camera-web-demo/blob/master/depthdemo.html does more or less what it says, but contains optimizations using extensions etc. If that could be simplified somehow we might be able to include it some how...

Shaders could be multiline using ``

gl.shaderSource(pixel_shader, `
  precision mediump float;

  uniform sampler2D s;
  varying vec2 t;

  void main() {
    vec4 tex = texture2D(s, t); 
    gl_FragColor = vec4(tex.r, tex.g, tex.b, tex.a);
  }`);

@astojilj
Copy link
Contributor

@kenchris
Unfortunately, seems that the second example is not going to be supported (upload 16 bit data to split R&G components).

Usage of floats mandates activating via extension (otherwise no way to use float and it is the only and seems like the best way):
in WebGL2: gl.getExtension('EXT_color_buffer_float');
in WebGL1: gl.getExtension('OES_texture_float'); (I also need to update the demo - thanks for pointing this out)

In WebGL2, EXT_color_buffer_float also brings a possibility to use single component float, with 4x lower bandwidth and much faster upload to texture consumption.

I don't know about the platform where these extensions are not supported.

Good point about multiline, will upload the demo. Thanks.

@kenchris
Copy link
Author

@astojilj I guess we could change the example then to more or less what you are doing in your demo.

I think for the sake of the spec, showing webgl2 should be fine. It is an example after all and it will be widely supported (Safari said they will support it too in addition to their WebGPU work)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants