In this video I go over a pair of vital GLSL functions used in fragment(pixel) shader graphics programming: step and smoothstep.
I take a look at the syntax for the two and then I use a line drawing function to show you how smoothstep can produce a…
In this video I go over a pair of vital GLSL functions used in fragment(pixel) shader graphics programming: step and smoothstep.
I take a look at the syntax for the two and then I use a line drawing function to show you how smoothstep can produce a line.
At the end of the video I briefly introduce you to what "shaping" functions are and how we can use them to manipulate what gets drawn on our OpenGL canvas.
Normalising in OpenGL: https://www.bitchute.com/video/vth6JWpzn39C/
This series is based off of the free on-line book, "The Book Of Shaders", by Patricio Gonzalez Vivo and Jen Lowe.
https://thebookofshaders.com/
If you feel like donating, please donate to those two; a donation link is found on their website linked above.
Editor used: https://patriciogonzalezvivo.github.io/glslEditor/
Subscribe to my Bitchute: https://www.bitchute.com/channel/gPUmRsVcChxX/
Subscribe to my Youtube: https://www.youtube.com/channel/UCar-9GMCRk9QdKJXq6s1yeg/
If you find value in what I do, think about supporting my channel:
Paypal: https://www.paypal.me/anobjisa
Bitcoin: 3H4NKKwPdbiE5Gtc3Uk2DiwszqHhrRbmKK
Ethereum: 0x48702412F448a27be03836fb6FE6456603668030
Litecoin: MNJ4uv3GD4r62VpQ8rHX1Pj1ihWCj74hCK
Find me here:
Twitter: https://twitter.com/anobjectisa1
Minds: https://www.minds.com/an_object_is_a/
Instagram: https://www.instagram.com/an_object_is_a/
Code Used:
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
// Plot a line on Y using a value between 0.0-1.0
float plot(vec2 st, float pct){
return smoothstep( pct-0.05, pct, st.y) -
smoothstep( pct, pct+0.05, st.y);
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution;
float y = st.x;
vec3 line_color = vec3(0.0,1.0,0.0);
// Get all values associated with geometric line
float line_values = plot(st,y);
vec3 line = line_color * line_values;
vec3 canvas = line;
gl_FragColor = vec4(canvas,1.0);
}