半透明剔除(dither/Screen-Door Transparency Shader)
参考网站
- https://digitalrune.github.io/DigitalRune-Documentation/html/fa431d48-b457-4c70-a590-d44b0840ab1e.htm
- https://www.youtube.com/watch?v=rVeS7oh3oug
- https://tedsieblog.wordpress.com/2020/02/13/stipple-transparency-shader-screen-door-transparency-shader/
核心代码
- Dither Noise
(% = fmod 取余)
1 | void Unity_Dither_float(float4 ScreenPosition, out float Out) |
将Noise映射到屏幕
float dither84 = Dither4x4Bayer( fmod(screenPosition.x, 4), fmod(screenPosition.y, 4) );需要一个深度
可以直接用LinearEyeDepth(需要深度图)或算物体与相机的距离
连连看
这边算的是物体和相机的距离,然后减去noise,结果用smoothstep进行微调
Unilt shader(代码有点问题,连连看连反了)
1 | Shader "ASESampleShaders/DitheringFade" |
消除色阶
Dithering:使用8-bit dithering像素点抖动技术,消除色阶。
https://zhuanlan.zhihu.com/p/84434802
https://bartwronski.com/2016/10/30/dithering-in-games-mini-series/
补充方案
射线检测对象是否在后面然后材质改成透明