基于光照的物理模型(一)_使用基于物理的阴影:一种实用方法

基于光照的物理模型(一)

Throughout the development of Unity 5, we’ve used our Viking Village project internally as a testing ground for shading and lighting workflows.

在Unity 5的整个开发过程中,我们内部一直在使用Viking Village项目作为着色和照明工作流程的测试场。

If you’re using the Unity 5 beta, you can download the Viking Village package from the Asset Store to get insights into how you can assemble and illuminate a scene in Unity 5. We also present some of our learnings below.

如果您正在使用Unity 5 beta,则可以从Asset Store下载Viking Village软件包,以深入了解如何在Unity 5中组装和照明场景。我们还将在下面提供一些学习内容。

创建模板环境 (Creating a template environment)

In order to ensure that your texturing and shader configuration is behaving appropriately, we recommend that you use a simple scene with a variety of lighting setups. This could mean differing skyboxes, lights etc – anything that contributes to illuminating your model.

为了确保您的纹理和着色器配置正确地表现,我们建议您使用具有各种照明设置的简单场景。 这可能意味着不同的天空盒,灯光等–有助于照亮模型的任何东西。

When you open Unity 5, you’ll notice that any new empty scene has a procedural sky as well as default ambient and reflection settings. This provides a suitable starting point.

打开Unity 5时,您会注意到任何新的空白场景都有程序天空以及默认的环境和反射设置。 这提供了合适的起点。

lightcond5fr640x480loop.1

For our template environment we used:

对于我们的模板环境,我们使用:

  • HDR camera rendering

    HDR相机渲染

  • A few scattered reflection probes (for localized reflections on objects)

    一些分散的反射探针(用于对象的局部反射)

  • A group of light-probes

    一组光探针

  • A set of HDR sky-textures and materials, as well as procedural skies. The sky which ships with this project was custom-made for Unity by Bob Groothuis, author of Dutch Skies 360.

    一组HDR天空纹理和材质以及程序天空。 此项目附带的天空是由荷兰天空360的作者Bob Groothuis为Unity定制的。

  • Off-white directional lights with matched intensity and HDR sky color

    灰白色定向灯,具有匹配的强度和HDR天空色

调整天空纹理全景 (Adjusting sky texture panoramas)

Most sky textures include the sun (along with flares etc.), thus, light from the sun gets reflected by surfaces. This has the potential to cause three issues:

大多数天空纹理包括太阳(以及耀斑等),因此,来自太阳的光会被表面反射。 这有可能导致三个问题:

1) The Directional light you use to represent the sun must match the exact direction of the sun painted onto the skybox or there will be multiple specular hotspots on the material.

1)用于表示太阳的定向光必须与绘制在天窗上的太阳的确切方向匹配,否则材质上将存在多个镜面反射热点。

2) The reflected sun and the specular hotspot overlap, causing intense specular highlights.

2)反射的太阳和镜面反射热点重叠,导致强烈的镜面反射高光。

3) The baked-in sun reflection is not occluded when the surface is in shadow and it becomes overly shiny in darkness.

3)当表面处于阴影中并且在黑暗中变得过于发亮时,不会遮挡烘烤的阳光反射。

image11

The sun is erased from the sky texture and re-added using a directional light and a lens flare.

太阳从天空纹理中删除,然后使用定向光和镜头眩光重新添加。

As a result, the sun highlight, flares, sunrays and HDR values need to be edited out of the sky texture and reapplied using Directional Lights.

因此,需要从天空纹理中编辑高光,耀斑,阳光和HDR值,并使用定向光重新应用。

创作基于物理的着色材料 (Authoring physically-based shading materials)

To avoid the guesswork involved in emulating real world materials, it is useful to follow a reliable known reference.The Standard Shader supports both a Specular Color and a Metallic workflow. They both define the color of the reflections leaving the surface. In the Specular workflow, color is specified directly, whilst in the Metallic workflow, the color is derived from a combination of the diffuse color and the metallic value set in the Standard Shader controls

