// Physically based lightness calculation // for a point light above a 100% matte (Lambertian) ground plane, // moving up and down. // details: https://hyperknot.com/blog/area_lights_in_shaders/ float point_light(vec2 uv, float h, float i) { // h - light's height over the ground // i - light's intensity return i * h * pow(dot(uv,uv) + h*h, -1.5); } float lin_to_srgb ( float val ) { if( val < 0.0031308 ) return val * 12.92; else return 1.055 * pow(val,1.0/2.4) - 0.055; } void mainImage( out vec4 fragColor, in vec2 fragCoord ){ vec2 uv = ( fragCoord - .5*iResolution.xy ) / iResolution.y; float h = pow(sin(iTime/3.), 2.) * 0.1 + 0.001; float v = point_light(uv, h, 0.005); v = lin_to_srgb(v); fragColor=vec4(v); }