Skip to content

A port of Blender's AgX to darktable #19026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ output*png
Brewfile.lock.json
CMakeLists.txt.user
workspace/
cmake-build-debug/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes in this file are probably superfluous.

.idea/
29 changes: 29 additions & 0 deletions data/darktableconfig.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -3520,6 +3520,7 @@
<enum>
<option>scene-referred (sigmoid)</option>
<option>scene-referred (filmic)</option>
<option>scene-referred (agx)</option>
<option>display-referred (legacy)</option>
<option>none</option>
</enum>
Expand Down Expand Up @@ -3851,6 +3852,34 @@
<shortdescription>active tab in tone equaliser module</shortdescription>
<longdescription>which of simple, advanced or masking tabs will show at startup</longdescription>
</dtconfig>
<dtconfig>
<name>plugins/darkroom/agx/enable_curve_tab</name>
<type>bool</type>
<default>false</default>
<shortdescription>whether to enable the curve tab</shortdescription>
<longdescription>if enabled, the settings tab will have fewer controls and will occupy less vertical space</longdescription>
</dtconfig>
<dtconfig>
<name>plugins/darkroom/agx/expand_curve_graph</name>
<type>bool</type>
<default>false</default>
<shortdescription>whether to expand the curve graph</shortdescription>
<longdescription>this is just to store whether to show the curve graph or not</longdescription>
</dtconfig>
<dtconfig>
<name>plugins/darkroom/agx/curve_graph_height</name>
<type min="100" max="300">int</type>
<default>200</default>
<shortdescription>height of agx graph in per cent</shortdescription>
<longdescription>height of agx graph in per cent</longdescription>
</dtconfig>
<dtconfig>
<name>plugins/darkroom/agx/expand_curve_advanced</name>
<type>bool</type>
<default>false</default>
<shortdescription>whether to show advanced curve parameters</shortdescription>
<longdescription>this is just to store whether to show advanced curve parameters or not</longdescription>
</dtconfig>
<dtconfig>
<name>plugins/lighttable/collect/windowheight</name>
<type>int</type>
Expand Down
6 changes: 6 additions & 0 deletions src/common/iop_order.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const dt_iop_order_entry_t legacy_order[] = {
{ {44.0f }, "lowlight", 0},
{ {45.0f }, "monochrome", 0},
{ {45.3f }, "sigmoid", 0},
{ {45.5f }, "agx", 0},
{ {46.0f }, "filmic", 0},
{ {46.5f }, "filmicrgb", 0},
{ {47.0f }, "colisa", 0},
Expand Down Expand Up @@ -253,6 +254,7 @@ const dt_iop_order_entry_t v30_order[] = {
// on camera JPEG default look
{ {45.0f }, "filmic", 0}, // same, but different (parametric) approach
{ {45.3f }, "sigmoid", 0},
{ {45.5f }, "agx", 0},
{ {46.0f }, "filmicrgb", 0}, // same, upgraded
{ {36.0f }, "lut3d", 0}, // apply a creative style or film emulation, possibly non-linear
{ {47.0f }, "colisa", 0}, // edit contrast while damaging colour
Expand Down Expand Up @@ -370,6 +372,7 @@ const dt_iop_order_entry_t v50_order[] = {
// on camera JPEG default look
{ {45.0f }, "filmic", 0}, // same, but different (parametric) approach
{ {45.3f }, "sigmoid", 0},
{ {45.5f }, "agx", 0},
{ {46.0f }, "filmicrgb", 0}, // same, upgraded
{ {36.0f }, "lut3d", 0}, // apply a creative style or film emulation, possibly non-linear
{ {47.0f }, "colisa", 0}, // edit contrast while damaging colour
Expand Down Expand Up @@ -487,6 +490,7 @@ const dt_iop_order_entry_t v30_jpg_order[] = {
{ { 44.0f }, "basecurve", 0 }, // conversion from scene-referred to display referred, reverse-engineered
// on camera JPEG default look
{ { 45.0f }, "filmic", 0 }, // same, but different (parametric) approach
{ {45.5f }, "agx", 0},
{ { 45.3f }, "sigmoid", 0},
{ { 46.0f }, "filmicrgb", 0 }, // same, upgraded
{ { 36.0f }, "lut3d", 0 }, // apply a creative style or film emulation, possibly non-linear
Expand Down Expand Up @@ -608,6 +612,7 @@ const dt_iop_order_entry_t v50_jpg_order[] = {
// on camera JPEG default look
{ { 45.0f }, "filmic", 0 }, // same, but different (parametric) approach
{ { 45.3f }, "sigmoid", 0},
{ {45.5f }, "agx", 0},
{ { 46.0f }, "filmicrgb", 0 }, // same, upgraded
{ { 36.0f }, "lut3d", 0 }, // apply a creative style or film emulation, possibly non-linear
{ { 47.0f }, "colisa", 0 }, // edit contrast while damaging colour
Expand Down Expand Up @@ -1177,6 +1182,7 @@ GList *dt_ioppr_get_iop_order_list(const dt_imgid_t imgid,
_insert_before(iop_order_list, "colorbalance", "diffuse");
_insert_before(iop_order_list, "nlmeans", "blurs");
_insert_before(iop_order_list, "filmicrgb", "sigmoid");
_insert_before(iop_order_list, "filmicrgb", "agx");
_insert_before(iop_order_list, "colorbalancergb", "colorequal");
_insert_before(iop_order_list, "highlights", "rasterfile");
}
Expand Down
90 changes: 90 additions & 0 deletions src/common/iop_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,96 @@ void dt_ioppr_get_export_profile_type(struct dt_develop_t *dev,
"[dt_ioppr_get_export_profile_type] can't find colorout iop");
}

/**
* Get the export profile settings configured in the colorout module.
* This retrieves the settings as configured in the GUI, regardless of the
* current pipeline type (display, export, etc.).
*
* @param dev develop struct
* @param profile_type pointer to store the profile type
* @param profile_filename buffer to store the filename (supply size)
* @param filename_size size of the profile_filename buffer
* @param profile_intent pointer to store the rendering intent
* @return TRUE if colorout module and parameters were found, FALSE otherwise
*/
gboolean dt_ioppr_get_configured_export_profile_settings(
struct dt_develop_t *dev,
dt_colorspaces_color_profile_type_t *profile_type,
char *profile_filename,
size_t filename_size,
dt_iop_color_intent_t *profile_intent)
{
// Initialize output parameters to default/invalid values
if (profile_type) *profile_type = DT_COLORSPACE_NONE;
if (profile_filename) profile_filename[0] = '\0';
if (profile_intent) *profile_intent = DT_INTENT_PERCEPTUAL; // Default intent

dt_iop_module_so_t *colorout_so = NULL;
// Find the colorout module SO (should be loaded)
for(const GList *modules = darktable.iop; modules; modules = g_list_next(modules))
{
dt_iop_module_so_t *module_so = modules->data;
if(dt_iop_module_is(module_so, "colorout"))
{
colorout_so = module_so;
break;
}
}

if (!colorout_so || !colorout_so->get_p)
{
// colorout module SO not found or doesn't support get_p
dt_print(DT_DEBUG_ALWAYS, "[get_configured_export_profile_settings] colorout SO or get_p not found.");
return FALSE;
}

dt_iop_module_t *colorout = NULL;
// Find the colorout instance in the current pipeline (dev->iop)
// Start from the end, as colorout is usually last
for(const GList *modules = g_list_last(dev->iop); modules; modules = g_list_previous(modules))
{
dt_iop_module_t *module = modules->data;
if(dt_iop_module_is(module->so, "colorout"))
{
colorout = module;
break;
}
}

if (!colorout)
{
// colorout module instance not found in this pipeline
dt_print(DT_DEBUG_ALWAYS, "[get_configured_export_profile_settings] colorout module not found in pipe.");
return FALSE;
}

// Get pointers to the parameter values using introspection
dt_colorspaces_color_profile_type_t *_type = colorout_so->get_p(colorout->params, "type");
char *_filename = colorout_so->get_p(colorout->params, "filename");
dt_iop_color_intent_t *_intent = colorout_so->get_p(colorout->params, "intent");

// Check if all expected parameters were successfully retrieved
if (_type && _filename && _intent)
{
// Populate the output parameters
if (profile_type) *profile_type = *_type;
if (profile_filename && filename_size > 0) g_strlcpy(profile_filename, _filename, filename_size);
if (profile_intent) *profile_intent = *_intent;

dt_print(DT_DEBUG_DEV,
"[get_configured_export_profile_settings] Retrieved export profile: type=%d, filename='%s', intent=%d",
*profile_type, profile_filename, *profile_intent);
return TRUE; // Success
}
else
{
dt_print(DT_DEBUG_ALWAYS,
"[get_configured_export_profile_settings] Failed to get colorout parameters via get_p.");
// Even on failure, the output parameters were initialized to default/invalid
return FALSE;
}
}

void dt_ioppr_get_histogram_profile_type(dt_colorspaces_color_profile_type_t *profile_type,
const char **profile_filename)
{
Expand Down
10 changes: 10 additions & 0 deletions src/common/iop_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ void dt_ioppr_get_input_profile_type(struct dt_develop_t *dev,
void dt_ioppr_get_export_profile_type(struct dt_develop_t *dev,
dt_colorspaces_color_profile_type_t *profile_type,
const char **profile_filename);
/**
* @see dt_ioppr_get_configured_export_profile_settings()
*/
gboolean dt_ioppr_get_configured_export_profile_settings(
struct dt_develop_t *dev,
dt_colorspaces_color_profile_type_t *profile_type,
char *profile_filename,
size_t filename_size,
dt_iop_color_intent_t *profile_intent);

/** returns the current setting of the histogram profile */
void dt_ioppr_get_histogram_profile_type(dt_colorspaces_color_profile_type_t *profile_type,
const char **profile_filename);
Expand Down
3 changes: 2 additions & 1 deletion src/common/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,8 @@ gboolean dt_str_commasubstring(const char *list,
gboolean dt_is_scene_referred(void)
{
return dt_conf_is_equal("plugins/darkroom/workflow", "scene-referred (filmic)")
|| dt_conf_is_equal("plugins/darkroom/workflow", "scene-referred (sigmoid)");
|| dt_conf_is_equal("plugins/darkroom/workflow", "scene-referred (sigmoid)")
|| dt_conf_is_equal("plugins/darkroom/workflow", "scene-referred (agx)");
}

gboolean dt_is_display_referred(void)
Expand Down
1 change: 1 addition & 0 deletions src/iop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ add_iop(cacorrectrgb "cacorrectrgb.c")
add_iop(diffuse "diffuse.c")
add_iop(blurs "blurs.c")
add_iop(sigmoid "sigmoid.c")
add_iop(agx "agx.c")
add_iop(primaries "primaries.c")
add_iop(colorequal "colorequal.c")
add_iop(rasterfile "rasterfile.c")
Expand Down
Loading
Loading