MaterialX 1.39.1
Loading...
Searching...
No Matches
ConvolutionNode.h
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
13MATERIALX_NAMESPACE_BEGIN
14
15extern MX_GENSHADER_API const std::array<float, 3> GAUSSIAN_KERNEL_3;
16extern MX_GENSHADER_API const std::array<float, 5> GAUSSIAN_KERNEL_5;
17extern MX_GENSHADER_API const std::array<float, 7> GAUSSIAN_KERNEL_7;
18
21class MX_GENSHADER_API ConvolutionNode : public ShaderNodeImpl
22{
23 public:
24 void createVariables(const ShaderNode& node, GenContext& context, Shader& shader) const override;
25
26 protected:
29
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
41 virtual const ShaderInput* getSamplingInput(const ShaderNode& node) const;
42
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
53MATERIALX_NAMESPACE_END
54
55#endif
vector< string > StringVec
A vector of strings.
Definition: Library.h:55
Base class for shader node implementations.
Utility class for implementations of nodes which perform convolutions.
Definition: ConvolutionNode.h:22
void emitInputSamplesUV(const ShaderNode &node, unsigned int sampleCount, unsigned int filterWidth, float filterSize, float filterOffset, const string &sampleSizeFunctionUV, GenContext &context, ShaderStage &stage, StringVec &sampleStrings) const
Generate upstream / input sampling code in uv space and cache the output variable names which will ho...
ConvolutionNode()
Constructor.
virtual const ShaderInput * getSamplingInput(const ShaderNode &node) const
Get input which is used for sampling.
virtual bool acceptsInputType(TypeDesc type) const =0
Derived classes are responsible for returning if a given type is an acceptable input.
void createVariables(const ShaderNode &node, GenContext &context, Shader &shader) const override
Create shader variables needed for the implementation of this node (e.g.
A context class for shader generation.
Definition: GenContext.h:31
Class containing all data needed during shader generation.
Definition: Shader.h:33
An input on a ShaderNode.
Definition: ShaderNode.h:264
Class representing a node in the shader generation DAG.
Definition: ShaderNode.h:320
Class handling the shader generation implementation for a node.
Definition: ShaderNodeImpl.h:32
A shader stage, containing the state and resulting source code for the stage.
Definition: ShaderStage.h:139
A type descriptor for MaterialX data types.
Definition: TypeDesc.h:35