URP打开半透明阴影(一百二十七)
source link: https://www.xuanyusong.com/archives/4868
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
URP打开半透明阴影(一百二十七)
在URP下默认只有不透明才会有阴影,其实可以使用alpha test给shadowmap上画阴影, 物体本身则使用alpha blend这样也更加合理。
首先拷贝一下默认的Lit.shader,在Properties中添加一个Toggle变量来控制是否开启半透明阴影。
在写一个shader面板,继承默认的BaseShaderGUI
根据Toggle决定是否启动半透明阴影
然后在面板中启动半透明阴影,如下图所示,启动半透明阴影,然后是Alpha Clipping,通过观察URP源码发现,如果不想影响到半透明渲染,只给阴影生效,也可以自己拓展一个Threshold变量在ShadowCaster中使用alpha Test,这里就关闭面板上的alpha clipping。
最终半透明物体可以产生阴影了。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK