当前位置:网站首页>Unity AR Shadow 阴影
Unity AR Shadow 阴影
2022-06-29 06:32:00 【萌萌的提莫队长】
起因:
网上搜了一堆Shader,BuildIn默认渲染管线,都不好使。
在Scene视图正常,在Game就一团黑,然后打包后看不到阴影。 反正不能用。
搜了搜可能BuildIn 或者shader的问题吧,用不了,那就接着找(裂开)


结果:
工程升级至URP,在换上shader ,阴影出现
升级URP需要注意材质升级,以及创建 SRP 基本配置
Configuring AR Camera Background with a Scriptable Render Pipeline | AR Foundation | 3.0.1
效果图:

好用的话,记得点赞、关注、收藏一件三连
URP Shader:
https://github.com/dilmerv/ARFoundationOcclusion/tree/feature/URPOcclusion
Shader "URP AR Shadow Receiver"
{
Properties
{
_ShadowColor ("Shadow Color", Color) = (0.35,0.4,0.45,1.0)
}
SubShader
{
Tags
{
"RenderPipeline"="UniversalPipeline"
"RenderType"="Transparent"
"Queue"="Transparent-1"
}
Pass
{
Name "ForwardLit"
Tags { "LightMode" = "UniversalForward" }
Blend DstColor Zero, Zero One
Cull Back
ZTest LEqual
ZWrite Off
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
#pragma target 2.0
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
#pragma multi_compile _ _SHADOWS_SOFT
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
CBUFFER_START(UnityPerMaterial)
float4 _ShadowColor;
CBUFFER_END
struct Attributes
{
float4 positionOS : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float3 positionWS : TEXCOORD0;
float fogCoord : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
Varyings vert (Attributes input)
{
Varyings output = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
output.positionCS = vertexInput.positionCS;
output.positionWS = vertexInput.positionWS;
output.fogCoord = ComputeFogFactor(vertexInput.positionCS.z);
return output;
}
half4 frag (Varyings input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
half4 color = half4(1,1,1,1);
#ifdef _MAIN_LIGHT_SHADOWS
VertexPositionInputs vertexInput = (VertexPositionInputs)0;
vertexInput.positionWS = input.positionWS;
float4 shadowCoord = GetShadowCoord(vertexInput);
half shadowAttenutation = MainLightRealtimeShadow(shadowCoord);
color = lerp(half4(1,1,1,1), _ShadowColor, (1.0 - shadowAttenutation) * _ShadowColor.a);
color.rgb = MixFogColor(color.rgb, half3(1,1,1), input.fogCoord);
#endif
return color;
}
ENDHLSL
}
}
}边栏推荐
- Browser local storage
- How to combine two byte arrays [repeat] - how to combine two byte arrays [duplicate]
- MySQL learning notes
- Fault: administrator account cannot be selected for login
- Fault: display Storport driver out of date in component health
- Fault: KDC warning log for id29
- 2022-01 Microsoft vulnerability notification
- 'only_ full_ group_ The influence of by'sql mode on group by and its treatment
- Fault: ntfrs warning log for id13562
- Fault: NetBt log for id4321
猜你喜欢

Why are keys unordered in golang map

Testing grpc service with grpcui

Are there too many programmers in China at present?

Two houses with different colors and the farthest distance

MySQL add / delete / modify query SQL statement exercise yyds dry goods inventory

Monitor employee turnover dynamics. This system makes employees tremble!

Games101 Lecture 10 geometry 1 Notes

Programming specification and variables of shell script

2-nitro-5,10,15,20-tetra (4-methylphenyl) porphyrin copper (no2tmpp) Cu) /2-nitro-5,10,15,20-tetra (4-methylphenyl) porphyrin (no2tmpp) H2) Qiyue porphyrin supply

ICLR is going to have a big discussion on the deep generation model. Max welling and the winner of the AAAI million dollar award are here. Bengio is one of the organizers
随机推荐
What should I learn before learning programming?
Is there any difference between a=a+b and a+=b?
Why are keys unordered in golang map
2022.02.15
String and variable are spliced into variable name
Activiti Designer
想请教一下,究竟有哪些劵商推荐?在线开户是安全么?
Awk of shell script
β- Tetraphenyl nickel porphyrin with all chlorine substitution| β- Thiocyano tetraphenyl porphyrin copper| β- Dihydroxy tetraphenyl porphyrin 𞓜 2-nitroporphyrin | supplied by Qiyue
64 commonly used terms for data analysis, really all!
Love that can't be met -- what is the intimate relationship maintained by video chat
Two houses with different colors and the farthest distance
2022.02.14 - 239. A single element in an ordered array
2022.02.14
Convert data frame with date column to timeseries
Servlet version conflict causes page 404
National Defense University project summary
51 lines of code, self-made TX to MySQL software!
Hyperledger Fabric 2. X custom smart contract
Will the order of where conditions in MySQL affect the union index? Will where 1 =1 affect the use of the index? Does where 1 =1 affect the use of indexes?
