On Tue May 2 12:52:57 2023 +0000, Ethan Lee wrote:
Will definitely rebase this once !191 is in - similar to those tests I will probably make a new sample-grad.shader_test as well. In the meantime I'll see if I can find a sample somewhere that shows how this function really works... the IR/bytecode part works of course, but mathematically I'm a bit clueless on this one (like dsx/dsy before).
I'm not an expert myself either, but my understanding is that if your gradient is of the order of magnitude of 1.0 then sampling is done from LOD 0 (i.e., the original texture), and each time you double the gradient you add 1 to the LOD. So I'd begin sampling with derivatives (1.0, 0.0) and (0.0, 1.0) and expect that you sample from LOD 0, then sampling with (2.0, 0.0) and (0.0, 2.0) and expect that you sample for LOD 1, or something like that. Don't quote me on the details, as I said I don't know much myself.
I don't genuinely know what happens when your sample degenerates, either because the derivatives vector become parallel (e.g., (1.0, 0.0) and (1.0, 0.0)) or because one becomes much bigger than the other (e.g., (1.0, 0.0) and (0.0, 100.0)). Or when they go to zero. I don't think it is necessary to test these degenerations at this stage (but of course I don't mean to stop if you if you feel like).