Linear Workflow and Color returned from Shader



  • On 29/10/2015 at 10:44, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:    
    Platform:      
    Language(s) :

    ---------
    Hi! In my shader, I'm reading a color user data field and return that color from Output(). The problem
    is that this color looks different than what the color would look like if I used it directly in a Color shader
    or the Color field of the Material channel. However, this is only when Linear Workflow is enabled.

    I've only found this topic and I tried calling InitRenderStruct::TransformColor() before I return the
    color from ShaderData::Output(), but it did not change the result at all.

    return this->_irs->TransformColor(resultColor);
    

    I don't know how to fix this, any ideas? Thanks in advance.
    -N



  • On 29/10/2015 at 11:06, xxxxxxxx wrote:

    Maybe the InitRenderStruct is not valid from InitRender() to FreeRender(). I saved the pointer to the
    IRS passed to ShaderData::InitRender(). Now that I store a copy of the IRS, it works fine.

    INITRENDERRESULT Shader::InitRender(BaseShader* shader, const InitRenderStruct& irs) {
      this->_irs = irs;
      // ...
    }
      
    Vector Shader::Output(BaseShader* shader, ChannelData* cd) {
      // ..
      return this->_irs.TransformColor(color);
    }
    


  • On 30/10/2015 at 03:09, xxxxxxxx wrote:

    Hello,

    a typical pattern to handle linear workflow is to save the transformation type in InitRender() and apply it in Output() using TransformColor(). Something like this:

      
    // save color transformation information  
      
    if (irs.linear_workflow && irs.document_colorprofile == DOCUMENT_COLORPROFILE_SRGB)  
     _trans = COLORSPACETRANSFORMATION_SRGB_TO_LINEAR;  
    else  
     _trans = COLORSPACETRANSFORMATION_NONE;  
       
        
    // ...  
      
    // apply color transformation  
    return TransformColor(result, _trans);  
    

    best wishes,
    Sebastian


Log in to reply