I'm trying to implement color correction with the 3d lookup table. The lookup table is actually just a 2d texture 256x16 and consists of 16 squares which one is 16x16.
When it comes to rendering, I pass 2 textures to shader: first one is whatever I rendered on the screen and the second is a lookup table. Shader takes RGB components of the rendered image, and uses it to find a replacement in a lookup table.
And there is two problems: first, I can't use filter to smooth colors (16 for each dimension is not enough) because it also smoothes the line between two contiguous 16x16 squares and that's inappropriate; second problem is no interpolation for a B-component.
Using a volume texture could solve both problems, but, unfortunately I'm short on time and there are not so many information about using 3d-textures in shaders. So, here's my questions.
- Is it possible to pass a 3d-texture to shader (HLSL)?
- If it is possible, could the filter be applied to the 3d dimension?
- Maybe there is a better way to implement color-grading that I don't know?
Answer
Yes, you can use a volume texture in HLSL and get hardware interpolation along all three axes.
- In D3D9, create a
sampler3D
variable and use thetex3d
function to read it in the shader. - In D3D10-11, create a
Texture3D
variable and use itsSample
method to read it in the shader.
In either case you must have created the texture as a 16x16x16 3D texture from the main application, not as a flattened 256x16 2D texture.
No comments:
Post a Comment