mayognaise / aframe-gif-shader

A shader to display GIF for A-Frame VR.
https://mayognaise.github.io/aframe-gif-shader/basic
MIT License
107 stars 44 forks source link

Fix Transparent GIFs #8

Closed pablodiegoss closed 5 years ago

pablodiegoss commented 5 years ago

I've been using your GIF component on a application, after some time studying GIFs and Decoders i found what has been bugging this feature.
http://matthewflickinger.com/lab/whatsinagif/animation_and_transparency.asp
Studying this awesome article i discovered that your GIF decoder wasn't returning the Disposal method for each frame. They indicate if you should clean or not your canvas after drawing a frame, this solves the transparency issue, as some GIFs do not store each frame completely, just the pixels that are different from the last frame, so in this case you should not always clean your canvas, it depends on the disposal method flag that is stored inside each graphic control unit.

margauxdivernois commented 5 years ago

I found this component yesterday and I must thank both mayognaise for the system and you for this awesome PR - which was really useful to me.

However, while it did reduce most of the glitch, I still had one glitch staying. To successfully remove it - it was experimental - I added the else here :

if(this.__frameIdx != 0) {
   if(lastFrame.disposalMethod == 8 || lastFrame.disposalMethod == 9){
      this.__clearCanvas();
   }
}
else {
   this.__clearCanvas();
} 

in __draw() of index.js.

mayognaise commented 5 years ago

@pablodiegoss @margauxdivernois thank you so much for working on this one. 🙏 also im so sorry i didnt get back to you soon.