Trilinear implementation