您的位置:首页 > 移动开发 > Unity3D

unity3D Text 使用shader

2015-12-01 12:38 453 查看
unity里面的3dtext可以很方便得使用,包括了替换材质等等

替换字体简单的就是下面视图步骤,注意使用的Texture是导入字体后的Texture



shader使用以下基本写法,稍稍更改下就行

ShaderLab - 3DText.shader

Shader "GUI/3D Text Shader" {
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}

SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Lighting Off Cull Off ZWrite Off Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Color [_Color]
SetTexture [_MainTex] {
combine primary, texture * primary
}
}
}
}

ShaderLab - 3DTextOneSided.shader

Replacing "Cull Off" to "Cull Back", makes the text one sided.

Shader "GUI/3D Text Shader - Cull Back" {
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}

SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Lighting Off Cull Back ZWrite Off Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Color [_Color]
SetTexture [_MainTex] {
combine primary, texture * primary
}
}
}
}
链接
http://wiki.unity3d.com/index.php?title=3DText
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: