Giter VIP home page Giter VIP logo

vrstreaming's Introduction

Unity VR Render Streaming SDK

Release Discord YouTube Channel Subscribers

This SDK package is built based on Unity Render Streaming and Unity WebRTC. By using this package, you can stream any Unity scene from the the Unity Editor or a Standalone build to a WebXR client on the FusedVR Website : https://fusedvr.com/rendering. To try this this package, it is as simple as dragging the included Render Streaming Services prefab into your Unity scene that you would like to stream and setting up the connect to the WebRTC server.

For an overview of this package, please refer to this video tutorial on the FusedVR Youtube Channel: Streaming Your First WebXR Unity Game to Oculus Quest


How To Setup CloudXR to WebXR

Setup

This project can either be imported via the Unity Package Manager using the Github Repo URL or alternatively via NPM. If importing via NPM, you will need to include the following information to your Scoped Registries, located under Project Settings. The primary advantage of using NPM is that you will be notified of updates via the Unity Package Manager.


Unity Setup

  1. Import this Github Repo as a Unity Package via the Unity Package Manager Add from Git URL : https://github.com/FusedVR/VRStreaming.git
  2. Drag the provided Render Streaming Service prefab into your Unity scene
  3. Verify the WebRTC server address on the Render Streaming Service Gameobject and Component is : wss://webrtc-pcehljv7ea-uw.a.run.app
  4. Start the scene (click Play in Editor or create a standalone Build). NOTE : The Game View must be selected otherwise streaming will not work as documented in issue #12
  5. Open https://fusedvr.com/rendering in a WebRTC compatible browser with a WebXR compatible VR Headset connected (most standard browsers support this). a. Please verify that the URL is being served over an https connection! b. This page will connect to the WebRTC server served at webrtc-pcehljv7ea-uw.a.run.app using the Google STUN Server (stun:stun.l.google.com:19302)
  6. On the Browser, click "Connect to Cloud VR Streaming Server"
  7. Once you see the video feed, click "Enter Virtual Reality"

Unity Versions

Tested & Verfied with Unity 2019.4 LTS. Limited testing has been done with Unity 2020.3 LTS and seems to be working as intended there as well.

Please also refer to Unity Render Streaming for their list of supported Unity versions.

Configurations

