#version 410 in vec3 colV; in vec3 modelPosV; in vec3 worldPosV; in vec3 viewPosV; in vec3 norV; in vec2 uvV; out vec4 fragColor; vec3 eyePos = vec3(0,0,1.8); uniform sampler2D texture1; float mapRange(float x, float inLow, float inHigh, float outLow, float outHigh) { x -= inLow; x *= (outHigh - outLow) / (inHigh - inLow); x += outLow; x = clamp(x, outLow, outHigh); return x; } vec3 mf(vec3 x) { return x - floor(x); } void main (void) { vec3 colVL = colV; if(!gl_FrontFacing) { // colVL *= 0.98; } else { // 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); vec2 co = gl_FragCoord.xy / 1024.0; // co.x += 0.1; // co.y += 0.02; // co += norV.xy * .001; vec3 norN = normalize(norV); vec2 nor2 = norV.xy + vec2(norV.z * .001, norV.z * .001); nor2 += sin(uvV * 3.0) * 10.0; vec2 coR = co + nor2.xy * 0.001; vec2 coG = co + nor2.xy * 0.00102; vec2 coB = co + nor2.xy * 0.00104; fragColor = vec4(texture(texture1, coR).r, texture(texture1, coG).g, texture(texture1, coB).b, 1) * vec4(0.83, 0.92, 0.95, 1.0); fragColor *= vec4(vec2(1,1) - 0.3 * uvV, 1, 1); fragColor *= vec4(1, .5, .8, 1); fragColor += vec4(.3, .2, .1, 0)/3.0; fragColor += vec4(uvV,0,1); { vec3 nNor = normalize(norV); 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); } if(false) if(gl_FrontFacing) { // front fragColor = mix(vec4(.3, .3, .3, 1), vec4(modelPosV, 1), 0.1); } else { // back fragColor = vec4(modelPosV,1); } }