Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
timchen1002
CustomSRP_03_DirectionalLights
提交
65c5e13d
C
CustomSRP_03_DirectionalLights
项目概览
timchen1002
/
CustomSRP_03_DirectionalLights
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
CustomSRP_03_DirectionalLights
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
65c5e13d
编写于
9月 07, 2021
作者:
timchen1002
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
81f5facc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
73 addition
and
13 deletion
+73
-13
Assets/RawAssets/Lit Opague.mat
Assets/RawAssets/Lit Opague.mat
+3
-3
Assets/RawAssets/Unlit Red Opaque.mat
Assets/RawAssets/Unlit Red Opaque.mat
+4
-4
Assets/Scenes/SampleScene.unity
Assets/Scenes/SampleScene.unity
+1
-1
Assets/Scripts/Editor/CustomShaderGUI.cs
Assets/Scripts/Editor/CustomShaderGUI.cs
+65
-5
未找到文件。
Assets/RawAssets/Lit Opague.mat
浏览文件 @
65c5e13d
...
...
@@ -9,11 +9,11 @@ Material:
m_PrefabAsset
:
{
fileID
:
0
}
m_Name
:
Lit Opague
m_Shader
:
{
fileID
:
4800000
,
guid
:
6848ac66b88696c4ea2f1389e0877b8e
,
type
:
3
}
m_ShaderKeywords
:
_PREMULTIPLY_ALPHA
m_ShaderKeywords
:
m_LightmapFlags
:
4
m_EnableInstancingVariants
:
0
m_DoubleSidedGI
:
0
m_CustomRenderQueue
:
-1
m_CustomRenderQueue
:
2000
stringTagMap
:
{}
disabledShaderPasses
:
[]
m_SavedProperties
:
...
...
@@ -73,7 +73,7 @@ Material:
-
_Mode
:
0
-
_OcclusionStrength
:
1
-
_Parallax
:
0.02
-
_PremulAlpha
:
1
-
_PremulAlpha
:
0
-
_Smoothness
:
0.68
-
_SmoothnessTextureChannel
:
0
-
_SpecularHighlights
:
1
...
...
Assets/RawAssets/Unlit Red Opaque.mat
浏览文件 @
65c5e13d
...
...
@@ -13,7 +13,7 @@ Material:
m_LightmapFlags
:
4
m_EnableInstancingVariants
:
0
m_DoubleSidedGI
:
0
m_CustomRenderQueue
:
-1
m_CustomRenderQueue
:
3000
stringTagMap
:
{}
disabledShaderPasses
:
[]
m_SavedProperties
:
...
...
@@ -28,9 +28,9 @@ Material:
-
_Clipping
:
0
-
_Cull
:
2
-
_Cutoff
:
0.5
-
_DstBlend
:
0
-
_SrcBlend
:
1
-
_ZWrite
:
1
-
_DstBlend
:
1
0
-
_SrcBlend
:
5
-
_ZWrite
:
0
m_Colors
:
-
_BaseColor
:
{
r
:
0.8207547
,
g
:
0.18970275
,
b
:
0.18970275
,
a
:
1
}
-
_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
...
...
Assets/Scenes/SampleScene.unity
浏览文件 @
65c5e13d
...
...
@@ -7171,7 +7171,7 @@ GameObject:
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
m_IsActive
:
0
---
!u!4
&1603649012
Transform
:
m_ObjectHideFlags
:
0
...
...
Assets/Scripts/Editor/CustomShaderGUI.cs
浏览文件 @
65c5e13d
...
...
@@ -7,6 +7,7 @@ public class CustomShaderGUI : ShaderGUI
MaterialEditor
editor
;
Object
[]
materials
;
MaterialProperty
[]
properties
;
bool
showPresents
;
public
override
void
OnGUI
(
MaterialEditor
materialEditor
,
MaterialProperty
[]
properties
)
{
...
...
@@ -14,18 +15,35 @@ public class CustomShaderGUI : ShaderGUI
editor
=
materialEditor
;
materials
=
materialEditor
.
targets
;
this
.
properties
=
properties
;
OpaquePreset
();
EditorGUILayout
.
Space
();
showPresents
=
EditorGUILayout
.
Foldout
(
showPresents
,
"Presents"
,
true
);
if
(
showPresents
)
{
OpaquePreset
();
ClipPreset
();
FadePreset
();
TransparentPreset
();
}
}
void
SetProperty
(
string
name
,
string
keyword
,
bool
value
)
{
SetProperty
(
name
,
value
?
1f
:
0f
);
SetKeyword
(
keyword
,
value
);
if
(
SetProperty
(
name
,
value
?
1f
:
0f
))
{
SetKeyword
(
keyword
,
value
);
}
}
void
SetProperty
(
string
name
,
float
value
)
bool
SetProperty
(
string
name
,
float
value
)
{
FindProperty
(
name
,
properties
).
floatValue
=
value
;
MaterialProperty
property
=
FindProperty
(
name
,
properties
,
false
);
if
(
property
!=
null
)
{
property
.
floatValue
=
value
;
return
true
;
}
return
false
;
}
void
SetKeyword
(
string
keyword
,
bool
enabled
)
...
...
@@ -82,6 +100,9 @@ public class CustomShaderGUI : ShaderGUI
}
}
bool
HasProperty
(
string
name
)
=>
FindProperty
(
name
,
properties
,
false
)
!=
null
;
bool
HasPremultiplyAlpha
=>
HasProperty
(
"_PremulAlpha"
);
bool
PresetButton
(
string
name
)
{
if
(
GUILayout
.
Button
(
name
))
{
...
...
@@ -103,4 +124,43 @@ public class CustomShaderGUI : ShaderGUI
RenderQueue
=
RenderQueue
.
Geometry
;
}
}
void
ClipPreset
()
{
if
(
PresetButton
(
"Clip"
))
{
Clipping
=
true
;
PremultiplyAlpha
=
false
;
SrcBlend
=
BlendMode
.
One
;
DstBlend
=
BlendMode
.
Zero
;
ZWrite
=
true
;
RenderQueue
=
RenderQueue
.
AlphaTest
;
}
}
void
FadePreset
()
{
if
(
PresetButton
(
"Fade"
))
{
Clipping
=
false
;
PremultiplyAlpha
=
false
;
SrcBlend
=
BlendMode
.
SrcAlpha
;
DstBlend
=
BlendMode
.
OneMinusSrcAlpha
;
ZWrite
=
false
;
RenderQueue
=
RenderQueue
.
Transparent
;
}
}
void
TransparentPreset
()
{
if
(
HasPremultiplyAlpha
&&
PresetButton
(
"Transparent"
))
{
Clipping
=
false
;
PremultiplyAlpha
=
true
;
SrcBlend
=
BlendMode
.
One
;
DstBlend
=
BlendMode
.
OneMinusSrcAlpha
;
ZWrite
=
false
;
RenderQueue
=
RenderQueue
.
Transparent
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录