ImfDeepCompositing.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2012, Weta Digital Ltd
  4. //
  5. // All rights reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions are
  9. // met:
  10. // * Redistributions of source code must retain the above copyright
  11. // notice, this list of conditions and the following disclaimer.
  12. // * Redistributions in binary form must reproduce the above
  13. // copyright notice, this list of conditions and the following disclaimer
  14. // in the documentation and/or other materials provided with the
  15. // distribution.
  16. // * Neither the name of Weta Digital nor the names of
  17. // its contributors may be used to endorse or promote products derived
  18. // from this software without specific prior written permission.
  19. //
  20. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. //
  32. ///////////////////////////////////////////////////////////////////////////
  33. #ifndef INCLUDED_IMF_DEEPCOMPOSITING_H
  34. #define INCLUDED_IMF_DEEPCOMPOSITING_H
  35. //-----------------------------------------------------------------------------
  36. //
  37. // Class to sort and composite deep samples into a frame buffer
  38. // You may derive from this class to change the way that CompositeDeepScanLine
  39. // and CompositeDeepTile combine samples together - pass an instance of your derived
  40. // class to the compositing engine
  41. //
  42. //-----------------------------------------------------------------------------
  43. #include "ImfForward.h"
  44. #include "ImfNamespace.h"
  45. #include "ImfExport.h"
  46. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
  47. class DeepCompositing
  48. {
  49. public:
  50. IMF_EXPORT
  51. DeepCompositing();
  52. IMF_EXPORT
  53. virtual ~DeepCompositing();
  54. //////////////////////////////////////////////
  55. ///
  56. /// composite together the given channels
  57. ///
  58. /// @param outputs - return array of pixel values -
  59. /// @param inputs - arrays of input sample
  60. /// @param channel_names - array of channel names for corresponding channels
  61. /// @param num_channels - number of active channels (3 or greater)
  62. /// @param num_samples - number of values in all input arrays
  63. /// @param sources - number of different sources
  64. ///
  65. /// each array input has num_channels entries: outputs[n] should be the composited
  66. /// values in array inputs[n], whose name will be given by channel_names[n]
  67. ///
  68. /// The channel ordering shall be as follows:
  69. /// Position Channel
  70. /// 0 Z
  71. /// 1 ZBack (if no ZBack, then inputs[1]==inputs[0] and channel_names[1]==channel_names[0])
  72. /// 2 A (alpha channel)
  73. /// 3-n other channels - only channels in the frame buffer will appear here
  74. ///
  75. /// since a Z and Alpha channel is required, and channel[1] is ZBack or another copy of Z
  76. /// there will always be 3 or more channels.
  77. ///
  78. /// The default implementation calls sort() if and only if more than one source is active,
  79. /// composites all samples together using the Over operator from front to back,
  80. /// stopping as soon as a sample with alpha=1 is found
  81. /// It also blanks all outputs if num_samples==0
  82. ///
  83. /// note - multiple threads may call composite_pixel simultaneously for different pixels
  84. ///
  85. ///
  86. //////////////////////////////////////////////
  87. IMF_EXPORT
  88. virtual void composite_pixel(float outputs[],
  89. const float * inputs[],
  90. const char * channel_names[],
  91. int num_channels,
  92. int num_samples,
  93. int sources
  94. );
  95. ////////////////////////////////////////////////////////////////
  96. ///
  97. /// find the depth order for samples with given channel values
  98. /// does not sort the values in-place. Instead it populates
  99. /// array 'order' with the desired sorting order
  100. ///
  101. /// the default operation sorts samples from front to back according to their Z channel
  102. ///
  103. /// @param order - required output order. order[n] shall be the nth closest sample
  104. /// @param inputs - arrays of input samples, one array per channel_name
  105. /// @param channel_names - array of channel names for corresponding channels
  106. /// @param num_channels - number of channels (3 or greater)
  107. /// @param num_samples - number of samples in each array
  108. /// @param sources - number of different sources the data arises from
  109. ///
  110. /// the channel layout is identical to composite_pixel()
  111. ///
  112. ///////////////////////////////////////////////////////////////
  113. IMF_EXPORT
  114. virtual void sort(int order[],
  115. const float * inputs[],
  116. const char * channel_names[],
  117. int num_channels,
  118. int num_samples,
  119. int sources);
  120. };
  121. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  122. #endif