Rendering with Replaced Shaders
【Rendering with Replaced Shaders】
1、RenderType tag
RenderType tag categorizes shaders into several predefined groups, e.g. is is an opaque shader, or an alpha-tested shader etc. This is used by Shader Replacement and in some cases used to produce camera’s depth texture.
2、Rendering with Replaced Shaders
Some rendering effects require rendering a scene with a different set of shaders.
For example, good edge detection would need a texture with scene normals, so it could detect edges where surface orientations differ. Other effects might need a texture with scene depth, and so on. To achieve this, it is possible to render the scene with replaced shaders of all objects.
Shader replacement is done from scripting using Camera.RenderWithShader or Camera.SetReplacementShader functions. Both functions take a shader and a replacementTag.


It works like this: the camera renders the scene as it normally would. the objects still use their materials, but the actual shader that ends up being used is changed:
- If replacementTag is empty, then all objects in the scene are rendered with the given replacement shader.
- If replacementTag is not empty, then for each object that would be rendered:
- The real object’s shader is queried for the tag value.
- If it does not have that tag, object is not rendered.
- A subshader is found in the replacement shader that has a given tag with the found value. If no such subshader is found, object is not rendered.
- Now that subshader is used to render the object.
只有含有 replacementTag 的 Shader 才会被渲染,并且会用 replacement shader 中含有 replacementTag's value 相同的 subshader 进行渲染。
So if all shaders would have, for example, a “RenderType” tag with values like “Opaque”, “Transparent”, “Background”, “Overlay”, you could write a replacement shader that only renders solid objects by using one subshader with RenderType=Solid tag. The other tag types would not be found in the replacement shader, so the objects would be not rendered. Or you could write several subshaders for different “RenderType” tag values. Incidentally, all built-in Unity shaders have a “RenderType” tag set.
3、Shader replacement tags in built-in Unity shaders
All built-in Unity shaders have a “RenderType” tag set that can be used when rendering with replaced shaders. Tag values are the following:
- Opaque: most of the shaders (Normal, Self Illuminated, Reflective, terrain shaders).
- Transparent: most semitransparent shaders (Transparent, Particle, Font, terrain additive pass shaders).
- TransparentCutout: masked transparency shaders (Transparent Cutout, two pass vegetation shaders).
- Background: Skybox shaders.
- Overlay: GUITexture, Halo, Flare shaders.
- TreeOpaque: terrain engine tree bark.
- TreeTransparentCutout: terrain engine tree leaves.
- TreeBillboard: terrain engine billboarded trees.
- Grass: terrain engine grass.
- GrassBillboard: terrain engine billboarded grass.
4、
void Start() {
camera.SetReplacementShader (EffectShader, "RenderType");
}
Rendering with Replaced Shaders的更多相关文章
- unity, 替换shader渲染(Rendering with Replaced Shaders)
实现特效,尤其是一些后处理特效,经常需要将各物体的shader替换为另一套shader进行渲染到纹理,再后再进行合成或以某种叠加方式叠加到最后的画面上去. 再复杂一点儿的,可能不同的物体所用的替换sh ...
- unity, 替换shader渲染(Rendering with Replaced Shaders)【转】
实现特效,尤其是一些后处理特效,经常需要将各物体的shader替换为另一套shader进行渲染到纹理,再后再进行合成或以某种叠加方式叠加到最后的画面上去. 再复杂一点儿的,可能不同的物体所用的替换sh ...
- Unity ShaderLab学习总结
http://www.jianshu.com/p/7b9498e58659 Unity ShaderLab学习总结 Why Bothers? 为什么已经有ShaderForge这种可视化Shader编 ...
- Unity3D脚本中文系列教程(九)
Unity3D脚本中文系列教程(八) name 对象名称hideFlags 该物体是否被隐藏,保存在场景中或被用户修改继承的函数 GetInstanceID 返回该物体的实例id继承的类函数 oper ...
- Unity Shader 基础(1): RenderType & ReplacementShader
很多Shader中都会定义RenderType这个类型,但是一直搞不明白到底是干嘛的,官方文档是这样结解释的:Rendering with Replaced Shaders Rendering wit ...
- Unity3D脚本学习——运行时类
AssetBundle 类,继承自Object.AssetBundles让你通过WWW类流式加载额外的资源并在运行时实例化它们.AssetBundles通过BuildPipeline.BuildAss ...
- ShaderLab学习总结
转载 Unity ShaderLab学习总结 Why Bothers? 为什么已经有ShaderForge这种可视化Shader编辑器.为什么Asset Store已经有那么多炫酷的Shader组件可 ...
- unity,荧光效果(bloom)实现过程
两个月前,刚接触unity的时候费了半天劲儿做了个荧光效果(见:http://www.cnblogs.com/wantnon/p/4430749.html),今天终于抽空整理了一下,把过程写下来. 荧 ...
- Unity -----一些可能存在的错误
关于Unity中的资源管理,你可能遇到这些问题 张鑫 8 个月前 原文链接:关于Unity中的资源管理,你可能遇到这些问题 - Blog 在优化Unity项目时,对资源的管理可谓是个系统纷繁的大工程. ...
随机推荐
- Nodejs总结(一)
Node.js 是一个基于Chrome JavaScript 运行时建立的一个平台,事件驱动I/O服务端JavaScript环境,基于Google的V8引擎,V8引擎执行Javascript的速度非常 ...
- 【每日一学】pandas_透视表函数&交叉表函数
每日一悟 [分开工作内外8小时] 前一个月,我经常把工作内的问题带到路上.地铁上.睡觉前,甚至是周末. 然而很快发现,我工作外的成就几乎没有,而工作内的进展也并不理想. 仔细想想,工作外是需要学新东西 ...
- 浅谈Android MVP
什么是MVP MVP,全称 Model-View-Presenter.要说MVP那就不得不说一说它的前辈--MVC(Model-View-Controller,模型-视图-控制器). View:对应于 ...
- Linux下安装FTP服务(Ubuntu)
在Ubuntu 14.04 上安装 FTP 服务 第一步>>更新库 linuxidc@linuxidc:~$ sudo apt-get update 第二步>>采用如下命令安装 ...
- 【Linux】CentOS7 安装,遇到的各种问题,并修复win7启动项
https://www.cnblogs.com/sxdcgaq8080/p/7457255.html ------------------------------------------------- ...
- 机器学习入门-文本数据-构造词频词袋模型 1.re.sub(进行字符串的替换) 2.nltk.corpus.stopwords.words(获得停用词表) 3.nltk.WordPunctTokenizer(对字符串进行分词操作) 4.np.vectorize(对函数进行向量化) 5. CountVectorizer(构建词频的词袋模型)
函数说明: 1. re.sub(r'[^a-zA-Z0-9\s]', repl='', sting=string) 用于进行字符串的替换,这里我们用来去除标点符号 参数说明:r'[^a-zA-Z0- ...
- Matplotlib中文乱码问题
一.找到并修改matplotlibrc文件 进入Python安装目录下的Lib\site-packages\matplotlib\mpl-data目录,用记事本打开matplotlibrc文件:找到f ...
- Jmeter的安装与使用
安装Jmeter之前需要先配置Java环境 当配置完Jmeter运行的环境之后,就可以开始安装Jmeter了. 为什么既要告诉各位"在Linux系统内安装Jmeter",又要告诉各位"在Windo ...
- 使用mysqlbinlog恢复指定表
从整库备份的sql文件中导出某个表的sql语句时,vim查找到表的第一条INSERT语句后,按上下换行键计数INSERT语句的条数,然后按n yy复制,退出vim后,再新建一个文件,按p粘贴刚才的n条 ...
- NIPS 2016上22篇论文的实现汇集
http://blog.csdn.net/jiandanjinxin/article/details/54087592 日前,LightOn CEO 兼联合创始人 Igor Carron 在其博客上放 ...