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 ...
随机推荐
- 【知识笔记】VS调试问题
一.无法在web服务器上启动调试,您没有调试web服务器进程的权限,您需要以web服务器的用户账户身份运行,或者具有管理员权限. 现象:手动修改网站项目的启动端口号,调试报错 原因:从Windows ...
- db_recovery_file_dest_size 修改大一点及删除归档日志 |转|
今天给客户测 试问题,让客户把数据发过来了.解压缩后一看,他们还是用的oracle 815版本的(他们exp导出时,带了导出日志,从导出日志中看出来是oracle 815版本的),不过没有关系,低版本 ...
- Opencv2.2 移植到am335x-y开发板
1.虚拟机上运行cmake-gui,报找不到文件,指示安装. 2.下载opencv2.2.0 http://opencv.org/downloads.html 3.cmake-gui,配置参考< ...
- Mac环境下终端(Terminal)用ssh 连接服务器问题 Received disconnect from 120.55.x.x: 2: Too many authentication failures for root
由于这台Mac配置git生成公钥后,ssh连接就出现来这个问题 Received disconnect from 120.55.x.x: 2: Too many authentication fail ...
- HL7 Tools suite
HL7的官网有很多开源工具, 比如:RoseTree,V3Generator,RMIM Designer, Design Repository, V2 & V3 Mapping Tools等. ...
- Android中处理崩溃异常 (转)
大家都知道,现在安装Android系统的手机版本和设备千差万别,在模拟器上运行良好的程序安装到某款手机上说不定就出现崩溃的现象,开发者个人不可能购买所有设备逐个调试,所以在程序发布出去之后,如果出现了 ...
- Ubuntu 16.04配置OpenGL教程
sudo apt-get install build-essential sudo apt-get install libgl1-mesa-dev sudo apt-get install libgl ...
- 【转】Jmeter使用之常用函数介绍
"_csvRead"函数 csvRead函数是从外部读取参数,csvRead函数可以从一个文件中读取多个参数. 下面具体讲一下如何使用csvread函数: 1.新建一个csv或者t ...
- 初学者手册-MyBatis踩坑记(org.apache.ibatis.binding.BindingException)
1.参数绑定失败 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Bi ...
- python3第一次作业
需要一个文件users,里面有用户名密码以及是否锁定的标识符 lzd--123--1wdl--123--0lw--123--0aaa--123--0bbb--123--0ccc--123--1ddd- ...