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

Standard material handles textures in sRGB format #6736

Merged
merged 2 commits into from
Jun 20, 2024

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Jun 20, 2024

  1. Deprecated old and replaced with new texture formats, to match RGB8 and RGBA8 formats, as they're the same but in addition handles sRGB conversion:
PIXELFORMAT_SRGB -> PIXELFORMAT_SRGB8
PIXELFORMAT_SRGBA -> PIXELFORMAT_SRGBA8;
  1. Added support for SRGBA8 on WebGPU

  2. When standard material uses a texture in sRGB space, we skip in-shader conversion of sRGB->linear, as sampling it gives us a linear value already.

Comment on lines +979 to +991
[PIXELFORMAT_DXT1, { name: 'DXT1', blockSize: 8, srgb: true }],
[PIXELFORMAT_DXT3, { name: 'DXT3', blockSize: 16, srgb: true }],
[PIXELFORMAT_DXT5, { name: 'DXT5', blockSize: 16, srgb: true }],
[PIXELFORMAT_ETC1, { name: 'ETC1', blockSize: 8, srgb: true }],
[PIXELFORMAT_ETC2_RGB, { name: 'ETC2_RGB', blockSize: 8, srgb: true }],
[PIXELFORMAT_ETC2_RGBA, { name: 'ETC2_RGBA', blockSize: 16, srgb: true }],
[PIXELFORMAT_PVRTC_2BPP_RGB_1, { name: 'PVRTC_2BPP_RGB_1', blockSize: 8, srgb: true }],
[PIXELFORMAT_PVRTC_2BPP_RGBA_1, { name: 'PVRTC_2BPP_RGBA_1', blockSize: 8, srgb: true }],
[PIXELFORMAT_PVRTC_4BPP_RGB_1, { name: 'PVRTC_4BPP_RGB_1', blockSize: 8, srgb: true }],
[PIXELFORMAT_PVRTC_4BPP_RGBA_1, { name: 'PVRTC_4BPP_RGBA_1', blockSize: 8, srgb: true }],
[PIXELFORMAT_ASTC_4x4, { name: 'ASTC_4x4', blockSize: 16, srgb: true }],
[PIXELFORMAT_ATC_RGB, { name: 'ATC_RGB', blockSize: 8, srgb: true }],
[PIXELFORMAT_ATC_RGBA, { name: 'ATC_RGBA', blockSize: 16, srgb: true }],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, they're all SRGB all the time? Can't I have a linear normal map, say, using these compressed formats?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these we convert to linear manually.
Soon I'll add compressed texture formats stored in sRGB as well, separate PR.

@mvaligursky mvaligursky merged commit 1c4c025 into main Jun 20, 2024
8 checks passed
@mvaligursky mvaligursky deleted the mv-srgb-standard-mat branch June 20, 2024 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue enhancement
2 participants