Unity3D

来源:互联网 发布:centos 移除mysql 编辑:程序博客网 时间:2024/06/06 23:52

这里写图片描述

官方视频:https://unity3d.com/cn/learn/tutorials/topics/graphics/standard-shader

官方Demo:https://github.com/biezhihua/Unity3DTutorials/tree/master/Graphics/StandardShader

视频字幕文件:https://github.com/biezhihua/Unity3DTutorials/blob/master/Graphics/%5BDownSub.com%5D%20Unity%205%20Graphics%20-%20The%20Standard%20Shader%20-%20Unity%20Official%20Tutorials.srt

视频字幕内容:

The Standard Shader is a powerful and versatile shader.

This single physically-based shadercan be used to make such a wide varietyof materials it’s easilypossible that this one shader can makeevery material in a given project.

The standard is used to create Unity’s default material.

So all mesh rendered usingthe default material will be using the standard shader.

All new materials that are createdwill use the standard shader as well.

To change the shader used by a materialselect the Shader menu on the material.

Select Standard to use the standard shader.

It is worth noting the Unityhas shaders available for bothpopular approaches to physically-based rendering.

Metallic, as default,and specular.

To choose the standard shaderusing the specular approachselect Standard (Specular Setup).

Otherwise use Standardfor the metallic approach.

It is important to understand that themetallic approach to physically-based shadingis not only for materials which aresupposed to look metallic.

This mode is known as metallicbecause this approach is based ondefining how metallic or non-metallicthat material’s surface is.

This is opposed to the specular approachwhich defines how specular,or non-specular that surface is.

Both approaches are valid ways todescribe a physically-based material.

This physically-based material isstill a standard Unity materialand this material is associatedwith a renderer in the same way as usual.

There are three sections to the standard shader.

Rendering Mode.

Main Mapsand Secondary Maps.

The standard shader has four rendering modes.

Opaque, Cutout, Fade and Transparent.

Most materials are opaque, or solid materials.

Opaque is the default render mode.

For transparent materials, such as glass,choose Transparent.

In transparent rendering modethe alpha channel on the diffuse colour propertyis used to control the level of transparency.

With rendering mode cutoutthe alpha channel of the diffuse imageis used to mask out parts of the texture.

If the alpha channel has a gradient value to the maskthe alpha cutoff slider can be usedto adjust the shape of the cutout.

based on the strength of the mask in the alpha channel.

Rendering mode fade is similarto rendering mode transparent.

Fade is intended for fading outgame objects on screen.

With rendering mode transparenta transparent material will preserve it’sreflectivity regardless of it’s alpha value.

Fade however will fade allrelevant aspects of the materialso the faded material is completely invisible.

The main map section defines the look of the material.

Before going in to the details of each propertythere are a few subjects that are worth covering first.

Optimisation.

The standard shader is highly optimised.

When the standard shader is builttwo important things happen.

All properties that are not being used are discarded.

The build target is checkedand the shader is optimised for that device.

Because of this there is no need to populate everyproperty with a map or values.

And there is no need to worry about wastedresources due to unused properties.

Physically-based shading.

Physically-based shading tries to definecertain physical aspects of a material’s surface.

Including it’s diffuse colour,specular refection and other propertiesso the material behaves correctlyand believably in all lighting environments.

The response of the scene lighting to the materialcreated with a physically based shadermimics light in the real physical world.

This means that even though there isfull control over the values onall of the properties in the standard shaderthere are certain ranges of values thatwork best for certain types of materials.

This is particularly true of the metallic and specular valuesdepending up which approach is being usedTaking specular colour for example,when analysing real-world materialsmost materials have a specular rangethat is a very dark grey.

Metals created with a specular workflow are one of the few exceptions,they have very bright specular values.

As well, no material, even the most dull,has no specularity at all.

This means to have a physically basedmaterial behave correctlysome attention needs to be paid in usingthe correct physical values for some key properties,especially the specular or metallic propertiesdepending upon the approach being used.

For more information on physical-based shading,material charts and sample materialsplease see the information linked below.

There is no need to panic however.

Items with materials from previous versions of Unitywill work well out of the box.

Upgrading from a legacy diffuse shaderto the standard shader should display little or no difference.

In the main map section each of these propertiescontrol one aspect of the final material.

