10#include <Common/assertion.h>
24template<
typename OperatorType,
typename InputTypeA,
typename InputTypeB,
typename InputTypeC,
typename OutputType>
25concept CTernaryOperator =
requires (OperatorType op, InputTypeA inputA, InputTypeB inputB, InputTypeC inputC)
27 { op(inputA, inputB, inputC) } -> std::same_as<OutputType>;
30template<
typename InputTypeA,
typename InputTypeB,
typename InputTypeC,
typename OutputType>
35 const InputTypeA& inputValueA,
36 const InputTypeB& inputValueB,
37 const InputTypeC& inputValueC)
const
39 constexpr bool canCallClampMethod =
requires (InputTypeA a, InputTypeB b, InputTypeC c)
41 { a.clamp(b, c) } -> std::convertible_to<OutputType>;
44 constexpr bool canCallMathClamp =
requires (InputTypeA a, InputTypeB b, InputTypeC c)
46 {
math::clamp(a, b, c) } -> std::convertible_to<OutputType>;
49 if constexpr(canCallClampMethod)
51 return inputValueA.clamp(inputValueB, inputValueC);
53 else if constexpr(canCallMathClamp)
55 return math::clamp(inputValueA, inputValueB, inputValueC);
59 PH_STATIC_ASSERT_DEPENDENT_FALSE(OutputType,
60 "Cannot perform clamp operation for the specified types.");
87 InputTexResC inputC)
requires std::default_initializable<OperatorType>
102 : m_inputA (
std::move(inputA))
103 , m_inputB (
std::move(inputB))
104 , m_inputC (
std::move(inputC))
105 , m_operator(
std::move(op))
113 PH_ASSERT(out_value);
115 InputTypeA inputValueA;
116 m_inputA->sample(sampleLocation, &inputValueA);
118 InputTypeB inputValueB;
119 m_inputB->sample(sampleLocation, &inputValueB);
121 InputTypeC inputValueC;
122 m_inputC->sample(sampleLocation, &inputValueC);
124 *out_value = m_operator(inputValueA, inputValueB, inputValueC);
131 OperatorType m_operator;
Definition SampleLocation.h:22
Definition ternary_texture_operators.h:78
TTernaryTextureOperator(InputTexResA inputA, InputTexResB inputB, InputTexResC inputC, OperatorType op)
Definition ternary_texture_operators.h:96
std::shared_ptr< TTexture< InputTypeC > > InputTexResC
Definition ternary_texture_operators.h:82
TTernaryTextureOperator(InputTexResA inputA, InputTexResB inputB, InputTexResC inputC)
Definition ternary_texture_operators.h:84
void sample(const SampleLocation &sampleLocation, OutputType *const out_value) const override
Definition ternary_texture_operators.h:108
std::shared_ptr< TTexture< InputTypeB > > InputTexResB
Definition ternary_texture_operators.h:81
std::shared_ptr< TTexture< InputTypeA > > InputTexResA
Definition ternary_texture_operators.h:80
Definition ternary_texture_operators.h:32
OutputType operator()(const InputTypeA &inputValueA, const InputTypeB &inputValueB, const InputTypeC &inputValueC) const
Definition ternary_texture_operators.h:34
Definition ternary_texture_operators.h:25
Miscellaneous math utilities.
T clamp(const T value, const T lowerBound, const T upperBound)
Clamps a value to [lowerBound, upperBound]. None of value, lowerBound and upperBound can be NaN,...
Definition math.h:77
The root for all renderer implementations.
Definition EEngineProject.h:6