bilerp

taichi_glsl.sampling.bilerp(field: <taichi.lang.kernel_arguments.Template object at 0x7f9dc1a06d30>, P)

Bilinear sampling an 2D field with a real index.

Parameters
  • field – (2D Tensor) Specify the field to sample.

  • P – (2D Vector of float) Specify the index in field.

Note

If one of the element to be accessed is out of field.shape, then bilerp will automatically do a clamp for you, see sample().

Returns

The return value is calcuated as:

I = int(P)
x = fract(P)
y = 1 - x
return (sample(field, I + D.xx) * x.x * x.y +
        sample(field, I + D.xy) * x.x * y.y +
        sample(field, I + D.yy) * y.x * y.y +
        sample(field, I + D.yx) * y.x * x.y)