I'm working on a scientific visualization project and need to create a transfer function widget. The volume data is either in range
0-255 or it can be 16 bit i.e.
0-65535. Now the main problem is in order to color certain sections, the user needs to be able to define certain control points with varying colors and the colors need to be smoothly transitioned between those control points. Then during rendering, we find the color for every isovalue through a texture lookup in a ramp texture and color the volume data.
I've decided to do cubic spline interpolation between these control points. My question is, how do I actually render and store this gradient in an Nx1 ramp texture. Firstly, regarding the rendering part. I'm using OpenGL but also Dear-ImGui for GUI. So I don't have low level access to rendering like vertex/fragment shader for rendering this gradient. Just low level functions like rendering lines/rectangles etc.
For 8 bit volumes, I could render 256 lines of thickness
gradient_width_in_pixels/256. I think this would give me the look of a rectangular gradient? However suppose I have a 16 bit volume. The max value now is 65k. I could go on and convert it to
0-255 but let's say I don't because there would be a loss of precision as in the
0-255 scale 1 value represents approximately 256 values of
0-65535 scale. What if the user wanted to color within that range? What's the proper way to handle this scenario now?
Secondly, regarding storing the gradient information. For 8bit datasets, again it'd seem pretty simple to just create an
256x1 texture. However the problem again rises for 16 bit datasets. 65k pixels don't sound good or are they okay? I know
65k x 1 texture is just a
256x256 texture but dunno if increasing only 1 dimension will cause problems.
EDIT: I thought I should clarify regarding rendering the gradient part and ask the question differently. What I wanna know is given a color control point at pixel coord (x1,y) and another point at (x2, y), how many lines of any thickness should I render to get a color gradient with smooth transition between those two colors?