Skip to content

Conversation

panxinmiao
Copy link
Contributor

@panxinmiao panxinmiao commented Feb 23, 2025

While debugging transmission light sampling textures, I discovered that we cannot correctly generate mipmaps for -srgb format textures. This issue arises and found because our transmission light maps are copied from Blender's color_tex, which is in the rgba8unorm-srgb format.

Currently, we generate mipmap textures using compute shaders with advanced (Gaussian) filtering algorithms. However:

  • Compute shaders do not support “-srgb” format textures.
  • Moreover, for standard mipmap usage—such as smooth sampling at varying distances and scaling levels—linear interpolation downsampling is more accurate. (For textures with sizes that are powers of two, this method is equivalent to a box filter, where each pixel in the mipmap uses the average of the four adjacent pixels from the previous mipmap level.)
  • Additionally, performing interpolation filtering and computing in the srgb space for srgb textures is not entirely correct (should in linear space).

Our current mipmap generation is primarily used for IBL (Image-Based Lighting) ambient light calculations. The existing IBL employs an approximation algorithm that uses standard mipmap textures combined with this approximation, rather than PMREM (Pre-Filtered Environment Map). Therefore, this issue is not critical, and Gaussian filtering might even provide visually better results for IBL. However, as we expand support for more advanced rendering techniques, correctly generating standard mipmap textures becomes increasingly important.

Regarding IBL, there's no need to worry. After completing work related to texture formats and HDR support, I will implement a standard PMREM generator and the corresponding IBL algorithms.

@Korijn Korijn closed this Feb 28, 2025
@Korijn Korijn reopened this Feb 28, 2025
@Korijn Korijn enabled auto-merge (squash) February 28, 2025 12:03
@Korijn Korijn merged commit b058cc0 into pygfx:main Feb 28, 2025
14 of 27 checks passed
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.

3 participants