URP——着色器和材质——灯光着色器 Lit

Lit Shader

灯光着色器让你渲染真实世界的表面像石头,木材,玻璃,塑料,金属在照片现实的质量。您的光等级和反射看起来栩栩如生,并在各种光照条件下反应正确,例如明亮的阳光,或一个黑暗的洞穴。这个着色器在通用渲染管道(URP)中使用了计算量最大的着色模型

Using the Lit Shader in the Editor

选择和使用这个着色器:

  1. 在你的项目中,创建或找到你想使用着色器的材质。选择材质。这时会打开一个材质检查窗口。
  2. 点击着色器,选择Universal Render Pipeline > Lit

UI overview

这个着色器的检查器窗口包含以下元素:

Surface Options

Surface选项控制URP如何在屏幕上渲染材质。

Surface Options

Surface选项控制URP如何在屏幕上渲染材质。

PropertyDescription
Workflow Mode

Use this drop-down menu to choose a workflow that fits your Textures, either Metallic and Specular.
When you have made your choice, the main Texture options in the rest of the Inspector now follow your chosen workflow. For information on metallic or specular workflows, see this Manual page for the Standard built-in Shader in Unity.

使用这个下拉菜单选择一个工作流,适合你的纹理,金属和高光。

当你做出你的选择,主要的纹理选项在检查器的其余部分现在按照你选择的工作流程。显示有关金属或高光工作流程的信息,请参阅Unity中内置的标准着色器的手册页。

Surface Type

Use this drop-down to apply an Opaque or Transparent surface type to the Material. This determines which render pass URP renders the material in. Opaque surface types are always fully visible, regardless of what’s behind them. URP renders opaque Materials first. Transparent surface types are affected by their background, and they can vary according to which type of transparent surface type you choose. URP renders transparent Materials in a separate pass after opaque objects. If you select Transparent, the Blending Mode drop-down appears.

使用此下拉菜单为材质应用不透明或透明的表面类型。这决定了URP的渲染路径。不透明的表面类型总是完全可见的,不管它们背后是什么。URP首先渲染不透明的材料。透明表面类型受其背景的影响,它们可以根据您选择的透明表面类型的类型而变化。URP在不透明对象之后单独渲染透明材质。如果你选择透明,混合模式下拉菜单就会出现。

Blending Mode

Use this drop-down to determine how URP calculates the color of each pixel of the transparent Material by blending the Material with the background pixels.
Alpha uses the Material’s alpha value to change how transparent an object is. 0 is fully transparent. 1 appears fully opaque, but the Material is still rendered during the Transparent render pass. This is useful for visuals that you want to be fully visible but to also fade over time, like clouds.
Premultiply applies a similar effect to the Material as Alpha, but preserves reflections and highlights, even when your surface is transparent. This means that only the reflected light is visible. For example, imagine transparent glass.
Additive adds an extra layer to the Material, on top of another surface. This is good for holograms. 
Multiply multiplies the color of the Material with the color behind the surface. This creates a darker effect, like when you look through colored glass.

使用这个下拉列表来确定URP如何通过混合材质和背景像素来计算透明材质的每个像素的颜色。

Alpha使用材质的Alpha值来改变物体的透明度。0是完全透明的。1显示完全不透明,但是在透明渲染过程中材质仍然被渲染。这对于那些你想要完全可见但又想要随着时间逐渐消失的图像,比如云,是很有用的。

Premultiply 在材质上应用了类似Alpha的效果,但是保留了反射和高光,即使你的表面是透明的。这意味着只有反射光是可见的。例如,想象一下透明的玻璃。

在材料的另一个表面上增加一个额外的层。这对全息图很有用。

Multiply 将材料的颜色与表面后面的颜色进行叠加。这会产生一种更暗的效果,就像你透过彩色玻璃看东西一样。

Render Face

Use this drop-down to determine which sides of your geometry to render.
Front Face renders the front face of your geometry and culls the back face. This is the default setting. 
Back Face renders the front face of your geometry and culls the front face. 
Both makes URP render both faces of the geometry. This is good for small, flat objects, like leaves, where you might want both sides visible.

使用这个下拉菜单来确定要渲染几何图形的哪一面。

Front Face 渲染几何图形的前面并剔除后面。这是默认设置。

