panda3d / panda3d

Powerful, mature open-source cross-platform game engine for Python and C++, developed by Disney and CMU
https://www.panda3d.org/
Other
4.46k stars 781 forks source link

WebM with alpha isnt transparent #229

Closed drewc5131 closed 6 years ago

drewc5131 commented 6 years ago

This webm file does have transparency. But in a panda application, it doesn't

webmtest.zip

rdb commented 6 years ago

This is supported (I've just tested it), but a few conditions need to be met for this to work.

Firstly, in the case of Windows, Panda needs to be compiled with a more up-to-date version of ffmpeg than the one in the 1.9.4 thirdparty libs. I've uploaded a build of ffmpeg 3.2.4 that can be dropped into the thirdparty/win-libs-vc10(-x64) directory here: (64-bit) (32-bit)

Secondly, ffmpeg defaults to its built-in VP8 decoder, which doesn't support alpha. We need to tell ffmpeg to explicitly prefer the libvpx-based decoder, which does support it. Panda can do this automatically if you set this in Config.prc:

ffmpeg-prefer-libvpx true

Thirdly, you need to call setTransparency(1) on your card to enable alpha blending.

rdb commented 6 years ago

Are you still having issues with playing VP8-encoded videos with transparency?

drewc5131 commented 6 years ago

@rdb Not sure, haven't rebuilt it yet, i am starting it now though.

drewc5131 commented 6 years ago

@rdb Still doesnt work. With that file i provided it still doesnt have alpha, and when i try to use this other file https://corporateclash.net/rebrand/resources/animation/logo.webm (downloaded obviously and renamed to toontown-logo.webm), it still crashes the game with :gobj(error): Texture "/e/ttsource/game/resources/phase_3/maps/toontown-logo.webm" exists but cannot be read.

rdb commented 6 years ago

Works fine for me using the code you gave, including the transparency. Can you make sure that you compiled with ffmpeg support, and that you somewhere have "load-video-type webm p3ffmpeg" in Config.prc? (The default prc file should already contain "load-video-type * p3ffmpeg" however, which should be enough.)

Also, check if any other error messages are present. It could be that your build of ffmpeg is not compiled with webm support enabled.

You can check whether your build has ffmpeg support by checking for the existence of libp3ffmpeg.dll.

drewc5131 commented 6 years ago

I rebuilt the engine overnight last night using the ffmpeg download you put. The test webm doesn't have transparency and the other webm i sent from Corporate Clash doesnt load still. 🤔 I wonder if for some reason the ffmpeg-prefer-libvpx true line isnt being recognized, I'll continue trying to get it working

rdb commented 6 years ago

Keep in mind you also need to call setTransparency(True) in order for the transparency to show up.

Are you sure it gets loaded at all, though? The error you indicated suggests it can't load the file at all, not that the transparency doesn't work. That suggests either an earlier error in loading or that ffmpeg isn't available at all. Are there any other error messages? Is libp3ffmpeg.dll present in your build?

drewc5131 commented 6 years ago

I have two files, one loads but doesnt show transparency, the other is from http://corporateclash.net which doesnt load at all saying it exists. It is present in my build, and i do have that

        logoTex = loader.loadTexture("phase_3/maps/test.webm")
        logoTex.play()
        self.logo = OnscreenImage(image = iconTex, scale = (.5, .5, .2))
        self.logo.reparentTo(aspect2d)
        self.logo.setTransparency(1)
        self.logo.setPos(0, 0, .5)
        # Zoom in and out animation for the logo
        self.logoSeq = Sequence(
            self.logo.scaleInterval(1, Point3(.55, .55, .22), blendType="easeInOut"),
            self.logo.scaleInterval(1, Point3(.5, .5, .2), blendType="easeInOut"))

        self.logoSeq.loop()
drewc5131 commented 6 years ago

I must have put the ffmpeg in the wrong libs folder since i have two, i rebuilt the engine and it works now