20 minutes ago, matt77hias said:
But sample_lod can stay the same between consecutive iterations?
It's a float - therefore you will get fractions.
If I remember correctly hardware trilinear filtering will work like this (I wrote it from my head - so I might've made some typos!):
float xf = frac(coord.x * TEXTURE_SIZE_X);
float yf = frac(coord.y * TEXTURE_SIZE_Y);
float yz = frac(coord.y * TEXTURE_SIZE_Z);
uint m0 = (uint)miplevel;
uint m1 = min(m0 + 1, TEXTURE_MIPCOUNT);
float m = frac(miplevel);
float4 c0 =
lerp(
lerp(
lerp(texture.SampleLevel(sampler, coord + (0, 0, 0), m0), texture.SampleLevel(sampler, coord + (1, 0, 0), m0), xf),
lerp(texture.SampleLevel(sampler, coord + (0, 1, 0), m0), texture.SampleLevel(sampler, coord + (1, 0, 0), m0), xf),
yf),
lerp(
lerp(texture.SampleLevel(sampler, coord + (0, 0, 1), m0), texture.SampleLevel(sampler, coord + (1, 0, 1), m0), xf),
lerp(texture.SampleLevel(sampler, coord + (0, 1, 1), m0), texture.SampleLevel(sampler, coord + (1, 0, 1), m0), xf),
yf),
zf);
float4 c1 =
lerp(
lerp(
lerp(texture.SampleLevel(sampler, coord + (0, 0, 0), m1), texture.SampleLevel(sampler, coord + (1, 0, 0), m1), xf),
lerp(texture.SampleLevel(sampler, coord + (0, 1, 0), m1), texture.SampleLevel(sampler, coord + (1, 0, 0), m1), xf),
yf),
lerp(
lerp(texture.SampleLevel(sampler, coord + (0, 0, 1), m1), texture.SampleLevel(sampler, coord + (1, 0, 1), m1), xf),
lerp(texture.SampleLevel(sampler, coord + (0, 1, 1), m1), texture.SampleLevel(sampler, coord + (1, 0, 1), m1), xf),
yf),
zf);
return lerp(c0, c1, m);
So you actually interpolate between mip levels too - as per description here https://msdn.microsoft.com/en-us/library/windows/desktop/bb509699(v=vs.85).aspx:
LOD
[in] A number that specifies the mipmap level. If the value is ≤ 0, the zero'th (biggest map) is used. The fractional value (if supplied) is used to interpolate between two mipmap levels.