Skip to content
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 support for named UV maps / Increase the limit of UV maps per material above 2 #651

Closed
Uradamus opened this issue Mar 30, 2020 · 7 comments

Comments

@Uradamus
Copy link

Describe the project you are working on:
I've been working on 3D as a hobby for about 20 years now, first with Maya and then with Blender for the past 14 years or so. I want to start making any of several game projects I have in mind with Godot, but I keep running into limitations on the 3D front that keep making it feel like a non-starter.

Describe the problem or limitation you are having in your project:
Due to terrible unresolved bleeding issues with texture atlases that seem like they may never be resolved, the next best alternative are texture arrays. But there is a problem with that, as Godot materials only support 2 UV map slots, which effectively means 1 UV map per material if you want to bake lighting. Due to this limitation, every single texture in an array needs a unique material, since in order to use more than 1 index per material, you would need a UV map for each to associate with them. The whole point of using a texture atlas is to limit draw calls by allowing you to UV map different faces to several different sub-textures at once with a single material, something that can't be done in Godot with the current UV map setup and/or with the abysmal atlas support.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
A way around this would be to change up the way UV maps are handled, replacing the hard coded 2 slot limit with the much more flexible named UV map setup adopted by most 3D programs and many other engines (Blender, Maya, Unreal, Panda3D, Armory, and UPBGE to name a few I've tried in the past).

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Since Blender is what I have the most experience with, I can explain how they use it with their shader nodes, which is to have a UV Map node, which basically has a drop down field that lists all of the available UV maps by their name to choose from. and it's output can be fed into any node that needs UV map input. I would imagine in code they can be basically treated as variable names or used as string input for some sort of attribute lookup function.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
I'd be using it a lot if atlas support isn't some day fixed. The only alternative I see is having a material for every texture needed, which seems terribly inefficient. I would definitely prefer being able to use atlases, especially since I have a ton of legacy content that uses atlases already, but if that isn't an option, I'd want to be using texture arrays with multiple UV maps in their place.

Is there a reason why this should be core and not an add-on in the asset library?:
Doesn't get much more core than UV maps when it comes to 3D.

@Calinou Calinou changed the title Named UV maps Add support for named UV maps Mar 31, 2020
@Tooniis
Copy link

Tooniis commented Jun 28, 2020

While I don't care much about having named UVs and I'm fine with just numbered UVs, I definitely agree that the 2 UV limit should be lifted or at least raised. Maybe edit the title since it doesn't make it clear that this proposal is also about the 2 UV limit.

@FrandSX
Copy link

FrandSX commented Jun 28, 2020

Another vote to increase the amount of UV channels supported by the engine. Additional channels can be used to import many different kinds of per-vertex data. Blender supports 8 channels, this would be a good minimum baseline.

@Calinou Calinou changed the title Add support for named UV maps Add support for named UV maps / Increase the limit of UV maps per material above 2 Nov 30, 2020
@Calinou Calinou added this to the 4.0 milestone Dec 2, 2020
@reduz
Copy link
Member

reduz commented Dec 2, 2020

This is now being implemented in godotengine/godot#44025
Besides the two UV maps, there are now 4 custom attributes you can use them in any way you want. You can choose the following formats for any of them:

  • RGBA8_UNORM
  • RGBA8_SNORM
  • RG_HALF
  • RGBA_HALF
  • R_FLOAT
  • RG_FLOAT
  • RGB_FLOAT
  • RGBA_FLOAT

Eventually an import option will be added so extra UV channels found in imported files can be mapped to those.

@Xyotic
Copy link

Xyotic commented Jun 23, 2021

I noticed these custom attributes are currently only available in the vertex shader. (on Master)
Are there plans to make these accessible in fragment as well?
Having only 2 UV channels in fragment shader is very little. Considering UV2 is used for lightmaps as well...

@fire
Copy link
Member

fire commented Sep 2, 2021

Making sure #2266 is cross linked.

@Bauxitedev
Copy link

@Xyotic I think you can use varyings to pass data from the vertex shader to the fragment shader.

E.g. something like this:

varying vec3 my_custom_attribute;

void vertex() {
	my_custom_attribute = CUSTOM0;
}

void fragment()
{
    // You can now use "my_custom_attribute" here
}

(I'm not sure what the attributes are actually called but you get the idea)

@fire
Copy link
Member

fire commented Jan 5, 2022

Superseded by: godotengine/godot#52504

I think named uv maps is a feature that needs a separate proposal / design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants