当前位置:网站首页>URP - shaders and materials - light shader lit

URP - shaders and materials - light shader lit

2022-07-07 07:23:00 Programmer base camp

Lit Shader

Light shaders let you render real-world surfaces like stones , Wood , glass , plastic , The quality of metal in the reality of photos . Your light levels and reflections look lifelike , And react correctly under various light conditions , For example, bright sunshine , Or a dark cave . This shader is in the general rendering pipeline (URP) The most computationally intensive shading model .

Using the Lit Shader in the Editor

Select and use this shader :

  1. In your project , Create or find the material you want to use the shader . Select material . A material inspection window will open .
  2. Click shader , choice Universal Render Pipeline > Lit.

UI overview

The inspector window of this shader contains the following elements :

Surface Options

Surface Options control URP How to render materials on the screen .

Surface Options

Surface Options control URP How to render materials on the screen .

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.

Use this drop-down menu to select a workflow , Suitable for your texture , Metal and highlights .

When you make your choice , The main texture options are in the rest of the checker now according to the workflow you choose . Display information about metal or highlight workflow , see also Unity Man pages for standard shaders built into .

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.

Use this drop-down menu to apply an opaque or transparent surface type to the material . To determine the URP The rendering path of . Opaque surface types are always completely visible , No matter what's behind them .URP First render opaque materials . The type of transparent surface is affected by its background , They can vary according to the type of transparent surface you choose .URP Render transparent materials separately after opaque objects . If you choose transparency , The mixed mode drop-down menu will appear .

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.

Use this drop-down list to determine URP How to calculate the color of each pixel of transparent materials by mixing materials and background pixels .

Alpha Using materials Alpha Value to change the transparency of the object .0 It's completely transparent .1 The display is completely opaque , But the material is still rendered during transparent rendering . This is for those images that you want to be completely visible but want to fade away over time , Such as cloud , It's very useful .

Premultiply  Similar materials are applied Alpha The effect of , But it retains reflections and highlights , Even if your surface is transparent . This means that only reflected light is visible . for example , Imagine transparent glass .

Add an additional layer on another surface of the material . This is very useful for holograms .

Multiply  Superimpose the color of the material with the color behind the surface . This will produce a darker effect , Just like you see things through stained glass .

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.

Use this drop-down menu to determine which side of the geometry to render .

Front Face  Render the front of the geometry and weed out the back . This is the default setting .

Back Face  Render the front of the geometry and weed out the front .

Both  Both make URP Render both sides of the geometry . This is useful for small, flat objects , Like leaves , You may want it to be visible on both sides .

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.

Make your material behave like a clipping shader . Use this to create a transparent effect with hard edges between opaque and transparent areas . for example , Create leaves of grass . To achieve this effect ,URP Do not render below the specified threshold alpha value , Threshold is enabled alpha Appears when cutting . You can set the threshold by moving the slider , The slider accepts from 0 To 1 Value . All values above the threshold are opaque , All values below the threshold are invisible . for example , The threshold for 0.1 signify URP Do not render below 0.1 Of alpha value . The default value is 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.

Check this box to make your game object cast shadows by other objects . If you cancel this box , Game objects will not have shadows .

Surface Inputs

Surface input describes the surface itself . for example , You can use these attributes to make your surface look wet 、 dry 、 Rough or smooth .

Be careful : If you are used to built-in Unity Rendering pipeline Standard shaders , These options are similar to Material editor Main map settings in .

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.

Add color to the surface , Also known as diffuse mapping . To assign a texture to the base map settings , Click the object selector next to it . This will open the asset browser , There you can choose from the texture of your project . perhaps , You can use the color selector . The color next to the setting shows the color on the texture you assigned . To specify another hue , You can click on this palette . If you choose transparent or Alpha Tailoring , Your material will use texture Alpha Channel or color .

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.

Display the map input of the workflow mode you selected in the surface option .

about metal Map workflow ,Map The basis assigned from above Map Get color . Use the slider to control the metal appearance of the surface .1 It's completely metallic , Like silver or copper ,0 It is completely dielectric , Like plastic or wood . For dirty or corrosive metals , You can usually use 0 To 1 Between the value of the .

For highlight map settings , You can assign texture to it by clicking the object selector next to it . This will open the asset browser , There you can choose from the texture of your project . perhaps , You can use the color selector .

For these two workflows , You can use the smooth slider to control the extension of highlights on the surface .0 Gives a light highlight .1 Give a small , Sharp highlights are like glass . Values in between produce a semi smooth appearance . for example ,0.5 It can produce gloss similar to plastic .