Back Face 渲染几何图形的前面并剔除前面。

Both 两者都使URP渲染几何图形的两面。这对小而扁平的物体很有用,比如叶子,你可能想让它的两边都可见。

Alpha Clipping

Makes your Material act like a Cutout Shader. Use this to create a transparent effect with hard edges between the opaque and transparent areas. For example, to create blades of grass. To achieve this effect, URP does not render alpha values below the specified Threshold, which appears when you enable Alpha Clipping. You can set the Threshold by moving the slider, which accepts values from 0 to 1. All values above your threshold are fully opaque, and all values below your threshold are invisible. For example, a threshold of 0.1 means that URP doesn't render alpha values below 0.1. The default value is 0.5.

使你的材质表现得像一个剪切着色器。使用这个在不透明和透明区域之间创建一个有硬边的透明效果。例如,创建草的叶片。为了实现此效果,URP不渲染低于指定阈值的alpha值,阈值在启用alpha剪切时出现。您可以通过移动滑块来设置阈值,滑块接受从0到1的值。阈值以上的所有值都是不透明的,而阈值以下的所有值都是不可见的。例如,阈值为0.1意味着URP不渲染低于0.1的alpha值。默认值是0.5。

Receive Shadows

Tick this box to enable your GameObject to have shadows cast upon it by other objects. If you untick this box, the GameObject will not have shadows on it.

勾选此框可以让你的游戏物体被其他物体投射阴影。如果你取消这个框,游戏对象将不会有阴影。

Surface Inputs

表面输入描述了表面本身。例如,您可以使用这些属性使您的表面看起来湿、干、粗糙或光滑。

注意:如果你习惯了内置Unity渲染管线中的标准着色器,这些选项类似于材质编辑器中的主贴图设置。

PropertyDescription
Base Map

Adds color to the surface, also known as the diffuse map. To assign a Texture to the Base Map setting, click the object picker next to it. This opens the Asset Browser, where you can select from the Textures in your Project. Alternatively, you can use the color picker. The color next to the setting shows the tint on top of your assigned Texture. To assign another tint, you can click this color swatch. If you select Transparent or Alpha Clipping under Surface Options, your Material uses the Texture’s alpha channel or color.

为表面添加颜色,也称为漫反射贴图。要为基础贴图设置分配纹理,请单击它旁边的对象选择器。这会打开资产浏览器,在那里你可以从你的项目的纹理中选择。或者,您可以使用颜色选择器。设置旁边的颜色显示了你分配的纹理上的色彩。要指定另一种色调,可以单击这个色板。如果你在表面选项下选择透明或Alpha剪裁,你的材质会使用纹理的Alpha通道或颜色。

Metallic / Specular Map

Shows a map input for your chosen Workflow Mode in the Surface Options.
For the Metallic Map workflow, the map gets the color from the Base Map assigned above. Use the slider to control how metallic the surface appears. 1 is fully metallic, like silver or copper, and 0 is fully dielectric, like plastic or wood. You can generally use values in between 0 and 1 for dirty or corroded metals.
For the Specular Map setting, you can assign a texture to it by clicking the object picker next to it. This opens the Asset Browser, where you can select from the Textures in your Project. Alternatively, you can use the color picker.
For both workflows, you can use the Smoothness slider to control the spread of highlights on the surface. 0 gives a wide, rough highlight. 1 gives a small, sharp highlight like glass. Values in between produce semi-glossy looks. For example, 0.5 produces a plastic-like glossiness.
Use the Source drop-down menu to select where the shader samples a smoothness map from. Options are: Metallic Alpha (alpha channel from the metallic map), and Albedo Alpha (alpha channel from the base map). The default value is Metallic Alpha.
If the selected source has the alpha channel, the shader samples the channel and multiplies each sample by the Smoothness value.

在表面选项中显示您所选择的工作流模式的贴图输入。

对于metal Map工作流,Map从上面分配的基础Map获得颜色。使用滑块控制表面的金属外观。1是完全金属的,像银或铜,0是完全介电的,像塑料或木材。对于脏的或腐蚀的金属,通常可以使用0到1之间的值。

对于高光贴图设置,你可以通过点击它旁边的对象选择器来给它分配纹理。这会打开资产浏览器,在那里你可以从你的项目的纹理中选择。或者,您可以使用颜色选择器。

