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
Answer by Namey5 · Jan 09, 2019 at 09:48 AM
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.
Your answer
Follow this Question
Related Questions
i wanna draw inside like outside. shader.... 1 Answer
Getting Color Generated from Shader to Script to Shader 0 Answers
A public list of color in shader. 0 Answers
What is the difference between Semantic POSITION and SV_POSITION both 0 Answers
How do i get a shader to affect every object with the same material? 0 Answers