well after defining the RADIUS and LIGHT COLOR IN THE SHADER you could do that
vertex shader:
attribute vec3 Vpos;
varying vec2 vert;
void main()
{
vert = Vpos.xy; //pass texture coord
gl_Position = vec4(Vpos.xy, 0.0, 1.0);
}
in fragment
something liek that:
varying vec2 vert;
varying vec3 vertex_pos;
uniform vec3 LPOS;
uniform vec3 LDIFF;
uniform float LRadius;
float n3ddistance(vec3 first_point, vec3 second_point)
{
float x = first_point.x-second_point.x;
float y = first_point.y-second_point.y;
float z = first_point.z-second_point.z;
float val = x*x + y*y + z*z;
return sqrt(val);
}
void main()
{
float dst = n3ddistance(LPOS, vertex_pos);
float intensity = clamp(1.0 - dst / LRadius, 0.0, 1.0);
vec4 color = vec4(LDIFF.x, LDIFF.y, LDIFF.z, 1.0)*intensity;
gl_FragColor = color;
}
ofc that wont compile i just mixed two different shaders
vertex is from drawing a fullscreen quad on screen
second is a pointlight but in 3d so (additionallyi pass a vertex position to fragment shader)
looks like this:
still one thing to consider you need to know if you will pass light radius in ndc coord (or screen coords ) or in worldspace coords everything is enterely up to you