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

Rename uv to uv_a and VERTEX_UVS to VERTEX_UVS_A in shaders. #10237

Closed
wants to merge 1 commit into from

Conversation

pcwalton
Copy link
Contributor

Objective

We now support two sets of UVs, so uv and VERTEX_UVS in shaders are now ambiguous.

Solution

To solve this, we explicitly mark the UV set we're using in the shaders, so as to distinguish it from the second UV set used for lightmaps in PR #10231.

The obvious question is "why use UV_A and UV_B instead of UV0 and UV1?" The answer is that Naga doesn't currently allow preprocessor definitions that end in numbers. To work around this restriction, I renamed UV0 to UV_A and UV1 to UV_B.


Changelog

Changed

  • In shaders, the uv field is now uv_a, and the corresponding define changed from VERTEX_UVS to VERTEX_UVS_A, for clarity when multiple UV sets are involved.

Migration Guide

  • If you were using the uv field of the vertex input or output in a custom shaders, change it to uv_a. Likewise, the corresponding define should be changed from VERTEX_UVS to VERTEX_UVS_A.

We now support two sets of UVs, so `uv` and `VERTEX_UVS` in shaders are
now ambiguous.

To solve this, we explicitly mark the UV set we're using in the shaders,
so as to distinguish it from the second UV set used for lightmaps in PR

The obvious question is "why use `UV_A` and `UV_B` instead of UV0 and
UV1?" The answer is that Naga doesn't currently allow preprocessor
definitions that end in numbers. To work around this restriction, I
renamed UV0 to `UV_A` and UV1 to `UV_B`.
@pcwalton pcwalton mentioned this pull request Oct 23, 2023
@pcwalton pcwalton requested review from superdump and robtfm October 23, 2023 08:10
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Oct 23, 2023
@robtfm
Copy link
Contributor

robtfm commented Oct 23, 2023

a quick correction - preprocessor definitions that end in numbers or _ should be fine i think. the problem is that struct members can't end in numbers or underscores - the .uv_1 in this case.

@pcwalton
Copy link
Contributor Author

Closing per discussion on Discord. The preference is to leave uv as it is.

@pcwalton pcwalton closed this Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants