Skip to content

Commit def812e

Browse files
committed
Improve TDF2018_Particle_HueShift.shader
1 parent e0d14a8 commit def812e

File tree

10 files changed

+346
-154
lines changed

10 files changed

+346
-154
lines changed

Assets/Demoscene/Projects/2018-10-28-TDF2018/ImageEffectMaterials/Glitch.mat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Material:
8585
- _UVSec: 0
8686
- _ZWrite: 1
8787
m_Colors:
88-
- _BlendColor: {r: 1, g: 1, b: 1, a: 0}
88+
- _BlendColor: {r: 0.9920197, g: 0.9920197, b: 0.9920197, a: 0}
8989
- _Color: {r: 1, g: 1, b: 1, a: 1}
9090
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
91-
- _FlashColor: {r: 0, g: 0, b: 0, a: 0}
91+
- _FlashColor: {r: 1, g: 1, b: 1, a: 0}

Assets/Demoscene/Projects/2018-10-28-TDF2018/Shaders/TDF2018_Particle_HueShift.shader

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
Tags { "RenderType" = "Transparent" "Queue"="Transparent" }
1717
Blend SrcAlpha OneMinusSrcAlpha
1818

19+
// Reflection Probeがバグったのでコメントアウト
20+
// Cull Off
21+
1922
Pass
2023
{
2124
CGPROGRAM
@@ -28,11 +31,11 @@
2831
struct appdata
2932
{
3033
float4 vertex : POSITION;
31-
float4 uv : TEXCOORD0;
34+
float4 uv : TEXCOORD0;// z: age_percent, w: random
3235
};
3336
struct v2f
3437
{
35-
float2 uv : TEXCOORD0;
38+
float4 uv : TEXCOORD0;// z: age_percent, w: hue
3639
float4 vertex : SV_POSITION;
3740
float4 color : COLOR;
3841
};
@@ -52,31 +55,63 @@
5255
{
5356
v2f o;
5457
o.vertex = UnityObjectToClipPos(v.vertex);
55-
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
58+
o.uv.xy = TRANSFORM_TEX(v.uv.xy, _MainTex);
59+
o.uv.z = v.uv.z;
5660

5761
float random = v.uv.z + v.uv.w;
58-
float hue = _EmissionHsv.r + _EmissionHueShiftBeat * _Beat + _EmissionHueShiftRandom * random;
62+
float hue = fract(_EmissionHsv.r + _EmissionHueShiftBeat * _Beat + _EmissionHueShiftRandom * random);
5963
o.color.rgb = hsvToRgb(float3(hue, _EmissionHsv.gb)) * _EmissionHsv.a;
6064
o.color.a = 1.0;
6165

66+
o.uv.w = hue;
67+
6268
return o;
6369
}
6470

71+
float dSphere(vec2 p, float r) {
72+
return length(p) - r;
73+
}
74+
6575
float dBox(vec2 p, vec2 b) {
6676
vec2 d = abs(p) - b;
67-
return max(d.x, d.y);
77+
return max(d.x, d.y);// + min(max(d.x, d.y), 0.0);
6878
}
6979

80+
// TODO: gam0022 これだと s = (1,1) とのきに (1.5, 1) となるので治す
7081
float dTriangle(vec2 p, vec2 s) {
7182
return dBox(p, vec2(s.x - p.y * s.x / s.y, s.y));
7283
}
7384

7485
fixed4 frag (v2f i) : SV_Target
7586
{
76-
//float scale = exp(-1.0 * fract(_Beat));
77-
//float d = dTriangle(i.uv.xy - float2(0.5, 0.5), float2(0.24, 0.2) * scale);
78-
//float alpha = saturate(-100.0 * d);
79-
//if (alpha < 0.001) discard;
87+
float hue = i.uv.w;// hue
88+
float d = -1.0;
89+
90+
float step = 0.25;
91+
float2 uv = i.uv.xy;
92+
if (hue > step * 3.0 ) {
93+
// Triangle
94+
float2 size = float2(0.25, 0.43301270189);
95+
float2 center = float2(0.5, 0.3556624327);// y: 1 / 2 - sqrt(3) / 12
96+
d = dTriangle(uv - center, size);
97+
d = max(d, -dTriangle(uv - center, size * 0.3));
98+
} else if (hue > step * 2.0) {
99+
// Box
100+
float2 center = float2(0.5, 0.5);
101+
d = dBox(uv - center, 0.5);
102+
d = max(d, -dBox(uv - center, 0.25));
103+
} else if (hue > step * 1.0) {
104+
float2 center = float2(0.5, 0.5);
105+
d = dSphere(uv - center, 0.5);
106+
d = max(d, -dSphere(uv - center, 0.25));
107+
} else {
108+
float2 center = float2(0.5, 0.5);
109+
d = dBox(uv - center, float2(0.15, 0.5));
110+
d = min(d, dBox(uv - center, float2(0.5, 0.15)));
111+
}
112+
113+
float alpha = saturate(-100.0 * d);
114+
if (alpha < 0.001) discard;
80115

81116
return i.color;
82117
}

Assets/Demoscene/Projects/2018-10-28-TDF2018/Shaders/TDF2018_Particle_TDF2018Logo.shader

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
Tags { "RenderType" = "Transparent" "Queue"="Transparent" }
1212
Blend SrcAlpha OneMinusSrcAlpha
1313

14+
// Reflection Probeがバグったのでコメントアウト
15+
// Cull Off
16+
1417
Pass
1518
{
1619
CGPROGRAM

Assets/Demoscene/Projects/2018-10-28-TDF2018/TDF2018.playable

Lines changed: 14 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,13 @@ AnimationClip:
183183
serializedVersion: 2
184184
m_Curve:
185185
- serializedVersion: 3
186-
time: 0
187-
value: 5
188-
inSlope: 0
189-
outSlope: 0
190-
tangentMode: 136
191-
weightedMode: 0
192-
inWeight: 0.33333334
193-
outWeight: 0.33333334
194-
- serializedVersion: 3
195-
time: 115.11667
186+
time: 121.61667
196187
value: 3
197-
inSlope: 0
198-
outSlope: 0
199-
tangentMode: 136
188+
inSlope: 0.007848616
189+
outSlope: 0.007848616
190+
tangentMode: 0
200191
weightedMode: 0
201-
inWeight: 0.33333334
192+
inWeight: 0.11706664
202193
outWeight: 0.33333334
203194
m_PreInfinity: 2
204195
m_PostInfinity: 2
@@ -263,7 +254,7 @@ AnimationClip:
263254
m_AdditiveReferencePoseClip: {fileID: 0}
264255
m_AdditiveReferencePoseTime: 0
265256
m_StartTime: 0
266-
m_StopTime: 116.083336
257+
m_StopTime: 121.61667
267258
m_OrientationOffsetY: 0
268259
m_Level: 0
269260
m_CycleOffset: 0
@@ -414,22 +405,13 @@ AnimationClip:
414405
serializedVersion: 2
415406
m_Curve:
416407
- serializedVersion: 3
417-
time: 0
418-
value: 5
419-
inSlope: 0
420-
outSlope: 0
421-
tangentMode: 136
422-
weightedMode: 0
423-
inWeight: 0.33333334
424-
outWeight: 0.33333334
425-
- serializedVersion: 3
426-
time: 115.11667
408+
time: 121.61667
427409
value: 3
428-
inSlope: 0
429-
outSlope: 0
430-
tangentMode: 136
410+
inSlope: 0.007848616
411+
outSlope: 0.007848616
412+
tangentMode: 0
431413
weightedMode: 0
432-
inWeight: 0.33333334
414+
inWeight: 0.11706664
433415
outWeight: 0.33333334
434416
m_PreInfinity: 2
435417
m_PostInfinity: 2
@@ -5995,25 +5977,7 @@ MonoBehaviour:
59955977
m_RotationOrder: 4
59965978
m_MixOutCurve:
59975979
serializedVersion: 2
5998-
m_Curve:
5999-
- serializedVersion: 3
6000-
time: 0
6001-
value: 1
6002-
inSlope: 0
6003-
outSlope: 0
6004-
tangentMode: 0
6005-
weightedMode: 0
6006-
inWeight: 0
6007-
outWeight: 0
6008-
- serializedVersion: 3
6009-
time: 1
6010-
value: 0
6011-
inSlope: 0
6012-
outSlope: 0
6013-
tangentMode: 0
6014-
weightedMode: 0
6015-
inWeight: 0
6016-
outWeight: 0
5980+
m_Curve: []
60175981
m_PreInfinity: 2
60185982
m_PostInfinity: 2
60195983
m_RotationOrder: 4
@@ -6601,25 +6565,7 @@ MonoBehaviour:
66016565
m_RotationOrder: 4
66026566
m_MixOutCurve:
66036567
serializedVersion: 2
6604-
m_Curve:
6605-
- serializedVersion: 3
6606-
time: 0
6607-
value: 1
6608-
inSlope: 0
6609-
outSlope: 0
6610-
tangentMode: 0
6611-
weightedMode: 0
6612-
inWeight: 0
6613-
outWeight: 0
6614-
- serializedVersion: 3
6615-
time: 1
6616-
value: 0
6617-
inSlope: 0
6618-
outSlope: 0
6619-
tangentMode: 0
6620-
weightedMode: 0
6621-
inWeight: 0
6622-
outWeight: 0
6568+
m_Curve: []
66236569
m_PreInfinity: 2
66246570
m_PostInfinity: 2
66256571
m_RotationOrder: 4
@@ -6712,25 +6658,7 @@ MonoBehaviour:
67126658
m_BlendOutDuration: -1
67136659
m_MixInCurve:
67146660
serializedVersion: 2
6715-
m_Curve:
6716-
- serializedVersion: 3
6717-
time: 0
6718-
value: 0
6719-
inSlope: 0
6720-
outSlope: 0
6721-
tangentMode: 0
6722-
weightedMode: 0
6723-
inWeight: 0
6724-
outWeight: 0
6725-
- serializedVersion: 3
6726-
time: 1
6727-
value: 1
6728-
inSlope: 0
6729-
outSlope: 0
6730-
tangentMode: 0
6731-
weightedMode: 0
6732-
inWeight: 0
6733-
outWeight: 0
6661+
m_Curve: []
67346662
m_PreInfinity: 2
67356663
m_PostInfinity: 2
67366664
m_RotationOrder: 4

0 commit comments

Comments
 (0)