-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
About texture and image data formats #728
Comments
Last parameter has
Usually, runtime passes
|
OK, maybe I'll have to read more in different docs here, but until now, I fetched the The quoted passage from the WebGL spec seems to say that this should work even when the type is not RGBA, and that the However, for non-JavaScript, non-Browser-based environments, I assume that the |
If you have a variable of var img = document.getElementById('myimg');
gl.texImage2D(target, 0, internalformat, format, type, img); WebGL will convert data to the specified
For PNG/GIF/JPG images For proper support of traditional GPU texture formats, |
Thanks for these inputs. Regarding the particular case of JavaScript, I'll have to read more about how this plays together (or can be combined with) asynchronous operations. My gut feeling until is that using the But if I understood this correctly, it is valid to ignore the |
Much simpler:
Both
|
Closing as there's no action items here. Advanced texture transmission will be covered by CTTF/KTX2. |
Sorry, this is likely not a real "issue". And it's hard to phrase this as a clear question. But after having created basic glTF viewers in Java and JavaScript, there is still this uncomfortable feeling of not having understood the intended image- and texture handling properly.
There are various pieces of information related to textures and image data formats in the discussions of previous issues, and in some issues that are still open ( #620 , #640 ...). I have to admit that I did not yet wrap my head around all the relevant points of these discussions, and likely am not as deeply familiar with some details and best practices in OpenGL/WebGL/JavaScript as I should be.
A
texture
basically contains several GL constants, and a reference to animage
:The constants are exactly the parameters that are supposed to be passed to
texImage2D
.(Fortunately, in WebGL 1, the
format
and theinternalFormat
must be the same. This simplifies things, considering the can of worms that is opened with format conversions ).As the last parameter, this function receives the image data that was read from the
source
image of the texture. From my understanding, in JavaScript, the image data will usually (but not necessarily) be anImageData
object. According to the documentation, thedata
that may be obtained from thisImageData
object is...So I assume the following: When the
ImageData
version of this function is used, then theformat
/type
have to beGL_RGBA
/GL_UNSIGNED_BYTE
. Is this correct?Conversely, and what mainly confuses me here: You may not even know in which
format
/type
you receive the image data. Particularly, the data may simply "appear" in a format that is different from the one that is given in thetexture
.As an example, I'm thinking about Java here. You can write
and then you don't know (but have to check) whether the image data type is
or some other type. This depends on several factors, e.g. whether the image contains transparency etc. Similarly, there might be an image loading library in JavaScript or C++ that "by default" delivers the image data as
GL_RGBA
/GL_UNSIGNED_INT
orGL_BRG
/GL_UNSIGNED_BYTE
.How is this supposed to be handled by a viewer? Wouldn't it be legitimate to simply ignore the
format
/type
, and just make sure that the image data at hand is somehow uploaded to GL?I know, the type information will be crucial for "custom" image types and more generic image sources (i.e. images that are not read from PNG/JPG files). But for the common case, I wonder whether one should take the detour of converting image data that was read e.g. as
INT_ARGB
into the format that is given in thetexture
, when the outcome is always the same: The image data can be used by OpenGL, regardless of how it got there...The text was updated successfully, but these errors were encountered: