love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
4.72k stars 385 forks source link

Integrate Effekseer runtime for .efk effect support #1691

Closed gittup closed 2 years ago

gittup commented 3 years ago

Effekseer (https://effekseer.github.io/en/index.html) is a particle effect creation tool, which can generate some pretty awesome looking effects. Although it's possible to export small effects as sprite images, I think it would be great if Love2d supported the Effekseer runtime. This would let Love2d open and use .efk files directly, which has a few benefits:

1) Overall filesize is much smaller. For example, a small 256x256 effect is 3.5MB as a spritesheet, but only a 2.5k .efk file and ~100k of textures natively. (And the textures can be shared amongst multiple effects!) Larger effects aren't really feasible to export into spritesheets.

2) The effects can have randomness in them to make them more dynamic, so explosions and such look a little different every time.

Other game engines have added support for the runtime, like Unity (https://github.com/effekseer/EffekseerForUnity) and Godot (https://github.com/effekseer/EffekseerForGodot3).

I made an attempt at implementing it in Love2d, and documented some of more results here: https://love2d.org/forums/viewtopic.php?f=4&t=90591&p=240037

While it does appear to work, it could definitely benefit from some help by someone who is more familiar with Love2d's OpenGL internals, so that the runtime could use those to manage the shaders and textures and such. That's probably the bare minimum required before a pull request could be created from it.

Thoughts? Any objections to getting this officially in love?

slime73 commented 3 years ago

If it exported to a well-documented parseable file format which existing engines and runtimes could interpret to suit their needs I think that'd be interesting. But from what I can tell it only supports its own runtime which needs really deep integration into the underlying rendering API? I'm not sure that fits with LÖVE's philosophy in general, and it seems like it'd be quite a burden to maintain.

EDIT:

It seems like the other engines listed don't have built-in support for Effekseer, instead the Effekseer developers built plugins which use those engines.

LÖVE allows you to create meshes with arbitrary vertex formats and use custom vertex and pixel shaders – I think that's probably everything Effekseer needs. There isn't a C API yet (see #1640), but Effekseer could still call LÖVE's Lua APIs. I don't believe modifying LÖVE's source code is necessary.

gittup commented 3 years ago

Thanks for the feedback! So if I understand you correctly, I'd want a separate effekseer.so runtime (written in C/C++) that provides Lua bindings for my game (to call newEffect() or whatever), and internally it creates meshes by calling LÖVE's Lua API? Is there an example of other addons that use a similar approach?

@durswd - I'm not sure if you're familiar with LÖVE at all, but do you have any suggestions from the Effekseer perspective on the best approach?

MikuAuahDark commented 3 years ago

Is there an example of other addons that use a similar approach?

My Live2D Cubism 2 LOVE binding does something like that https://github.com/MikuAuahDark/Live2LOVE. Beware of messy code though, I haven't updated it for a while.

EDIT: There's also love-imgui https://github.com/slages/love-imgui but I'd say that's more complicated.

gittup commented 3 years ago

Is there an example of other addons that use a similar approach?

My Live2D Cubism 2 LOVE binding does something like that https://github.com/MikuAuahDark/Live2LOVE. Beware of messy code though, I haven't updated it for a while.

Thanks! That's definitely helpful. I was imagining it to be way more complicated than that :). I'm trying to port what I already have to a plugin, and then see if I can get it to integrate more directly with LÖVE's rendering.

gittup commented 3 years ago

I was able to get my previous built-in-LÖVE approach to work as a plugin. It still uses Effekseer's separate OpenGL resource management rather than LÖVE's, so that may result in odd graphical glitches if I didn't find them all. I haven't tried to convert it to use the meshes / custom vertex shader approach, but I think that's beyond my expertise at the moment.

The plugin is available here if anyone wants to use it: https://github.com/gittup/EffekseerForLove

I've only tested it on Linux and building as a wasm module for love.js, but I'll add Windows & Mac at some point.

MikuAuahDark commented 3 years ago

If I look correctly, looks like you need to write "LOVE" renderer backend for Effekseer. This is certainly not an easy task because you need to pass lua_State* to the renderer and communicate every graphics operation using Lua C API.

gittup commented 3 years ago

If I look correctly, looks like you need to write "LOVE" renderer backend for Effekseer. This is certainly not an easy task because you need to pass lua_State* to the renderer and communicate every graphics operation using Lua C API.

Yeah, it seems like it would be pretty tricky to me, but I don't have a good handle on Effekseer's internals or how to properly use the mesh API :).

I did update the plugin to support local Mac builds, as well as cross Linux -> Mac and Linux -> Windows. (So Linux can build for itself, love.js, Mac, and Windows if you setup all the cross environments properly). Presumably a local Windows build could be done as well.

slime73 commented 2 years ago

I think the eventual C API (#1640) will cover this.