PDA

View Full Version : what is FramebufferTexture1D for ?



Yoonjae
09-16-2009, 01:48 AM
I'm very curious about what we can do with FramebufferTexture1D(). I searched for any information and usage of this function in this forum and google, it was fruitless.

Does it mean we can render to 1D texture apart from 2D, 3D, 2D array and cube ?
But I can hardly imagine that fragment shader can write to 1D texture.
What do you think the common usage of FramebufferTexture1D is ?
I presume something like "render-to-texture-buffer" may be possible via this function, but I have no confidence on it.

Heiko
09-16-2009, 02:41 AM
Yes, you can render to a 1D texture. Often 1D textures are used as lookup textures. Rendering to the 1D (lookup) texture is a way to fill your lookup table.

Yoonjae
09-16-2009, 03:07 AM
Thanks for your reply, Heiko.
Frankly, I have problem in understanding the rasterization of 3D object to 1D render-target. I doubt it's of any use.

What I'm wondering is, if we render two fragments having the same y coordinate in NDC to 1D texture, then does one of them overwrite the other one ?
I.e, in NDC, the two fragments (-1,0) and (-1,1) both are written to the left-most pixel of 1D texture ?

Heiko
09-16-2009, 03:15 AM
There is probably not much use of rendering 3d objects to a 1D texture. But if you really want to, you could render objects to a 1D texture, using a viewport that has a very small height (of 1 pixel).

In the example you give, one of the fragments would fall outside the viewport and won't be rendered at all. So: no, only one of them is written to the left-most pixel.

Probably more useful is to render a 1 by n quad to a 1D texture and perform some calculations in the fragment shader to put useful values in the 1D texture. In another render pass you can use the 1D texture as a lookup table.

Yoonjae
09-16-2009, 03:28 AM
Adjusting viewport seems to be a good option for FramebufferTexture1D. Thanks.