I’d like to use mipmapping in a final shader pass but I can’t seem to get it to work. I know I need to use mipmap_inputN = true, but otherwise I’m lost. When I sample the source texture it just turns out the same? Can someone post an example of a simple preset and shader that shows how it works or point me in the write direction?
The “ambient glow” border shader uses mips to get the average color. I believe there’s at least one video driver that just straight-up doesn’t do them properly, so you might be hitting that.
Best you use it with the pass you are sampling from and with the pass you are sampling with. But you can test-debug the mip sampling further with various drivers…
A good example of mip sampling is:
vec3 avg = textureLod(Source, vec2(0.5, 0.5), m).rgb; // average screen rgb value
where mip-level m can be calculated:
float m = max(log2(SourceSize.x), log2(SourceSize.y));
You can also add:
m = ceil(m); // etc...
Indeed the keyworkd naming is misleading.
With mipmap_inputX you’re not telling that everything sampled by X can get a mipmap, but that pass X-1 will provide mipmaps to everything that samples from it (with some caveats about feedbacks).
This weird behaviour applies to other metadatas as well.
quoting my rant in the discord channel from years ago:
This was driving me crazy since days. Finally I understood, and is the same old (mis)behaviour of retroarch chain system. As we know, to have passN filtered,mipmapped,wrapped, you have to set those metadatas in passN+1.
However, to linear filter the mipmaps feedback of passN, you have to set filter=linear in the passN metadat itself, NOT passN+1
It probably applies to other metadatas too, but did not bothered to try. (EDIT- confirmed for wrap mode too)
Of course this is unoptimal and a bug, because feedback and previous pass share the same filtering and wrap modes.
And even then, mipmap_input metadata (good thing, no waste of performance) does not follow that rule. (read: mipmap_input1=true does not make textureLod(pass1Feedback,N) working)