Changing Media Hints at runtime
When trying to change the stereo mode at runtime, nothing happens. This is needed for 3D VR video as otherwise menus and annotations spawned in front of the video are difficult to focus on. This is dealt with in other players by switching to 2D when you opening a menu. Is this possible in the current version?
- Unity version: 2021.3.21
- AVPro Video version (number and edition (trial/core/ultra/enterprise)): Core V2
- Operating system version: Win11
- Device model: PicoG2
- Video specs (resolution, frame-rate, codec, file size): 180 3D video
To Reproduce
- While playing a 180 3d video, set the media hints stereo packing to none
No, its not an option at the moment as we've not had any requests for this previously. Would you not just render the 2D elements into the scene at a comfortable depth, on a separate canvas, instead of right in front of a persons eyes?
Thanks for the reply, we have tried placing our 2D assets at different distances to see if anything is comfortable, but as the 3D effect can differ per video, there doesn't seem to be a way to automate this. I assume this is why most video apps tend to pop to you out of 3d when you bring up a scrub/play/pause menu
Support for changing mono/stereo hints at runtime is a feature that we could potentially add in the future, but its not likely to be added in the near future.
If you wanted to have a go at adding support ahead of us (which could be some time as this has been requested by two people in all the years AVPro Video has existed), then I would suggest looking at where IsStereoEyeLeft() is used in the shader you are using. This respects the following shader enum:
[KeywordEnum(None, Left, Right)] ForceEye ("Force Eye Mode", Float) = 0
I suspect it might be as easy as adjusting when the function call result is used, or interrupting and forcing a true/false (depending on which eye you want for both eyes) value to be used. The function resides in AVProVideo.cginc should you wish to look at what it does.
Do let us know how you get on if you look at a local fix.
Thanks for the help! My shader skills are not great and so I failed to force the eye mode, I tried material.enableKeyword(Keyword_ForceEyeRight); in VideoRenderer.cs, but it didn't seem to work. What has worked for me is duplicating the InsideSphere Unlit Transparent shader, and replacing the line
float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), _MainTex_ST.y < 0.0);
with
float4 scaleOffset = GetStereoScaleOffset(false, _MainTex_ST.y < 0.0);
and then switching between those shaders when needed
I'm not sure why I couldn't force IsStereoEyeLeft() to return false using a keyword, but that's almost certainly my lack of shader knowledge showing.
I also needed to run a ForceUpdate on the media player after the shader switch. Feels a bit hacky but works for my purpose.
I just info that i see this in documentation: https://www.renderheads.com/content/docs/AVProVideo/articles/feature-stereo-video.html#forcing-stereo-eye-mode
And i tested it and it works but not with all materials ;)
If you check AVProVideo\Runtime\Shaders\AVProVideo-VR-InsideSphere.shader you will see line:
[KeywordEnum(None, Left, Right)] ForceEye ("Force Eye Mode", Float) = 0
and after another line:
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
After that you just need to check is your material used for sphere also has same lines. If no just add these two lines and use static function VideoRender.SetupStereoEyeModeMaterial(material, StereoEye.Left); to enable or disable monoscopia.
Hello there,
I'm facing a similar problem now that I've switched to AVpro Ultra.
I used to be able to change the stereo packing via script at runtime with : MediaPlayer.m_StereoPacking = StereoPacking.LeftRight;
But now, this does not work. So instead, I've tried : MediaPlayer.VideoLayoutMapping = VideoMapping.EquiRectangular180; MediaHints hint = MediaPlayer.FallbackMediaHints; hint.stereoPacking = StereoPacking.LeftRight;
Nothing seems to be working and the stereopacking of my media player stays at "None". This is very unfortunate as I need to change it depending on the video I'm loading which can be 360 or 180. What's weird to me is that whenever I change it through the editor (even at runtime) it seems to be working. Is there anything I can do to set it at runtime correctly like before?
Cheers
Hello there,
Your issue is not related to this issue.
How to change stereo packing described here: https://www.renderheads.com/content/docs/AVProVideo/articles/feature-stereo-video.html
Looks like you forgot to change hint in mediaplayer (third line):
MediaHints hint = MediaPlayer.FallbackMediaHints; hint.stereoPacking = StereoPacking.LeftRight; MediaPlayer.FallbackMediaHints = hint;
You don't need to change videomapping if you need just change stereopacking. And after changing it you will have to reload video.
@Anton111111 You are totally right, I totally forgot to reassign the hints back to the mp... It's obviously working now, thank you very much and sorry for the unrelated post.