1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Floating point buffer

Posted by Romz on Jun 15, 2008

Hi there !

First thing: excellent tool ! Thanks for doing this !

I read a lot of examples, but I can't find something I need.
Actually I need some kind of floating point buffer, just like a texture or canvas containing colors, but something that doesn't clamp values to 1.0.

The thing is I want to add a color to an existing buffer (like: pixels[x + y * width] += color), and then scale these values (amongst other things) so it become real (drawable) colors. It's like some HDR computations (not for common HDR things at all).

Is there anything that is existing to do such a thing ?
In C/C++ I would have used a "float buffer[width*height*3]", and then after scaling the values, put them in a rgb (24bits) texture.

Thank you very much !




Posted by Tom De Smedt on Jun 27, 2008

I'm not sure I understand what you need, but wouldn't a solution be to work with your own list of values, and then create a color from the list when you're done with it ? E.g.

# Your own list of values to work with, no clamping:
rgba = [0.5, 1.3, 0.1, 0.9]
for i in range(len(rgba)):
    rgba[i] *= 2
print rgba
 
# The * unpacks the values in the list 
# as parameters for the color() command:
clr = color(*rgba) 
background(clr)