[vtkusers] [vtk-developers] Passing arbitrary float data to a shader through a vtkTexture
Patrick Bergeron
pbergeron at spiria.com
Tue Feb 19 12:42:04 EST 2019
Hi Ken
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.
Patrick Bergeron
On Feb 19, 2019, at 08:30, Ken Martin <ken.martin at kitware.com<mailto:ken.martin at kitware.com>> wrote:
Two different things here I think
I believe float data in the texture is the full range as long as the underlying VTK data type is float.
The image buffer (pixels that get drawn to) by default is unsigned char normalized 0 to 1. To use float you need a float backed image buffer. Something like
https://gitlab.kitware.com/vtk/vtk/blob/master/Rendering/OpenGL2/Testing/Cxx/TestFramebufferHDR.cxx
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.
On Mon, Feb 18, 2019 at 7:07 PM Patrick Bergeron <pbergeron at spiria.com<mailto:pbergeron at spiria.com>> wrote:
Hi.
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).
How can I do this in VTK ?
Patrick.
_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Search the list archives at: http://markmail.org/search/?q=vtk-developers
Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers
--
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
101 East Weaver Street
Carrboro, North Carolina
27510 USA
This communication, including all attachments, contains confidential and legally privileged information, and it is intended only for the use of the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on it is prohibited and may be unlawful. If you received this communication in error please notify us immediately and destroy the original message. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20190219/8217761e/attachment.html>
More information about the vtkusers
mailing list