martinchrzan / ColorPicker

Windows system-wide color picker
MIT License
339 stars 29 forks source link

Feature Request: function evaluation in custom formats #27

Open KhardanOne opened 1 year ago

KhardanOne commented 1 year ago

I use ColorPicker in PowerToys as a dev-tool during glsl programming, and loving it! Thank you.

Whenever I try to figure out what is happening inside one of my shaders, I take the values in question, turn them into RGB values, and display them as colored pixels. Then I use ColorPicker and calculate from RGB values backwards to get to the original values. I hope, this makes sense. Here is a common example:

Let's suppose I have a vec3 v; where x, y, z values can go from -1.0 to 1.0. Then I can do something like this: fragColor = vec4(v * 0.5 + 0.5, 1.0); As a result, pixels with v(0.0, 0.0, 0.0) values become 50% gray, v(-1.0, -1.0, -1.0) become black, v(1.0, 1.0, 1.0) become white.

After color picking them, I use formulas:

x = color.r * 2.0 - 1.0;
y = color.g * 2.0 - 1.0;
z = color.b * 2.0 - 1.0;

to get back the value of v. This is just an example. I use several other formulas for different kinds of things.

This last step is what I do in head or in a calculator, and would love to automate. The idea is to put these functions inside ColorPicker's custom format field, and have ColorPicker evaluate them. E.g. like this:vec3($(Ref * 2.0 - 1.0), $(Grf * 2.0 - 1.0), $(Blf * 2.0 - 1.0)) or something similar.

This might be quite a non-typical use-case. What do you think, is it worth adding it to ColorPicker?