Mateversum is a peer-to-peer WebXR metaverse project.

Overview

Mateversum 🍾

Mateversum (pronounced: MAH-tay-ver-sum) is a peer-to-peer WebXR metaverse project.

The idea is that you'd be able to connect to a network of peers, load into a room, choose an avatar and hang out, all without any central servers. Inside a web browser.

Some of this sort-of works at the moment, but it's got a long way to go.

Real time networking between a browser on a laptop running the WebXR API Emulator extension and a browser on an android phone running in AR mode. I threw this very quickly so the lighting and bottle model could be better.

Running It

Mateversum is really not fit for any kind of public use right now. That said, you can try out an online version at: https://github.com/expenses/webxr-pbr-wasm (I'm going to change the address for that at some point). Simply wait for it to load the initial WASM blob and click 'Start VR' on a desktop (with the WebXR API Emulator extension) or 'Start AR'. The default models/textures are pretty huge (250 mb or so) so I recommend doing this on a decent wifi connection. They'll be cached after the initial load though.

Compiling It

On a Unix/WSL machine run sh run.sh to compile Mateversum and start a local server. You'll need Rust, wasm-bindgen and the Caddy HTTP server (or equivalent) for this.

Compiling the shaders

Because we're especially cool, we use rust-gpu for the GPU shaders. Run sh compile_shaders.sh to compile these, but the script needs some special stuff to be installed for that I can't be bothered documenting it yet.

Compiling the javascript for networking

The javascript code that we use for networking can be built by cding into networking-js, running npm install followed by npm run build.

A Few Implementation Details

