当前位置:网站首页>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
}
}
}边栏推荐
- Honeypot based on MySQL load data local INFILE
- Rich material libraries make modeling easy and efficient for developers
- [high concurrency] deeply analyze the callable interface
- Alphacode made its debut! The programming version of "Alpha dog" competed quietly and defeated half of the programmers
- Mongodb sort function
- Regular expressions for shell script values
- Personal blog item: processing of reading number +1 after viewing article details
- Failure: unable to log in to "taxpayer equity platform"
- Awk of shell script
- QT (x): innosetup for software packaging
猜你喜欢

Hyperledger Fabric 2. X custom smart contract

Devops development, operation and maintenance Basics: using Jenkins to automatically build projects and notify by email

Fresnel diffraction with rectangular aperture based on MATLAB
![Meso tetra (4-N, N, n-trimethylaminophenyl) porphyrin (ttmapp) /meso tetra - [4- (BOC threonine) aminophenyl] porphyrin (TAPP thr BOC) supplied by Qiyue](/img/a9/0869c4f39a96cff63d1e310292c46d.jpg)
Meso tetra (4-N, N, n-trimethylaminophenyl) porphyrin (ttmapp) /meso tetra - [4- (BOC threonine) aminophenyl] porphyrin (TAPP thr BOC) supplied by Qiyue

Clickhouse data type

Regular expressions for shell script values

Use of sed in shell script

How to insert pseudo code into word documents simply and quickly?

Hyperledger Fabric 2. X custom smart contract

Fault: NetBt log for id4321
随机推荐
Rich material libraries make modeling easy and efficient for developers
Implementation of queue
Servlet version conflict causes page 404
Case of single file component files
[Flink] flinksql and table programming cases
Fresnel diffraction with rectangular aperture based on MATLAB
Test Development - ten years of sharpening one sword (VII) interface test tool postman
Maximum ascending subarray sum of leetcode simple problem
Meta metauniverse female safety problems occur frequently. How to solve the relevant problems in the metauniverse?
Can redis implement hot standby?
Difference between parametric continuity and geometric continuity
Difference between URI and URL
Alphacode made its debut! The programming version of "Alpha dog" competed quietly and defeated half of the programmers
The first commercial spacewalk of mankind is finalized! Musk SpaceX announced a new round of space travel plan, and the American rich became repeat customers
How does MySQL implement distributed locks?
5- (4-benzoimide phenyl) - 10,15,20-triphenylporphyrin (battph2) and its Zn complex (battpzn) / tetra (4-aminophenyl) porphyrin (tapph2) Qiyue supply
Ti Click: quickly set up tidb online laboratory through browser | ti- team interview can be conducted immediately
Teach you how to develop your own NPM package (publish to the NPM official website)
Pytest (7) -yield and termination function
Use of sed in shell script
