HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HwTransformNode.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_HWTRANSFORMNODE_H
7 #define MATERIALX_HWTRANSFORMNODE_H
8 
10 
13 
15 
16 /// Generic transformation node for hardware languages
18 {
19  public:
20  void createVariables(const ShaderNode& node, GenContext& context, Shader& shader) const override;
21  void emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const override;
22 
23  protected:
24  virtual const string& getMatrix(const string& fromSpace, const string& toSpace) const;
25  virtual const string& getModelToWorldMatrix() const = 0;
26  virtual const string& getWorldToModelMatrix() const = 0;
27  virtual string getHomogeneousCoordinate() const = 0;
28  virtual bool shouldNormalize() const { return false; }
29 
30  virtual string getFromSpace(const ShaderNode&) const;
31  virtual string getToSpace(const ShaderNode&) const;
32 
33  static const string FROM_SPACE;
34  static const string TO_SPACE;
35  static const string MODEL;
36  static const string OBJECT;
37  static const string WORLD;
38 };
39 
40 /// Vector transform implementation for hardware languages
42 {
43  public:
44  static ShaderNodeImplPtr create();
45 
46  protected:
47  const string& getModelToWorldMatrix() const override { return HW::T_WORLD_MATRIX; }
48  const string& getWorldToModelMatrix() const override { return HW::T_WORLD_INVERSE_MATRIX; }
49  string getHomogeneousCoordinate() const override { return "0.0"; }
50 };
51 
52 /// Point transform implementation for hardware languages
54 {
55  public:
56  static ShaderNodeImplPtr create();
57 
58  protected:
59  string getHomogeneousCoordinate() const override { return "1.0"; }
60 };
61 
62 /// Normal transform implementation for hardware languages
64 {
65  public:
66  static ShaderNodeImplPtr create();
67 
68  protected:
69  const string& getModelToWorldMatrix() const override { return HW::T_WORLD_INVERSE_TRANSPOSE_MATRIX; }
70  const string& getWorldToModelMatrix() const override { return HW::T_WORLD_TRANSPOSE_MATRIX; }
71  string getHomogeneousCoordinate() const override { return "0.0"; }
72  bool shouldNormalize() const override { return true; }
73 };
74 
76 
77 #endif
string getHomogeneousCoordinate() const override
Point transform implementation for hardware languages.
static const string FROM_SPACE
static const string WORLD
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition: Library.h:39
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
MX_GENHW_API const string T_WORLD_INVERSE_MATRIX
virtual bool shouldNormalize() const
string getHomogeneousCoordinate() const override
MX_GENHW_API const string T_WORLD_INVERSE_TRANSPOSE_MATRIX
const string & getWorldToModelMatrix() const override
Normal transform implementation for hardware languages.
static const string TO_SPACE
MX_GENHW_API const string T_WORLD_TRANSPOSE_MATRIX
const string & getModelToWorldMatrix() const override
const string & getModelToWorldMatrix() const override
bool shouldNormalize() const override
Vector transform implementation for hardware languages.
static const string OBJECT
GLuint shader
Definition: glcorearb.h:785
MX_GENHW_API const string T_WORLD_MATRIX
Definition: Shader.h:32
const string & getWorldToModelMatrix() const override
string getHomogeneousCoordinate() const override
static ShaderNodeImplPtr create()
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
#define MX_GENHW_API
Definition: Export.h:18
static const string MODEL
virtual void createVariables(const ShaderNode &node, GenContext &context, Shader &shader) const
virtual void emitFunctionCall(const ShaderNode &node, GenContext &context, ShaderStage &stage) const
Emit the function call or inline source code for given node instance in the given context...
Generic transformation node for hardware languages.