#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; 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); spec = spec * .3; { // pin specular brightness to largest of the main color components float specAmt = max(max(colV.r, colV.g), colV.b); specAmt = max(0.3, specAmt); spec *= specAmt; fragColor += vec4(spec, spec, spec, 1.0); } } { // some depth-dimming // z is negative the further it is from us. // if(z < 0.0) { float z = -viewPosV.z - 10.0; float dimming = 1.0 - z / 100.0; dimming = clamp(dimming, 0.1, 1.0); fragColor *= dimming; } // z stripes // float z = viewPosV.z; // z = z - floor(z); // z = z < 0.5 ? 0.0 : 1.0; // fragColor = vec4(z,z,z,1.0); // if(viewPosV.z < 0.0) // fragColor = vec4(1.0,z,z,1.0); // if(viewPosV.z < -5.0) // fragColor = vec4(1.0,1.0,z,1.0); } }