为避免在模拟真实世界的材料时涉及的猜测,遵循可靠的已知参考很有用。“标准着色器”同时支持“镜面反射颜色”和“金属”工作流程。 它们都定义了离开表面的反射的颜色。 在“镜面反射”工作流程中,直接指定颜色,而在“金属”工作流程中,颜色是从漫反射颜色和在“标准着色器”控件中设置的金属值的组合得出的

For the Viking Village project, we used the Standard Shader’s Specular Color Workflow. Our calibration scene, which you can download from the Asset Store, includes some handy calibration charts. We referenced the charts regularly when designing our materials.

对于Viking Village项目,我们使用了标准着色器的镜面反射颜色工作流程。 您可以从Asset Store下载的校准场景包括一些方便的校准图。 在设计材料时,我们会定期参考图表。

When approaching materials you can choose between what we call the Specular and the Metallic workflows, each with its own set of values and a reference chart. In the Specular workflow you choose the color of the specularly reflected light directly, in the metallic workflow you choose if the material behaves like a metal when it is illuminated.

处理材料时,您可以在我们称为“镜面”工作流程和“金属”工作流程之间进行选择,每个工作流程都具有自己的一组值和一个参考图。 在“镜面反射”工作流程中,您可以直接选择镜面反射光的颜色,在金属工作流程中,可以选择当材质在照明时是否像金属一样工作。

The specular value chart:

高光值图表:

UnitySpecularChart

The metallic value chart:

金属价值图:

UnityMetallicChart

Aside from charts and values, gathering samples of real world surfaces is highly valuable. It is of great help to find the surface type you are trying to imitate and try to get an understanding of how it reacts to light.

除了图表和值外,收集现实世界表面的样本非常有价值。 找到您要模仿的表面类型并试图了解它对光的React有很大的帮助。

设置材料 (Setting up the material)

When starting out, it’s often useful to create a plain but tweakable representation of the materials using colors, values and sliders derived from the calibration charts. Then, you can apply textures while keeping the original material as a reference to confirm that characteristics are preserved.

开始时,通常使用从校准图得出的颜色,值和滑块创建材料的简单但可调整的表示形式,这很有用。 然后,您可以在保留原始材质作为参考的同时应用纹理,以确认保留了特性。

materialcompare_refl.1

Top row: untextured. Bottom row: textured. Left to right: Rock, Wood, Bone, Metal.

第一行:无纹理。 下排:纹理。 从左到右:岩石,木材,骨头,金属。

创建纹理的传统方法 (The traditional approach to creating textures)

Textures in the Viking Village have been authored using both manual-traditional methods (photos + tweaking) as well as through scanned Diffuse/albedo, specular-, gloss and normal map images which were provided to us by Quixel.

维京村的纹理是使用手动传统方法(照片+调整)以及由Quixel提供给我们的扫描的漫反射/反照率,镜面反射,光泽和法线贴图图像创作的

Be careful when adding detail in the texture channels of the material. For example, it usually pays to avoid placing lighting (Ambient Occlusion, shadows etc.) in your textures: remember that the physically based rendering approach provides all the lighting you should need.

在材质的纹理通道中添加细节时要小心。 例如,通常需要避免在纹理中放置照明(环境光遮挡,阴影等):请记住,基于物理的渲染方法可提供所需的所有照明。

Naturally, retouching photographs is more demanding than using scanned data, specially when it comes to PBS-friendly values. There are tools that provide assistance to make the process easier, such as Quixel Suite and Allegorithmic Substance Painter.

自然,与使用扫描数据相比,修饰照片的要求更高,尤其是在涉及PBS友好值方面。 有一些工具可以帮助简化过程,例如Quixel SuiteAllegorithmic Substance Painter

扫描数据 (Scanned data)

PBS-calibrated scanned textures alleviate the need for editing, since data is already separated into channels and contains values for albedo, specular and smoothness. It is best if the software that provides the PBS-calibrated data contains a Unity profile for export. You can always use the reference charts as a sanity check and as a guide if you need to calibrate the values using Photoshop or a related tool.

