#version 410 in vec3 colV; in vec3 modelPosV; in vec3 worldPosV; in vec3 viewPosV; in vec2 uvV; out vec4 fragColor; vec3 mf(vec3 x) { return x - floor(x); } float mapRange(float x, float minIn, float maxIn, float minOut, float maxOut) { x -= minIn; x = x * (maxOut - minOut) / (maxIn - minIn); x += minOut; x = clamp(x, minOut, maxOut); return x; } void main (void) { vec2 uv = uvV; if(uv.x > 0.5) uv.x = 1.0 - uv.x; if(uv.y > 0.5) uv.y = 1.0 - uv.y; float e = min(uv.x, uv.y); float edgeLimit = 0.1; e = mapRange(e, 0.0, edgeLimit, 0.9, 1.0); vec3 shadowey3 = worldPosV; shadowey3 = modelPosV / 3; float r = cos(shadowey3.x) + cos(shadowey3.y) + cos(shadowey3.z); r = mapRange(r, -3, 3, 0.8, 1.0); fragColor = vec4(colV,1); fragColor.rgb *= e * r; }