Blender 2.8x default is HSV, but I want RGB like in 2.7x.
Saving startup file doesn't store new settings.
In the preferences settings one can only change circle to square or HSV to HSL, nothing more. No circle or square RGB
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communitythere is no option to change the color picker type to rgb
but you can download source of blender 2.83 and add an option to change colors to rgb
blender-2.83.5\source\blender\editors\interface_region_color_picker.c
as you know enum has a default value
enum ePickerType {
PICKER_TYPE_RGB = 0,
PICKER_TYPE_HSV = 1,
PICKER_TYPE_HEX = 2,
};
by default color picker type is PICKER_TYPE_HSV = 1
so you can change it to PICKER_TYPE_RGB = 0
static char colormode = 0;
you should add a case for RGB in preferences
switch (U.color_picker_type) {
case USER_CP_SQUARE_SV:
ui_colorpicker_square(block, ptr, prop, UI_GRAD_SV, cpicker);
break;
case USER_CP_SQUARE_HS:
ui_colorpicker_square(block, ptr, prop, UI_GRAD_HS, cpicker);
break;
case USER_CP_SQUARE_HV:
ui_colorpicker_square(block, ptr, prop, UI_GRAD_HV, cpicker);
break;
/* user default */
case USER_CP_CIRCLE_HSV:
case USER_CP_CIRCLE_HSL:
case USER_CP_CIRCLE_RGB: # I ADD THIS CASE HERE
default:
ui_colorpicker_circle(block, ptr, prop, cpicker);
break;
}
there is a function to change the hsv/hsl to rgb:
void ui_color_picker_to_rgb(float r_cp0, float r_cp1, float r_cp2, float *r, float *g, float *b)
{
switch (U.color_picker_type) {
case USER_CP_CIRCLE_HSL:
hsl_to_rgb(r_cp0, r_cp1, r_cp2, r, g, b);
break;
default:
hsv_to_rgb(r_cp0, r_cp1, r_cp2, r, g, b);
break;
}
}
enum ePickerType {
PICKER_TYPE_RGB = 0,
PICKER_TYPE_HSV = 1,
PICKER_TYPE_HEX = 2,
};
How does enum work?
/* mode */
yco = -1.5f * UI_UNIT_Y;
UI_block_align_begin(block);
bt = uiDefButC(block,
UI_BTYPE_ROW,
0,
IFACE_("RGB"),
0,
yco,
width / 3,
UI_UNIT_Y,
&colormode,
0.0,
(float)PICKER_TYPE_RGB,
0,
0,
"");
UI_but_flag_disable(bt, UI_BUT_UNDO);
UI_but_func_set(bt, ui_colorpicker_create_mode_cb, bt, NULL);
bt->custom_data = cpicker;
bt = uiDefButC(block,
UI_BTYPE_ROW,
0,
IFACE_((U.color_picker_type == USER_CP_CIRCLE_HSL) ? "HSL" : "HSV"),
width / 3,
yco,
width / 3,
UI_UNIT_Y,
&colormode,
0.0,
PICKER_TYPE_HSV,
0,
0,
"");
then you can use this function to change the color picker type:
bpy.context.preferences.view.color_picker_type = 'CIRCLE_RGB'
I also downloaded blender 2.79 source I found a function to convert rgb to hsv maybe useful:
2.79\scripts\addons\cycles\source\util\util_color.h
ccl_device float3 rgb_to_hsv(float3 rgb)
{
float cmax, cmin, h, s, v, cdelta;
float3 c;
cmax = fmaxf(rgb.x, fmaxf(rgb.y, rgb.z));
cmin = min(rgb.x, min(rgb.y, rgb.z));
cdelta = cmax - cmin;
v = cmax;
if(cmax != 0.0f) {
s = cdelta/cmax;
}
else {
s = 0.0f;
h = 0.0f;
}
if(s != 0.0f) {
float3 cmax3 = make_float3(cmax, cmax, cmax);
c = (cmax3 - rgb)/cdelta;
if (rgb.x == cmax) h = c.z - c.y;
else if(rgb.y == cmax) h = 2.0f + c.x - c.z;
else h = 4.0f + c.y - c.x;
h /= 6.0f;
if(h < 0.0f)
h += 1.0f;
}
else {
h = 0.0f;
}
return make_float3(h, s, v);
}
PICKER_TYPE_RGB = 0
and it worked fine. But adding case USER_CP_CIRCLE_RGB:
throws error: ‘USER_CP_CIRCLE_RGB’ undeclared (first use in this function);
$\endgroup$
you can use a macro recorder to change the color type!!!
when you change the color type once it works for other colors until you close the blender
so use this program when you open the blender
import pyautogui
print(pyautogui.position())
pyautogui.moveTo(863,687,0.2) # Materil Position
pyautogui.click()
pyautogui.moveTo(976,677,0.2) # Color Position
pyautogui.click()
pyautogui.moveTo(834,559,0.2) # Change The Color Type to RGB
pyautogui.click()
bpy.context.preferences.view.color_picker_type = 'CIRCLE_HSV'
I also try to change theNodeSocketColor
but there is no access to this class $\endgroup$