- Home /
Image-Based Lighting refreshing
I wrote a code to read from a 360-degree camera and transfer the panoramic video into a cubeMap which change the reflection light of the virtual object through the shader based on the current environment in the real scene for AR application but the code is so heavy, and I don't know where it goes wrong! But when I run the code, I couldn't stop the process. I try to press stop button but the code still running in a loop
Is it because I am calling the functions in Update() and it should be somewhere else! I want to refresh the result of the interaction when the light intensity or movement happened in the camera feed mainly in every frame. But I don't know how I can fix this issue!
here the part of the code where I call the necessary functions:
void LateUpdate()
{
if (CamFeedTexture.isPlaying)
{
if (CamFeedTexture.didUpdateThisFrame)
{
m_ConvertPanoramaToCubemap();
// m_CreateSkybox();
m_CreateCubemap();
Renderer rend = this.GetComponentInChildren<Renderer>();
foreach (Material m in rend.sharedMaterials)
{
if (m.HasProperty("_Cube"))
{
m.SetTexture("_Cube", m_Cubemap);
}
}
}
}
please help!