将纹理添加到未点亮的透明颜色着色器
Add Texture to Unlit Transparent Color Shader
如何将 Texture
添加到 Oculus API 提供的以下着色器中以进行淡入淡出:
Shader "Oculus/Unlit Transparent Color" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {} // I added this property to apply Texture. Where can I use it?
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Fog {Mode Off}
Cull Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Color [_Color]
Pass {}
}
}
您可以使用您在 Pass {}
中添加的 属性,其中至少应包含一个顶点着色器和一个片段着色器(或表面着色器)。
在通道中,您定义了一个与 属性 同名的 sampler2D
,因此您可以在着色器函数中使用它。
Unitys 文档中有一些示例着色器:
https://docs.unity3d.com/Manual/ShaderTut2.html
https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html
编辑
还有一个结构类似于您的着色器的示例:
https://docs.unity3d.com/Manual/ShaderTut1.html
根据这个,你可以添加类似
SetTexture [_MainTex] {
// some properties
}
所以以类似的方式设置颜色。
(抱歉,我还没有使用过这样结构的着色器,只有 vertex/fragment 着色器,所以你必须尝试它是否有效 and/or 阅读 unity 提供的示例或等待其他人的回答更多专业知识:) )
作为 xyLe_ suggested in his ,在 Pass{}
块中,我添加了以下代码并且有效:
SetTexture [_MainTex] {
constantColor [_Color]
Combine texture * primary DOUBLE, texture * constant
}
如何将 Texture
添加到 Oculus API 提供的以下着色器中以进行淡入淡出:
Shader "Oculus/Unlit Transparent Color" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {} // I added this property to apply Texture. Where can I use it?
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Fog {Mode Off}
Cull Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Color [_Color]
Pass {}
}
}
您可以使用您在 Pass {}
中添加的 属性,其中至少应包含一个顶点着色器和一个片段着色器(或表面着色器)。
在通道中,您定义了一个与 属性 同名的 sampler2D
,因此您可以在着色器函数中使用它。
Unitys 文档中有一些示例着色器:
https://docs.unity3d.com/Manual/ShaderTut2.html
https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html
编辑
还有一个结构类似于您的着色器的示例:
https://docs.unity3d.com/Manual/ShaderTut1.html
根据这个,你可以添加类似
SetTexture [_MainTex] {
// some properties
}
所以以类似的方式设置颜色。 (抱歉,我还没有使用过这样结构的着色器,只有 vertex/fragment 着色器,所以你必须尝试它是否有效 and/or 阅读 unity 提供的示例或等待其他人的回答更多专业知识:) )
作为 xyLe_ suggested in his Pass{}
块中,我添加了以下代码并且有效:
SetTexture [_MainTex] {
constantColor [_Color]
Combine texture * primary DOUBLE, texture * constant
}