diff options
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 00b8ce54eb3..a8d4821a483 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -429,6 +429,17 @@ void squeeze(float val, float width, float center, out float outval) outval = 1.0 / (1.0 + pow(2.71828183, -((val - center) * width))); } +void map_range( + float value, float fromMin, float fromMax, float toMin, float toMax, out float result) +{ + if (fromMax != fromMin) { + result = toMin + ((value - fromMin) / (fromMax - fromMin)) * (toMax - toMin); + } + else { + result = 0.0; + } +} + void vec_math_add(vec3 v1, vec3 v2, out vec3 outvec, out float outval) { outvec = v1 + v2; |