-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
WebGLRenderer: Add support for uv3 and uv4. #25788
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
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
I really dislike the But I don't know how many things, if any, would be to rename them now. And if we did, should it be |
I'm afraid too many things depend on these names. But if we could start from scratch I would favor the |
|
uv_0 sounds good. |
|
I slightly prefer "uv" over "texcoord". I think the glTF "texcoord" abbreviation is less common, and we use the word UV elsewhere in our API, not just the attribute name, so it is quite a breaking change. It would be great for the index used in the name to match up with the value assigned to Do we want to mix underscores with camel case though? If we someday add an additional set of skinning weights, do we prefer |
Me, too. How about geometry.attributes.uvs[ i ]with |
|
@WestLangley I think it can’t just be a simple array since then you could make it sparse? Some api (add, remove) could be more robust. |
|
I personally do not see the issue with Whatever the case, though, please do not use an array of BufferAttributes in the attributes dictionary:
I've often generically iterated over the attribute fields to process them into textures, merge geometries, compress data, etc. Adding a new object structure in Please also consider that changing the name of |
|
What about a mechanism on the geometry not the attributes? Not sure how it would look like, but this doesn’t feel like this belongs on the attributes, rather above it, managing them. |
|
I fully agree with what @gkjohnson said 👍 . |
|
I did a bad job at explaining what it is that I don't like 😅 When I implemented
Option 1
Option 2
I think I prefer the second option and if people is okay with it I can give it a try after merging this PR. |
|
Agreed. I like both of those, and also have a small preference for option 2. No need to change the underlying geometry/attribute API. |
|
See if you can give it some more thought. I don’t think that this belongs in the attributes, attributes are just attributes. And while texcoord seems to be a GL term, it soon changes to UV. Kinda curious about that historically. But, since it is doing some magic - some in a sense - more than the magic when you name your buffer ‘foo’ I feel like it could be explored a bit how it would look like if geometry managed this. more maybe have some builder helper. There is no reason why someone would dynamically alter - remove or add uv attributes at runtime. |
|
why not just write an attribute name (string) into texture.channel @mrdoob |
|
Hmmm, you would have to “turn it off” for its actual name? So that you don’t get “horse” and uv0? But I kinda like this idea. |
|
Duplicate |
|
@pailhead like, if users want to use the attribute named "horse" - let them. why not? what's the big deal? just set it to "uv" by default, and to "uvX" in the model loader with correct X for the maps that require another layer. |
|
I see, if you write “horse” to an array, you would still call setAttribute(“horse”…) but you would actually get uv_x and no horse? That’s what I meant by management. The presence of channels:[“horse”] means the actual attribute vec2 horse; should not appear. |
|
why array? I was talking about apparently numeric property of Texture that mrdoob modelled after gltf spec. apparently. |
|
e.g. if the texture is marked to use "horse" (or "uv3"), three would check if there is such an attribute (and it normally will be, because the loader loaded uv3, or the user added the horse) and if not - throw some error at which point the user knows his code needs fixing. |
|
I think I get it, there wouldn’t even be a channel int, just the name of the attribute to be used as such channel? |
|
yep. |
|
As an interface that makes sense to me. Feels like it would be a massive change. |
|
Actually, i don't think it would be such a massive change. Such an list would still mean that textures are used via Could actually even eliminate a lot of this duplicated code that deals with injecting |
|
more massive than renaming uv to uv_0 for no reason? 😅 like, people will need to edit their shaders and stuff |
just do 'v' + capitalize(attributeName). so that uv turns to vUv (like now? iirc), uv3 to vUv3, horse to vHorse |
|
I was thinking at least the fragment shaders wouldn’t have to be changed. And there is no need to prefix anything just point an attribute to where uv would have been accessed |
|
but then you have to order them somehow. and you would also have a failure if users specify 5 channels. besides, how would that even work your way? suppose you have hardcoded ao map to vUv2 in fragment, but material.aoMap.channel is 4 - what do you do? if you just route 4-th attribute into vUv2, it means no other map/code can use vUv2 in fragment shader... so in the end, you will have one varying per texture, even if they all use the same attribute? |
Related issue: #25721
Description
Support up to 4 uv channels instead of just 2.
Also moved attribute definitions to
WebGLProgram.js.