Another batch of GetValues() overrides. (#6915)
* Another batch of GetValues() overrides. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Added missing headers. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Addressed PR feedback. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
This commit is contained in:
@@ -151,34 +151,28 @@ namespace GradientSignal
|
||||
float PosterizeGradientComponent::GetValue(const GradientSampleParams& sampleParams) const
|
||||
{
|
||||
const float bands = AZ::GetMax(static_cast<float>(m_configuration.m_bands), 2.0f);
|
||||
const float input = AZ::GetClamp(m_configuration.m_gradientSampler.GetValue(sampleParams), 0.0f, 1.0f);
|
||||
float output = 0.0f;
|
||||
const float input = m_configuration.m_gradientSampler.GetValue(sampleParams);
|
||||
return PosterizeValue(input, bands, m_configuration.m_mode);
|
||||
}
|
||||
|
||||
// "quantize" the input down to a number that goes from 0 to (bands-1)
|
||||
const float band = AZ::GetClamp(floorf(input * bands), 0.0f, bands - 1.0f);
|
||||
|
||||
// Given our quantized band, produce the right output for that band range.
|
||||
switch (m_configuration.m_mode)
|
||||
void PosterizeGradientComponent::GetValues(AZStd::span<AZ::Vector3> positions, AZStd::span<float> outValues) const
|
||||
{
|
||||
if (positions.size() != outValues.size())
|
||||
{
|
||||
default:
|
||||
case PosterizeGradientConfig::ModeType::Floor:
|
||||
// Floor: the output range should be the lowest value of each band, or (0 to bands-1) / bands
|
||||
output = (band + 0.0f) / bands;
|
||||
break;
|
||||
case PosterizeGradientConfig::ModeType::Round:
|
||||
// Round: the output range should be the midpoint of each band, or (0.5 to bands-0.5) / bands
|
||||
output = (band + 0.5f) / bands;
|
||||
break;
|
||||
case PosterizeGradientConfig::ModeType::Ceiling:
|
||||
// Ceiling: the output range should be the highest value of each band, or (1 to bands) / bands
|
||||
output = (band + 1.0f) / bands;
|
||||
break;
|
||||
case PosterizeGradientConfig::ModeType::Ps:
|
||||
// Ps: the output range should be equally distributed from 0-1, or (0 to bands-1) / (bands-1)
|
||||
output = band / (bands - 1.0f);
|
||||
break;
|
||||
AZ_Assert(false, "input and output lists are different sizes (%zu vs %zu).", positions.size(), outValues.size());
|
||||
return;
|
||||
}
|
||||
|
||||
const float bands = AZ::GetMax(static_cast<float>(m_configuration.m_bands), 2.0f);
|
||||
|
||||
// Fill in the outValues with all of the generated inupt gradient values.
|
||||
m_configuration.m_gradientSampler.GetValues(positions, outValues);
|
||||
|
||||
// Run through all the input values and posterize them.
|
||||
for (auto& outValue : outValues)
|
||||
{
|
||||
outValue = PosterizeValue(outValue, bands, m_configuration.m_mode);
|
||||
}
|
||||
return AZ::GetClamp(output, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
bool PosterizeGradientComponent::IsEntityInHierarchy(const AZ::EntityId& entityId) const
|
||||
|
||||
Reference in New Issue
Block a user