Topic locked

GUITexture Aspect Ratio gets stretched during on-texture video playback

June 19, 2014 - 6:12am #1

We have issues with the GUI Text and GUI Texture that gets displaced and stretched during on-texture video playback.

 

It seems there is a process that tweaks the camera aspect ratio or something. However, with Vuforia 2.8, we do not have access to most script files to try and locate the issue and possibly fix it, as it seems to mainly be in precompiled libraries (DLLs?)

 

This GUI element stretch completely destroys our user interface and any solutions found online or on the Qualcomm support forum talks about altering the Vuforia scripts.

 

Is there anything that can be done to solve the problem?

GUITexture Aspect Ratio gets stretched during on-texture video p

June 23, 2014 - 6:57am #13

You're welcome ;-)

GUITexture Aspect Ratio gets stretched during on-texture video p

June 23, 2014 - 6:32am #12

Thanks a lot Alessandro!

 

It works great for us, using the GL.Viewport addition do VideoPlayerHelper's UpdateVideoData.

 

We were under the impression that it was due to some Viewport being wrongfully left at a wrong size, but couldn't find out where (or should we say when) to resize it.

 

It does fix all of GUI Texture and GUI text issues - no more resize and no more displacement. Thanks a lot.

GUITexture Aspect Ratio gets stretched during on-texture video p

June 20, 2014 - 2:47am #11

Hi, I have identified the issue, which is caused by some code setting the OpenGL viewport to the size of the played Video within the libVuforiaMedia.so library, which is the piece of software that allows playing the Videos on texture using OpenGL native code;

that library is located here:

YOUR_PROJECT\Assets\Plugins\Android\libs\armeabi-v7a\

since that library is not part of the "core" SDK and is only built on purpose for the VideoPlayback sample,  we distribute the source code of it (located in YOUR_PROJECT\Android\VuforiaMediaSource\jni), so you could fix this by recompiling that C++ code using NDK-BUILD and bulding an updated libVuforiaMedia.so to replace the original one.

The proper fix would consist in adding the following lines at the beginning of the _copyTexture() function:

GLint viewport[4]; 
glGetIntegerv(GL_VIEWPORT, viewport); 

and this line at the end of the same function (_copyTexture):

glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); 

 

However, a much simpler (and equally effective) solution is to simply modify the UpdateVideoData() method in VideoPlayerHelper.cs script in your Unity project, by adding a call to GL.Viewport() right after calling videoPlayerUpdateVideoData:

 public MediaState UpdateVideoData()
 {
     MediaState ms = (MediaState) videoPlayerUpdateVideoData();

	// FIX: RESET THE VIEWPORT WITH THIS LINE
	GL.Viewport (new Rect(0,0,Screen.width, Screen.height));

	return ms;
 }

 

Let me know if that solves your issue (it did solve it for me, based on the tests with the sample).

 

 
 

GUITexture Aspect Ratio gets stretched during on-texture video p

June 19, 2014 - 10:33am #10

Alessandro, if this can help: The problem seems to be Android-only, the GUITextures don't seem to stretch on iOS.

GUITexture Aspect Ratio gets stretched during on-texture video p

June 19, 2014 - 9:52am #9

Thanks!

 

It is greatly appreciated.

GUITexture Aspect Ratio gets stretched during on-texture video p

June 19, 2014 - 9:51am #8

OK, let me look into it, and I will get back to you as soon as I have some upates..

GUITexture Aspect Ratio gets stretched during on-texture video p

June 19, 2014 - 9:49am #7

Alessandro,

 

just create a new Unity project, add to it the main vuforia package ( we use vuforia-unity-android-ios-2-8-9) and the video playback package ( we use videoplayback-2-8-13)

Add it a GUI Texture, and it will distord during video playback. At least it does on Android.

 

We got into thinking it is some internal process to the video playback feature that distord the camera view or something to that end.

GUITexture Aspect Ratio gets stretched during on-texture video p

June 19, 2014 - 9:31am #6

Thanks for the video.  I would then need a repro-case to reproduce this;

would it be sufficient to attach a GUITexture on top of the Vuforia VideoPlayback sample scene ?

or are there an special / specific settings I should be aware of in order to reproduce this?

 

GUITexture Aspect Ratio gets stretched during on-texture video p

June 19, 2014 - 9:17am #5

Here is a video I made - the standard Unity splash GUI Texture is centered and sized in the screen, and has no scripts at all. Its scale is at zero. When the video playback, see how it is moved and stretched. There is nothing at all causing this to happen.

As you see, it happens when the video playback starts, and ends when video playback finishes. Again, there is no script at all on the object, its values are unchanged, but displayal is all wrong.

 

AttachmentSize
Package icon fail-.zip1.66 MB

GUITexture Aspect Ratio gets stretched during on-texture video p

June 19, 2014 - 9:13am #4

So, if I understand correctly, this happens only while rendering the video on texture ? but not with other features of Vuforia ?

could you clarify what you mean with:

 will instantly get both stretched and displaced as the video playback texture changes

?

What is the specific type of  "texture change" you mention ? (possibly in reference with some of the sample code that refers to this functionality).

 

 

GUITexture Aspect Ratio gets stretched during on-texture video p

June 19, 2014 - 9:03am #3

Alessandro,

 

When there's a GUITexture being displayed, and there's a VideoPlayback that starts, that GUITexture will instantly get both stretched and displaced as the video playback texture changes. Once the playback stops (pause or ends) then the GUITexture gets back to what it should be. Our whole UI is greatly damaged by this behaviour. This shouldn't be happening.

I do not believe it has anything to do with Unity's scale. Scale is unchanged. We are using pixel inset to resize and reposition our GUI elements within the screen. Our GUITexture's transform's scale are all Vector3.zero.

 

Note: on mobile, it is greatly suggested to NOT use onGUI - so we are not using it and want to stick with GUITextures and GUITexts. Vuforia should not damage displayal of those.

 

AlessandroB wrote:

Hi,

the GUITexture is a legacy feature of Unity, but since Unity 2.0 a better way of handling GUI elements is by overriding OnGUI() method of MonoBehaviou class... (and in Unity 4.6 there will also be a new GUI system).

The stretching issue is also discussed here in the Unity website:

http://answers.unity3d.com/questions/390728/guitextures-appear-stretched.html

in there, they seem to suggest to set the scale to (0,0,0 and use the Pixel Inset approach.

 

 

GUITexture Aspect Ratio gets stretched during on-texture video p

June 19, 2014 - 8:22am #2

Hi,

the GUITexture is a legacy feature of Unity, but since Unity 2.0 a better way of handling GUI elements is by overriding OnGUI() method of MonoBehaviou class... (and in Unity 4.6 there will also be a new GUI system).

The stretching issue is also discussed here in the Unity website:

http://answers.unity3d.com/questions/390728/guitextures-appear-stretched.html

in there, they seem to suggest to set the scale to (0,0,0 and use the Pixel Inset approach.

 

 

Topic locked