simplify smoothstep maths

except if there is a pedagogical reason for using smoothstep twice, using it once seems simpler to understand
pull/245/head
Julien Moumné 5 years ago committed by GitHub
parent 9789040caa
commit 7e3f278ee2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,9 +7,8 @@ uniform vec2 u_mouse;
uniform float u_time;
// Plot a line on Y using a value between 0.0-1.0
float plot(vec2 st, float pct){
return smoothstep( pct-0.02, pct, st.y) -
smoothstep( pct, pct+0.02, st.y);
float plot(vec2 st) {
return smoothstep(0.02, 0.0, abs(st.y - st.x));
}
void main() {
@ -20,7 +19,7 @@ void main() {
vec3 color = vec3(y);
// Plot a line
float pct = plot(st,y);
float pct = plot(st);
color = (1.0-pct)*color+pct*vec3(0.0,1.0,0.0);
gl_FragColor = vec4(color,1.0);

Loading…
Cancel
Save