Unity Graphics (Unity 图形渲染 ) 官方教程文档笔记系列之十三
Unity Graphics (Unity 图形渲染 )
- Everything for Lighting and Rendering in Unity
- 主要涉及到光照与渲染方面的知识
本文档主要是对Unity官方教程的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于 Unity2018.3版本
参考链接:https://unity3d.com/cn/learn/tutorials/s/graphics
下面是将要介绍的章节,黑体是本次内容:
- Introduction to Lighting and Rendering
介绍光照和渲染 - Precomputed Realtime GI (Realtime Global Illumination)
预处理实时全局光照 -
Rendering and Shading(13)
渲染与着色(13) - Cameras and Effects
相机与效果 - Geometry in Unity
几何体
08.Using detail textures for extra realism close-up
为额外的写实特写使用细节纹理
A detail texture is a pattern that is faded in gradually on a mesh as the camera gets close. This can can be used to simulate dirt, weathering or other similar detail on a surface without adding to rendering overhead when the camera is too far away to see the difference. This lesson explains how to use detail textures with Unity.
细节纹理是一种模式,当相机靠近时,在网格上逐渐淡入。这可以用来模拟污垢,风化或其他类似的细节表面。而相机太远,看不到差异时不会增加渲染开销。这节课将解释如何使用细节纹理。
Obtaining the texture
获取的纹理
A detail texture is a greyscale image that is used to lighten or darken another texture selectively. Where a pixel has a brightness value between 0 and 127 the image will be darkened (where zero denotes maximum darkness) and when the value is between 129 and 255, the image will be lightened (where 255 denotes maximum brightness). A value of exactly 128 will leave the underlying image unchanged.
细节纹理是一种灰度图像,用于选择性地使另一种纹理变亮或变暗。当像素的亮度值在0到127之间时,图像将变暗(0表示最大黑暗),当像素值在129到255之间时,图像将变亮(255表示最大亮度)。值正好为128将保持底层映像不变。
If the detail image has an average brightness greater or lower than 128, the whole image will appear to be lightened or darkened as the camera gets close, which gives the wrong effect. It is therefore important to make sure that the brightness levels in the image are roughly symmetrical around 128. You can check this is the case in most image editing software by looking at the image histogram or the Levels adjustment (which typically also shows the histogram). If the histogram shows a symmetrical “bulge” that is slightly to the left or right of the centre, you can bracket the bulge with the min/max input level arrows to get the brightness centred on 127.
如果细节图像的平均亮度大于或低于128,那么当相机靠近时,整个图像就会出现变亮或变暗的现象,从而产生错误的效果。因此,确保图像中的亮度水平大致对称于128左右是很重要的。您可以通过查看图像直方图或级别调整(通常也显示直方图)来检查大多数图像编辑软件中的情况。如果直方图显示一个对称的“凸起”,稍微偏左或偏右,您可以用最小/最大输入箭头将凸起调整,以得到以127为中心的亮度。
To avoid visible boundaries where the detail texture wraps, you should ideally use an image that tiles perfectly. If the image is created using the image editor’s noise function, the results will typically tile without artifacts. Also, filters such as Difference Clouds often have setting to make the resulting image wrap. Simple effects like this can make quite effective detail maps when simulating dirt, grainy surfaces or weathering.
为了避免看到细节纹理的边界,理想情况下应该使用完全平铺的图像。如果图像是使用图像编辑器的噪声函数创建的,那么结果通常是平铺的,不需要额外工作。此外,像分层云彩这样的过滤器通常具有设置来生成图像边界。在模拟污垢、颗粒状表面或风化时,类似这样的简单效果可以制作出相当有效的细节纹理。
Unity import settings for the detail texture
Unity 细节纹理的导入设置
Once you have saved your image to the Unity project, you can select it to see its import settings in the Inspector.
一旦将你的纹理保存到Unity项目中,你可以选择查看它在检查器中的导入设置。
Set the texture type to Advanced and then enable the Fadeout Mip Maps setting under Generate Mip Maps. You should see a range control for the Fade Range; the numeric values for the range aren’t specified but the defaults are suitable for most purposes. For distances below the start of the range, the detail texture will be visible. The range indicates the distance values over which the detail texture will gradually fade before eventually becoming invisible.
将纹理类型设置为Advanced,然后在Generate Mip Maps下启用淡出Mip Maps设置。你应该看到一个淡化范围的范围控制;该范围的数值没有指定,但默认值适用于大多数用途。对于距离开始范围以下的距离,细节纹理将会可见的。细节纹理距离值范围表示逐渐淡出,并在最终变得不可见。
The detail material
细节材质
To use the detail texture, you should set the material to use the Diffuse Detail shader using the menu on the Material Inspector.
要使用细节纹理,您应该使用材质检查器上的菜单将材质设置为使用漫射细节着色器。
In addition to the base texture, you will see a second sampler box to receive the detail texture you have just imported. Typically, you will want to set its Tiling values quite high (maybe about 10).
除了基本纹理外,您还将看到第二个采样器框来接收刚刚导入的细节纹理。通常,您会希望将其平铺值设置得非常高(大约10)。[截图设置有误]
The detail material can now be applied to any suitable object to show the detailing effect.
细节材质现在可以应用于任何合适的对象,以显示细节效果。