Each property can be defined by a texture map.

With the metallic approach,for the albido, metallic and emission propertiesthe texture is optional.

The albido and emission propertiescan simply use a colour value instead of a texture.

The colour value is not available onthe emission property until the emissivescale is larger than 0.

The metallic property can use a sliderinstead of a texture.

The albido property uses acombination of an optional texture.

And a colour value to define the base look of the material.

The colour value will tint the texture.

Where pure white leaves the main texture unaffected,if there is no texture being usedthe tint colour will be the base colour for the materialThe metallic property can be definedby either a textureor a value from 0 to 1set by the slider.

This defines the metalness of the material surface.

Metalness works very closely with smoothness.

The smoothness property is used tocontrol the smoothness,or micro-surface detail, of the material.

It is also a value between 0 and 1.

The less smooth the surface is,the more diffuse the reflections will be.

The more smooth, the sharper the reflections.

The metallic property can use a textureto define the material’s metalness.

This texture can be a simple shade of greyused to define the metalness from black,or non-metallic,to white, completely metallic.

However, the advantage of using a textureto define the metalness of a materialis to vary the metalness valueacross the surface of the material.

An additional advantage is this texture’s alpha channel.

This alpha channel can be used to definea smoothness map.

Many materials are far more complexthan a single uniform surface.

Take this leather case for example.

With a single value for metalness and asingle value for smoothnessthe case looks good.

But it could look better.

Use a metalness and smoothness mapto describe the properties.

And it looks much better.

Note how the straps are far more glossythan the main body of the case.

Giving them a feel of polished leather.

It is worth noting that when using a textureto define the metalnessthe smoothness value must also bedefined by that texture’s alpha channel.

It is also worth noting that the metalnessvalue is stored only in the redchannel of the metalness map’s RGB values.

The green and blue channels are ignored.

It is often easier however to visualisethe metalness values of a textureif all three colour channels share the same map,so the texture appears as a greyscale image.

When using the standard shader with the specular setupthe metallic property is replaced withthe specular property.

The specular approach also usesa smoothness property, which behaves essentiallyin the same way as with the metalness approach.

The specualar property can either be a textureor a colour valueand defines the specular reflectivityof the material’s surface.

The specular value can have some colour in itbut looking at real world valueswith the exception of some metalsthis is usually a grey and often very dark.

Specular maps are usually a dark grey as well.

When a specular texture map is not being usedthe overall surface smoothness can beset with the slider.

This is easier to see when the albidotexture is removed.

The ball looks like polished porcelain.

For a more true mirror, the specular from dark grey,which makes the ball look like porcelainin to the range of metals and it will nowreflect the sky and surroundings.

The smoother the surface, the more it is mirror-like.

The rougher the surface the more diffuse,or scattered the reflections are.

The normal map property is an optional propertyused to define the apparent bumpiness of the surface.

When a normal map is appliedthe strength of the normal map can be controlledby adjusting the normal map value.

As well as positive numbers, this valuecan be a negative numberor 0.

The height map property is an optionalproperty used to define the apparentheight of the surface.

When a height map is appliedthe strength of the height map can be controlledby adjusting the height map value.

The occlusion property uses atexture map to define the amount ofambient occlusion that is applied to the material.

This is used to help darkenhidden or recessed areas on the texture.

The ambient occlusion map alsoprevents specular and reflections inthese occluded areas, given the materiala more realistic look.

The emission property controls whether or notthe material’s surface will emit light.

The material’s emission value can contributeto the scene’s global illumination.

The strength of the emission can be controlledby the emission value.

The shape of the emission can be controlled with an emission map.

The map can be a simple black and white map.

bBut this texture can also be a colour map.

When there is a value for emissionthe contribution of the emissive lightcan be assigned to either the baked light mapsor to the real time light maps.

The detail mask property is an optional mask elementto control the secondary maps.

Tiling and offset control the position of the map.

The secondary maps are used to defineadditional surface detail.

This additional detail, sometimes referred to as micro detail,is added on top of the surface definedby the main maps.

This helps to add extra detail andvariation to a material, which is overlaidon top of the main maps defining that material.

Because detail maps can be tiled across meshesthey can add incredibly high levels of surface detail.

原创粉丝点击