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(TypeDesc type) const = 0;
32  [[deprecated]] bool acceptsInputType(const TypeDesc* type) const { return acceptsInputType(*type); }
33 
34  // Derived classes are responsible for computing offset strings relative to the center sample
35  // The sample size and offset type are passed in as arguments.
36  virtual void computeSampleOffsetStrings(const string& sampleSizeName, const string& offsetTypeString,
37  unsigned int filterWidth, StringVec& offsetStrings) const = 0;
38 
39  /// Get input which is used for sampling. If there is none
40  /// then a null pointer is returned.
41  virtual const ShaderInput* getSamplingInput(const ShaderNode& node) const;
42 
43  /// Generate upstream / input sampling code in uv space and cache the output variable names which
44  /// will hold the sample values after execution.
45  void emitInputSamplesUV(const ShaderNode& node,
46  unsigned int sampleCount, unsigned int filterWidth,
47  float filterSize, float filterOffset,
48  const string& sampleSizeFunctionUV,
49  GenContext& context, ShaderStage& stage,
50  StringVec& sampleStrings) const;
51 };
52 
54 
55 #endif
MX_GENSHADER_API const std::array< float, 7 > GAUSSIAN_KERNEL_7
MX_GENSHADER_API const std::array< float, 5 > GAUSSIAN_KERNEL_5
bool acceptsInputType(const TypeDesc *type) const
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
vector< string > StringVec
A vector of strings.
Definition: Library.h:60
#define MX_GENSHADER_API
Definition: Export.h:18
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
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