Re: [vtk-developers] Passing arbitrary float data to a shader
What you ask is more a GLSL topic than VTK I guess. What you need is the texelFetch() method instead the texture() one. texture() clamps the values to 0-1 extent. texelFetch returns the actual value stored and with floatBitsToInt you can even "encode/decode" integer values if needed.
I believe float data in the texture is the full range as long as the underlying VTK data type is float.
I would have assumed so too! But as per my follow up note I sent just a little while ago, the floats are unfortunately not the full range as they get converted to rgba 8 bit per channel in the vtkOpenGLTexture::Load() function ?- for which I submitted a simple fix to indeed keep the full range.
Just to be clear, I need to pass data to a shader in order to shade a triangle mesh in a particular way. I don?t need to write to a float framebuffer.
The data I need is not pixels and it?s not colors. It?s a float array used for some arbitrary shader computation.
I used to pass these floats as uniform data to the shader but I ran out of uniforms and had to encode this data elsewhere, eg: in an image buffer instead. In my shader I access this data with the glsl function texelFetch() instead of reading a uniform.
But even with that example in the end the framebuffer will be blitted to screen which is typically an 8bit buffer. But at least in that example you can accumulate etc in floating point all you want prior to that final blit to the screen.
I am trying to pass custom float data to my shader in the form of a vtkTexture which contains VTK_FLOAT data (4 components).
As per the documentation, it appears that float data in the image buffer gets clamped in the 0-1 range, which is a huge problem for me as I'm only getting 0-1 data in the shader: I need the pixel data to be the actual float data (which can be anything, not restricted to any particular range).