Textures are Upside Down on OpenGL only
Summary
All textures VLC for Unity outputs are flipped vertically.
Minimal project and steps to reproduce
- Make a new Unity project and import VLCUnity from the Package Manager. (Any unity version should do, but I am using 2020.3.6f1.)
- Open the MinimalPlayback scene.
- Press Play.
- Select the VLC Screen 1 object.
- In the inspector, expand the material.
- Double click on the texture preview. (This shows the texture as it actually is in memory.)
What is the current bug behavior?
The texture is flipped vertically.

The VLCScreen1 object looks okay because it's scale is -1, 1, 1, which flips it back. This is one of several easy workarounds, so this is not a major issue. However, I am pretty sure it is a bug. The video player built in to Unity outputs video the right way up, and other video player assets either output the right way up or provide a simple option to flip if you need to. This makes it harder to migrate an existing project, and plus it's just sort of wrong for no good reason. Many workarounds exist, but they shouldn't be necessary.
What is the expected correct behavior?
The texture should be the right way up. At least there should be an easy way to switch it in code, which as far as I know there isn't. (If there is already a way, at very least the demo should use that rather than a negatively-scaled screen.)
Does it work on other plaforms? Does it work with the official VLC apps?
Right now VLC for Unity only supports one platform, but Unity does sometimes have issues with textures being flipped vertically on WebGL platforms so that's another reason to add a flip option instead of just hardcoding it to always flip.
It works fine on the official VLC apps. (I think this is a difference between DirectX and OpenGL textures maybe?)
Environment
- OS: Windows
- Version 10 LTSC
- Device: PC
- LibVLC version and architecture 4.0.0 x64
- LibVLCSharp version Not quite sure how to check this, sorry.
- VLC Unity plugin version 0.1.3
- Scripting backend used Mono
Possible fixes
I don't know anything about the vlc-unity code yet, but mfkl on discord suggested that this line might be a place to fix a similar problem, and it sure does look like an easy place to do the flip in C++.
https://code.videolan.org/videolan/vlc-unity/-/blob/master/PluginSource/RenderAPI_D3D11.cpp#L497
You could work around it in C# by creating a second texture and blitting the main output texture to it flipped. But that's a lot more expensive than flipping it in C++.
You can work around it in Unity by negatively scaling the screen object (the demo does this), or negatively scaling a the texture input on the material, or by flipping the UVs in a shader (right now this is what I'm doing.) It isn't hard to deal with a flipped texture, but it'd be much nicer if it wasn't flipped when it came out of VLC.
There's a VLC filter that flips videos vertically, and VLC Unity supports it! Works great, very cool. But it doesn't flip subtitles and I don't know of any way to flip subtitles so it doesn't seem like a good fix for this. #108 (closed) This guy tried that trick, and it looks like it has other issues too. But no subtitles would be enough.