Use Source Drop down menu to select where shader samples smooth map . Option has :metal Alpha( come from metal map Of Alpha passageway ) and Albedo Alpha( come from base map Of Alpha passageway ). The default value is metal Alpha.

If the selected source has alpha passageway , The shader samples the channel and multiplies each sample by the smoothing value .

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.

Add a normal map to the surface . Use normal mapping , You can add surface details , Such as bump 、 Scratches and grooves . To add a map , Click the object selector next to it . Normal map picks up rays in the environment .
The floating-point value next to this setting is the multiplier of the normal mapping effect . Low values will reduce the effect of normal mapping . The higher the value , The stronger the effect .

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 Parallax mapping technology , Use the height map to translate the visible surface texture area , Realize the occlusion effect of surface layer . To add a map , Click the object selector next to it .
The floating value next to this setting is the multiplier for the height map effect . Low values will reduce the effect of the height map . The higher the value , The stronger the effect .

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.

Select an occlusion map . This simulates shadows caused by ambient light and reflection , Make the light look more realistic , Make less light reach the corners and cracks of the object . To select an occlusion map , Click the object selector 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.

Make the surface look as if it is shining . When enabled ,Emission Map Self illumination map and Emission Color  The self illumination color setting will appear .

To assign a self illumination map , Please click the object image next to it . This will open the asset browser , There you can choose from the texture of your project .

For self illumination color , You can use the color selector to assign a hue at the top of the color . This can be more than 100% White , This is very useful for the effect , Such as lava , Glitter is brighter than white , But it's still another color .

If you don't assign a self illumination map , The glow setting uses only the shading you assigned in the self illumination color .

If self illumination is not enabled ,URP Set self illumination to black , And self illumination is not calculated .

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.

One 2D Double value-added , according to U and V Axis scales the texture to fit the mesh . Good for surfaces like floors and walls . The default value is 1, This means no scaling . Set a higher value to make the texture repeat on your mesh . Set a low value to stretch the texture . Try different values , Until you get the effect you want .

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.

Locate the texture on the mesh 2D Offset . To adjust the position of the grid , stay U Axis or V Move the texture on the axis .

Detail Inputs

Use the detail input settings to add additional details to the surface .

requirement :GPU Support shader Model 2.5 Or higher .

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.

Select a texture to define Unity Overlay the area of the detail map on the surface input map . The mask uses the selected texture alpha passageway . Tiling and offset settings have no effect on the mask .

Base Map

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

Select a texture that contains surface details .Unity Use overlay mode to mix this map with the surface base map .

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.

Select the texture containing normal vector data . Use normal mapping to add surface details , Such as bump 、 Scratches and grooves .
Use the slider next to the settings to change the intensity of the mapping effect . The default value is 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.

Use this setting to scale the base map and normal map on the mesh along U and V Axis , In this way, the map can best match the mesh . The default value is 1. Choose one higher than 1 The value of makes the map repeat in the mesh . Set a value less than 1 To stretch the mapping .

Offset

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

Along the grid U Axis and V Axis shift offset of base map and normal map .

Advanced

Advanced settings affect the underlying calculation of rendering . They have no obvious effect on your surface .

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.

Enabling this option allows your material to get highlights from direct lighting , For example, directional light 、 Point light and spotlight . This means that your material will reflect the light of these light sources . Disable this to ignore these highlight calculations , This makes your shader render 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.

Use the nearest reflection probe for reflection sampling , perhaps , If you set a reflection probe in the lighting window , Then use the illumination probe for reflection sampling . If you disable this , You will have less coloring calculation , But it also means that there is no reflection on your surface .

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.

If possible, make URP Render meshes with the same geometry and materials in a batch . This makes rendering faster . If the mesh has different materials or the hardware does not support GPU Instantiation ,URP You cannot render meshes in a batch .

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.

Use this slider to determine the rendering order of materials .URP First render higher value materials . You can use it to reduce over rendering on your device , The method is to let the pipeline render the material before other materials , So it doesn't need to render the overlapping area twice . This is similar to the built-in Unity Render queue in render pipeline .

Channel packing

This shader uses channel padding , So you can make metal 、 The smoothing and occlusion attributes use a RGBA texture . When you use texture packaging , You only need to load a texture into memory , Instead of three separate textures . When you are in Substance or Photoshop When writing texture maps in programs , You can pack the map like this :

ChannelProperty
RedMetallic
GreenOcclusion
BlueNone
AlphaSmoothness
原网站

版权声明
本文为[Programmer base camp]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130704049287.html