Unity-Technologies / Unity-Technologies/com.unity.webrtc

[REQUEST]: Mipmap support for incoming video streams

Open
#1,032 0 comments 0 reactions 1 assignee View on GitHub

@karasusan is already working on this.

Since May 15, 2024.

enhancement
Dominant language
Assembly
Stars
852
Forks
238
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem?

I'm always frustrated when streaming screen capture video to my Unity WebRTC project the texture looks pixelated if viewed from far:
image

Describe the solution you'd like

It would be great if we could enable mipmaps on the texture returned by VideoStreamTrack.OnVideoReceived:
image

Describe alternatives you've considered

I have tried to make changes to the package but I only managed to get the first mip level populated (I am not very familiar with low level graphics commands, maybe someone more experimented have an idea where I am wrong)

VideoStreamTrack.CreateRenderTexture():

var tex = new RenderTexture(width, height, 0, format);
tex.useMipMap = true;
tex.autoGenerateMips = false;
tex.Create();

VideoStreamTrack.OnVideoFrameResizeInternal():

var format = WebRTC.GetSupportedGraphicsFormat(SystemInfo.graphicsDeviceType);
Texture = new Texture2D(width, height, format, TextureCreationFlags.MipChain);
track.OnVideoFrameResize(Texture);

VideoDecoderMethods.UpdateRendererTexture():

_command.IssuePluginCustomTextureUpdateV2(callback, texture, rendererId);
Graphics.ExecuteCommandBuffer(_command);
_command.GenerateMips(texture);
_command.Clear();
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.