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

Transparente Gif not working as expected #2

Closed tinchoforever closed 5 years ago

tinchoforever commented 7 years ago

Hello everyone! I have tried the component using transparent gif and it seems that the material doesn't clean every frame and keeps all the frames while the animation continues. Any Idea why is this? Are there any work arounds or plans to fix it or where we can check to fix it?

Thanks!

his is the GIF http://belisario.herokuapp.com/belisariocorre_v01.gif

tinchoforever commented 7 years ago

`

``` ```

`

mayognaise commented 7 years ago

Hi @tinchoforever, sorry for late replying. I could reproduce the issue. I will debug it when I have time, though it's been hectic these days... :/

aliy321 commented 7 years ago

is there another work around for this?

mayognaise commented 7 years ago

@tinchoforever @aliy321 hi! im so sorry for the late response. so i debugged and i could reproduce the issue. i assume it's how gif has made. it picks color different between previous and current frames and somehow this causes the error. i will debug more if i can make it work, but no guarantee if it is possible. thank you so much for your patient.

keangame commented 7 years ago

I just change aframe-gif-component.js as:

draw: function draw() {

      if (this.clearimg) {
        this.__ctx.clearRect( 0, 0, this.__width, this.__height);
    }else{
          this.__ctx.drawImage(this.__frames[this.__frameIdx], 0, 0, this.__width, this.__height);
          this.__texture.needsUpdate = true;
    }
      if (this.clearimg)
          this.clearimg = false;
     else
          this.clearimg = true;

  },

this may fix your problem.

keangame commented 7 years ago

maybe you can just clearRect before drawImage, for me it 's worked

rttmax commented 7 years ago

__draw: function __draw() { this.__clearCanvas(); this.__ctx.drawImage(this.__frames[this.__frameIdx], 0, 0, this.__width, this.__height); this.__texture.needsUpdate = true; } This is working for me.

mayognaise commented 7 years ago

@keangameThank you and I'm sorry for the late response. @rttmax Thank you so much for the response. It's a shame I didn't clear each frame... 😱 I will update this as soon as I get home.

mayognaise commented 7 years ago

hi @keangame @rttmax, do you mind to share the gif which actually works? I tried using the gif @tinchoforever shared and somehow it still didint work..

image

rttmax commented 7 years ago

i.e. http://i.stack.imgur.com/e8nZC.gif @tinchoforevers gif is working for me: mouse <a-box position="0 0 0" width="1" height="1" depth="0" material="shader:gif;src:url(images/mouse.gif);" transparent="true" gif="" rotation="" scale="" visible="" geometry=""></a-box>

wiseshrimp commented 7 years ago

When I did this fix, this fixed transparent gifs but messed up non-transparent gifs. Did anyone find a fix to make both work?

screen shot 2017-03-06 at 11 10 18 am

Here's an example of what a non-transparent gif looks like. The smaller, black tesseracts are what it's supposed to look like. ^___^

sambshapiro commented 7 years ago

@wiseshrimp is right. Adding this.__clearCanvas(); to the draw function messes up non-transparent gifs.

I also tried this.__ctx.clearRect(0,0,this.__width,this.__height) but it has the same effect.

kencessna commented 7 years ago

