Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
constant_textures.h
Go to the documentation of this file.
1#pragma once
2
8
9#include <Common/assertion.h>
10
11#include <utility>
12
13namespace ph
14{
15
22template<typename OutputType>
23class TConstantTexture : public TTexture<OutputType>
24{
25public:
26 explicit TConstantTexture(OutputType value)
27 : TTexture<OutputType>()
28 , m_value(std::move(value))
29 {}
30
31 void sample(const SampleLocation& sampleLocation, OutputType* const out_value) const override
32 {
33 PH_ASSERT(out_value);
34
35 *out_value = m_value;
36 }
37
38private:
39 OutputType m_value;
40};
41
46template<math::EColorSpace COLOR_SPACE = math::EColorSpace::Linear_sRGB>
47class TConstantTristimulusTexture : public TTexture<math::Spectrum>
48{
49public:
51 : TTexture<math::Spectrum>()
52 , m_value(std::move(value))
53 {}
54
56 : TTexture<math::Spectrum>()
57 , m_value({value, value, value})
58 {}
59
60 void sample(const SampleLocation& sampleLocation, math::Spectrum* const out_value) const override
61 {
62 PH_ASSERT(out_value);
63
64 out_value->setTransformed<COLOR_SPACE>(m_value, sampleLocation.expectedUsage());
65 }
66
67private:
69};
70
75template<math::EColorSpace COLOR_SPACE = math::EColorSpace::Spectral>
76class TConstantSpectralTexture : public TTexture<math::Spectrum>
77{
78public:
80 : TTexture<math::Spectrum>()
81 , m_value(std::move(value))
82 {}
83
84 void sample(const SampleLocation& sampleLocation, math::Spectrum* const out_value) const override
85 {
86 PH_ASSERT(out_value);
87
88 out_value->setSpectral<COLOR_SPACE>(m_value, sampleLocation.expectedUsage());
89 }
90
91private:
93};
94
95}// end namespace ph
Definition SampleLocation.h:22
math::EColorUsage expectedUsage() const
Gets expected type of the usage for the sample.
Definition SampleLocation.h:123
A constant color texture that can adapt spectral values to spectrum. Converts spectral values to spec...
Definition constant_textures.h:77
TConstantSpectralTexture(math::SpectralSampleValues value)
Definition constant_textures.h:79
void sample(const SampleLocation &sampleLocation, math::Spectrum *const out_value) const override
Definition constant_textures.h:84
Texture storing one single constant of arbitrary type. This texture provides only a constant value....
Definition constant_textures.h:24
void sample(const SampleLocation &sampleLocation, OutputType *const out_value) const override
Definition constant_textures.h:31
TConstantTexture(OutputType value)
Definition constant_textures.h:26
A constant color texture that can adapt values in tristimulus color space to spectrum....
Definition constant_textures.h:48
void sample(const SampleLocation &sampleLocation, math::Spectrum *const out_value) const override
Definition constant_textures.h:60
TConstantTristimulusTexture(math::ColorValue value)
Definition constant_textures.h:55
TConstantTristimulusTexture(math::TristimulusValues value)
Definition constant_textures.h:50
Definition TTexture.h:12
Derived & setTransformed(const auto &srcColorValues, EColorUsage usage)
Derived & setSpectral(const TSpectralSampleValues< T > &sampleValues, EColorUsage usage)
Helper for setting spectral values to this spectrum.
Definition TTristimulusSpectrum.h:11
TSpectralSampleValues< ColorValue > SpectralSampleValues
Definition color_basics.h:60
real ColorValue
Definition color_basics.h:42
TTristimulusValues< ColorValue > TristimulusValues
Definition color_basics.h:59
The root for all renderer implementations.
Definition EEngineProject.h:6
Definition TAABB2D.h:96