当前位置:网站首页>Unity AR阴影投射透明地面 仅渲染模型实时阴影 Shader实现
Unity AR阴影投射透明地面 仅渲染模型实时阴影 Shader实现
2022-08-04 15:05:00 【Sevol_Y】
亲测可用!
项目有个需求,通过灯光照射,仅渲染模型阴影,相当于接受阴影的地面透明。原理就是使用一个shader,将接受阴影地面透明,并且仅仅渲染阴影。
shader代码:
Shader "ChuckLee/ARShadow"
{
Properties
{
_ShadowColor("Shadow Color", Color) = (0.1, 0.1, 0.1, 0.53)
}
SubShader
{
Tags{ "RenderType" = "Transparent" "Queue" = "Geometry+1" }
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
Tags{ "LightMode" = "ForwardBase" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
#include "AutoLight.cginc"
struct appdata
{
float4 vertex : POSITION;
};
struct v2f
{
float4 pos : SV_POSITION;
SHADOW_COORDS(2)
};
fixed4 _ShadowColor;
v2f vert(appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
TRANSFER_SHADOW(o);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed atten = SHADOW_ATTENUATION(i);
return fixed4(_ShadowColor.rgb,saturate(1 - atten)*_ShadowColor.a);
}
ENDCG
}
}
FallBack "Diffuse"
}
我的项目工程:阴影投射工程。。。。。。。。-其它文档类资源-CSDN下载
shader实现博主:AR中虚拟物体投射阴影的Unity Shader实现 - 知乎
边栏推荐
- ping的原理
- Find My Technology | Prevent your pet from getting lost, Apple Find My technology can help you
- vim 常用操作命令
- eNSP-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)
- Sum of four squares, laser bombs
- B. Construct a simple sequence (greedy)
- 【Today in History】August 4: First female Turing Award winner; NVIDIA acquires MediaQ; first Cybersecurity Challenge completed
- AOSP built-in APP franchise rights white list
- 推荐一个鸿蒙即时通讯软件《果聊》
- Next -20- 使用自定义样式 (custom style)
猜你喜欢
leetcode:251. 展开二维向量
Bluetooth Technology|In the first half of the year, 1.3 million charging piles were added nationwide, and Bluetooth charging piles will become the mainstream of the market
Redis-哨兵模式
一看就会的Chromedriver(谷歌浏览器驱动)安装教程
Google plug-in. Download contents file is automatically deleted after solution
Find My技术|防止你的宠物跑丢,苹果Find My技术可以帮到你
性能提升400倍丨外汇掉期估值计算优化案例
分布式链路追踪Jaeger + 微服务Pig在Rainbond上的实践分享
leetcode:259. 较小的三数之和
Hangzhou Electric School Competition (Counter Attack Index)
随机推荐
Roslyn 通过 nuget 统一管理信息
指数族分布与最大熵
Flutter 运动鞋商铺小demo
uni-app 从零开始-生命周期(二)
Find My Technology | Prevent your pet from getting lost, Apple Find My technology can help you
快速整明白Redis中的字典到底是个啥
卖家寄卖流程梳理
C# 谁改了我的代码
[in-depth study of 4 g / 5 g / 6 g project - 50] : URLLC - 16 - the 3 GPP URLLC agreement, specification, technical principle of depth interpretation - 10 - high reliability technology - 1 - low codin
Bluetooth Technology|In the first half of the year, 1.3 million charging piles were added nationwide, and Bluetooth charging piles will become the mainstream of the market
leetcode:259. 较小的三数之和
Technology sharing | Description of the electronic fence function in the integrated dispatching system
PTA 6-2 多项式求值
【Web技术】1401- 图解 Canvas 入门
Roslyn 节点的 Span 和 FullSpan 有什么区别
leetcode: 250. Count subtrees of equal value
用了TCP协议,就一定不会丢包吗?
leetcode: 254. Combinations of factors
Nuget 通过 dotnet 命令行发布
vim common operation commands