ImfDeepCompositing.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Copyright (c) Weta Digital, Ltd and Contributors to the OpenEXR Project.
  4. //
  5. #ifndef INCLUDED_IMF_DEEPCOMPOSITING_H
  6. #define INCLUDED_IMF_DEEPCOMPOSITING_H
  7. //-----------------------------------------------------------------------------
  8. //
  9. // Class to sort and composite deep samples into a frame buffer
  10. // You may derive from this class to change the way that CompositeDeepScanLine
  11. // and CompositeDeepTile combine samples together - pass an instance of your derived
  12. // class to the compositing engine
  13. //
  14. //-----------------------------------------------------------------------------
  15. #include "ImfForward.h"
  16. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
  17. class IMF_EXPORT_TYPE DeepCompositing
  18. {
  19. public:
  20. IMF_EXPORT
  21. DeepCompositing();
  22. IMF_EXPORT
  23. virtual ~DeepCompositing();
  24. //////////////////////////////////////////////
  25. ///
  26. /// composite together the given channels
  27. ///
  28. /// @param outputs - return array of pixel values -
  29. /// @param inputs - arrays of input sample
  30. /// @param channel_names - array of channel names for corresponding channels
  31. /// @param num_channels - number of active channels (3 or greater)
  32. /// @param num_samples - number of values in all input arrays
  33. /// @param sources - number of different sources
  34. ///
  35. /// each array input has num_channels entries: outputs[n] should be the composited
  36. /// values in array inputs[n], whose name will be given by channel_names[n]
  37. ///
  38. /// The channel ordering shall be as follows:
  39. /// Position Channel
  40. /// 0 Z
  41. /// 1 ZBack (if no ZBack, then inputs[1]==inputs[0] and channel_names[1]==channel_names[0])
  42. /// 2 A (alpha channel)
  43. /// 3-n other channels - only channels in the frame buffer will appear here
  44. ///
  45. /// since a Z and Alpha channel is required, and channel[1] is ZBack or another copy of Z
  46. /// there will always be 3 or more channels.
  47. ///
  48. /// The default implementation calls sort() if and only if more than one source is active,
  49. /// composites all samples together using the Over operator from front to back,
  50. /// stopping as soon as a sample with alpha=1 is found
  51. /// It also blanks all outputs if num_samples==0
  52. ///
  53. /// note - multiple threads may call composite_pixel simultaneously for different pixels
  54. ///
  55. ///
  56. //////////////////////////////////////////////
  57. IMF_EXPORT
  58. virtual void composite_pixel(float outputs[],
  59. const float * inputs[],
  60. const char * channel_names[],
  61. int num_channels,
  62. int num_samples,
  63. int sources
  64. );
  65. ////////////////////////////////////////////////////////////////
  66. ///
  67. /// find the depth order for samples with given channel values
  68. /// does not sort the values in-place. Instead it populates
  69. /// array 'order' with the desired sorting order
  70. ///
  71. /// the default operation sorts samples from front to back according to their Z channel
  72. ///
  73. /// @param order - required output order. order[n] shall be the nth closest sample
  74. /// @param inputs - arrays of input samples, one array per channel_name
  75. /// @param channel_names - array of channel names for corresponding channels
  76. /// @param num_channels - number of channels (3 or greater)
  77. /// @param num_samples - number of samples in each array
  78. /// @param sources - number of different sources the data arises from
  79. ///
  80. /// the channel layout is identical to composite_pixel()
  81. ///
  82. ///////////////////////////////////////////////////////////////
  83. IMF_EXPORT
  84. virtual void sort(int order[],
  85. const float * inputs[],
  86. const char * channel_names[],
  87. int num_channels,
  88. int num_samples,
  89. int sources);
  90. };
  91. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  92. #endif