| 72 | } |
| 73 | |
| 74 | void SpotLight::commit() |
| 75 | { |
| 76 | Light::commit(); |
| 77 | position = getParam<vec3f>("position", vec3f(0.f)); |
| 78 | direction = getParam<vec3f>("direction", vec3f(0.f, 0.f, 1.f)); |
| 79 | float openingAngle = getParam<float>("openingAngle", 180.f); |
| 80 | float penumbraAngle = getParam<float>("penumbraAngle", 5.f); |
| 81 | radius = max(0.0f, getParam<float>("radius", 0.f)); |
| 82 | innerRadius = |
| 83 | clamp(getParam<float>("innerRadius", 0.f), 0.0f, 0.999f * radius); |
| 84 | |
| 85 | // per default perpendicular to direction |
| 86 | intensityDistribution.c0 = std::abs(direction.x) < std::abs(direction.y) |
| 87 | ? vec3f(0.0f, direction.z, direction.y) |
| 88 | : vec3f(direction.z, 0.0f, direction.x); |
| 89 | intensityDistribution.readParams(*this); |
| 90 | |
| 91 | // check ranges and pre-compute parameters |
| 92 | openingAngle = clamp(openingAngle, 0.f, 360.f); |
| 93 | penumbraAngle = clamp(penumbraAngle, 0.f, 0.5f * openingAngle); |
| 94 | |
| 95 | cosAngleMax = std::cos(deg2rad(0.5f * openingAngle)); |
| 96 | const float cosAngleMin = |
| 97 | std::cos(deg2rad(0.5f * openingAngle - penumbraAngle)); |
| 98 | cosAngleScale = 1.0f / (cosAngleMin - cosAngleMax); |
| 99 | |
| 100 | queryIntensityQuantityType(intensityDistribution |
| 101 | ? OSP_INTENSITY_QUANTITY_SCALE |
| 102 | : OSP_INTENSITY_QUANTITY_INTENSITY); |
| 103 | processIntensityQuantityType(openingAngle); |
| 104 | } |
| 105 | |
| 106 | void SpotLight::processIntensityQuantityType(const float openingAngle) |
| 107 | { |
nothing calls this directly
no test coverage detected