Although lightmapping adds greatly to the realism of a scene, it has the disadvantage that non-static objects in the scene are less realistically rendered and can look disconnected as a result. It isn't possible to calculate lightmapping for moving objects in real time but it is possible to get a similar effect using light probes. The idea is that the lighting is sampled at strategic points in the scene, denoted by the positions of the probes. The lighting at any position can then be approximated by interpolating between the samples taken by the nearest probes. The interpolation is fast enough to be used during gameplay and helps avoid the disconnection between the lighting of moving objects and static lightmapped objects in the scene. 尽管使用光照贴图可以大大提升场景的真实程度,但是它有一个缺点,那就是场景中非静态物体缺少真实的渲染,看上去就好像和场景格格不入。实时为移动物体计算光照贴图是不可能的,但是通过使用灯光探测器我们可以模拟达到类似的效果。大概原理是这样的,在场景中的标记为探测器的静态点的位置采样光照,然后对相邻的几个光照探测器位置所采样的灯光照明进行差值,在游戏进行的过程中计算差值的速度很快,玩家察觉不到。这样就可以帮助我们避免移动物体的光照和烘培场景格格不入的感觉。 Adding Light probes 添加灯光探测器The Light Probe Group component (menu: Component -> Rendering -> Light Probe Group) can be added to any available object in the scene. The inspector can be used to add new probes to the group. The probes appear in the scene as yellow spheres which can be positioned in the same manner as GameObjects. Selected probes can also be duplicated with the usual keyboard shortcut (ctrl+d/cmd+d). 灯光探测器组 组件(菜单:Component -> Rendering -> Light Probe Group)可以被添加到场景中任何可利用的物体。可以通过检视面板为探测器组中添加新的探测器。探测器在场景中用黄色的球体表示,并且可以像其他游戏物体那样编辑移动它的位置,被选择的探测器可以通过键盘快捷键进行复制。(ctrl+d/cmd+d). Choosing Light Probe positions 选择灯光探测器位置Remember to place probes where you want to sample light or sample darkness. The probes need to form a volume within the scene for the space subdivision to work properly. 记得放置好你的灯光探测器的位置,哪里是照亮的地方,哪里是黑暗的地方。场景中的探测器需要达到一定的数量才能烘培,这样做的目的是场景能够被合理的细分。 The simplest approach to positioning is to arrange them in a regular 3D grid pattern. While this setup is simple and effective, it is likely to consume a lot of memory (each light probe is essentially a spherical, panoramic HDR image of the view from the sample point). It is worth noting that probes are only needed for regions that players, NPCs or other dynamic objects can actually move to. Also, since lighting conditions are interpolated for positions between probes, it is not necessary to use lots of them across areas where the light doesn't change very much. For example, a large area of uniform shadow would not need a large number of probes and neither would a brightly lit area far away from reflective objects. Probes are generally needed where the lighting conditions change abruptly, for instance at the edge of a shadow area or in places where pieces of scenery have different colors. 最简单的探测器定位方式是将探测器排列成一个规则的3D网格样式,这样设置简单而高效,但是会消耗大量的内存。(从采样点每个灯光探测器本质上是一个球形的,全景的HDR图像)。值得注意的是,探测器仅用于实际上可以移动到所需地区的玩家、NPC或其他动态物体。此外,由于光照条件下插值探测器之间的位置,没有必要使用大量跨区域,灯光不会改变太多。例如,大面积均匀的阴影也不太明亮的区域远离反射物体不会需要大量的探测器。探测器一般需要照明条件的突然改变,比如在一个阴影区的边缘或在背景块的位置有不同的颜色。 In some cases, the infrastructure of the game can be useful in choosing light probe positions. For example, a racing game typically uses waypoints around the track for AI and other purposes. These are likely to be good candidates for probe positions and it would likely be straightforward to set these positions from an editor script. Similarly, navigation meshes typically define the areas that can be reached by players and these also lend themselves to automated positioning of probes. 在这种情况下, 游戏中的一些基础设施可以被用来作为生成光照探测器的位置参考。例如在赛车游戏中通常我们会在赛道上设置路径点,供AI或者其他方面使用。这些路径点位置就是生成光照探测器的绝佳参考物体。通过编辑器脚本我们可以利用这些资源简单高效的生成理想的光照探测器。同样,地形网格通常被用来规定玩家可以到达的地方。我们也可以利用他们来自动生成光照探测器的位置。 Here light probes have been baked over surfaces where our characters can walk on, but only where there are interesting lighting changes to capture: 这里我们在角色可以走过的物体表面烘培了光照探测器。但仅仅在有光照变化的地方进行光照信息的捕捉。 Flat 2D levels 平面化As it is now, the light probe system can't bake a completely flat probe cloud. So even if all your characters move only on a plane, you still have to take care to position at least some probes in a higher layer, so that a volume is formed and interpolation can work properly. 目前光照探测器系统无法烘培使用完全平面的探测器集。所以,即使你所有的角色只在一个平面上移动,你仍然需要照顾位置至少有一些探测器在一个更高的位置。这有这样布局探测器才能有效的工作。
Good: This is the original probe placement. The characters can move up the ramps and up onto the boxes, so it's good to sample lighting up there as well.
好:这是原始的探测器的定位,角色可以爬上斜坡到盒子上面。这样悲剧可以使上面的光照得到更好的采样。
Good: Here we assume the characters can only move on the plane. Still, there's a couple of probes placed a little bit higher, so that a volume is formed and thin cell are avoided.
好:我们假设角色只在下面的平面上移动。我们仍然将几对探测器的位置定位的略微高一点点。不过我们尽量避免产生细长的差值空间。
Bad: The probes are placed too flat, which creates really long and thin cells and produces unintuitive interpolation results.
坏:探测器几乎定位在了一个水平面上,这样会产生很多长而细的差值空间,在做灯光差值计算的时候产生非常遭的效果。 Using Light Probes 使用灯光探测器To allow a mesh to receive lighting from the probe system, you should enable the Use Light Probes option on its MeshRenderer: 如果想要使一个网格接受来自探测器系统的光照,只需要将MeshRenderer组件上个LightProbes选项勾选就可以。 The probe interpolation requires a point in space to represent the position of the mesh that is receiving light. By default, the centre of the mesh's bounding box is used but it is possible to override this by dragging a Transform to the MeshRenderer's Light Probe Anchor property (this Transform's position will be used as the interpolation point instead). This may be useful when an object contains two separate adjoining meshes; if both meshes are lit individually according to their bounding box positions then the lighting will be discontinuous at the place where they join. This can be prevented by using the same Transform (for example the parent or a child object) as the interpolation point for both MeshRenderers. 探测器差值需要使用空间中的一点来表示接受灯光的网格的位置。通常情况下使用包围盒的中心来表示。我们也可以使用自定义的位置覆盖默认的位置只需要将一个Transform(变换)拖拽到MeshRenderer组件的 LightProbeAnchor(光照探测器锚点)插槽上。(这个Transform的位置将被用来表示计算差值的物体中心点)。当我们的游戏物体是由两个分离的相邻网格组成的时候,这个功能非常有用,如果这个这些网格都按照各自独立的包围盒中心作为光照差值点的时候,光照会在他们结合的位置断开。这也能使由多个MeshRenderer组件的组成的游戏物体公用一个Transform(比如使用一个父物体或者子物体)。 When an object using light probes is the active selected object in the Light Probes Scene View mode, its interpolated probe will be rendered on top of it for preview. The interpolated probe is the one used for rendering the object and is connected with 4 thin blue lines (3 when outside of the probe volume) to the probes it is being interpolated between: 当一个使用了光照探测器的物体在Light Probes Scene View(在场景中查看光照探测器)。模式下被高亮选择以后,它的差值探测器将被渲染到物体的前面这样用户就能够预览到探测器的位置。差值探测器通常被渲染为一个物体,并在探测器的差值范围内显示四条蓝色的线(当物体超出探测器的覆 的范围后将显示三条)。 Dual Lightmaps vs. Single Lightmaps mode
双重光照贴图VS单光照贴图模式In Single Lightmaps mode all static lighting (including lights set to 'Auto' lightmapping mode) is baked into the light probes. 在单光照贴图模式下所有的静态光照(包括被设置为"Auto"(自动)光照贴图模式的灯光)都将烘培到光照探测器中。 In Dual Lightmaps mode light probes will store lighting in the same configuration as 'Near' lightmaps, i.e. full illumination from sky lights, emissive materials, area lights and 'Baked Only' lights, but only indirect illumination from 'Auto' lights. Thanks to that the object can be lit in real-time with the 'Auto' lights and take advantage of dynamic elements such as real-time shadows, but at the same time receive indirect lighting added to the scene by these lights. 使用双重光照贴图模式的,灯光探测器只存贮了"Near"(近端)光照贴图配置。例如:天光产生的全局光照,自发光材质,面积光和被是设置为"Baked Only"(仅烘培)模式的灯光。和被设置为"Auto"模式的间接照明。我们要感谢物体可以被设置为"Auto"模式的灯光实时照明。并且产生一些高级的动态成分。例如实时阴影,同时接受探测器存贮的这些灯光的间接光照信息并叠加到场景中。
|