-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
537 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!21 &2100000 | ||
Material: | ||
serializedVersion: 6 | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInternal: {fileID: 0} | ||
m_Name: PixelMaskCut | ||
m_Shader: {fileID: 4800000, guid: 0575c9a6c829af54b8afea2e0da24048, type: 3} | ||
m_ShaderKeywords: | ||
m_LightmapFlags: 4 | ||
m_EnableInstancingVariants: 0 | ||
m_DoubleSidedGI: 0 | ||
m_CustomRenderQueue: -1 | ||
stringTagMap: {} | ||
disabledShaderPasses: [] | ||
m_SavedProperties: | ||
serializedVersion: 3 | ||
m_TexEnvs: | ||
- _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: 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} | ||
- _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} | ||
m_Floats: | ||
- _BumpScale: 1 | ||
- _Cutoff: 0.5 | ||
- _DetailNormalMapScale: 1 | ||
- _DstBlend: 0 | ||
- _GlossMapScale: 1 | ||
- _Glossiness: 0.5 | ||
- _GlossyReflections: 1 | ||
- _Metallic: 0 | ||
- _Mode: 0 | ||
- _OcclusionStrength: 1 | ||
- _Parallax: 0.02 | ||
- _PosX: 0 | ||
- _PosY: 0 | ||
- _SizeX: 0 | ||
- _SizeY: 0 | ||
- _SmoothnessTextureChannel: 0 | ||
- _SpecularHighlights: 1 | ||
- _SrcBlend: 1 | ||
- _UVSec: 0 | ||
- _ZWrite: 1 | ||
m_Colors: | ||
- _Color: {r: 1, g: 1, b: 1, a: 1} | ||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | ||
|
||
Shader "PixelMaskCut" | ||
{ | ||
Properties | ||
{ | ||
_MainTex ("Texture", 2D) = "white" {} | ||
_MaskTex ("Texture", 2D) = "white" {} | ||
_SizeX("Size X", float) = 0.0 | ||
_SizeY("Size Y", float) = 0.0 | ||
_PosX("Pos X", float) = 0.0 | ||
_PosY("Pos Y", float) = 0.0 | ||
} | ||
SubShader | ||
{ | ||
LOD 200 | ||
|
||
Tags | ||
{ | ||
"Queue" = "Transparent" | ||
"IgnoreProjector" = "True" | ||
"RenderType" = "Transparent" | ||
"LightMode"="ForwardBase" | ||
} | ||
|
||
// No culling or depth | ||
Cull Off | ||
Lighting Off | ||
ZWrite Off | ||
Offset -1, -1 | ||
Fog { Mode Off } | ||
ColorMask RGB | ||
Blend SrcAlpha OneMinusSrcAlpha | ||
|
||
Pass | ||
{ | ||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
#pragma target 3.0 | ||
|
||
#include "UnityCG.cginc" | ||
|
||
struct appdata | ||
{ | ||
float4 vertex : POSITION; | ||
half4 color : COLOR; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
struct v2f | ||
{ | ||
float4 vertex : SV_POSITION; | ||
half4 color : COLOR; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
|
||
sampler2D _MainTex; | ||
sampler2D _MaskTex; | ||
float4 _MainTex_ST; | ||
uniform half4 _MainTex_TexelSize; // 主纹理的像素尺寸 | ||
uniform half4 _MaskTex_TexelSize; // 遮挡纹理的像素尺寸 | ||
float _SizeX; | ||
float _SizeY; | ||
float _PosX; | ||
float _PosY; | ||
|
||
v2f vert (appdata v) | ||
{ | ||
v2f o; | ||
o.vertex = UnityObjectToClipPos(v.vertex); | ||
o.uv = v.uv.xy * _MainTex_ST.xy + _MainTex_ST.zw; | ||
o.color = v.color; | ||
return o; | ||
} | ||
|
||
fixed4 frag (v2f i) : SV_Target | ||
{ | ||
// _PosX是MaskTex中心点相对于MainTex中心的像素坐标 | ||
fixed4 srcColor = tex2D(_MainTex, i.uv); | ||
// 计算对应的遮挡纹理坐标 | ||
float2 curPixelPos = i.uv * _MainTex_TexelSize.zw; | ||
float2 relative = _MainTex_TexelSize.zw / 2 - float2(_SizeX, _SizeY) / 2; | ||
float2 maskPixelPos = curPixelPos - (relative + float2(_PosX, _PosY)); | ||
float2 newUV = maskPixelPos * _MaskTex_TexelSize.xy; | ||
// 当遮挡纹理坐标在0~1之间时才会取红色分量作为透明度,否则透明度为0 | ||
float alpha = 0; | ||
if (newUV.x >= 0 && newUV.x <= 1.0 && newUV.y >= 0 && newUV.y <= 1.0) | ||
{ | ||
alpha = tex2D(_MaskTex, newUV).r; | ||
} | ||
return fixed4(srcColor.rgb, alpha * i.color.a * srcColor.a); | ||
} | ||
ENDCG | ||
} | ||
} | ||
Fallback "Diffuse" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.