#version 410 uniform float eyePos; uniform float time; in vec3 colV; in vec3 modelPosV; in vec3 worldPosV; in vec3 viewPosV; in vec3 norV; in vec2 uvV; out vec4 fragColor; vec3 mf(vec3 x) { return x - floor(x); } void main (void) { vec3 nNor = normalize(norV); vec3 colVL = colV; // float k = sin(time) * 10.0 + 10.0; // if(distance(worldPosV, vec3(0,0,0)) > k) // discard; if(gl_FrontFacing) { // do the plaid-ing float sqF = .25; float w = 0.5; float plaidShade = 0.96; vec3 t = mf(modelPosV / sqF); if(t.x < w || t.y < w) colVL *= plaidShade; if(t.y < w || t.z < w) colVL *= plaidShade; if(t.z < w || t.x < w) colVL *= plaidShade; } fragColor = vec4(colVL,1); { // add a specular vec3 eyePos3 = vec3(0.0, 0.0, eyePos); float spec = dot(normalize(eyePos3 - viewPosV), normalize(nNor)); spec = pow(spec,100.0); fragColor += vec4(spec, spec, spec, 1.0); } }