rainyt / openfl-spine

初次版本
MIT License
17 stars 6 forks source link

Blend Modes #28

Open PadTwo opened 2 years ago

PadTwo commented 2 years ago

Hi @rainyt, I have been using your library extensively lately and i was wondering if it is possible to implement a similar Shader optimization as it is for BlendMode.additive also for the other blend modes ( BlendMode.additive , BlendMode.additive ).

I have tried looking into SpineRenderShader and SkeletonSprite but without much success.

rainyt commented 2 years ago

Hello, BlendMode.additive is BlendMode.Add? At present, it should be supported. Is there any strange problem?

rainyt commented 2 years ago

At present, only add's blendmode is implemented by shaders, while other blendmodes cannot be implemented by shaders for the time being. But there may be unexpected phenomena? If you can provide me with a problem spine to try?

PadTwo commented 2 years ago

It is more of an improvement really, not a real problem. I am currently working on a skeleton with 123 Slots and some of them use BlendMode.Screen which cause a performance drop, the current solution is to use Add instead of Screen.

rainyt commented 2 years ago

Is there a way to get the background color from the shader?

rainyt commented 2 years ago

Use bitmapData to cache the background pixel map in each frame, and then provide it to spine for mixed rendering?

PadTwo commented 2 years ago

Is there a way to get the background color from the shader?

Is Add currently applied only to objects inside SkeletonSprite ? if so maybe the same principle could be applied to other blend modes ( as an option maybe ). In the project i am working on every object with a blend mode applied has its background inside the skeleton.

Maybe i am missing something, my knowledge of shaders is relatively limited.

rainyt commented 2 years ago

Since other blendmodes need background colors for calculation and blendmode, only Blendmode.ADD is not need. Therefore, SkeletonSprite only supports add when it does not digest drawcall; Other blendmode requires 1 drawcall.

rainyt commented 2 years ago

Maybe there is a way to detect whether there are multiple hierarchical blendmodes, and then make it a sprite to mix blendmodes, which should reduce the consumption of drawcall.