AlphaTesting
【Alpha Testing】
The alpha test is a last chance to reject a pixel from being written to the screen.
After the final output color has been calculated, the color can optionally have its alpha value compared to a fixed value. If the test fails, the pixel is not written to the display.
在最终颜色(pixel-color)被计算后,可以通过Alpha Test来排除顶点。
[Syntax]
- AlphaTest Off
- Render all pixels (default).
- AlphaTest comparison AlphaValue
- Set up the alpha test to only render pixels whose alpha value is within a certain range.
Comparison
AlphaValue
A floating-point number between 0 and 1. This can also be a variable reference to a float or range property, in which case it should be written using the standard square bracket notation ([VariableName]).
[Alpha测试的用途]
对于半透明的凹形图形,用Alpha测试与Blending配合使用才能产生较好的效果。
左图:ZWrite On,AlphaTest Equal 1.0。由于Alpha均为1,所以无Blending。在此条件下产生出一个锐利的图像。
中图:ZWrite On,AlphaTest Off。在此条件下,Alpha为0的部分会遮挡住Alpha非零的部分,产生奇怪的图。
右图:1)ZWrite On,AlphaTest Equal 1.0。此遍渲染非透明物体。
2)ZWrite Offet,AlphaTest Less 1.0。此遍渲染透明物体。
右图能够产生较为完美的图像。
右图的Shader如下:
Shader "Vegetation" {
Properties {
_Color ("Main Color", Color) = (., ., ., .)
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
_Cutoff ("Base Alpha cutoff", Range (,.)) = .
}
SubShader {
// Set up basic lighting
Material {
Diffuse [_Color]
Ambient [_Color]
}
Lighting On // Render both front and back facing polygons.
Cull Off // first pass:
// render any pixels that are more than [_Cutoff] opaque
Pass {
AlphaTest Greater [_Cutoff]
SetTexture [_MainTex] {
combine texture * primary, texture
}
} // Second pass:
// render in the semitransparent details.
Pass {
// Dont write to the depth buffer
ZWrite off
// Don't write pixels we have already written.
ZTest Less
// Only render pixels less or equal to the value
AlphaTest LEqual [_Cutoff] // Set up alpha blending
Blend SrcAlpha OneMinusSrcAlpha SetTexture [_MainTex] {
combine texture * primary, texture
}
}
}
}
AlphaTesting的更多相关文章
- Unity3D Optimizing Graphics Performance for iOS
原地址:http://blog.sina.com.cn/s/blog_72b936d801013ptr.html icense Comparisons http://unity3d.com/unity ...
- Performance Optimization (2)
DesktopGood performance is critical to the success of many games. Below are some simple guidelines f ...
- 【C++0x】表达式之类型(decltype)
C++0x引入了新的关键字decltype,它是一个操作符,用来取得表达式的类型,主要在泛型编程中使用.这里,简单介绍一下语法规则. 语法形式:decltype (expression)其中,这里 ...
- Unity官网针对IOS开发有比较好的建议
Unity官网针对IOS开发有比较好的建议,我总结了翻译如下,后面附上原文. 尽量控制定点数量(注意所谓顶点不是建模时的顶点,而是引擎渲染时的顶点.例如,模型一个顶点如果设置了2个法向,那么对引擎来说 ...
- 移动平台unity3d优化
目录(?)[-] Focus on GPUs 着眼于GPU Good practice 优秀的实践 Sharer optimizations 着色器优化 Focus on CPUs 着眼于CPUs G ...
随机推荐
- spring事务中隔离级别和spring的事务传播机制
Transaction 也就是所谓的事务了,通俗理解就是一件事情.从小,父母就教育我们,做事情要有始有终,不能半途而废. 事务也是这样,不能做一般就不做了,要么做完,要 么就不做.也就是说,事务必须是 ...
- spring boot 使用spring.resources.static-locations 分离系统模版&&资源文件
方便我们将资源配置以及模版&&静态文件分离出来,而不是打包在一起,比如以下的一个demo 参考配置: server.port=8006 spring.application.name= ...
- nginx unit 安装试用
1. yum 源 nano /etc/yum.repos.d/unit.repo 内容 [unit] name=unit repo baseurl=https://packages.nginx.org ...
- 异常处理—Exception(二)
在上一篇中"异常处理--Exception(一)"中,跟大家简单介绍了一下Exception,也使大家充分的了解了Exception管理在一个项目中的重要性,那如何在我们的项目中处 ...
- 如何把SQLServer数据库从高版本降级到低版本
如何把SQLServer数据库从高版本降级到低版本 编写人:CC阿爸 2015-4-7 近期在给一个客户推行ECM系统时,基本客户的硬件环境,我们为其安装的为SQL2008 64位的数据库系统.在安装 ...
- Exce信息提取
Exce信息提取 Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub 信息汇总( ...
- 【转】用Jmeter制造测试数据
在平时的测试过程中,肯定会有碰到需要一批大量的数据的情况,如果这些数据本身没有太多的要求,或者说需求比较简单,可以通过简单的参数化实现的,推荐用Jmeter来造数据. 限制: Jmeter只能支持ja ...
- centos7系统安装python3,pip3,django
首先去python官网下载python3的源码包,网址:https://www.python.org/ 或者直接wget下载 wget https://www.python.org/ftp/pytho ...
- Angular2快速入门-5.使用http(新闻数据来自http请求)
Angular2官网通过http请求模拟API 来请求hero 数据,感觉有点繁琐,很让人理解不了,我们不采用它的办法,直接展示怎么使用http请求来获取我们的数据 ,直截了当. 第一.准备工作,创建 ...
- Metasploit对安卓手机的攻击
首先要kali进行内网穿透,可参考http://www.cnblogs.com/sch01ar/p/7562954.html 首先生成一个apk木马 命令:msfvenom -p android/me ...