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 
12 
13 /// Generic transformation node for hardware languages
15 {
16  public:
17  void createVariables(const ShaderNode& node, GenContext& context, Shader& shader) const override;
18  void emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const override;
19 
20  protected:
21  virtual const string& getMatrix(const string& fromSpace, const string& toSpace) const;
22  virtual const string& getModelToWorldMatrix() const = 0;
23  virtual const string& getWorldToModelMatrix() const = 0;
24  virtual string getHomogeneousCoordinate() const = 0;
25  virtual bool shouldNormalize() const { return false; }
26 
27  virtual string getFromSpace(const ShaderNode&) const;
28  virtual string getToSpace(const ShaderNode&) const;
29 
30  static const string FROM_SPACE;
31  static const string TO_SPACE;
32  static const string MODEL;
33  static const string OBJECT;
34  static const string WORLD;
35 };
36 
38 {
39  public:
40  static ShaderNodeImplPtr create();
41 
42  protected:
43  const string& getModelToWorldMatrix() const override { return HW::T_WORLD_MATRIX; }
44  const string& getWorldToModelMatrix() const override { return HW::T_WORLD_INVERSE_MATRIX; }
45  string getHomogeneousCoordinate() const override { return "0.0"; }
46 };
47 
49 {
50  public:
51  static ShaderNodeImplPtr create();
52 
53  protected:
54  string getHomogeneousCoordinate() const override { return "1.0"; }
55 };
56 
58 {
59  public:
60  static ShaderNodeImplPtr create();
61 
62  protected:
63  const string& getModelToWorldMatrix() const override { return HW::T_WORLD_INVERSE_TRANSPOSE_MATRIX; }
64  const string& getWorldToModelMatrix() const override { return HW::T_WORLD_TRANSPOSE_MATRIX; }
65  string getHomogeneousCoordinate() const override { return "0.0"; }
66  bool shouldNormalize() const override { return true; }
67 };
68 
70 
71 #endif
string getHomogeneousCoordinate() const override
static const string FROM_SPACE
static const string WORLD
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition: Library.h:40
MX_GENSHADER_API const string T_WORLD_TRANSPOSE_MATRIX
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
MX_GENSHADER_API const string T_WORLD_MATRIX
virtual bool shouldNormalize() const
string getHomogeneousCoordinate() const override
#define MX_GENSHADER_API
Definition: Export.h:18
const string & getWorldToModelMatrix() const override
static const string TO_SPACE
MX_GENSHADER_API const string T_WORLD_INVERSE_TRANSPOSE_MATRIX
const string & getModelToWorldMatrix() const override
MX_GENSHADER_API const string T_WORLD_INVERSE_MATRIX
const string & getModelToWorldMatrix() const override
bool shouldNormalize() const override
static const string OBJECT
GLuint shader
Definition: glcorearb.h:785
Definition: Shader.h:32
const string & getWorldToModelMatrix() const override
string getHomogeneousCoordinate() const override
static ShaderNodeImplPtr create()
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
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.