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

Import the second UV map if present in glTF files. #9992

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

pcwalton
Copy link
Contributor

@pcwalton pcwalton commented Oct 2, 2023

Conventionally, the second UV map (TEXCOORD1, UV1) is used for lightmap UVs. This commit allows Bevy to import them, so that a custom shader that applies lightmaps can use those UVs if desired.

Note that this doesn't actually apply lightmaps to Bevy meshes; that will be a followup. It does, however, open the door to future Bevy plugins that implement baked global illumination.

Changelog

Added

The Bevy glTF loader now imports a second UV channel (TEXCOORD1, UV1) from meshes if present. This can be used by custom shaders to implement lightmapping.

crates/bevy_render/src/mesh/mesh/mod.rs Outdated Show resolved Hide resolved
@pcwalton
Copy link
Contributor Author

pcwalton commented Oct 2, 2023

Oh oops, looked like I missed a spot (I was testing with a custom shader so that didn't show up). Should be fixed now.

Conventionally, the second UV map (`TEXCOORD1`, `UV1`) is used for
lightmap UVs. This commit allows Bevy to import them, so that a custom
shader that applies lightmaps can use those UVs if desired.

Note that this doesn't actually apply lightmaps to Bevy meshes; that
will be a followup. It does, however, open the door to future Bevy
plugins that implement baked global illumination.
@JMS55
Copy link
Contributor

JMS55 commented Oct 2, 2023

Need to modify prepass_io.wgsl as well maybe

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen A-Assets Load files from disk to use for things like images, models, and sounds C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Oct 2, 2023
@pcwalton
Copy link
Contributor Author

pcwalton commented Oct 2, 2023

Need to modify prepass_io.wgsl as well maybe

I don't think so, because I didn't update the prepass vertex bindings. I didn't see any need for the prepass to have access to UV1.

@JMS55
Copy link
Contributor

JMS55 commented Oct 2, 2023

The prepass uses the same vertex buffer though, right? Idk, maybe it doesn't actually cause issues. Idk how bevy setups up the vertex attributes off the top of my head.

@pcwalton
Copy link
Contributor Author

pcwalton commented Oct 2, 2023

Yeah, I don't think it causes any issues because the mesh attributes are referred to by name inside Bevy.

@nicopap
Copy link
Contributor

nicopap commented Oct 2, 2023

This was a longstanding missing feature. Consider searching the bug tracker. I think there is at least a couple issues that can be closed when this gets merged.

@IceSentry
Copy link
Contributor

The prepass uses it's own vertex layout, so it doesn't need to be updated for this

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Oct 2, 2023
@superdump superdump added this pull request to the merge queue Oct 2, 2023
@pcwalton
Copy link
Contributor Author

pcwalton commented Oct 2, 2023

This was a longstanding missing feature. Consider searching the bug tracker. I think there is at least a couple issues that can be closed when this gets merged.

Good point, I found #8699, part of #1802, and part of #4629.

Merged via the queue into bevyengine:main with commit 44a9a4c Oct 2, 2023
25 checks passed
@Adriaaaaan
Copy link

Is this limited to only uv1? As mentioned in the other ticket, exporting lightmaps from unreal seem to use several uv1 maps for reasons I don't really understand tbh (at least UV1-4)

ameknite pushed a commit to ameknite/bevy that referenced this pull request Oct 3, 2023
Conventionally, the second UV map (`TEXCOORD1`, `UV1`) is used for
lightmap UVs. This commit allows Bevy to import them, so that a custom
shader that applies lightmaps can use those UVs if desired.

Note that this doesn't actually apply lightmaps to Bevy meshes; that
will be a followup. It does, however, open the door to future Bevy
plugins that implement baked global illumination.

## Changelog

### Added

The Bevy glTF loader now imports a second UV channel (`TEXCOORD1`,
`UV1`) from meshes if present. This can be used by custom shaders to
implement lightmapping.
@cart cart mentioned this pull request Oct 13, 2023
43 tasks
regnarock pushed a commit to regnarock/bevy that referenced this pull request Oct 13, 2023
Conventionally, the second UV map (`TEXCOORD1`, `UV1`) is used for
lightmap UVs. This commit allows Bevy to import them, so that a custom
shader that applies lightmaps can use those UVs if desired.

Note that this doesn't actually apply lightmaps to Bevy meshes; that
will be a followup. It does, however, open the door to future Bevy
plugins that implement baked global illumination.

## Changelog

### Added

The Bevy glTF loader now imports a second UV channel (`TEXCOORD1`,
`UV1`) from meshes if present. This can be used by custom shaders to
implement lightmapping.
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
Conventionally, the second UV map (`TEXCOORD1`, `UV1`) is used for
lightmap UVs. This commit allows Bevy to import them, so that a custom
shader that applies lightmaps can use those UVs if desired.

Note that this doesn't actually apply lightmaps to Bevy meshes; that
will be a followup. It does, however, open the door to future Bevy
plugins that implement baked global illumination.

## Changelog

### Added

The Bevy glTF loader now imports a second UV channel (`TEXCOORD1`,
`UV1`) from meshes if present. This can be used by custom shaders to
implement lightmapping.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants