def _get_scene(cfg, seed=0, enable_computes=True):
    cfg.duration = 30
    cfg.aspect_ratio = (16, 9)
    rng = cfg.rng
    rng.seed(seed)
    cfg.texture_cache = {}

    t0, t1 = 0, cfg.duration

    # Some discrete abstract background
    bg = ngl.RenderGradient4(
        color_tl=_get_random_animated_color(rng, t0, t1),
        color_tr=_get_random_animated_color(rng, t0, t1),
        color_br=_get_random_animated_color(rng, t0, t1),
        color_bl=_get_random_animated_color(rng, t0, t1),
        filters=[ngl.FilterExposure(-1.5)],
    )

    # Always update all the textures to avoid time jumps
    textures = list(cfg.texture_cache.values())

    # The main overlay
    root = _get_random_layer(cfg, rng, t0, t1, enable_computes)

    group = ngl.Group(children=textures + [root])

    camera = ngl.Camera(group)
    camera.set_eye(0.0, 0.0, 2.0)
    camera.set_center(0.0, 0.0, 0.0)
    camera.set_up(0.0, 1.0, 0.0)
    camera.set_perspective(45.0, cfg.aspect_ratio_float)
    camera.set_clipping(1.0, 10.0)
    return ngl.Group(children=(bg, camera))
Esempio n. 2
0
def filter_composition_colors(cfg):
    return ngl.RenderGradient4(filters=(
        ngl.FilterExposure(exposure=0.9),
        ngl.FilterContrast(contrast=1.5),
        ngl.FilterSaturation(saturation=1.1),
        ngl.FilterOpacity(opacity=0.8),
    ), )
Esempio n. 3
0
def _base_scene(cfg, *filters):
    return ngl.RenderGradient4(
        opacity_tl=0.3,
        opacity_tr=0.4,
        opacity_br=0.5,
        opacity_bl=0.6,
        filters=filters,
    )
Esempio n. 4
0
def filter_gamma_correct(cfg, linear=True):
    """This test operates a gamma correct blending (the blending happens in linear space)"""

    # Hue colors rotated clockwise
    dst = ngl.RenderGradient4(
        color_tl=COLORS.rose,
        color_tr=COLORS.blue,
        color_br=COLORS.sgreen,
        color_bl=COLORS.yellow,
    )

    # Hue colors rotated counter-clockwise started with another color
    src = ngl.RenderGradient4(
        color_tl=COLORS.orange,
        color_tr=COLORS.magenta,
        color_br=COLORS.azure,
        color_bl=COLORS.green,
    )

    # Screen blending so that working in linear space makes a significant
    # difference
    blend = ngl.GraphicConfig(
        ngl.Group(children=(dst, src)),
        blend=True,
        blend_src_factor="one",
        blend_dst_factor="one_minus_src_color",
        blend_src_factor_a="one",
        blend_dst_factor_a="zero",
    )

    # Intermediate RTT so that we can gamma correct the result
    tex = ngl.Texture2D(width=320, height=240)
    rtt = ngl.RenderToTexture(blend, color_textures=[tex])
    render = ngl.RenderTexture(tex)

    if linear:
        # The result of the combination is linear
        dst.add_filters(ngl.FilterSRGB2Linear())
        src.add_filters(ngl.FilterSRGB2Linear())
        # ...and we compress it back to sRGB
        render.add_filters(ngl.FilterLinear2sRGB())

    return ngl.Group(children=(rtt, render))
Esempio n. 5
0
def transform_eye_camera(cfg):
    cfg.duration = 3.0
    cfg.aspect_ratio = (1, 1)

    node = ngl.RenderGradient4(geometry=ngl.Circle(radius=0.7, npoints=128))
    animkf = [
        ngl.AnimKeyFrameVec3(0, (0, -0.5, 0)),
        ngl.AnimKeyFrameVec3(cfg.duration / 2, (0, 1, 0)),
        ngl.AnimKeyFrameVec3(cfg.duration, (0, -0.5, 0)),
    ]
    return ngl.Camera(node, eye=ngl.AnimatedVec3(animkf))