Mitsuba Renderer
0.5.0
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
texture.h
Go to the documentation of this file.
1
/*
2
This file is part of Mitsuba, a physically based rendering system.
3
4
Copyright (c) 2007-2014 by Wenzel Jakob and others.
5
6
Mitsuba is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License Version 3
8
as published by the Free Software Foundation.
9
10
Mitsuba is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#pragma once
20
#if !defined(__MITSUBA_RENDER_TEXTURE_H_)
21
#define __MITSUBA_RENDER_TEXTURE_H_
22
23
#include <
mitsuba/core/cobject.h
>
24
#include <
mitsuba/core/properties.h
>
25
#include <
mitsuba/render/shader.h
>
26
27
MTS_NAMESPACE_BEGIN
28
29
/**
30
* \brief Base class of all textures. Computes values for an arbitrary surface
31
* point. \ref Texture2D is a specialization to UV-based textures.
32
* \ingroup librender
33
*/
34
class
MTS_EXPORT_RENDER
Texture
:
public
ConfigurableObject
,
public
HWResource
{
35
public
:
36
/**
37
* \brief Return the texture value at \c its
38
* \param filter
39
* Specifies whether a filtered texture lookup is desired. Note
40
* that this does not mean that filtering will actually be used.
41
*/
42
virtual
Spectrum
eval(
const
Intersection
&its,
bool
filter =
true
)
const
;
43
44
/**
45
* \brief Return the texture gradient at \c its
46
*
47
* The parameter \c gradient should point to an array with space for
48
* two \ref Spectrum data structures corresponding to the U and V derivative.
49
*
50
* \remark This function is usually implemented pointwise without any kind of filtering.
51
* The Python signature is <tt>dx, dy = tex.evalGradient(its)</tt>.
52
*/
53
virtual
void
evalGradient(
const
Intersection
&its,
Spectrum
*gradient)
const
;
54
55
/// Return the component-wise average value of the texture over its domain
56
virtual
Spectrum
getAverage()
const
;
57
58
/// Return the component-wise minimum of the texture over its domain
59
virtual
Spectrum
getMinimum()
const
;
60
61
/// Return the component-wise maximum of the texture over its domain
62
virtual
Spectrum
getMaximum()
const
;
63
64
/// Return the resolution in pixels, if applicable
65
virtual
Vector3i
getResolution()
const
;
66
67
/// Return whether the texture takes on a constant value everywhere
68
virtual
bool
isConstant()
const
;
69
70
/**
71
* \brief Return whether the texture is monochromatic / spectrally uniform
72
*
73
* The implementation may conservatively return \c false if it is not sure.
74
*/
75
virtual
bool
isMonochromatic()
const
;
76
77
/**
78
* \brief Does this texture perform any pre-filtering when
79
* ray differentials are available?
80
*/
81
virtual
bool
usesRayDifferentials()
const
;
82
83
/**
84
* \brief Some textures are only proxies for an actual
85
* implementation. This function returns the actual
86
* texture implementation to be used.
87
*
88
* The default implementation returns <tt>this</tt>.
89
*/
90
virtual
ref<Texture>
expand();
91
92
/// Serialize to a binary data stream
93
virtual
void
serialize
(
Stream
*stream,
InstanceManager
*manager)
const
;
94
95
/**
96
* \brief Return a bitmap representation of the texture
97
*
98
* When the class implementing this interface is a bitmap-backed texture,
99
* this function directly returns the underlying bitmap. When it is procedural,
100
* a bitmap version must first be generated. In this case, the parameter
101
* \ref sizeHint is used to control the target size. The default
102
* value <tt>-1, -1</tt> allows the implementation to choose a suitable
103
* size by itself.
104
*/
105
virtual
ref<Bitmap>
getBitmap(
const
Vector2i
&sizeHint =
Vector2i
(-1, -1))
const
;
106
107
MTS_DECLARE_CLASS
()
108
protected:
109
Texture
(const
Properties
&props);
110
Texture
(
Stream
*stream,
InstanceManager
*manager);
111
112
virtual ~
Texture
();
113
};
114
115
/**
116
* \brief Base class of all 2D textures
117
* \ingroup librender
118
*/
119
class
MTS_EXPORT_RENDER
Texture2D
: public Texture {
120
public
:
121
/**
122
* \brief Return the texture value at \c its
123
* \param filter
124
* Specifies whether a filtered texture lookup is desired. Note
125
* that this does not mean that filtering will actually be used.
126
*/
127
Spectrum
eval(
const
Intersection
&its,
bool
filter =
true
)
const
;
128
129
/**
130
* \brief Return the texture gradient at \c its
131
*
132
* The parameter \c gradient should point to an array with space for
133
* two \ref Spectrum data structures corresponding to the U and V derivative.
134
*
135
* \remark This function is usually implemented pointwise without any kind of filtering.
136
*/
137
void
evalGradient(
const
Intersection
&its,
Spectrum
*gradient)
const
;
138
139
/// Serialize to a binary data stream
140
virtual
void
serialize
(
Stream
*stream,
InstanceManager
*manager)
const
;
141
142
/// Unfiltered texture lookup -- Texture2D subclasses must provide this function
143
virtual
Spectrum
eval(
const
Point2
&uv)
const
= 0;
144
145
/// Filtered texture lookup -- Texture2D subclasses must provide this function
146
virtual
Spectrum
eval(
const
Point2
&uv,
const
Vector2
&d0,
147
const
Vector2
&d1)
const
= 0;
148
149
/// Unfiltered radient lookup lookup -- Texture2D subclasses can optionally provide this function
150
virtual
void
evalGradient(
const
Point2
&uv,
Spectrum
*gradient)
const
;
151
152
/**
153
* \brief Return a bitmap representation of the texture
154
*
155
* When the class implementing this interface is a bitmap-backed texture,
156
* this function directly returns the underlying bitmap. When it is procedural,
157
* a bitmap version must first be generated. In this case, the parameter
158
* \ref sizeHint is used to control the target size. The default
159
* value <tt>-1, -1</tt> allows the implementation to choose a suitable
160
* size by itself.
161
*/
162
virtual
ref<Bitmap>
getBitmap(
const
Vector2i
&sizeHint =
Vector2i
(-1, -1))
const
;
163
164
MTS_DECLARE_CLASS
()
165
protected:
166
Texture2D
(const
Properties
&props);
167
Texture2D
(
Stream
*stream,
InstanceManager
*manager);
168
169
virtual ~
Texture2D
();
170
protected:
171
Point2
m_uvOffset;
172
Vector2
m_uvScale;
173
};
174
175
MTS_NAMESPACE_END
176
177
#endif
/* __MITSUBA_RENDER_TEXTURE_H_ */
Vector2i
TVector2< int > Vector2i
Definition:
fwd.h:108
cobject.h
mitsuba::ConfigurableObject
Generic serializable object, which supports construction from a Properties instance.
Definition:
cobject.h:40
mitsuba::Texture
Base class of all textures. Computes values for an arbitrary surface point. Texture2D is a specializa...
Definition:
texture.h:34
mitsuba::HWResource
Abstract hardware resource.
Definition:
shader.h:39
MTS_NAMESPACE_BEGIN
#define MTS_NAMESPACE_BEGIN
Definition:
platform.h:137
shader.h
mitsuba::ConfigurableObject::serialize
virtual void serialize(Stream *stream, InstanceManager *manager) const
Serialize this object to a binary data stream.
mitsuba::Stream
Abstract seekable stream class.
Definition:
stream.h:58
MTS_DECLARE_CLASS
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition:
class.h:158
TPoint2
Definition:
fwd.h:99
ref
Reference counting helper.
Definition:
ref.h:40
properties.h
TVector3
Definition:
fwd.h:96
mitsuba::Properties
Associative parameter map for constructing subclasses of ConfigurableObject.
Definition:
properties.h:46
mitsuba::Intersection
Container for all information related to a surface intersection.
Definition:
shape.h:36
mitsuba::InstanceManager
Coordinates the serialization and unserialization of object graphs.
Definition:
serialization.h:65
MTS_EXPORT_RENDER
#define MTS_EXPORT_RENDER
Definition:
platform.h:109
mitsuba::Texture2D
Base class of all 2D textures.
Definition:
texture.h:119
mitsuba::Spectrum
Discrete spectral power distribution based on a number of wavelength bins over the 360-830 nm range...
Definition:
spectrum.h:663
TVector2
Definition:
fwd.h:95
MTS_NAMESPACE_END
#define MTS_NAMESPACE_END
Definition:
platform.h:138
include
mitsuba
render
texture.h
Generated on Thu Nov 21 2024 06:25:04 for Mitsuba Renderer by
1.8.5