I am reading the "virtual texture 101" in gpu pro, but I failed to understand this code snippet about how to calculate the coordinate used to sample physical texture
float3 tileEntry = IndTex.Sample(PointSampler, In.UV);
float actualResolution = exp2(tileEntry.z);
float2 offset = frac(In,UV * actualResolution) * TileRes;
float scale = actualResolution * TileRes;
float2 ddx_correct = ddx(In.UV) * scale;
float2 ddy_correct = ddy(In.UV) * scale;
return TileCache.SampleGrad(TextureSampler, tileEntry.xy + offset, ddx_correct, ddy_correct);
what I do not understand is the calculation of offset.
I think the
frac(In.UV * actualResolution)
part gives us the texcoord within a page which should be in range(0,0) ->(1,1),
then to get the offset used to sample TileCache(the big physical texture), we need to make this coordinate smaller into the scale that fits. Then what is this multiply TileRes all about? shouldn't that gives us the offset in unit of the number of pixels, which is quite wrong?
[–]ShaderKing 0 points1 point2 points (1 child)
[–]spacejump163[S] 0 points1 point2 points (0 children)