对于这两个工作流,您可以使用平滑滑块来控制表面上高光的扩展。0给出了粗浅的高光。1给出一个小的,尖锐的高光像玻璃。介于两者之间的值会产生半光滑的外观。例如,0.5可以产生类似塑料的光泽度。

使用Source下拉菜单选择着色器采样平滑贴图的地方。选项有:metal Alpha(来自metal map的Alpha通道)和Albedo Alpha(来自base map的Alpha通道)。默认值是metal Alpha。

如果所选的源有alpha通道,着色器对通道采样并将每个采样乘以平滑值。

Normal Map

Adds a normal map to the surface. With a normal map, you can add surface details like bumps, scratches and grooves. To add the map, click the object picker next to it. The normal map picks up ambient lighting in the environment. 
The float value next to the setting is a multiplier for the effect of the Normal Map. Low values decrease the effect of the normal map. High values create stronger effects.

向表面添加法线贴图。使用法线贴图,您可以添加表面细节,如凹凸、划痕和凹槽。要添加贴图,单击它旁边的对象选择器。法线贴图拾取环境中的光线。
该设置旁边的浮点值是法线贴图效果的乘数。低值会降低法线贴图的效果。价值越高,效果越强。

Height Map

URP implements the parallax mapping technique which uses the height map to achieve surface-level occlusion effect by shifting the areas of the visible surface texture. To add the map, click the object picker next to it. 
The float value next to the setting is a multiplier for the effect of the Height Map. Low values decrease the effect of the height map. High values create stronger effects.

URP采用视差贴图技术,利用高度贴图对可见的表面纹理区域进行平移,实现表面层遮挡效果。要添加贴图,单击它旁边的对象选择器。
该设置旁边的浮动值是用于高度图效果的乘数。低值会降低高度图的效果。价值越高,效果越强。

Occlusion Map

Select an occlusion map. This simulates shadows from ambient light and reflection, which makes lighting look more realistic as less light reaches corners and crevices of objects. To select the occlusion map, click the object picker next to it.

选择一个遮挡贴图。这模拟了环境光和反射产生的阴影,使得光线看起来更加真实,使更少的光线到达物体的角落和缝隙。要选择遮挡贴图,单击它旁边的对象选择器。

Emission

Makes the surface look like it emits lights. When enabled, the Emission Map and Emission Color settings appear.
To assign an Emission Map, click the object picture next to it. This opens the Asset Browser, where you can select from the textures in your Project.
For Emission Color, you can use the color picker to assign a tint on top of the color. This can be more than 100% white, which is useful for effects like lava, that shines brighter than white while still being another color.
If you have not assigned an Emission Map, the Emission setting only uses the tint you’ve assigned in Emission Color.
If you do not enable Emission, URP sets the emission to black and does not calculate emission.

使表面看起来像在发光。启用后,Emission Map自发光贴图和Emission Color 自发光颜色设置就会出现。

若要分配自发光贴图,请单击它旁边的对象图片。这会打开资产浏览器,在那里你可以从你的项目的纹理中选择。

对于自发光颜色,您可以使用颜色选择器在颜色的顶部分配一个色调。这可以是超过100%的白色,这对效果很有用,如熔岩,闪耀比白色更明亮,但仍然是另一种颜色。

如果您没有分配一个自发光贴图,发光设置只使用您在自发光颜色中分配的着色。

如果不启用自发光,URP将自发光设置为黑色,并且不计算自发光。

Tiling

A 2D multiplier value that scales the Texture to fit across a mesh according to the U and V axes. This is good for surfaces like floors and walls. The default value is 1, which means no scaling. Set a higher value to make the Texture repeat across your mesh. Set a lower value to stretch the Texture. Try different values until you reach your desired effect.

一个2D倍增值,根据U和V轴缩放纹理以适应网格。对地板和墙壁这样的表面很好。默认值是1,这意味着没有缩放。设置一个更高的值使纹理在你的网格上重复。设置一个较低的值来拉伸纹理。尝试不同的值,直到达到你想要的效果。

Offset

The 2D offset that positions the Texture on the mesh. To adjust the position on your mesh, move the Texture across the U or V axes.

在网格上定位纹理的2D偏移量。为了调整网格的位置,在U轴或V轴上移动纹理。

