HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConvolutionNode.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_CONVOLUTIONNODE_H
7 #define MATERIALX_CONVOLUTIONNODE_H
8 
10 
11 #include <array>
12 
14 
15 extern MX_GENSHADER_API const std::array<float, 3> GAUSSIAN_KERNEL_3;
16 extern MX_GENSHADER_API const std::array<float, 5> GAUSSIAN_KERNEL_5;
17 extern MX_GENSHADER_API const std::array<float, 7> GAUSSIAN_KERNEL_7;
18 
19 /// Utility class for implementations of nodes which perform convolutions
20 ///
22 {
23  public:
24  void createVariables(const ShaderNode& node, GenContext& context, Shader& shader) const override;
25 
26  protected:
27  /// Constructor
29 
30  /// Derived classes are responsible for returning if a given type is an acceptable input.
31  virtual bool acceptsInputType(const TypeDesc* type) const = 0;
32 
33  // Derived classes are responsible for computing offset strings relative to the center sample
34  // The sample size and offset type are passed in as arguments.
35  virtual void computeSampleOffsetStrings(const string& sampleSizeName, const string& offsetTypeString,
36  unsigned int filterWidth, StringVec& offsetStrings) const = 0;
37 
38  /// Get input which is used for sampling. If there is none
39  /// then a null pointer is returned.
40  virtual const ShaderInput* getSamplingInput(const ShaderNode& node) const;
41 
42  /// Generate upstream / input sampling code in uv space and cache the output variable names which
43  /// will hold the sample values after execution.
44  void emitInputSamplesUV(const ShaderNode& node,
45  unsigned int sampleCount, unsigned int filterWidth,
46  float filterSize, float filterOffset,
47  const string& sampleSizeFunctionUV,
48  GenContext& context, ShaderStage& stage,
49  StringVec& sampleStrings) const;
50 };
51 
53 
54 #endif
MX_GENSHADER_API const std::array< float, 7 > GAUSSIAN_KERNEL_7
MX_GENSHADER_API const std::array< float, 5 > GAUSSIAN_KERNEL_5
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
vector< string > StringVec
A vector of strings.
Definition: Library.h:57
#define MX_GENSHADER_API
Definition: Export.h:18
int & sampleCount(char *base, int xStride, int yStride, int x, int y)
Definition: ImfMisc.h:62
GLuint shader
Definition: glcorearb.h:785
Definition: Shader.h:32
MATERIALX_NAMESPACE_BEGIN MX_GENSHADER_API const std::array< float, 3 > GAUSSIAN_KERNEL_3
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
virtual void createVariables(const ShaderNode &node, GenContext &context, Shader &shader) const
type
Definition: core.h:1059