9
$\begingroup$

Blender 2.8x default is HSV, but I want RGB like in 2.7x.

Saving startup file doesn't store new settings.

enter image description here

In the preferences settings one can only change circle to square or HSV to HSL, nothing more. No circle or square RGB

enter image description here

$\endgroup$
4
  • $\begingroup$ "Saving startup file doesn't store new settings." Settings are saved in the settings file not startup, so you should probably be saving settings from the user preferences dialog $\endgroup$ Aug 19 '20 at 11:07
  • 5
    $\begingroup$ @Duarte Farrajota Ramos There is no such option in preferences, I can only change circle to square or HSV to HSL, nothing more (or I couldn't find) $\endgroup$
    – Serge L
    Aug 19 '20 at 11:25
  • $\begingroup$ blender.stackexchange.com/a/140994/19307 $\endgroup$ Aug 19 '20 at 11:35
  • $\begingroup$ I tried to change it by code but there is no option as RGB color! bpy.context.preferences.view.color_picker_type = 'CIRCLE_HSV' I also try to change the NodeSocketColor but there is no access to this class $\endgroup$ Aug 28 '20 at 2:50
8
+100
$\begingroup$

there 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

Easy Solution

as you know enum has a default value

enter image description here

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;

enter image description here

Hard Solution Adding to preferences

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;
  }
}

enter image description here

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);
}
$\endgroup$
6
  • $\begingroup$ @susu I edited my answer and I did my best to explain how to change the color picker type to RGB $\endgroup$ Aug 30 '20 at 20:29
  • $\begingroup$ For 2.9 i edited source/blender/editors/interface_templates.c with 'setting 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$
    – susu
    Aug 31 '20 at 4:00
  • $\begingroup$ @susu cheers!!! sorry as I'm a beginner I didn't know how to build the blender and how to test my code. but I was sure about my code! if you tell me how to test it I will try again. $\endgroup$ Aug 31 '20 at 4:05
  • 1
    $\begingroup$ wiki.blender.org/wiki/Building_Blender $\endgroup$
    – susu
    Aug 31 '20 at 4:09
  • $\begingroup$ could it be that the definition is set in a different file? /source/blender/editors/interface/interface_templates.c ? $\endgroup$
    – susu
    Aug 31 '20 at 4:15
2
$\begingroup$

Silly Solution

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

enter image description here

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()
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.