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

Re: [Public WebGL] Adding internalformat param to all texImage2d variants



On 18 May 2010, at 19:00, Chris Marrin wrote:

> 
> On May 17, 2010, at 5:57 PM, Vladimir Vukicevic wrote:
> 
>> 
>> ----- "Kenneth Russell" <kbr@google.com> wrote: 
>> On Fri, May 14, 2010 at 4:06 PM, Chris Marrin <cmarrin@apple.com> wrote:
>>> 
>>> I would feel comfortable doing that if the browser implementors agree that this is information we can get from the HTML image element.
>> 
>> WebKit would currently always return RGBA as the internal format, or
>> perhaps RGB if we could determine that the original image has no alpha
>> channel. We might be able to improve the precision of this query over
>> time. Does this sound acceptable and/or useful?
>> We would do the same for now.  Would be straightforward to improve in the future.
> 
> That doesn't solve the X3DOM problem today. Unless they add an internalformat property to ImageTexture, there would be no way to get a 1 or 2 channel image into the system.
> 
> FWIW, WebKit remembers whether or not an image has an alpha channel as an optimization. I haven't looked at the code, but I suspect it would not be hard to remember if the image has 1 or 2 channels as well. If we were to add getTexLevelParameter() to the spec as Ken suggests, we could return this information.
> 
> Here's how I think it would work. We would add an internalformat param to all texImage2D() forms that don't currently have it. We would also add getTexLevelParameter() and all the enums described here:
> 
> 	http://www.opengl.org/sdk/docs/man/xhtml/glGetTexLevelParameter.xml
> 
> Some of the queried values would return default values, e.g., TEXTURE_DEPTH (always 1), TEXTURE_BORDER (always 0), etc.
> 
> If you pass one of the legal internalformat enums to texImage2D() it will convert the source image into that format. In that case getTexLevelParameter would always return that value for gl.TEXTURE_INTERNAL_FORMAT. You can also pass NONE which would convert the image to the "original" format, according to the table:
> 
> 1 channel: LUMINANCE
> 2 channel: LUMINANCE_ALPHA
> 3 channel: RGB
> 4 channel: RGBA
> 
> Note that there is no way to create an ALPHA texture from a 1 channel image. This is a problem in X3D as well. There is no way I know of to create an ImageTexture that is alpha-only. I don't think this is a problem. You'd just have to know the image you're loading is 1 channel and then set internalformat to ALPHA. 
> 
> The form of texImage2D which takes an ArrayBufferView would not all NONE as an internalformat and would generate a GL error.
> 
> How does all that sound?

Sounds perfect! And I still believe this is not only useful for X3DOM. Getting e.g. an alpha-mask as single-channel texture into your system is also useful for other systems. 

best regards
johannes

> 
> -----
> ~Chris
> cmarrin@apple.com
> 
> 
> 
> 
> 
> -----------------------------------------------------------
> You are currently subscribe to public_webgl@khronos.org.
> To unsubscribe, send an email to majordomo@khronos.org with
> the following command in the body of your email:
> 

--
Dr. Johannes Behr
Leiter Projektbereich VR

Fraunhofer-Institut für Graphische Datenverarbeitung IGD
Fraunhoferstr. 5  |  64283 Darmstadt  |  Germany
Tel +49 6151 155-510  |  Fax +49 6151 155-196
johannes.behr@igd.fraunhofer.de  |  www.igd.fraunhofer.de


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