BradyBrenot / huestacean

Philips Hue control app for desktop with screen syncing. C++ with Qt Quick GUI.
http://huestacean.com
Apache License 2.0
564 stars 54 forks source link

Processing image on GPU before downscale #78

Open BradyBrenot opened 6 years ago

BradyBrenot commented 6 years ago

I could just as well do part of the processing on the GPU before bringing the image over to the CPU.

Spitballing, might be off:

Render the texture out to a buffer using a shader that

  1. Convert to LCh color space
  2. Stores color, lightness threshold passing, and zeroes out color that doesn't pass the threshold

Then we render down to our small texture (however many buckets, let's say 10x10), and

This doesn't do much as far as performance gains (maybe on very marginal Android CPUs) since we're already working with pretty small numbers of pixels on the CPU, but it might improve color by not scaling the image in RGB (interpolation in RGB is bad and not perceptually consistent), and giving us that early in for thresholding (so we don't end up with whites and blacks dulling all our beautiful colours, and blacks unnecessarily dimming the image).


Not sure being in a polar/cylindrical color space makes sense, polar coordinates and linear interpolation, blah.

Lab* would preserve perceptual brightness but not saturation.

Dracrius commented 6 years ago

Would this have any impact on the gpu while it is already in heavy use? I use huestacean while I'm playing games and some times while I'm playing VR games (keeps any outside light leakage consistent with the game - really cool for recordings) which can at times max out my lowly GTX 970 so I wouldn't want to start losing frames to huestacean using up GPU overhead. In VR a few frames can mean the difference between playing for hours or having to quite after one and feeling sick. If this will impact performance but is needed I'd just like to be aware.

BradyBrenot commented 6 years ago

It will. #19 will possibly have a larger effect, though, and will happen sooner. I'm going to try to keep an eye on it, I still want this to be as light as possible.