OpenColorIO icon indicating copy to clipboard operation
OpenColorIO copied to clipboard

OCIODisplay dropdown channel shuffling wrong in Nuke 9

Open dbr opened this issue 10 years ago • 0 comments

The order of the items in the "channel view" dropdown changed between Nuke 8 and 9 (R/G/B/Matte Overlay/Luminace)

Here's a patch of the 1.0.9 code - shall try and remember to make a pull request for this later:

diff --git a/src/nuke/OCIODisplay/OCIODisplay.cpp b/src/nuke/OCIODisplay/OCIODisplay.cpp
index bf82ab8..9b8ad16 100644
--- a/src/nuke/OCIODisplay/OCIODisplay.cpp
+++ b/src/nuke/OCIODisplay/OCIODisplay.cpp
@@ -32,7 +32,13 @@ OCIODisplay::OCIODisplay(Node *n) : DD::Image::PixelIop(n)
     m_displayKnob = m_viewKnob = NULL;
     m_gain = 1.0;
     m_gamma = 1.0;
+#if kDDImageVersionMajorNum < 9
+    // RGB is third option in Nuke 8 and prior
     m_channel = 2;
+#else
+    // RGB is first option by default in Nuke 9
+    m_channel = 0;
+#endif
     m_transform = OCIO::DisplayTransform::Create();

     try
@@ -142,17 +148,33 @@ void OCIODisplay::knobs(DD::Image::Knob_Callback f)
     DD::Image::Float_knob(f, &m_gamma, DD::Image::IRange(0, 4), "gamma");
     DD::Image::SetFlags(f, DD::Image::Knob::NO_ANIMATION | DD::Image::Knob::NO_UNDO | DD::Image::Knob::LOG_SLIDER);
     DD::Image::Tooltip(f, "Gamma correction applied after the display transform.");
-    
-    static const char* const channelvalues[] = {
-      "Luminance",
-      "Matte overlay",
-      "RGB",
-      "R",
-      "G",
-      "B",
-      "A",
-      0
-    };
+
+#if kDDImageVersionMajorNum < 9
+        // Old ordering (in Nuke 8 and prior)
+        static const char* const channelvalues[] = {
+            "Luminance",
+            "Matte overlay",
+            "RGB",
+            "R",
+            "G",
+            "B",
+            "A",
+            0
+        };
+#else
+        // New ordering changed in Nuke 9
+        static const char* const channelvalues[] = {
+            "RGB",
+            "R",
+            "G",
+            "B",
+            "A",
+            "Luminance",
+            "Matte overlay",
+            0
+        };
+#endif
+
     DD::Image::Enumeration_knob(f, &m_channel, channelvalues, "channel_selector", "channel view");
     DD::Image::SetFlags(f, DD::Image::Knob::NO_ANIMATION | DD::Image::Knob::NO_UNDO);
     DD::Image::Tooltip(f, "Specify which channels to view (prior to the display transform).");
@@ -293,36 +315,56 @@ void OCIODisplay::_validate(bool for_real)
         // Add Channel swizzling
         {
             int channelHot[4] = { 0, 0, 0, 0};
-            
+#if kDDImageVersionMajorNum < 9
+            enum ChannelValues{
+                LUMA,
+                OVERLAY,
+                RGB,
+                R,
+                G,
+                B,
+                A,
+            };
+#else
+            enum ChannelValues{
+                RGB,
+                R,
+                G,
+                B,
+                A,
+                LUMA,
+                OVERLAY,
+            };
+#endif
             switch(m_channel)
             {
-            case 0: // Luma
+            case LUMA:
                 channelHot[0] = 1;
                 channelHot[1] = 1;
                 channelHot[2] = 1;
                 break;
-            case 1: //  Channel overlay mode. Do rgb, and then swizzle later
+            case OVERLAY: //  Channel overlay mode. Do rgb, and then swizzle later
                 channelHot[0] = 1;
                 channelHot[1] = 1;
                 channelHot[2] = 1;
                 channelHot[3] = 1;
                 break;
-            case 2: // RGB
+            case RGB:
                 channelHot[0] = 1;
                 channelHot[1] = 1;
                 channelHot[2] = 1;
                 channelHot[3] = 1;
                 break;
-            case 3: // R
+            case R:
                 channelHot[0] = 1;
                 break;
-            case 4: // G
+            case G:
                 channelHot[1] = 1;
                 break;
-            case 5: // B
+            case B:
                 channelHot[2] = 1;
                 break;
-            case 6: // A
+            case A:
                 channelHot[3] = 1;
                 break;
             default:

dbr avatar Jan 22 '15 23:01 dbr