5#include <Common/assertion.h>
6#include <Common/logging.h>
13template<
typename OutputType>
17 const OutputType& oddValue,
const OutputType& evenValue) :
25template<
typename OutputType>
32 if(numUtiles <= 0.0f || numVtiles <= 0.0f)
34 PH_DEFAULT_LOG(Warning,
35 "at TCheckerboardTexture's ctor, number of tiles <= 0 (numUtiles = {}, numVtiles = {})",
36 numUtiles, numVtiles);
39 setOddTexture(oddTexture);
40 setEvenTexture(evenTexture);
45 m_uTileSize = 1.0f / numUtiles;
46 m_vTileSize = 1.0f / numVtiles;
49template<
typename OutputType>
51 const SampleLocation& sampleLocation, OutputType*
const out_value)
const
53 PH_ASSERT(m_oddTexture && m_oddTexture.get() !=
this);
54 PH_ASSERT(m_evenTexture && m_evenTexture.get() !=
this);
57 const int32 uNumber =
static_cast<int32
>(std::floor(uvw.
x() / m_uTileSize));
58 const int32 vNumber =
static_cast<int32
>(std::floor(uvw.
y() / m_vTileSize));
60 if(std::abs(uNumber % 2) != std::abs(vNumber % 2))
62 m_oddTexture->sample(sampleLocation.
getUvwScaled(m_oddUvwScale),
67 m_evenTexture->sample(sampleLocation.
getUvwScaled(m_evenUvwScale),
72template<
typename OutputType>
76 if(!oddTexture || oddTexture.get() ==
this)
78 PH_DEFAULT_LOG(Warning,
79 "at TCheckerboardTexture::setOddTexture(), does not allow empty or self-referencing tile");
83 m_oddTexture = oddTexture;
86template<
typename OutputType>
90 if(!evenTexture || evenTexture.get() ==
this)
92 PH_DEFAULT_LOG(Warning,
93 "at TCheckerboardTexture::setEvenTexture(), does not allow empty or self-referencing tile");
97 m_evenTexture = evenTexture;
105template<
typename OutputType>
108 m_oddUvwScale = scale.
rcp();
111template<
typename OutputType>
114 m_evenUvwScale = scale.
rcp();
Definition SampleLocation.h:22
math::Vector3R uvw() const
Gets and sets the uvw coordinates of this sample location.
Definition SampleLocation.h:90
SampleLocation getUvwScaled(const math::Vector3R &scale) const
Definition SampleLocation.h:116
Texture representing checker patterns.
Definition TCheckerboardTexture.h:28
void sample(const SampleLocation &sampleLocation, OutputType *out_value) const override
Definition TCheckerboardTexture.ipp:50
TCheckerboardTexture(real numUtiles, real numVtiles, const OutputType &oddValue, const OutputType &evenValue)
Definition TCheckerboardTexture.ipp:14
void setEvenTextureScale(const math::Vector3R &scale)
Definition TCheckerboardTexture.ipp:112
void setOddTexture(const std::shared_ptr< TTexture< OutputType > > &oddTexture)
Sets the texture that is going to be used in odd cells.
Definition TCheckerboardTexture.ipp:73
void setOddTextureScale(const math::Vector3R &sale)
Sets the scale factors of cell texture. Larger u-, v- and w-scale makes texture appears to be larger ...
Definition TCheckerboardTexture.ipp:106
void setEvenTexture(const std::shared_ptr< TTexture< OutputType > > &evenTexture)
Sets the texture that is going to be used in even cells.
Definition TCheckerboardTexture.ipp:87
Texture storing one single constant of arbitrary type. This texture provides only a constant value....
Definition constant_textures.h:24
T & y()
Definition TVector3.ipp:189
T & x()
Definition TVector3.ipp:183
Derived rcp() const
Definition TArithmeticArrayBase.ipp:484
The root for all renderer implementations.
Definition EEngineProject.h:6