Pattern Grow Fade Mask
This commit is contained in:
parent
29a92837a6
commit
175f58fd07
|
@ -662,7 +662,7 @@ Pattern_StemSolid(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r
|
||||||
v2_strip Strip = Assembly.Strips[StripIndex];
|
v2_strip Strip = Assembly.Strips[StripIndex];
|
||||||
for (u32 i = 0; i < Strip.LedCount; i++)
|
for (u32 i = 0; i < Strip.LedCount; i++)
|
||||||
{
|
{
|
||||||
v4 P = Leds->Positions[i];
|
v4 P = Leds->Positions[Strip.LedLUT[i]];
|
||||||
Leds->Colors[i] = WhiteMask;
|
Leds->Colors[i] = WhiteMask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -686,5 +686,40 @@ Pattern_PrimaryHue(led_buffer* Leds, led_buffer_range Range, assembly Assembly,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
Pattern_GrowFadeMask(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData)
|
||||||
|
{
|
||||||
|
blumen_lumen_state* BLState = (blumen_lumen_state*)UserData;
|
||||||
|
Time = Time * BLState->PatternSpeed;
|
||||||
|
|
||||||
|
r32 Period = 10.0f; // seconds
|
||||||
|
r32 ElapsedPct = FractR32(Time / Period);
|
||||||
|
|
||||||
|
r32 ElapsedPctGrow = PowR32(ElapsedPct * 2, 2);
|
||||||
|
r32 ElapsedPctFade = Clamp01((ElapsedPct * 2) - 1);
|
||||||
|
|
||||||
|
r32 Radius = 300 * ElapsedPctGrow;
|
||||||
|
|
||||||
|
v3 Origin = Assembly.Center - v3{0, 150, 0};
|
||||||
|
|
||||||
|
r32 Brightness = Smoothstep(1.0f - ElapsedPctFade);
|
||||||
|
|
||||||
|
pixel COutside = V4ToRGBPixel(BlackV4);
|
||||||
|
pixel CInside = V4ToRGBPixel(WhiteV4 * Brightness);
|
||||||
|
for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++)
|
||||||
|
{
|
||||||
|
v3 P = Leds->Positions[LedIndex].xyz;
|
||||||
|
r32 Dist = V3Mag(P - Origin);
|
||||||
|
if (Dist < Radius)
|
||||||
|
{
|
||||||
|
Leds->Colors[LedIndex] = CInside;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Leds->Colors[LedIndex] = COutside;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define BLUMEN_PATTERNS_H
|
#define BLUMEN_PATTERNS_H
|
||||||
#endif // BLUMEN_PATTERNS_H
|
#endif // BLUMEN_PATTERNS_H
|
|
@ -217,6 +217,8 @@ BlumenLumen_LoadPatterns(app_state* State)
|
||||||
|
|
||||||
Patterns_PushPattern(Patterns, Pattern_StemSolid, PATTERN_MULTITHREADED);
|
Patterns_PushPattern(Patterns, Pattern_StemSolid, PATTERN_MULTITHREADED);
|
||||||
Patterns_PushPattern(Patterns, Pattern_PrimaryHue, PATTERN_MULTITHREADED);
|
Patterns_PushPattern(Patterns, Pattern_PrimaryHue, PATTERN_MULTITHREADED);
|
||||||
|
|
||||||
|
Patterns_PushPattern(Patterns, Pattern_GrowFadeMask, PATTERN_MULTITHREADED);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
|
|
Loading…
Reference in New Issue