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