您的位置:首页 > 移动开发 > Unity3D

unityshader固定管线的一些概念理解

2015-08-11 18:01 489 查看
Meterial语句块
Material
{
Diffuse [_Color]  <span style="white-space:pre">		</span>//漫反射颜色块
Ambient [_Color]  <span style="white-space:pre">		</span>//环境光颜色块,通常和漫反射颜色是同一个
Shininess [_Shininess]  <span style="white-space:pre">	</span>//光泽度,用来指定光斑(镜面高光照亮的部分)的大小,其值约大,光斑越小,反之则越大,要在SeparateSpecular On时才会有效
Specular [_SpecColor]  <span style="white-space:pre">		</span>//镜面高光的颜色,一般只影响光斑部分颜色
Emission [_Emission]  <span style="white-space:pre">		</span>//光泽颜色,会影响整个贴图,影响甚至比_Color要大
}


最终由Meterial决定的颜色是
Ambient * RenderSettings ambient setting +(Light Color * Diffuse + Light Color * Specular) + Emission


环境光颜色*渲染设置中的环境光设置+(光颜色*漫反射+光颜色*高光色)+光泽颜色

这是最开始部分

接下来是SetTexture

combine src1 * src2

Multiplies src1 and src2 together. The result will be darker than either input.

将源1和源2的元素相乘。结果会比单独输出任何一个都要暗

combine src1 + src2

Adds src1 and src2 together. The result will be lighter than either input.

将将源1和源2的元素相加。结果会比单独输出任何一个都要亮

combine src1 - src2

Subtracts src2 from src1.

源1 减去 源2

combine src1 +- src2

Adds src1 to src2, then subtracts 0.5 (a signed add).

先相加,然后减去0.5(添加了一个符号)

combine src1 lerp (src2) src3

Interpolates between src3 and src1, using the alpha of src2. Note that the interpolation is opposite direction: src1 is used when alpha is one, and src3 is used when alpha is zero.

使用源2的透明度通道值在源3和源1中进行差值,注意差值是反向的:当透明度值是1是使用源1,透明度为0时使用源3

combine src1 * src2 + src3

Multiplies src1 with the alpha component of src2, then adds src3.

源1和源2的透明度相乘,然后加上源3

combine src1 * src2 +- src3

Multiplies src1 with the alpha component of src2, then does a signed add with src3.

源1和源2的透明度相乘,然后和源3做符号加

combine src1 * src2 - src3

Multiplies src1 with the alpha component of src2, then subtracts src3.

源1和源2的透明度相乘,然后和源3相减

src属性

previous上一次SetTexture的结果,如果最开始使用就是Meterial材质块计算出来的颜色,如SetTexture[_MainTex](combine previous)

Primary 来自光照计算的颜色或是当它绑定时的顶点颜色,个人认为是材质块计算出来的颜色,最开始时候效果和previous是一样的,如SetTexture[_MainTex](combine
primary),如有觉得不对,请高手赐教。

Texture 在SetTexture中被定义的纹理的颜色,就是纹理颜色,这个没什么问题。

Constant被ConstantColor定义的颜色,自定义颜色,这个也很容易
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: