Minor optimization in pointlight scatter.
Compute some values before loop.
This commit is contained in:
parent
9cec9c5cea
commit
14389925fe
@ -31,15 +31,15 @@ void main()
|
|||||||
float stepsize = length(farthestpoint - closestpoint) / 16.;
|
float stepsize = length(farthestpoint - closestpoint) / 16.;
|
||||||
vec3 fog = vec3(0.);
|
vec3 fog = vec3(0.);
|
||||||
vec3 xpos = farthestpoint;
|
vec3 xpos = farthestpoint;
|
||||||
|
vec3 fog_factor = light_col * density * stepsize * energy * 20.;
|
||||||
|
vec3 xpos_step = eyedir * stepsize;
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
float d = distance(light_pos, xpos);
|
float d = distance(light_pos, xpos);
|
||||||
float l = (16. - float(i)) * stepsize;
|
float l = (16. - float(i)) * stepsize;
|
||||||
float att = energy * 20. / (1. + d * d);
|
fog += fog_factor / (1. + d * d) * max((radius - d) / radius, 0.) * exp(- density * d) * exp(- density * l);
|
||||||
att *= max((radius - d) / radius, 0.);
|
xpos += xpos_step;
|
||||||
fog += density * light_col * att * exp(- density * d) * exp(- density * l) * stepsize;
|
|
||||||
xpos += stepsize * eyedir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Fog = vec4(fogcol * fog, 0.);
|
Fog = vec4(fogcol * fog, 0.);
|
||||||
|
Loading…
Reference in New Issue
Block a user