|void GetMainLightData_float(out half3 direction, out half3 color, out half distanceAttenuation, out half shadowAttenuation)|
|// In Shader Graph Preview we will assume a default light direction and white color|
|direction = half3(-0.3, -0.8, 0.6);|
|color = half3(1, 1, 1);|
|distanceAttenuation = 1.0;|
|shadowAttenuation = 1.0;|
|// Universal Render Pipeline|
|// GetMainLight defined in Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl|
|Light mainLight = GetMainLight();|
|direction = -mainLight.direction;|
|color = mainLight.color;|
|distanceAttenuation = mainLight.distanceAttenuation;|
|shadowAttenuation = mainLight.shadowAttenuation;|
|// ToDo: make it work for HDRP (check define above)|
|// if (_DirectionalLightCount > 0)|
|// DirectionalLightData light = _DirectionalLightDatas;|
|// lightDir = -light.forward.xyz;|
|// color = light.color;|
No, I haven't looked at it since. But it shouldn't be to hard, I think the comments get point in the right direction..
You can hack around the HDRP issue by creating a component to sample your Sun Light. Once you have your component just sample the properties you want and set global variables. Then, in your shaders create the global properties that the component can write to.
Look up the Shader.SetGlobal* methods for setting those global property types.
I have this setup in my project and it works like a charm.