PBS校准的扫描纹理减轻了编辑的需要,因为数据已经被分成通道,并且包含反照率,镜面反射率和平滑度的值。 最好是提供PBS校准数据的软件包含要导出的Unity配置文件。 如果需要使用Photoshop或相关工具来校准值,则始终可以将参考图用作健全性检查和指南。

材料实例 (Material examples)

The Viking Village Scene features a large amount of content while trying to stay within reasonable texture memory consumption. Let’s take a look at how we set up a 10-meter-high wooden crane as an example.

Viking Village Scene具有大量内容,同时试图保持合理的纹理内存消耗。 让我们以如何设置一个10米高的木制起重机为例。

Notice that many textures, especially specular and diffuse textures, are homogenous and require different resolutions.

请注意,许多纹理(尤其是镜面和漫反射纹理)是同质的,需要不同的分辨率。

image10
Example1: This Crane object has 2 materials: 2 diffuse, 1 specular-smoothness, 2 occlusion and 2 detailed textures.
示例1:这个Crane对象具有2种材质:2种漫反射,1种镜面平滑度,2种遮挡和2种详细纹理。
image06
Example 2: The shield prop has 1 material: 1 diffuse, 1 specular-smoothness, 1 occlusion and no detailed textures. 示例2:防护道具具有1种材料:1种漫反射,1种镜面光滑度,1种遮挡并且没有详细的纹理。
Screen Shot 2015-02-17 at 17.12.23
On the left: Crane Inspector for both materials. Rightmost is the shield prop material.
左侧:两种材料的Crane Inspector。 最右边是盾牌道具材料。
    vv albedo texture
    Painted Crane Diffuse Map snippet with plain wooden color and intensity. Contains a modest amount of detail. Right image: Shield Diffuse texture with higher (ppi) unique detail.
    Diffuse value (no texture) for crane material
    vv反照率纹理
    涂漆的起重机漫射贴图片段具有纯木制颜色和强度。 包含少量细节。 右图:具有更高(ppi)独特细节的Shield Diffuse纹理。 起重机材料的扩散值(无纹理)
    • Specular: Non-metals (insulators) are comparatively dark and in grayscale while metal values are bright and could be colored (remember that rust, oil and dirt on a metal are not metallic). Specular for the wood surface did not benefit extensively from a specular texture, so a value was used instead of inputting a map.

      镜面反射:非金属(绝缘体)相对较暗,呈灰度,而金属值较亮且可以着色(请记住,金属上的锈,油和污垢 不是 金属)。 木质表面的镜面反射并没有从镜面反射纹理中广泛受益,因此使用值代替输入贴图。

    image07
    Crane Specular values for wood. 起重机的木材镜面反射值。
    Screen Shot 2015-02-17 at 17.40.23
    Crane Specular map for metal (not using metallic shader). Right: Shield Specular texture.
    起重机的金属镜面贴图(不使用金属着色器)。 右图:Shield Specular纹理。
    • Smoothness is a key element in PBS materials. It contributes variation, imperfections and detail to surfaces and helps represent their state and age. For the crane, smoothness happened to be fairly constant across the surface and was therefore substituted by a value. This delivered a reasonable texture memory gain.

      光滑度是PBS材料的关键要素。 它有助于表面的变化,缺陷和细节,并有助于表示其状态和年龄。 对于起重机,光滑度在整个表面上都相当恒定,因此被一个值代替。 这提供了合理的纹理存储增益。

    image05
    Crane Smoothness values for wood. No textures required!
    木材的起重机平整度值。 不需要纹理!
    Screen Shot 2015-02-17 at 17.51.13
    Crane Smoothness map for metal (not using metallic shader). Right: Shield Smoothness map with mixed metal and wood surfaces.
    金属的“起重机平滑度”贴图(不使用金属着色器)。 右:混合金属和木质表面的“盾牌平滑度”贴图。
    • Occlusion indicates how exposed different points of the surface are to the light of the surrounding environment. Ambient Occlusion brings out surface detail and depth by muting ambient and reflection in areas with little indirect light.
      Keep in mind that there’s also the option of using SSAO (Screen Space Ambient Occlusion) in your scene. Using SSAO and AO could result in double darkening of certain areas, in which case you may want to consider treating the AO map as a cavity map.
      An AO map that would emphasise deep cracks and creases may be the best option if the game uses SSAO and/or lightmapped Ambient Occlusion.

      遮挡表示表面的不同点如何暴露于周围环境的光线。 环境光遮蔽通过在几乎没有间接光的区域中使环境和反射静音来展现表面细节和深度。
      请记住,场景中还可以选择使用SSAO(屏幕空间环境光遮挡)。 使用SSAO和AO可能会使某些区域变暗,在这种情况下,您可能需要考虑将AO贴图视为 空腔贴图
      如果游戏使用SSAO和/或光照映射的环境光遮挡,则强调深层裂缝和折痕的AO地图可能是最佳选择。

    image01

    1 Lightmapped AO, 2: Occlusion texture, 3: Occlusion in Diffuse, 4: Image effect SSAO 

    1光照贴图AO,2:遮挡纹理,3:漫射遮挡,4:图像效果SSAO

    次要纹理和分辨率 (Secondary Textures and resolution)

    Secondary Textures can be used to increase the level of detail or provide variation within the material. They can be masked using the Detail Mask property.

    次要纹理可用于增加细节级别或提供材质内的变化。 可以使用“详细蒙版”属性对它们进行蒙版。

    Due to the low resolution primary diffuse wood texture in the Crane example, the secondary texture set is crucial. It adds the fine detail to the final surface. In this instance, the detail-maps are tiled and at a reasonably low resolution. They are repeated on many other wooden surfaces, thus delivering a major texture memory saving.

    由于在Crane示例中低分辨率的主要漫射木材纹理,因此次要纹理集至关重要。 它将精细的细节添加到最终表面。 在这种情况下,细节图将以较低的分辨率平铺。 它们可以在许多其他木质表面上重复使用,从而节省了大量的纹理记忆。

    image20
    Secondary albedo- and normal maps compensate for the low-resolution main diffuse and normal map. Both textures reduce overall texture memory by being widely “overlayed” and tiled on wooden surfaces throughout the village. Be cautious when providing lighting information to a diffuse detail map as it this has a similar effect to adding such information to primary diffuse.

    次要的反照率和法线贴图补偿了低分辨率的主漫反射图和法线贴图。 两种纹理都被广泛地“覆盖”并铺在整个村庄的木质表面上,从而降低了整体纹理记忆。 向漫反射细节贴图提供照明信息时请务必谨慎,因为这与将此类信息添加到主要漫反射中具有相似的效果。

    image16
    Crane wooden surface with (left) and without (right) secondary texture maps. 使用(左)和不使用(右)辅助纹理贴图来起重机木表面。

    These workflows certainly helped us when designing the Viking Village project. We hope you also find them useful, and look forward to reading your comments!

    这些工作流程在设计Viking Village项目时无疑对我们有所帮助。 我们希望您也觉得它们有用,并期待阅读您的评论!

    致谢 (Acknowledgements)

    The Viking Village project was launched in partnership with the creative team at Quixel, developer of HDR surface capture technology and the Quixel Megascans library of PBS-ready textures.

    Viking Village项目是与Quixel的创意团队合作发起的, Quixel是HDR表面捕获技术的开发人员以及Quixel Megascans的PBS就绪纹理库。

    Big thanks to the very talented Emmanuel “Manu” Tavares and Plamen “Paco” Tamnev for bringing this scene to life.

    非常感谢非常有才华的伊曼纽尔·“马努”·塔瓦雷斯和普拉门·“帕科”·塔姆涅夫,使这一场面栩栩如生。

    资产商店下载项目 。 请注意,它已针对Unity 5.0.0 RC2进行了优化。 (Go and download the project at the Asset Store. Be aware that it’s optimised for Unity 5.0.0 RC2.)

    翻译自: https://blogs.unity3d.com/2015/02/18/working-with-physically-based-shading-a-practical-approach/

    基于光照的物理模型(一)

    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

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

    抵扣说明:

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

    余额充值