1
\$\begingroup\$

Let's say that i have a regular 2d texture (not a volume texture). Is it possible to do trilinear texture sampling of that texture even though it isn't a volume texture in opengl or directx?

Specifically, if i had a 2x4 texture laid out like below where A through H are pixels:

A B
C D
E F
G H

What I'd like to get is a trilinear sample being the result of linearly interpolating the bilinear sampling of (A,B,C,D) and (E,F,G,H).

I know i could take two bilinear texture samples and lerp them to get what I want, but is there a hardware supported way to do this?

\$\endgroup\$
8
  • \$\begingroup\$ Can you offer a bit more context about why you want to blend two adjacent pixel quads like this? What formula determines the third interpolation factor? \$\endgroup\$
    – DMGregory
    May 24, 2015 at 1:32
  • \$\begingroup\$ Sure thanks for asking! It'll be interesting to hear if it makes a difference. Basically, if it were a 2x2x2 volume texture, there would be a single value that was used as the interpolation for all three axes. Basically I'd be sampling along the diagonal only. \$\endgroup\$
    – Alan Wolfe
    May 24, 2015 at 2:04
  • \$\begingroup\$ As for why, I'm trying to interpolate some data stored in textures (don't want to get into details). If I'm able to do this, I'll be able to store the data in a more efficient pattern and use smaller textures. \$\endgroup\$
    – Alan Wolfe
    May 24, 2015 at 2:18
  • 1
    \$\begingroup\$ This is equivalent to a single lerp between A and the average of the whole 2x2x2 block (if t <= 0.5), or between the average and H (if t >= 0.5). So you could pre-process your texture into a single line of pixels and use a conventional sample. That would be about 2n pixels of storage instead of n^3. \$\endgroup\$
    – DMGregory
    May 24, 2015 at 4:18
  • 1
    \$\begingroup\$ You're right, hasty late-night math on my part. Sorry about that. The lerp formula is A + t(B + C + E - 3A) + t^2(3A + F + G - 2B - 2C - 2E) + t^3(B + C + E + H - A - D - F - G). I don't think there's anything in hardware that will apply this lerp formula to texture data that's being read as 2D. \$\endgroup\$
    – DMGregory
    May 24, 2015 at 13:36

1 Answer 1

0
\$\begingroup\$

No, it is not possible, unless you read the involved pixels into a pixel shader, and then do the interpolation in the shader program manually.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .