Squashed commit of the following:

commit 994279b09e8676155176aecbcd43f13ab90f2c92
Author: SAIPO <grasste0403@hotmail.com>
Date:   Mon Nov 29 23:59:44 2021 +0800

    任务:编写效果Shader
    1.增加了通过高斯模糊公式实现的高斯模糊shader(建议用在背景层,让画面有一些景深感觉)
    2.增加了像素化的shader,通过在片元着色器上的uv合并,可以使贴图变为像素风格
    3.增加了闪光划过的shader

commit 271e45aeb97212640573a9faf71483cece293043
Author: SAIPO <grasste0403@hotmail.com>
Date:   Mon Nov 29 23:09:30 2021 +0800

    11.29合并分支

commit dfa618fabaf36626e1b92e7ab34c87d497bcdeb3
Author: SAIPO <grasste0403@hotmail.com>
Date:   Sat Nov 27 13:42:16 2021 +0800

    合并分支

commit de8d79b73e560814ff9fc8a0c3418009682c5ef8
Author: SAIPO <grasste0403@hotmail.com>
Date:   Tue Nov 23 21:25:44 2021 +0800

    任务:搭建Mysql数据库相关框架
    1.完成Mysql动态链接库的导入
    2.实现基本的服务器连接数据框架
    3.实现Sql语句查询框架

# Conflicts:
#	Assets/Behavior Designer/Resources/BehaviorDesignerGlobalVariables.asset.meta
#	Assets/Demigiant/DOTween/Editor.meta
#	Assets/Fungus/Integrations/Playmaker/Fungus-PlayMaker.unitypackage.meta
#	Assets/Fungus/Integrations/Spine/Fungus-Spine.unitypackage.meta
#	Assets/Plugins/Sirenix/Demos/Custom Attribute Processors.unitypackage.meta
#	Assets/Plugins/Sirenix/Demos/Custom Drawers.unitypackage.meta
#	Assets/Plugins/Sirenix/Demos/Editor Windows.unitypackage.meta
#	Assets/Plugins/Sirenix/Demos/Sample - RPG Editor.unitypackage.meta
#	Assets/Shader.meta
#	Assets/Shader/像素化.meta
This commit is contained in:
Roman 2021-11-30 00:50:39 +08:00
parent ff4639d2cf
commit f4b96539c5
16 changed files with 451 additions and 20 deletions

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: ed09910c0094cb27be8f3ca264680da3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: cc355dd4cf1e6173beaeb22c2858cbe1
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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: pixelStyle
m_Shader: {fileID: 4800000, guid: cc03c594f26dca54a865a79095019c2a, 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:
- _PixelSize: 23
m_Colors: []
m_BuildTextureStacks: []

View File

@ -1,7 +1,8 @@
fileFormatVersion: 2
guid: f597f19f656ba56eae4f6a3a7cc528f4
DefaultImporter:
guid: f33e0f1f7dc1db64c87cfa0b1e4187e1
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,75 @@
Shader "Unlit/pixelStyle"
{
//                                     
//                     
//                                
//                  
//                   
//                       
//                      
//                   
//                       
//                   
//                       
//                      
//                         
//                                                                                        
Properties
{
_MainTex("Texture", 2D) = "white" {}
_PixelSize("Pixel Size", Range(1,256)) = 64 //转化后的像素大小
}
SubShader
{
Tags { "RenderType"="Opaque" }
Blend SrcAlpha OneMinusSrcAlpha
LOD 100
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;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _PixelSize;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col;
float ratioX = (int)(i.uv.x * _PixelSize) / _PixelSize;
float ratioY = (int)(i.uv.y * _PixelSize) / _PixelSize;
col = tex2D(_MainTex, float2(ratioX, ratioY));
if (col.a < 0.5)
{
col.a = 0;
}
return col;
}
ENDCG
}
}
}

View File

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

View File

@ -1,5 +1,6 @@
fileFormatVersion: 2
guid: 81dbcde0f90df4e9ba9ca2794490e57a
guid: 96bbccba323c8ef45b7e0316c6125152
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:

View File

