Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.82k stars 821 forks source link

Any ways to create BevelFilter? #1018

Open CrazyFlasher opened 6 years ago

CrazyFlasher commented 6 years ago

Are there any ready implementations of BevelFilter? Something like in native flash display list? gif 32aaacf545

varadig commented 6 years ago

http://wiki.starling-framework.org/extensions/dynamic_lighting

CrazyFlasher commented 6 years ago

Yes, I know about dynamic lightning. But I have kinematic animation (not sprite sheet) with starling display object tree created with Flump. I cannot create normal maps in my case

CrazyFlasher commented 6 years ago

I really don't want do dig into AGAL to write custom shader, so any help will be appreciated :)

devon-o commented 6 years ago

That makes sense. I'll drop an email later (may be tomorrow) for more details.

oskaraqp commented 6 years ago

Just as a suggestion your kinematic animation works moving images(textures extracted from your spritesheet) around so probably the dynamic_lightning approach would work if you can modify Flump in order to use the normal maps and overlap it with the texture(copying the moving and applying it), also a workaround could be to copy the sprite currently being using into a bitmap and apply the filter, time ago I was trying to get the bevel filter to work on Starling but there were some issues to replicate as it was needed a bitmap anyway in order to duplicate the borders.

CrazyFlasher commented 6 years ago

If I apply filter to each body part used in animation, I'll get bad result: Expected result: ex

Actual result: ac

CrazyFlasher commented 6 years ago

Btw, inner glow can be used instead of bevel in my case. But I think the problem to implement inner glow is the same as bevel?

PrimaryFeather commented 6 years ago

Mhm, with the existing filters, only the Dynamic Lighting extension will give you a bevel-like result. However, it is rendered per mesh, thus the result you're seeing is different than what you'd get with a filter.

It would be possible to create an inner glow filter — with a few adaptations of the Starling code. The DropShadowFilter and the GlowFilter actually work in two steps:

  1. Blur the original object (using a BlurFilter) and tint the result with a single color.
  2. Combine blurred object with original object using a CompositeFilter.

Right now, the CompositeFilter can only draw textures on top of each other. But it was always designed to get a "knockout" mode, where the alpha of one layer is inverted. With that implemented, it should work, in theory.

However, there's still the performance penalty, of course: a blur filter takes several passes, and then it needs to be combined with the original texture. If that makes sense for you depends on the number of objects you need to process like this, and the devices you want to target.

hardcoremore commented 4 years ago

Yes, Bevel filter would be great addition to Starling!