W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2013

Re: [whatwg] Adding features needed for WebGL to ImageBitmap

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 10 Jul 2013 22:17:00 +0000 (UTC)
To: Gregg Tavares <gman@google.com>, "Tab Atkins Jr." <jackalmage@gmail.com>, Rik Cabanier <cabanier@gmail.com>
Message-ID: <alpine.DEB.2.00.1307102205450.22191@ps20323.dreamhostps.com>
Cc: WHATWG <whatwg@whatwg.org>
On Wed, 19 Jun 2013, Gregg Tavares wrote:
>
> In order for ImageBitmap to be useful for WebGL we need more options

ImageBitmap is trying to just be a generic HTMLImageElement, that is, a 
bitmap image. It's not trying to be anything more than that.

Based on some of these questions, though, maybe you mean ImageData?


> premultipliedAlpha: true/false (default true)
> Nearly all GL games use non-premultipiled alpha textures. So all those
> games people want to port to WebGL will require non-premultipied textures.
> Often in games the alpha might not even be used for alpha but rather for
> glow maps or specular maps or the other kinds of data.

How do you do this with <img> today?


> flipY: true/false (default false)
> Nearly all 3D modeling apps expect the bottom left pixel to be the first 
> pixel in a texture so many 3D engines flip the textures on load. WebGL 
> provides this option but it takes time and memory to flip a large image 
> therefore it would be nice if that flip happened before the callback 
> from ImageBitmap

No pixel is the first pixel in an ImageBitmap. I don't really understand 
what this means.


> colorspaceConversion: true/false (default true)
> Some browsers apply color space conversion to match monitor settings.
> That's fine for images with color but WebGL apps often load heightmaps,
> normalmaps, lightmaps, global illumination maps and many other kinds of
> data through images. If the browser applies a colorspace conversion the
> data is not longer suitable for it's intended purpose therefore many WebGL
> apps turn off color conversions. As it is now, when an image is uploaded to
> WebGL, if colorspace conversion is
> off<http://www.khronos.org/registry/webgl/specs/latest/#PIXEL_STORAGE_PARAMETERS>,
> WebGL has to synchronously re-decode the image. It would be nice if
> ImageBitmap could handle this case so it can decode the image without
> applying any colorspace manipulations.

ImageBitmap doesn't apply any colour space manipulation. That's only done 
when drawing, according to the spec.


On Wed, 19 Jun 2013, Gregg Tavares wrote:
> 
> colorspaceConversion: true   = browser does whatever it thinks is best for
> color images.
> colorspaceConversion: false  = give me the bits in the image file. Don't
> manipulate them with either embedded color data or local machine gamma
> corrections or anything else.

This seems like something that should apply when _using_ the image, not in 
the API that just represents the raw image data.

We could provide a way to say "strip color space information from any 
images loaded this way", but I don't understand why you'd include color 
space information that was wrong in the first place.


>     c = document.createElement("canvas");
>     ctx = c.getContext("2d");
>     i = ctx.getImageData(0, 0, 1, 1);
>     i.data[0] = 255;
>     ctx.putImageData(i, 0, 0);
>     i2 = ctx.getImageData(0, 0, 1, 1);
>     console.log(i2.data[0])  // prints 0 on both FF and Chrome

This is using ImageData, not ImageBitmap. Are we talking about the same 
thing here? I'm confused.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 10 July 2013 22:17:25 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:22 UTC