Example #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
Example #2
0
 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
     })
Example #3
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
Example #4
0
 def _effect(*args):
     return stage.ShaderStage("common/passthrough.vert", "post/slices.frag",
                              {
                                  "slices": 3.0,
                                  "offset": 0.03,
                                  "time": time * 0.1,
                                  "speedV": 0.3
                              })
Example #5
0
def effect_scanlines_coarse():
    effect = stage.ShaderStage("common/passthrough.vert", "post/scanlinescoarse.frag")
    seed = np.random.uniform(low=0.0, high=10.0)
    def _effect(*args):
        effect.set_uniforms({
            "uNoiseTexture" : util.load_texture("noise3.png"),
            "time" : time + seed
        })
        return effect
    return _effect
Example #6
0
def effect_scanlines_fine():
    effect = stage.ShaderStage("common/passthrough.vert", "post/scanline.frag")
    def _effect(*args):
        effect.set_uniforms({
            "time" : time,
            "count" : 400.0,
            "noiseAmount" : 0.25,
            "linesAmount" : 0.25
        })
        return effect
    return _effect
Example #7
0
def effect_slices():
    effect = stage.ShaderStage("common/passthrough.vert", "post/slices.frag")
    def _effect(*args):
        effect.set_uniforms({
            "slices" : 3.0,
            "offset" : 0.03,
            "time" : time * 0.1,
            "speedV" : 0.3
        })
        return effect
    return _effect
Example #8
0
def effect_chromatic_aberration():
    effect = stage.ShaderStage("common/passthrough.vert", "post/chromaticaberration.frag")
    def _effect(*args):
        angle = np.random.uniform(math.radians(0.0), np.radians(360.0), size=(4,))
        rotation = np.random.uniform(low=-0.5, high=0.5, size=(4,))
        offset = np.random.uniform(low=0.0, high=25.0, size=(4,))
        def uniforms(program):
            t = float(time)
            stage.apply_uniforms(program, {
                "uDirections" : angle + t * rotation,
                "uDirectionsOffset" : offset
            })
        effect.set_uniforms(uniforms)
        return effect
    return _effect
Example #9
0
            "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([
    current_mask2,
    stage.ShaderStage("common/passthrough.vert", "common/passthrough.frag", transform=[transform.scale(1.2)]),
    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)) + 0.5,
        "uSegmentCount" : 6,
    }),
])

mask_shadow = stage.Pipeline()
Example #10
0
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(
    stage.ShaderStage("common/passthrough.vert", "common/red.frag"))

background = stage.Pipeline()
background.add_stage(current_background)
background.add_stage(
    Selected(keys[ord("B")] | changes["background_effect"],
             min_n=1,
             max_n=2,
             stages=[effect_mirror(), effect_slices()]))

pipeline = stage.Pipeline()
pipeline.add_stage(background)
pipeline.add_stage(foreground)
#pipeline.add_stage(mask)

visualapp.run(window, audio, pipeline)