On the Render Streaming Service Game Object, there are a few configuration options to make it easier to customize your Render Streaming Game.

  • Game ID (optional) : This field allows you to specify an ID that a user will be required to enter in order to connect with your game. If left blank, any user will be able to connect with the game.
  • Max Connections : This field limits the number of clients that can connect to your game. Defaults to 1 and depending on the GPU you are using and what you are rendering, it is recommended to keep this to be no more than 5. As recommended by Unity in the Render Streaming FAQ, if you are planning to allow more than 5 clients to connect, you may want to consider using an SFU Rebroadcaster. This can be very useful in cases where you would like to build an asymmetrical game or get data from another device (see blockchain support below).
  • Player Prefabs : This field allows you to setup multiple prefabs that will be spawned once a player connects to the server. These prefabs must contain the [ClientStreams.cs])(https://github.com/FusedVR/VRStreaming/blob/master/Runtime/Scripts/ClientStreams.cs) component, which is responsible for defining the video streams that you would like to stream to the browser as well as the associated Data Channel.


VR Broadcast Component

Samples

Provided with the package are several samples to help with quick testing the SDK : HDRP, VRTK Integration , Asymmetrical Multiplayer , Blockchain Testing. These samples can be imported via the Package Manager once you have imported the SDK into your Unity project.

High Definition Render Pipeline

The first one uses the Unity HDRP Built In Template to show case streaming a scene with the High Definition Render Pipeline into WebXR. This is one of the very few ways to play a HDRP game / app within Oculus Quest / WebXR. In order to utilize this sample, import the High Definition RP package from the Unity registry.

Watch how to setup the project on Youtube


HDRP Streaming

VRTK Input Integration

The second provided sample shows integration with VRTK to showcase how to utilize the input that is streamed from the WebXR client into Unity. Using this input, we can build an Archery Sandbox. Simply pick up the bow and then grab arrows from behind your back to begin shooting. Please note that to you use this sample you will need to manually also import the following VRTK Tilia Packages:

  • io.extendreality.tilia.camerarigs.trackedalias.unity
  • io.extendreality.tilia.interactions.interactables.unity
  • io.extendreality.tilia.interactions.snapzone.unity

Watch how to setup the project on Youtube


VRTK Bow & Arrow

Asymmetrical Multiplayer

The third provided sample shows an example of creating a asymmetrical multiplayer experience, where up to 4 users can enter the application either in VR or in 2D as a laptop or mobile user to view an apartment. VR users will be able to teleport around using the enabled VRTK integration. Please note that to you use this sample you will need to manually also import the following VRTK Tilia Packages:

  • io.extendreality.tilia.camerarigs.trackedalias.unity
  • io.extendreality.tilia.locomotors.teleporter.unity
  • io.extendreality.tilia.indicators.objectpointers.unity

Apartment

Blockchain Testing

The forth sample shows an example of interacting with the Blockchain. This sample shows you how to use each feature of the Blockchain interaction highlighted above. Due to documented UI issues with Unity Render Streaming, this sample is a bit unstable to setup. If you are testing within Unity, please make sure the Game View is selected; otherwise input will fail to be recognized by the Editor Canvas. If you are running into trouble, please follow this README guide from Render Streaming in order to setup browser input. There is also a work around script (RemoteInput.cs) that has been implemented to avoid the bug caused in this issue.

Some recommendations

  • In Project Setting->Player->Other Setting, check Allow 'unsafe' code
  • For UnityEditor, Open Window->Analysis->Input Debugger and turn on Lock Input to Game View in Options

Blockchain UI

Authentication

Additionally, to help developers get started with building their own blockchain applications / NFTs, a new sample was recently added in the 0.6.1 update, which highlights how developers can authenticate a smart contract deployed on the Polygon network. More information will eventually be available on the nft.games project, which will be used as a means for storing metadata and easily hosting your own NFT.

Camera Eye Resolution

At this time, the WebXR Client sends the resolution required to render per eye based on the connected VR device to Unity in order to adapt the resolution that is sent. However, IPD data is not sent and is hard-coded to a standard default IPD of 64mm. If you would like to adjust the resolution yourself, you may change the VRInputManager and change the code related to the VRDataType.Display.

Cloud Support

This project has been tested to work on AWS EC2 leveraging Nvidia's Gaming AMIs. See the following videos for documentation on how to setup your Unity VR Streaming project and get it deployed on the Cloud : Windows / Linux


Windows Server with Tesla T4 GPU Accelerated Graphics


Ubuntu 18.04 with Tesla T4 GPU Accelerated Graphics

GPU Recommendations

It is strongly recommended to utlize a NVIDIA GPU as these GPUs support Hardware Accelerated Encoding, which is a requirement for lower latency VR Streaming. You can check the fully compatability matrix on the Unity WebRTC documentation. If you are using a GPU that does not support Hardware Acceleration, you will need to uncheck this option on the Render Streaming Service Game Object and Component

WebXR Input

Controller Input is captured via the A-Frame Tracked-Controls component and then sent over the data channel to the Unity SDK. This data protocol is adapted from the Unity Broadcast system, which was also capable of sending Keyboard, Mouse, Touch, and Gamepad data back to Unity via the RemoteInput.cs script in Unity. As such, VR data is sent from the client to Unity as Data Array buffers, defined in bytes.

The first byte of the data Array Byffer refers to the input mode to determine how to parse the data as an id. The following IDs were reservered for Web Input by the Unity Render Streaming system and integrated with their Remote Input class.

  • ID 0 = Keyboard
  • ID 1 = Mouse
  • ID 2 = MouseWheel
  • ID 3 = Touch
  • ID 4 = UI (legacy)
  • ID 5 = Gamepad (currently not implemented)

ID 6 is used for all WebXR Input specific to VR. Within VR Input, we specify 3 different modes for sending data, which are:

  • ID 0 = Positional and Rotational Data of the Headset and Hands
  • ID 1 = Controller Button Data ( A , B , Trigger, Grip )
  • ID 2 = Controller Axis Data (Joystick & Trackpad)

ID 7 is used for Blockchain Transaction Data (see next section).

The Raw Data from the Client is passed to VRInputManager, who is responsible for transmitting events based on the data mode recieved. Controller Input is then parsed by the ControllerInputManager, which has events that can be subscribed to for VR Input.

Blockchain / Ethereum Web Wallet Integration

In order to support decentralized payments, the SDK now supports the ability to send and recieve information from any client with a web wallet that supports window.ethereum i.e. Metamask or Coinbase Wallet. The implementation for this is located with in the BlockchainData.cs script, which is a static class that allows you to call 3 key functions that will broadcast your message over the Data Channel to all connected clients :

  • GetAccount() : returns the currently active Blockchain account
  • Signature(string message) : returns the signed hash of the input message
  • SendTransaction(string to, string value) : returns the transaction hash for the ethereum transaction that will send value ethereum to the to address from the active web wallet account
  • RegisterContract(string contractAddres , string abi) : registers the smart contract address with an associated abi on the clients. This enables the client to make calls to the Smart Contract instead of the server bundling the request into the data field of the SendTransaction
  • RunTransaction(string contractAddress, string functionName, string[] args) : runs the smart contract transaction on the client. If it is a read-only transaction, the client will return the value from the blockchain i.e. name / symbol. if the function requires writting to the blockchain, then the client will return a transaction hash.

Once any of these methods has been called, the data will be sent over each Client's Data Channel to be processed on the client. If the Client supports the Web Wallet, then the message will be processed and returned back to the server. From Unity, you can listen from the return values on the BlockchainData.CryptoEvent event handler, which will return the event name and the result depending on which method was called. Please refer to the Blockchain Testing sample above for instructions on how to use the functionality.

How To Use Blockchain Support

The most common scenario where this can be integrated is when a VR device like Oculus Quest NOT support Blockchain integration and would like to have a secondary device (i.e. smart phone) to be paired with the headset in order to authorize payments. A user could simply connect both the VR headset and phone to the same server and the headset would be responsible for displaying VR, while the phone / computer would be responsible for authorizing any payments using Metamask.

To implement this, you will need to :

  • Increase the number of clients that can connect to the server from 1 to 2.
  • If desired, create a specific ClientStreamer prefab dedicated for Blockchain support and assign that prefab to the VRBroadcast. If unchanged, the video stream will be passed through, which may or may not be desired.

More Blockchain Requests?

Please file Github feature request issues for additional methods and web wallet support that you would like to see implemented on clients.

vrstreaming's People

Contributors

vmohan7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vrstreaming's Issues

New testnetwork ?

First, really cool work and project. So i know this is depreciated because it was created on ropsten... but if there any documentation for switching to an active testnet like Goerli?

Thanks

Add recommended Unity version to readme

It might work on multiple versions but I always like to know the version that is most likely to just work.

The package.json mentions 2019.4. Is that right? Most people wouldn't think to look there.

[Feature] Asymmetrically Streaming to support Multi-Device per Server

Currently, the SDK disables multiple users from connecting to the server to avoid spying case scenarios. However, there can be useful cases where it would be desirable to have multiple devices connect to the same server. For example, an asymmetrical game or even mobile blockchain authentication (Metamask Mobile for example)

Late Latch Functionality on WebXR Client

To improve experienced latency, we would want to adapt the video streams for the WebXR Client to use some sort of late latch technology like asynchronous timewarp to adjust the frames based on the latest input from the user.

Greg from Nvidia does a good job explaining the value proposition for this in the CloudXR AWE session : https://youtu.be/hYqzFdLleHI?t=1974

[Feature] Bi-Directional Audio (Microphone Support)

Is your feature request related to a problem? Please describe.

For feature parity with Nvidia CloudXR, we will want bi-directional audio support to create multiplayer applications where players can talk with each other.

Describe the solution you'd like

Microphone support from WebXR that sends audio stream to Unity. Unity Render Streaming should have a sample that already supports this.

Missing Camera Module when import to Unity

Describe the bug

After I install I do not see the camera module. I have tried different versions of unity and the git hub project but have had no luck so far.

Desktop (please complete the following information):

  • OS: Window 11

Test Issue

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

[BUG] Camera resets from unity placement view rotation on viewing

I can place the WebVR Camera orientation to line up where I want the viewer to see, but when I load the stream in a browser the camera resets directions to the default 0,0,0 rotation.

Currently I have to orient the entire scene to face the right direction so that when the stream is viewed the 0,0,0 rotation is the right direction.

[Feature] Add a Editor GUI to combine settings into one common place

Various different configurations are scattered onto different components such as Default Bitrate, GameID, Anti-Aliasing settings, etc.

It would be great to combine these into a singular Unity editor window that acts as a one stop shop for configuration. Something similar to the editor window used by the MobiledgeX Unity SDK for example.

image

[Feature] Determine IPD from WebXR APIs to send to Server

Similar to how we are able to calculate the VR Display Size with WebXR and send to the server, we should do the same for IPD as that will allow us that ability to fine tune the visuals from the SDK to match the user preferences.

an Issue from exporting Blockchain Testing into webgl

Hello,

I am using my unity editor version 2020.3.24

I imported latest version 0.6.2 and 0.6.0 into my unity package at a different time to export Blockchain Testing into webgl.

I did "check Allow 'unsafe' code" and "turn on Lock Input to Game View in Options"

errors from 0.6.0
image

errors from 0.6.2
image

Please help me..

[BUG] One eye not streaming in VR headset

When using the OQ2 browser to navigate to the rendered web page and try to run it in VR, my the right eye doesn't load/remains black. I also found that if I disconnect, re-connect in the browser, try to view in VR then it won't load in either eye.

https://discord.com/channels/871764886563196948/872852590336020521/882390145179979820

Initial commentary by Fuseman:
"so i have noticed that sometimes happens from the editor. try closing Unity and then playing. you will likely see a crash. i think there is something broken with the Render Streaming plugin specific to the editor (have not noticed in a standalone build). if you can document that and file an github issue on it, we can also pass it along to the Unity Render Streaming team"

Poor Render Quality in Oculus Quest2

Recently I have been working on Unity render streaming with oculus quest 2, its working and running up but the video render quality is not that good, I have been trying to modify all the versions of the WebRTC package and tried with the hardware encoder (H.264) and software encoder (VP8), software encoder is better but not the best.
Can anyone have more options for the optimization of video rendering,
Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.