Skip to content

Commit e0ff8a2

Browse files
Keijiro TakahashiKeijiro Takahashi
Keijiro Takahashi
authored and
Keijiro Takahashi
committed
Add emission color control.
1 parent a82b05e commit e0ff8a2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Assets/CubeCluster/CubeClusterRenderer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class CubeClusterRenderer : MonoBehaviour
4545
#region Private members
4646

4747
float[] _randomParams = new float[8];
48+
Color _emissionColor;
4849
float _time;
4950

5051
#endregion
@@ -56,6 +57,8 @@ public void ResetParams()
5657
for (var i = 0; i < 8; i++)
5758
_randomParams[i] = Random.value > 0.66f ? 1 : 0;
5859

60+
_emissionColor = Color.HSVToRGB(Random.value, 0.5f, 1);
61+
5962
_time = 0;
6063
}
6164

@@ -86,6 +89,7 @@ void Update()
8689
_material.SetTexture("_MainTex", _metallicMap);
8790
_material.SetTexture("_BumpMap", _normalMap);
8891
_material.SetFloat("_BumpScale", 1);
92+
_material.SetColor("_Emission", _emissionColor);
8993

9094
_material.SetFloat("_Size", 1.0f / _mesh.columnCount);
9195
_material.SetFloat("_TextureScale", _textureScale);

Assets/CubeCluster/Shader/CubeCluster.shader

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
_MainTex("", 2D) = "white" {}
77
_BumpMap("", 2D) = "bump"{}
88
_BumpScale("", Float) = 1
9+
_Emission("", Color) = (1, 1, 1, 1)
910
}
1011
SubShader
1112
{
@@ -22,6 +23,7 @@
2223
sampler2D _MainTex;
2324
sampler2D _BumpMap;
2425
half _BumpScale;
26+
half4 _Emission;
2527

2628
float _Size;
2729
float _TextureScale;
@@ -151,7 +153,7 @@
151153
// apply modification
152154
v.vertex.xyz = rotate_vector(vpos, rot) * scale + offs;
153155
v.normal = rotate_vector(v.normal, rot);
154-
v.color = dft2 * float4(3, 1.2, 1, 0);
156+
v.color = dft2 * _Emission * 3;
155157

156158
// texture coordnate
157159
v.texcoord.xy *= _TextureScale;

0 commit comments

Comments
 (0)