diff --git a/Assets/Shader.meta b/Assets/Shader.meta new file mode 100644 index 0000000..0927acc --- /dev/null +++ b/Assets/Shader.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f8975581ee3d3b44b5f923fba5b7c04 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shader/转场.meta b/Assets/Shader/转场.meta new file mode 100644 index 0000000..6132238 --- /dev/null +++ b/Assets/Shader/转场.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 05ac7bbe423ae334a93df7b81daa457d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shader/转场/LoadScreen.shader b/Assets/Shader/转场/LoadScreen.shader new file mode 100644 index 0000000..47b29d1 --- /dev/null +++ b/Assets/Shader/转场/LoadScreen.shader @@ -0,0 +1,94 @@ +Shader "Unlit/LoadScreen" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _BlurRadius ("BlurRadius", Range(0, 50)) = 0 //模糊半径 + _TextureSize ("TextureSize", Float) = 640 + _SecTex("SecTex",2D) = "white" {} + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + // make fog work + #pragma multi_compile_fog + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + UNITY_FOG_COORDS(1) + float4 vertex : SV_POSITION; + }; + + sampler2D _MainTex; + sampler2D _SecTex; + float4 _MainTex_ST; + int _BlurRadius; + float _TextureSize; + float GetGaussWeight(float x, float y, float sigma) + { + float sigma2 = pow(sigma, 2.0f); + float left = 1 / (2 * sigma2 * 3.1415926f); + float right = exp(-(x*x+y*y)/(2*sigma2)); //e的指数幂 + return left * right; + } + + float4 GaussBlur(float2 uv) //高斯公式 + { + float sigma = (float)_BlurRadius / 3.0f;//权重 + float4 col = float4(0, 0, 0, 0); + for (int x = - _BlurRadius; x <= _BlurRadius; ++x) + { + for (int y = - _BlurRadius; y <= _BlurRadius; ++y) + { + //获取周围像素的颜色 + //转为uv上的坐标值 + float4 color = tex2D(_SecTex, uv + float2(x / _TextureSize, y / _TextureSize)); + //获取此像素的权重 + float weight = GetGaussWeight(x, y, sigma); + //计算此点的最终颜色 + col += color * weight; //颜色乘以权重 + } + } + return col; + } + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + UNITY_TRANSFER_FOG(o,o.vertex); + return o; + } + + float4 frag (v2f i) : SV_Target + { + float4 black = float4(0,0,0,0); + float4 col = GaussBlur(i.uv); + col*=1+_BlurRadius; + col=smoothstep(0.1,0.9,col); + col=step(col,0.5); + col*=tex2D(_MainTex,i.uv); + col = lerp(col,black,_BlurRadius*(1.0/50)); + return col; + } + ENDCG + } + } +} diff --git a/Assets/Shader/转场/LoadScreen.shader.meta b/Assets/Shader/转场/LoadScreen.shader.meta new file mode 100644 index 0000000..e430c06 --- /dev/null +++ b/Assets/Shader/转场/LoadScreen.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d51f93ad8a827f544904c4d2f8a1d1d8 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shader/转场/Unlit_LoadScreen.mat b/Assets/Shader/转场/Unlit_LoadScreen.mat new file mode 100644 index 0000000..2701ae6 --- /dev/null +++ b/Assets/Shader/转场/Unlit_LoadScreen.mat @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Unlit_LoadScreen + m_Shader: {fileID: 4800000, guid: d51f93ad8a827f544904c4d2f8a1d1d8, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SecTex: + m_Texture: {fileID: 8400000, guid: d8cdceb52a559c745b57588acf28ed1f, type: 2} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BlurRadius: 0 + - _TextureSize: 640 + m_Colors: [] + m_BuildTextureStacks: [] diff --git a/Assets/Shader/转场/Unlit_LoadScreen.mat.meta b/Assets/Shader/转场/Unlit_LoadScreen.mat.meta new file mode 100644 index 0000000..a40979f --- /dev/null +++ b/Assets/Shader/转场/Unlit_LoadScreen.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2a4f749e5c54eee4898623e6f54feaaf +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shader/转场/oB.shader b/Assets/Shader/转场/oB.shader new file mode 100644 index 0000000..d0dbf29 --- /dev/null +++ b/Assets/Shader/转场/oB.shader @@ -0,0 +1,99 @@ +Shader "pp/ScreenEffectShader" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _Color("color",Color) = (1,1,1,1) + + + } + SubShader + { + // No culling or depth + Cull Off ZWrite Off ZTest Always + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + float4 vertex : SV_POSITION; + }; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = v.uv; + return o; + } + + sampler2D _MainTex; + sampler2D _GulussTex; + float4 _MainTex_TexelSize; + float4 _GulussTex_TexelSize; + float3 _Color; + float _BlurRadius; + float _Radius; + + static float r = 1; + + fixed luminance(fixed3 col) + { + return col.x * 0.299 + col.y * 0.587 + col.z * 0.114; + } + + fixed4 frag (v2f i) : SV_Target + { + + fixed3 col = tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(-1,-1)).rgb * -1; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(0,-1)).rgb * -2; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(1,-1)).rgb * -1; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(-1,0)).rgb * 0; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(0,0)).rgb * 0; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(1,0)).rgb * 0; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(-1,1)).rgb * 1; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(0,1)).rgb * 2; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(1,1)).rgb * 1; + + fixed gray = abs(luminance(col)); + + col = tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(-1,-1)).rgb * -1; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(0,-1)).rgb * 0; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(1,-1)).rgb * 1; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(-1,0)).rgb * -2; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(0,0)).rgb * 0; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(1,0)).rgb * 2; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(-1,1)).rgb * -1; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(0,1)).rgb * 0; + col += tex2D(_MainTex,i.uv + _MainTex_TexelSize.xy*r*fixed2(1,1)).rgb * 1; + + gray += abs(luminance(col)); + + fixed3 enhance = fixed3(gray, gray, gray)*_Color; + + //fixed3 ori = tex2D(_MainTex, i.uv).rgb + enhance * 0.5; + + return fixed4(enhance,1); + } + + ENDCG + } + + + } + + FallBack Off +} \ No newline at end of file diff --git a/Assets/Shader/转场/oB.shader.meta b/Assets/Shader/转场/oB.shader.meta new file mode 100644 index 0000000..3891bbb --- /dev/null +++ b/Assets/Shader/转场/oB.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c4a1de8de8fd5ff449c6860268d1afb7 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shader/转场/pp_ScreenEffectShader.mat b/Assets/Shader/转场/pp_ScreenEffectShader.mat new file mode 100644 index 0000000..d7cb529 --- /dev/null +++ b/Assets/Shader/转场/pp_ScreenEffectShader.mat @@ -0,0 +1,29 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: pp_ScreenEffectShader + m_Shader: {fileID: 4800000, guid: c4a1de8de8fd5ff449c6860268d1afb7, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: [] + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Shader/转场/pp_ScreenEffectShader.mat.meta b/Assets/Shader/转场/pp_ScreenEffectShader.mat.meta new file mode 100644 index 0000000..e286e79 --- /dev/null +++ b/Assets/Shader/转场/pp_ScreenEffectShader.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 80f9c88836cf1aa4b92196b9fa4751a8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shader/转场/描边.renderTexture b/Assets/Shader/转场/描边.renderTexture new file mode 100644 index 0000000..689c517 --- /dev/null +++ b/Assets/Shader/转场/描边.renderTexture @@ -0,0 +1,38 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!84 &8400000 +RenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: "\u63CF\u8FB9" + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + m_IsAlphaChannelOptional: 0 + serializedVersion: 3 + m_Width: 1920 + m_Height: 1080 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 2 + m_ColorFormat: 8 + m_MipMap: 0 + m_GenerateMips: 1 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 1 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 diff --git a/Assets/Shader/转场/描边.renderTexture.meta b/Assets/Shader/转场/描边.renderTexture.meta new file mode 100644 index 0000000..1bc8a46 --- /dev/null +++ b/Assets/Shader/转场/描边.renderTexture.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d8cdceb52a559c745b57588acf28ed1f +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 8400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/URP/HLRenderPass.cs b/Assets/URP/HLRenderPass.cs new file mode 100644 index 0000000..b2aca82 --- /dev/null +++ b/Assets/URP/HLRenderPass.cs @@ -0,0 +1,53 @@ +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + + public class HLRenderPass : ScriptableRenderPass + { + public Material mMat; + public int blitShaderPassIndex = 0; + public FilterMode filterMode { get; set; } + private RenderTargetIdentifier source { get; set; } + private RenderTargetHandle destination { get; set; } + RenderTargetHandle m_temporaryColorTexture; + + string m_ProfilerTag; + public HLRenderPass(string passname, RenderPassEvent _event, Material _mat,float contrast) + { + m_ProfilerTag = passname; + this.renderPassEvent = _event; + mMat = _mat; + mMat.SetFloat("_Contrast", contrast); + m_temporaryColorTexture.Init("temporaryColorTexture"); + } + public void Setup(RenderTargetIdentifier src, RenderTargetHandle dest) + { + this.source = src; + this.destination = dest; + } + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + CommandBuffer cmd = CommandBufferPool.Get(m_ProfilerTag); + + RenderTextureDescriptor opaqueDesc = renderingData.cameraData.cameraTargetDescriptor; + opaqueDesc.depthBufferBits = 0; + if (destination == RenderTargetHandle.CameraTarget) + { + cmd.GetTemporaryRT(m_temporaryColorTexture.id, opaqueDesc, filterMode); + Blit(cmd, source, m_temporaryColorTexture.Identifier(), mMat, blitShaderPassIndex); + Blit(cmd, m_temporaryColorTexture.Identifier(), source); + } + else + { + Blit(cmd, source, destination.Identifier(), mMat, blitShaderPassIndex); + } + context.ExecuteCommandBuffer(cmd); + CommandBufferPool.Release(cmd); + } + + public override void FrameCleanup(CommandBuffer cmd) + { + if (destination == RenderTargetHandle.CameraTarget) + cmd.ReleaseTemporaryRT(m_temporaryColorTexture.id); + } + } diff --git a/Assets/URP/HLRenderPass.cs.meta b/Assets/URP/HLRenderPass.cs.meta new file mode 100644 index 0000000..4d80e0b --- /dev/null +++ b/Assets/URP/HLRenderPass.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8f0d9b79fa606ed4c9ad4a0b26a34a6c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/URP/RenderPassFeature.cs b/Assets/URP/RenderPassFeature.cs new file mode 100644 index 0000000..cac03b9 --- /dev/null +++ b/Assets/URP/RenderPassFeature.cs @@ -0,0 +1,51 @@ +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + + public class RenderPassFeature : ScriptableRendererFeature + { + public enum Target + { + Color, + Texture + } + [System.Serializable] + public class HLSettings + { + public RenderPassEvent renderPassEvent = RenderPassEvent.AfterRenderingSkybox; + public Material mMat; + public Target destination = Target.Color; + public int blitMaterialPassIndex = -1; + public string textureId = "_ScreenTexture"; + public float contrast = 0.5f; + } + + public HLSettings settings = new HLSettings(); + RenderTargetHandle m_renderTargetHandle; + + HLRenderPass m_ScriptablePass; + + public override void Create() + { + int passIndex = settings.mMat != null ? settings.mMat.passCount - 1 : 1; + settings.blitMaterialPassIndex = Mathf.Clamp(settings.blitMaterialPassIndex, -1, passIndex); + m_ScriptablePass = new HLRenderPass("HLPostEffectRender", settings.renderPassEvent, settings.mMat, settings.contrast); + m_renderTargetHandle.Init(settings.textureId); + } + + + public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) + { + var src = renderer.cameraColorTarget; + var dest = (settings.destination == Target.Color) ? RenderTargetHandle.CameraTarget : m_renderTargetHandle; + if (settings.mMat == null) + { + Debug.LogWarningFormat("丢失blit材质"); + return; + } + m_ScriptablePass.Setup(src,dest); + renderer.EnqueuePass(m_ScriptablePass); + } + } + + diff --git a/Assets/URP/RenderPassFeature.cs.meta b/Assets/URP/RenderPassFeature.cs.meta new file mode 100644 index 0000000..862f8ce --- /dev/null +++ b/Assets/URP/RenderPassFeature.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f339cedbc8ff35843b05671c5ea71a2f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index 2f87e15..0aa92fd 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -6,26 +6,14 @@ EditorUserSettings: serializedVersion: 4 m_ConfigSettings: RecentlyUsedScenePath-0: - value: 224247031146466b011b0b2b1e301034131a112d25292824620d3207f5e53136d2f539a9c2223e31290eea2f4b1a2e0be50f0c05d7050306101af4011fc0311707c416c61fcc5109c51008d7 - flags: 0 - RecentlyUsedScenePath-1: - value: 224247031146466b011b0b2b1e301034131a112d25292824620d3207f5e53136d2f539a9c2223e31290eea2f4b1a2e0be50f0c05c60a1e035f1bf30705e6 - flags: 0 - RecentlyUsedScenePath-2: - value: 224247031146466b011b0b2b1e301034131a112d25292824620d3207f5e53136d2f539a9c2223e31290eea2f4b1a2e0be50f0c05d7050306101af4011fc0321202cc1bd654dd1115df00 - flags: 0 - RecentlyUsedScenePath-3: value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d flags: 0 - RecentlyUsedScenePath-4: + RecentlyUsedScenePath-1: value: 22424703114646680e0b0227036cdafbfb5831243c3d3204283a097df7ee3d2cfb flags: 0 - RecentlyUsedScenePath-5: + RecentlyUsedScenePath-2: value: 22424703114646680e0b0227036cdafbfb583124382d34312e3d2936f1f47a2decee22f0 flags: 0 - RecentlyUsedScenePath-6: - value: 22424703114646680e0b0227036cdbc9e6582b2b21382a357c67083debf42d - flags: 0 vcSharedLogLevel: value: 0d5e400f0650 flags: 0