-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Add internalFormat to Texture
#15121
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
Add internalFormat to Texture
#15121
Conversation
|
It has been a long time. I am going to fix the linting. |
6a9c62f to
38ccba8
Compare
|
Many formats are still missing, for example R16UI. Here is a table showing all possible formats: https://webgl2fundamentals.org/webgl/lessons/webgl-data-textures.html It would be good to have them all. |
|
Good point, the spec is a bit fuzzy on all the available formats / internal formats. |
7298a83 to
570afb6
Compare
|
Thanks @bilgorajskim for the thorough list of formats. @Mugen87 @WestLangley Are you happy with it? |
|
I've opened another PR in your fork that fixes a few things that were still missing. @DavidPeicho |
|
Considering that How about just doing: texture.internalGLFormat = 'R8'And make the code just do |
|
I would be really up for that, because it makes debugging so much easier. Though right now I am not too opinionated about that in general. In the same ideas of what you propose, what about texture.gpuFormatSo it can match later with a |
That's okay.
Sounds good to me 👍 |
|
@DavidPeicho do you think you can update the PR with that change? 😇 |
|
@mrdoob Yes I will change it. Do we still go through the mapping in // User sets the internal format using the GL name.
texture.gpuFormat= 'R8'// Renderer uploads the texture using:
var glInternalFormat = WebGL2RenderingContext[texture.gpuFormat] |
|
Those two lines should be enough I think. |
|
hope to merge soon |
I didn't change the current Three.js constant mapping to WebGL2 constants, but I kept it as-is, i.e: myTexture.gpuFormat = THREE.R11F_G11F_B10FFormat; // THREE.R11F_G11F_B10FFormat = 1067
// 1067 is later mapped to WebGL2RenderingContext.R11F_G11F_B10FFor a simple reason, the WebGL2 Specification states that you can still use the myTexture.gpuFormat = THREE.RGBFormat;Except if in Otherwise we can also delete all constants for gpu format and simply use string, but WebGPU will anyway supports those kind of formats, so I guess it's actually better for Three.js to define it's own constants, and later perform the mapping for each GPU backend (like it's done right now with every constant). Tell me what you think @mrdoob. If we keep the constants, maybe it could make sense to rename them a bit, I didn't think too much on that. |
Then can't do What I'm proposing is to not add all these new constants and just pass a string to |
|
@mrdoob done.
|
Do you want me to squash the commits? |
That would be great! 😇 |
* Adds `internalFormat` attribute to Texture.js and Texture.d.ts * Adds `internalFormat` string mapping to GL constant in WebGLTextures.js * Adds `internalFormat` in Texture documentation * Adds internal format string constants to constants documentation
88fb7fe to
d97151b
Compare
|
Squashed the commits and rebased. Just a note to @bilgorajskim, sorry your commits went away. The decision has been made to use directly the GL string as |
|
No problem :) The way it works now is simpler, and I agree with the decision. |
…ork in all cases Some WebGL2 internal formats rely on new WebGL2 formats. This change add the 4 new PixelFormat constants that are needed
eb2189e to
2f188f6
Compare
|
I pushed again a few changes to According to the spec,
|
|
Great! I'll do some additional clean up after merging but this looks great. |
|
Thanks for being patient! 😇 |
|
@DavidPeicho Awesome! |
|
It seems like you can uniquely infer the Any reason not to accept an |
|
Moving properties around in the constructor is a pain and the usage is messy. |
internalFormatattribute toTextureObject;internalFormatcopy toTexture.copy();WebGLUtils;SAMPLER_3D, andSAMPLER_2D_ARRAYtoWebGLUniformsSorry if sometimes the name are not consistant between each internal format. Just tell me what you like the most between
R16FFormatandR16FloatFormatfor instance, it is quite quick to change.@takahirox sorry for the time I took for that. My own fork already had this feature, and my work was a priority.