Writing an Imagepipeline Plugin

From LuxCoreRender Wiki
Revision as of 08:51, 2 December 2017 by Byob (talk | contribs) (Created page with " == C++ Code == Files that need to be created: * Header: include/slg/film/imagepipeline/plugins/yourpluginname.h * Source: src/slg/film/imagepipeline/plugins/yourpluginname.cp...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

C++ Code

Files that need to be created:

  • Header: include/slg/film/imagepipeline/plugins/yourpluginname.h
  • Source: src/slg/film/imagepipeline/plugins/yourpluginname.cpp

Files that need to be edited:

  • Filmparse: src/slg/film/filmparse.cpp
  • CMakeLists.txt: src/slg/CMakeLists.txt

Example: OverExposureDetection Plugin

As an exmaple for this tutorial, we'll write a plugin that sets the pixel color to red when it detects pixels which are brighter than a specified threshold. The threshold can be specified by the user in the .cfg file.

Header File

Create a new header file with filepath include/slg/film/imagepipeline/plugins/overexposuredetection.h


Modifying Filmparse

Open the file src/slg/film/filmparse.cpp and include your header file, right under the last include line and before the "using namespace x" lines.

#include "slg/film/imagepipeline/plugins/overexposuredetection.h"

In the same file, go to the function Film::AllocImagePipeline. You'll see a long if/else if/... section where the plugins are initialized. Add an else if clause at the end, before the final else: // ... } else if (type == "OVEREXPOSURE_DETECTION") { const float threshold = Clamp(props.Get(Property(prefix + ".threshold")(1000.f)).Get<float>(), 0.f, INFINITY); imagePipeline->AddPlugin(new OverExposureDetection(threshold)); } else // ...

OpenCL Code