淺談Unity 5.4新功能:Light Probe Proxy Volume
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了淺談Unity 5.4新功能:Light Probe Proxy Volume,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3902字,纯文字阅读大概需要6分钟。
内容图文
Unity 5.4進入到Beta的階段。当中一個特別的功能是光照探頭代理Light Probe Proxy Volume(LPPV)。本篇會向大家介紹什麼是LPPV,並介紹它怎样運作
對Unity5.4beta有興趣能够從這裡下載,必須有Pro的序號才干使用。
什麼是光照探頭代理
怎样使用LPPV元件
使用LPPV元件必須要跟著一組光探頭組(Light Probe Group)。能够從 Component -> Rendering -> Light Probe Proxy Volume找到它,在預設情況下。這個元件看起來是這樣:
這個元件须要加到像是有網格甚至光照探頭組的遊戲物件中,想要用到LPPV的物件须要有MeshRenderer或者Renderer元件。並將Light Probes屬性設為“Use Proxy Volume”。
你能够透過指定Proxy Volume Override來使用其他GameObject上的LPPV元件。仅仅需拖放這個物件到不论什么你想要使用它的Renderer元件的屬性裡。
比如:將LPPV元件加到光照探頭組物件中,那麼你就能够透過Proxy Volume Override屬性在全部Renderer元件中共用它:
設定邊界:
- Automatic Local
- Automatic World
- Custom
Automatic Local:預設屬性,邊界會在本地空間內計算,插值光探頭位置將在這個範圍內產生。計算包括Renderer和它底下階層全部有設定Use Proxy Volume的Renderer元件,Automatic World也是一樣算法。
這兩種選項應該與Proxy Volume Override屬性配合使用在其他的Renderer元件上。另外你也能够將同一個LPPV元件指定到最上層的父物件來使全部下層的物件使用這個LPPV元件。
World和Local的區別在於,在Local模式下當一個階層太多的子物件嘗試使用父物件的LPPV元件會在計算邊界時比较耗效能,但計算出來的邊界尺寸也許會更小,那麼光照資料就會更確實。
Custom:這個模式能用工具來自訂邊界,從場景裡直接編輯或是從inspector介面來改动大小。這個模式邊界是在物件的本地空間中設定的,所以你须要確定全部帶有Renderer元件的物件都要在LPPV的範圍內。
設置解析度/密度:
設定完邊界之後,你還须要考慮代理的密度和解析度。在Resolution Mode底下有兩個選項:
Automatic:自動 - 預設屬性。用來給密度設定一個值,比如每單位的探頭數量。每單位在X,Y,Z軸上的探頭數量計算,數量取決於邊界大小。
Custom:自訂 - 用下拉式功能表來設定X,Y,Z軸上解析度的值。值從1开始以2的次方遞增最大到32,所以你最多能够有32x32x32 個內插(Interpolation)探頭
使用LPPV時效能的考量:
請記住每批64個內插光探頭的內插計算大概须要0.15毫秒的CPU運算(i7-4Ghz)(用Profiler觀察的數據)。光探頭內插計算能够是多執行緒的,但不论什么小於或等於64個內插光照探頭不會用多緒而仅仅在主執行緒中執行。
所以當你使用Unity內建的Profiler在Timeline視圖你會看到BlendLightProbesJob在主執行緒上,假设你將內插光探頭數量添加到超過64個,你就會在工作執行緒上看到BlendLightProbesJob:
當仅仅有一批次的64個內插光探頭時將仅仅會在主執行緒上計算,當有多個批次(大於64)的時候仅仅會在主執行緒上計算一批,其他的會分配到工作執行緒上。但這個行為仅仅針對單個LPPV。
假设你有多個LPPV,並且都少於64個內插光探頭的話。那他們都會主執行緒上運作。
硬體需求:
使用ShadeSHPerPixel的粒子系統著色器的範例:
Unity的標準著色器是支援這個功能的。但假设你想使用自訂Shader。能够用ShadeSHPerPixel函式。
這個範例說明怎样使用這個函式:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
Shader
"Particles/AdditiveLPPV"
{
Properties
{
_MainTex
(
"Particle
Texture"
,
2D) =
"white"
{}
_TintColor
(
"Tint
Color"
,
Color) = (0.5,0.5,0.5,0.5)
}
Category
{
Tags
{
"Queue"
=
"Transparent"
"IgnoreProjector"
=
"True"
"RenderType"
=
"Transparent"
}
Blend
SrcAlpha One
ColorMask
RGB
Cull
Off Lighting Off ZWrite Off
SubShader
{
Pass
{
CGPROGRAM
#pragma
vertex vert
#pragma
fragment frag
#pragma
multi_compile_particles
#pragma
multi_compile_fog
//
Don’t forget to specify the target
#pragma
target 3.0
#include
"UnityCG.cginc"
//
You have to include this header to have access to ShadeSHPerPixel
#include
"UnityStandardUtils.cginc"
fixed4
_TintColor;
sampler2D
_MainTex;
struct
appdata_t
{
float4
vertex : POSITION;
float3
normal : NORMAL;
fixed4
color : COLOR;
float2
texcoord : TEXCOORD0;
};
struct
v2f
{
float4
vertex : SV_POSITION;
fixed4
color : COLOR;
float2
texcoord : TEXCOORD0;
UNITY_FOG_COORDS(1)
float3
worldPos : TEXCOORD2;
float3
worldNormal : TEXCOORD3;
};
float4
_MainTex_ST;
v2f
vert (appdata_t v)
{
v2f
o;
o.vertex
= UnityObjectToClipPos(v.vertex);
o.worldNormal
= UnityObjectToWorldNormal(v.normal);
o.worldPos
= mul(unity_ObjectToWorld, v.vertex).xyz;
o.color
= v.color;
o.texcoord
= TRANSFORM_TEX(v.texcoord,_MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return
o;
}
fixed4
frag (v2f i) : SV_Target
{
half3
currentAmbient = half3(0, 0, 0);
half3
ambient = ShadeSHPerPixel(i.worldNormal, currentAmbient, i.worldPos);
fixed4
col = _TintColor * i.color * tex2D(_MainTex, i.texcoord);
>col.xyz
+= ambient;
UNITY_APPLY_FOG_COLOR(i.fogCoord,
col, fixed4(0,0,0,0));
//
fog towards black due to our blend mode
return
col;
}
ENDCG
}
}
}
}
|
原文:https://www.cnblogs.com/llguanli/p/8367178.html
内容总结
以上是互联网集市为您收集整理的淺談Unity 5.4新功能:Light Probe Proxy Volume全部内容,希望文章能够帮你解决淺談Unity 5.4新功能:Light Probe Proxy Volume所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。