Gamua / Starling-Framework

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

[Feature Suggestion] Vector Graphic Tesselation #1107

Open Fancy2209 opened 5 months ago

Fancy2209 commented 5 months ago

Starling is the main way to use Hardware Acceleration on Flash, but currently, it does not natively support using Vector Art, who is Flash's main art form My suggestion is adding tesselation support (converting it to triangles and feeding to the gpu), who is how all flash emulators (Scaleform, AwayFL, Ruffle) handle it, that way supporting using Vectors in hardware too.

PrimaryFeather commented 5 months ago

Hi there, You're absolutely right, the lack of native vector shapes is the main drawback of Starling, and what you're suggesting would be the way to go to make this possible.

However, to be honest - as you can see from the lack of recent updates - I don't have much time to develop Starling at the moment, so I'm afraid it's unlikely to happen any time soon.

(I've always loved working on Starling, but since the financial support from Adobe and others stopped, I had to move on to other projects and reduced my development efforts for Starling mostly to fixing urgent bugs and keeping it compatible with the latest AIR versions. It's totally possible to add a small feature here or there when requested, but what you're asking would be a major effort.)

Fancy2209 commented 5 months ago

Hi there, You're absolutely right, the lack of native vector shapes is the main drawback of Starling, and what you're suggesting would be the way to go to make this possible.

However, to be honest - as you can see from the lack of recent updates - I don't have much time to develop Starling at the moment, so I'm afraid it's unlikely to happen any time soon.

(I've always loved working on Starling, but since the financial support from Adobe and others stopped, I had to move on to other projects and reduced my development efforts for Starling mostly to fixing urgent bugs and keeping it compatible with the latest AIR versions. It's totally possible to add a small feature here or there when requested, but what you're asking would be a major effort.)

I completely understand, it's still impressive you have maintained Starling support for so long! Away3D basically died the year Adobe cut funds, so it is appreciated you at least made sure to keep Starling working after all this time. It really just striked me off this was missing you know? I am surprised no one suggested this sooner

Fancy2209 commented 1 month ago

https://github.com/Fancy2209/Starling-Dynamite I got a POC working but the starling graphics extension forks out there all have issues displaying flash shapes as they weren't tested to render such things The built in Canvas has no LineTo/MoveTo/CurveTo right? I might try to port NanoVG to AS3 if it doesn't.

PrimaryFeather commented 1 month ago

Mhm, Flash shapes had some very specific properties, right? I was always impressed how drawing in Flash / Adobe Animate felt almost like working with a pixel-based app. I can imagine it's hard to replicate that 100%.

The built in Canvas of Starling doesn't have those methods; the closest that's there is the drawPolygon method, which triangulates a simple list of points, but doesn't support any curves. All rather bare-bones, I'm afraid. 😳

Fancy2209 commented 3 weeks ago

Mhm, Flash shapes had some very specific properties, right? I was always impressed how drawing in Flash / Adobe Animate felt almost like working with a pixel-based app. I can imagine it's hard to replicate that 100%.

The built in Canvas of Starling doesn't have those methods; the closest that's there is the drawPolygon method, which triangulates a simple list of points, but doesn't support any curves. All rather bare-bones, I'm afraid. 😳

I undesrtand, I've decided for a new version of my project that takes these limitations into account, by making a class extending Canvas, that

  1. Takes the Vector. in it's constructor
  2. Uses the Canvas implementatoion for Fills
  3. Basing code out off this function from AwayJS' GraphicsPath Implementation (who is pretty accurate, partly because Away uses it in their Flash Emulator) to make countours out of the GraphicsPath Data
  4. Pass the contours through a Worker running LibTess2 to Tesselate them (AwayJS does this, so I thought I should do it too)
  5. Draw the Path Contour with Canvas as a Polygon made out of the output

Still haven't finished doing this new version but wanted to share my current idea on implementing this. Will share the code when I get this to work.