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 ...
随机推荐
- 一步步用python制作游戏外挂【转】
转自:http://www.cnblogs.com/xsmhero/archive/2013/01/03/2842973.html 玩过电脑游戏的同学对于外挂肯定不陌生,但是你在用外挂的时候有没有想过 ...
- MySQL5.6版本性能调优my.cnf详解
[client] port = 3306 socket = /tmp/mysql.sock [mysqld] port = 3306 socket = /tmp/mysql.sock basedir ...
- 单机数据库优化的一些实践(mysql)
数据库优化有很多可以讲,按照支撑的数据量来分可以分为两个阶段:单机数据库和分库分表,前者一般可以支撑500W或者10G以内的数据,超过这个值则需要考虑分库分表.另外,一般大企业面试往往会从单机数据库问 ...
- 网络流量监控分析工具 Ntopng 安装
官方说明:http://packages.ntop.org/ http://packages.ntop.org/centos-stable/ http://packages.ntop.o ...
- new String(tmp,1,nlen,"UTF8")
tmp是一个byte(字节)数组,如:['a','b','c'...],tmp[0]是去byte中的第一个,运算符&表示按位运算‘且’,就是前后值的二进制相同位有0取0,否则取1,如:2&am ...
- xdebug : Debug session was finished without being paused
一.当调试模式出现说路径不匹配的时候,需要检查当前请求的URL和设置断点的是否在同样的位置 Debug session was finished without being paused It may ...
- C#如何:启用和禁用自动绑定重定向 (微软)
https://msdn.microsoft.com/zh-cn/library/2fc472t2.aspx 如何:启用和禁用自动绑定重定向 .NET Framework (current versi ...
- 使用Nancy搭建简单的Http服务的示例demo
刚刚接触Nancy没几天,暂时还不会使用Nancy来做web开发,只是使用Nancy实现了一个简单的Http服务的Demo程序,实现对Post和Get请求的处理. Demo的示例代码地址如下:http ...
- (转) Docker EE/Docker CE简介与版本规划
随着Docker的不断流行与发展,docker公司(或称为组织)也开启了商业化之路,Docker 从 17.03版本之后分为 CE(Community Edition) 和 EE(Enterprise ...
- Oracle重建临时表空间
[oracle@hd58 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 27 11:58:25 ...