当前位置:网站首页>Unity ar shadow shadow
Unity ar shadow shadow
2022-06-29 06:37:00 【Cute captain Timo】
cause :
I searched a lot of Internet Shader,BuildIn Default render pipeline , It 's not easy .
stay Scene The view is normal , stay Game It's just dark , Then you can't see the shadow after packing . You can't use it anyway .
After searching, it is possible that BuildIn perhaps shader The question of , Can not use , Then keep looking ( Split )


result :
The project is upgraded to URP, It's changing shader , Shadow appears
upgrade URP You need to pay attention to material upgrading , And how to create SRP Basic configuration
Configuring AR Camera Background with a Scriptable Render Pipeline | AR Foundation | 3.0.1
design sketch :

Easy to use words , Remember the praise. 、 Focus on 、 Collect a piece of Sanlian
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
}
}
}边栏推荐
- Why are keys unordered in golang map
- What are the uses of final?
- 关于DDNS
- Easy to understand TCP four waves (multi picture explanation)
- QT (x): innosetup for software packaging
- 目标检测——使用yolov6进行视频推理
- How does MySQL implement distributed locks?
- Client and server working modes of JVM
- ASP. Net core 6 framework unveiling example demonstration [03]:dapr initial experience
- I would like to ask what securities dealers recommend? Is it safe to open an account online?
猜你喜欢

Monitor employee turnover dynamics. This system makes employees tremble!

Labor skills courses integrated into steam Education

Chapter IV introduction to FPGA development platform

Delete tag

Segment in Lucene

VLAN experiment

How to change the password after forgetting the MySQL password (the latest version of 2022 detailed tutorial nanny level)

Observer mode vs publish subscribe mode

What is the "danksharding" of V God Kop on Valentine's day?

用机器人教育创造新一代生产和服务工具
随机推荐
Mongodb sort function
Convert data frame with date column to timeseries
The most complete machine learning model training process
关于 localStorage 的一些高阶用法
Installing modules in pycharm
Jenkins operation Chapter 5 trigger, configuration webhook, Jenkins parameterized construction
Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- multi axis mirroring function
Unity AR Shadow 阴影
Implementation of queue
Rich material libraries make modeling easy and efficient for developers
Week 10 - task 3- from point to circle to cylinder
QT (x): innosetup for software packaging
National Defense University project summary
Two houses with different colors and the farthest distance
Linux Installation redis
Stack -- 739 Daily temperature
Analysis on the wave of learning robot education for children
[C language series] - branch and loop statements
Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- length and angle measurement function
Go compile source code (window environment)
