88b312d3 |
1 | //! Returns point light source attenuation factor |
2 | float occRangedPointLightAttenuation (in float theDistance, in float theRange) |
3 | { |
4 | if (theDistance <= theRange) |
5 | { |
6 | float aResult = theDistance / theRange; |
7 | aResult *= aResult; |
8 | aResult *= aResult; |
9 | aResult = 1.0 - aResult; |
10 | aResult = clamp(aResult, 0.0, 1.0); |
11 | aResult /= max(0.0001, theDistance * theDistance); |
12 | return aResult; |
13 | } |
14 | return -1.0; |
15 | } |
16 | |
17 | //! Returns point light source attenuation factor with quadratic attenuation in case of zero range. |
18 | float occPointLightAttenuation (in float theDistance, in float theRange) |
19 | { |
20 | if (theRange == 0.0) |
21 | { |
22 | return 1.0 / max(0.0001, theDistance * theDistance); |
23 | } |
24 | return occRangedPointLightAttenuation (theDistance, theRange); |
25 | } |
26 | |
27 | //! Returns point light source attenuation factor with linear attenuation in case of zero range. |
28 | float occPointLightAttenuation (in float theDistance, in float theRange, in float theLinearAttenuation, in float theConstAttenuation) |
29 | { |
30 | if (theRange == 0.0) |
31 | { |
32 | return 1.0 / (theConstAttenuation + theLinearAttenuation * theDistance); |
33 | } |
34 | return occRangedPointLightAttenuation (theDistance, theRange); |
78607702 |
35 | } |