Photon Engine
2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TSampler.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Core/Texture/TTexture.h
"
4
#include "
Core/SurfaceHit.h
"
5
#include "
Core/Texture/SampleLocation.h
"
6
#include "
Math/math_fwd.h
"
7
#include "
Math/Color/color_enums.h
"
8
9
#include <Common/primitive_type.h>
10
11
namespace
ph
12
{
13
16
template
<
typename
OutputType>
17
class
TSampler
final
18
{
19
public
:
20
TSampler
() :
21
TSampler
(math::
EColorUsage
::
Raw
)
22
{}
23
24
TSampler
(
const
math::EColorUsage
sampleUsage) :
25
TSampler
(sampleUsage, 0)
26
{}
27
28
TSampler
(
const
math::EColorUsage
sampleUsage,
const
uint32 sampledChannel) :
29
m_sampleUsage(sampleUsage), m_sampledChannel(sampledChannel)
30
{}
31
32
OutputType
sample
(
const
TTexture<OutputType>
& texture,
const
SurfaceHit
& X)
const
33
{
34
HitDetail
channeledDetail = X.
getDetail
();
35
if
(m_sampledChannel != 0)
36
{
37
channeledDetail = X.
switchChannel
(m_sampledChannel).
getDetail
();
38
}
39
40
OutputType value;
41
texture.
sample
(
SampleLocation
(channeledDetail, m_sampleUsage), &value);
42
return
value;
43
}
44
45
OutputType
sample
(
const
TTexture<OutputType>
& texture,
const
math::Vector3R
& uvw)
const
46
{
47
OutputType value;
48
texture.
sample
(
SampleLocation
(uvw, m_sampleUsage), &value);
49
return
value;
50
}
51
52
OutputType
sample
(
const
TTexture<OutputType>
& texture,
const
math::Vector2R
& uv)
const
53
{
54
OutputType value;
55
texture.
sample
(
SampleLocation
(uv, m_sampleUsage), &value);
56
return
value;
57
}
58
59
OutputType
sampleOrDefault
(
60
const
TTexture<OutputType>
* texture,
61
const
SurfaceHit
& X,
62
const
OutputType& defaultValue)
const
63
{
64
if
(texture)
65
{
66
return
sample
(*texture, X);
67
}
68
else
69
{
70
return
defaultValue;
71
}
72
}
73
74
private
:
75
math::EColorUsage
m_sampleUsage;
76
uint32 m_sampledChannel;
77
};
78
79
}
// end namespace ph
SampleLocation.h
SurfaceHit.h
TTexture.h
ph::HitDetail
Detailed information regarding a ray-primitive intersection.
Definition
HitDetail.h:26
ph::SampleLocation
Definition
SampleLocation.h:22
ph::SurfaceHit
General information about a ray-surface intersection event.
Definition
SurfaceHit.h:59
ph::SurfaceHit::getDetail
const HitDetail & getDetail() const
Definition
SurfaceHit.h:159
ph::SurfaceHit::switchChannel
SurfaceHit switchChannel(uint32 newChannel) const
Definition
SurfaceHit.cpp:28
ph::TSampler
Common settings and operations for sampling a texture.
Definition
TSampler.h:18
ph::TSampler::sample
OutputType sample(const TTexture< OutputType > &texture, const SurfaceHit &X) const
Definition
TSampler.h:32
ph::TSampler::TSampler
TSampler(const math::EColorUsage sampleUsage, const uint32 sampledChannel)
Definition
TSampler.h:28
ph::TSampler::sample
OutputType sample(const TTexture< OutputType > &texture, const math::Vector2R &uv) const
Definition
TSampler.h:52
ph::TSampler::sample
OutputType sample(const TTexture< OutputType > &texture, const math::Vector3R &uvw) const
Definition
TSampler.h:45
ph::TSampler::TSampler
TSampler()
Definition
TSampler.h:20
ph::TSampler::sampleOrDefault
OutputType sampleOrDefault(const TTexture< OutputType > *texture, const SurfaceHit &X, const OutputType &defaultValue) const
Definition
TSampler.h:59
ph::TSampler::TSampler
TSampler(const math::EColorUsage sampleUsage)
Definition
TSampler.h:24
ph::TTexture
Definition
TTexture.h:12
ph::TTexture::sample
virtual void sample(const SampleLocation &sampleLocation, Output *out_value) const =0
ph::math::TVector2< real >
ph::math::TVector3< real >
color_enums.h
math_fwd.h
ph::math::EColorUsage
EColorUsage
Definition
color_enums.h:140
ph::math::EColorUsage::Raw
@ Raw
ph
The root for all renderer implementations.
Definition
EEngineProject.h:6
Source
Core
Texture
TSampler.h
Generated by
1.11.0