画一堵墙
示例代码
#ifdef GL_ES
precision mediump float;
#endif
uniform float u_time;
uniform vec2 u_resolution;
uniform vec2 u_mouse;
/**
* @param {float } x 坐标点
* @param {float } s 划线的位置
* @param {float } w 现对与屏幕宽度的线宽
*/
float stroke(float x, float s, float w){
float d = step(s, x + w * 0.5) - step(s, x - w * 0.5);
return clamp(d, 0.0, 1.0);
}
void main(){
vec2 st = gl_FragCoord.xy / u_resolution;
st.x *= u_resolution.x/u_resolution.y;
vec3 color = vec3(0.0);
color += stroke(st.x, 0.5, 0.15);
gl_FragColor = vec4(color, 1.0);
}
代码效果

《像素精灵元素GLSL》期待你的关注与点赞