移动设备的高级阴影和照明

Hello everyone. You have probably already heard about Shadowgun, the new mobile game developed by MADFINGER Games. You might also have seen Shadowgun being demoed at WWDC on stage during the Graphics State of the Union talk.

大家好。 你可能已经听说过SHADOWGUN ,通过开发新的手机游戏MADFINGER游戏 。 您可能还已经在《图形联盟状况》演讲期间在舞台上看到了Shadowgun在WWDC上的演示。

Needless to say, we’re very proud of the next great creation made in Unity, and we love how it delivers console quality to the mobile with the help of Unity’s awesome tech. It runs at an impressive 60fps on the iPad 2 and 30fps on the iPad, iPhone 4 & 3GS. It will also be released on Android. Since lighting is one of the main elements making the game look so good, here are some notes about the techniques we used.

不用说,我们为Unity的下一个伟大创造感到非常自豪,并且我们喜欢它如何借助Unity的出色技术为手机提供控制台质量。 它在iPad 2上以惊人的60fps的速度运行,在iPad,iPhone 4和3GS上以30fps的速度运行。 它还将在Android上发布。 由于照明是使游戏外观如此出色的主要因素之一,因此以下是有关我们使用的技术的一些注意事项。

字符底纹 (Character shading)

All characters in the game use the same per pixel normal mapped isotropic BRDF pixel shader, which goes beyond the usual Phong shading. It gives a great effect on the skin of the character, metal and cloth. Our solution combines off-line precomputed texture which describes how surface interacts with lighting and run-time per-pixel calculations to achieve both artistic control and superb performance.

游戏中的所有角色都使用相同的每像素法向映射的各向同性BRDF像素着色器,这超出了通常的Phong着色。 它对角色,金属和布料的皮肤产生很大的影响。 我们的解决方案结合了离线预先计算的纹理,该纹理描述了表面如何与光照交互以及运行时每像素计算,以实现艺术控制和出色的性能。

光探头 (Light probes)

shadowgun-green

Light probes are an advanced technique for lighting dynamic objects and characters with high-quality baked lighting. It is possible to capture incoming direct and bounced lighting within a scene at a number of points – light probes. As a character moves through the scene, nearby probes are picked, interpolated, and the result is then passed to the shader to efficiently light the surface. There it can be sampled per-vertex or per-pixel, if you want to use the normalmap-perturbed normal to do so.

光线探测器是一种先进的技术,可以通过高质量的烘烤照明来照亮动态物体和角色。 可以在场景中的多个点处捕获入射的直接和反射光–光探测器。 当角色在场景中移动时,将对附近的探针进行拾取,内插,然后将结果传递到着色器以有效地照亮表面。 如果要使用法线贴图扰动的法线,可以按顶点或每个像素对其进行采样。

Choosing and interpolating the right probes (and doing it fast!) is a hard problem, though. We have developed a technique, which takes an arbitrary set of probes and performs Delaunay tetrahedralization on them to divide the entire space into tetrahedron-shaped cells.

但是,选择和插值正确的探针(并快速完成!)是一个难题。 我们已经开发出一种技术,该技术可以使用任意一组探针并对它们执行Delaunay四面体化,以将整个空间划分为四面体形状的单元格。

Shadowgun_muzzle

That gives us fast interpolation with great properties and no light popping – when you’re in a given tetrahedron, weights for the four corner probes are your barycentric coordinates! Finding the right tetrahedron can also be done efficiently by checking the one from last frame – if it’s not a hit (most of the time it is!), we check it’s neighbours. Finally we make sure interpolation works outside of the volume of the probes just as fast and as good with a clever projection onto the hull surface.

这使我们能够快速插值,并具有出色的性能并且不会出现光弹-当您处于给定的四面体中时,四个角探针的权重就是您的重心坐标! 通过检查最后一帧中的四面体,也可以有效地找到正确的四面体–如果不是命中(大多数情况下是命中!),我们将其作为邻居。 最终,我们确保在探针体积之外进行插值的速度与在船体表面上的巧妙投影一样快且良好。

I’m especially proud of the light probes, since we managed to shape them up to be extremely fast and have low memory footprint – perfect even on mobiles and giving so much bang for the buck. As far as we know, it’s also the first time it has been used to such extent (at all?) on mobile devices.

我特别为光探头感到骄傲,因为我们设法将它们整形为极快的速度并具有低内存占用量-即使在移动设备上也非常完美,并且物有所值。 据我们所知,这也是在移动设备上第一次(完全如此)使用它。

枪口闪烁 (Muzzle flashes)

As a bonus, since we’re already rendering every character with a light probe, we can project any additional lights onto the probe as well. We do that for the muzzle flash effect. For a very low CPU cost and no GPU cost characters get lit by dynamic light.

另外,由于我们已经使用光探针渲染了每个角色,因此我们也可以将任何其他光投射到探针上。 我们这样做是为了使枪口具有闪光效果。 对于非常低的CPU成本并且没有GPU成本的字符,动态光照亮。

上帝的光芒,光轴,火光和雾 (God rays, light shafts, light flares and fog)

God rays, light shafts, light flares and fog are rendered using both static and animated alpha-blended geometry with very optimized vertex and pixel shaders to save fillrate.

使用静态和动画的alpha混合几何体渲染了上帝的光线,光轴,耀斑和雾,并具有非常优化的顶点和像素着色器,以节省填充率。

光照贴图 (Lightmaps)

Lightmaps were baked with one click in Unity using Beast to capture all the beautiful Global Illumination on static geometry. To give the objects a more detailed look while still keeping the shaders extremely fast, we calculate approximate specular reflections per vertex and then modulate them per pixel with a gloss mask to differentiate between shiny and rough parts. Reflective objects additionally use a pre-baked cube map matching the surroundings.

使用Beast在Unity中一键式烘焙光照贴图,以捕获静态几何体上所有美丽的全局照明。 为了在保持着色器极快的同时使对象更加详细,我们计算每个顶点的近似镜面反射,然后使用光泽蒙版对每个像素进行调制,以区分发亮的部分和粗糙的部分。 反射对象还使用与环境匹配的预烘焙立方体贴图。

焦散和字符阴影 (Caustics and character shadows)

Caustics from the light passing through the green fluid, character shadows and rotating ventilator shadows were simulated with textures projected onto tight geometry (to keep the fillrate requirements low) and then animated in the shaders.

通过将光投射到绿色流体,字符阴影和通风机旋转阴影的焦散,将纹理投影到紧密的几何体上(以保持较低的填充率要求),然后在着色器中进行动画处理。

shadowgun-in-game-unity

We plan to release light probes with Unity 3.5; all the other effects can already be achieved in Unity! :)

我们计划使用Unity 3.5发布光探头; 所有其他效果都可以在Unity中实现! :)

翻译自: https://blogs.unity3d.com/2011/06/08/advanced-shading-and-lighting-for-mobile/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值