当前位置:网站首页>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
}
}
}边栏推荐
- 2022.02.14
- String and variable are spliced into variable name
- Go basic data types: characters and strings
- Go basic data type conversion
- Draw smooth curves - methods needed - drawing smooth curves - methods needed
- Benign competition will promote each other
- 百度小程序自动提交搜索
- Part 63 - interpreter and compiler adaptation (II)
- What are the uses of final?
- VerilogA——动态比较器
猜你喜欢

Pytest (7) -yield and termination function

VLAN experiment

Installing modules in pycharm

Call the computer calculator and use it to convert several base numbers

Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- length and angle measurement function

用机器人教育创造新一代生产和服务工具

Leetcode simple question: judging the color of a grid on a chess board

The generation of leetcode simple questions each character is an odd number of strings

Principle of screen printing adjustment of EDA (cadence and AD) software

There are two ways for golang to develop mobile applications
随机推荐
【OSPF引入直连路由时巧借静态黑洞路由做汇总】
Why are keys unordered in golang map
Are there too many programmers in China at present?
Week 10 - task 1- fill in the blank: line class inherits point class
Mongodb paging method
What are the uses of static?
Monitor employee turnover dynamics. This system makes employees tremble!
Longest substring between two identical characters of leetcode simple question
Analysis on the wave of learning robot education for children
What is MES? What does it do?
VerilogA——动态比较器
[C language series] - branch and loop statements
2022.02.15 - 240. Lucky number in matrix
How to combine two byte arrays [repeat] - how to combine two byte arrays [duplicate]
Implementation of queue
Analysis comp122 the Caesar cipher
Linux Installation redis
Antd work item memo w3.0
Principle of screen printing adjustment of EDA (cadence and AD) software
Agile invincible event
