2015-06-20 12:39:58 +00:00
|
|
|
// Author @patriciogv ( patriciogonzalezvivo.com ) - 2015
|
|
|
|
|
2015-03-15 15:35:14 +00:00
|
|
|
#ifdef GL_ES
|
|
|
|
precision mediump float;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
uniform vec2 u_resolution;
|
|
|
|
uniform float u_time;
|
|
|
|
|
|
|
|
vec2 brickTile(vec2 _st, float _zoom){
|
|
|
|
_st *= _zoom;
|
2015-06-20 12:39:58 +00:00
|
|
|
|
|
|
|
// Here is where the offset is happening
|
2015-07-14 14:34:43 +00:00
|
|
|
_st.x += step(1., mod(_st.y,2.0)) * 0.5;
|
2015-06-20 12:39:58 +00:00
|
|
|
|
2015-03-15 15:35:14 +00:00
|
|
|
return fract(_st);
|
|
|
|
}
|
|
|
|
|
|
|
|
float box(vec2 _st, vec2 _size){
|
|
|
|
_size = vec2(0.5)-_size*0.5;
|
|
|
|
vec2 uv = smoothstep(_size,_size+vec2(1e-4),_st);
|
|
|
|
uv *= smoothstep(_size,_size+vec2(1e-4),vec2(1.0)-_st);
|
|
|
|
return uv.x*uv.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void main(void){
|
|
|
|
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
|
|
|
vec3 color = vec3(0.0);
|
|
|
|
|
|
|
|
// Modern metric brick of 215mm x 102.5mm x 65mm
|
|
|
|
// http://www.jaharrison.me.uk/Brickwork/Sizes.html
|
|
|
|
// st /= vec2(2.15,0.65)/1.5;
|
|
|
|
|
2015-06-20 12:39:58 +00:00
|
|
|
// Apply the brick tiling
|
2015-03-15 15:35:14 +00:00
|
|
|
st = brickTile(st,5.0);
|
2015-12-19 20:50:59 +00:00
|
|
|
|
2015-06-20 12:39:58 +00:00
|
|
|
color = vec3(box(st,vec2(0.9)));
|
|
|
|
|
|
|
|
// Uncomment to see the space coordinates
|
2015-03-15 15:35:14 +00:00
|
|
|
// color = vec3(st,0.0);
|
|
|
|
|
2015-12-19 20:50:59 +00:00
|
|
|
gl_FragColor = vec4(color,1.0);
|
2017-08-19 10:11:58 +00:00
|
|
|
}
|