Unity shader examples
Use these with geometry you export from Open Brush and import into Unity. However, you should prefer to use the Open Brush Toolkit, which comes with all the Open Brush shaders.

Opaque shader

1
Shader "Brush/Standard"
2
{
3
Properties
4
{
5
_Color ("Main Color", Color) = (1,1,1,1)
6
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0)
7
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
8
_MainTex ("Base (RGBA)", 2D) = "white" {}
9
_BumpMap ("Normalmap", 2D) = "bump" {}
10
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
11
}
12
SubShader
13
{
14
Tags
15
{
16
"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"
17
}
18
LOD 400
19
CGPROGRAM
20
#pragma target 3.0
21
#pragma surface surf StandardSpecular vertex:vert alphatest:_Cutoff addshadow
22
struct Input
23
{
24
float2 uv_MainTex;
25
float2 uv_BumpMap;
26
float4 color : Color;
27
};
28
29
sampler2D _MainTex;
30
sampler2D _BumpMap;
31
fixed4 _Color;
32
half _Shininess;
33
34
void vert(inout appdata_full i)
35
{
36
}
37
38
void surf(Input IN, inout SurfaceOutputStandardSpecular o)
39
{
40
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
41
o.Albedo = tex.rgb * _Color.rgb * IN.color.rgb;
42
o.Smoothness = _Shininess;
43
o.Specular = _SpecColor;
44
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
45
o.Alpha = tex.a * IN.color.a;
46
}
47
ENDCG
48
}
49
FallBack "Transparent/Cutout/VertexLit"
50
}
Copied!

Additive shader

1
Shader "Brush/Additive"
2
{
3
Properties
4
{
5
_MainTex ("Texture", 2D) = "white" {}
6
}
7
Category
8
{
9
Tags
10
{
11
"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"
12
}
13
Blend SrcAlpha One
14
AlphaTest Greater .01
15
ColorMask RGB
16
Cull Off Lighting Off ZWrite Off Fog
17
{
18
Color (0,0,0,0)
19
}
20
SubShader
21
{
22
Pass
23
{
24
CGPROGRAM
25
#pragma vertex vert
26
#pragma fragment frag
27
#include "UnityCG.cginc"
28
sampler2D _MainTex;
29
30
struct appdata_t
31
{
32
float4 vertex : POSITION;
33
fixed4 color : COLOR;
34
float3 normal : NORMAL;
35
float2 texcoord : TEXCOORD0;
36
};
37
38
struct v2f
39
{
40
float4 vertex : POSITION;
41
fixed4 color : COLOR;
42
float2 texcoord : TEXCOORD0;
43
};
44
45
float4 _MainTex_ST;
46
47
v2f vert(appdata_t v)
48
{
49
v2f o;
50
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
51
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
52
o.color = v.color;
53
return o;
54
}
55
56
fixed4 frag(v2f i) : COLOR
57
{
58
half4 c = tex2D(_MainTex, i.texcoord);
59
return i.color * c;
60
}
61
ENDCG
62
}
63
}
Copied!
Export as PDF
Copy link
Edit on GitHub
Contents