Added follow cam
Added "Controlled" mesh classes Added Global Lighting Class Added Gamepad controls Split terrain nodes into Height and Perlin classes Fixed Splitmesh node stuff
This commit is contained in:
@ -15,6 +15,7 @@ ColorGradient::~ColorGradient()
|
||||
// Get the RGBA value at the give point
|
||||
RGBA ColorGradient::GetRGBAValue(float inputValue)
|
||||
{
|
||||
// Check if we are at the start or end, return those values if so
|
||||
if (inputValue <= _minValue)
|
||||
{
|
||||
return _colorSteps.front();
|
||||
@ -24,10 +25,12 @@ RGBA ColorGradient::GetRGBAValue(float inputValue)
|
||||
return _colorSteps.back();
|
||||
}
|
||||
|
||||
// Get the point which the input value is at between the entire range
|
||||
float range = _maxValue - _minValue;
|
||||
float value = inputValue - _minValue;
|
||||
float steps = range / (float)(_colorSteps.size() - 1);
|
||||
|
||||
// Which gradient step are we in
|
||||
int colorStepInside = (int)(value / steps);
|
||||
|
||||
float normalisedValue = (value - (colorStepInside * steps)) / steps;
|
||||
@ -38,6 +41,7 @@ RGBA ColorGradient::GetRGBAValue(float inputValue)
|
||||
// Method for interpolating the color between each step
|
||||
RGBA ColorGradient::Interpolate(RGBA a, RGBA b, float pointValue)
|
||||
{
|
||||
// Check if we are at the start or end, return those values if so
|
||||
if (pointValue <= 0.0f)
|
||||
{
|
||||
return a;
|
||||
@ -47,10 +51,13 @@ RGBA ColorGradient::Interpolate(RGBA a, RGBA b, float pointValue)
|
||||
return b;
|
||||
}
|
||||
|
||||
unsigned int currentRed = (unsigned int)((1.0f - pointValue) * a.red + pointValue * b.red);
|
||||
unsigned int currentGreen = (unsigned int)((1.0f - pointValue) * a.green + pointValue * b.green);
|
||||
unsigned int currentBlue = (unsigned int)((1.0f - pointValue) * a.blue + pointValue * b.blue);
|
||||
unsigned int currentAlpha = (unsigned int)((1.0f - pointValue) * a.alpha + pointValue * b.alpha);
|
||||
//pointValue = SharedMethods::Clamp<float>(pointValue * 1.5f, 0.0f, 1.0f);
|
||||
|
||||
// Lerp the color values for each channel between the steps
|
||||
unsigned int currentRed = (unsigned int)SharedMethods::Lerp<unsigned int>(a.red, b.red, pointValue);
|
||||
unsigned int currentGreen = (unsigned int)SharedMethods::Lerp<unsigned int>(a.green, b.green, pointValue);
|
||||
unsigned int currentBlue = (unsigned int)SharedMethods::Lerp<unsigned int>(a.blue, b.blue, pointValue);
|
||||
unsigned int currentAlpha = (unsigned int)SharedMethods::Lerp<unsigned int>(a.alpha, b.alpha, pointValue);
|
||||
|
||||
return RGBA{ currentRed, currentGreen, currentBlue, currentAlpha };
|
||||
}
|
Reference in New Issue
Block a user