@ -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: Custom_Flash
m_Shader: {fileID: 4800000, guid: 0b518c54844bba34f8dbececf7a524d1, 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:
- _Angle: 80
- _DelayTime: 0.2
- _FlashTime: 1
- _LoopInterval: 2
- _Width: 0.2
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []

View File

@ -1,7 +1,8 @@
fileFormatVersion: 2
guid: 48e08dc33330d11e9d4a1b246c52e4f6
DefaultImporter:
guid: dd84cc2fc2c79654d964910278d4d10a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,121 @@
Shader "Custom/Flash"
{
//                        
//               
//                     
//                      
//                      
//             
//                       
//                      
//                     
//                  
//                   
//                     
//                
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {}
_Color("Color", Color) = (1,1,1,1)
_Angle("angle", Range(0, 360)) = 75
_Width("width", Range(0, 1)) = 0.2
_FlashTime("flash time", Range(0, 100)) = 1
_DelayTime("delay time", Range(0, 100)) = 0.2
_LoopInterval("interval time", Range(0, 100)) = 2
}
SubShader
{
LOD 200
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Pass
{
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Offset -1, -1
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _Color;
float _Angle;
float _Width;
float _FlashTime;
float _DelayTime;
float _LoopInterval;
float4 _MainTex_ST;
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
v2f o;
v2f vert (appdata_t v)
{
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
o.color = v.color;
return o;
}
// 计算亮度
//角度 宽度(x方向) 运行时间 开始时间 循环间隔
float flash(float2 uv, float angle, float w, float runtime, float delay, float interval)
{
float brightness = 0;
float radian = 0.0174444 * angle;
float curtime = _Time.y; //当前时间
float starttime = floor(curtime/interval) * interval; //本次flash开始时间
float passtime = curtime - starttime;//本次flash流逝时间
if (passtime > delay)
{
float projx = uv.y / tan(radian); //y的x投影长度
float br = (passtime - delay) / runtime; //底部右边界
float bl = br - w; //底部左边界
float posr = br + projx; //此点所在行右边界
float posl = bl + projx; //此点所在行左边界
if (uv.x > posl && uv.x < posr)
{
float mid = (posl + posr) * 0.5; //flash中心点
brightness = 1 - abs(uv.x - mid)/(w*0.5);
}
}
return brightness;
}
float4 frag (v2f i) : COLOR
{
float4 col = tex2D(_MainTex, i.texcoord);
float bright = flash(i.texcoord, _Angle, _Width, _FlashTime, _DelayTime, _LoopInterval);
float4 outcol = col + _Color*bright * col.a;// * step(0.5, col.a);
return outcol;
}
ENDCG
}
}
}

View File

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

View File

@ -1,5 +1,6 @@
fileFormatVersion: 2
guid: fd02c799f3f5c4c83b2fc26c105a3821
guid: 35a3095c7f6403b4d9b8bb90d77e374c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:

View File

@ -0,0 +1,114 @@
Shader "Unlit/GaussianBlur"
{
//
//                                                   
//                                      
//                
//                                  
//                            
//                           
//                                     
//                         
//                           
//                             
//                                    
//                            
//                                       
//                                                                                                                      
Properties
{
_MainTex ("Texture", 2D) = "white" {} //基础贴图
_BlurRadius ("BlurRadius", Range(2, 15)) = 5 //模糊半径
_TextureSize ("TextureSize", Float) = 640
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
int _BlurRadius;
float _TextureSize;
float GetGaussWeight(float x, float y, float sigma)
{
float sigma2 = pow(sigma, 2.0f); //pow 次方公式 这里是平方
float left = 1 / (2 * sigma2 * 3.1415926f);
float right = exp(-(x*x+y*y)/(2*sigma2)); //e的指数幂
return left * right;
}
fixed4 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(_MainTex, uv + float2(x / _TextureSize, y / _TextureSize));
//获取此像素的权重
float weight = GetGaussWeight(x, y, sigma);
//计算此点的最终颜色
col += color * weight; //颜色乘以权重
}
}
return col;
}
fixed4 SimpleBlur(float2 uv)
{
float4 col = float4(0, 0, 0, 0);
for (int x = - _BlurRadius; x <= _BlurRadius; ++x)
{
for (int y = - _BlurRadius; y <= _BlurRadius; ++y)
{
float4 color = tex2D(_MainTex, uv + float2(x / _TextureSize, y / _TextureSize));
col += color;
}
}
//取平均数,所取像素为边长为(半径*2+1)的矩阵
col = col / pow(_BlurRadius * 2 + 1, 2.0f);
return col;
}
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float4 col = SimpleBlur(i.uv);
return col;
}
ENDCG
}
}
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 964cfd1fc6adf4c4b9805c17662d195c
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,30 @@
%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_GaussianBlur
m_Shader: {fileID: 4800000, guid: 964cfd1fc6adf4c4b9805c17662d195c, 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:
- _BlurRadius: 15
- _TextureSize: 640
m_Colors: []
m_BuildTextureStacks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 27f35ce513c18264f8a0613e66fbcf7c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant: