Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

_DirectionalLightDatas changes order depending on intensity

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

  1. focuslabstudios


    Feb 23, 2018
    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?