[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Loading WebGLBuffer from an HTMLImageElement

On Tue, Apr 12, 2011 at 12:34 PM, Glenn Maynard <glenn@zewt.org> wrote:
> On Tue, Apr 12, 2011 at 1:48 PM, Kenneth Russell <kbr@google.com> wrote:
>> Uploading an image to be used as vertex data is a hack. You'll only be
>> guaranteed lossless data transfer with PNGs. I don't think we would
>> want to add these entry points in the general case as they would
>> promote poor application development practices. Why do you not want to
>> download binary data?
> In this case, I want to load a user-provided image to generate a
> histogram.  The user-supplied image may be a remote URL, which I can
> load and manipulate but not access directly due to same-origin
> restrictions.
> The first pass of that (per channel) would be to use the pixel data to
> generate points.  It could use vertex shader texture sampling, but
> there's no guarantee that any vertex texture units exist (and most
> current implementations don't implement them at all), so using a
> vertex buffer here eliminates the dependency on optional requirements.
>  (It's also simpler to implement, and probably faster.)
> (I'm not interested in weird hacks like, say, loading mesh data from a
> PNG.  That's not very useful--PNG won't be good at compressing it, and
> you'd need to compound the hack badly to get anything other than 8-bit
> integers out of it.)

Thanks, I understand your use case now. However, I am still concerned
that adding APIs to upload images, canvases and video elements into
(vertex) buffers will encourage gross misuse.

I think it should be possible for you to achieve your use case by
accumulating summary statistics in a fragment shader while repeatedly
downsampling the image. I've spoken with colleagues that have computed
mean and standard deviation of an image's brightness in a fragment
shader using this technique. Could you give this approach some


>> Second, some
>> WebGL implementations today do support floating point textures via the
>> OES_texture_float extension; see
>> http://www.khronos.org/registry/webgl/extensions/ .
> I hadn't seen that page.  I suggest adding it to
> http://www.khronos.org/webgl/; after some searching I only see it
> linked from the wiki.

It's linked from the specification as well.

There's some confusion on the Khronos site between the landing page
for some APIs (like WebGL) and the associated registry. The latter is
located at http://www.khronos.org/registry/webgl/ . I would rather not
add lots of links to the landing page until this gets resolved.

You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl