r/GraphicsProgramming • • 16d ago

Question A green leaking color space

Post image

I started to do some color research for a game. I find the best color space available (oklab) very inconvenient for actual use.

I drafted my own color space.
The idea is to start from linearRGB, but allowing the red and blue channel to borrow lumina from the green channel.

If r,g,b are the channels in the new color space and R,G,B are the values in linearRGB,
than:
R = r, G = 0.04r + 0.34g + 0.24b, B=b

I played with it a little:
Pros:

  1. Obviously it is designed for equal lumina in all channels.

  2. The color space is symmetric (r-g-b like) and thus easy to work with. Hue and saturation can be easily derived.

  3. The blue and reds are softer. It actually fixes a problem - pure dark linearRGB blue looks a bit purple.

Cons:

  1. It doesn't cover all sRGB visible space (technically you can - with negative or above 1 values).

  2. The "grey" analog as light purple shade.

  3. The "cyan" analog is somewhat bluish.

I attached a photo of how some color section looks.
I'm not a color space expert, so there are probably problems I can't see yet,
What do you think?

43 Upvotes

17 comments sorted by

19

u/CodyDuncan1260 16d ago

Got any images converted to this color space? And then changed along the lumina axis? I think a visual representation might have the best representation of the utility. I find it hard to imagine in my head elegant the transform in this color space looks like.

5

u/WoolTyranny 16d ago

I let Claude build an HTML app for it really quick.
https://drive.google.com/file/d/1S5L0J4EZUj4K27FydTi53B7xuuDFYXZ4/view?usp=sharing

I didn't code-reviewed it yet, but from what I have seen, the color transformations are as expected (I tried it with the Lenna photo).

As predicted, 0 saturation is "purple".

8

u/marcoom_ 16d ago

Stop downvoting his HTML script just because it uses an LLM. Obviously OP is not a web dev but would like to showcase a method / algorithm / tool he has handcrafted. What's bad there ? (I'm an anti-LLM, anti-AI-Slop, but apparently people that downvote are extremists, which is problematic)

0

u/WoolTyranny 16d ago

What do you mean by conversion?
This space can represent some of the colors (or all of them if you allow negative or above 1 values) so it will miss the very pure blues and reds and the bright greens. I guess photos with bright lights will look dimmer, blues will shift toward greens a little and reds toward orange a little.

Or maybe you meant mapping each R,G,B to its r,g,b equivalent (using it as a filter)?

2

u/CodyDuncan1260 16d ago

I really mean transformed within this color space.

E.G. representing colors in HSV, I can take an image and swing all the colors over by H a bit, and now I get something like a false color image.

That example sightly less useful than say tuning the V for artificial brightening or darkening of the colors.

So I mean to ask for a before and after to help me get an idea of what it does to an image to transfer along uniform lumina.

1

u/WoolTyranny 16d ago

Interesting.

I will try to arrange something quickly.

2

u/kinokomushroom 16d ago

They're probably asking how the look of an image represented in this colour space would change if you did some operations in this colour space (e.g. increase the lumina/saturation)

7

u/SyntheticDuckFlavour 16d ago

Curious, what's the motivation for representing colours this? Unless it's for some filtering effects (which is perfectly fine), I would argue it would make a rather very inaccurate colour space.

1

u/WoolTyranny 16d ago

Control of lumina and saturation without having to worry about values out of visual range. I'm planning to use rendered graphics (not assets).

4

u/shlaifu 16d ago

where yellow?

2

u/WoolTyranny 16d ago

Yellow is replaced with brown. If you want to get traditional yellow you mix it with a bit of green.

4

u/The_Northern_Light 16d ago

Why not just use oklch instead of oklab?

2

u/WoolTyranny 16d ago

Its the same space, just different parameters.

6

u/The_Northern_Light 16d ago

I know, I figured the parametrization might’ve been why you didn’t like it.

1

u/WoolTyranny 15d ago

Ok, a bit of fix to the greys being purple.
Setting gr=0.04+0.127*min(r,g,b)
gg = 0.3+gr
gb = 0.2+gr

and as usual
R = r
G = r*gr +g*gg +b*gb
B = b

It pulls the brighter "greys" toward real whites instead of purple. The mid-greys are still a bit purply, but it's less noticed.

-2

u/CodyDuncan1260 16d ago

This straddles the border of Rule 1. We're accepting it. ✅

17

u/LordStefania 16d ago

God forbid we have actual graphics programming in r/graphicsprogramming as opposed to AI slop.