I am trying to prevent this problem in opengl:
![](https://uploads.gamedev.net/forums/monthly_2021_06/06790127f7db4c5ea6cbbdd6295173a1.image.png)
as you can see there is hard fall of in light if a fragment is too far away from light.
this was when the light sphere radius was 11
I then mildly solved this problem and now its like this:
![](https://uploads.gamedev.net/forums/monthly_2021_06/47d79d5e24094ffab0a5888e44c7cb38.image.png)
this was done with this code:
for (int i = 0; i < activePointLights; i++) {
float dist=distance(f_position,pointLights[i].position);
if (dist <= pointLights[i].radius+pointLights[i].dropoffRadius){
result += CalcPointLight(pointLights[i], norm, f_position, viewDir, diffColor, tangentLightPos, tangentFragPos)*clamp(2*pointLights[i].dropoffRadius*(1-dist)+pointLights[i].radius-pointLights[i].dropoffRadius,0,1);
}
}
here dropoffradius was 1 and the light sphere radius was 23
the equation inside clamp was made by linearly interpolating input from (sphereradius - dropoffradius to sphereradius + dropoffradius)
being mapped to range (1 to 0)
.
When I increase pointLights[i].dropoffRadius
to 2 I get way less illuminated area and I have to crank up the radius of the pointlight sphere.
what I want now is to make the edges of the boundary of light affecting fragments in plane of above picture more soft controlled by a value like pointLights[i].dropoffRadius
.