I would like to make sure that my texture is sampled from the next larger mip map only. Therefore my approach would be to set an LOD offset of -0.5 and then select NEAREST
for the mip level interpolation. The idea would be to always just sample the mip map that is just bigger than the rendered resolution on screen.
Unfortunately lodGenerationOffset
doesn’t seem to work for Texture
instances the way it does for CubeTexture
instances.
Is there any feasible way of achieving the selection of the mip map that is just larger than the on-screen resolution?
This playground sample shows what I tried to do: https://playground.babylonjs.com/#ETZMC9#8
Note: The texture is a 2048x2048 texture which includes the mip level number within each of its mip maps. This makes it easy to debug which mip-levels are used. Playing with lodGenerationOffset
within this sample doesn’t seem to change anything unfortunately.
The best way is to simply disable the mipmaping. This way you will always get the data from your source texture:
This would be an option, but I would like to avoid that, so I don‘t risk obvious aliasing artefacts by sampling a texture that is far too large for the current render size
Sorry but then I do not follow you
If you want the higher LOD this will be one of the outcome right?
Probably an example could help to better explain what I am looking for
:
Let’s stick to the scenario in the playground sample where I have a 2048x2048 texture including all mip levels. When rendering the textured quad on screen with a resolution of 750x750, linear mip level sampling would interpolate between sampled texels from the 512x512 and the 1024x1024 mip maps. Therefore, I would get some slightly blurry outcome due to the 512x512 mip level having less resolution than the on-screen quad.
When choosing nearest mip level sampling mode, it would just use the 512x512 mip map, because it is closer to 750x750 than the 1024x1024 mip map, which obviously also leads to a slightly blurry result.
What I would prefer, is that it would just use the 1024x1024 mip map, which is just larger than the on-screen resolution, for sampling in the 750x750 on-screen resolution case. This should not be prone to aliasing artefacts and deliver a crisp rendering. In contrast, when always sampling from the full resolution of 2048x2048, I would risk aliasing artefacts for smaller on-screen resolutions.
If I’m not mistaken, this should be an approach that delivers crisp results without obvious aliasing. The only drawback I would see, is that when zooming in/out, one would see the jumping between the choosing of the mip map due to the lack of interpolation between different levels.
You can only with a custom shader using textureLod so that you can pick the mip level you want
or using texture with an extra bias
That’s where I would go too