62 PH_ASSERT(m_beginTexture);
63 PH_ASSERT(m_beginTexture.get() !=
this);
64 PH_ASSERT(m_endTexture);
65 PH_ASSERT(m_endTexture.get() !=
this);
67 const auto baseVec = m_endUVW - m_beginUVW;
68 const real baseLength = baseVec.length();
69 const real rcpBaseLength = 1.0_r / baseLength;
70 const auto baseAxis = baseVec * rcpBaseLength;
71 const auto sampleVec = sampleLocation.
uvw() - m_beginUVW;
72 const real sampleLength = sampleVec.
dot(baseAxis);
76 const real beginRatio = (baseLength - sampleLength) * rcpBaseLength;
77 const real endRatio = sampleLength * rcpBaseLength;
79 OutputType beginValue, endValue;
80 m_beginTexture->sample(sampleLocation, &beginValue);
81 m_endTexture->sample(sampleLocation, &endValue);
83 *out_value = beginValue * beginRatio + endValue * endRatio;
math::Vector3R uvw() const
Gets and sets the uvw coordinates of this sample location.
Definition SampleLocation.h:90
Definition TLinearGradientTexture.h:16
void sample(const SampleLocation &sampleLocation, OutputType *out_value) const override
Definition TLinearGradientTexture.ipp:59
TLinearGradientTexture(real beginU, const std::shared_ptr< TTexture< OutputType > > &beginTexture, real endU, const std::shared_ptr< TTexture< OutputType > > &endTexture)
Definition TLinearGradientTexture.ipp:12