Open Zeta48 opened 2 years ago
I found out my mistake. I should use angles instead of directly using interpolateBilinear. `
void dirToSphericalAngles(const Math::Vec3& dir, nbFloat32& angleH, nbFloat32& angleV)
{
angleH = (0.5f + 0.5f * atan2(dir.x, dir.z) / Math::Pi.getValue()) * 360.0f;
angleV = (1.f - acos(dir.y) / Math::Pi.getValue()) * 180.0f;
}
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;
nbFloat32 angleH, angleV;
dirToSphericalAngles(-sample.L, angleH, angleV);
sample.intensityMultiplier = m_iesLoadHelper.interpolate2D(*m_iesFileInfo, angleV, angleH);
return sample;
}
`
Hello,
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).
For example: The ground truth: https://imgur.com/CrxT7bv The result I get: https://imgur.com/pJ7VU5e
My renderer use a right handed Y up coordinate system: https://i.stack.imgur.com/vg1P7.png
Here is my sampling code:
`
`
Thanks in advance for helping.