树叶边缘渲染

树叶边缘渲染通常使用alpha test,但会产生碎片效果。为实现更好的边缘效果,可以结合alpha blend和alpha test。通过官方文档示例,了解到一种解决方案:首先用alpha testing渲染大部分,然后仅在边缘部分进行alpha blend,避免排序问题,同时保持边缘的平滑过渡。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

树叶边缘渲染一般的做法就是使用alpha test,但这样做在边缘上会出现一些很“碎”的效果,特别是离摄像机远的时候。

如果要边缘效果好,就要采用alpha blend的方式,但这种方法有排序的问题,会造成前后错乱。

之前看斗战神的草,发现边缘是用blend的效果,但没有排序问题。当时有美术同事问如何做到的,一时我也答不出来。

后来翻译unity3d官方文档的时候,发现有个例子提供了解决方案:只在边缘进行alpha blend,其它部位仍然使用alpha test来渲染。这样既保证了边缘的柔和,也没有渲染顺序的问题,因为边缘只是很小的部分,边缘本身的排序问题几乎不会被发现。

以下是原文:


When rendering plants and trees, many games have the hard edges typical of alpha testing. A way around that is to render the object twice. In the first pass, we use alpha testing to only render pixels that are more than 50% opaque. In the second pass, we alpha-blend the graphic in the parts that were cut away, without recording the depth of 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值