2014-08-24 13:56:23|?次阅读|上传:huigezrx【已有?条评论】发表评论
关键词:游戏, 虚拟现实, Unity3D|来源:唯设编程网
Unity Manual > Advanced > Shadows in Unity
Unity手册->高级->Unity中的阴影
Unity 2.0 Pro makes it possible to use real-time shadows on any light. Objects can cast shadows onto each other and onto parts of themselves ("self shadowing"). All types of Lights - Directional, Spot and Point - support shadows.
Unity2.0专业版本可能使用任何光线实时阴影。对象可以投射到对方,走上自己的阴影部分(“自我阴影”)。所有类型的光源-方向光源,聚光光源和点光源-支持阴影。
Using shadows can be as simple as choosing Hard Shadows or Soft Shadows on a Light. However, if you want optimal shadow quality and performance, there are some additional things to consider.
使用阴影可以很简单的选择上硬阴影或软阴影。不过,如果你想最佳的阴影质量和性能,还有一些额外的事情要考虑。
The Shadow Troubleshooting page contains solutions to common shadowing problems. 阴影疑难解答页包含解决公共问题的阴影。
Curiously enough, the best shadows are non-realtime ones! Whenever your game level geometry and lighting is static, just precompute lightmaps in your 3D application. Computing shadows offline will always result in better quality and performance than displaying them in real time. Now onto the realtime ones...
奇怪的是,最好的阴影是非实时的!每当你的游戏水平几何和照明是静态的,只要预先计算在您的3D应用光映射。离线阴影计算总是产生更好的质量和性能超过实时显示它们。现在,到实时的...
Tweaking shadow quality 调整阴影质量
Unity uses so called shadow maps to display shadows. Shadow mapping is a texture based approach, it's easiest to think of it as "shadow textures" projecting out from lights onto the scene. Thus much like regular texturing, quality of shadow mapping mostly depends on two factors:
Unity使用所谓的阴影图形显示阴影。阴影映射是一种基于纹理的方法,最简单的把它看成“阴影纹理”从光源里投射到场景上。因此,就像常规纹理,阴影映射的质量主要取决于两个因素:
Different Light types use different algorithms to calculate shadows. 不同的类型的光源使用不同的算法来计算阴影。
Details on how shadow map sizes are computed are in Shadow Size Details page.阴影图形尺寸的详情如何计算在阴影大小详细信息页。
Shadow performance 阴影性能
Realtime shadows are quite performance hungry, so use them sparingly. For each light to render its shadows, first any potential shadow casters must be rendered into the shadow map, then all shadow receivers are rendered with the shadow map. This makes shadow casting lights even more expensive than Pixel lights, but hey, computers are getting faster as well! 实时阴影要求相当高的性能,所以要适可而止。对于每一个光渲染的它自己的阴影,首先调整任何潜在的阴影都必须进入到阴影图形里,那么所有的阴影接收阴影图形渲染。这使得阴影投影甚至比像素光源昂贵。但是,嘿,电脑速度越来越快的!
Soft shadows are more expensive to render than Hard shadows. The cost is entirely on the graphics card though (it's only longer shaders), so Hard vs. Soft shadows don't make any impact on the CPU or memory.
软阴影是较昂贵的渲染比硬阴影。费用完全是图形卡,但(这只是长久的阴影),所以硬阴影与软阴影相比,不受任何CPU或内存的影响
Quality Settings contains a setting called Shadow Distance - this is how far from the camera shadows are drawn. Often it makes no sense to calculate and display shadows that are 500 meters away from the camera, so use as low shadow distance as possible for your game. This will help performance (and will improve quality of directional light shadows, see above). 质量设置包含一个名为阴影距离-这就是远距离摄像机阴影绘制。往往是没有意义的计算和显示阴影,有500米距离相机,因此使用尽可能低的阴影距离为你的游戏。这将有助于性能(和将提高定向阴影质量,见上文)。
Hardware support for shadows 硬件支持的阴影
Built-in shadows require a fragment program (pixel shader 2.0) capable graphics card. This is the list of supported cards: 内置阴影需要一个片断程序(支持Pixel Shader 2.0)的图形卡。这是支持的卡列表:
Notes 注释