OpenGl Hue Rotation???

Andrew Sblendorio's icon

Hey everyone,

I'm working on an RGB shift video mixer, I've already got one working well with the normal Jitter objects but am working on an OpenGL version. One thing I have not been able to find a substitute for is the jit.hue object to be able to rotate the overall hue of the image, does any one have a jit.gl.pix or jit.gl.slab worked up that performs this function? If not, does anyone have any ideas on how to develop one? Thank you!

metamax's icon

One way to do this is to do a matrix rotation of RGB cube space along the grayscale axis (cube diagonal) to change hue while maintaining constant luminance. [jit.gl.pix] also has rgb2hsl and hsl2rgb operators.

Andrew Sblendorio's icon

Sounds like your first idea may be a bit beyond my level, how could I implement the rgb2hsl operator to do the job? I'm trying to figure it out, simply running a video through the operator and outputting it changes all the colors, and I can't figure out how to parse just the hue information and alter it...any ideas?

Rob Ramirez's icon

gl.pix is tricky to get the hang of, but once you do your jitter-gl world opens up significantly.

for hue shifting, you send the input through rgb2hsl, swiz the hue value (component 0, or 'r', or 'x'), modify with your hue parameter, concat back with the other components, send back to hsl2rgb and out the outlet.

Max Patch
Copy patch and select New From Clipboard in Max.

metamax's icon

Sounds like your first idea may be a bit beyond my level, how could I implement the rgb2hsl operator to do the job?

Yeah, it's kinda beyond my level too. However, today... today is a good day - for me and you and any other hue-rotating yahoos in maxspace.
I managed to create a drop-in [jit.hue] replacement in genexpr that actually does a better job at maintaining constant color-brightness with smoother hue transitions + saturation adjustments that also maintain constant luma... yee haw.

The issue is that certain colors are brighter than others. If hue is changed without adjusting for that difference, there is a secondary shift in brightness. That's the idea behind [jit.hue] which does a better job at maintaining constant luma than the quick and easy HSL breakout.

For example, you might map amplitude to brightness and pitch to hue. But as hue is adjusted, amplitude gets affected. Maybe you want that, maybe you don't. To keep the secondary param from fluctuating, the space can be rotated and sheared so that changes to the hue-angle map to the same luma plane. The visual difference is very obvious with less banding and distortion. Of course you might want those artifacts, so be sure to test using different gradients and textures. Either way, this is as close to [jit.hue] on the GPU as I have seen in Max.

Max Patch
Copy patch and select New From Clipboard in Max.

mh77's icon

Hello guys,
i experience some strange problems with hue adjustment and jit.gl.pix.
the problem is that i cant open the help file of jit.gl.pix [where a hue example is integrated]
in max7.3 64bit the software crashes.

if i use max7.3 in 32bit mode i can open the help file but the result is always black and white.
its the same with jit.gl.slab and cc.hsl2rgb.jxs file loaded. its black/white only.

maybe you can confirm this or you can give me a hint what i can do.
i'm using Windows 10 [with anniversary update] and max7.3 64bit and 32bit

thank you in advance.

Andrew Sblendorio's icon

The first issue with 64 bit vs 32 bit is that (at least on windows) 64 bit does not do video. You have to do it in 32-bit Max.

With the second issue, do you mean there is an image and the image is black and white or that you can only see two colors, all black and all white? Either way I am not sure what the answer is there.

mh77's icon

Hi Andrew,
thanks for you answer.
yes. i just open the jit.gl.pix helpfile , start the default movie [bball.mov] and if i change the hue_shift nothing happens.
i see the movie in black and white only. i attached a screenshot.

and concerning the the first issue. if i change to viddll engine it shouldl work [and i think it worked before]
also in 64bit max. but the second issue is more important.

thanks again in advance.
matthias

hue_problem.png
png
Andrew Sblendorio's icon

You are correct about viddll engine, I was thinking of the qt limitation. Anyways I the example I have is working in color, the one thing I was thinking of was that the range of hue rotation is from 0. to 1. but it looks like you already know that since you're set to 0.2 in your screenshot. So I am not sure what is causing it to only be in black and white.

Rob Ramirez's icon

hi MH77, we've seen this reported a few times, where the rgb2hsl gen object is broken on certain Windows machines. this would most likely be the cause of your problem. we are looking into this, and will hopefully have a fix for it soon.

mh77's icon

hi rob, thank you for your comment.
somehow i believe it has to do with nvidia drivers.
i had one success in deinstalling the newest driver and install
an nvidia driver from september 2016.

it worked, but not for long.
so. i hope you find a solution.

best
m

Rajan Craveri - micron's icon

I have the same problem.
Nvidia gtx1070
windows 10
max 32 and 64 bit the same

Rajan Craveri - micron's icon

Solved after update Nvidia drivers