40 changed files with 1415 additions and 94 deletions
@ -1 +1 @@ |
|||||||
{"_t":"MainSceneInitResource","InitResourceItems":[{"_t":"InitResourceItem","ConfigId":1001,"PosX":-13,"PosY":4.5,"MonsterGroupConfigId":0,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":1002,"PosX":-17,"PosY":1.5,"MonsterGroupConfigId":0,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2001,"PosX":18,"PosY":3,"MonsterGroupConfigId":0,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2003,"PosX":6,"PosY":3,"MonsterGroupConfigId":1,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2002,"PosX":-6,"PosY":0,"MonsterGroupConfigId":1,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2004,"PosX":-1.5,"PosY":7.75,"MonsterGroupConfigId":0,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2005,"PosX":6,"PosY":7.5,"MonsterGroupConfigId":1,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2002,"PosX":-9,"PosY":-4.5,"MonsterGroupConfigId":1,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2001,"PosX":10.5,"PosY":5.75,"MonsterGroupConfigId":0,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2001,"PosX":6.5,"PosY":10.25,"MonsterGroupConfigId":1,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2006,"PosX":12.5,"PosY":1.25,"MonsterGroupConfigId":1,"RefreshType":0,"RefreshParameter":0}]} |
{"_t":"MainSceneInitResource","InitResourceItems":[{"_t":"InitResourceItem","ConfigId":1001,"PosX":-13,"PosY":4.5,"MonsterGroupConfigId":0,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":1002,"PosX":-17,"PosY":1.5,"MonsterGroupConfigId":0,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2001,"PosX":18,"PosY":3,"MonsterGroupConfigId":0,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2002,"PosX":-6,"PosY":0,"MonsterGroupConfigId":1,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2002,"PosX":-9,"PosY":-4.5,"MonsterGroupConfigId":1,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2001,"PosX":10.5,"PosY":5.75,"MonsterGroupConfigId":0,"RefreshType":1,"RefreshParameter":0},{"_t":"InitResourceItem","ConfigId":2001,"PosX":6.5,"PosY":10.25,"MonsterGroupConfigId":1,"RefreshType":1,"RefreshParameter":0}]} |
Binary file not shown.
@ -1,3 +1,3 @@ |
|||||||
{"list":[ |
{"list":[ |
||||||
{"_t":"InitialResourceConfig","_id":1,"Food":100,"Water":100,"Wood":100,"Stone":100,"SilverTael":100,"GoldIngot":100,"Villagers":[1001,1002],"StartSeason":1,"StartTime":600}, |
{"_t":"InitialResourceConfig","_id":1,"Food":100,"Water":100,"Wood":100,"Stone":100,"SilverTael":100,"GoldIngot":100,"Villagers":[1,2,3,4,5,6,7],"StartSeason":1,"StartTime":600}, |
||||||
]} |
]} |
||||||
|
@ -1,3 +1,3 @@ |
|||||||
{"list":[ |
{"list":[ |
||||||
{"_t":"InitialResourceConfig","_id":1,"Food":100,"Water":100,"Wood":100,"Stone":100,"SilverTael":100,"GoldIngot":100,"Villagers":[1001,1002],"StartSeason":1,"StartTime":600}, |
{"_t":"InitialResourceConfig","_id":1,"Food":100,"Water":100,"Wood":100,"Stone":100,"SilverTael":100,"GoldIngot":100,"Villagers":[1,2,3,4,5,6,7],"StartSeason":1,"StartTime":600}, |
||||||
]} |
]} |
||||||
|
@ -0,0 +1,46 @@ |
|||||||
|
%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: 2DLight |
||||||
|
m_Shader: {fileID: 4800000, guid: e260cfa7296ee7642b167f1eb5be5023, type: 3} |
||||||
|
m_ValidKeywords: [] |
||||||
|
m_InvalidKeywords: [] |
||||||
|
m_LightmapFlags: 4 |
||||||
|
m_EnableInstancingVariants: 0 |
||||||
|
m_DoubleSidedGI: 0 |
||||||
|
m_CustomRenderQueue: -1 |
||||||
|
stringTagMap: {} |
||||||
|
disabledShaderPasses: [] |
||||||
|
m_SavedProperties: |
||||||
|
serializedVersion: 3 |
||||||
|
m_TexEnvs: |
||||||
|
- _AlphaTex: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
- _MainTex: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
- _MaskTex: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
- _NormalMap: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
m_Ints: [] |
||||||
|
m_Floats: |
||||||
|
- _EnableExternalAlpha: 0 |
||||||
|
m_Colors: |
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 1} |
||||||
|
- _Flip: {r: 1, g: 1, b: 1, a: 1} |
||||||
|
- _RendererColor: {r: 1, g: 1, b: 1, a: 1} |
||||||
|
m_BuildTextureStacks: [] |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 374868c26a9f55b4397a7e73227f54f3 |
||||||
|
NativeFormatImporter: |
||||||
|
externalObjects: {} |
||||||
|
mainObjectFileID: 2100000 |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,56 @@ |
|||||||
|
%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: GameObject |
||||||
|
m_Shader: {fileID: 4800000, guid: ead99fbd6ac1a744a84dc3d90b426628, type: 3} |
||||||
|
m_ValidKeywords: [] |
||||||
|
m_InvalidKeywords: [] |
||||||
|
m_LightmapFlags: 4 |
||||||
|
m_EnableInstancingVariants: 0 |
||||||
|
m_DoubleSidedGI: 0 |
||||||
|
m_CustomRenderQueue: -1 |
||||||
|
stringTagMap: {} |
||||||
|
disabledShaderPasses: [] |
||||||
|
m_SavedProperties: |
||||||
|
serializedVersion: 3 |
||||||
|
m_TexEnvs: |
||||||
|
- _AlphaTex: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
- _MainTex: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
- _MaskTex: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
- _NormalMap: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
m_Ints: [] |
||||||
|
m_Floats: |
||||||
|
- _DetectAlpha: 0.1 |
||||||
|
- _EFFECT_EDGE: 0 |
||||||
|
- _EFFECT_HIGHLIGHT: 0 |
||||||
|
- _EFFECT_HiGHLIGHT: 0 |
||||||
|
- _EnableExternalAlpha: 0 |
||||||
|
- _HaveEdgeEffect: 1 |
||||||
|
- _ImageCullAlpha: 0.2 |
||||||
|
- _PixelSize: 5.46 |
||||||
|
- _Smooth: 5.92 |
||||||
|
- _SmoothAlphaBase: 0.678 |
||||||
|
m_Colors: |
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 1} |
||||||
|
- _Flip: {r: 1, g: 1, b: 1, a: 1} |
||||||
|
- _OutLineColor: {r: 1, g: 0.21058662, b: 0, a: 1} |
||||||
|
- _RendererColor: {r: 1, g: 1, b: 1, a: 1} |
||||||
|
m_BuildTextureStacks: [] |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 802e1eafac60ee044aed8fc50fe0e7b1 |
||||||
|
NativeFormatImporter: |
||||||
|
externalObjects: {} |
||||||
|
mainObjectFileID: 2100000 |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,56 @@ |
|||||||
|
%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: GameObjectLit |
||||||
|
m_Shader: {fileID: 4800000, guid: 844b1f34770e3fe4aa7afbe4c622a6d0, type: 3} |
||||||
|
m_ValidKeywords: [] |
||||||
|
m_InvalidKeywords: [] |
||||||
|
m_LightmapFlags: 4 |
||||||
|
m_EnableInstancingVariants: 0 |
||||||
|
m_DoubleSidedGI: 0 |
||||||
|
m_CustomRenderQueue: -1 |
||||||
|
stringTagMap: {} |
||||||
|
disabledShaderPasses: [] |
||||||
|
m_SavedProperties: |
||||||
|
serializedVersion: 3 |
||||||
|
m_TexEnvs: |
||||||
|
- _AlphaTex: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
- _MainTex: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
- _MaskTex: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
- _NormalMap: |
||||||
|
m_Texture: {fileID: 0} |
||||||
|
m_Scale: {x: 1, y: 1} |
||||||
|
m_Offset: {x: 0, y: 0} |
||||||
|
m_Ints: [] |
||||||
|
m_Floats: |
||||||
|
- _DetectAlpha: 0.2 |
||||||
|
- _EFFECT_EDGE: 0 |
||||||
|
- _EFFECT_HIGHLIGHT: 0 |
||||||
|
- _EFFECT_HiGHLIGHT: 0 |
||||||
|
- _EnableExternalAlpha: 0 |
||||||
|
- _HaveEdgeEffect: 1 |
||||||
|
- _ImageCullAlpha: 0.718 |
||||||
|
- _PixelSize: 6 |
||||||
|
- _Smooth: 5.92 |
||||||
|
- _SmoothAlphaBase: 0.678 |
||||||
|
m_Colors: |
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 1} |
||||||
|
- _Flip: {r: 1, g: 1, b: 1, a: 1} |
||||||
|
- _OutLineColor: {r: 1, g: 0.21058662, b: 0, a: 1} |
||||||
|
- _RendererColor: {r: 1, g: 1, b: 1, a: 1} |
||||||
|
m_BuildTextureStacks: [] |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 760052f9f92321d44839e8d3342dac3c |
||||||
|
NativeFormatImporter: |
||||||
|
externalObjects: {} |
||||||
|
mainObjectFileID: 2100000 |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,141 @@ |
|||||||
|
Shader "PeachValley/GameObject" |
||||||
|
{ |
||||||
|
Properties |
||||||
|
{ |
||||||
|
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {} |
||||||
|
_Color ("Tint", Color) = (1,1,1,1) |
||||||
|
[PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {} |
||||||
|
[PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0 |
||||||
|
|
||||||
|
[Space] |
||||||
|
[Header(Edge)] |
||||||
|
[Toggle] _EFFECT_EDGE ("Enable Edge", Float) = 0 |
||||||
|
_OutLineColor ("Outline color", Color) = (0.804, 0.2, 0, 1)//描边颜色 |
||||||
|
_PixelSize ("Pixel Size", Range(0, 10)) = 6 |
||||||
|
_DetectAlpha ("DetectAlpha", Range(0, 0.2)) = 0.1 //四周的点算alpha平均,若大于则显示描边 |
||||||
|
_ImageCullAlpha ("ImageCullAlpha", Range(0, 1)) = 0.2 //当前所在的点若大于改值,则无条件原图 |
||||||
|
// _Smooth ("Smooth", Range(1, 10)) = 10 |
||||||
|
// _SmoothAlphaBase ("SmoothAlphaBase", Range(0, 1)) = 0.8 |
||||||
|
_HaveEdgeEffect ("HaveEdgeEffect", Range(0, 1)) = 1 |
||||||
|
|
||||||
|
[Space] |
||||||
|
[Header(Highlight)] |
||||||
|
[Toggle] _EFFECT_HIGHLIGHT("Enable Highlight", Float) = 0 |
||||||
|
} |
||||||
|
SubShader |
||||||
|
{ |
||||||
|
Tags |
||||||
|
{ |
||||||
|
"Queue"="Transparent" |
||||||
|
"IgnoreProjector"="True" |
||||||
|
"RenderType"="Transparent" |
||||||
|
"PreviewType"="Plane" |
||||||
|
"CanUseSpriteAtlas"="True" |
||||||
|
} |
||||||
|
|
||||||
|
Cull Off |
||||||
|
Lighting Off |
||||||
|
ZWrite Off |
||||||
|
Blend One OneMinusSrcAlpha |
||||||
|
|
||||||
|
Pass |
||||||
|
{ |
||||||
|
CGPROGRAM |
||||||
|
#pragma vertex vert |
||||||
|
#pragma fragment frag |
||||||
|
#pragma target 2.0 |
||||||
|
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA |
||||||
|
#pragma multi_compile _EFFECT_EDGE _EFFECT_EDGE_ON |
||||||
|
#pragma multi_compile _EFFECT_HIGHLIGHT _EFFECT_HIGHLIGHT_ON |
||||||
|
#include "UnityCG.cginc" |
||||||
|
|
||||||
|
struct appdata_t |
||||||
|
{ |
||||||
|
float4 vertex : POSITION; |
||||||
|
float4 color : COLOR; |
||||||
|
float2 texcoord : TEXCOORD0; |
||||||
|
}; |
||||||
|
|
||||||
|
struct v2f |
||||||
|
{ |
||||||
|
float4 vertex : SV_POSITION; |
||||||
|
fixed4 color : COLOR; |
||||||
|
float2 texcoord : TEXCOORD0; |
||||||
|
}; |
||||||
|
|
||||||
|
fixed4 _Color; |
||||||
|
|
||||||
|
v2f vert(appdata_t IN) |
||||||
|
{ |
||||||
|
v2f OUT; |
||||||
|
OUT.vertex = UnityObjectToClipPos(IN.vertex); |
||||||
|
OUT.texcoord = IN.texcoord; |
||||||
|
OUT.color = IN.color * _Color; |
||||||
|
#ifdef PIXELSNAP_ON |
||||||
|
OUT.vertex = UnityPixelSnap (OUT.vertex); |
||||||
|
#endif |
||||||
|
|
||||||
|
return OUT; |
||||||
|
} |
||||||
|
|
||||||
|
sampler2D _MainTex; |
||||||
|
sampler2D _AlphaTex; |
||||||
|
|
||||||
|
// for edge |
||||||
|
fixed4 _OutLineColor; |
||||||
|
float _PixelSize; |
||||||
|
float2 _MainTex_TexelSize; |
||||||
|
float _DetectAlpha; |
||||||
|
float _ImageCullAlpha; |
||||||
|
// float _Smooth; |
||||||
|
// float _SmoothAlphaBase; |
||||||
|
half _HaveEdgeEffect; |
||||||
|
|
||||||
|
void Edge(inout fixed4 outColor, half2 changedUV) |
||||||
|
{ |
||||||
|
_PixelSize = _PixelSize * _MainTex_TexelSize; |
||||||
|
// fixed4 color = tex2D(_MainTex, fixed2(changedUV.x, changedUV.y)); |
||||||
|
fixed color1 = tex2D(_MainTex, fixed2(changedUV.x + _PixelSize, changedUV.y + _PixelSize)).a; |
||||||
|
fixed color2 = tex2D(_MainTex, fixed2(changedUV.x - _PixelSize, changedUV.y - _PixelSize)).a; |
||||||
|
fixed color3 = tex2D(_MainTex, fixed2(changedUV.x + _PixelSize, changedUV.y - _PixelSize)).a; |
||||||
|
fixed color4 = tex2D(_MainTex, fixed2(changedUV.x - _PixelSize, changedUV.y + _PixelSize)).a; |
||||||
|
fixed a = (color1 + color2 + color3 + color4) / 4; |
||||||
|
int if1 = step(outColor.a, _ImageCullAlpha); |
||||||
|
int if2 = step(a, _DetectAlpha); |
||||||
|
// outColor = outColor* (1 - _HaveEdgeEffect) + _HaveEdgeEffect *(if1 * (((1 - if2) * fixed4(_OutLineColor.rgb, pow(a + _SmoothAlphaBase, _Smooth) * _OutLineColor.a))) + color * (1 - if1)); |
||||||
|
outColor = outColor* (1 - _HaveEdgeEffect) + _HaveEdgeEffect *(if1 * (((1 - if2) * _OutLineColor)) + outColor * (1 - if1)); |
||||||
|
} |
||||||
|
|
||||||
|
fixed4 SampleSpriteTexture (float2 uv) |
||||||
|
{ |
||||||
|
fixed4 color = tex2D (_MainTex, uv); |
||||||
|
|
||||||
|
#if ETC1_EXTERNAL_ALPHA |
||||||
|
fixed4 alpha = tex2D (_AlphaTex, uv); |
||||||
|
color.a = lerp (color.a, alpha.r, _EnableExternalAlpha); |
||||||
|
#endif |
||||||
|
|
||||||
|
return color; |
||||||
|
} |
||||||
|
|
||||||
|
fixed4 frag(v2f IN) : SV_Target |
||||||
|
{ |
||||||
|
fixed4 c = SampleSpriteTexture (IN.texcoord) * IN.color; |
||||||
|
|
||||||
|
#if _EFFECT_HIGHLIGHT_ON |
||||||
|
c.rgb *= fixed3(1.3, 1.3, 1.3); |
||||||
|
#endif |
||||||
|
|
||||||
|
#if _EFFECT_EDGE_ON |
||||||
|
Edge(c, IN.texcoord); |
||||||
|
#endif |
||||||
|
c.rgb *= c.a; |
||||||
|
|
||||||
|
return c; |
||||||
|
} |
||||||
|
|
||||||
|
ENDCG |
||||||
|
} |
||||||
|
} |
||||||
|
FallBack "Diffuse" |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: ead99fbd6ac1a744a84dc3d90b426628 |
||||||
|
ShaderImporter: |
||||||
|
externalObjects: {} |
||||||
|
defaultTextures: [] |
||||||
|
nonModifiableTextures: [] |
||||||
|
preprocessorOverride: 0 |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,334 @@ |
|||||||
|
Shader "PeachValley/GameObjectLit" |
||||||
|
{ |
||||||
|
Properties |
||||||
|
{ |
||||||
|
_MainTex("Diffuse", 2D) = "white" {} |
||||||
|
_MaskTex("Mask", 2D) = "white" {} |
||||||
|
_NormalMap("Normal Map", 2D) = "bump" {} |
||||||
|
|
||||||
|
// Legacy properties. They're here so that materials using this shader can gracefully fallback to the legacy sprite shader. |
||||||
|
[HideInInspector] _Color("Tint", Color) = (1,1,1,1) |
||||||
|
[HideInInspector] _RendererColor("RendererColor", Color) = (1,1,1,1) |
||||||
|
[HideInInspector] _Flip("Flip", Vector) = (1,1,1,1) |
||||||
|
[HideInInspector] _AlphaTex("External Alpha", 2D) = "white" {} |
||||||
|
[HideInInspector] _EnableExternalAlpha("Enable External Alpha", Float) = 0 |
||||||
|
|
||||||
|
[Space] |
||||||
|
[Header(Edge)] |
||||||
|
[Toggle] _EFFECT_EDGE ("Enable Edge", Float) = 0 |
||||||
|
_OutLineColor ("Outline color", Color) = (0.804, 0.2, 0, 1)//描边颜色 |
||||||
|
_PixelSize ("Pixel Size", Range(0, 10)) = 6 |
||||||
|
_DetectAlpha ("DetectAlpha", Range(0, 0.2)) = 0.1 //四周的点算alpha平均,若大于则显示描边 |
||||||
|
_ImageCullAlpha ("ImageCullAlpha", Range(0, 1)) = 0.2 //当前所在的点若大于改值,则无条件原图 |
||||||
|
// _Smooth ("Smooth", Range(1, 10)) = 10 |
||||||
|
// _SmoothAlphaBase ("SmoothAlphaBase", Range(0, 1)) = 0.8 |
||||||
|
_HaveEdgeEffect ("HaveEdgeEffect", Range(0, 1)) = 1 |
||||||
|
|
||||||
|
[Space] |
||||||
|
[Header(Highlight)] |
||||||
|
[Toggle] _EFFECT_HIGHLIGHT("Enable Highlight", Float) = 0 |
||||||
|
} |
||||||
|
|
||||||
|
SubShader |
||||||
|
{ |
||||||
|
Tags {"Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" } |
||||||
|
|
||||||
|
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha |
||||||
|
Cull Off |
||||||
|
ZWrite Off |
||||||
|
|
||||||
|
Pass |
||||||
|
{ |
||||||
|
Tags { "LightMode" = "Universal2D" } |
||||||
|
|
||||||
|
HLSLPROGRAM |
||||||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" |
||||||
|
|
||||||
|
#pragma vertex CombinedShapeLightVertex |
||||||
|
#pragma fragment CombinedShapeLightFragment |
||||||
|
|
||||||
|
#pragma multi_compile USE_SHAPE_LIGHT_TYPE_0 __ |
||||||
|
#pragma multi_compile USE_SHAPE_LIGHT_TYPE_1 __ |
||||||
|
#pragma multi_compile USE_SHAPE_LIGHT_TYPE_2 __ |
||||||
|
#pragma multi_compile USE_SHAPE_LIGHT_TYPE_3 __ |
||||||
|
#pragma multi_compile _ DEBUG_DISPLAY |
||||||
|
|
||||||
|
#pragma multi_compile _EFFECT_EDGE _EFFECT_EDGE_ON |
||||||
|
#pragma multi_compile _EFFECT_HIGHLIGHT _EFFECT_HIGHLIGHT_ON |
||||||
|
|
||||||
|
struct Attributes |
||||||
|
{ |
||||||
|
float3 positionOS : POSITION; |
||||||
|
float4 color : COLOR; |
||||||
|
float2 uv : TEXCOORD0; |
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID |
||||||
|
}; |
||||||
|
|
||||||
|
struct Varyings |
||||||
|
{ |
||||||
|
float4 positionCS : SV_POSITION; |
||||||
|
half4 color : COLOR; |
||||||
|
float2 uv : TEXCOORD0; |
||||||
|
half2 lightingUV : TEXCOORD1; |
||||||
|
#if defined(DEBUG_DISPLAY) |
||||||
|
float3 positionWS : TEXCOORD2; |
||||||
|
#endif |
||||||
|
UNITY_VERTEX_OUTPUT_STEREO |
||||||
|
}; |
||||||
|
|
||||||
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl" |
||||||
|
|
||||||
|
TEXTURE2D(_MainTex); |
||||||
|
SAMPLER(sampler_MainTex); |
||||||
|
TEXTURE2D(_MaskTex); |
||||||
|
SAMPLER(sampler_MaskTex); |
||||||
|
half4 _MainTex_ST; |
||||||
|
float4 _Color; |
||||||
|
half4 _RendererColor; |
||||||
|
|
||||||
|
#if USE_SHAPE_LIGHT_TYPE_0 |
||||||
|
SHAPE_LIGHT(0) |
||||||
|
#endif |
||||||
|
|
||||||
|
#if USE_SHAPE_LIGHT_TYPE_1 |
||||||
|
SHAPE_LIGHT(1) |
||||||
|
#endif |
||||||
|
|
||||||
|
#if USE_SHAPE_LIGHT_TYPE_2 |
||||||
|
SHAPE_LIGHT(2) |
||||||
|
#endif |
||||||
|
|
||||||
|
#if USE_SHAPE_LIGHT_TYPE_3 |
||||||
|
SHAPE_LIGHT(3) |
||||||
|
#endif |
||||||
|
|
||||||
|
Varyings CombinedShapeLightVertex(Attributes v) |
||||||
|
{ |
||||||
|
Varyings o = (Varyings)0; |
||||||
|
UNITY_SETUP_INSTANCE_ID(v); |
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); |
||||||
|
|
||||||
|
o.positionCS = TransformObjectToHClip(v.positionOS); |
||||||
|
#if defined(DEBUG_DISPLAY) |
||||||
|
o.positionWS = TransformObjectToWorld(v.positionOS); |
||||||
|
#endif |
||||||
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex); |
||||||
|
o.lightingUV = half2(ComputeScreenPos(o.positionCS / o.positionCS.w).xy); |
||||||
|
|
||||||
|
o.color = v.color * _Color * _RendererColor; |
||||||
|
return o; |
||||||
|
} |
||||||
|
|
||||||
|
// for edge |
||||||
|
half4 _OutLineColor; |
||||||
|
float _PixelSize; |
||||||
|
float2 _MainTex_TexelSize; |
||||||
|
float _DetectAlpha; |
||||||
|
float _ImageCullAlpha; |
||||||
|
// float _Smooth; |
||||||
|
// float _SmoothAlphaBase; |
||||||
|
half _HaveEdgeEffect; |
||||||
|
|
||||||
|
void Edge(inout half4 outColor, half2 changedUV) |
||||||
|
{ |
||||||
|
_PixelSize = _PixelSize * _MainTex_TexelSize; |
||||||
|
// fixed4 color = tex2D(_MainTex, fixed2(changedUV.x, changedUV.y)); |
||||||
|
half color1 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, half2(changedUV.x + _PixelSize, changedUV.y + _PixelSize)).a; |
||||||
|
half color2 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, half2(changedUV.x - _PixelSize, changedUV.y - _PixelSize)).a; |
||||||
|
half color3 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, half2(changedUV.x + _PixelSize, changedUV.y - _PixelSize)).a; |
||||||
|
half color4 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, half2(changedUV.x - _PixelSize, changedUV.y + _PixelSize)).a; |
||||||
|
half a = (color1 + color2 + color3 + color4) / 4; |
||||||
|
int if1 = step(outColor.a, _ImageCullAlpha); |
||||||
|
int if2 = step(a, _DetectAlpha); |
||||||
|
// outColor = outColor* (1 - _HaveEdgeEffect) + _HaveEdgeEffect *(if1 * (((1 - if2) * fixed4(_OutLineColor.rgb, pow(a + _SmoothAlphaBase, _Smooth) * _OutLineColor.a))) + color * (1 - if1)); |
||||||
|
outColor = outColor* (1 - _HaveEdgeEffect) + _HaveEdgeEffect *(if1 * (((1 - if2) * _OutLineColor)) + outColor * (1 - if1)); |
||||||
|
} |
||||||
|
|
||||||
|
void Outline(inout half4 outColor, half2 uv) |
||||||
|
{ |
||||||
|
float totalAlpha = 1.0; |
||||||
|
|
||||||
|
[unroll(16)] |
||||||
|
for (int i = 1; i < _PixelSize + 1; i++) { |
||||||
|
half4 pixelUp = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv + half2(0, i * _MainTex_TexelSize.y)); |
||||||
|
half4 pixelDown = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv - half2(0,i * _MainTex_TexelSize.y)); |
||||||
|
half4 pixelRight = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv + half2(i * _MainTex_TexelSize.x, 0)); |
||||||
|
half4 pixelLeft = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv - half2(i * _MainTex_TexelSize.x, 0)); |
||||||
|
|
||||||
|
totalAlpha = totalAlpha * pixelUp.a * pixelDown.a * pixelRight.a * pixelLeft.a; |
||||||
|
} |
||||||
|
|
||||||
|
if (totalAlpha == 0) { |
||||||
|
outColor.rgba = half4(1, 1, 1, 1) * _OutLineColor; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/CombinedShapeLightShared.hlsl" |
||||||
|
|
||||||
|
half4 CombinedShapeLightFragment(Varyings i) : SV_Target |
||||||
|
{ |
||||||
|
const half4 main = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv); |
||||||
|
const half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, i.uv); |
||||||
|
SurfaceData2D surfaceData; |
||||||
|
InputData2D inputData; |
||||||
|
|
||||||
|
InitializeSurfaceData(main.rgb, main.a, mask, surfaceData); |
||||||
|
InitializeInputData(i.uv, i.lightingUV, inputData); |
||||||
|
|
||||||
|
half4 outColor = CombinedShapeLightShared(surfaceData, inputData); |
||||||
|
|
||||||
|
#if _EFFECT_HIGHLIGHT_ON |
||||||
|
outColor.rgb *= half3(1.3, 1.3, 1.3); |
||||||
|
#endif |
||||||
|
|
||||||
|
#if _EFFECT_EDGE_ON |
||||||
|
// Edge(outColor, i.uv); |
||||||
|
Outline(outColor, i.uv); |
||||||
|
#endif |
||||||
|
|
||||||
|
return outColor; |
||||||
|
} |
||||||
|
ENDHLSL |
||||||
|
} |
||||||
|
|
||||||
|
Pass |
||||||
|
{ |
||||||
|
Tags { "LightMode" = "NormalsRendering"} |
||||||
|
|
||||||
|
HLSLPROGRAM |
||||||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" |
||||||
|
|
||||||
|
#pragma vertex NormalsRenderingVertex |
||||||
|
#pragma fragment NormalsRenderingFragment |
||||||
|
|
||||||
|
struct Attributes |
||||||
|
{ |
||||||
|
float3 positionOS : POSITION; |
||||||
|
float4 color : COLOR; |
||||||
|
float2 uv : TEXCOORD0; |
||||||
|
float4 tangent : TANGENT; |
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID |
||||||
|
}; |
||||||
|
|
||||||
|
struct Varyings |
||||||
|
{ |
||||||
|
float4 positionCS : SV_POSITION; |
||||||
|
half4 color : COLOR; |
||||||
|
float2 uv : TEXCOORD0; |
||||||
|
half3 normalWS : TEXCOORD1; |
||||||
|
half3 tangentWS : TEXCOORD2; |
||||||
|
half3 bitangentWS : TEXCOORD3; |
||||||
|
UNITY_VERTEX_OUTPUT_STEREO |
||||||
|
}; |
||||||
|
|
||||||
|
TEXTURE2D(_MainTex); |
||||||
|
SAMPLER(sampler_MainTex); |
||||||
|
TEXTURE2D(_NormalMap); |
||||||
|
SAMPLER(sampler_NormalMap); |
||||||
|
half4 _NormalMap_ST; // Is this the right way to do this? |
||||||
|
|
||||||
|
Varyings NormalsRenderingVertex(Attributes attributes) |
||||||
|
{ |
||||||
|
Varyings o = (Varyings)0; |
||||||
|
UNITY_SETUP_INSTANCE_ID(attributes); |
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); |
||||||
|
|
||||||
|
o.positionCS = TransformObjectToHClip(attributes.positionOS); |
||||||
|
o.uv = TRANSFORM_TEX(attributes.uv, _NormalMap); |
||||||
|
o.color = attributes.color; |
||||||
|
o.normalWS = -GetViewForwardDir(); |
||||||
|
o.tangentWS = TransformObjectToWorldDir(attributes.tangent.xyz); |
||||||
|
o.bitangentWS = cross(o.normalWS, o.tangentWS) * attributes.tangent.w; |
||||||
|
return o; |
||||||
|
} |
||||||
|
|
||||||
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/NormalsRenderingShared.hlsl" |
||||||
|
|
||||||
|
half4 NormalsRenderingFragment(Varyings i) : SV_Target |
||||||
|
{ |
||||||
|
const half4 mainTex = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv); |
||||||
|
const half3 normalTS = UnpackNormal(SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, i.uv)); |
||||||
|
|
||||||
|
return NormalsRenderingShared(mainTex, normalTS, i.tangentWS.xyz, i.bitangentWS.xyz, i.normalWS.xyz); |
||||||
|
} |
||||||
|
ENDHLSL |
||||||
|
} |
||||||
|
|
||||||
|
Pass |
||||||
|
{ |
||||||
|
Tags { "LightMode" = "UniversalForward" "Queue"="Transparent" "RenderType"="Transparent"} |
||||||
|
|
||||||
|
HLSLPROGRAM |
||||||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" |
||||||
|
|
||||||
|
#pragma vertex UnlitVertex |
||||||
|
#pragma fragment UnlitFragment |
||||||
|
|
||||||
|
struct Attributes |
||||||
|
{ |
||||||
|
float3 positionOS : POSITION; |
||||||
|
float4 color : COLOR; |
||||||
|
float2 uv : TEXCOORD0; |
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID |
||||||
|
}; |
||||||
|
|
||||||
|
struct Varyings |
||||||
|
{ |
||||||
|
float4 positionCS : SV_POSITION; |
||||||
|
float4 color : COLOR; |
||||||
|
float2 uv : TEXCOORD0; |
||||||
|
#if defined(DEBUG_DISPLAY) |
||||||
|
float3 positionWS : TEXCOORD2; |
||||||
|
#endif |
||||||
|
UNITY_VERTEX_OUTPUT_STEREO |
||||||
|
}; |
||||||
|
|
||||||
|
TEXTURE2D(_MainTex); |
||||||
|
SAMPLER(sampler_MainTex); |
||||||
|
float4 _MainTex_ST; |
||||||
|
float4 _Color; |
||||||
|
half4 _RendererColor; |
||||||
|
|
||||||
|
Varyings UnlitVertex(Attributes attributes) |
||||||
|
{ |
||||||
|
Varyings o = (Varyings)0; |
||||||
|
UNITY_SETUP_INSTANCE_ID(attributes); |
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); |
||||||
|
|
||||||
|
o.positionCS = TransformObjectToHClip(attributes.positionOS); |
||||||
|
#if defined(DEBUG_DISPLAY) |
||||||
|
o.positionWS = TransformObjectToWorld(v.positionOS); |
||||||
|
#endif |
||||||
|
o.uv = TRANSFORM_TEX(attributes.uv, _MainTex); |
||||||
|
o.color = attributes.color * _Color * _RendererColor; |
||||||
|
return o; |
||||||
|
} |
||||||
|
|
||||||
|
float4 UnlitFragment(Varyings i) : SV_Target |
||||||
|
{ |
||||||
|
float4 mainTex = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv); |
||||||
|
|
||||||
|
#if defined(DEBUG_DISPLAY) |
||||||
|
SurfaceData2D surfaceData; |
||||||
|
InputData2D inputData; |
||||||
|
half4 debugColor = 0; |
||||||
|
|
||||||
|
InitializeSurfaceData(mainTex.rgb, mainTex.a, surfaceData); |
||||||
|
InitializeInputData(i.uv, inputData); |
||||||
|
SETUP_DEBUG_DATA_2D(inputData, i.positionWS); |
||||||
|
|
||||||
|
if(CanDebugOverrideOutputColor(surfaceData, inputData, debugColor)) |
||||||
|
{ |
||||||
|
return debugColor; |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
return mainTex; |
||||||
|
} |
||||||
|
ENDHLSL |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Fallback "Sprites/Default" |
||||||
|
|
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 844b1f34770e3fe4aa7afbe4c622a6d0 |
||||||
|
ShaderImporter: |
||||||
|
externalObjects: {} |
||||||
|
defaultTextures: [] |
||||||
|
nonModifiableTextures: [] |
||||||
|
preprocessorOverride: 0 |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,21 @@ |
|||||||
|
using System; |
||||||
|
using FairyGUI; |
||||||
|
|
||||||
|
namespace ET |
||||||
|
{ |
||||||
|
public class FUIFarmlandWindow: Window |
||||||
|
{ |
||||||
|
public Action OnWindowShow; |
||||||
|
public Action OnWindowHide; |
||||||
|
|
||||||
|
protected override void OnShown() |
||||||
|
{ |
||||||
|
this.OnWindowShow?.Invoke(); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnHide() |
||||||
|
{ |
||||||
|
this.OnWindowHide?.Invoke(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
using UnityEngine; |
||||||
|
|
||||||
|
namespace ET.Util |
||||||
|
{ |
||||||
|
public class MaterialHelper : SingletonBase<MaterialHelper> |
||||||
|
{ |
||||||
|
public Material EdgeHighlightMat { get; } |
||||||
|
public Material HighlightMat { get; } |
||||||
|
public MaterialHelper() |
||||||
|
{ |
||||||
|
this.EdgeHighlightMat = new Material(Shader.Find("PeachValley/GameObject")); |
||||||
|
this.EdgeHighlightMat.EnableKeyword("_EFFECT_EDGE_ON"); |
||||||
|
this.EdgeHighlightMat.EnableKeyword("_EFFECT_HIGHLIGHT_ON"); |
||||||
|
|
||||||
|
this.HighlightMat = new Material(Shader.Find("PeachValley/GameObject")); |
||||||
|
this.HighlightMat.EnableKeyword("_EFFECT_HIGHLIGHT_ON"); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
namespace ET.Util |
||||||
|
{ |
||||||
|
using System; |
||||||
|
/// <summary> |
||||||
|
/// A base class for the singleton design pattern. |
||||||
|
/// https://www.codeproject.com/Articles/572263/A-Reusable-Base-Class-for-the-Singleton-Pattern-in |
||||||
|
/// </summary> |
||||||
|
/// <typeparam name="T">Class type of the singleton</typeparam> |
||||||
|
public abstract class SingletonBase<T> where T : class
|
||||||
|
{ |
||||||
|
#region Members |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Static instance. Needs to use lambda expression |
||||||
|
/// to construct an instance (since constructor is private). |
||||||
|
/// </summary> |
||||||
|
private static readonly Lazy<T> sInstance = new Lazy<T>(() => CreateInstanceOfT()); |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Properties |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets the instance of this singleton. |
||||||
|
/// </summary> |
||||||
|
public static T Instance { get { return sInstance.Value; } } |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Methods |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Creates an instance of T via reflection since T's constructor is expected to be private. |
||||||
|
/// </summary> |
||||||
|
/// <returns></returns> |
||||||
|
private static T CreateInstanceOfT() |
||||||
|
{ |
||||||
|
return Activator.CreateInstance(typeof(T)) as T; |
||||||
|
//return new T(); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue