Skip to content

Commit 21ad29a

Browse files
committed
- added shaders for textured custom colored objects
1 parent cf8e987 commit 21ad29a

8 files changed

+182
-2
lines changed

Assets/Resources/Materials.meta

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Resources/Shaders.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Shader "Parkitect/CustomColorsMaskedDiffuse"
2+
{
3+
Properties
4+
{
5+
_MainTex ("Albedo (RGB)", 2D) = "white" {}
6+
_MaskTex ("Mask (RGBA)", 2D) = "white" {}
7+
}
8+
SubShader
9+
{
10+
Tags { "RenderType"="Opaque" }
11+
LOD 200
12+
13+
CGPROGRAM
14+
// Physically based Standard lighting model, and enable shadows on all light types
15+
#pragma surface surf Standard fullforwardshadows
16+
17+
// Use shader model 3.0 target, to get nicer looking lighting
18+
#pragma target 3.0
19+
20+
sampler2D _MainTex;
21+
22+
struct Input
23+
{
24+
float2 uv_MainTex;
25+
};
26+
27+
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
28+
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
29+
// #pragma instancing_options assumeuniformscaling
30+
UNITY_INSTANCING_BUFFER_START(Props)
31+
// put more per-instance properties here
32+
UNITY_INSTANCING_BUFFER_END(Props)
33+
34+
void surf (Input IN, inout SurfaceOutputStandard o)
35+
{
36+
// Albedo comes from a texture tinted by color
37+
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
38+
o.Albedo = c.rgb;
39+
// Metallic and smoothness come from slider variables
40+
o.Metallic = 0;
41+
o.Smoothness = 0.5;
42+
o.Alpha = c.a;
43+
}
44+
ENDCG
45+
}
46+
FallBack "Diffuse"
47+
}

Assets/Resources/Shaders/CustomColorsMaskedDiffuse.shader.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Shader "Parkitect/CustomColorsMaskedDiffuseCutout"
2+
{
3+
Properties
4+
{
5+
_MainTex ("Albedo (RGB)", 2D) = "white" {}
6+
_MaskTex ("Mask (RGBA)", 2D) = "white" {}
7+
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5
8+
}
9+
SubShader
10+
{
11+
Tags{ "RenderType" = "TransparentCutout" "Queue" = "AlphaTest" "ParkitectInstancing" = "On" }
12+
LOD 200
13+
14+
CGPROGRAM
15+
// Physically based Standard lighting model, and enable shadows on all light types
16+
#pragma surface surf Standard keepalpha addshadow
17+
18+
// Use shader model 3.0 target, to get nicer looking lighting
19+
#pragma target 3.0
20+
21+
sampler2D _MainTex;
22+
fixed _Cutoff;
23+
24+
struct Input
25+
{
26+
float2 uv_MainTex;
27+
};
28+
29+
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
30+
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
31+
// #pragma instancing_options assumeuniformscaling
32+
UNITY_INSTANCING_BUFFER_START(Props)
33+
// put more per-instance properties here
34+
UNITY_INSTANCING_BUFFER_END(Props)
35+
36+
void surf (Input IN, inout SurfaceOutputStandard o)
37+
{
38+
// Albedo comes from a texture tinted by color
39+
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
40+
41+
clip(c.a - _Cutoff);
42+
43+
o.Albedo = c.rgb;
44+
// Metallic and smoothness come from slider variables
45+
o.Metallic = 0;
46+
o.Smoothness = 0.5;
47+
o.Alpha = c.a;
48+
}
49+
ENDCG
50+
}
51+
FallBack "Diffuse"
52+
}

Assets/Resources/Shaders/CustomColorsMaskedDiffuseCutout.shader.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Shader "Parkitect/CustomColorsMaskedSpecular"
2+
{
3+
Properties
4+
{
5+
_MainTex ("Albedo (RGB)", 2D) = "white" {}
6+
_MaskTex ("Mask (RGBA)", 2D) = "white" {}
7+
}
8+
SubShader
9+
{
10+
Tags { "RenderType"="Opaque" }
11+
LOD 200
12+
13+
CGPROGRAM
14+
// Physically based Standard lighting model, and enable shadows on all light types
15+
#pragma surface surf Standard fullforwardshadows
16+
17+
// Use shader model 3.0 target, to get nicer looking lighting
18+
#pragma target 3.0
19+
20+
sampler2D _MainTex;
21+
22+
struct Input
23+
{
24+
float2 uv_MainTex;
25+
};
26+
27+
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
28+
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
29+
// #pragma instancing_options assumeuniformscaling
30+
UNITY_INSTANCING_BUFFER_START(Props)
31+
// put more per-instance properties here
32+
UNITY_INSTANCING_BUFFER_END(Props)
33+
34+
void surf (Input IN, inout SurfaceOutputStandard o)
35+
{
36+
// Albedo comes from a texture tinted by color
37+
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
38+
o.Albedo = c.rgb;
39+
// Metallic and smoothness come from slider variables
40+
o.Metallic = 0.45;
41+
o.Smoothness = 0.4;
42+
o.Alpha = c.a;
43+
}
44+
ENDCG
45+
}
46+
FallBack "Diffuse"
47+
}

Assets/Resources/Shaders/CustomColorsMaskedSpecular.shader.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)