光照计算无疑是Unity3D Shader 开发的重中之重,而了解Unity3d提供的光照计算数据,函数,和提供规则,无遗是光照计算的基础,在下目前在边学边整理这个表格,有好的资料,也希望有人可以提供连接大家互相交流。
渲染路径下的特别设置 |
||||||
VertexLit |
ForwardBase |
ForwardAdd |
Defferred |
ShadowCaster |
||
UnityLightingCommon.cginc |
||||||
fixed4 _LightColor0 |
当前排序第1个pixel光源的光源颜色。
扫描二维码关注公众号,回复:
2739070 查看本文章
|
无数据 |
有数据 |
有数据 |
未知 |
|
UnityShaderVariables.cginc |
||||||
float4 unity_4LightPosX0 |
当前排序头4个pixel光源在世界空间下的坐标的x分量 |
无数据 |
||||
float4 unity_4LightPosY0 |
当前排序头4个pixel光源在世界空间下的坐标的x分量 |
无数据 |
||||
float4 unity_4LightPosZ0 |
当前排序头4个pixel光源在世界空间下的坐标的x分量 |
无数据 |
||||
half4 unity_4LightAtten0 |
当前排序头4个pixel光源的衰减系数 |
无数据 |
||||
float4 unity_LightPosition[8] |
当前排序的前8个光源在View空间下的位置或方向 w=0 为点光源或聚光灯 xyz 为光源位置 w=1 为方向光 xyz 为光源的方向量的反方向 |
|||||
half4 unity_LightColor[8] |
当前排序的前8个光源的颜色 |
|||||
half4 unity_LightAtten[8] |
当前排序的前8个光源的衰减 x = cos(spotAngle/2) or -1 for non-spot y = 1/cos(spotAngle/4) or 1 for non-spot z = quadratic attenuation w = range*range |
|||||
float4 unity_SpotDirection[8] |
当前排序的前8个光源在View空间下的方向 聚光灯光源为聚光灯方向 非聚光灯光源值为(0,0,1,0) |