Orama-Interactive / Pixelorama

Unleash your creativity with Pixelorama, a powerful and accessible open-source pixel art multitool. Whether you want to create sprites, tiles, animations, or just express yourself in the language of pixel art, this software will realize your pixel-perfect dreams with a vast toolbox of features. Available on Windows, Linux, macOS and the Web!
https://orama-interactive.itch.io/pixelorama
MIT License
6.83k stars 372 forks source link

Implement layer effects #940

Closed OverloadedOrama closed 9 months ago

OverloadedOrama commented 9 months ago

Introduces a non-destructive workflow for effects/filters as proposed in #619.

https://github.com/Orama-Interactive/Pixelorama/assets/35376950/4cd36686-6aa8-48fb-a575-dfa64bfbeb61

https://github.com/Orama-Interactive/Pixelorama/assets/35376950/9b4a03be-4ce0-48e1-a8df-a422d5df98f8

All it does is essentially takes a copy of the images of the cels, uses ShaderImageEffect to apply each shader of every effect into the copy, and display that copy to the canvas (if Display Layer Effects is enabled) and to the exported image. The image data of the cels are not affected in any way, thus making it non-destructive.

The biggest issue with this system is performance. Drawing is noticeably laggier when effects are enabled, and this is due to RenderingServer.force_draw() that ShaderImageEffect is using. This method is necessary however, without it the resulting image is blank. A better solution may be this https://github.com/godotengine/godot/pull/75436, or to use something like this https://github.com/godotengine/godot-proposals/issues/7379.

The UI is different than the one proposed in #619, because I used a newer mockup by mrtripie which was posted on our Discord server. Feel free to give feedback!

To avoid code duplication with the destructive image effect UI and to future-proof the system, the parameter UI of the effects is being generated on the fly by reading the shader code and making the appropriate UI elements for each uniform (ValueSliders for ints and floats, CheckBoxes for bools, ColorPickerButtons for vec4s, etc). This system is future-proofed in the sense that we 1) don't have to update the UI every time a shader changes (although we have to do it anyway for the destructive image effects as of right now), and 2) it supports custom shaders loaded by the user, whenever we implement this feature.

Features not yet implemented, not inside this PR's scope:

OverloadedOrama commented 9 months ago

Should be finished for now. I just implemented undo/redo support, as well as a way to permanently apply effects (destructively) to all cels of the layer. The main thing missing is pxo saving, but this can be handled after we deal with #939.