How the get the lighting data from the skybox?

Hello,

I am freshman to the Unity3d shader. I am writing a custome unlit shader now. I know I can use normalize(_WorldSpaceLightPos0.xyz) to get the direction of a directional light source, and use float attenuation = LIGHT_ATTENUATION(i); float3 attenColor = attenuation * _LightColor0.rgb; to get the radiance(Li) of the light. Finally I can use Li*my_custome_brdf to render a material.

However, if I have a skybox instead of a light source, how can I get the light information? The radiance(Li) is coming from my skybox now. How can I get the value of them and compute Li*my_custome_brdf?

Thanks

Skybox lighting is generally used as an ambient factor in combination with directional lighting (for shadow support, etc). However, if you want to directly access the ambient contribution of the skybox, you can do so with the following function;

//Where 'normal' is the surface normal in world-space
half4 skylight = ShadeSH9 (half4 (normal, 0));

Whilst that is the correct way of writing it, for whatever reason the Unity documentation has it written as;

ShadeSH9 (half4 (normal, 1));

So if the first doesn’t quite look right, try the second.