unity3d 定制的表面着色器(Surface Shader)的标准输出结构是这种:

struct SurfaceOutput 

half3 Albedo; //反射率 

half3 Normal; //法线 

half3 Emission; //自发光,用于增强物体自身的亮度,使之看起来好像能够自己发光 

half Specular; //镜面 

half Gloss; //光泽 

half Alpha; //透明 

};

 

Surface Shader compile directives 表面着色器编译指令

Surface shader is placed inside CGPROGRAM..ENDCG block, just like any other shader. The differences are:

表面着色器放在CGPROGRAM .. ENDCG块里面。就像其它的着色器一样。差别是:

It must be placed inside SubShader block, not inside Pass. Surface shader will compile into multiple passes itself.

它必须嵌在子着色器(SubShader)块里面。

而不是Pass块里面。

表面着色器( Surface shader)将在多重通道(multiple passes)内编译自己。

It uses #pragma surface ... directive to indicate it's a surface shader.

它使用的 #pragma surface...指令,以声明它是一个表面着色器(surface shader)。

The #pragma surface directive is:

#pragma surface 这个指令是:

#pragma surface surfaceFunction lightModel [optionalparams]

Required parameters:

所需參数:

surfaceFunction - which Cg function has surface shader code. The function should have the form of void surf (Input IN, inout SurfaceOutput
o), where Input is a structure you have defined. Input should contain any texture coordinates and extra automatic variables needed by surface function.

surfaceFunction - 表示Cg函数中有表面着色器(surface shader)代码。这个函数的格式应该是这样:void surf (Input IN,inout SurfaceOutput o), Input是你自己定义的结构。Input结构中应该包括全部纹理坐标(texture
coordinates)和和表面函数(surfaceFunction)所须要的额外的必需变量。

lightModel - lighting model to use. Built-in ones are Lambert (diffuse) and BlinnPhong (specular). See Custom Lighting Models page for how
to write your own.

lightModel -在光照模式中使用。内置的是Lambert (diffuse)和 BlinnPhong (specular)。假设想编写自己的光照模式,请參考:自己定义光照模式。

Optional parameters:

可选參数:

alpha - Alpha blending mode. Use this for semitransparent shaders.

alpha -透明( Alpha)混合模式。使用它能够写出半透明的着色器。

alphatest:VariableName - Alpha testing mode. Use this for transparent-cutout shaders. Cutoff value is in float variable with VariableName.

alphatest:VariableName -透明( Alpha)測试模式。使用它能够写出 镂空效果的着色器。

镂空大小的变量(VariableName)是一个float型的变量。

vertex:VertexFunction - Custom vertex modification function. See Tree Bark shader for example.

vertex:VertexFunction - 自己定义的顶点函数(vertex function)。请參考范例:树皮着色器(Tree Bark shader)。

finalcolor:ColorFunction - Custom final color modification function. See Surface Shader Examples.

finalcolor:ColorFunction - 自己定义的终于颜色函数(final color function)。 请參考范例:表面着色器样例(Surface Shader Examples)。

exclude_path:prepass or exclude_path:forward - Do not generate passes for given rendering path.

exclude_path:prepass 或者 exclude_path:forward - 使用指定的渲染路径,不须要生成通道。

addshadow - Add shadow caster & collector passes. Commonly used with custom vertex modification, so that shadow casting also gets any procedural
vertex animation.

addshadow - 加入阴影投射 & 收集通道(collector passes)。

通经常使用自己定义顶点改动,使阴影也能投射在不论什么程序的顶点动画上。

dualforward - Use dual lightmaps in forward rendering path.

dualforward - 在正向(forward)渲染路径中使用 双重光照贴图(dual lightmaps)。

fullforwardshadows - Support all shadow types in Forward rendering path.

fullforwardshadows - 在正向(forward)渲染路径中支持全部阴影类型。

decal:add - Additive decal shader (e.g. terrain AddPass).

