unity shadergraph 控制 inspector面板显示隐藏
时间: 2023-09-08 08:03:37 浏览: 137
在Unity ShaderGraph中,我们可以使用Properties的InspectorName和HideInInspector属性来控制Inspector面板中的属性显示和隐藏。
首先,在ShaderGraph编辑器中选择想要控制的属性节点。在节点的Inspector面板中,可以看到一个框中有一个标签为"InspectorName"的输入框。我们可以在这里输入自定义的属性名,用作在Inspector面板中显示的名称。
要隐藏属性,可以在Inspector面板展开的节点上添加一个空行,并在此行中输入"[HideInInspector]"(不包括引号)。这样做将会使属性在Inspector面板中隐藏起来,只能在ShaderGraph编辑器中看到。
举例来说,我们有一个属性节点用于调整物体的透明度。我们可以在这个节点的InspectorName框中输入"透明度",这样在Inspector面板中会显示为"透明度"属性。
如果我们想在Inspector面板中隐藏这个属性,我们可以在该节点的Inspector面板的空行处输入"[HideInInspector]"(不包括引号)。这样,在Inspector面板中将不再显示"透明度"属性,但在ShaderGraph编辑器中该属性仍然可见。
通过使用InspectorName和HideInInspector属性,我们可以自由地控制ShaderGraph中节点属性的显示和隐藏,以便更方便地编辑和调整着色器。
相关问题
unity里shader怎么使用
1. 创建一个新的shader
在Unity的Project面板中右键点击Assets文件夹,选择Create > Shader > Standard Surface Shader。这将创建一个新的shader文件,打开它并开始编辑。
2. 编写shader代码
Unity的shader代码采用一种类似于Cg的语言,可以使用一些基本的着色器语法来定义shader的外观和行为。在shader文件中,你可以定义材质的颜色、纹理、反射等属性,并使用GPU的计算能力来计算每个像素的颜色。
3. 应用shader
将shader应用到你的材质上。在Unity中,你可以在Inspector面板中选择材质并将其渲染器组件的Shader属性设置为你创建的shader。
4. 调试shader
当你创建和应用shader时,你可能会遇到一些错误和问题。Unity提供了一些工具来帮助你调试shader代码,例如Shader Inspector、Shader Graph和Shader Forge等插件。
5. 导入外部shader
你可以在Unity Asset Store上找到许多现成的shader,也可以从其他开发者那里获取。要将外部shader导入到Unity中,只需将其文件夹拖放到Project面板中即可。然后,你可以像使用任何其他shader一样使用它们。
unity URP 玻璃shader
以下是使用Unity URP实现玻璃shader的步骤:
1.创建一个新的Shader Graph,将其命名为“Glass”。
2.在Shader Graph中,创建一个新的Unlit Master节点,并将其命名为“Glass”。
3.在Shader Graph中,创建一个新的Input节点,并将其命名为“Glass Texture”。将其类型设置为“Texture 2D”,并将其连接到Unlit Master节点的Base Color输入。
4.在Shader Graph中,创建一个新的Input节点,并将其命名为“Glass Normal Map”。将其类型设置为“Texture 2D”,并将其连接到Unlit Master节点的Normal输入。
5.在Shader Graph中,创建一个新的Input节点,并将其命名为“Glass Tint Color”。将其类型设置为“Color”,并将其连接到Unlit Master节点的Base Color输入。
6.在Shader Graph中,创建一个新的Input节点,并将其命名为“Glass Refraction”. 将其类型设置为“Vector1”,并将其连接到Unlit Master节点的Refraction输入。
7.在Shader Graph中,创建一个新的Sample Texture 2D节点,并将其命名为“Glass Texture Sample”。将其连接到“Glass Texture”输入节点。
8.在Shader Graph中,创建一个新的Sample Texture 2D节点,并将其命名为“Glass Normal Map Sample”。将其连接到“Glass Normal Map”输入节点。
9.在Shader Graph中,创建一个新的Normal Map节点,并将其命名为“Glass Normal Map”. 将其连接到“Glass Normal Map Sample”节点的RGB输出。
10.在Shader Graph中,创建一个新的Multiply节点,并将其命名为“Glass Normal Strength”. 将其连接到“Glass Normal Map”节点的Output输出,并将其另一个输入连接到“Glass Normal Strength”输入节点。
11.在Shader Graph中,创建一个新的Lerp节点,并将其命名为“Glass Refraction Lerp”. 将其一个输入连接到“Glass Refraction”输入节点,将其另一个输入连接到常量值“1.0”,并将其第三个输入连接到常量值“0.1”。
12.在Shader Graph中,创建一个新的Multiply节点,并将其命名为“Glass Refraction Strength”. 将其一个输入连接到“Glass Refraction Lerp”节点的Output输出,并将其另一个输入连接到常量值“0.1”。
13.在Shader Graph中,创建一个新的Add节点,并将其命名为“Glass Refraction Add”. 将其一个输入连接到“Glass Refraction Strength”节点的Output输出,并将其另一个输入连接到常量值“1.0”。
14.在Shader Graph中,创建一个新的Multiply节点,并将其命名为“Glass Refraction Multiply”. 将其一个输入连接到“Glass Refraction Add”节点的Output输出,并将其另一个输入连接到“Glass Texture Sample”节点的Alpha输出。
15.在Shader Graph中,创建一个新的Lerp节点,并将其命名为“Glass Tint Lerp”. 将其一个输入连接到“Glass Tint Color”输入节点,将其另一个输入连接到常量值“1.0”,并将其第三个输入连接到常量值“0.1”。
16.在Shader Graph中,创建一个新的Multiply节点,并将其命名为“Glass Tint Strength”. 将其一个输入连接到“Glass Tint Lerp”节点的Output输出,并将其另一个输入连接到常量值“0.1”。
17.在Shader Graph中,创建一个新的Add节点,并将其命名为“Glass Tint Add”. 将其一个输入连接到“Glass Tint Strength”节点的Output输出,并将其另一个输入连接到常量值“1.0”。
18.在Shader Graph中,创建一个新的Multiply节点,并将其命名为“Glass Tint Multiply”. 将其一个输入连接到“Glass Tint Add”节点的Output输出,并将其另一个输入连接到“Glass Texture Sample”节点的RGB输出。
19.在Shader Graph中,创建一个新的Add节点,并将其命名为“Glass Final Add”. 将其一个输入连接到“Glass Tint Multiply”节点的Output输出,并将其另一个输入连接到“Glass Refraction Multiply”节点的Output输出。
20.在Shader Graph中,将“Glass Final Add”节点连接到Unlit Master节点的Base Color输入。
21.在场景中创建一个Plane对象,并将其缩放为适当的大小。
22.将玻璃纹理拖放到Plane对象上,并将其材质设置为“Glass”。
23.选择Main Camera,在Inspector面板勾选Glass Ctrl组件的Show Glass即可看到效果。