We support models in the brilliant glTF format. The core of glTF is a JSON file that references both binary geometry data blobs and texture files as external URLs. These URLs can be delivered either by standard HTTP/HTTPS or (IPFS (currently only through a gateway but we'll hopefully use js.ipfs.io soon.)). We support textures files in the KTX 2 format. This lets us load textures progressively up from 1x1 pixel mipmaps all the way to 4096x4096 and beyond (with adjustable limits so that you can control bandwidth and memory).

Peer-to-peer networking is done via WebRTC. It's extremely bare-bones at the moment, with everyone just connecting to a single room and sending the position of their hand and hands to everyone else. WebRTC requires you to do a handshake where one peer sends a session descriptor offer packet to another peer, who then sends an answer packet back.

The transmission of these packets has to happen over an existing channel, usually using what's known as a signalling server. We're currently using Webtorrent trackers as signalling servers using the trystero library, but using a custom fork that cryptographically signs the packets to prevent a bad server from performing a Man-in-the-middle attack (MITM).

Ideally we'd use libp2p for most if not all networking, but their WebRTC support isn't especially stable yet. See libp2p/specs#220.

Comments
  • Render to a HDR framebuffer and tonemap to the device buffer

    Render to a HDR framebuffer and tonemap to the device buffer

    We want tonemapping to be able to handle HDR. We could do the tonemapping inline at the end of regular shaders, but this would mean that we couldn't do HDR post processing such as bloom, as well as other effects like accurate transmissive rendering.

    This does cause some problems for AR, because by default we're blitting the entire HDR framebuffer to the output framebuffer, which writes over the camera image. I'm not sure if it's possible to copy the camera image to the HDR framebuffer first (need to check) but a better solution is to probably use stencil testing for this so we only blit pixels we've written to.

    opened by expenses 5
  • Image Based Lighting (IBL)

    Image Based Lighting (IBL)

    Currently lighting is just a single fixed directional light and things look pretty ugly. A much better solution would be to load a HDR image (per world) for use as a skybox and IBL.

    Babylon.js uses it's own funky format for IBL environment maps: https://doc.babylonjs.com/divingDeeper/materials/using/HDREnvironment#what-is-a-env-tech-deep-dive. It might be worth thinking about using this, but I don't like that it uses packed .PNGs but then treats them as being HDR even when they're not, really.

    https://github.com/derkreature/IBLBaker is another project to look into. I think it exports DDSes though but I imagine there's some tool to losslessly convert them to KTX 2s.

    opened by expenses 5
  • Framebuffer perf improvements

    Framebuffer perf improvements

    Mateversum currently isnt too performant on mobile GPUs such as the Oculus quest 2 and OnePlus Nord (my phone).

    A decent amount of this can be attributed to the sampling cost of the cubemaps (can be mitigated by reducting them down to 512x512).

    Another source is that we're rendering to a fp16 hdr framebuffer even if we're just immediately tonemapping it. Doing this is useful because it gives us a place to insert effects like bloom, but that's only really viable for discrete GPUs. So we should do the following:

    • On high perf GPUs, keep things as is.
    • on low perf GPUs when doing VR, tonemap in fragment shaders to the multiview framebuffer, then copy that over to the device framebuffer.
    • on low perf GPUs when not doing VR, tonemap in the fragment shader to the device framebuffer

    This also gives us the advantage of having a better AR mode, as we would be able to render ontop of the camera view again!

    opened by expenses 3
  • Basic VR Movement

    Basic VR Movement

    We have basic android chrome AR movement where you hold press in a direction to move in, so we should add something around the same level of effort for VR.

    opened by expenses 2
  • Unlit materials probably shouldn't be tonemapped

    Unlit materials probably shouldn't be tonemapped

    https://gltf-viewer.donmccurdy.com/ displays the Alicia.vrm VRM sample as like this:

    20220627_17h18m08s_grim

    while we currently render Alicia.VRM like this:

    20220627_17h18m02s_grim

    This is because we're doing tonemapping for unlit materials but probably shouldn't be.

    This is very solveable when doing inline tonemapping - just don't tonemap and just do the linear-to-srgb conversion instead! But when we're doing a seperate tonemapping pass it gets harder. How do we tell that a fragment should be tonemapped or not? Perhaps we could write to the alpha channel and tonemap if the alpha is 1.0 and not if it's 0.0.

    opened by expenses 1
  • Implement logging in main() from query param

    Implement logging in main() from query param

    https://github.com/expenses/mateversum/blob/master/src/lib.rs#L51

    Problem: web worker main thread - different global object - not window.foo, but rather worker.foo

    To solve: should just be as easy as passing the query param into console_log::init_with_level ?

    From https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/location

    console.log(location); inside a worker should return an object->href shaped like http://localhost:8000/worker.js, which might not contain the query params passed by the user.

    opened by ianklatzco 1
  • Volumetric Video

    Volumetric Video

    I want to look into implementing the XRFoundation's volumetric video codec for Mateversum: https://github.com/XRFoundation/Universal-Volumetric The have demo files here: https://github.com/XRFoundation/UniversalVolumetric-Demo

    Parsing the json manifest and loading the geometry into buffers seems easy enough. The harder part is handling the video texture. I made some rough changes to wgpu to allow for external textures a while ago, so I'd need to dig those out.

    opened by expenses 0
  • performance checklist

    performance checklist

    Just for when I try things out on a quest 2. All of these things should probably be toggleable though.

    • lower/off anisotropic filtering
    • lower texture sizes.
    • change log level (large potential gains here!)
    • reduce cubemap sizes to 512x512.
    • replace diffuse cubemap with a constant. Ideally use sphere harmonics
    • turn off mirror
    • test doing a depth pre-pass
    opened by expenses 2
  • Anti aliasing

    Anti aliasing

    Related to https://github.com/expenses/mateversum/issues/28.

    I was trying out VR with a headset connected to a poertful gpu and noticed that the flickering from aliasing was quite bad. The regular, hardware based approach to anti aliasing is to use multisampled anti aliasing. Unfortunately we can only multisample (in WebGL) if:

    • we're rendering objects directly to the device framebuffer
    • OR if we're the Oculus webgl multisampling extension: https://developer.oculus.com/documentation/web/web-multiview/#using-multiview-in-webgl-20 (only implemented in the Oculus browser).

    This unfortunately leaves out GPUs that are rendering to a HDR framebuffer for things like bloom. A solution here might be to use a shader-based anti aliasing method like fxaa (or txaa?)

    Additionally it's worth mentioning that resolving a multisampled hdr framebuffer has some requirements to allow for better edges. See https://mynameismjp.wordpress.com/2012/10/24/msaa-overview/. Also discussed for bevy: https://github.com/bevyengine/bevy/pull/3425.

    opened by expenses 1
Owner
Ashley
Graphics programmer and occasional gamedev living in Berlin, DE
Ashley
Simple Peer-to-Peer Exchange

Near Cetificate Devoloper - Demo Simple Peer-to-Peer Exchange On NEAR How it works? See how p2p exchange work here. Exploring The Code The contract co

null 3 Dec 20, 2021
IDP2P is a peer-to-peer identity protocol which enables a controller to create, manage and share its own proofs as well as did documents

IDP2P Experimental, inspired by ipfs, did:peer and keri Background See also (related topics): Decentralized Identifiers (DIDs) Verifiable Credentials

null 5 Oct 31, 2022
Peer-to-peer communications library for Rust based on QUIC protocol

qp2p Crate Documentation MaidSafe website SAFE Dev Forum SAFE Network Forum Overview This library provides an API to simplify common tasks when creati

MaidSafe 337 Dec 14, 2022
Easy-to-use wrapper for WebRTC DataChannels peer-to-peer connections written in Rust and compiling to WASM.

Easy-to-use wrapper for WebRTC DataChannels peer-to-peer connections written in Rust and compiling to WASM.

null 58 Dec 11, 2022
Peer-to-peer overlay routing

Rust_Pinecone This is a port of the peer-to-peer overlay routing mechanism Pinecone and aims to be interoperable with it, although it isn't yet becaus

null 3 Aug 2, 2022
Quick Peer-To-Peer UDP file transfer

qft QFT is a small application for Quick (and really reliable) Peer-To-Peer UDP file transfer. If a friend sent you here... ...look at the "Releases"

Daniel H. 99 Jan 7, 2023
Core library for Lightning Network peer-to-peer nostr platform

Mostro server This document explains how Mostro works. Overview Due to the growing need to be able to operate with Bitcoin without giving up personal

Mostro 16 Jan 4, 2023
BitTorrent peer ID registry/parser/(soon) encoder for Rust

BitTorrent peer ID registry/parser/(soon) encoder By convention, BitTorrent clients identify themselves and their versions in peer IDs they send to tr

TORRENTDYNE 3 Oct 16, 2023
Altruistic Angelshark is a project devoted to making Communication Manager (ACM) automation easier.

This project makes automating over one or more Communication Managers easier via OSSI over SSH.

ADP, LLC. 3 Feb 13, 2022
Simple project to test grpc between ruby (client) and rust (server)

grpc-example Simple project to test grpc between ruby (client) and rust (server). Usage To simplify a lot this project uses docker and docker compose

Bruno Arueira 2 Oct 14, 2021
This Intelligent Transportation Systems (ITS) MQTT client based on the JSon ETSI specification transcription provides a ready to connect project for the mobility

This Intelligent Transportation Systems (ITS) MQTT client based on the JSon ETSI specification transcription provides a ready to connect project for the mobility (connected and autonomous vehicles, road side units, vulnerable road users,...). Let's connect your device or application to our Intelligent Transport Systems (ITS) platform!

Orange 4 Nov 29, 2022
A metrics collection application for Linux machines. Created for MSCS 710 Project at Marist College.

Linux-Metrics-Collector A metrics collection application for Linux machines. Created for MSCS 710 Project at Marist College. Development Environment S

Christopher Ravosa 2 May 2, 2022
Final Project for "Computer Networking Security": A Layer-3 VPN implementation over TLS

Final Project for "Computer Networking Security": A Layer-3 VPN implementation over TLS

Siger Yang 2 Jun 7, 2022
The protocol are designed and made for the future of cross-IP, cross-chain metaverse.

Avatar-protocol 化身协议 This project demonstrates how to use the Solana Javascript API to interact with programs on the Solana blockchain. The project co

Wind-protocol 1 Jan 10, 2022
Using flashbots to mint Otherside metaverse land safely with purchased KYC'd wallets.

Work in progress. Hardcoded to mint 2 lands for 610 APE and approves 100k ape for spending atm, will be updated. Building Install rust, https://rustup

cc 6 May 5, 2022
kytan: High Performance Peer-to-Peer VPN in Rust

kytan: High Performance Peer-to-Peer VPN kytan is a high performance peer to peer VPN written in Rust. The goal is to to minimize the hassle of config

Chang Lan 368 Dec 31, 2022
Painless peer-to-peer WebRTC networking for rust wasm

Matchbox Painless peer-to-peer WebRTC networking for rust wasm applications. The goal of the Matchbox project is to enable udp-like, unordered, unreli

Johan Klokkhammer Helsing 363 Jan 5, 2023
Simple Peer-to-Peer Exchange

Near Cetificate Devoloper - Demo Simple Peer-to-Peer Exchange On NEAR How it works? See how p2p exchange work here. Exploring The Code The contract co

null 3 Dec 20, 2021
Dione is an anonymize and encrypted messaging system build on top on a peer to peer layer.

Secure and Anonymous Messaging WARNING: Currently Dione is not ready to be used nor does it fulfill its goal of being an anonymous messenger. In order

Dione 41 Jan 5, 2023
IDP2P is a peer-to-peer identity protocol which enables a controller to create, manage and share its own proofs as well as did documents

IDP2P Experimental, inspired by ipfs, did:peer and keri Background See also (related topics): Decentralized Identifiers (DIDs) Verifiable Credentials

null 5 Oct 31, 2022