iOS Development

c# – Unity WebCamTexture to RenDerTexture Flipped 90 Levels on iOS

Spread the love


I’ve a must stream a person’s digital camera on iPhone/Android utilizing a streaming service (Dolby.IO). As well as, I need o show the person’s video in my app as nicely. Suppose like FaceTime, the place you see your personal video in addition to the particular person you’re speaking to. The streaming service takes in a RenderTexure to stream. My utility is Portrait mode solely. The issue is the video from the cellphone digital camera is rotated 90 levels. I exploit a WebCamTexture to a RenderTexture to show and ship the video. I discovered a method to rotate the quad that shows the video to point out it in Panorama mode on the cellphone, however that also leaves two issues.

  1. The RenderTexture nonetheless sends the video to the stream flipped 90 levels.
  2. As soon as I flip it, it is a panorama video whereas the particular person is holding their cellphone in portrait. I want the video to appear like it will in case you opened your digital camera app and took a video in portrait mode.

Right here is a few of my code:

void Begin()
{
//code right here

    webCamTexture = new WebCamTexture(thedevice.identify, decision.width, decision.peak);
    renderTexture = new RenderTexture(decision.width, decision.peak, 16,  RenderTextureFormat.BGRA32);
    quad.GetComponent<Renderer>().materials.mainTexture = webCamTexture;
    webCamTexture.Play();

//extra code right here
}

void Replace()
{
    Graphics.Blit(webCamTexture, renderTexture);
}

I’ve learn you should use customized shaders to rotate the WebCamTexture, however I’ve not labored with shaders a lot. And each answer I’ve tried has not labored. I do not perceive how this can be a factor. It looks as if Unity needs to be studying the orientation of the gadget and managing the digital camera picture accordingly. Or not less than have a method for us to do merely that doesn’t contain wanting on the Rotation of the digital camera after which adjusting the remodel of an object (which doesn’t remedy the RenderTexture downside).

Any options on easy methods to remedy this.

Here’s a image of what occurs. I’m holding the cellphone in Portrait mode. I want that to be a portrait mode video. As a substitute it’s panorama and squeezed in. The white area would be the incoming video of the opposite particular person.

enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *