11#include <Common/assertion.h>
26template<
typename OperatorType,
typename InputType,
typename OutputType>
29 { op(input) } -> std::same_as<OutputType>;
34template<
typename InputType,
typename OutputType>
41 "`OutputType` must be buildable from `InputType`");
43 return OutputType(inputValue);
60 return (*
this)(scalarValue[0]);
65 return (*
this)(scalarValue[0]);
69template<
typename InputType,
typename OutputType>
75 constexpr bool canCallAbsMethod =
requires (InputType input)
77 { input.abs() } -> std::convertible_to<OutputType>;
80 constexpr bool canCallStdAbs =
requires (InputType input)
82 { std::abs(input) } -> std::convertible_to<OutputType>;
85 if constexpr(canCallAbsMethod)
87 return inputValue.abs();
89 else if constexpr(canCallStdAbs)
91 return std::abs(inputValue);
95 PH_STATIC_ASSERT_DEPENDENT_FALSE(OutputType,
96 "Cannot perform absolute operation for the specified types.");
106 typename ConstantType,
108 CBinaryOperator<InputType, ConstantType, OutputType> BinaryOperatorType
114 : m_constant(
std::move(constant))
119 static_assert(std::default_initializable<BinaryOperatorType>);
121 return BinaryOperatorType{}(inputValue, m_constant);
125 ConstantType m_constant;
133 typename ConstantTypeA,
134 typename ConstantTypeB,
136 CTernaryOperator<InputType, ConstantTypeA, ConstantTypeB, OutputType> TernaryOperatorType
142 : m_constantA(
std::move(constantA))
143 , m_constantB(
std::move(constantB))
148 static_assert(std::default_initializable<TernaryOperatorType>);
150 return TernaryOperatorType{}(inputValue, m_constantA, m_constantB);
154 ConstantTypeA m_constantA;
155 ConstantTypeB m_constantB;
158template<
typename InputType,
typename ConstantType,
typename OutputType>
165template<
typename InputType,
typename ConstantType,
typename OutputType>
172template<
typename InputType,
typename ConstantType,
typename OutputType>
179template<
typename InputType,
typename ConstantType,
typename OutputType>
186template<
typename InputType,
typename ConstantType,
typename OutputType>
193template<
typename InputType,
typename ConstantTypeA,
typename ConstantTypeB,
typename OutputType>
225 m_inputTexture(
std::move(inputTexture)),
226 m_operator (
std::move(op))
231 PH_ASSERT(m_inputTexture);
232 PH_ASSERT(out_value);
234 InputType inputValue;
235 m_inputTexture->sample(sampleLocation, &inputValue);
237 *out_value = m_operator(inputValue);
242 OperatorType m_operator;
245template<
typename InputType,
typename OutputType>
Definition SampleLocation.h:22
Definition unary_texture_operators.h:216
TUnaryTextureOperator(InputTexRes inputTexture, OperatorType op)
Definition unary_texture_operators.h:224
TUnaryTextureOperator(InputTexRes inputTexture)
Definition unary_texture_operators.h:220
void sample(const SampleLocation &sampleLocation, OutputType *const out_value) const override
Definition unary_texture_operators.h:229
std::shared_ptr< TTexture< InputType > > InputTexRes
Definition unary_texture_operators.h:218
Definition TArithmeticArray.h:13
Definition TTristimulusSpectrum.h:11
Definition unary_texture_operators.h:71
OutputType operator()(const InputType &inputValue) const
Definition unary_texture_operators.h:73
Definition binary_texture_operators.h:33
Definition ternary_texture_operators.h:32
Constructs output value from input value.
Definition unary_texture_operators.h:36
OutputType operator()(const InputType &inputValue) const
Definition unary_texture_operators.h:38
Definition binary_texture_operators.h:72
Definition binary_texture_operators.h:59
Definition binary_texture_operators.h:85
Converts a scalar value to spectrum.
Definition unary_texture_operators.h:51
math::Spectrum operator()(const T scalarValue) const
Definition unary_texture_operators.h:53
Definition binary_texture_operators.h:46
Uses binary operator as a unary one by treating the second input as constant.
Definition unary_texture_operators.h:111
OutputType operator()(const InputType &inputValue) const
Definition unary_texture_operators.h:117
TUnaryFromBinary(ConstantType constant)
Definition unary_texture_operators.h:113
Uses ternary operator as a unary one by treating the second and third inputs as constants.
Definition unary_texture_operators.h:139
OutputType operator()(const InputType &inputValue) const
Definition unary_texture_operators.h:146
TUnaryFromTernary(ConstantTypeA constantA, ConstantTypeB constantB)
Definition unary_texture_operators.h:141
Definition unary_texture_operators.h:27
LinearSRGBSpectrum Spectrum
Definition spectrum_fwd.h:33
The root for all renderer implementations.
Definition EEngineProject.h:6
Check if object conversion can be made.
Definition traits.h:70