当前位置:网站首页>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实现 - 知乎
边栏推荐
- How to automatically renew the token after it expires?
- leetcode: 250. Count subtrees of equal value
- 直播系统开发——直播间架构的设计及难点分析
- Hangzhou Electric School Competition (Counter Attack Index)
- 微软表示将向内部网络安全专家共享数据 为企业提供更安全保护
- Basic Introduction for PLSQL
- Roslyn 通过 nuget 统一管理信息
- Leetcode: 215 disorderly to find the first big k element in the array
- Database recovery
- 如何和程序员谈恋爱
猜你喜欢

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:253. 至少需要多少间会议室

输入输出流总结

用了TCP协议,就一定不会丢包吗?

IP第十五天笔记

数据链路层-------以太网协议

JCMsuite应用:倾斜平面波传播透过光阑的传输

代码随想录笔记_动态规划_1049最后一块石头的重量II

leetcode: 250. Count subtrees of equal value

Redis 高可用
随机推荐
【Harmony OS】【FAQ】鸿蒙问题合集2
7 天找个 Go 工作,Gopher 要学的条件语句,循环语句 ,第3篇
【云原生 | 从零开始学Kubernetes】kubernetes之StatefulSet详解
Android Sqlite3基本命令
李沐的深度学习笔记来了!
C# BBcode 转 Markdown
宣传海报
C# 将dll打包到程序中
Cisco-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)
指数族分布与最大熵
快速整明白Redis中的字典到底是个啥
Makefile syntax and usage notes
Codeforces Round #811 A~F
I/O stream summary
手搓一个“七夕限定”,用3D Engine 5分钟实现烟花绽放效果
兆骑科创创新创业大赛活动举办,线上直播路演,投融资对接
leetcode: 253. How many meeting rooms are required at least
卖家寄卖流程梳理
IP第十八天笔记
[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