我有一个用于 2D 灯光的简单 GLSL 片段着色器,有没有办法修改它来实现设置灯光的半径和/或强度?目前唯一可用的修改是恒定/线性/二次光衰减。
这是当前的着色器代码(未更新到现代 OpenGL)
uniform vec2 lightpos;
uniform vec4 lightColor;
uniform float screenHeight;
uniform vec3 lightAttenuation;
uniform float radius; //Doesn't do anything
uniform float intensity; //Doesn't do anything
uniform sampler2D texture;
void main()
{
vec2 pixel=gl_FragCoord.xy;
pixel.y=screenHeight-pixel.y;
vec2 aux=lightpos-pixel;
float distance=length(aux);
float attenuation=1.0/(lightAttenuation.x+lightAttenuation.y*distance+lightAttenuation.z*distance*distance);
vec4 color=vec4(attenuation,attenuation,attenuation,1.0)*lightColor;
gl_FragColor = color;//*texture2D(texture,gl_TexCoord[0].st);
}