studycase2

This commit is contained in:
2025-11-24 21:29:46 +08:00
parent 749719e862
commit 173fe7574b
608 changed files with 52537 additions and 39 deletions

View File

@@ -0,0 +1,123 @@
Shader "Custom/URPOutline"
{
Properties
{
_BaseColor("Base Color", Color) = (1,1,1,1)
_OutlineColor("Outline Color", Color) = (1,0,0,1)
_OutlineWidth("Outline Width", Range(0, 0.1)) = 0.05
}
SubShader
{
Tags
{
"RenderType"="Opaque"
"RenderPipeline"="UniversalPipeline"
"Queue"="Geometry"
}
// <20><>һ<EFBFBD><D2BB>Pass<73><73><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD>
Pass
{
Name "Outline"
Tags { "LightMode" = "SRPDefaultUnlit" }
Cull Front
ZWrite On
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
};
CBUFFER_START(UnityPerMaterial)
float4 _OutlineColor;
float _OutlineWidth;
CBUFFER_END
Varyings vert(Attributes input)
{
Varyings output;
// <20>ط<EFBFBD><D8B7>߷<EFBFBD><DFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>
float3 normalOS = normalize(input.normalOS);
float3 positionOS = input.positionOS.xyz + normalOS * _OutlineWidth;
output.positionCS = TransformObjectToHClip(positionOS);
return output;
}
half4 frag(Varyings input) : SV_Target
{
return _OutlineColor;
}
ENDHLSL
}
// <20>ڶ<EFBFBD><DAB6><EFBFBD>Pass<73><73><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><E5B1BE>
Pass
{
Name "ForwardLit"
Tags { "LightMode" = "UniversalForward" }
Cull Back
ZWrite On
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float3 normalWS : TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
float4 _BaseColor;
CBUFFER_END
Varyings vert(Attributes input)
{
Varyings output;
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
output.normalWS = TransformObjectToWorldNormal(input.normalOS);
return output;
}
half4 frag(Varyings input) : SV_Target
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Light mainLight = GetMainLight();
float3 normalWS = normalize(input.normalWS);
float NdotL = saturate(dot(normalWS, mainLight.direction));
float3 color = _BaseColor.rgb * (mainLight.color * NdotL + 0.2);
return half4(color, _BaseColor.a);
}
ENDHLSL
}
}
}