Skip to content
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

OCIO base support #840

Conversation

bernardkwok
Copy link
Contributor

No description provided.

@@ -87,4 +115,105 @@ ShaderNodePtr ColorManagementSystem::createNode(const ShaderGraph* parent, const
return shaderNode;
}

} // namespace MaterialX

Copy link
Contributor

Choose a reason for hiding this comment

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

Pulled out from ShaderGraph code into CM system where these utilities should belong.
They allow for insert on CM transforms on inputs and outputs. If need be a conversion from color3 to color4
can be performed as well as OCIO requires color4.

@@ -24,6 +24,58 @@ class ShaderGenerator;
/// A shared pointer to a ColorManagementSystem
using ColorManagementSystemPtr = shared_ptr<class ColorManagementSystem>;

/// Set of mappings between a uniform name and it's associated value
Copy link
Contributor

Choose a reason for hiding this comment

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

Structures to hold the interface for a transform which may be uniform constants or textures.

const size_t OCIO_RESOURCEMAP_SIZE = size_t(ColorManagementSystem::ResourceType::TEXTURE3D) + 1;

// OCIO related information
class OCIOInformation
Copy link
Contributor

Choose a reason for hiding this comment

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

Structure to keep track of OCIO specific information.

ColorManagementResourceMapPtr resourceMap[OCIO_RESOURCEMAP_SIZE];
};

void OCIOInformation::updateUniformResources(OCIO::GpuShaderDescRcPtr shaderDesc)
Copy link
Contributor

Choose a reason for hiding this comment

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

Convert OCIO specific non-texture information into a list of color management resources.

}
}

void OCIOInformation::updateTextureResources(OCIO::GpuShaderDescRcPtr shaderDesc)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the same to map OCIO texture resource information

glActiveTexture(GL_TEXTURE0 + textureUnit);
glBindTexture(GL_TEXTURE_2D, image->getResourceId());
glBindTexture(targetType, image->getResourceId());
Copy link
Contributor

Choose a reason for hiding this comment

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

Generalize code to be able to specify more than 1D textures.

}

// Handle non-texture uniforms
ColorManagementResourceMapPtr uniformItems = cms->getResource(ColorManagementSystem::ResourceType::UNIFORM);
Copy link
Contributor

Choose a reason for hiding this comment

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

Resources cached when OCIO transforms are created are bound here.

ImagePtr uniformImage = imageHandler->getImage(uniformName);
if (!uniformImage)
{
uniformImage = imageHandler->createImage(uniformName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Textures (LUT) are dynamically created.

- The OCIO library can be used during code generation instead of the default system provided the following is set up:
- The MATERIALX_BUILD_OCIO build option is set to be ON.
- The MATERIALX_OCIO_DIR build option is set to point to the root of the OCIO installation.
- For unit tests: A valid OCIO configuration file is specified for the `colorManagementConfigFile` option in the `_options.mtlx` options file.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can set a config file to use in options file.

@@ -33,7 +33,10 @@ const std::string options =
" --remap [TOKEN1:TOKEN2] Specify the remapping from one token to another when MaterialX document is loaded\n"
" --skip [NAME] Specify to skip elements matching the given name attribute\n"
" --terminator [STRING] Specify to enforce the given terminator string for file prefixes\n"
" --help Display the complete list of command-line options\n";
#ifdef MATERIALX_BUILD_OCIO
" --ocioConfigFile [STRING] Specify a OCIO configuration file to use for color management.\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can set a config file to use for the viewer.

@bernardkwok
Copy link
Contributor Author

Will proceed with just some updates and no OCIO at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants