-
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
Image and image filter / mipmapping #40
Comments
Ok, I am curious why it shouldn't be handled with techniques/passes, I would prefer not adding too much concept especially if they can be handled generically. |
What I was saying too is that the surface information is important for the run-time, but the image indirection not so much. In COLLADA it is important, as it is designed to enable decoupling the image format from the format in the surface. |
Currently in WebGL, the sampler state (filters and repeat) is part of the texture object (however, they are separate in OpenGL ES 3.0). This means that we can't bind a texture twice, each with a different sampler state, for the same draw call. To do so, we have to duplicate the texture since the sampler state is part of the texture. Currently, glTF decouples the image and the sampler state, making it possible to declare two parameters used in the same technique that use the same image, but different sampler state. Although this is a rare case, it puts an implementation burden on the client, who will have to detect this and duplicate the texture to create a conformant implementation. To solve this, all I suggest is wording in the spec that explicitly disallows this for the WebGL 1.0.x profile. Assuming WebGL 2.0 adds sampler objects, the WebGL 2.0 profile would lift this restriction. |
yes, but also have the converted to duplicate automatically the texture. On Wed, Apr 17, 2013 at 12:51 PM, Patrick Cozzi notifications@github.comwrote:
|
@pjcozzi ok, in my first comment I misunderstood what you meant here... |
@pjcozzi weither you have or not sampler objects, you do not need to duplicate the texture you can change the filter and wrap mode for given texture on the fly OR duplicate the texture. It's a trade off & decision that has to be made on client side. It's easy to detect that different samplers are used for the same texture. In some situation when you have enormous images it's better to actually change the wrap mode, even if this happens each frames, but if you have reasonnably small images duplicating might be cleaner... It looks that you avoid the possibility of changing the wrap/filter mode on the fly but this does work (and even better with sampler objects) |
AFAIK in WebGL 1.0, If you have one texture bound to two different texture units used in the same draw call, they must use the same sampler state because the sampler state is part of the texture. This is one reason why GL_ARB_sampler_objects was introduced. |
Ah yes, you're right. But I overlooked something else in my previous comment. |
Yes, this is exactly what I am saying, but we should make it easy for clients. This is a pain to have to implement; we've done it before for COLLADA. I suggest just explicitly disallowing this in the WebGL 1.0.x profile of glTF. I don't know of any models that do this in practice, so I don't see enough value in making clients think they have to support this. When GL_ARB_sampler_objects are supported, we can support this in a later profile. |
The decision of duplicating or not the image is on the client side, and I don't think it is a pain to implement. You can just create a hascode with the sampler infos. If a client really wants to prevent re-applying wrap / filter mode then we probably need a textureID (as Remi suggested), and then we could decide in the converter if textures needs to be duplicated or not. Though, I am not sure yet how the schema will look... |
following the email discussion. More to that point, I ran into a problem. Loading one glTF, and then another one. They had the same imageID, pointing to a different image. not using imageID and using the image path only fixed the problem immediately. So I think that the spec should be changed to:
before:
after:
|
Thanks Remi. I like most of your proposal. About the image indirection I have to disagree:
|
I agree with @fabricerobinet about image ID "leakage" between scenes: it We should definitely allow for images to be packed ("concatenated"), this Tony On Fri, May 10, 2013 at 9:16 AM, Fabrice Robinet
Tony Parisi tparisi@gmail.com Read my book! WebGL, Up and Running |
@RemiArnaud @pjcozzi @tparisi I can move forward on the converter about this. I explained above why we should keep the image property, it should be seen more as a way to share images client side than an indirection (among other reasons above).. But eventually, texture should probably point to a "source" property that could be either an "image" or a "video" (still to be introduced in the spec). We will discuss this in another issue. (about source for media...). @pjcozzi can you remind me what was your proposal ? I see you prefer to not allow to specify different filter for a given texture and the updated proposal does not (not easily, but still possible if developer really want to). |
👍
Currently in WebGL, the sampler state (filters and repeat) is part of the texture object (however, they are separate in OpenGL ES 3.0). This means that we can't bind a texture twice, each with a different sampler state, for the same draw call. To do so, we have to duplicate the texture since the sampler state is part of the texture. Currently, glTF decouples the image and the sampler state, making it possible to declare two parameters used in the same technique that use the same image, but different sampler state. Although this is a rare case, it puts an implementation burden on the client, who will have to detect this and duplicate the texture to create a conformant implementation. To solve this, all I suggest is wording in the spec that explicitly disallows this for the WebGL 1.0.x profile. Assuming WebGL 2.0 adds sampler objects, the WebGL 2.0 profile would lift this restriction.
Later, we would do this to mirror sampler_objects, which are in ES 3.0. |
@pjcozzi actually, I was referring to the latest iteration based on Remi's feedback to introduce The other change a bit on side of this that I would like to introduce is to use |
Just spent some time trying to put all this in JSON...
but... then what if someone wants to pass manually the mip levels?, I propose this:
|
I really like this direction. For specifying the mip levels:
Because we describe level 0 as the base level.
having sources are needed regardless of the levels, they are required for texture cube, where you need 6 images even if you specify just one level for each of them.
Yes, If you provide mip levels, you need to provide them all till you reach 1x1 size otherwise the mip map chain will be considered incomplete.
I would that if filtering specify mip mapping AND there is no |
Concretely, I'm proposing something like this: 2D texture. No mipmapping: "texture0" : {
"target" : "TEXTURE_2D",
"internalFormat" : "RGBA",
"format" : "RGBA"
"source" : "image_0",
"sampler" : "sampler0"
} 2D texture. Mipmapping: "texture0" : {
"target" : "TEXTURE_2D",
"internalFormat" : "RGBA",
"format" : "RGBA",
"mipLevels" : [ "image_0_level0", "image_0_level1", "image_0_level2" ],
"sampler" : "sampler0"
} 2D texture. Client-side generated mipmaps: "texture0" : {
"target" : "TEXTURE_2D",
"internalFormat" : "RGBA",
"format" : "RGBA"
"source" : "image_0",
"sampler" : "sampler0",
"generateMipmap" : true
} As for cube maps... Cube map. No mipmapping. "texture1" : {
"target" : "TEXTURE_CUBE",
"internalFormat" : "RGBA",
"format" : "RGBA"
"sources" ["img1_negX","img1_posX","img1_negY","img1_posY","img1_negZ","img1_posZ"],
"sampler" : "sampler1"
}, Cube map. Mipmapping. "texture1" : {
"target" : "TEXTURE_CUBE",
"internalFormat" : "RGBA",
"format" : "RGBA"
"mipLevels" [["img1_negX_level0", "img1_negX_level1", "img1_negX_level2"],["img1_posX_level0", ...],["img1_negY_level0", ...],["img1_posY_level0", ...],["img1_negZ_level0", ...],["img1_posZ_level0", ...]],
"sampler" : "sampler1"
}, Cube map. Client-side mipmaps. "texture1" : {
"target" : "TEXTURE_CUBE",
"internalFormat" : "RGBA",
"format" : "RGBA"
"sources" ["img1_negX","img1_posX","img1_negY","img1_posY","img1_negZ","img1_posZ"],
"sampler" : "sampler1",
"generateMipmap" : true
}, My only questions here are:
|
Thanks for putting this together Patrick. I have 2 issues:
Same here, I agree with this trade-off
I was not particularly happy to have an object but removing |
OK with me since it is minimal and complete, but this is likely to be a source of bugs. Users will just use the sampler without thinking to generate mipmaps. GL developers already do it all the time, and now we are making it really easy for them. We need to document it prominently.
Here's the code for it: if (typeof texture.source !== 'undefined) {
// call texImage2D with level 0
} else {
for each texture.mipLevels {
// call texImage2D with each level
}
} Compared to the original proposal: // call texImage2D with level 0
if (typeof texture.nextLevels === 'undefined) {
for each texture.nextLevels {
// call texImage2D with level
}
} The original is not as bad as I thought. Maybe rename As for string vs. object, if |
If we keep So I could live with Remember what a level is, in the base level ( == My point is to show that [*] I did this simplification to avoid an indirection right under texture, as in most case we'll just deal with the base level. @pjcozzi |
@fabrobinet keeping it as an object is fine with me; I'm just trying to avoid lots of indirection as we've grown glTF into more levels of indirection that I expected and that our original charter called for. However, so far, it hasn't been a pain to implement. Leave the object or leave the string and a later glTF version can allow either a string or an object with multiple properties. |
Thank you, I will implement this right after the skinning... |
done f4d8f40 . Removing the converter keyword then. |
flagging as resolved. |
The WG agreed that providing images of mipmaps wasn't critical for V1.0 and that just specifying the flag for mipmapping generation would be enough. Watchers of the project are welcome to provide feedback about this decision. |
@tparisi for the draft 1.0 spec add:
@tparisi if you want to see the code in Cesium, see https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Model.js#L1476 |
…-feature-ids Clarification for only using feature IDs
I'll have a spec proposal soon, but we need to be careful not to decouple images and image filters because this is not supported in WebGL and OpenGL ES without duplicating the image, which is painful on the client.
The fix could be as simple as the spec disallowing multiple textures to be bound at the same time with different filters. Otherwise, this requires GL_ARB_sampler_objects.
I'll think about it a bit more before proposing something...
The text was updated successfully, but these errors were encountered: