LWRP has GetMainLight() does HDRP have an equivalent? Or is there another way to get the same info?
There isn’t a similar magic method in HDRP to do this, instead I had to create a class that would set some Global variables
public class ShaderGlobals : MonoBehaviour
{
[SerializeField] Light mainLight;
void Start()
{
Shader.SetGlobalVector("_MainLightDirection", mainLight.transform.forward);
Shader.SetGlobalFloat("_MainLightAttenuation", mainLight.range);
Shader.SetGlobalColor("_MainLightColor", mainLight.color);
}
}
And then in the shader graph create the three properties of the correct type, and rename their references to be the same as the global variables I’ve set, and untick exposed.
https://gyazo.com/92a8d7b07c46e32fa3571057d32528bc
4 Likes
Thank you sir
1 Like
Does anyone have a way to also apply this to point / spot lights etc?