Adding more channels/data to an image?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Adding more channels/data to an image?
Is it possible in löve to add more channels than the only r,g,b,a one's? Like a 5th channel that can accept any number, decimal, negative etc. which isn't contrained to a range of 0-255.
Re: Adding more channels/data to an image?
You can store data to VRAM the same way as in RAM (not exactly, but still), so if you can write appropriate shader to use it, you can. You'd have to handle memory manually though.
Re: Adding more channels/data to an image?
Thanks for the suggestion raidho36, but think I'll go for an easier solution.. if there is any. I thought of something like:
I store the value I want over the 4 channels, in that way I will get a number limit of 255^4=4228250625, which I think is a reasonable limit for my purpose.
Kindof like: (r=205,g=4,b=1,a=1) equals the number: 4*255+205=1255. It's like a counter; when 'r' reaches 255, 'g' adds 1 to itself, and so on. I can't use decimals though. Would this idea work?
I store the value I want over the 4 channels, in that way I will get a number limit of 255^4=4228250625, which I think is a reasonable limit for my purpose.
Kindof like: (r=205,g=4,b=1,a=1) equals the number: 4*255+205=1255. It's like a counter; when 'r' reaches 255, 'g' adds 1 to itself, and so on. I can't use decimals though. Would this idea work?
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Adding more channels/data to an image?
If you want to pack a float value in 4 unsigned bytes (which is what each pixel in an ImageData is), you can do something like this http://aras-p.info/blog/2009/07/30/enco ... the-final/ , although if you use it outside a shader you'll have to either modify it to work in the 0-255 range instead of 0-1, or convert your numbers to 0-1 instead of 0-255 and convert back to 0-255 from 0-1 when reading from the function.
ImageData always stores 4-component RGBA data at 1 byte per component (32 bits total) per pixel, you can't change that.
In LÖVE 0.9.0, you will be able to create "HDR" Canvases (but not ImageData or Images) which store data at 64 bits per pixel (2 bytes per component and 4 color components per pixel) whose values can range from -infinity to +infinity. You'll need to use shaders to do anything useful with that, though.
ImageData always stores 4-component RGBA data at 1 byte per component (32 bits total) per pixel, you can't change that.
In LÖVE 0.9.0, you will be able to create "HDR" Canvases (but not ImageData or Images) which store data at 64 bits per pixel (2 bytes per component and 4 color components per pixel) whose values can range from -infinity to +infinity. You'll need to use shaders to do anything useful with that, though.
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests