1.利用取整函数绘制
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = (fragCoord.xy - 0.5 * iResolution.xy) / iResolution.y;
uv *= 6.0;
float c = 0.0;
float d = 0.0;
float ax = (floor(uv.x + 0.5));
float ay = (floor(uv.y));
if( int(mod(ay , 2.0)) == 0 && int(mod(ax, 2.0)) == 0)
{
c = 1.0;
}
if( int(mod(ay , 2.0)) == 1 && int(mod(ax, 2.0)) == 1)
{
c = 1.0;
}
fragColor = vec4(c * vec3(1.0,1.0,0.0),1.0);
}
效果: