Ejemplo n.º 1
0
def effect_mirror(mode=None):
    move = stage.ShaderStage("common/passthrough.vert", "post/move.frag")
    mirror = stage.ShaderStage("common/passthrough.vert", "post/mirror.frag")
    effect = stage.Pipeline([move, mirror])
    def _effect(*args):
        m = mode
        if m is None:
            m = np.random.randint(low=0, high=4)
        if m == 3:
            # horizontal and vertical mirrored
            angle = math.radians(np.random.randint(low=0, high=7) * 45.0)
            move.set_uniforms({"uDirection" : angle, "uDirectionOffset" : time * 25.0})
        mirror.set_uniforms({"uMode" : m})
        return effect
    return _effect
Ejemplo n.º 2
0
 def _effect(*args):
     mode = np.random.randint(low=0, high=4)
     effect = stage.Pipeline()
     if mode == 3:
         # horizontal and vertical mirrored
         angle = math.radians(np.random.randint(low=0, high=7) * 45.0)
         effect.add_stage(
             stage.ShaderStage("common/passthrough.vert", "post/move.frag",
                               {
                                   "uDirection": angle,
                                   "uDirectionOffset": time * 25.0
                               }))
     effect.add_stage(
         stage.ShaderStage("common/passthrough.vert", "post/mirror.frag",
                           {"uMode": mode}))
     return effect
Ejemplo n.º 3
0
    def evaluate(self):
        if not self._event.value and not self.is_first_evaluation:
            return None
        # this selection includes initial state (self.is_first_evaluation)

        k = np.random.randint(low=self._min_n, high=self._max_n + 1)
        indices = set(random.sample(list(range(0, len(self._stages))), k=k))

        stages = []
        for i in indices:
            actual_stage = self._stages[i]
            if callable(actual_stage):
                actual_stage = actual_stage()
            stages.append(actual_stage)

        return stage.Pipeline(stages)
Ejemplo n.º 4
0
        return effect
    return _effect

def effect_glitch(bw=False):
    def _effect(*args):
        fragment = "post/glitchbw.frag" if bw else "post/glitch.frag"
        return stage.ShaderStage("common/passthrough.vert", fragment, {
            "time" : time,
            "amount" : var.lerp(beat_status, 0.05 * 0.1, 0.05 * 3),
            "speed" : 0.1
        })
    return _effect

bpm = 122.0

mask = stage.Pipeline()
mask.add_stage(current_mask)
mask.add_stage(generative.Selected(keys[ord("M")], min_n=2, max_n=2, stages=[
    #effect_mirror(mode=1),
    
    #effect_glitch(bw=True),

    stage.ShaderStage("common/passthrough.vert", "post/mirror_polar.frag", {
        "uAngleOffset" : var.Const(bpm / 60.0 * 2 * 3.14159265) * time * var.Const(1.0 / (bpm / 8.0)),
        "uSegmentCount" : 6,
    }),

    #stage.ShaderStage("common/passthrough.vert", "common/passthrough.frag", transform=[transform.zrotate(time * _V(2.0))])
]))

mask2 = stage.Pipeline([
Ejemplo n.º 5
0

def effect_glitch(bw=False):
    def _effect(*args):
        fragment = "post/glitchbw.frag" if bw else "post/glitch.frag"
        return stage.ShaderStage(
            "common/passthrough.vert", fragment, {
                "time": time,
                "amount": var.lerp(beat_status.as_var, 0.05 * 0.1, 0.05 * 3),
                "speed": 0.1
            })

    return _effect


mask = stage.Pipeline()
mask.add_stage(current_mask)
mask.add_stage(
    Selected(
        keys[ord("M")],
        min_n=1,
        max_n=1,
        stages=[
            #stage.ShaderStage("common/passthrough.vert", "common/passthrough.frag", transform=[transform.zrotate(var.Time() * 10.0)]),
            effect_glitch(bw=True)
        ]))

foreground = stage.Pipeline()
foreground.add_stage(current_foreground)
foreground.add_stage(stage.MaskStage(mask))
foreground.add_stage(