This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/gpu/shaders/material/gpu_shader_material_clamp.glsl
Charlie Jolly 958d0d4236 Shader Nodes: Add Interpolation modes to Map Range node
Modes: Linear interpolation (default), stepped linear, smoothstep and smootherstep.

This also includes an additional option for the **Clamp node** to switch between **Min Max** (default) and **Range** mode.

This was needed to allow clamping when **To Max** is less than **To Min**.

Reviewed By: JacquesLucke, brecht

Differential Revision: https://developer.blender.org/D5827
2019-12-07 12:52:42 +00:00

10 lines
258 B
GLSL

void clamp_value(float value, float min, float max, out float result)
{
result = clamp(value, min, max);
}
void clamp_range(float value, float min, float max, out float result)
{
result = (max > min) ? clamp(value, min, max) : clamp(value, max, min);
}