rainyt / openfl-spine

Supports Spine renderer versions 3.8 to 4.2 on OpenFL
MIT License
18 stars 6 forks source link

Possibility to specify alpha threshold, for !isNative #14

Closed CrazyFlasher closed 3 years ago

CrazyFlasher commented 5 years ago

It would be cool the have possibility to specify alpha threshold, when image will be invisible. Currently !isNative doesn't support color or alpha transform. So that would be helpful feature.

rainyt commented 5 years ago

This is the same problem as changing the color, and Openfl has a suitable API to implement.

CrazyFlasher commented 5 years ago

It has, or hasn't?

rainyt commented 5 years ago

It seems that it cannot be implemented directly by the drawTriangles method. I have no good ideas.

rainyt commented 5 years ago

If possible, you can try rendering with tilemap, which supports transparency, color changes I am not sure if it works.

CrazyFlasher commented 5 years ago

I've just tested with tilemap. Tilemap skeleton does not support color transform :( Can it be fixed? wild.zip

Also can I combine tilesets to render them on 1 tilemap?

Also there are problems with stripwhitespace is on sesame_shiba.zip

CrazyFlasher commented 5 years ago

May be those issues can be fixed, like you did for sprite skeleton?

rainyt commented 5 years ago

https://github.com/rainyt/openfl-spine/commit/a6dd0e6b11a2fb1a57b1a54fae4c04e4213dbf0c

You can use the texture packer to generate a sprite sheet to render different Spines. Added support for color changes above.

Does the sesame_shiba.zip file occur in a Sprite or a Tilemap?

CrazyFlasher commented 5 years ago

Thanks, I'll check soon. Sesame shibe works with sprite skeleton fine

CrazyFlasher commented 5 years ago

Ok, I've tested. Color transform works now fine, but animations with "strip whitespace on", are broken using tilemap skeleton: image

"Strip whitespace on" works fine with sprite skeletons: image

CrazyFlasher commented 5 years ago

Tilemap skeletons with color transform give a lot of drawcalls anyways. But much less than sprite skeleron with isNative true image Code

        SpineManager.init(stage);

        var m:IntMap<String> = new IntMap<String>();

        var animBasePath:String = "anims/";

        m.set(0, animBasePath + "bonus/bonus");
        m.set(1, animBasePath + "White_shiba/white_shiba");
        m.set(2, animBasePath + "Black_shiba/black_shiba");
        m.set(3, animBasePath + "Red_shiba/red_shiba");
        m.set(4, animBasePath + "Seasame_Shiba/sesame_shiba");
        m.set(5, animBasePath + "A/A");
        m.set(6, animBasePath + "K/K");
        m.set(7, animBasePath + "Q/Q");
        m.set(8, animBasePath + "J/J");
        m.set(9, animBasePath + "10/10");
        m.set(10, animBasePath + "wild/wild");

        var x:Float = 100;
        var y:Float = 200;

        var vo:SpineVo = SpineAssets.get(m.get(4));
        var tm:Tilemap = new Tilemap(1000, 1000, vo.atlas.loader.getTileset());

        for (i in 0...50)
        {
            var s:SkeletonAnimation = vo.atlas.buildTilemapSkeleton(null, vo.jsonData);
            tm.addTile(s);

            s.scaleX = s.scaleY = 0.3;
            s.x = x;
            s.y = y;

            s.play("animation");

            x += 100;

            if (x > 900)
            {
                x = 100;
                y += 100;
            }
        }

        stage.addChild(tm);
    }
rainyt commented 5 years ago

I am busy today, I may have to spend some time on strip whitespace on. The drawcall of a tilemap may be caused by a color change

CrazyFlasher commented 5 years ago

Thank you very much though! I'll ask animators to re-export sources with turned off strip whitespace

CrazyFlasher commented 5 years ago

Also something is wrong with this animation:

Sprite isNative true - OK sprite_isNative

Tilemap - WRONG tilemap

bonus.zip

rainyt commented 5 years ago

这个动画也有问题:

Sprite isNative true-确定 sprite_isNative

拼贴图-错误 瓷砖地图

bonus.zip

https://github.com/rainyt/openfl-spine/commit/13f41e566573bd2562dba2a2e1aada87823ae041 Fix this problem.

CrazyFlasher commented 5 years ago

I ❤️ you 😄 !

CrazyFlasher commented 5 years ago

Hi. Sorry for bothering. Any success with strip whitespace on and tilemaps? :)

rainyt commented 5 years ago

No, I haven't found an effective solution yet.

CrazyFlasher commented 5 years ago

Hi again. Got some issues with animation (tilemaps).

There are several scales: 1, 0.5, 0.25. 0.5 - OK 0.25 - OK 1 - Broken

Animation with scale 1 has 3 pngs. May be it's related to it?

wild.zip

rainyt commented 5 years ago

Only isNative supports multiple image loading, and all images need to be loaded when loading.

CrazyFlasher commented 5 years ago

Ok. I lower export size to fit. Stripwhitespace would help in this case :)

rainyt commented 3 years ago

Now, !isNaitve support:

openfl-spine Update to 1.6.0

haxelib update openfl-spine haxelib install openfl-glsl 1、Deprecated: The isNative rendering support of SpriteSpine is no longer supported, and it is invalid by default; if there is still a need, please refer to multipleTextureRender multi-texture rendering support. 2、Improvement: Added the SpineRenderShader shader, improved the SpriteSpine rendering, and now has added support for transparency, BlendMode.ADD, color modification, etc. (mesh supports at the same time). 3、Dependency: Need to depend on the openfl-glsl library.

@CrazyFlasher

rainyt commented 3 years ago

The current function is already supported.