openfl / starling

Known as the "Cross-Platform Game Engine", Starling is a popular Stage3D framework for OpenFL and Haxe
Other
236 stars 68 forks source link

DisplacementMapFilter Implementation Broken #154

Closed Cleod9 closed 1 year ago

Cleod9 commented 4 years ago

For reference: https://forum.starling-framework.org/d/21156-how-to-create-a-shock-wave-effect-with-displacementmapfilter-like-this

I spent hours trying to figure out why it was impossible to get my displacement filter code to work like the one linked above, even when I was able to confirm I was placing the effect at the correct coordinates. At first I thought it was some issue with too much Sprite nesting, since the result I was seeing was spitting out pixels that were wildly out of place. But I ended up finding out the DisplacementMapFilter code is incorrect.

I was able to confirm this by copying code from the user Giorgi on OpenFL's forums, and it actually started working correctly: https://community.openfl.org/t/shock-wave-effect-with-displacementmapfilter/11686/2

The easiest way to demonstrate the issue is by compiling the Starling sample demo with Giorgi's code instead of the latest code on 2.5.1 and/or master.

Have a look at a comparison: image

If you compare the two images, Starling's code looks rather strange while Giorgi's appears to match the exact behavior on the official Starling website:

https://gamua.com/starling/demo/

I attempted to figure out which line of code exactly is the source of the problem, but unfortunately I wasn't able to figure it out (it's more than just the AGAL code since simply copying that portion from Giorgi's code doesn't work). But overall it appears Giorgi's code is the correct implementation.

Anyway, it seems like a serious issue since the filter is most likely unusable in its current state. Though I imagine it was probably overlooked since these types of effects are a bit complicated for your average every day project.

Is anyone able to speak more to this issue? I could submit a pull request with Giorgi's code if desired but I want to make sure it's safe to do so without breaking existing projects that may rely on the broken code (since i imagine there could be a scenario where the code does in fact work)

jgranick commented 4 years ago

Hi, what version of Lime are you using?

Thank you 😀

Cleod9 commented 4 years ago

I'm using Lime 7.7.0 / OpenFL 8.9.6 and Haxe 4.1.3. I also tested in Lime 7.2.0 / OpenFL 8.7.0 with Haxe 3.4.7 to make sure it wasn't something that used to work within the past few versions.

joshtynjala commented 1 year ago

Closed by #164