To attach a shader to a particular layer, you need to first write two functions; one that contains code to activate the shader, and another to stop the shader. The first you attach to the layer with layer_script_being
, the second with layer_script_end
. This makes the shader affect that particular layer only.
The start script must send player position to the shader as uniforms. Inside the shader, you need to do some trigonometry to calculate distance from the pixel to the player, and use that to judge how much the pixel needs to be brightened, if at all. When adjusting brightness, mind that RGB color values run from 0 to 1 in shaders. You'll have to process all three colors: move the color value from current value towards max brightness value of 1 by a fraction on their difference. That is, if the color value is were 0.2 and you want to adjust brightness by 40%, you take that percentage of the difference (1 minus 0.2) and add it to current value: current + ((1 - current) * brightnessadjust), or 0.2 + ((1 - 0.2) * 0.4) = 0.52.
Or simply just add a value to all three color components, for a simpler process.