Search Unity

_DirectionalLightDatas changes order depending on intensity

Discussion in 'High Definition Render Pipeline' started by TimDoesDev, Jan 28, 2021.

  1. TimDoesDev

    TimDoesDev

    Joined:
    Feb 23, 2018
    Posts:
    35
    Hi! For the love of god I'm going insane so please help me. I'm trying to make a procedural skybox shader and I'm using 2 directional lights, one for sun and one for moon. Needless to say I wanna control the intensity so that the moon increases when it is night and I wanna decrease the intensity on the sun when it goes down etc.

    Now in the code I'm using

    Code (CSharp):
    1. for (uint i = 0; i < _DirectionalLightCount; i++)
    2.             {
    3.                 light = _DirectionalLightDatas[i];
    4.                 break;
    5.             }
    to get the lightdata. Problem is that the order in _DirectionalLightDatas changes based on intensity which makes it impossible for me to know which light data is connected to what directional light. Is there any way to actually figure this out or to stop it from changing order depending on which light has the highest intensity?

    Thanks,
    Tim