ALS technical notes: Difference between revisions

Jump to navigation Jump to search
Quoting GLSL shader code in the Wiki is too detailed (and misleading, generally people expect copy/pastable examples).
(Quoting GLSL shader code in the Wiki is too detailed (and misleading, generally people expect copy/pastable examples).)
Line 1,542: Line 1,542:


Up to inner_angle, the light will have full intensity. From inner to outer angle the light will linearly fade to outer_gain. From outer angle to zero angle, the light intensity will linearly fade to zero.
Up to inner_angle, the light will have full intensity. From inner to outer angle the light will linearly fade to outer_gain. From outer angle to zero angle, the light intensity will linearly fade to zero.
'''Note:''' To better explain the relation of the variables ''inner_angle'', ''outer_angle'' and ''zero angle'', this is the algorithm that produces the scalar value ''directional_fade'' from which the intensity value is defined in the shaders file ''light-ALS.frag'':
<syntaxhighlight lang="xml">
float directional_fade (in float direction) {
  float arg = clamp(direction, 0.0, 1.0);
  float ia = (1.0 - inner_angle);
  float oa = (1.0 - outer_angle);
  float za = (1.0 - zero_angle);
  if (direction > ia) {return 1.0;}
  else if (direction > oa)
{return outer_gain + (1.0-outer_gain) * (direction - oa) / (ia - oa);}
  else if (direction > za)
{return outer_gain * (direction - za) / (oa - za);}
  else {return 0.0;}
}
</syntaxhighlight>


====Strobe effect====
====Strobe effect====
1,360

edits

Navigation menu