【移动区域】增加一个移动区域面片专用shader

main
刘涛 2025-03-26 13:52:12 +08:00
parent 4933ba7800
commit 6c6210b214
3 changed files with 106 additions and 6 deletions

View File

@ -21,18 +21,17 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ground_area_mat_cannot
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
m_Shader: {fileID: 4800000, guid: b3965819cb8d8864c9a4dd369a2f57f8, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
m_ValidKeywords: []
m_InvalidKeywords:
- _ALPHATEST_ON
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2452
stringTagMap:
RenderType: TransparentCutout
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
@ -130,6 +129,7 @@ Material:
- _ColorMode: 0
- _Cull: 2
- _CullMode: 0
- _CutOff: 0.023
- _Cutoff: 0.083
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
@ -194,6 +194,7 @@ Material:
- _Color: {r: 0.36477974, g: 0.010132772, b: 0, a: 1}
- _ColorAddSubDiff: {r: 1, g: 0, b: 0, a: 0}
- _EmissionColor: {r: 0, g: 1.4794679, b: 0.31592146, a: 1}
- _MainColor: {r: 0.36477977, g: 0, b: 0, a: 1}
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
- _TintColor: {r: 0.83100003, g: 1, b: 0.49411762, a: 0.6039216}

View File

@ -0,0 +1,90 @@
Shader "NLD_URP/NLD_Scene_Unit_Inst_Opaque"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_MainColor ("Main Color", Color) = (1, 1, 1, 1)
_CutOff ("Alpha Clip", Range(0, 1)) = 0.5
}
SubShader
{
Tags {
"RenderType" = "Opaque"
"RenderPipeline" = "UniversalPipeline"
}
Pass
{
Tags
{
"LightMode" = "SRPDefaultUnlit"
}
ZWrite On
ZTest LEqual
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
// gpu instancing
#pragma multi_compile_instancing
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct appdata {
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
// UNITY_INSTANCING_BUFFER_START(UnityPerMaterial)
//
// UNITY_DEFINE_INSTANCED_PROP(float4, _MainTex_ST)
// UNITY_DEFINE_INSTANCED_PROP(float4, _MainColor)
// UNITY_DEFINE_INSTANCED_PROP(float, _CutOff)
//
// UNITY_INSTANCING_BUFFER_END(UnityPerMaterial)
float4 _MainColor;
float _CutOff;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
o.positionHCS = TransformObjectToHClip(v.positionOS);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
half4 frag (v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
// sample the texture
half4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
if (col.a < _CutOff)
{
discard;
}
col *= _MainColor;
return col;
}
ENDHLSL
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b3965819cb8d8864c9a4dd369a2f57f8
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: