[Public WebGL] y-orientation for texImage2D from HTML elements

Jeff Gilbert [email protected]
Fri Dec 7 16:52:39 PST 2012

This is an interesting point, and formalizes what I was referring to as texImage2D's 'automatic' handling of TypedArray row order. However, this also highlights the difference between the effect of UNPACK_Y_FLIP on TypedArray and HTML element uploads.

However, with the spec in its current state, it seems willfully naive of the API to do all the image data converting and reformatting, then, knowing that for texImage2D, by spec, "rows are stacked from bottom to top forming the image". Since we also clearly understand that HTML elements are treated as origin-top-left, it seems naive that the API should not also convert the row order, given everything else we convert.

If we modify our definition of the behavior of texImage, then, when uploading HTML elements, it may be understandable to upload them top-row-first, since that's their origin. However, in this case, UNPACK_Y_FLIP becomes a hacky way to specify that we want HTML elements uploaded as if their origin was at the bottom-left. It seems somewhat perverse that for this use-case, we would require TypedArray and HTML element texImage calls to be interspersed with twiddling of UNPACK_Y_FLIP, when what we really want to set here is which origin to grant to HTML elements. However, this is much more self-consistent than what is specified today.

I am much more satisfied by our implementation of HTML element uploads with this modified definition of texImage. However, we should probably check with the GL or GLES group to check that there were not reasons for the current wording that we have not considered.

I do feel this is changing the definition to match our implementations, though.

----- Original Message -----
From: "Georg Kolling" <[email protected]>
To: "Mark Callow" <[email protected]>, "Jeff Gilbert" <[email protected]>
Cc: "Gregg Tavares (社用)" <[email protected]>, "public webgl" <[email protected]>
Sent: Friday, December 7, 2012 7:31:41 AM
Subject: RE: [Public WebGL] y-orientation for texImage2D from HTML elements

In my opinion the fault here lies with the GL specification which incorrectly applies a physical orientation to an abstract coordinate space. 

In reality TexImage2D accepts pixel data in “origin-first, S-major (S-increasing, T-increasing)” order. The first pixel passed, at the memory address given, is taken to be at (or near) the texture space origin. Each row of pixels form a line along the positive S axis, and subsequent rows are located at increasing T. 

Physical orientation has no meaning in an abstract coordinate space such as texture space. Positive T direction is neither “up” nor “down” (or left-right, front-back, north-south, you get the idea). 

If you take the description above, i.e. “origin-first” it immediately becomes clear that if you want to preserve the origin location, HTML elements with their origin in the top-left corner should be passed to TexImage2D top-left corner first. 



From: [email protected] [mailto:[email protected]] On Behalf Of Mark Callow 
Sent: 07 December 2012 03:33 
To: Jeff Gilbert 
Cc: "Gregg Tavares ( 社用 )"; public webgl 
Subject: Re: [Public WebGL] y-orientation for texImage2D from HTML elements 

On 2012/12/07 12:07, Jeff Gilbert wrote: 

At the absolute minimum, we need wording in the spec that spells this out: "We send decoded image data top-row-first into texImage2D, which, per spec, expects bottom-row-first data. This means that textures uploaded this way will be upside down compared to textures uploaded via other methods. You can force HTML element uploads to upload bottom-row-first by using UNPACK_FLIP_Y_WEBGL=true, but this also flips the order that TypedArray rows are uploaded." 

I have no objection to adding a note to the spec. I would prefer something along the lines of: 

The default texture coordinate system in OpenGL is such that the first row of data loaded by texImage2D will appear at bottom of the texture. However the first row of data in HTML elements is the logical top of the image therefore textures uploaded from HTML elements will appear upside down. One way of adjusting for this is to set UNPACK_FLIP_Y_WEBGL=true. Then texImage2D will flip the rows of data as it uploads them. UNPACK_FLIP_Y_WEBGL affects the operation of texImage2D for all data sources. 




注意:この電子メールには、株式会社エイチアイの機密情報が含まれている場合が有ります。正式なメール受信者では無い場合はメール複製、 再配信または情報の使用を固く禁じております。エラー、手違いでこのメールを受け取られましたら削除を行い配信者にご連絡をお願いいたし ます . 

NOTE: This electronic mail message may contain confidential and privileged information from HI Corporation. If you are not the intended recipient, any disclosure, photocopying, distribution or use of the contents of the received information is prohibited. If you have received this e-mail in error, please notify the sender immediately and permanently delete this message and all related copies.

You are currently subscribed to [email protected]
To unsubscribe, send an email to [email protected] with
the following command in the body of your email:
unsubscribe public_webgl

More information about the public_webgl mailing list