Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmarSquircleArt <omar.squircleart@gmail.com>2019-08-13 17:29:32 +0300
committerOmarSquircleArt <omar.squircleart@gmail.com>2019-08-13 17:38:56 +0300
commit71641ab56d0f0cb52c301b83ff499699029fa032 (patch)
tree18029c373c2ec777e8c151e888bc708aa2537988 /source/blender/gpu
parentaef08fda3ade2d0223b77d4c9c0dd5e9fcabe7b2 (diff)
Shading: Add Map Range node to Cycles and EEVEE.
This patch adds a new Map Range node that linearly remaps an input value from a range to another. This node is similar to the compositor's Map Range node. Reviewers: brecht, JacquesLucke Differential Revision: https://developer.blender.org/D5471
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl11
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;