maxMipLevel
Queries and retrieves the maximum Mipmap level count (as a float) of a given texture.
Core Advantages
Encapsulates the Mipmap level query within a node, eliminating the need for manual calculation in JS and passing it as a uniform, which makes shader logic more self-contained and maintainable.
Common Uses
Debugging and visualizing Mipmap levels
Custom LOD (Level of Detail) effects
Clamping Mipmap levels in custom sampling logic
As a parameter for procedural generation effects
How to adjust
The node's output value is determined by the input texture's dimensions and cannot be adjusted directly. Its effect is seen in how the output is used: for instance, swapping the input texture for one of a different size will change its return value, or using this output in other calculations within the node graph, such as normalizing the current Mipmap level for debug visualization or clamping the range of a custom LOD calculation.
Code Examples
1// Manually calculate a mip level and use maxMipLevel to ensure it's in a valid range
2const customMipLevel = roughness.mul( 10.0 );
3const maxLevel = maxMipLevel( texture( myTex ) );
4
5const safeMipLevel = clamp( customMipLevel, 0.0, maxLevel );