decal:add - 加入贴花着色器(decal shader) (比如: terrain AddPass)。

decal:blend - Semitransparent decal shader.

decal:blend - 混合半透明的贴花着色器(Semitransparent decal shader)。

softvegetation - Makes the surface shader only be rendered when Soft Vegetation is on.

softvegetation - 使表面着色器(surface shader)仅能在Soft Vegetation打开时渲染。

noambient - Do not apply any ambient lighting or spherical harmonics lights.

noambient - 不适用于不论什么环境光照(ambient lighting)或者球面调和光照(spherical harmonics lights)。

novertexlights - Do not apply any spherical harmonics or per-vertex lights in Forward rendering.

novertexlights - 在正向渲染(Forward rendering)中不适用于球面调和光照(spherical harmonics lights)或者每一个顶点光照(per-vertex lights)。

nolightmap - Disables lightmap support in this shader (makes a shader smaller).

nolightmap - 在这个着色器上禁用光照贴图(lightmap)。(适合写一些小着色器)

nodirlightmap - Disables directional lightmaps support in this shader (makes a shader smaller).

nodirlightmap - 在这个着色器上禁用方向光照贴图(directional lightmaps)。

(适合写一些小着色器)。

noforwardadd - Disables Forward rendering additive pass. This makes the shader support one full directional light, with all other lights computed
per-vertex/SH. Makes shaders smaller as well.

noforwardadd - 禁用正向渲染加入通道(Forward rendering additive pass)。

这会使这个着色器支持一个完整的方向光和全部光照的per-vertex/SH计算。(也是适合写一些小着色器).

approxview - Computes normalized view direction per-vertex instead of per-pixel, for shaders that need it. This is faster, but view direction
is not entirely correct when camera gets close to surface.

approxview - 着色器须要计算标准视图的每一个顶点(per-vertex)方向而不是每一个像索(per-pixel)方向。

这样更快,可是视图方向不全然是当前摄像机(camera) 所接近的表面。

halfasview - Pass half-direction vector into the lighting function instead of view-direction. Half-direction will be computed and normalized
per vertex. This is faster, but not entirely correct.

halfasview - 在光照函数(lighting function)中传递进来的是half-direction向量,而不是视图方向(view-direction)向量。

Half-direction会计算且会把每一个顶点(per vertex)标准化。这样做会非常快,但不全然准确。

Unity3D Shaderlab 学习记录的更多相关文章

  1. Unity3D ShaderLab 修改渲染队列进行深度排序

    Unity3D ShaderLab 修改渲染队列进行深度排序 为了更深刻的理解透明度,我们还需要学习一下深度排序,简单来说就是物体被渲染的先后顺序. Unity允许我们通过代码来控制某个特定物体渲染到 ...

  2. 开启unity3D的学习之路

    2014年5月11号.我開始了我的Unity3D的学习之路.我将在此记录我学习过程中各个进程,这样在将来的某天,自己忘记了某部分内容时.也能够回过头来复习一下.

  3. Quartz 学习记录1

    原因 公司有一些批量定时任务可能需要在夜间执行,用的是quartz和spring batch两个框架.quartz是个定时任务框架,spring batch是个批处理框架. 虽然我自己的小玩意儿平时不 ...

  4. Java 静态内部类与非静态内部类 学习记录.

    目的 为什么会有这篇文章呢,是因为我在学习各种框架的时候发现很多框架都用到了这些内部类的小技巧,虽然我平时写代码的时候基本不用,但是看别人代码的话至少要了解基本知识吧,另外到底内部类应该应用在哪些场合 ...

  5. Apache Shiro 学习记录4

    今天看了教程的第三章...是关于授权的......和以前一样.....自己也研究了下....我觉得看那篇教程怎么说呢.....总体上是为数不多的精品教程了吧....但是有些地方确实是讲的太少了.... ...

  6. UWP学习记录12-应用到应用的通信

    UWP学习记录12-应用到应用的通信 1.应用间通信 “共享”合约是用户可以在应用之间快速交换数据的一种方式. 例如,用户可能希望使用社交网络应用与其好友共享网页,或者将链接保存在笔记应用中以供日后参 ...

  7. UWP学习记录11-设计和UI

    UWP学习记录11-设计和UI 1.输入和设备 通用 Windows 平台 (UWP) 中的用户交互组合了输入和输出源(例如鼠标.键盘.笔.触摸.触摸板.语音.Cortana.控制器.手势.注视等)以 ...

  8. UWP学习记录10-设计和UI之控件和模式7

    UWP学习记录10-设计和UI之控件和模式7 1.导航控件 Hub,中心控件,利用它你可以将应用内容整理到不同但又相关的区域或类别中. 中心的各个区域可按首选顺序遍历,并且可用作更具体体验的起始点. ...

  9. UWP学习记录9-设计和UI之控件和模式6

    UWP学习记录9-设计和UI之控件和模式6 1.图形和墨迹 InkCanvas是接收和显示墨迹笔划的控件,是新增的比较复杂的控件,这里先不深入. 而形状(Shape)则是可以显示的各种保留模式图形对象 ...

