Repository navigation
Expand file tree
/
Copy pathtexture_node.h
More file actions
109 lines (91 loc) · 2.28 KB
/
Copy pathtexture_node.h
File metadata and controls
109 lines (91 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <cstddef>
#include "core/vector3.h"
#include "graphics/render_graph/node.h"
#include "graphics/sampler.h"
#include "graphics/texture.h"
#include "graphics/texture_usage.h"
namespace iris
{
class ShaderCompiler;
/**
* Enumeration of possible sources of UV data.
*/
enum class UVSource
{
/** Source from vertex data. */
VERTEX_DATA,
/** Source from screen space of fragment being rendered. */
SCREEN_SPACE,
/** Source from a node. */
NODE
};
/**
* Implementation of Node which provides access to a texture.
*/
class TextureNode : public Node
{
public:
/**
* Create a new TextureNode.
*
* @param texture
* Texture to provide access to.
*
* @param uv_source
* Source of UV data.
*
* @param uv_input
* Optional node to calculate uv, only valid if uv_source is NODE.
*/
TextureNode(const Texture *texture, UVSource uv_source = UVSource::VERTEX_DATA, const Node *uv_input = nullptr);
~TextureNode() override = default;
/**
* Accept a compiler visitor.
*
* @param compiler
* Compiler to accept.
*/
void accept(ShaderCompiler &compiler) const override;
/**
* Get texture.
*
* @returns
* Texture.
*/
const Texture *texture() const;
/**
* Get source of UV data.
*
* @returns
* UV data source.
*/
UVSource uv_source() const;
/**
* Get node for uv input.
*
* @returns
* Node if source is NODE, otherwise nullptr.
*/
const Node *uv_input() const;
/**
* Compute hash of node.
*
* @return
* Hash of node.
*/
std::size_t hash() const override;
private:
/** Texture. */
const Texture *texture_;
/** Source of UV data. */
UVSource uv_source_;
/** Optional node for uv. */
const Node *uv_input_;
};
}