jack013

08-29-2015, 01:30 PM

Hi,

while my question may be pretty application-specific, I think I stems from the fact that I'm not yet fully grasping the programming paradigms of OpenGL. So bear with me. :confused:

So here's my problem:

I have a grid of 3d sample points given in world space, at which some value V has been computed. Now, I want to visualize the V's as a colored rectangle, one rectangle for each "slice". While I can directly assign a color to the pixels belonging to the sample points, I need to interpolate V's for the remaining pixels, which belong to world points that lie somewhere in the grid (but not at the sample points).

I know that OpenGL is able to interpolate fragment shader inputs according to their location on the primitive. This is, however, only an interpolation that takes place in 2d (on triangles, lines). I, on the other hand, need to trilinearly interpolate each V from the 8 surrounding neighbors.

In an attempt to determine these neighbors, I have tried to unproject the window coordinates of each fragment back to world coordinates. This is however, where I get stuck. I don't know how to reliably find the 8 neighboring sample points (and therefore the V's associated with them).

(In a second attempt, I have briefly looked into 3d textures. As I understand it, I would need to use buffered textures, which are only available for 1d.)

My question: My approach seems like a quirky backwards solution. Am I missing out on a more straightforward approach that could somehow associate the 8 V's (of the neighbors) with each fragment, or better yet, give me the interpolated V's?

Thank you for your answers. :o

Also, feel free to ask if something is unclear.

while my question may be pretty application-specific, I think I stems from the fact that I'm not yet fully grasping the programming paradigms of OpenGL. So bear with me. :confused:

So here's my problem:

I have a grid of 3d sample points given in world space, at which some value V has been computed. Now, I want to visualize the V's as a colored rectangle, one rectangle for each "slice". While I can directly assign a color to the pixels belonging to the sample points, I need to interpolate V's for the remaining pixels, which belong to world points that lie somewhere in the grid (but not at the sample points).

I know that OpenGL is able to interpolate fragment shader inputs according to their location on the primitive. This is, however, only an interpolation that takes place in 2d (on triangles, lines). I, on the other hand, need to trilinearly interpolate each V from the 8 surrounding neighbors.

In an attempt to determine these neighbors, I have tried to unproject the window coordinates of each fragment back to world coordinates. This is however, where I get stuck. I don't know how to reliably find the 8 neighboring sample points (and therefore the V's associated with them).

(In a second attempt, I have briefly looked into 3d textures. As I understand it, I would need to use buffered textures, which are only available for 1d.)

My question: My approach seems like a quirky backwards solution. Am I missing out on a more straightforward approach that could somehow associate the 8 V's (of the neighbors) with each fragment, or better yet, give me the interpolated V's?

Thank you for your answers. :o

Also, feel free to ask if something is unclear.