Detail Inputs

使用细节输入设置向表面添加额外的细节。

要求:GPU支持shader模型2.5或更高。

PropertyDescription
Mask

Select a texture that defines areas where Unity overlays the Detail maps over the Surface Inputs maps. The mask uses the alpha channel of the selected texture. The Tiling and Offset settings have no effect on the mask.

选择一个纹理来定义Unity在表面输入贴图上覆盖细节贴图的区域。蒙版使用所选纹理的alpha通道。平铺和偏移设置对蒙版没有影响。

Base Map

Select the texture containing the surface details. Unity blends this map with the Surface Base Map using the overlay mode.

选择包含表面细节的纹理。Unity使用叠加模式混合这个贴图和表面基础贴图。

Normal Map

Select the texture containing the normal vector data. Use a normal map to add surface details like bumps, scratches and grooves.
Use the slider next to the setting to change the intensity of the effect of the map. The default value is 1.

选择包含法向量数据的纹理。使用法线贴图添加表面细节,如凹凸、划痕和凹槽。
使用设置旁边的滑块来改变贴图效果的强度。默认值是1。

Tiling

Use this setting to scale the Base Map and the Normal Map on the mesh along the U and V axes, so that the maps fit the mesh best. The default value is 1. Select a value higher than one to make the maps repeat themselves across the mesh. Set a value lower than 1 to stretch the maps.

使用这个设置来缩放网格上的基础贴图和法线贴图沿着U和V轴,这样贴图就能最好的匹配网格。默认值是1。选择一个高于1的值使贴图在网格中重复。设置一个小于1的值来拉伸映射。

Offset

The offset that moves the Base Map and the Normal Map on the mesh along the U and V axes.

在网格上沿着U轴和V轴移动基础贴图和法线贴图的偏移。

Advanced

高级设置会影响渲染的底层计算。它们对你的表面没有明显的影响。

ropertyDescription
Specular Highlights

Enable this to allow your Material to have specular highlights from direct lighting, for example Directional, Point, and Spot lights. This means that your Material reflects the shine from these light sources. Disable this to leave out these highlight calculations, so your Shader renders faster. By default, this feature is enabled.

启用这个选项可以让你的材质从直接光照中获得高光,例如方向光、点光和聚光灯。这意味着你的材质会反射这些光源的光芒。禁用这个来忽略这些高亮计算,这样你的着色器渲染更快。默认情况下,该特性是启用的。

Environment Reflections

Sample reflections using the nearest Reflection Probe, or, if you have set one in the Lighting window, the Lighting Probe. If you disable this, you will have fewer Shader calculations, but this also means that your surface has no reflections.

使用最近的反射探针进行反射取样,或者,如果您在照明窗口中设置了反射探针,则使用照明探针进行反射取样。如果你禁用这个,你将有更少的着色计算,但这也意味着你的表面没有反射。

Enable GPU Instancing

Makes URP render meshes with the same geometry and Material in one batch, when possible. This makes rendering faster. URP cannot render Meshes in one batch if they have different Materials or if the hardware does not support GPU instancing.

如果可能的话使URP渲染网格与相同的几何和材料在一批。这使得渲染速度更快。如果网格有不同的材质或者硬件不支持GPU实例化,URP不能在一批中渲染网格。

Priority

Use this slider to determine the chronological rendering order for a Material. URP renders Materials with higher values first. You can use this to reduce overdraw on devices by making the pipeline render Materials in front of other Materials first, so it doesn't have to render overlapping areas twice. This works similarly to the render queue in the built-in Unity render pipeline.

使用这个滑块来决定材质的渲染顺序。URP首先渲染较高值的材质。您可以使用它来减少设备上的过度渲染,方法是让管线首先在其他材质之前渲染材质,这样它就不需要渲染两次重叠的区域。这类似于内置的Unity渲染管道中的渲染队列。

Channel packing

这个着色器使用通道填充,所以你可以为金属、平滑和遮挡属性使用一个RGBA纹理。当你使用纹理打包时,你只需要加载一个纹理到内存中,而不是三个单独的纹理。当你在Substance或Photoshop等程序中编写纹理贴图时,你可以这样打包贴图:

ChannelProperty
RedMetallic
GreenOcclusion
BlueNone
AlphaSmoothness
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值