aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/shaders/modules/utils.glsl
blob: 3520df1683fc22acb01dd5a1fa61f65a57f602d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
float smin(float a, float b, float k) {
  float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);
  return mix(b, a, h) - k * h * (1.0 - h);
}

float ssubtract(float a, float b, float k) {
  return -smin(-a, b, k);
}

vec3 srgb(float r, float g, float b) {
  return vec3(pow(r, 2.2), pow(g, 2.2), pow(b, 2.2));
}
vec3 srgb(vec3 c) {
  return srgb(c.r, c.g, c.b);
}