This commit is contained in:
SoulliesOfficial
2026-01-21 00:31:23 -05:00
parent 66a1701087
commit 4fe6ee5f99
70 changed files with 1595 additions and 687 deletions

View File

@@ -0,0 +1,142 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: PseudoShadow
m_Shader: {fileID: 4800000, guid: c021be98004cdbc488ba46d630d8c33b, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords:
- USE_RIM
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 5392668a037c8bf49b4479948ee1f3fd, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _RimPower: 3
- _ShadowSmoothness: 0.74
- _ShadowStrength: 1
- _ShadowThreshold: 0.11
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _UseRim: 1
- _UseWorldLight: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0.6698113, g: 0.609781, b: 0.609781, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _FakeLightDir: {r: 0.23, g: 0.24, b: 0.24, a: 0}
- _RimColor: {r: 1, g: 1, b: 1, a: 1}
- _ShadowColor: {r: 0.22961909, g: 0.22961909, b: 0.299, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
--- !u!114 &1391350818744910211
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 7

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7a6fc2b30c0629b4588a962feb20e76e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,104 @@
Shader "Custom/ImprovedPseudoShadow" {
Properties {
[Header(Base)]
_MainTex ("Texture", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
[Header(Shadow)]
_ShadowColor ("Shadow Color", Color) = (0.2, 0.2, 0.3, 1) // 默认偏蓝的阴影
_ShadowThreshold ("Shadow Threshold", Range(-1,1)) = 0.0
_ShadowSmoothness ("Shadow Smoothness", Range(0,1)) = 0.1
[Header(Lighting Mode)]
_UseWorldLight ("Use Fixed World Light?", Range(0,1)) = 0
_FakeLightDir ("Fake Light Dir (XYZ)", Vector) = (0.5, 1, 0.5, 0) // 模拟从右上方来的光
}
SubShader {
Tags { "RenderType"="Transparent" }
LOD 100
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// 开启 GPU Instancing 支持
#pragma multi_compile_instancing
#include "UnityCG.cginc"
struct appdata {
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID // Instancing ID
};
struct v2f {
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
float lightFactor : TEXCOORD1; // 传递光照因子
UNITY_VERTEX_INPUT_INSTANCE_ID // Instancing ID
};
sampler2D _MainTex;
float4 _MainTex_ST;
// 声明 Instancing 属性变量
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color)
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ShadowColor)
UNITY_DEFINE_INSTANCED_PROP(float4, _FakeLightDir)
UNITY_DEFINE_INSTANCED_PROP(float, _ShadowThreshold)
UNITY_DEFINE_INSTANCED_PROP(float, _ShadowSmoothness)
UNITY_DEFINE_INSTANCED_PROP(float, _UseWorldLight)
UNITY_INSTANCING_BUFFER_END(Props)
v2f vert (appdata v) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(o, v);
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
float3 normalWorld = UnityObjectToWorldNormal(v.normal);
float3 lightDir;
float useWorldLight = UNITY_ACCESS_INSTANCED_PROP(Props, _UseWorldLight);
float3 fakeDir = normalize(UNITY_ACCESS_INSTANCED_PROP(Props, _FakeLightDir).xyz);
float3 viewDir = normalize(WorldSpaceViewDir(v.vertex));
// 用lerp实现分支
lightDir = normalize(lerp(viewDir, fakeDir, useWorldLight));
float dotProduct = dot(normalWorld, lightDir);
o.lightFactor = dotProduct;
return o;
}
fixed4 frag (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
// 获取属性
fixed4 mainColor = UNITY_ACCESS_INSTANCED_PROP(Props, _Color);
fixed4 shadowColor = UNITY_ACCESS_INSTANCED_PROP(Props, _ShadowColor);
float threshold = UNITY_ACCESS_INSTANCED_PROP(Props, _ShadowThreshold);
float smoothness = UNITY_ACCESS_INSTANCED_PROP(Props, _ShadowSmoothness);
fixed4 texCol = tex2D(_MainTex, i.uv) * mainColor;
// 改进2更平滑且可控的阈值计算 (Smoothstep)
// lightFactor 越大说明越直接面对光源
float lightIntensity = smoothstep(threshold, threshold + smoothness, i.lightFactor);
// 改进3基于光照强度的颜色插值 (Lerp)
// 0 (背光) -> ShadowColor
// 1 (受光) -> Texture Color
fixed3 finalRGB = lerp(shadowColor.rgb * texCol.rgb, texCol.rgb, lightIntensity);
return fixed4(finalRGB, texCol.a);
}
ENDCG
}
}
FallBack "VertexLit"
}

View File

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