Jump to content

  • Log In with Google      Sign In   
  • Create Account


Texture3D Sampling


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Such1   Members   -  Reputation: 435

Like
0Likes
Like

Posted 02 December 2012 - 02:48 AM

Hey guys, I'm using 3D textures on my engine, but one thing I need to do is to get the exact texture coordinate of a pixel.
Like this, my 3D texture is actually several 2D textures. But I am using them like that because they are also used as render target.
But when I use them as resource I need to separate them again. How is the texture coordinates system work? I tried a few times and sometimes I get blended between 2 2D Textures.

EDITED:
Actually, I just changed my code to use Texture2DArray instead. I realized that they don't have a render target limit that could affect me.

Edited by Such1, 02 December 2012 - 03:03 AM.


Sponsor:

#2 Bacterius   Crossbones+   -  Reputation: 8693

Like
1Likes
Like

Posted 02 December 2012 - 06:33 AM

You fixed your problem and used a 2D array, which is more logical, but I think your blending problem is because, well, in a 3D texture, you also get bilinear (trilinear, actually) filtering, which means if you were just stacking textures one on top of the other, you might end up interpolating two different textures.

I think the problem is you tried to sample the 3D texture "between" two adjacent textures instead of on exactly one, probably by using the z-coordinate = (texture I want) / (number of textures total) trick. This will work, but only if you add a 0.5 offset to your texture number, because of the way sampling works, so you need to use (texture I want + 0.5) / (number of textures total) to sample right on a given texture in your 3D texture (a "slice" of your 3D texture).

The 3D texture coordinates work exactly the same as the 2D and 1D coordinates - a floating-point range from 0 inclusive to 1 exclusive, in each dimension. That said, if you have D3D10, you can use the Load() method to bypass sampling and directly access each texel through integer coordinates (but you also lose sampling, which is not what you want anyway).

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#3 Such1   Members   -  Reputation: 435

Like
0Likes
Like

Posted 02 December 2012 - 04:41 PM

I tried all your suggestions before I posted here, none of them worked. Maybe I got something wrong. But I fixed it by using Texture2DArray anyway so...
But thank you for your suggestions.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS