RDK Linear Workflow

This document describes how to use the RDK linear workflow class in C/C++.

Introduction

Many consumer digital cameras output JPEG files which use the sRGB color space. This color space incorporates gamma correction which makes it possible to directly display the images on a computer monitor without even knowing that gamma correction exists. This means that many available photographic textures have already been gamma-corrected. Working with these images can give unsatisfactory results when intermediate processing and rendering works in a linear fashion. This problem can be avoided by using a Linear Workflow. This means that the gamma correction is removed from the images before they are used for rendering, and reapplied afterwards for display.

The Document Linear Workflow

The RDK Document Linear Workflow is a document-resident linear workflow object which affects renderings and viewports. If you have a Rhino document, you can read and write that document’s linear workflow settings through the document’s IRhRdkLinearWorkflow interface. Any changes you make will appear in the Rendering UI and will also be stored in the 3dm file. Getting the linear workflow from a document always returns a const reference. To write to the linear workflow, you must begin a batch of write operations and afterwards end the batch. This is done using the RDK’s standard BeginChange / EndChange system. The following is an example of how to access and change the document linear workflow settings:

static class CLinearWorkflowExampleCommand : public CRhinoTestCommand
{
protected:
	virtual UUID CommandUUID() override { static const UUID uuid = your_uuid_here; return uuid; }
	virtual const wchar_t* EnglishCommandName() override { return RHSTR_LIT(L"LinearWorkflowExample"); }
	virtual CRhinoCommand::result RunCommand(const CRhinoCommandContext& context) override;
}
theLinearWorkflowExampleCommand;

CRhinoCommand::result CLinearWorkflowExampleCommand::RunCommand(const CRhinoCommandContext& context)
{
	auto* pDoc = context.Document();
	if (nullptr == pDoc)
		return failure;

	const auto& lw = pDoc->LinearWorkflow();

	RhinoApp().Print(L"LW gamma before: %.1f\n", lw.PreProcessGamma());

	auto& write_lw = lw.BeginChange(RhRdkChangeContext::Program);
	write_lw.SetPreProcessGamma(3.5f);
	write_lw.EndChange();

	RhinoApp().Print(L"LW gamma after: %.1f\n", lw.PreProcessGamma());

	return success;
}