Possible to use image manipulator on render?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Possible to use image manipulator on render?

#1 Post by strayerror »

Hi there,

I have a Composite (Container) which contains 15 or so ConditionSwitches. Ideally I'd like to be able to use the im.MatrixColor manipulator on the resulting texture. I'd hoped that this would be possible using a combination of either Flatten or render and render_to_texture, before feeding the result into the manipulator, but that appears not to be possible. Am I just going about this wrong, or is it simply not possible to achieve this?

Goal:

Code: Select all

+-im.Matrix-----------------+
|                           |
| +-Composite-------------+ |
| |                       | |
| | +-ConditionSwitch---+ | |
| | |      |     |      | | |
| | |      |     |      | | |
| | +------+-----+------+ | |
| |                       | |
| | +-ConditionSwitch---+ | |
| | |    |    |    |    | | |
| | |    |    |    |    | | |
| | +----+----+----+----+ | |
| |                       | |
| +-----------------------+ |
|                           |
+---------------------------+
Thanks for your input!

strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Re: Possible to use image manipulator on render?

#2 Post by strayerror »

So I managed to get something working, but only with the SW renderer, unfortunately. When using GL a TextureGrid is used as part of the render rather than a pygame.Surface and the im functions aren't able to work with it. It's unclear as yet whether it would be possible to load a TextureGrid into a Surface, and even then whether the overhead would prove too much for the approach to be viable.

Here is what I have working on the SW renderer in case it's of use to, or spurs any ideas for others:

Code: Select all

init python hide:
    from renpy.display.layout import Container, render


    class MatrixColorDisplayable(Container):
        def __init__(self, child, matrix, **properties):
            super(MatrixColorDisplayable, self).__init__(**properties)
            self.add(child)
            self.matrix = matrix

        def render(self, w, h, st, at):
            # SW RENDERER ONLY
            what = render(self.child, w, h, st, at)
            dest = renpy.display.swdraw.surface(what.width, what.height, True)

            surf = what.render_to_texture(True)

            renpy.display.module.colormatrix(surf, dest, self.matrix)

            rv = renpy.display.render.Render(what.width, what.height)
            rv.blit(dest, (0, 0))
            rv.depends_on(what, focus=True)

            return rv


    renpy.store.MatrixColorDisplayable = MatrixColorDisplayable


default happy = False
image bright = MatrixColorDisplayable(Composite(
    (config.screen_width, config.screen_height),
    (0,0), 'bg washington',
    (0.5, 0.0), ConditionSwitch(
        'happy', 'eileen vhappy',
        None, 'eileen concerned')),
    renpy.display.im.matrix.colorize('#f00', '#0f0') *
    renpy.display.im.matrix.saturation(0.1))


label main_menu:
    python hide:
        _confirm_quit = False
        # force sw rendering for this example
        if _preferences.renderer != 'sw':
            _preferences.renderer = 'sw'
            renpy.utter_restart()
    return

label start:
    scene bright
    "Please, click to cheer me up ..."
    $ happy = True
    "Yaaaaaay!"
    return

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Possible to use image manipulator on render?

#3 Post by PyTom »

It's not possible to use an image manipulator on anything more complicated than a single image. I'm working on a new architecture for how Ren'Py draws images that will allow arbitrary shaders to be used, but it's taking awhile. It'll likely be in 7.2, but I don't have an ETA for 7.2 yet.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Re: Possible to use image manipulator on render?

#4 Post by strayerror »

That's awesome news! Thanks for your efforts, Tom!

User avatar
Alera
Miko-Class Veteran
Posts: 651
Joined: Sun Mar 21, 2010 3:20 am
Completed: Tortichki // Zayay // Hero's Spirit
Deviantart: psyalera
itch: psyalera
Location: UK
Contact:

Re: Possible to use image manipulator on render?

#5 Post by Alera »

Hello,

Apologies for reviving this old thread but I was wondering if there was a way of doing this that has been implemented yet? It's exactly what I've been trying to achieve and while I have a cheat workaround right now, it's only for one sprite and I'm looking for a proper way to implement it in the future that can be applied to any character.

Thank you~
Image
Games:
❤️ Zayay [Otome?][BxPlayer][NaNo 2013]
❤️ Tortichki [Drag&Drop mini game]

Other games I've worked on:
My Heart's Flame Emissary of Starlight Freedom From Silence Sickness
And many more unannounced/secret projects. (. .)

Post Reply

Who is online

Users browsing this forum: No registered users