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

gpu_shader_material_float_curve.glsl « material « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 514409f7fdfdf8965a35627a367b50596e104229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ext is vec4(in_x, in_dy, out_x, out_dy). */
float curve_float_extrapolate(float x, float y, vec4 ext)
{
  if (x < 0.0) {
    return y + x * ext.y;
  }
  else if (x > 1.0) {
    return y + (x - 1.0) * ext.w;
  }
  else {
    return y;
  }
}

#define RANGE_RESCALE(x, min, range) ((x - min) * range)

void curve_float(float fac,
                 float vec,
                 sampler1DArray curvemap,
                 float layer,
                 float range,
                 vec4 ext,
                 out float outvec)
{
  float xyz_min = ext.x;
  vec = RANGE_RESCALE(vec, xyz_min, range);

  outvec = texture(curvemap, vec2(vec, layer)).x;

  outvec = curve_float_extrapolate(vec, outvec, ext);

  outvec = mix(vec, outvec, fac);
}