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

Re: [Public WebGL] Moving float color buffer proposals to draft (was Re: Fixing the OES_texture_float mess)

This discussion is rather pointless as it is too late to change this version of WebGL but it is important that people understand the intent of the API design to prevent cock-ups like this in the future.

In OpenGL {,ES} textures have an external and an internal format. The format & type parameters specify the external format. The internalformat parameter specifies the internal format. In ES, the external and internal formats are the same modulo allowable precision changes which I don't think any recent implementation does. The reason that the type parameter influences the internal format in ES is because the internal format is the external format.

When I wrote "GL_UNSIGNED_SHORT_4_4_4_4 and GL_RGBA4 are the same format" I was referring to the memory layout not the enum token values and that is also what I refer to when I say the internal and external formats are the same.

On 2012/11/15 18:46, Gregg Tavares (社用) wrote:

In ES if you specified

texImage2D(GL_TEXTURE2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_FLOAT, data)

where data points to unsigned byte data (which is in effect what WebGL's OES_texture_float is telling the app to do)

No it's not. format and data tell it type of data you are supplying. WebGL will supply that data. If you tell it format = GL_RGBA, type = GL_FLOAT WebGL will supply GL_RGBA, GL_FLOAT (16 bytes per color).
You are viewing this from the perspective of a WebGL implementer. You need to pass type=FLOAT to ES because that is the external format of the data you are providing to ES.

From the perspective of a WebGL application programmer, the external format is whatever the format of the HTML elements is (most like RGB888 or RGBA8888) and the internal format he/she wants is FLOAT but, according to the real meaning of the type parameter, OES_texture_float is telling him/her to misclassify his/her external data as FLOAT. Hence the example I gave above.

The texImage2D commands that take elements should not even have a type parameter. It is unnecessary as the element has a known (to the WebGL implementation) external format. internalformat should be used to tell WebGL what internal format the application would like used to store the resulting texture. That is its purpose in GL and ES. See OES_required_internal_format or the OpenGL ES 3.0 specification.



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

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.