Skip to content

Add support for second set of UVs; #860

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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

Add support for second set of UVs; #860

wants to merge 3 commits into from

Conversation

bjornbytes
Copy link
Owner

This is an attempt to add support for importing Models with a second set of UVs.

  • There is a new vertex attribute available in vertex shaders named VertexUV2, and a new fragment shader input named UV2 which can be used to sample textures.
  • All UVs for models are converted from 32 bit floats to unsigned shorts. This allows us to squeeze in a second set of UVs without increasing the size of model vertices, but it has a few consequences:
    • Precision loss. Instead of 4 billion unique UV values, there are only 65535. This is still a lot of precision though, any difference shouldn't be noticeable.
    • UVs can only be between 0 and 1 now, instead of any number. This could break some models, although the vast majority of models use UVs between 0 and 1. You can still use the UV offset and UV scale feature to get larger UV ranges.
      • LÖVR could try to warn you if the glTF says it has UVs outside of the range, or even normalize the UVs to a bigger range and apply a UV scale (trading off even more precision to extend the UV range).
  • If the second set of UVs is missing, it uses data from the first set of UVs (??? this is kinda weird, maybe take this out).
    • It does mean that shaders could use UV2 and still work when the model only has 1 set of UVs. This could be cool for OcclusionTexture, which is often used for lightmaps with the second set of UVs. LÖVR could use UV2 when sampling from the occlusion texture in any builtin shader functions and this wouldn't break models that only have 1 set of UVs.
  • glTF has this feature where each material texture can indicate which set of UVs it wants to use. Not many engines support this and this PR doesn't add any support for this.

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

Successfully merging this pull request may close these issues.

1 participant