#version 410 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); } 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) { vec3 nNor = normalize(norV); vec3 colVL = colV; 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); float viewPosLength = length(viewPosV); float tinyDetailIntensity = mapRange(viewPosLength, 1.5, 0.0, 0, 0.0065); float tinyDetailChecker = (int(uvV.x * 200) + int(uvV.y * 200) & 1) != 0 ? -1.0 : 1.0; colVL += tinyDetailIntensity * vec3(tinyDetailChecker, tinyDetailChecker, tinyDetailChecker); fragColor = vec4(colVL,1); float br = 8.0; if(viewPosLength < br) { float bk = (br - viewPosLength) / (br * 10.0); fragColor.rgb += vec3(bk, bk, bk); } fragColor = clamp(fragColor, 0, 1); fragColor.rgb *= e; }