Skip to content

Instantly share code, notes, and snippets.

@patriciogonzalezvivo
Last active December 5, 2016 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patriciogonzalezvivo/9695e787d604ecc14569ddd461e9f65b to your computer and use it in GitHub Desktop.
Save patriciogonzalezvivo/9695e787d604ecc14569ddd461e9f65b to your computer and use it in GitHub Desktop.
Multistep functions
```glsl
float mix4smoothstep(float a, float b, float c, float d, float x ) {
return mix(mix(a,b,smoothstep(0.,.33,x)),
mix(b,
mix(c,d,smoothstep(.66,.99,x)),
smoothstep(.33,.66,x)),
step(.33,x));
}
float mix4linear(float a, float b, float c, float d, float x ) {
return mix(mix(a,b,clamp(x,0.,.33)*3.),
mix(b,
mix(c,d,(clamp(x,.66,1.)-.66)*3.),
(clamp(x,.33,.66)-.33)*3.),
step(0.33,x));
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment