Skip to content

Commit

Permalink
upd: dev
Browse files Browse the repository at this point in the history
  • Loading branch information
victorsun committed Sep 10, 2024
1 parent f22765d commit 99e990d
Show file tree
Hide file tree
Showing 303 changed files with 5,527 additions and 8,681 deletions.
1 change: 0 additions & 1 deletion [Graphics]/StudyProject/Assets/Arts/00-Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,3 @@ Shader "Unlit/MyShader"
}
}
```

2 changes: 2 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/01-FrameWork.shader
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Shader "victor/FrameWork"
{
// SV_POSITION 表示顶点在屏幕空间中的位置
float4 pos :SV_POSITION;
// 除了 SV_POSITION 还有 TEXCOORD(高精度float) COLOR(低精度fixed) 等
// v2f 中的语义并不表示类型,只是表示精度区别
};

/*
Expand Down
2 changes: 1 addition & 1 deletion [Graphics]/StudyProject/Assets/Arts/19.mat
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ Material:
m_Ints: []
m_Floats: []
m_Colors:
- _Distort: {r: 0.31, g: 0.36, b: 0.06, a: 0}
- _Distort: {r: 0.8, g: -0.24, b: -0.03, a: 0}
m_BuildTextureStacks: []
9 changes: 9 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/20-UI_Shader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# UI Shader

1. 基础纹理采样

2. 支持组件中的调色功能

3. 遮罩支持

4. 去色功能(扫光等)
7 changes: 7 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/20-UI_Shader.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/21-UIGray.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// UI去色
Shader "Unlit/UIGray"
{
Properties
{
// UI 必须用内置的一些变量,关联贴图,对应 Source Image
// PerRendererData 配合 GetPropertyBlock/SetPropertyBlock 使用,用于统一修改全部用到该Shader的材质,此处设置后在面板中参数置灰,因为已经对应 Source Image
[PerRendererData]_MainTex("MainTex", 2D) = "white"{}
}
SubShader
{
Tags{"Queue" = "Transparent"}
// 固定使用此 Blend
Blend SrcAlpha OneMinusSrcAlpha

Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

struct appdata
{
float4 vertex : POSITION;
float2 uv: TEXCOORD;
};

struct v2f
{
float4 pos: SV_POSITION;
float2 uv: TEXCOORD;
};

sampler2D _MainTex;

v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}

fixed4 frag (v2f i): SV_TARGET
{
fixed4 mainTex = tex2D(_MainTex, i.uv);
return mainTex;
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/21-UIGray.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/21.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%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: 21
m_Shader: {fileID: 4800000, guid: 19d7c7f31213e471dab3caa866029574, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Ints: []
m_Floats: []
m_Colors: []
m_BuildTextureStacks: []
8 changes: 8 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/21.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/22-Stencil.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 模版缓冲区、模版测试
// 模版测试是基于模版缓冲区和自身区域值进行对比,如UI中的遮罩
// 需要在mask节点上添加mask组件,指定为遮罩
// 模版测试公式:
// (Ref & ReadMask) Comp (StencilBufferValue & ReadMask)
// Ref 为Shader中自定义的值,StencilBufferValue 为模版缓冲区中的值

Shader "Unlit/Stencil"
{
Properties
{
[PerRendererData]_MainTex("MainTex", 2D) = "white"{}
// 模版测试参数
_Ref("Stencil Ref", int) = 0
[Enum(UnityEngine.Rendering.CompareFunction)]_StencilComp("Stencil Comp", int) = 0
[Enum(UnityEngine.Rendering.StencilOp)]_StencilOp("Stencil OP", int) = 0
}
SubShader
{
Tags{"Queue" = "Transparent"}
Blend SrcAlpha OneMinusSrcAlpha

// 模版测试
Stencil {
Ref [_Ref] // 0 1
// ReadMask
// WriteMask
Comp [_StencilComp] // Equal
Pass [_StencilOp] // Keep
// Fail
// ZFail
}

Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

struct appdata
{
float4 vertex : POSITION;
float2 uv: TEXCOORD;
};

struct v2f
{
float4 pos: SV_POSITION;
float2 uv: TEXCOORD;
};

sampler2D _MainTex;

v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}

fixed4 frag (v2f i): SV_TARGET
{
fixed4 mainTex = tex2D(_MainTex, i.uv);
return mainTex;
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/22-Stencil.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/22.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
%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: 22
m_Shader: {fileID: 4800000, guid: dd6fe0fd438924b38adf87c7f63005dd, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Ref: 1
- _StencilComp: 3
- _StencilOp: 0
m_Colors: []
m_BuildTextureStacks: []
8 changes: 8 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/22.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/23-ColorMask.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 颜色遮罩,对颜色缓冲区的值过滤

Shader "Unlit/ColorMask"
{
Properties
{
[PerRendererData]_MainTex("MainTex", 2D) = "white"{}
_Ref("Stencil Ref", int) = 0
[Enum(UnityEngine.Rendering.CompareFunction)]_StencilComp("Stencil Comp", int) = 0
[Enum(UnityEngine.Rendering.StencilOp)]_StencilOp("Stencil OP", int) = 0
}
SubShader
{
Tags{"Queue" = "Transparent"}
Blend SrcAlpha OneMinusSrcAlpha

// ColorMask
// ColorMask 0 // 什么都不显示
// ColorMask RGBA // RGBA的任意组合
ColorMask R // RGBA的任意组合

Stencil {
Ref [_Ref]
Comp [_StencilComp]
Pass [_StencilOp]
}

Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

struct appdata
{
float4 vertex : POSITION;
float2 uv: TEXCOORD;
};

struct v2f
{
float4 pos: SV_POSITION;
float2 uv: TEXCOORD;
};

sampler2D _MainTex;

v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}

fixed4 frag (v2f i): SV_TARGET
{
fixed4 mainTex = tex2D(_MainTex, i.uv);
return mainTex;
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/23-ColorMask.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/23.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
%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: 23
m_Shader: {fileID: 4800000, guid: 4e27097398a824e609070fdcc0307df4, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Ref: 0
- _StencilComp: 0
- _StencilOp: 0
m_Colors: []
m_BuildTextureStacks: []
8 changes: 8 additions & 0 deletions [Graphics]/StudyProject/Assets/Arts/23.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 99e990d

Please sign in to comment.