-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
WebGLRenderer: Add support for multiple uv sets and transforms. #25721
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.
|
|
Some progress: https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/MultiUVTest
|
|
Maybe we can do something like const mapKeys = [ 'map', 'emissiveMap', 'lightMap', otherMaps ];
for ( const key of mapKeys ) {
parameters[ key ] = !! material[ key ];
parameters[ key + 'Uv' ] = !! material[ key ] && getUVSetVar( material[ key ].uvSet );
}and similar in other places? Just to simplify the code. |
|
Yeah, I'll leave that for another PR though. |
|
I can do such PR (cleaning |
|
Trying to add multiple texture transforms while I'm at it. https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/TextureTransformMultiTest
|
|
I'm going to merge this and release today. If we find issues I'm happy to do patch releases. |
|
I've noted in the migration guide that the |
Yeah, I tried with models with a bunch of maps too and didn't see a difference. I believe this has been one of the premature optimisations that have damaged the project the most... 😬 Feels pretty good to be outside of that hole now though! |
|
Right now https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLPrograms.js#L38-L44 Adding support 3 or 4 is pretty straight forward though. Have you ever seen a gltf file with more than 2 uv sets? |
|
Hello @mrdoob, |
|
@mrdoob I've certainly seen glTF files with 3+ UV sets. Usually one or more of the UV sets are unused, I don't know enough about the art workflow to think of cases where 3+ UV sets would be needed. To my understanding Blender, Godot, Unity, and Unreal Engine each support up to 8 UV sets, but various conditions (Shader Graph in Unity, Skinning in Unreal, perhaps more...) will knock that limit down to 4 or fewer. I think supporting 4 UVs would be a nice bit of flexibility, if we aren't hurting performance. @JonathanIcon do you mind explaining what this file does? Is the combination of MSFT_lod and KHR_materials_variants (both contained in the file) important to using additional UV sets here? |
|
@donmccurdy we can ignore the MSFT_LOD yes but we use the KHR_materials_variants having 1 variant per material and each material has a different UV set; |
|
I think good question here would be:
Or
If three can in any scenario exist or be used without GLTF perhaps it shouldn't be the only consideration when designing this feature. Ie. "GLTF has only two channels, let's design three so that it uses only two channels". If i may suggest an alternative pattern: If we consider these uvs as just array of attributes that exist without GLTF, OBJ, dae, 3ds and whatnot, i think it may become obvious that 2 channels is rather arbitrary :) |
|
This is, is how this editor looks in 3ds max: The Feel free to ping me, i've worked with 3d studio max and other sowftware for 20 years before i thought myself how to program. |
|
Hm, it's also worth noting that 3ds max treats all of this as UVW. So in theory i think at any moment you can designate something as UV kinda like: So in a sense (i don't know much about GLTF) it can be even more generic? I imagine that GLTF saves space and wouldn't write a bunch of zeros for UVW, but write two numbers for UV. Thus probably making something like this incompatible with three. However: Should be pretty generic if applying the same pattern. Any mesh, as long as it's the same can be combined into a geometry? |
The art flow from an engineering point can be seen as very generic. It's a creative process, and there may be a way to use several UVs while reusing several textures to create an effect that no one has thought of before. We are limited by the number of attributes in GL land, but when considering that a technical artist can be involved, i wouldn't find it unreasonable for someone to have a need to use say 8 channels, while using no attributes for skinning or perhaps even normals. I think the channel info tool from 3ds max is a good example. (it's several meshes of 960 triangles, combined into one) |
|
Many devices are limited to 16 vertex attributes. In theory we could support up to 15 UVs + 1 position attribute, but in practice it may reduce complexity to have some limit. We are not designing around glTF here — it has no limit either — just trying to compare notes on use cases, and how often we see them. |
|
Correct, so maybe even something like: This wires it to three's |
Newer three.js versions support multiple uv attributes for gltf models. This introduces the need to specify which uv attributes is the one relevant for our lightmap texture. See mrdoob/three.js#25721
Newer three.js versions support multiple uv attributes for gltf models. This introduces the need to specify which uv attributes is the one relevant for our lightmap texture. See mrdoob/three.js#25721 Co-authored-by: Antonio Pisano <[email protected]>
Newer three.js versions support multiple uv attributes for gltf models. This introduces the need to specify which uv attributes is the one relevant for our lightmap texture. See mrdoob/three.js#25721 Co-authored-by: Antonio Pisano <[email protected]>







Fixes #12608
Fixes #9457
Description
Pushing what I have for now. Still trying to figure out how to make this work.