1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-01 17:36:21 +03:00
occt/resources/Shaders/PointLightAttenuation.glsl
Pasukhin Dmitry df4b931988
Configuration - Resource structure reorganization #429
Reorganized resources to keep source part in src and real-time scripts in resource folder.
For the installation result no changes, still installed to src for windows.
2025-03-18 22:54:43 +00:00

36 lines
1.1 KiB
GLSL

//! Returns point light source attenuation factor
float occRangedPointLightAttenuation (in float theDistance, in float theRange)
{
if (theDistance <= theRange)
{
float aResult = theDistance / theRange;
aResult *= aResult;
aResult *= aResult;
aResult = 1.0 - aResult;
aResult = clamp(aResult, 0.0, 1.0);
aResult /= max(0.0001, theDistance * theDistance);
return aResult;
}
return -1.0;
}
//! Returns point light source attenuation factor with quadratic attenuation in case of zero range.
float occPointLightAttenuation (in float theDistance, in float theRange)
{
if (theRange == 0.0)
{
return 1.0 / max(0.0001, theDistance * theDistance);
}
return occRangedPointLightAttenuation (theDistance, theRange);
}
//! Returns point light source attenuation factor with linear attenuation in case of zero range.
float occPointLightAttenuation (in float theDistance, in float theRange, in float theLinearAttenuation, in float theConstAttenuation)
{
if (theRange == 0.0)
{
return 1.0 / (theConstAttenuation + theLinearAttenuation * theDistance);
}
return occRangedPointLightAttenuation (theDistance, theRange);
}