随机推荐

  1. Magento 2中文手册教程 - Magento 2 安装流程图

    下图提供了安装Magento 2的安装流程概述: 设置你的服务器环境. 安装magento 2 必备软件, PHP, Apache, MySQL. 系统需求详细信息: 2.1.x 系统需求 获得mag ...

  2. (转载).NET的五层架构

    我们刚开始学习架构的时候,首先会想到分层的概念,分层架构比较经典的是三层架构,那么,什么是三层架构呢?它包括表现层,业务层,数据访问层:而对于一个新手来说,从抽象意义上的三层架构,逻辑上就划分为三个层 ...

  3. C#利用WinForm调用WebServices实现增删改查

    实习导师要求做一个项目,用Winform调用WebServices实现增删改查的功能.写下这篇博客,当做是这个项目的总结.如果您有什么建议,可以给我留言.欢迎指正. 1.首先,我接到这个项目的时候,根 ...

  4. Lucene学习之四:Lucene的索引文件格式(1)

    本文转载自:http://www.cnblogs.com/forfuture1978/archive/2009/12/14/1623597.html Lucene的索引里面存了些什么,如何存放的,也即 ...

  5. No.4一步步学习vuejs之表单输入绑定

    基础用法 你可以用 v-model 指令在表单控件元素上创建双向数据绑定.它会根据控件类型自动选取正确的方法来更新元素.尽管有些神奇,但 v-model 本质上不过是语法糖,它负责监听用户的输入事件以 ...

  6. python的爬虫

    requests库的安装 https://blog.csdn.net/xiaokuang5020/article/details/80580631 Response对象属性 属性 说明 r.statu ...

  7. 设置$.getJSON同步执行的笨方法

    $.ajaxSettings.async=false; $.getJSON("action/logon_checkAcc.action", function(json){ aler ...

  8. Android加载大图片实例详解

    摘要:在Android下采用ARGB表示颜色,每个像素占四个字节.其加载图片申请空间时与图片的实际大小没有关系,与像素有关系.

  9. vcfc之zk+postsql+keystore(cassandra)框架分析

    vcfc框架总结: 1 一. bus和keystore是如何协调处理的,什么样的问题是处理不了的? 1. 如果在备重启的过程中,主处理了某个时间1,备机如果同步数据呢? 二 .数据可靠性和一致性分析 ...

  10. 模块与包&常用模块

    一.模块的使用 模块定义:一系列功能的集合体 分为三大类:1.自定义模块 2.内置模块(比如 time,os,sys) 3.第三方模块 模块的表现形式: 1.使用python编写的py文件 2.已被编 ...