Hi, sorry but I don`t get this working at all! I tried your basic script and the screen stays write even though the paths are correct. And when I build a scene with basic geo and map a gif on one of them it the object stays white too. Please help!

Thanks for developing all this! Cheers, Can

tinchoforever commented 7 years ago

Hello everyone with @rttmax fix works ;)

this.__clearCanvas(); this.__ctx.drawImage(this.__frames[this.__frameIdx], 0, 0, this.__width, this.__height); this.__texture.needsUpdate = true;

tinchoforever commented 7 years ago

You can check https://belisario.herokuapp.com/ and https://belisario.herokuapp.com/ar/index.html

tinchoforever commented 7 years ago

And the base is here https://github.com/tinchoforever/belisario.com.ar/blob/master/scripts/aframe-gif-shader.js

sambshapiro commented 7 years ago

@tinchoforever The fix only works if the gif is transparent; currently there is no solution that works for both transparent and non-transparent gifs.

mayognaise commented 7 years ago

Hi @rttmax I'm so sorry I didn't response when you give me the example. I totally missed your comment as I was busy at the moment. Thank you so much for fixing it. That's awesome.

@tinchoforever Thank you for sharing the link. However this link doesn't work for me. https://github.com/tinchoforever/belisario.com.ar/blob/master/scripts/aframe-gif-shader.js I guess maybe the repo is private?

@sambshapiro I'll integrate it and will make it work both transparent and not. Also the code is super old so will optimize it.. no more __ as standard..

@wiseshrimp Hmm I see.. I'm not sure if I can fix the issue..

sambshapiro commented 7 years ago

@mayognaise how will you determine whether or not the gif is transparent?

mayognaise commented 7 years ago

@sambshapiro i was gonna check if the material has transparent: true; 😆

javismiles commented 6 years ago

I have the same issue, the gif is not clearing the previous frames, could you please update us on what's the recommended fix for that?

javismiles commented 6 years ago

for this fix, can you please explain where exactly I have to add that code? thank you very much

__draw: function __draw() { this.__clearCanvas(); this.__ctx.drawImage(this.__frames[this.__frameIdx], 0, 0, this.__width, this.__height); this.__texture.needsUpdate = true; } This is working for me.

javismiles commented 6 years ago

friends, I implemented the fix below and it works, great, BUT fit flickers, obviously the canvas deletion makes it flicker, how can we eliminate the flickering? thank u

this.__ctx.clearRect( 0, 0, this.__width, this.__height); this.__ctx.drawImage(this.__frames[this.__frameIdx], 0, 0, this.__width, this.__height); this.__texture.needsUpdate = true;

Angelo8828 commented 6 years ago

Sorry guys but any updates for this bug? Thanks

tinchoforever commented 6 years ago

Check here https://github.com/tinchoforever/belisario.com.ar/blob/master/scripts/aframe-gif-shader.js

As Javier said, some times there are some flickers... but it works.

Martín Nahuel Rabaglia

Tech & Experiences Director / Co-Founder

[image: Imágenes integradas 4]

genosha.com.ar http://www.genosha.com.ar/

Phone: (+54) 9 11 2386 6243

Skype: martin.rabaglia

C.A.B.A - Argentina

On Wed, Jan 3, 2018 at 5:24 AM, Angelo Salvador notifications@github.com wrote:

Sorry guys but any updates for this bug? Thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mayognaise/aframe-gif-shader/issues/2#issuecomment-354957752, or mute the thread https://github.com/notifications/unsubscribe-auth/AAr6kFx15XsRjmbWNd8KY6FkIS5CFq51ks5tGzlYgaJpZM4Kw2Ok .

vettorazi commented 6 years ago

@javismiles hey, i am wondering the same thing. can you please tell where did you put this snnipet?

pablodiegoss commented 5 years ago

It's been a long time since this issue was opened, but i've fixed this problem on #8, thought would be nice to cite it here o/

i've been using this GIF component on a project, check it out if you like :)

mayoyml commented 5 years ago

@pablodiegoss sorry i havent responsed this for long! thank you so much for the contribution, will fix it this weekend!

mayognaise commented 5 years ago

Hi everyone here, I am so sorry it's been for so long since I commented last time... 🙏 I finally updated the package: https://www.npmjs.com/package/aframe-gif-shader @pablodiegoss I merged your PR, thank you so much 🙏

Lizzy-gg commented 5 years ago

Is the flickering of transparent animated gifs fixed yet? I still have this problem

jrDev1 commented 4 years ago

I am having some really weird issues even with having the transparency set to false. B3463EE4-2A69-41A8-8025-E3BFC3BB8286 1AB31E95-D503-46C9-82EA-A8FE32FB45C3

This is a black image with white background. It works fine on the MacBook but on iPhone it looks like that. Also looks like each gif frame is trimmed to the image then it fills in the background on its own (looking at the black edges of first pic...

jrDev1 commented 4 years ago

Hello,

So I have figured out the issue with the black borders. It was because I was using the scale parameter. So I recommend to NOT use the scale parameter and use width and height parameters instead!

dparker2 commented 2 years ago

DD83D973-8624-40BF-8206-EC558180F32E

Currently getting this behavior using the same banana gif in the example…