WIP: OK Color #107933

Draft
Jorijn de Graaf wants to merge 7 commits from bonj/blender:ok-color into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Contributor

OK HSV / HSL for color pickers.

OK HSV / HSL for color pickers.
Jorijn de Graaf added 1 commit 2023-05-15 01:36:54 +02:00
69dd42a693 OK Color initial implementation
The foundation is there, with a proper external module and build option.
Björn Ottosson's original code is a CPP header; I ported it to C with a header that only exposes the desired functions. I might add a diff for this later to keep track of changes.
The actual integration of these functions into Blender's color math is hacky and doesn't work properly, which is what I intend to work on next.
Jorijn de Graaf added 1 commit 2023-05-15 01:39:08 +02:00
YimingWu reviewed 2023-05-15 07:39:40 +02:00
@ -13,2 +16,4 @@
void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b)
{
#ifdef WITH_OK_COLOR
Member

We probably do not want to have a #ifdef here in such a generic color function because this is not only used in the color picker, but also other parts of Blender.

Also, We probably would like to have an additional option for the user to choose which style of the color picker do they want to use, it's better to expose there (see static const EnumPropertyItem color_picker_types[]). But then you will also probably need to deal with a little bit shader for the actual circle to be drawn correctly.

Additionally, The widget display/value conversion should (already?) follow viewport color management.

We probably do not want to have a `#ifdef` here in such a generic color function because this is not only used in the color picker, but also other parts of Blender. Also, We probably would like to have an additional option for the user to choose which style of the color picker do they want to use, it's better to expose there (see `static const EnumPropertyItem color_picker_types[]`). But then you will also probably need to deal with a little bit shader for the actual circle to be drawn correctly. Additionally, The widget display/value conversion should (already?) follow viewport color management.
Author
Contributor

I did it like this because I hadn't found a better way yet.
It's a draft for a reason haha.
Thanks for the tips, I'll try to make it an option.

I did it like this because I hadn't found a better way yet. It's a draft for a reason haha. Thanks for the tips, I'll try to make it an option.
YimingWu added the
Interest
User Interface
label 2023-05-15 07:55:04 +02:00
Jorijn de Graaf added 3 commits 2023-05-16 01:10:41 +02:00
51297be341 Remove unnecessary spaces in include
I don't know how this got here but it's bothering me.
It doesn't really matter as this isn't the right place to do this anyway but it doesn't hurt to fix either.
2642b455fd Clamp sRGB to OK HSV/L and do NaN checks
This is roughly the same I did for Godot, but built into the ok_color functions themselves.
Having these functions return only valid numbers makes life a lot easier.
Jorijn de Graaf added 1 commit 2023-05-16 01:46:41 +02:00
9af9c73c34 Make ok_color functions similar to math_color
You no longer need to use the structs to use these functions.
The clamping and NaN checks are done in the new functions, to keep the rest of the code closer to the original.
The actual calling of these functions is still done in math_color.c, which is definitely the wrong place; one step at a time.
Author
Contributor

Blender has a "perceptually linear color space" for color pickers, which gives strange results in combination with OK color, so I'll need to figure out how to turn that off.

Blender has a "perceptually linear color space" for color pickers, which gives strange results in combination with OK color, so I'll need to figure out how to turn that off.
Jorijn de Graaf added 1 commit 2023-05-22 23:58:03 +02:00
This pull request has changes conflicting with the target branch.
  • source/blender/makesrna/intern/rna_userdef.c

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u ok-color:bonj-ok-color
git checkout bonj-ok-color
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107933
No description provided.