I am trying to add IES lighting to my CPU renderer. To do so i used your IES parser.
Unfortunetly i am getting wrong results when i sample the lights(IESLoadHelper::interpolatePoint or IESLoadHelper::interpolateBilinear).
Math::Vec2 dirToSphericalUV(const Math::Vec3& dir)
{
return Math::Vec2(
0.5f + 0.5f * atan2(dir.x, dir.z) / 3.1415926f,
1.f - acos(dir.y) / 3.1415926f);
}
struct SampleToLight
{
Math::Vec3 L;
float length;
float intensityMultiplier = 1.0f;
};
SampleToLight IesLight::generateSampleToLight(const Math::Vec3& P) const
{
const Math::Vec3 lightWsPosition = this->readPosition();
SampleToLight sample;
sample.L = lightWsPosition - P;
sample.length = glm::length(sample.L);
sample.L /= sample.length;
//NOT WORKING
const Math::Vec2 profileUV = dirToSphericalUV(-1.f * sample.L);
const float profileCoordH = profileUV.x * (float)m_iesFileInfo->anglesNumH;
const float profileCoordV = profileUV.y * (float)m_iesFileInfo->anglesNumV;
sample.intensityMultiplier = m_iesLoadHelper.interpolateBilinear(*m_iesFileInfo, profileCoordH, profileCoordV);
return sample;
}
Thanks in advance for helping.